adding logout link if logged in
authorAnthony Talarico <talarico@gaslightmedia.com>
Wed, 4 Apr 2018 12:10:46 +0000 (08:10 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Wed, 4 Apr 2018 12:10:46 +0000 (08:10 -0400)
adding log out link if logged in

functions.php
header.php

index 6e7c74e..7fe5acb 100644 (file)
@@ -257,4 +257,15 @@ function accesspress_parallax_get_my_option(){
 
 add_action("wp_ajax_get_my_option", "accesspress_parallax_get_my_option");
 
-define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/options-framework/' );
\ No newline at end of file
+define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/options-framework/' );
+
+function add_logout($items, $args) {
+    $url =  wp_logout_url( home_url() );
+    if( $args->theme_location == 'login' ){
+    $items .= "<li class='menu-item menu-logout'>"
+            . "<a class='button glm-button' href='$url'>Logout</a>"
+            . "</li>";
+    }
+  return $items;
+}
+add_filter('wp_nav_menu_items', 'add_logout', 10, 2);
\ No newline at end of file
index 5692b33..9f8cd06 100644 (file)
                                'theme_location' => 'login' , 
                                'container'      => false
             ) ); 
-            wp_nav_menu( array( 
-                               'theme_location' => 'logout' , 
-                               'container'      => false
-                       ) ); 
+
             wp_nav_menu( array( 
                                'theme_location' => 'primary' , 
                                'container'      => false