Skip to content

Instantly share code, notes, and snippets.

@digitalchild
Created April 16, 2016 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save digitalchild/5f737f6c9c5e8771f5bce3262fa0a1ac to your computer and use it in GitHub Desktop.
Save digitalchild/5f737f6c9c5e8771f5bce3262fa0a1ac to your computer and use it in GitHub Desktop.
Insert View my store in menu
<?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