Last active
June 7, 2020 17:27
-
-
Save tokopress/0b499af632526f2f4aa4d65a66d25a34 to your computer and use it in GitHub Desktop.
Marketica - Modify WooCommerce Quick Nav Menus
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 | |
// To Add in the Functions.php on Child Theme | |
add_action( 'init', 'remove_actions_parent_theme'); | |
function remove_actions_parent_theme() { | |
remove_action( 'tokopress_quicknav_account', 'tokopress_wc_quicknav_account_menus', 50 ); | |
}; | |
add_action( 'tokopress_quicknav_account', 'tokopress_wc_quicknav_account_menus_new', 50 ); | |
function tokopress_wc_quicknav_account_menus_new() { | |
if ( is_user_logged_in() ) { | |
if ( apply_filters( 'tokopress_wc_quicknav_account_submenus', true ) ) { | |
if ( function_exists( 'wc_get_account_menu_items' ) ) { | |
foreach ( wc_get_account_menu_items() as $endpoint => $label ) { | |
if ( 'dashboard' == $endpoint ) { | |
$icon = '<i class="fa fa-dashboard"></i>'; | |
$label = esc_html__( 'My Account', 'tokopress' ); | |
} | |
elseif ( 'orders' == $endpoint ) { | |
$icon = '<i class="fa fa-shopping-basket"></i>'; | |
} | |
elseif ( 'downloads' == $endpoint ) { | |
$icon = '<i class="fa fa-file-archive-o"></i>'; | |
} | |
elseif ( 'edit-address' == $endpoint ) { | |
$icon = '<i class="fa fa-address-book-o"></i>'; | |
} | |
elseif ( 'payment-methods' == $endpoint ) { | |
$icon = '<i class="fa fa-credit-card"></i>'; | |
} | |
elseif ( 'edit-account' == $endpoint ) { | |
$icon = '<i class="fa fa-user"></i>'; | |
} | |
elseif ( 'customer-logout' == $endpoint ) { | |
$icon = '<i class="sli sli-logout"></i>'; | |
} | |
elseif ( 'subscriptions' == $endpoint ) { | |
$icon = '<i class="fa fa-refresh"></i>'; | |
} | |
else { | |
$icon = '<i class="fa fa-cog"></i>'; | |
} | |
printf( '<li><a rel="nofollow" href="%s">%s %s</a></li>', wc_get_account_endpoint_url( $endpoint ), esc_html( $label ), $icon ); | |
} | |
} | |
} | |
else { | |
printf( '<li><a rel="nofollow" href="%s">%s %s</a></li>', get_permalink( wc_get_page_id( 'myaccount' ) ), esc_html__( 'My Account', 'tokopress' ), '<i class="fa fa-cogs"></i>' ); | |
printf( '<li><a rel="nofollow" href="%s">%s %s</a></li>', wp_logout_url( home_url() ), esc_html__( 'Log Out', 'tokopress' ), '<i class="sli sli-logout"></i>' ); | |
} | |
} | |
else { | |
printf( '<li><a rel="nofollow" href="%s">%s %s</a></li>', get_permalink( wc_get_page_id( 'myaccount' ) ), esc_html__( 'Log In', 'tokopress' ), '<i class="sli sli-login"></i>' ); | |
if ( get_option( 'woocommerce_enable_myaccount_registration' ) === 'yes' ) { | |
printf( '<li><a rel="nofollow" href="%s">%s %s</a></li>', get_permalink( wc_get_page_id( 'myaccount' ) ), esc_html__( 'Register', 'tokopress' ), '<i class="fa fa-user-plus"></i>' ); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment