Guenni007

menu

Jun 24th, 2020
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 20.39 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Fullwidth Sub Menu
  4.  *
  5.  * Shortcode that allows to display a fullwidth Sub Menu
  6.  */
  7. if ( ! defined( 'ABSPATH' ) ) {  exit;  }    // Exit if accessed directly
  8.  
  9.  
  10. if ( ! class_exists( 'avia_sc_submenu' ) )
  11. {
  12.     class avia_sc_submenu extends aviaShortcodeTemplate
  13.     {
  14.         /**
  15.          *
  16.          * @var int
  17.          */
  18.         static protected $count = 0;
  19.  
  20.         /**
  21.          *
  22.          * @var int
  23.          */
  24.         static protected $custom_items = 0;
  25.  
  26.         /**
  27.          * Create the config array for the shortcode button
  28.          */
  29.         function shortcode_insert_button()
  30.         {
  31.             $this->config['version']        = '1.0';
  32.             $this->config['self_closing']   = 'no';
  33.  
  34.             $this->config['name']           = __( 'Fullwidth Sub Menu', 'avia_framework' );
  35.             $this->config['tab']            = __( 'Content Elements', 'avia_framework' );
  36.             $this->config['icon']           = AviaBuilder::$path['imagesURL'] . 'sc-submenu.png';
  37.             $this->config['order']          = 30;
  38.             $this->config['target']         = 'avia-target-insert';
  39.             $this->config['shortcode']      = 'av_submenu';
  40.             $this->config['shortcode_nested'] = array( 'av_submenu_item' );
  41.             $this->config['tooltip']        = __( 'Display a sub menu', 'avia_framework' );
  42.             $this->config['tinyMCE']        = array( 'disable' => 'true' );
  43.             $this->config['drag-level']     = 1;
  44.             $this->config['preview']        = false;
  45.             $this->config['disabling_allowed'] = true;
  46.            
  47.             $this->config['id_name']        = 'id';
  48.             $this->config['id_show']        = 'yes';
  49.             $this->config['alb_desc_id']    = 'alb_description';
  50.         }
  51.            
  52.         function extra_assets(){
  53.         // load css - now from child-theme folder shortcodes -
  54.         // necessary because some css rules set to !important can't be overwritten by quick css
  55.         wp_enqueue_style( 'avia-module-menu', get_stylesheet_directory_uri().'/shortcodes/menu.css', array( 'avia-layout' ), false );
  56.  
  57.         // load js - necessary because the if clause on hamburger visible had to be changed
  58.         // everything else here on menu.php is untouched
  59.         wp_enqueue_script( 'avia-module-menu', get_stylesheet_directory_uri().'/shortcodes/menu.js', array( 'avia-shortcodes' ), false, true );
  60.         }
  61.  
  62.         /**
  63.          * Popup Elements
  64.          *
  65.          * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  66.          * opens a modal window that allows to edit the element properties
  67.          *
  68.          * @return void
  69.          */
  70.         function popup_elements()
  71.         {
  72.            
  73.             $this->elements = array(
  74.                    
  75.                 array(
  76.                         'type'  => 'tab_container',
  77.                         'nodescription' => true
  78.                     ),
  79.                        
  80.                 array(
  81.                         'type'  => 'tab',
  82.                         'name'  => __( 'Content', 'avia_framework' ),
  83.                         'nodescription' => true
  84.                     ),
  85.                
  86.                     array(
  87.                             'type'          => 'template',
  88.                             'template_id'   => $this->popup_key( 'content_menus' ),
  89.                             'nodescription' => true
  90.                         ),
  91.                
  92.                 array(
  93.                         'type'  => 'tab_close',
  94.                         'nodescription' => true
  95.                     ),
  96.                
  97.                 array(
  98.                         'type'  => 'tab',
  99.                         'name'  => __( 'Styling', 'avia_framework' ),
  100.                         'nodescription' => true
  101.                     ),
  102.                
  103.                     array(
  104.                             'type'          => 'template',
  105.                             'template_id'   => $this->popup_key( 'styling_colors' ),
  106.                             'nodescription' => true
  107.                         ),
  108.                
  109.                 array(
  110.                         'type'  => 'tab_close',
  111.                         'nodescription' => true
  112.                     ),
  113.                
  114.                 array(
  115.                         'type'  => 'tab',
  116.                         'name'  => __( 'Advanced', 'avia_framework' ),
  117.                         'nodescription' => true
  118.                     ),
  119.                
  120.                     array(
  121.                             'type'  => 'toggle_container',
  122.                             'nodescription' => true
  123.                         ),
  124.                
  125.                         array(
  126.                                     'type'          => 'template',
  127.                                     'template_id'   => $this->popup_key( 'advanced_responsive' ),
  128.                                     'nodescription' => true
  129.                                 ),
  130.                
  131.                         array( 
  132.                                 'type'          => 'template',
  133.                                 'template_id'   => 'developer_options_toggle',
  134.                                 'args'          => array( 'sc' => $this )
  135.                             ),
  136.                
  137.                     array(
  138.                             'type'  => 'toggle_container_close',
  139.                             'nodescription' => true
  140.                         ),
  141.                
  142.                 array(
  143.                         'type'  => 'tab_close',
  144.                         'nodescription' => true
  145.                     ),
  146.  
  147.                 array(
  148.                         'type'  => 'tab_container_close',
  149.                         'nodescription' => true
  150.                     )
  151.                    
  152.                 );
  153.  
  154.         }
  155.        
  156.         /**
  157.          * Create and register templates for easier maintainance
  158.          *
  159.          * @since 4.6.4
  160.          */
  161.         protected function register_dynamic_templates()
  162.         {
  163.             global $avia_config;
  164.  
  165.             $this->register_modal_group_templates();
  166.            
  167.             /**
  168.              * Content Tab
  169.              * ===========
  170.              */
  171.            
  172.             $menus = array();
  173.             if( ! empty( $_POST ) && ! empty( $_POST['action'] ) && $_POST['action'] == 'avia_ajax_av_submenu' )
  174.             {
  175.                 $menus = AviaHelper::list_menus();
  176.             }
  177.            
  178.             $c = array(
  179.                         array( 
  180.                             'name'  => __( 'Which kind of menu do you want to display','avia_framework' ),
  181.                             'desc'  => __( 'Either use an existing menu, built in Appearance -> Menus or create a simple custom menu here', 'avia_framework' ),
  182.                             'id'    => 'which_menu',
  183.                             'type'  => 'select',
  184.                             'std'   => 'center',
  185.                             'subtype'   => array(  
  186.                                                 __( 'Use existing menu', 'avia_framework' )         => '',
  187.                                                 __( 'Build simple custom menu', 'avia_framework' )  => 'custom',
  188.                                             )
  189.                         ),
  190.  
  191.  
  192.                         array( 
  193.                             'name'  => __( 'Select menu to display', 'avia_framework' ),
  194.                             'desc'  => __( 'You can create new menus in ', 'avia_framework' ) . "<a target='_blank' href='" . admin_url( 'nav-menus.php?action=edit&menu=0' ) . "'>" . __( 'Appearance -> Menus', 'avia_framework' ) . '</a><br/>' . __( 'Please note that Mega Menus are not supported for this element ', 'avia_framework' ),
  195.                             'id'    => 'menu',
  196.                             'type'  => 'select',
  197.                             'std'   => '',
  198.                             'required'  => array( 'which_menu', 'not', 'custom' ),
  199.                             'subtype'   =>  $menus     
  200.                         ),
  201.                
  202.                         array(
  203.                             'name'          => __( 'Add/Edit submenu item text', 'avia_framework' ),
  204.                             'desc'          => __( 'Here you can add, remove and edit the submenu item text', 'avia_framework' ),
  205.                             'type'          => 'modal_group',
  206.                             'id'            => 'content',
  207.                             'required'      => array( 'which_menu', 'equals', 'custom' ),
  208.                             'modal_title'   => __( 'Edit Text Element', 'avia_framework' ),
  209.                             'std'           => array(
  210.                                                     array( 'title' => __( 'Menu Item 1', 'avia_framework' ) ),
  211.                                                     array( 'title' => __( 'Menu Item 2', 'avia_framework' ) ),
  212.                                                 ),
  213.                             'subelements'   => $this->create_modal()
  214.                         ),
  215.                
  216.                         array( 
  217.                             'name'  => __( 'Menu Position', 'avia_framework' ),
  218.                             'desc'  => __( 'Aligns the menu either to the left, the right or centers it', 'avia_framework' ),
  219.                             'id'    => 'position',
  220.                             'type'  => 'select',
  221.                             'std'   => 'center',
  222.                             'subtype'   => array(  
  223.                                                 __( 'Left', 'avia_framework' )      => 'left',
  224.                                                 __( 'Center', 'avia_framework' )    => 'center',
  225.                                                 __( 'Right', 'avia_framework' )     => 'right',
  226.                                             )
  227.                         ),
  228.                            
  229.                         array( 
  230.                             'name'  => __( 'Sticky Submenu', 'avia_framework' ),
  231.                             'desc'  => __( 'If checked the menu will stick at the top of the page once it touches it. This option is ignored when burger menu icon is shown.', 'avia_framework' ),
  232.                             'id'    => 'sticky',
  233.                             'std'   => 'true',
  234.                             'type'  => 'checkbox'
  235.                         ),
  236.                
  237.                 );
  238.            
  239.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_menus' ), $c );
  240.            
  241.            
  242.             /**
  243.              * Styling Tab
  244.              * ===========
  245.              */
  246.            
  247.             $desc  = __('The menu will use the color scheme you select. Color schemes are defined on your styling page', 'avia_framework' );
  248.             $desc .= '<br/><a target="_blank" href="' . admin_url( 'admin.php?page=avia#goto_styling' ) . '">';
  249.             $desc .= __( '(Show Styling Page)', 'avia_framework' ) . '</a>';
  250.  
  251.            
  252.             $c = array(
  253.                         array(
  254.                             'name'  => __( 'Menu Colors', 'avia_framework' ),
  255.                             'id'    => 'color',
  256.                             'desc'  => $desc,
  257.                             'type'  => 'select',
  258.                             'std'   => 'main_color',
  259.                             'subtype' =>  array_flip( $avia_config['color_sets'] )
  260.                         ),
  261.                
  262.                 );
  263.            
  264.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_colors' ), $c );
  265.            
  266.             /**
  267.              * Advanced Tab
  268.              * ============
  269.              */
  270.            
  271.             $c = array(
  272.                         array( 
  273.                             'name'  => __( 'Mobile Menu Display','avia_framework' ),
  274.                             'desc'  => __( 'How do you want to display the menu on mobile devices','avia_framework' ),
  275.                             'id'    => 'mobile',
  276.                             'type'  => 'select',
  277.                             'std'   => 'disabled',
  278.                             'subtype'   => array(  
  279.                                                 __( 'Display full menu (works best if you only got a few menu items)', 'avia_framework' )               => 'disabled',
  280.                                                 __( 'Display a button to open menu (works best for menus with a lot of menu items)', 'avia_framework' ) => 'active',
  281.                                             )
  282.                         ),
  283.                    
  284.                         array(
  285.                             'name'      => __( 'Screenwidth for burger menu button', 'avia_framework' ),
  286.                             'desc'      => __( 'Select the maximum screenwidth to use a burger menu button instead of full menu. Above that the full menu is displayed', 'avia_framework' ),
  287.                             'id'        => 'mobile_switch',
  288.                             'type'      => 'select',
  289.                             'std'       => 'av-switch-768',
  290.                             'required'  => array( 'mobile', 'equals', 'active' ),
  291.                             'subtype'   => array(
  292.                                                 __( 'Switch at 990px (tablet landscape)','avia_framework' )     => 'av-switch-990',
  293.                                                 __( 'Switch at 768px (tablet portrait)','avia_framework' )      => 'av-switch-768',
  294.                                                 __( 'Switch at 480px (smartphone portrait)','avia_framework' )  => 'av-switch-480',
  295.                                             )
  296.                         ),
  297.                    
  298.                         array( 
  299.                             'name'  => __( 'Hide Mobile Menu Submenu Items', 'avia_framework'),
  300.                             'desc'  => __( 'By default all menu items of the mobile menu are visible. If you activate this option they will be hidden and a user needs to click on the parent menu item to display the submenus', 'avia_framework'),
  301.                             'id'    => 'mobile_submenu',
  302.                             'required'  => array( 'mobile', 'equals', 'active' ),
  303.                             'type'  => 'checkbox',
  304.                             'std'   => ''
  305.                         ),
  306.                        
  307.                
  308.                 );
  309.            
  310.             $template = array(
  311.                             array( 
  312.                                 'type'          => 'template',
  313.                                 'template_id'   => 'toggle',
  314.                                 'title'         => __( 'Responsive', 'avia_framework' ),
  315.                                 'content'       => $c
  316.                             ),
  317.                     );
  318.            
  319.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_responsive' ), $template );
  320.            
  321.         }
  322.        
  323.         /**
  324.          * Creates the modal popup for a single entry
  325.          *
  326.          * @since 4.6.4
  327.          * @return array
  328.          */
  329.         protected function create_modal()
  330.         {
  331.             $elements = array(
  332.                
  333.                 array(
  334.                         'type'  => 'tab_container',
  335.                         'nodescription' => true
  336.                     ),
  337.                        
  338.                 array(
  339.                         'type'  => 'tab',
  340.                         'name'  => __( 'Content', 'avia_framework' ),
  341.                         'nodescription' => true
  342.                     ),
  343.                
  344.                     array(
  345.                             'type'          => 'template',
  346.                             'template_id'   => $this->popup_key( 'modal_content_menu' )
  347.                         ),
  348.                
  349.                 array(
  350.                         'type'  => 'tab_close',
  351.                         'nodescription' => true
  352.                     ),
  353.                
  354.                 array(
  355.                         'type'  => 'tab',
  356.                         'name'  => __( 'Styling', 'avia_framework' ),
  357.                         'nodescription' => true
  358.                     ),
  359.                
  360.                     array(
  361.                             'type'          => 'template',
  362.                             'template_id'   => $this->popup_key( 'modal_styling_style' )
  363.                         ),
  364.                
  365.                 array(
  366.                         'type'  => 'tab_close',
  367.                         'nodescription' => true
  368.                     ),
  369.                
  370.                 array(
  371.                         'type'  => 'tab',
  372.                         'name'  => __( 'Advanced', 'avia_framework' ),
  373.                         'nodescription' => true
  374.                     ),
  375.                
  376.                     array(
  377.                             'type'          => 'template',
  378.                             'template_id'   => $this->popup_key( 'modal_advanced_link' )
  379.                         ),
  380.                
  381.                 array(
  382.                         'type'  => 'tab_close',
  383.                         'nodescription' => true
  384.                     ),
  385.  
  386.                 array(
  387.                         'type'  => 'tab_container_close',
  388.                         'nodescription' => true
  389.                     )
  390.                
  391.                 );
  392.            
  393.             return $elements;
  394.         }
  395.        
  396.         /**
  397.          * Register all templates for the modal group popup
  398.          *
  399.          * @since 4.6.4
  400.          */
  401.         protected function register_modal_group_templates()
  402.         {
  403.             /**
  404.              * Content Tab
  405.              * ===========
  406.              */
  407.             $c = array(
  408.                         array(
  409.                             'name'  => __( 'Menu Text', 'avia_framework' ),
  410.                             'desc'  => __( 'Enter the menu text here', 'avia_framework' ) ,
  411.                             'id'    => 'title',
  412.                             'std'   => '',
  413.                             'type'  => 'input'
  414.                         ),
  415.                
  416.                
  417.                 );
  418.            
  419.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_content_menu' ), $c );
  420.            
  421.            
  422.             /**
  423.              * Styling Tab
  424.              * ===========
  425.              */
  426.             $c = array(
  427.                         array(
  428.                             'name'  => __( 'Style', 'avia_framework' ),
  429.                             'desc'  => __( 'Select the styling of your menu item', 'avia_framework' ),
  430.                             'id'    => 'button_style',
  431.                             'type'  => 'select',
  432.                             'std'   => '',
  433.                             'subtype'   => array(
  434.                                                 __( 'Default Style', 'avia_framework' )             => '',
  435.                                                 __( 'Button Style (Colored)', 'avia_framework' )    => 'av-menu-button av-menu-button-colored',
  436.                                                 __( 'Button Style (Bordered)', 'avia_framework' )   => 'av-menu-button av-menu-button-bordered',
  437.                                             ),
  438.                         )
  439.                
  440.                 );
  441.            
  442.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_styling_style' ), $c );
  443.            
  444.             /**
  445.              * Advanced Tab
  446.              * ===========
  447.              */
  448.            
  449.             $c = array(
  450.                         array( 
  451.                             'type'          => 'template',
  452.                             'template_id'   => 'linkpicker_toggle',
  453.                             'name'          => __( 'Menu Link?', 'avia_framework' ),
  454.                             'desc'          => __( 'Apply a link to the menu text?', 'avia_framework' ),
  455.                             'subtypes'      => array( 'manually', 'single', 'taxonomy' ),
  456.                             'no_toggle'     => true
  457.                         ),
  458.                 );
  459.            
  460.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_advanced_link' ), $c );
  461.            
  462.         }
  463.  
  464.  
  465.         /**
  466.          * Editor Sub Element - this function defines the visual appearance of an element that is displayed within a modal window and on click opens its own modal window
  467.          * Works in the same way as Editor Element
  468.          * @param array $params this array holds the default values for $content and $args.
  469.          * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  470.          */
  471.         function editor_sub_element( $params )
  472.         {
  473.             $template = $this->update_template( 'title', '{{title}}' );
  474.  
  475.             $params['innerHtml']  = '';
  476.             $params['innerHtml'] .= "<div class='avia_title_container'>";
  477.             $params['innerHtml'] .= "<span {$template} >{$params['args']['title']}</span></div>";
  478.  
  479.             return $params;
  480.         }
  481.            
  482.            
  483.         /**
  484.          * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  485.          * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  486.          * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  487.          *
  488.          *
  489.          * @param array $params this array holds the default values for $content and $args.
  490.          * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  491.          */
  492.         function editor_element( $params )
  493.         {  
  494. //          $term_args = array(
  495. //                          'taxonomy'      => 'nav_menu',
  496. //                          'hide_empty'    => false
  497. //                      );
  498. //
  499. //          $menus = AviaHelper::get_terms( $term_args );
  500.  
  501.        
  502.             $params = parent::editor_element( $params );
  503.            
  504.             return $params;
  505.         }
  506.            
  507.            
  508.         /**
  509.          * Returns false by default.
  510.          * Override in a child class if you need to change this behaviour.
  511.          *
  512.          * @since 4.2.1
  513.          * @param string $shortcode
  514.          * @return boolean
  515.          */
  516.         public function is_nested_self_closing( $shortcode )
  517.         {
  518.             if( in_array( $shortcode, $this->config['shortcode_nested'] ) )
  519.             {
  520.                 return true;
  521.             }
  522.  
  523.             return false;
  524.         }          
  525.  
  526.  
  527.         /**
  528.          * Frontend Shortcode Handler
  529.          *
  530.          * @param array $atts array of attributes
  531.          * @param string $content text within enclosing form of shortcode element
  532.          * @param string $shortcodename the shortcode found, when == callback name
  533.          * @return string $output returns the modified html string
  534.          */
  535.         function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' )
  536.         {
  537.             $atts = shortcode_atts( array(
  538.                             'style'         => '',
  539.                             'menu'          => '',
  540.                             'position'      => 'center',
  541.                             'sticky'        => '',
  542.                             'color'         => 'main_color',
  543.                             'mobile'        => 'disabled',
  544.                             'mobile_switch' => 'av-switch-768',
  545.                             'mobile_submenu'=> '',
  546.                             'which_menu'    => ''
  547.  
  548.                     ), $atts, $this->config['shortcode'] );
  549.  
  550.             if( 'disabled' == $atts['mobile'] )
  551.             {
  552.                 $atts['mobile_switch'] = '';
  553.             }
  554.             else if( empty( $atts['mobile_switch'] ) )
  555.             {
  556.                 $atts['mobile_switch'] = 'av-switch-768';
  557.             }
  558.  
  559.             extract( $atts );
  560.  
  561.             $output = '';
  562.             $sticky_div = '';
  563.             avia_sc_submenu::$count ++;
  564.             avia_sc_submenu::$custom_items = 0;
  565.                
  566.             $params['class'] = "av-submenu-container {$color} {$meta['el_class']}";
  567.             $params['open_structure'] = false;
  568.             $params['id'] = ! empty( $meta['custom_id_val'] ) ? $meta['custom_id_val'] : 'sub_menu' . avia_sc_submenu::$count;
  569.             $params['custom_markup'] = $meta['custom_markup'];
  570.             $params['style'] = "style='z-index:" . ( avia_sc_submenu::$count + 300 ) . "'";
  571.  
  572.             if( $sticky && $sticky != 'disabled' )
  573.             {
  574.                 $params['class'] .= ' av-sticky-submenu';
  575.                 $params['before_new'] = "<div class='clear'></div>";
  576.                 $sticky_div = "<div class='sticky_placeholder'></div>";
  577.             }
  578.  
  579.             $params['class'] .= ' ' . $mobile_switch;
  580.  
  581.             //we dont need a closing structure if the element is the first one or if a previous fullwidth element was displayed before
  582.             if( isset( $meta['index'] ) && $meta['index'] == 0 )
  583.             {
  584.                 $params['close'] = false;
  585.             }
  586.            
  587.             if( ! empty( $meta['siblings']['prev']['tag'] ) && in_array( $meta['siblings']['prev']['tag'], AviaBuilder::$full_el_no_section  ) )
  588.             {
  589.                 $params['close'] = false;
  590.             }
  591.            
  592.             if( isset($meta['index'] ) && $meta['index'] > 0 )
  593.             {
  594.                 $params['class'] .= ' submenu-not-first';
  595.             }
  596.                
  597.             if( $which_menu == 'custom' )
  598.             {
  599.                 $element = '';
  600.                 $custom_menu = ShortcodeHelper::avia_remove_autop( $content, true );
  601.                 if(!empty($custom_menu))
  602.                 {
  603.                     $element .= "<ul id='av-custom-submenu-" . avia_sc_submenu::$count . "' class='av-subnav-menu av-submenu-pos-{$position}'>";
  604.                     $element .= $custom_menu;
  605.                     $element .= '</ul>';
  606.                 }
  607.             }
  608.             else
  609.             {
  610.                 $element = wp_nav_menu(
  611.                     array(
  612.                         'menu'          => wp_get_nav_menu_object( $menu ),
  613.                         'menu_class'    => "av-subnav-menu av-submenu-pos-{$position}",
  614.                         'fallback_cb'   => '',
  615.                         'container'     => false,
  616.                         'echo'          => false,
  617.                         'walker'        => new avia_responsive_mega_menu( array('megamenu' => 'disabled' ) )
  618.                     )
  619.                 );
  620.             }
  621.  
  622.  
  623.             $submenu_hidden = '';
  624.             $mobile_button = $mobile == 'active' ? "<a href='#' class='mobile_menu_toggle' " . av_icon_string( 'mobile_menu' ) . "><span class='av-current-placeholder'>" . __( 'Menu', 'avia_framework' ) . '</span></a>' : '';
  625.             if( ! empty( $mobile_button ) && ! empty( $mobile_submenu ) && $mobile_submenu != 'disabled' )
  626.             {
  627.                 $submenu_hidden = 'av-submenu-hidden';
  628.             }
  629.  
  630.             // if(!ShortcodeHelper::is_top_level()) return $element;
  631.                    
  632.             $output .= avia_new_section( $params );
  633.             $output .=      "<div class='container av-menu-mobile-{$mobile} {$submenu_hidden}'>{$mobile_button}{$element}</div>";
  634.             $output .= avia_section_after_element_content( $meta , 'after_submenu', false, $sticky_div );
  635.            
  636.             return $output;
  637.         }
  638.            
  639.         /**
  640.          * Shortcode handler
  641.          *
  642.          * @param array $atts
  643.          * @param string $content
  644.          * @param string $shortcodename
  645.          * @param array $meta
  646.          * @return string
  647.          */
  648.         public function av_submenu_item( $atts, $content = '', $shortcodename = '', $meta = '' )
  649.         {
  650.             /**
  651.              * Fixes a problem when 3-rd party plugins call nested shortcodes without executing main shortcode  (like YOAST in wpseo-filter-shortcodes)
  652.              */
  653.             if( avia_sc_submenu::$count == 0 )
  654.             {
  655.                 return '';
  656.             }
  657.  
  658.             $output = '';
  659.             $atts = shortcode_atts( array( 
  660.                                 'title'         => '',
  661.                                 'link'          => '',
  662.                                 'linktarget'    => '',
  663.                                 'button_style'  => '',
  664.                             ), $atts, 'av_submenu_item' );
  665.  
  666.             extract( $atts );
  667.  
  668.             if( ! empty( $title) )
  669.             {
  670.                 avia_sc_submenu::$custom_items++;
  671.                 $link = AviaHelper::get_url( $link );
  672.                 $blank = ( strpos( $linktarget, '_blank' ) !== false || $linktarget == 'yes' ) ? ' target="_blank" ' : '';
  673.                 $blank .= strpos( $linktarget, 'nofollow' ) !== false ? ' rel="nofollow" ' : '';
  674.  
  675.                 $output .= "<li class='menu-item menu-item-top-level {$button_style} menu-item-top-level-" . avia_sc_submenu::$custom_items . "'>";
  676.                 $output .=      "<a href='{$link}' {$blank}><span class='avia-bullet'></span>";
  677.                 $output .=          "<span class='avia-menu-text'>{$title}</span>";
  678.                 //$output .=        "<span class='avia-menu-fx'><span class='avia-arrow-wrap'><span class='avia-arrow'></span></span></span>";
  679.                 $output .=      '</a>';
  680.                 $output .= '</li>';
  681.  
  682.             }
  683.  
  684.             return $output;
  685.         }
  686.            
  687.     }
  688. }
Add Comment
Please, Sign In to add comment