Advertisement
cipher87

Iconlist with aria-label for sub-items

Apr 15th, 2021
1,466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 31.44 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Icon List Shortcode
  4.  *
  5.  * Creates a list with nice icons beside
  6.  * Thread: https://kriesi.at/support/topic/add-aria-label-to-post-slider/
  7.  * @version 1.0.1
  8.  */
  9. if ( ! defined( 'ABSPATH' ) ) {  exit;  }    // Exit if accessed directly
  10.  
  11. if ( ! class_exists( 'avia_sc_iconlist' ) )
  12. {
  13.     class avia_sc_iconlist extends aviaShortcodeTemplate
  14.     {
  15.            
  16.         /**
  17.          *
  18.          * @since 4.5.5
  19.          * @var array
  20.          */
  21.         protected $screen_options;
  22.        
  23.         /**
  24.          * @since 4.5.5
  25.          * @var string
  26.          */
  27.         protected $icon_html_styling;
  28.        
  29.         /**
  30.          * @since 4.5.5
  31.          * @var string
  32.          */
  33.         protected $title_styling;
  34.        
  35.         /**
  36.          * @since 4.5.5
  37.          * @var string
  38.          */
  39.         protected $content_styling;
  40.        
  41.         /**
  42.          * @since 4.5.5
  43.          * @var string
  44.          */
  45.         protected $content_class;
  46.        
  47.         /**
  48.          * @since 4.5.5
  49.          * @var string
  50.          */
  51.         protected $title_class;
  52.        
  53.         /**
  54.          * @since 4.5.5
  55.          * @var string
  56.          */
  57.         protected $iconlist_styling;
  58.        
  59.         /**
  60.          *
  61.          * @since 4.5.5
  62.          * @param AviaBuilder $builder
  63.          */
  64.         public function __construct( $builder )
  65.         {
  66.             $this->screen_options = array();
  67.             $this->icon_html_styling = '';
  68.             $this->title_styling = '';
  69.             $this->content_styling = '';
  70.             $this->content_class = '';
  71.             $this->title_class = '';
  72.             $this->iconlist_styling = '';
  73.                
  74.             parent::__construct( $builder );
  75.         }
  76.        
  77.         /**
  78.          * @since 4.5.5
  79.          */
  80.         public function __destruct()
  81.         {
  82.             parent::__destruct();
  83.            
  84.             unset( $this->screen_options );
  85.         }
  86.        
  87.         /**
  88.          * Create the config array for the shortcode button
  89.          */
  90.         function shortcode_insert_button()
  91.         {
  92.             $this->config['version']        = '1.0';
  93.             $this->config['self_closing']   = 'no';
  94.             $this->config['base_element']   = 'yes';
  95.  
  96.             $this->config['name']           = __( 'Icon List', 'avia_framework' );
  97.             $this->config['tab']            = __( 'Content Elements', 'avia_framework' );
  98.             $this->config['icon']           = AviaBuilder::$path['imagesURL'] . 'sc-iconlist.png';
  99.             $this->config['order']          = 90;
  100.             $this->config['target']         = 'avia-target-insert';
  101.             $this->config['shortcode']      = 'av_iconlist';
  102.             $this->config['shortcode_nested'] = array( 'av_iconlist_item' );
  103.             $this->config['tooltip']        = __( 'Creates a list with nice icons beside', 'avia_framework' );
  104.             $this->config['preview']        = true;
  105.             $this->config['disabling_allowed'] = true;
  106.             $this->config['id_name']        = 'id';
  107.             $this->config['id_show']        = 'yes';
  108.             $this->config['alb_desc_id']    = 'alb_description';
  109.             $this->config['name_item']      = __( 'Icon List Item', 'avia_framework' );
  110.             $this->config['tooltip_item']   = __( 'An Icon List Element Item', 'avia_framework' );
  111.             $this->config['aria_label']     = 'yes'; // added
  112.         }
  113.            
  114.         function extra_assets()
  115.         {
  116.             wp_enqueue_style( 'avia-module-icon', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/icon/icon.css', array( 'avia-layout' ), false );
  117.             wp_enqueue_style( 'avia-module-iconlist', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/iconlist/iconlist.css', array( 'avia-layout' ), false );
  118.  
  119.             wp_enqueue_script( 'avia-module-iconlist', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/iconlist/iconlist.js', array( 'avia-shortcodes' ), false, true );
  120.         }
  121.  
  122.         /**
  123.          * Popup Elements
  124.          *
  125.          * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  126.          * opens a modal window that allows to edit the element properties
  127.          *
  128.          * @return void
  129.          */
  130.         function popup_elements()
  131.         {
  132.            
  133.             $this->elements = array(
  134.                        
  135.                 array(
  136.                         'type'  => 'tab_container',
  137.                         'nodescription' => true
  138.                     ),
  139.                        
  140.                 array(
  141.                         'type'  => 'tab',
  142.                         'name'  => __( 'Content', 'avia_framework' ),
  143.                         'nodescription' => true
  144.                     ),
  145.                
  146.                     array(
  147.                             'type'          => 'template',
  148.                             'template_id'   => $this->popup_key( 'content_iconfont' )
  149.                         ),
  150.                
  151.                 array(
  152.                         'type'  => 'tab_close',
  153.                         'nodescription' => true
  154.                     ),
  155.                
  156.                 array(
  157.                         'type'  => 'tab',
  158.                         'name'  => __( 'Styling', 'avia_framework' ),
  159.                         'nodescription' => true
  160.                     ),
  161.                
  162.                     array(
  163.                             'type'          => 'template',
  164.                             'template_id'   => 'toggle_container',
  165.                             'templates_include' => array(
  166.                                                     $this->popup_key( 'styling_general' ),
  167.                                                     $this->popup_key( 'styling_font_sizes' ),
  168.                                                     $this->popup_key( 'styling_font_colors' ),
  169.                                                     $this->popup_key( 'styling_icon_font_colors' )
  170.                                                 ),
  171.                             'nodescription' => true
  172.                         ),
  173.                
  174.                 array(
  175.                         'type'  => 'tab_close',
  176.                         'nodescription' => true
  177.                     ),
  178.                
  179.                 array(
  180.                         'type'  => 'tab',
  181.                         'name'  => __( 'Advanced', 'avia_framework' ),
  182.                         'nodescription' => true
  183.                     ),
  184.                
  185.                     array(
  186.                             'type'  => 'toggle_container',
  187.                             'nodescription' => true
  188.                         ),
  189.                
  190.                         array( 
  191.                                 'type'          => 'template',
  192.                                 'template_id'   => $this->popup_key( 'advanced_animation' )
  193.                             ),
  194.                
  195.                         array( 
  196.                                 'type'          => 'template',
  197.                                 'template_id'   => 'screen_options_toggle',
  198.                                 'lockable'      => true
  199.                             ),
  200.  
  201.                         array( 
  202.                                 'type'          => 'template',
  203.                                 'template_id'   => 'developer_options_toggle',
  204.                                 'args'          => array( 'sc' => $this )
  205.                             ),
  206.                
  207.                     array(
  208.                             'type'  => 'toggle_container_close',
  209.                             'nodescription' => true
  210.                         ),
  211.                
  212.                 array(
  213.                         'type'  => 'tab_close',
  214.                         'nodescription' => true
  215.                     ),
  216.                
  217.                 array( 
  218.                         'type'          => 'template',
  219.                         'template_id'   => 'element_template_selection_tab',
  220.                         'args'          => array( 'sc' => $this )
  221.                     ),
  222.  
  223.                 array(
  224.                         'type'  => 'tab_container_close',
  225.                         'nodescription' => true
  226.                     )
  227.                
  228.             );
  229.  
  230.         }
  231.        
  232.         /**
  233.          * Create and register templates for easier maintainance
  234.          *
  235.          * @since 4.6.4
  236.          */
  237.         protected function register_dynamic_templates()
  238.         {
  239.            
  240.             $this->register_modal_group_templates();
  241.            
  242.             /**
  243.              * Content Tab
  244.              * ===========
  245.              */
  246.            
  247.             $c = array(
  248.                         array(
  249.                             'name'          => __( 'Add/Edit List items', 'avia_framework' ),
  250.                             'desc'          => __( 'Here you can add, remove and edit the items of your item list.', 'avia_framework' ),
  251.                             'type'          => 'modal_group',
  252.                             'id'            => 'content',
  253.                             'modal_title'   => __( 'Edit List Item', 'avia_framework' ),
  254.                             'editable_item' => true,
  255.                             'lockable'      => true,
  256.                             'std'           => array(
  257.                                                     array(
  258.                                                         'title'     => __( 'List Title 1', 'avia_framework' ),
  259.                                                         'icon'      => '43',
  260.                                                         'content'   => __( 'Enter content here', 'avia_framework' )
  261.                                                     ),
  262.                                                     array(
  263.                                                         'title'     => __( 'List Title 2', 'avia_framework' ),
  264.                                                         'icon'      => '25',
  265.                                                         'content'   => __( 'Enter content here', 'avia_framework' )
  266.                                                     ),
  267.                                                     array(
  268.                                                         'title'     => __( 'List Title 3', 'avia_framework' ),
  269.                                                         'icon'      => '64',
  270.                                                         'content'   => __( 'Enter content here', 'avia_framework' )
  271.                                                     ),
  272.                                                 ),
  273.                             'subelements'   => $this->create_modal()
  274.                         )
  275.                 );
  276.            
  277.            
  278.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_iconfont' ), $c );
  279.            
  280.            
  281.             /**
  282.              * Styling Tab
  283.              * ============
  284.              */
  285.            
  286.            
  287.             $c = array(
  288.                         array(
  289.                             'name'  => __( 'Icon Position', 'avia_framework' ),
  290.                             'desc'  => __( 'Set the position of the icons', 'avia_framework' ),
  291.                             'id'    => 'position',
  292.                             'type'  => 'select',
  293.                             'std'   => 'left',
  294.                             'lockable'  => true,
  295.                             'subtype'   => array(  
  296.                                             __( 'Left', 'avia_framework' )  => 'left',
  297.                                             __( 'Right', 'avia_framework' ) => 'right',
  298.                                         )
  299.                             ),
  300.                
  301.                         array(
  302.                             'name'  => __( 'List Styling', 'avia_framework' ),
  303.                             'desc'  => __( 'Change the styling of your iconlist', 'avia_framework' ),
  304.                             'id'    => 'iconlist_styling',
  305.                             'type'  => 'select',
  306.                             'std'   => '',
  307.                             'lockable'  => true,
  308.                             'subtype'   => array(  
  309.                                             __( 'Default (Big List)', 'avia_framework' )    => '',
  310.                                             __( 'Minimal small list', 'avia_framework' )    => 'av-iconlist-small',
  311.                                         )
  312.                         ),
  313.                
  314.                 );
  315.            
  316.             $template = array(
  317.                             array( 
  318.                                 'type'          => 'template',
  319.                                 'template_id'   => 'toggle',
  320.                                 'title'         => __( 'General Styling', 'avia_framework' ),
  321.                                 'content'       => $c
  322.                             ),
  323.                     );
  324.            
  325.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_general' ), $template );
  326.            
  327.             $c = array(
  328.                         array(
  329.                             'name'  => __( 'Font Colors', 'avia_framework' ),
  330.                             'desc'  => __( 'Either use the themes default colors or apply some custom ones', 'avia_framework' ),
  331.                             'id'    => 'font_color',
  332.                             'type'  => 'select',
  333.                             'std'   => '',
  334.                             'lockable'  => true,
  335.                             'subtype'   => array(
  336.                                             __( 'Default', 'avia_framework' )   => '',
  337.                                             __( 'Define Custom Colors', 'avia_framework' )  => 'custom'
  338.                                         ),
  339.                         ),
  340.                    
  341.                         array( 
  342.                             'name'  => __( 'Custom Title Font Color', 'avia_framework' ),
  343.                             'desc'  => __( 'Select a custom font color. Leave empty to use the default', 'avia_framework' ),
  344.                             'id'    => 'custom_title',
  345.                             'type'  => 'colorpicker',
  346.                             'std'   => '',
  347.                             'container_class' => 'av_half av_half_first',
  348.                             'lockable'  => true,
  349.                             'required'  => array( 'font_color', 'equals', 'custom' )
  350.                         ), 
  351.                        
  352.                         array( 
  353.                             'name'  => __( 'Custom Content Font Color', 'avia_framework' ),
  354.                             'desc'  => __( 'Select a custom font color. Leave empty to use the default', 'avia_framework' ),
  355.                             'id'    => 'custom_content',
  356.                             'type'  => 'colorpicker',
  357.                             'std'   => '',
  358.                             'container_class' => 'av_half',
  359.                             'lockable'  => true,
  360.                             'required'  => array( 'font_color', 'equals','custom'   )
  361.                         )
  362.                 );
  363.            
  364.             $template = array(
  365.                             array( 
  366.                                 'type'          => 'template',
  367.                                 'template_id'   => 'toggle',
  368.                                 'title'         => __( 'Font Colors', 'avia_framework' ),
  369.                                 'content'       => $c
  370.                             ),
  371.                     );
  372.            
  373.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_font_colors' ), $template );
  374.            
  375.             $c = array(
  376.                         array(
  377.                             'name'  => __( 'Icon Colors', 'avia_framework' ),
  378.                             'desc'  => __( 'Either use the themes default colors or apply some custom ones', 'avia_framework' ),
  379.                             'id'    => 'color',
  380.                             'type'  => 'select',
  381.                             'std'   => '',
  382.                             'lockable'  => true,
  383.                             'subtype'   => array(
  384.                                                 __( 'Default', 'avia_framework' )   => '',
  385.                                                 __( 'Define Custom Colors', 'avia_framework' )  => 'custom'
  386.                                             ),
  387.                                                
  388.                         ),
  389.                    
  390.                         array( 
  391.                             'name'  => __( 'Custom Background Color', 'avia_framework' ),
  392.                             'desc'  => __( 'Select a custom background color. Leave empty to use the default', 'avia_framework' ),
  393.                             'id'    => 'custom_bg',
  394.                             'type'  => 'colorpicker',
  395.                             'std'   => '',
  396.                             'container_class' => 'av_third av_third_first',
  397.                             'lockable'  => true,
  398.                             'required'  => array( 'color', 'equals', 'custom' )
  399.                         ), 
  400.                        
  401.                         array( 
  402.                             'name'  => __( 'Custom Icon Font Color', 'avia_framework' ),
  403.                             'desc'  => __( 'Select a custom icon font color. Leave empty to use the default', 'avia_framework' ),
  404.                             'id'    => 'custom_font',
  405.                             'type'  => 'colorpicker',
  406.                             'std'   => '',
  407.                             'container_class' => 'av_third',
  408.                             'lockable'  => true,
  409.                             'required' => array( 'color', 'equals', 'custom' )
  410.                         ), 
  411.                    
  412.                         array( 
  413.                             'name'  => __( 'Custom Border Color', 'avia_framework' ),
  414.                             'desc'  => __( 'Select a custom border color. Leave empty to use the default', 'avia_framework' ),
  415.                             'id'    => 'custom_border',
  416.                             'type'  => 'colorpicker',
  417.                             'std'   => '',
  418.                             'container_class' => 'av_third',
  419.                             'lockable'  => true,
  420.                             'required' => array( 'color', 'equals', 'custom' )
  421.                         )
  422.                 );
  423.            
  424.             $template = array(
  425.                             array( 
  426.                                 'type'          => 'template',
  427.                                 'template_id'   => 'toggle',
  428.                                 'title'         => __( 'Icon Font Colors', 'avia_framework' ),
  429.                                 'content'       => $c
  430.                             ),
  431.                     );
  432.            
  433.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_icon_font_colors' ), $template );
  434.            
  435.             $c = array(
  436.                         array(
  437.                             'name'          => __( 'Title Font Sizes', 'avia_framework' ),
  438.                             'desc'          => __( 'Select a custom font size for the titles.', 'avia_framework' ),
  439.                             'type'          => 'template',
  440.                             'template_id'   => 'font_sizes_icon_switcher',
  441.                             'lockable'      => true,
  442.                             'subtype'       => array(
  443.                                                 'default'   => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  444.                                                 'medium'    => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  445.                                                 'small'     => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  446.                                                 'mini'      => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' )
  447.                                             ),
  448.                             'id_sizes'      => array(
  449.                                                 'default'   => 'custom_title_size',
  450.                                                 'medium'    => 'av-medium-font-size-title',
  451.                                                 'small'     => 'av-small-font-size-title',
  452.                                                 'mini'      => 'av-mini-font-size-title'
  453.                                             )
  454.                         ),
  455.                
  456.                         array(
  457.                             'name'          => __( 'Content Font Sizes', 'avia_framework' ),
  458.                             'desc'          => __( 'Select a custom font size for the content.', 'avia_framework' ),
  459.                             'type'          => 'template',
  460.                             'template_id'   => 'font_sizes_icon_switcher',
  461.                             'lockable'      => true,
  462.                             'subtype'       => array(
  463.                                                 'default'   => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  464.                                                 'medium'    => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  465.                                                 'small'     => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  466.                                                 'mini'      => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' )
  467.                                             ),
  468.                             'id_sizes'      => array(
  469.                                                 'default'   => 'custom_content_size',
  470.                                                 'medium'    => 'av-medium-font-size',
  471.                                                 'small'     => 'av-small-font-size',
  472.                                                 'mini'      => 'av-mini-font-size'
  473.                                             )
  474.                         )
  475.                
  476.                 );
  477.            
  478.             $template = array(
  479.                             array( 
  480.                                 'type'          => 'template',
  481.                                 'template_id'   => 'toggle',
  482.                                 'title'         => __( 'Font Sizes', 'avia_framework' ),
  483.                                 'content'       => $c
  484.                             ),
  485.                     );
  486.            
  487.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_font_sizes' ), $template );
  488.                
  489.             /**
  490.              * Advanced Tab
  491.              * ============
  492.              */
  493.            
  494.             $c = array(
  495.                          array(
  496.                             'name'  => __( 'Animation', 'avia_framework' ),
  497.                             'desc'  => __( 'Should the items appear in an animated way?', 'avia_framework' ),
  498.                             'id'    => 'animation',
  499.                             'type'  => 'select',
  500.                             'std'   => '',
  501.                             'lockable'  => true,
  502.                             'subtype' => array(
  503.                                             __( 'Animation activated', 'avia_framework' )   => '',
  504.                                             __( 'Animation deactivated', 'avia_framework' ) => 'deactivated',
  505.                                         )
  506.                         )
  507.                
  508.                 );
  509.            
  510.             $template = array(
  511.                             array( 
  512.                                 'type'          => 'template',
  513.                                 'template_id'   => 'toggle',
  514.                                 'title'         => __( 'Animation', 'avia_framework' ),
  515.                                 'content'       => $c
  516.                             ),
  517.                     );
  518.            
  519.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_animation' ), $template );
  520.         }
  521.        
  522.         /**
  523.          * Creates the modal popup for a single entry
  524.          *
  525.          * @since 4.6.4
  526.          * @return array
  527.          */
  528.         protected function create_modal()
  529.         {
  530.             $elements = array(
  531.                
  532.                 array(
  533.                         'type'  => 'tab_container',
  534.                         'nodescription' => true
  535.                     ),
  536.                        
  537.                 array(
  538.                         'type'  => 'tab',
  539.                         'name'  => __( 'Content', 'avia_framework' ),
  540.                         'nodescription' => true
  541.                     ),
  542.                
  543.                     array(
  544.                             'type'          => 'template',
  545.                             'template_id'   => $this->popup_key( 'modal_content_content' )
  546.                         ),
  547.                
  548.                 array(
  549.                         'type'  => 'tab_close',
  550.                         'nodescription' => true
  551.                     ),
  552.                
  553.                 array(
  554.                         'type'  => 'tab',
  555.                         'name'  => __( 'Advanced', 'avia_framework' ),
  556.                         'nodescription' => true
  557.                     ),
  558.                
  559.                     array(
  560.                             'type'          => 'template',
  561.                             'template_id'   => 'toggle_container',
  562.                             'templates_include' => array(
  563.                                                     $this->popup_key( 'modal_advanced_heading' ),
  564.                                                     $this->popup_key( 'modal_advanced_link' )
  565.                                                 ),
  566.                             'nodescription' => true
  567.                         ),
  568.                
  569.                 array(
  570.                         'type'  => 'tab_close',
  571.                         'nodescription' => true
  572.                     ),
  573.                
  574.                 array( 
  575.                         'type'          => 'template',
  576.                         'template_id'   => 'element_template_selection_tab',
  577.                         'args'          => array(
  578.                                                 'sc'            => $this,
  579.                                                 'modal_group'   => true
  580.                                             )
  581.                     ),
  582.                
  583.                 array(
  584.                         'type'  => 'tab_container_close',
  585.                         'nodescription' => true
  586.                     )
  587.                
  588.                 );
  589.            
  590.             return $elements;
  591.         }
  592.        
  593.         /**
  594.          * Register all templates for the modal group popup
  595.          *
  596.          * @since 4.6.4
  597.          */
  598.         protected function register_modal_group_templates()
  599.         {
  600.             /**
  601.              * Content Tab
  602.              * ===========
  603.              */
  604.            
  605.             $c = array(
  606.                         array(
  607.                                 'name'  => __( 'List Item Title', 'avia_framework' ),
  608.                                 'desc'  => __( 'Enter the list item title here (Better keep it short)', 'avia_framework' ) ,
  609.                                 'id'    => 'title',
  610.                                 'type'  => 'input',
  611.                                 'std'   => 'List Title',
  612.                                 'lockable'  => true
  613.                         ),
  614.                
  615.                         array(
  616.                             'name'  => __( 'List Item Content', 'avia_framework' ),
  617.                             'desc'  => __( 'Enter some content here', 'avia_framework' ) ,
  618.                             'id'    => 'content',
  619.                             'type'  => 'tiny_mce',
  620.                             'std'   => __( 'List Content goes here', 'avia_framework' ),
  621.                             'lockable'  => true
  622.                         ),
  623.                
  624.                         array(
  625.                             'name'  => __( 'List Item Icon', 'avia_framework' ),
  626.                             'desc'  => __( 'Select an icon for your list item below', 'avia_framework' ),
  627.                             'id'    => 'icon',
  628.                             'type'  => 'iconfont',
  629.                             'std'   => '',
  630.                             'lockable'  => true,
  631.                             'locked'    => array( 'icon', 'font' )
  632.                         ),
  633.  
  634.                         array(
  635.                             'name'  => __( 'Aria Label Text', 'avia_framework' ),
  636.                             'desc'  => __( 'Add a custom text for the element here. This text will be added to the aria-label attribute and can be used by accessibility tree and screen readers. Leave empty if not needed.', 'avia_framework' ) ,
  637.                             'id'    => 'aria_label',
  638.                             'type'  => 'input',
  639.                             'std'   => '',
  640.                             'lockable'  => true
  641.                         )
  642.                
  643.                 );
  644.            
  645.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_content_content' ), $c );
  646.            
  647.            
  648.             $c = array(
  649.                         array( 
  650.                             'type'          => 'template',
  651.                             'template_id'   => 'linkpicker_toggle',
  652.                             'name'          => __( 'Title Link?', 'avia_framework' ),
  653.                             'desc'          => __( 'Do you want to apply a link to the title?', 'avia_framework' ),
  654.                             'lockable'      => true,
  655.                             'subtypes'      => array( 'no', 'manually', 'single', 'taxonomy' ),
  656.                             'no_toggle'     => true
  657.                         ),
  658.                
  659.                         array(
  660.                             'name'  => __( 'Apply link to icon', 'avia_framework' ),
  661.                             'desc'  => __( 'Do you want to apply the link to the icon?', 'avia_framework' ),
  662.                             'id'    => 'linkelement',
  663.                             'type'  => 'select',
  664.                             'std'   => '',
  665.                             'lockable'  => true,
  666.                             'required'  => array( 'link', 'not', '' ),
  667.                             'subtype'   => array(
  668.                                             __( 'No, apply link to the title', 'avia_framework' )       => '',
  669.                                             __( 'Yes, apply link to icon and title', 'avia_framework' ) => 'both',
  670.                                             __( 'Yes, apply link to icon only', 'avia_framework' )      => 'only_icon'
  671.                                         )
  672.                         ),
  673.                        
  674.                 );
  675.            
  676.             $template = array(
  677.                             array( 
  678.                                 'type'          => 'template',
  679.                                 'template_id'   => 'toggle',
  680.                                 'title'         => __( 'Link Behaviour', 'avia_framework' ),
  681.                                 'content'       => $c
  682.                             ),
  683.                     );
  684.            
  685.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_advanced_link' ), $template );
  686.            
  687.             $c = array(
  688.                         array( 
  689.                             'type'              => 'template',
  690.                             'template_id'       => 'heading_tag',
  691.                             'theme_default'     => 'h4',
  692.                             'context'           => __CLASS__,
  693.                             'lockable'          => true
  694.                         ),
  695.                
  696.                 );
  697.            
  698.             $template = array(
  699.                             array( 
  700.                                 'type'          => 'template',
  701.                                 'template_id'   => 'toggle',
  702.                                 'title'         => __( 'Heading Tag', 'avia_framework' ),
  703.                                 'content'       => $c
  704.                             ),
  705.                     );
  706.            
  707.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_advanced_heading' ), $template );
  708.         }
  709.  
  710.         /**
  711.          * 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
  712.          * Works in the same way as Editor Element
  713.          * @param array $params this array holds the default values for $content and $args.
  714.          * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  715.          */
  716.         function editor_sub_element( $params )
  717.         {
  718.             $default = array();
  719.             $locked = array();
  720.             $attr = $params['args'];
  721.             Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode_nested'][0], $default, $locked );
  722.  
  723.             $template = $this->update_template_lockable( 'title', __( 'Element', 'avia_framework' ). ': {{title}}', $locked );
  724.  
  725.             extract( av_backend_icon( array( 'args' => $attr ) ) ); // creates $font and $display_char if the icon was passed as param 'icon' and the font as 'font'
  726.  
  727.             $params['innerHtml']  = '';
  728.             $params['innerHtml'] .=     "<div class='avia_title_container' data-update_element_template='yes'>";
  729.             $params['innerHtml'] .=         '<span ' . $this->class_by_arguments_lockable( 'font', $font, $locked ) . '>';
  730.             $params['innerHtml'] .=             '<span ' . $this->update_option_lockable( array( 'icon', 'icon_fakeArg' ), $locked ) . " class='avia_tab_icon'>{$display_char}</span>";
  731.             $params['innerHtml'] .=         '</span>';
  732.             $params['innerHtml'] .=         "<span {$template} >" . __( 'Element', 'avia_framework' ) . ": {$attr['title']}</span>";
  733.             $params['innerHtml'] .=     '</div>';
  734.            
  735.             return $params;
  736.         }
  737.  
  738.  
  739.  
  740.         /**
  741.          * Frontend Shortcode Handler
  742.          *
  743.          * @param array $atts array of attributes
  744.          * @param string $content text within enclosing form of shortcode element
  745.          * @param string $shortcodename the shortcode found, when == callback name
  746.          * @return string $output returns the modified html string
  747.          */
  748.         function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' )
  749.         {
  750.             $default = array(
  751.                         'position'              => 'left',
  752.                         'color'                 => '',
  753.                         'custom_bg'             => '',
  754.                         'custom_border'         => '',
  755.                         'custom_font'           => '',
  756.                         'font_color'            => '',
  757.                         'custom_title'          => '',
  758.                         'custom_content'        => '',
  759.                         'custom_title_size'     => '',
  760.                         'custom_content_size'   => '',
  761.                         'iconlist_styling'      => '',
  762.                         'animation'             => ''
  763.                     );
  764.            
  765.             $locked = array();
  766.             Avia_Element_Templates()->set_locked_attributes( $atts, $this, $shortcodename, $default, $locked, $content );
  767.             Avia_Element_Templates()->add_template_class( $meta, $atts, $default );
  768.            
  769.            
  770.             $this->screen_options = AviaHelper::av_mobile_sizes( $atts );
  771.             extract( $this->screen_options ); //return $av_font_classes, $av_title_font_classes and $av_display_classes
  772.            
  773.             extract( shortcode_atts( $default, $atts, $this->config['shortcode'] ) );
  774.                
  775.            
  776.  
  777.             $this->icon_html_styling = '';
  778.             $this->title_styling = '';
  779.             $this->content_styling = '';
  780.             $this->content_class = '';
  781.             $this->title_class = '';
  782.            
  783.             $this->iconlist_styling = $iconlist_styling == 'av-iconlist-small' ? 'av-iconlist-small' : 'av-iconlist-big';
  784.                
  785.             if( $color == 'custom' )
  786.             {
  787.                 $this->icon_html_styling .= ! empty( $custom_bg ) ? "background-color:{$custom_bg}; " : '';
  788.                 $this->icon_html_styling .= ! empty( $custom_border ) ? "border:1px solid {$custom_border}; " : '';
  789.                 $this->icon_html_styling .= ! empty( $custom_font ) ? "color:{$custom_font}; " : '';
  790.             }
  791.                
  792.             if( $font_color == 'custom' )
  793.             {
  794.                 $this->title_styling .= ! empty( $custom_title ) ? "color:{$custom_title}; " : '';
  795.                 $this->content_styling .= ! empty( $custom_content ) ? "color:{$custom_content}; " : '';
  796.  
  797.                 if( $this->content_styling )    
  798.                 {
  799.                     $this->content_class = 'av_inherit_color';
  800.                 }
  801.  
  802.                 if( $this->title_styling )
  803.                 {
  804.                     $this->title_class = 'av_inherit_color';
  805.                 }
  806.  
  807.             }
  808.                
  809.             if( $custom_title_size )
  810.             {
  811.                 $this->title_styling .= "font-size:{$custom_title_size}px; ";
  812.                 if( $this->iconlist_styling  == 'av-iconlist-small' )
  813.                 {
  814.                     $this->icon_html_styling .= "font-size:{$custom_title_size}px; ";
  815.                 }
  816.             }
  817.                
  818.             if( $custom_content_size )
  819.             {
  820.                 $this->content_styling .= "font-size:{$custom_content_size}px; ";
  821.             }
  822.                
  823.                
  824.             if( $this->icon_html_styling )
  825.             {
  826.                 $this->icon_html_styling = " style='{$this->icon_html_styling}'";
  827.             }
  828.            
  829.             if( $this->title_styling )  
  830.             {  
  831.                 $this->title_styling = " style='{$this->title_styling}'";
  832.             }
  833.            
  834.             if( $this->content_styling )
  835.             {
  836.                 $this->content_styling = " style='{$this->content_styling}'";
  837.             }
  838.  
  839.  
  840.             // animation
  841.             $animation_class = '';
  842.             if( $animation == '' )
  843.             {
  844.                 $animation_class = 'avia-iconlist-animate';
  845.             }
  846.  
  847.             $aria_label = ! empty( $meta['aria_label'] ) ? " aria-label='{$meta['aria_label']}' " : ''; // added       
  848.             $output  =  '';
  849.             $output .=  "<div {$meta['custom_el_id']} class='avia-icon-list-container {$av_display_classes} {$meta['el_class']} {$aria_label}'>";
  850.             $output .=      "<ul class='avia-icon-list avia-icon-list-{$position} {$this->iconlist_styling} avia_animate_when_almost_visible {$animation_class}'>";
  851.             $output .=          ShortcodeHelper::avia_remove_autop( $content, true );
  852.             $output .=      '</ul>';
  853.             $output .=  '</div>';
  854.  
  855.  
  856.             return $output;
  857.         }
  858.  
  859.         /**
  860.          * Shortcode Handler
  861.          *
  862.          * @param array $atts
  863.          * @param string $content
  864.          * @param string $shortcodename
  865.          * @return string
  866.          */
  867.         public function av_iconlist_item( $atts, $content = '', $shortcodename = '' )
  868.         {
  869.             /**
  870.              * Fixes a problem when 3-rd party plugins call nested shortcodes without executing main shortcode  (like YOAST in wpseo-filter-shortcodes)
  871.              */
  872.             if( empty( $this->screen_options ) )
  873.             {
  874.                 return '';
  875.             }
  876.            
  877.             $default = array(
  878.                         'title'         => '',
  879.                         'link'          => '',
  880.                         'icon'          => '',
  881.                         'font'          => '',
  882.                         'linkelement'   => '',
  883.                         'linktarget'    => '',
  884.                         'custom_markup' => '',
  885.                     );
  886.  
  887.             $locked = array();
  888.             Avia_Element_Templates()->set_locked_attributes( $atts, $this, $this->config['shortcode_nested'][0], $default, $locked, $content );
  889.             $meta = aviaShortcodeTemplate::set_frontend_developer_heading_tag( $atts );
  890.             $aria_label = ! empty( $atts['aria_label'] ) ? " aria-label='{$atts['aria_label']}' " : ''; // added
  891.  
  892.             $atts = shortcode_atts( $default, $atts, 'av_iconlist_item' );
  893.  
  894.             extract( $this->screen_options ); //return $av_font_classes, $av_title_font_classes and $av_display_classes
  895.            
  896.  
  897.             $display_char = av_icon( $atts['icon'], $atts['font'] );
  898.             $display_char_wrapper = array();
  899.  
  900.             $blank = AviaHelper::get_link_target( $atts['linktarget'] );
  901.             if( ! empty( $atts['link'] ) )
  902.             {
  903.                 $atts['link'] = AviaHelper::get_url( $atts['link'] );
  904.  
  905.                 if( ! empty( $atts['link'] ) )
  906.                 {
  907.                     $linktitle = $atts['title'];
  908.  
  909.                     switch( $atts['linkelement'] )
  910.                     {
  911.                         case 'both':
  912.                             if( $atts['title'] )
  913.                             {
  914.                                 $atts['title'] = "<a href='{$atts['link']}' title='" . esc_attr( $linktitle ) . "'{$blank}>{$linktitle}</a>";
  915.                             }
  916.                            
  917.                             $display_char_wrapper['start'] = "a href='{$atts['link']}' title='" . esc_attr( $linktitle ) . "' {$blank}";
  918.                             $display_char_wrapper['end'] = 'a';
  919.                             break;
  920.                         case 'only_icon':
  921.                             $display_char_wrapper['start'] = "a href='{$atts['link']}' title='" . esc_attr( $linktitle ) . "' {$blank}";
  922.                             $display_char_wrapper['end'] = 'a';
  923.                             break;
  924.                         default:
  925.                             if( $atts['title'] )
  926.                             {
  927.                                 $atts['title'] = "<a href='{$atts['link']}' title='" . esc_attr( $linktitle) . "'{$blank}>{$linktitle}</a>";
  928.                             }
  929.                            
  930.                             $display_char_wrapper['start'] = 'div';
  931.                             $display_char_wrapper['end'] = 'div';
  932.                             break;
  933.                     }
  934.                 }
  935.             }
  936.  
  937.             if( empty( $display_char_wrapper ) )
  938.             {
  939.                 $display_char_wrapper['start'] = 'div';
  940.                 $display_char_wrapper['end'] = 'div';
  941.             }
  942.  
  943.             $contentClass = '';
  944.             if( trim( $content ) == '' )
  945.             {
  946.                 $contentClass = 'av-iconlist-empty';
  947.             }
  948.                
  949.             $default_heading = ( $this->iconlist_styling == 'av-iconlist-small' ) ? 'div' : 'h4';
  950.             $default_heading = ! empty( $meta['heading_tag'] ) ? $meta['heading_tag'] : $default_heading;
  951.            
  952.             $args = array(
  953.                         'heading'       => $default_heading,
  954.                         'extra_class'   => $meta['heading_class']
  955.                     );
  956.  
  957.             $extra_args = array( $this, $atts, $content, $shortcodename );
  958.  
  959.             /**
  960.              * @since 4.5.7.2
  961.              * @return array
  962.              */
  963.             $args = apply_filters( 'avf_customize_heading_settings', $args, __CLASS__, $extra_args );
  964.  
  965.             $heading = ! empty( $args['heading'] ) ? $args['heading'] : $default_heading;
  966.             $css = ! empty( $args['extra_class'] ) ? $args['extra_class'] : $meta['heading_class'];
  967.  
  968.             $title_el = $heading;
  969.             $iconlist_title = ( $this->iconlist_styling == 'av-iconlist-small' ) ? '_small' : '';
  970.  
  971.             $output  = '';
  972.             $output .= '<li>';
  973.             $output .=      "<{$display_char_wrapper['start']} {$this->icon_html_styling} class='iconlist_icon  avia-font-".$atts['font']."'><span class='iconlist-char ' {$display_char}></span></{$display_char_wrapper['end']}>";
  974.             $output .=          '<article class="article-icon-entry '.$contentClass.'" '.avia_markup_helper(array('context' => 'entry','echo'=>false, 'custom_markup'=>$atts['custom_markup'])).'data-test="test" '.$aria_label.'>';
  975.             $output .=              "<div class='iconlist_content_wrap'>";
  976.             $output .=                  '<header class="entry-content-header">';
  977.  
  978.             $markup = avia_markup_helper( array( 'context' => 'entry_title', 'echo' => false, 'custom_markup' => $atts['custom_markup'] ) );
  979.             if( ! empty( $atts['title'] ) )
  980.             {
  981.                 $output .=                  "<{$title_el} class='av_iconlist_title iconlist_title{$iconlist_title} {$css} {$this->title_class} {$av_title_font_classes}' {$markup} {$this->title_styling}>".$atts['title']."</{$title_el}>";
  982.             }
  983.             $output .=                  '</header>';
  984.  
  985.             $markup = avia_markup_helper( array( 'context' => 'entry_content', 'echo' => false, 'custom_markup' => $atts['custom_markup'] ) );
  986.             $output .=                  "<div class='iconlist_content {$this->content_class} {$av_font_classes}' {$markup} {$this->content_styling}>" . ShortcodeHelper::avia_apply_autop( ShortcodeHelper::avia_remove_autop( $content ) ) . '</div>';
  987.             $output .=              '</div>';
  988.             $output .=              '<footer class="entry-footer"></footer>';
  989.             $output .=          '</article>';
  990.             $output .=      "<div class='iconlist-timeline'></div>";
  991.             $output .= '</li>';
  992.  
  993.             return $output;
  994.         }
  995.  
  996.     }
  997. }
  998.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement