Advertisement
Guenni007

menu

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