Guest User

Untitled

a guest
Mar 22nd, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. if( ! function_exists( 'safir_add_the_logo_onto_the_menu' ) ){
  2.     /**
  3.      * @param unknown_type $items
  4.      * @param unknown_type $args
  5.      */
  6.     function safir_add_the_logo_onto_the_menu( $items, $args ) {
  7.         // Change the custom logo url here or leave for default logo that is uploaded on WP Customiser.
  8.         $the_custom_logo_url    =   get_header_image();
  9.        
  10.         $output =   '';
  11.        
  12.         if( $args->theme_location == 'primary' && !empty( $the_custom_logo_url ) ){
  13.             $output .= '<li class="menu-logo" style="display:none">';
  14.                 $output .= '
  15.                     <a href="'. esc_url( home_url() ) .'">
  16.                         <img alt="'. esc_attr( get_bloginfo( 'description' ) ) .'" src="'. esc_url( $the_custom_logo_url ) .'">
  17.                     </a>
  18.                 ';
  19.             $output .= '</li>';
  20.         }
  21.         if( ! empty( $output ) ){
  22.             return $output . $items;
  23.         }
  24.         return $items;
  25.     }
  26.     add_filter('wp_nav_menu_items', 'safir_add_the_logo_onto_the_menu', 10, 2);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment