Advertisement
auseron

Menú de navegacion

May 27th, 2022
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.90 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  * Menú de navegaciion
  5.  *
  6.  *
  7.  * */
  8.  
  9. $menu_class     = \Fantomas\Inc\Menus::get_instance();
  10. $header_menu_id = $menu_class->get_menu_id( 'fantomas-header-menu' );
  11. $header_menus   = wp_get_nav_menu_items( $header_menu_id );
  12.  
  13. ?>
  14.  
  15. <nav  class="flex flex-col space-y-3 text-black">
  16.     <div class="flex flex-row items-center justify-center bg-green-900">
  17.     <?php
  18.     $custom_logo_id = get_theme_mod( 'custom_logo' );
  19.     $logo = wp_get_attachment_image_src( $custom_logo_id , 'thumbnail' );
  20.         if ( has_custom_logo() ) {
  21.             echo '<img class="w-10 m-3 rounded-full shadow shadow-slate-800" src="' . esc_url( $logo[0] ) . '" alt="' . get_bloginfo( 'name' ) . '">';
  22.         } else {
  23.             ?>
  24.             <a class="text-3xl text-red-300 text-shadow-md block w-full text-center" href="<?php bloginfo( 'url' ); ?>"><?php bloginfo( 'name' ); ?></a>    
  25.             <?php
  26.         }
  27.     ?>
  28.     </div>
  29.  
  30.     <!-- Menú -->
  31.    
  32.     <div class="relative space-y-7  divide-y divide-lime-400" x-data="{ open: false }" @mouseleave="open = false">
  33.     <?php
  34.     if ( ! empty( $header_menus ) && is_array( $header_menus ) ) {
  35.         foreach ( $header_menus as $menu_item ) {
  36.             if ( ! $menu_item->menu_item_parent ) {
  37.                 $child_menu_items   = $menu_class->get_child_menu_items( $header_menus, $menu_item->ID );
  38.                 $has_children       = ! empty( $child_menu_items ) && is_array( $child_menu_items );
  39.                 $has_sub_menu_class = ! empty( $has_children ) ? 'has-submenu' : '';
  40.                 $link_target        = ! empty( $menu_item->target ) && '_blank' === $menu_item->target ? '_blank' : '_self';
  41.  
  42.                 if ( ! $has_children ) {
  43.                     ?>
  44.                     <a href="<?php echo esc_url( $menu_item->url ); ?>" class=" p-3 block shadow shadow-red-600 w-full text-justify text-xl bg-cyan-900 text-white text-shadow-md" target="<?php echo esc_attr( $link_target ); ?>" title="<?php echo esc_attr( $menu_item->title ); ?>" >
  45.                     <span><?php echo esc_html( $menu_item->title ); ?></span>
  46.                     </a>
  47.                     <?php
  48.                 } else {
  49.                     ?>
  50.                     <a href="<?php echo esc_url( $menu_item->url ); ?>" @mouseover="open = true"  class="bg-cyan-900 flex items-center p-3 space-x-4 block shadow shadow-red-600 w-full text-justify text-xl text-white text-shadow-md" target="<?php echo esc_attr( $link_target ); ?>" title="<?php echo esc_attr( $menu_item->title ); ?>" >
  51.                     <span ><?php echo esc_html( $menu_item->title ); ?></span>
  52.                     <span > 🔻 </span>
  53.                     </a>
  54.                     <!--  &#43; -->
  55.                     <!-- Dropdown -->
  56.                     <div x-show="open" x-transition:enter.duration.500ms x-transition:leave.duration.800ms class="absolute left-0 mt-1  bg-white  shadow-md overflow-hidden text-xl">
  57.                     <?php
  58.                     foreach ( $child_menu_items as $child_menu_item ) {
  59.                         $link_target = ! empty( $child_menu_item->target ) && '_blank' === $child_menu_item->target ? '_blank' : '_self';
  60.                         ?>
  61.                         <div class="border-t border-gray-200">
  62.                         <a href="<?php echo esc_url( $child_menu_item->url ); ?>" class="block w-full p-3 text-justify bg-emerald-900  hover:bg-slate-700 hover:text-yellow-300 text-white text-shadow-md" target="<?php echo esc_attr( $link_target ); ?>" title="<?php echo esc_attr( $child_menu_item->title ); ?>">
  63.                         <?php echo esc_html( $child_menu_item->title ); ?>
  64.                         </a>
  65.  
  66.                         </div>
  67.                         <?php
  68.                     }
  69.                     ?>
  70.                     </div>
  71.                     <?php
  72.                    
  73.                 }
  74.             }
  75.         }
  76.     }
  77.    
  78.     ?>
  79.     </div>
  80.  
  81.  
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement