Skip to content

Instantly share code, notes, and snippets.

@AlexL-JWA
Created August 26, 2018 17:16
Show Gist options
  • Save AlexL-JWA/f7328f64a2b01d95de84759557988f48 to your computer and use it in GitHub Desktop.
Save AlexL-JWA/f7328f64a2b01d95de84759557988f48 to your computer and use it in GitHub Desktop.
добавление логин логаут в меню WP
// Filter output menu add sign in / sign out
add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'header_menu') {
$items .= '<li><a href="'. wp_logout_url(home_url()) .'"><i class="icon-user-login-button"></i><span>Выйти</span></a></li>';
}
elseif (!is_user_logged_in() && $args->theme_location == 'header_menu') {
$items .= '<li><a data-fancybox="" data-animation-duration="700" data-src="#register-popup" href="javascript:;"><i class="icon-Registration-01"></i><span>Регистрация</span></a></li>';
$items .= '<li><a data-fancybox="" data-animation-duration="700" data-src="#login-popup" href="javascript:;"><i class="icon-user-login-button"></i><span>Войти</span></a></li>';
}
return $items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment