Created
April 16, 2016 00:46
-
-
Save digitalchild/5f737f6c9c5e8771f5bce3262fa0a1ac to your computer and use it in GitHub Desktop.
Insert View my store in menu
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 | |
// Hijack vendor menu to insert view store link. | |
function wcv_store_menu_link( $items, $args ) { | |
if ( WCV_Vendors::is_vendor( get_current_user_id() ) ) { | |
// Only insert the link in the menu you want based on the menu slug you define below. | |
// In this example a menu has been created called 'Vendor Menu' that has the menu slug vendor-menu | |
// This link will be the last link in the vendor menu | |
if( is_user_logged_in() && ( $args->menu->slug == 'vendor-menu' ) ) { | |
$vendor_shop_link = WCVendors_Pro_Vendor_Controller::get_vendor_store_url( get_current_user_id() ); | |
$menu_item = '<li><a title="'.__( 'View My Store', 'wcvenodrs-pro' ) .'" href="'.$vendor_shop_link .'">'.__( 'View My Store', 'wcvenodrs-pro' ) .'</a></li>'; | |
$newitems = $items . $menu_item; | |
return $newitems; | |
} | |
} | |
return $items; | |
} | |
add_filter( 'wp_nav_menu_items', 'wcv_store_menu_link', 10, 2); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment