Advertisement
cipher87

alternate mobile menu fix

Jan 13th, 2021
1,309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.92 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {  exit;  }    // Exit if accessed directly
  3.  
  4.  
  5. global $avia_config;
  6.  
  7. $responsive     = avia_get_option('responsive_active') != "disabled" ? "responsive" : "fixed_layout";
  8. $headerS        = avia_header_setting();
  9. $social_args    = array('outside'=>'ul', 'inside'=>'li', 'append' => '');
  10. $icons          = !empty($headerS['header_social']) ? avia_social_media_icons($social_args, false) : "";
  11. $alternate_menu_id = ! empty( $headerS['alternate_menu'] ) && is_numeric( $headerS['alternate_menu'] ) && empty( $headerS['menu_display'] ) ? $headerS['alternate_menu'] : false;
  12.  
  13. /**
  14.  * For sidebar menus this filter allows to activate alternate menus - are disabled by default
  15.  *
  16.  * @since 4.5
  17.  * @param int|false $alternate_menu_id
  18.  * @param array $headerS
  19.  * @return int|false
  20.  */
  21. $alternate_menu_id = apply_filters( 'avf_alternate_mobile_menu_id', $alternate_menu_id, $headerS );
  22.  
  23. if( isset( $headerS['disabled'] ) )
  24. {    
  25.     return;  
  26. }
  27.  
  28. ?>
  29.  
  30. <header id='header' class='all_colors header_color <?php avia_is_dark_bg('header_color'); echo " ".$headerS['header_class']; ?>' <?php avia_markup_helper(array('context' => 'header','post_type'=>'forum'));?>>
  31.  
  32. <?php
  33.  
  34. //subheader, only display when the user chooses a social header
  35. if($headerS['header_topbar'] == true)
  36. {
  37. ?>
  38.         <div id='header_meta' class='container_wrap container_wrap_meta <?php echo avia_header_class_string(array('header_social', 'header_secondary_menu', 'header_phone_active'), 'av_'); ?>'>
  39.        
  40.                   <div class='container'>
  41.                   <?php
  42.                         /*
  43.                         *   display the themes social media icons, defined in the wordpress backend
  44.                         *   the avia_social_media_icons function is located in includes/helper-social-media-php
  45.                         */
  46.                         $nav = "";
  47.                        
  48.                         //display icons
  49.                         if(strpos( $headerS['header_social'], 'extra_header_active') !== false) echo $icons;
  50.                    
  51.                         //display navigation
  52.                         if(strpos( $headerS['header_secondary_menu'], 'extra_header_active') !== false )
  53.                         {
  54.                             //display the small submenu
  55.                             $avia_theme_location = 'avia2';
  56.                             $avia_menu_class = $avia_theme_location . '-menu';
  57.                             $args = array(
  58.                                 'theme_location'=>$avia_theme_location,
  59.                                 'menu_id' =>$avia_menu_class,
  60.                                 'container_class' =>$avia_menu_class,
  61.                                 'fallback_cb' => '',
  62.                                 'container'=>'',
  63.                                 'echo' =>false
  64.                             );
  65.                            
  66.                             $nav = wp_nav_menu($args);
  67.                         }
  68.                            
  69.                         if(!empty($nav) || apply_filters('avf_execute_avia_meta_header', false))
  70.                         {
  71.                             echo "<nav class='sub_menu' ".avia_markup_helper(array('context' => 'nav', 'echo' => false)).">";
  72.                             echo $nav;
  73.                             do_action('avia_meta_header'); // Hook that can be used for plugins and theme extensions (currently: the wpml language selector)
  74.                             echo '</nav>';
  75.                         }
  76.                        
  77.                        
  78.                         //phone/info text  
  79.                         $phone          = $headerS['header_phone_active'] != "" ? $headerS['phone'] : "";
  80.                         $phone_class    = !empty($nav) ? "with_nav" : "";
  81.                         if($phone)      { echo "<div class='phone-info {$phone_class}'><span>".do_shortcode($phone)."</span></div>"; }
  82.                            
  83.                            
  84.                     ?>
  85.                   </div>
  86.         </div>
  87.  
  88. <?php }
  89.    
  90.    
  91.    
  92.     $output      = "";
  93.     $temp_output = "";
  94.     $icon_beside = "";
  95.    
  96.     if($headerS['header_social'] == 'icon_active_main' && empty($headerS['bottom_menu']))
  97.     {
  98.         $icon_beside = " av_menu_icon_beside";
  99.     }
  100.    
  101.    
  102.    
  103.    
  104.    
  105.    
  106. ?>
  107.         <div  id='header_main' class='container_wrap container_wrap_logo'>
  108.    
  109.         <?php
  110.         /*
  111.         * Hook that can be used for plugins and theme extensions (currently:  the woocommerce shopping cart)
  112.         */
  113.         do_action('ava_main_header');
  114.        
  115.         if($headerS['header_position'] != "header_top") do_action('ava_main_header_sidebar');
  116.        
  117.    
  118.                  $output .= "<div class='container av-logo-container'>";
  119.                  
  120.                     $output .= "<div class='inner-container'>";
  121.                        
  122.                         /*
  123.                         *   display the theme logo by checking if the default logo was overwritten in the backend.
  124.                         *   the function is located at framework/php/function-set-avia-frontend-functions.php in case you need to edit the output
  125.                         */
  126.                         $addition = false;
  127.                         if( ! empty( $headerS['header_transparency'] ) && ! empty( $headerS['header_replacement_logo'] ) )
  128.                         {
  129.                             $addition = "<img src='{$headerS['header_replacement_logo']}' class='alternate' alt='{$headerS['header_replacement_logo_alt']}' title='{$headerS['header_replacement_logo_title']}' />";
  130.                         }
  131.                        
  132.                         $output .= avia_logo(AVIA_BASE_URL.'images/layout/logo.png', $addition, 'span', true);
  133.                        
  134.                             if(!empty($headerS['bottom_menu']))
  135.                             {
  136.                                 ob_start();
  137.                                 do_action('ava_before_bottom_main_menu'); // todo: replace action with filter, might break user customizations
  138.                                 $output .= ob_get_clean();
  139.                             }
  140.                            
  141.                             if($headerS['header_social'] == 'icon_active_main' && !empty($headerS['bottom_menu']))
  142.                             {
  143.                                 $output .= $icons;
  144.                             }
  145.                            
  146.                        
  147.                         /*
  148.                         *   display the main navigation menu
  149.                         *   modify the output in your wordpress admin backend at appearance->menus
  150.                         */
  151.                            
  152.                             if($headerS['bottom_menu'])
  153.                             {
  154.                                 $output .= "</div>";  
  155.                                 $output .= "</div>";
  156.                                
  157.                                 if( !empty( $headerS['header_menu_above'] ))
  158.                                 {
  159.                                     $avia_config['temp_logo_container'] = "<div class='av-section-bottom-logo header_color'>".$output."</div>";
  160.                                     $output = "";
  161.                                 }
  162.                                
  163.                                 $output .= "<div id='header_main_alternate' class='container_wrap'>";
  164.                                 $output .= "<div class='container'>";
  165.                             }
  166.                        
  167.                             $avia_theme_location = 'avia';
  168.                             $avia_menu_class = $avia_theme_location . '-menu';
  169.        
  170.                             $main_nav = "<nav class='main_menu' data-selectname='".__('Select a page','avia_framework')."' ".avia_markup_helper(array('context' => 'nav', 'echo' => false)).">";
  171.                                
  172.                             $args = array(
  173.                                     'theme_location'    => $avia_theme_location,
  174.                                     'menu_id'           => $avia_menu_class,
  175.                                     'menu_class'        => 'menu av-main-nav',
  176.                                     'container_class'   => $avia_menu_class.' av-main-nav-wrap'.$icon_beside,
  177.                                     'fallback_cb'       => 'avia_fallback_menu',
  178.                                     'echo'              =>  false,
  179.                                     'walker'            => new avia_responsive_mega_menu()
  180.                                 );
  181.                        
  182.                                 $wp_main_nav = wp_nav_menu($args);
  183.                                 $main_nav .= $wp_main_nav;
  184.                                
  185.                              
  186.                             /*
  187.                             * Hook that can be used for plugins and theme extensions
  188.                             */
  189.                             ob_start();
  190.                             do_action('ava_inside_main_menu'); // todo: replace action with filter, might break user customizations
  191.                             $main_nav .= ob_get_clean();
  192.                            
  193.                             if($icon_beside)
  194.                             {
  195.                                 $main_nav .= $icons;
  196.                             }
  197.                                
  198.                             $main_nav .= '</nav>';
  199.                            
  200.                             /**
  201.                              * Allow to modify or remove main menu for special pages
  202.                              *
  203.                              * @since 4.1.3
  204.                              */
  205.                             $output .= apply_filters( 'avf_main_menu_nav', $main_nav );
  206.                        
  207.                             /*
  208.                             * Hook that can be used for plugins and theme extensions
  209.                             */
  210.                             ob_start();
  211.                             do_action('ava_after_main_menu'); // todo: replace action with filter, might break user customizations
  212.                             $output .= ob_get_clean();
  213.                
  214.                      /* inner-container */
  215.                     $output .= "</div>";
  216.                        
  217.                 /* end container */
  218.                 $output .= " </div> ";
  219.                
  220.                
  221.                 //output the whole menu    
  222.                 echo $output;
  223.                
  224.                
  225.            ?>
  226.  
  227.         <!-- end container_wrap-->
  228.         </div>
  229. <?php
  230.         /**
  231.          * Add a hidden container for alternate mobile menu
  232.          *
  233.          * We use the same structure as main menu to be able to use same logic in js to build burger menu
  234.          *
  235.          * @added_by Günter
  236.          * @since 4.5
  237.          */
  238.         $out_alternate = '';
  239.         $avia_alternate_location = 'avia_alternate';
  240.         $avia_alternate_menu_class = $avia_alternate_location . '_menu';
  241.        
  242.         if( false !== $alternate_menu_id && is_nav_menu( $alternate_menu_id ) )
  243.         {
  244.             $out_alternate .= '<div id="avia_alternate_menu_container" style="display: none;">';
  245.            
  246.             $alternate_nav =    "<nav class='main_menu' data-selectname='" . __( 'Select a page', 'avia_framework' ) . "' " . avia_markup_helper( array( 'context' => 'nav', 'echo' => false ) ) . ">";
  247.            
  248.             $args = array(
  249.                             'menu'              => $alternate_menu_id,
  250.                             'menu_id'           => $avia_alternate_menu_class,
  251.                             'menu_class'        => 'menu av-main-nav',
  252.                             'container_class'   => $avia_alternate_menu_class.' av-main-nav-wrap',
  253.                             'fallback_cb'       => 'avia_fallback_menu',
  254.                             'echo'              => false,
  255.                             'walker'            => new avia_responsive_mega_menu()
  256.                         );
  257.  
  258.             $wp_nav_alternate = wp_nav_menu( $args );
  259.            
  260.             /**
  261.              * Hook that can be used for plugins and theme extensions
  262.              *
  263.              * @since 4.5
  264.              * @return string
  265.              */
  266.             $alternate_nav .=       apply_filters( 'avf_inside_alternate_main_menu_nav', $wp_nav_alternate, $avia_alternate_location, $avia_alternate_menu_class );
  267.            
  268.             $alternate_nav .=   '</nav>';
  269.  
  270.             /**
  271.              * Allow to modify or remove alternate menu for special pages.
  272.              *
  273.              * @since 4.5
  274.              * @return string
  275.              */
  276.             $out_alternate .= apply_filters( 'avf_alternate_main_menu_nav', $alternate_nav );
  277.  
  278.             $out_alternate .= '</div>';
  279.         }
  280.        
  281.         /**
  282.          * Hook to remove or modify alternate mobile menu
  283.          *
  284.          * @since 4.5
  285.          * @return string
  286.          */
  287.         $out_alternate = apply_filters( 'avf_alternate_mobile_menu', $out_alternate );
  288.        
  289.         if( ! empty ( $out_alternate ) )
  290.         {
  291.             echo $out_alternate;
  292.         }
  293. ?>
  294.         <div class='header_bg'></div>
  295.  
  296. <!-- end header -->
  297. </header>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement