Skip to content

Instantly share code, notes, and snippets.

@robincornett
Created October 2, 2017 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robincornett/95eda2641fc6572814584ec296ab0097 to your computer and use it in GitHub Desktop.
Save robincornett/95eda2641fc6572814584ec296ab0097 to your computer and use it in GitHub Desktop.
Add the WooCommerce account menu endpoints to the SuperSide Me menu panel.
<?php
// Do not include the opening tag.
add_filter( 'supersideme_menu_output', 'prefix_add_woo_account_menu_supersideme' );
/**
* Mimic the WooCommerce account menu and add it to the SuperSide Me menu panel.
*
* @param $output_menu
*
* @return array
*/
function prefix_add_woo_account_menu_supersideme( $output_menu ) {
if ( ! function_exists( 'wc_get_account_menu_items' ) || ! is_user_logged_in() ) {
return $output_menu;
}
$wc_menu = '<h3>' . __( 'My Account', 'prefix-text-domain' ) . '</h3>';
foreach ( wc_get_account_menu_items() as $endpoint => $label ) {
$wc_menu .= sprintf( '<li class="%s"><a href="%s">%s</a></li>',
wc_get_account_menu_item_classes( $endpoint ),
esc_url( wc_get_account_endpoint_url( $endpoint ) ),
$label
);
}
$output_menu[] = $wc_menu;
return $output_menu;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment