Wordpress drop-down menu

Add dropdown with User login, logout into menu.
This code used to replace "nav.php" in theme "QuickStrap" in XLfxs.com
It will add a menu to your navigation menu
Needs to have the theme "QuickStrap" installed (or any bootstrap -based theme) and Font-Awsome v4.7 (latest we have now)
That theme came in with nav.php in the theme folder, I modified it using Appearance --> Editor
https://wordpress.org/themes/quickstrap/

CodeFunctionName
What is this?

Public

Tested

Original Work
<nav class="navbar navbar-static-top navbar-inverse " role="navigation" >
<div class="container" >
<div class="navbar-header" >
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar" >
<span class="sr-only" >Toggle navigation </span >
<span class="icon-bar" > </span >
<span class="icon-bar" > </span >
<span class="icon-bar" > </span >
</button >
<a class="navbar-brand" href=" <?php echo home_url(); ? >" > <em style="font-family:'Angsana New';font-weight: normal;font-style: italic; bold; font-size: 44px;margin: 0;padding: 10px 0 0 15px;" > <?php bloginfo('name'); ? > </em > </a >
</div >

<div id="navbar" class="navbar-collapse collapse" >
<!-- Header Menu -- >
<?php wp_nav_menu( array(
'theme_location' = > 'header-nav',
'menu_class' = > 'nav navbar-nav',
'container' = > false,
'depth' = > 3,
'fallback_cb' = > 'wp_page_menu',
//Process nav menu using our custom nav walker
'walker' = > new wp_bootstrap_navwalker()
) ); ? >



<ul class="nav navbar-nav" >
<li class="menu-item dropdown" >
<a title="User" href="#" data-toggle="dropdown" class="dropdown-toggle" aria-haspopup="true" > <span class="fa fa-user" > </span > User <span class="fa fa-caret-down" > </span > </a >
<ul role="menu" class=" dropdown-menu" >
<?php if (is_user_logged_in()) : ? >
<li class="menu-item" > <a title="Profile" href="/wp-admin/profile.php" > <span class="fa fa-address-card-o" > </span > Profile </a > </li >
<li class="menu-item" > <a title="Dashboard" target="_blank" href="/wp-admin/" > <span class="fa fa-tachometer" > </span > Dashboard </a > </li >
<li role="separator" class="divider" > </li >
<li > <a href=" <?php echo wp_logout_url(get_permalink()); ? >" > <i class="fa fa-sign-out" > </i > Logout </a > </li >
<?php else : ? >
<li > <a href=" <?php echo wp_login_url(get_permalink()); ? >" > <i class="fa fa-sign-in" > </i > Login </a > </li >
<li > <a href="/wp-login.php?action=register" > <i class="fa fa-user-plus" > </i > Signup </a > </li >
<li > <a href="/wp-login.php?action=lostpassword" > <i class="fa fa-lock" > </i > Restore Password </a > </li >
<?php endif;? >
</ul >
</li >

</div > <!--/.nav-collapse -- >
</div >
</nav >


As you notice the additional menu I added comes after all my menus, and it is called "User", here is my change that you may use it inside any theme having bootstrap.
<li class="menu-item dropdown" >
<a title="User" href="#" data-toggle="dropdown" class="dropdown-toggle" aria-haspopup="true" > <span class="fa fa-user" > </span > User <span class="fa fa-caret-down" > </span > </a >
<ul role="menu" class=" dropdown-menu" >
<?php if (is_user_logged_in()) : ? >
<li class="menu-item" > <a title="Profile" href="/wp-admin/profile.php" > <span class="fa fa-address-card-o" > </span > Profile </a > </li >
<li class="menu-item" > <a title="Dashboard" target="_blank" href="/wp-admin/" > <span class="fa fa-tachometer" > </span > Dashboard </a > </li >
<li role="separator" class="divider" > </li >
<li > <a href=" <?php echo wp_logout_url(get_permalink()); ? >" > <i class="fa fa-sign-out" > </i > Logout </a > </li >
<?php else : ? >
<li > <a href=" <?php echo wp_login_url(get_permalink()); ? >" > <i class="fa fa-sign-in" > </i > Login </a > </li >
<li > <a href="/wp-login.php?action=register" > <i class="fa fa-user-plus" > </i > Signup </a > </li >
<li > <a href="/wp-login.php?action=lostpassword" > <i class="fa fa-lock" > </i > Restore Password </a > </li >
<?php endif;? >
</ul >
</li >

Views 3,057

Downloads 1,057

CodeID
DB ID