Created
October 2, 2017 14:43
-
-
Save robincornett/95eda2641fc6572814584ec296ab0097 to your computer and use it in GitHub Desktop.
Add the WooCommerce account menu endpoints to the SuperSide Me menu panel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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