Skip to content

Instantly share code, notes, and snippets.

@iambigd
Created August 9, 2014 15:51
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 iambigd/57175bd5e99fde54ec4a to your computer and use it in GitHub Desktop.
Save iambigd/57175bd5e99fde54ec4a to your computer and use it in GitHub Desktop.
woocommerce 加入登入登出按鈕
function add_login_logout_link($items, $args)
{
if(is_user_logged_in() && $args->theme_location == 'avia2')
{
$newitems = '<li><a title="'.__('Logout','avia_framework').'" href="'. wp_logout_url(get_permalink()) .'">'.__('Logout','avia_framework').'</a></li>';
$newitems .= $items;
}
else if($args->theme_location == 'avia2')
{
$newitems = '<li><a title="'.__('Login','avia_framework').'" href="'. wp_login_url(get_permalink()) .'">'.__('Login','avia_framework').'</a></li>';
$newitems .= $items;
}else{
$newitems .= $items;
}
return $newitems;
}
add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment