Created
September 1, 2020 01:29
-
-
Save FerFuego/26cd9442ec98329dbcabecc0040b8f25 to your computer and use it in GitHub Desktop.
Add Dropdown into Main Menu Login / Logout
This file contains hidden or 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 | |
/** | |
* Add Dropdown into Main Menu Login / Logout | |
*/ | |
add_filter( 'wp_nav_menu_items', 'fmc_items_login_logout', 10, 2); | |
function fmc_items_login_logout( $items, $args ) { | |
if ($args->theme_location == 'primary') { | |
$items .= '<li class="menu-item menu-item-type-custom menu-item-object-custom current-menu-ancestor current-menu-parent menu-item-has-children menu-item-12012 tc-menu-item tc-menu-depth-0 tc-menu-align-left tc-menu-layout-default"><a href="/alumnos" class="tc-menu-inner">Users</a><span class="icon-toggle"><i class="fa fa-angle-down"></i></span><ul class="sub-menu dropdown-menu-right">'; | |
if ( is_user_logged_in() ) { | |
$items .= '<li class="menu-item btn-menu btn-logout"><a href="'. wp_logout_url(get_permalink()) .'">'. __("Log Out") .'</a></li>'; | |
$items .= '<li class="menu-item btn-menu btn-logout"><a href="'.esc_url( home_url('/user-account')).'">'. __("My Account") .'</a></li>'; | |
} else { | |
$items .= '<li class="menu-item btn-menu btn-login"><a href="'.esc_url( home_url('/user-login')).'">'. __("Log In") .'</a></li>'; | |
$items .= '<li class="menu-item btn-menu btn-login"><a href="'.esc_url( home_url('/user-register')).'">'. __("Sign In") .'</a></li>'; | |
} | |
$items .='</ul></li>'; | |
} | |
return $items; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment