cipher87

Iconbox with aria-label

Apr 10th, 2021
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 24.46 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Icon Box
  4.  *
  5.  * Shortcode which creates a content block with icon to the left or above
  6.  * Thread: https://kriesi.at/support/topic/add-aria-label-to-post-slider/
  7.  */
  8. if ( ! defined( 'ABSPATH' ) ) {  exit;  }    // Exit if accessed directly
  9.  
  10.  
  11. if ( ! class_exists( 'avia_sc_icon_box' ) )
  12. {
  13.     class avia_sc_icon_box extends aviaShortcodeTemplate
  14.     {
  15.         /**
  16.          * Create the config array for the shortcode button
  17.          */
  18.         function shortcode_insert_button()
  19.         {
  20.             $this->config['version']        = '1.0';
  21.             $this->config['self_closing']   = 'no';
  22.             $this->config['base_element']   = 'yes';
  23.  
  24.             $this->config['name']           = __( 'Icon Box', 'avia_framework' );
  25.             $this->config['tab']            = __( 'Content Elements', 'avia_framework' );
  26.             $this->config['icon']           = AviaBuilder::$path['imagesURL'] . 'sc-icon_box.png';
  27.             $this->config['order']          = 90;
  28.             $this->config['target']         = 'avia-target-insert';
  29.             $this->config['shortcode']      = 'av_icon_box';
  30.             $this->config['tooltip']        = __( 'Creates a content block with icon to the left or above', 'avia_framework' );
  31.             $this->config['preview']        = 1;
  32.             $this->config['disabling_allowed'] = true;
  33.             $this->config['id_name']        = 'id';
  34.             $this->config['id_show']        = 'yes';
  35.             $this->config['aria_label']     = 'yes'; // added
  36.         }
  37.  
  38.         function extra_assets()
  39.         {
  40.             wp_enqueue_style( 'avia-module-icon', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/icon/icon.css', array( 'avia-layout' ), false );
  41.             wp_enqueue_style( 'avia-module-iconbox', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/iconbox/iconbox.css', array( 'avia-layout' ), false );
  42.         }
  43.  
  44.  
  45.         /**
  46.          * Popup Elements
  47.          *
  48.          * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  49.          * opens a modal window that allows to edit the element properties
  50.          *
  51.          * @return void
  52.          */
  53.         function popup_elements()
  54.         {
  55.             $this->elements = array(
  56.                    
  57.                 array(
  58.                         'type'  => 'tab_container',
  59.                         'nodescription' => true
  60.                     ),
  61.                        
  62.                 array(
  63.                         'type'  => 'tab',
  64.                         'name'  => __( 'Content', 'avia_framework' ),
  65.                         'nodescription' => true
  66.                     ),
  67.                
  68.                     array(
  69.                             'type'          => 'template',
  70.                             'template_id'   => $this->popup_key( 'content_iconbox' )
  71.                         ),
  72.                
  73.                 array(
  74.                         'type'  => 'tab_close',
  75.                         'nodescription' => true
  76.                     ),
  77.                
  78.                 array(
  79.                         'type'  => 'tab',
  80.                         'name'  => __( 'Styling', 'avia_framework' ),
  81.                         'nodescription' => true
  82.                     ),
  83.                
  84.                     array(
  85.                             'type'          => 'template',
  86.                             'template_id'   => 'toggle_container',
  87.                             'templates_include' => array(
  88.                                                     $this->popup_key( 'styling_general' ),
  89.                                                     $this->popup_key( 'styling_colors' ),
  90.                                                     $this->popup_key( 'styling_font_sizes' ),
  91.                                                 ),
  92.                             'nodescription' => true
  93.                         ),
  94.                
  95.                 array(
  96.                         'type'  => 'tab_close',
  97.                         'nodescription' => true
  98.                     ),
  99.                
  100.                 array(
  101.                         'type'  => 'tab',
  102.                         'name'  => __( 'Advanced', 'avia_framework' ),
  103.                         'nodescription' => true
  104.                     ),
  105.                
  106.                     array(
  107.                             'type'  => 'toggle_container',
  108.                             'nodescription' => true
  109.                         ),
  110.                
  111.                         array(
  112.                                 'type'          => 'template',
  113.                                 'template_id'   => $this->popup_key( 'advanced_heading' ),
  114.                                 'nodescription' => true
  115.                             ),
  116.                
  117.                         array(
  118.                                 'type'          => 'template',
  119.                                 'template_id'   => $this->popup_key( 'advanced_link' ),
  120.                                 'nodescription' => true
  121.                             ),
  122.                
  123.                         array( 
  124.                                 'type'          => 'template',
  125.                                 'template_id'   => 'screen_options_toggle',
  126.                                 'lockable'      => true
  127.                             ),
  128.  
  129.                         array( 
  130.                                 'type'          => 'template',
  131.                                 'template_id'   => 'developer_options_toggle',
  132.                                 'args'          => array( 'sc' => $this )
  133.                             ),
  134.                
  135.                     array(
  136.                             'type'  => 'toggle_container_close',
  137.                             'nodescription' => true
  138.                         ),
  139.                
  140.                 array(
  141.                         'type'  => 'tab_close',
  142.                         'nodescription' => true
  143.                     ),
  144.                
  145.                 array( 
  146.                         'type'          => 'template',
  147.                         'template_id'   => 'element_template_selection_tab',
  148.                         'args'          => array( 'sc' => $this )
  149.                     ),
  150.  
  151.                 array(
  152.                         'type'  => 'tab_container_close',
  153.                         'nodescription' => true
  154.                     )
  155.                    
  156.                 );
  157.  
  158.         }
  159.        
  160.         /**
  161.          * Create and register templates for easier maintainance
  162.          *
  163.          * @since 4.6.4
  164.          */
  165.         protected function register_dynamic_templates()
  166.         {
  167.            
  168.             /**
  169.              * Content Tab
  170.              * ===========
  171.              */
  172.            
  173.             $c = array(
  174.                         array(
  175.                             'name'  => __( 'IconBox Icon', 'avia_framework' ),
  176.                             'desc'  => __( 'Select an IconBox Icon below', 'avia_framework' ),
  177.                             'id'    => 'icon',
  178.                             'type'  => 'iconfont',
  179.                             'std'   => '',
  180.                             'lockable'  => true,
  181.                             'locked'    => array( 'icon', 'font' )
  182.                         ),
  183.                
  184.                         array(
  185.                             'name'  => __( 'Title', 'avia_framework' ),
  186.                             'desc'  => __( 'Add an IconBox title here', 'avia_framework' ),
  187.                             'id'    => 'title',
  188.                             'type'  => 'input',
  189.                             'std'   => __( 'IconBox Title', 'avia_framework' ),
  190.                             'lockable'  => true
  191.                         ),
  192.                
  193.                         array(
  194.                             'name'  => __( 'Content', 'avia_framework' ),
  195.                             'desc'  => __( 'Add some content for this IconBox', 'avia_framework' ),
  196.                             'id'    => 'content',
  197.                             'type'  => 'tiny_mce',
  198.                             'std'   => __( 'Click to add your own text here', 'avia_framework' ),
  199.                             'lockable'  => true
  200.                         )
  201.                 );
  202.            
  203.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_iconbox' ), $c );
  204.            
  205.             /**
  206.              * Styling Tab
  207.              * ============
  208.              */
  209.            
  210.             $c = array(
  211.                         array(
  212.                             'name'  => __( 'IconBox Styling', 'avia_framework' ),
  213.                             'desc'  => __( 'Defines the styling of the iconbox and the position of the icon', 'avia_framework' ),
  214.                             'id'    => 'position',
  215.                             'type'  => 'select',
  216.                             'std'   => 'left',
  217.                             'lockable'  => true,
  218.                             'subtype'   => array(
  219.                                                 __( 'Display small icon at the left side of the title', 'avia_framework' )          => 'left',
  220.                                                 __( 'Display icon at the left side of the whole content block', 'avia_framework' )  => 'left_content',
  221.                                                 __( 'Display icon at the right side of the whole content block', 'avia_framework' ) => 'right_content',
  222.                                                 __( 'Display icon above the title', 'avia_framework' )                              => 'top'
  223.                                             )
  224.                         ),
  225.    
  226.                         array(
  227.                             'name'  => __( 'Icon display', 'avia_framework' ),
  228.                             'desc'  => __( 'Select how to display the icon beside your content', 'avia_framework' ),
  229.                             'id'    => 'icon_style',
  230.                             'type'  => 'select',
  231.                             'std'   => '',
  232.                             'lockable'  => true,
  233.                             'required'  => array( 'position', 'contains','content' ),
  234.                             'subtype'   => array(
  235.                                                 __( 'Small with border', 'avia_framework' )     => '',
  236.                                                 __( 'Big without border', 'avia_framework' )    => 'av-icon-style-no-border',
  237.                                             )
  238.                         ),
  239.                    
  240.                         array(
  241.                             'name'  => __( 'Content block', 'avia_framework' ),
  242.                             'desc'  => __( 'Select if the iconbox should receive a border around the content', 'avia_framework' ),
  243.                             'id'    => 'boxed',
  244.                             'type'  => 'select',
  245.                             'std'   => '',
  246.                             'lockable'  => true,
  247.                             'required'  => array( 'position', 'equals', 'top' ),
  248.                             'subtype'   => array(
  249.                                                 __( 'Boxed content block with borders', 'avia_framework' )  => '',
  250.                                                 __( 'No box around content', 'avia_framework' )         => 'av-no-box',
  251.                                             )
  252.                         ),
  253.                    
  254.                 );
  255.            
  256.             $template = array(
  257.                             array( 
  258.                                 'type'          => 'template',
  259.                                 'template_id'   => 'toggle',
  260.                                 'title'         => __( 'General Styling', 'avia_framework' ),
  261.                                 'content'       => $c
  262.                             ),
  263.                 );
  264.            
  265.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_general' ), $template );
  266.            
  267.             $c = array(
  268.                         array(
  269.                             'name'  => __( 'Font Colors', 'avia_framework' ),
  270.                             'desc'  => __( 'Either use the themes default colors or apply some custom ones', 'avia_framework' ),
  271.                             'id'    => 'font_color',
  272.                             'type'  => 'select',
  273.                             'std'   => '',
  274.                             'lockable'  => true,
  275.                             'subtype'   => array(
  276.                                                 __( 'Default', 'avia_framework' )               => '',
  277.                                                 __( 'Define Custom Colors', 'avia_framework' )  => 'custom'),
  278.                         ),
  279.                    
  280.                         array( 
  281.                             'name'  => __( 'Custom Title Font Color', 'avia_framework' ),
  282.                             'desc'  => __( 'Select a custom font color. Leave empty to use the default', 'avia_framework' ),
  283.                             'id'    => 'custom_title',
  284.                             'type'  => 'colorpicker',
  285.                             'std'   => '',
  286.                             'container_class' => 'av_half av_half_first',
  287.                             'lockable'  => true,
  288.                             'required'  => array( 'font_color', 'equals', 'custom' )
  289.                         ), 
  290.                        
  291.                         array( 
  292.                             'name'  => __( 'Custom Content Font Color', 'avia_framework' ),
  293.                             'desc'  => __( 'Select a custom font color. Leave empty to use the default', 'avia_framework' ),
  294.                             'id'    => 'custom_content',
  295.                             'type'  => 'colorpicker',
  296.                             'std'   => '',
  297.                             'container_class' => 'av_half',
  298.                             'lockable'  => true,
  299.                             'required'  => array( 'font_color', 'equals', 'custom' )
  300.                         ),
  301.                
  302.                         array(
  303.                             'name'  => __( 'Icon Colors', 'avia_framework' ),
  304.                             'desc'  => __( 'Either use the themes default colors or apply some custom ones', 'avia_framework' ),
  305.                             'id'    => 'color',
  306.                             'type'  => 'select',
  307.                             'std'   => '',
  308.                             'lockable'  => true,
  309.                             'subtype'   => array(
  310.                                                 __( 'Default', 'avia_framework' )               => '',
  311.                                                 __( 'Define Custom Colors', 'avia_framework' )  => 'custom'),                      
  312.                         ),
  313.                    
  314.                         array( 
  315.                             'name'  => __( 'Custom Background Color', 'avia_framework' ),
  316.                             'desc'  => __( 'Select a custom background color. Leave empty to use the default', 'avia_framework' ),
  317.                             'id'    => 'custom_bg',
  318.                             'type'  => 'colorpicker',
  319.                             'std'   => '',
  320.                             'container_class' => 'av_third av_third_first',
  321.                             'lockable'  => true,
  322.                             'required'  => array( 'color', 'equals', 'custom' )
  323.                         ), 
  324.  
  325.                         array( 
  326.                             'name'  => __( 'Custom Font Color', 'avia_framework' ),
  327.                             'desc'  => __( 'Select a custom font color. Leave empty to use the default', 'avia_framework' ),
  328.                             'id'    => 'custom_font',
  329.                             'type'  => 'colorpicker',
  330.                             'std'   => '',
  331.                             'container_class' => 'av_third',
  332.                             'lockable'  => true,
  333.                             'required'  => array( 'color', 'equals', 'custom' )
  334.                         ), 
  335.  
  336.                         array( 
  337.                             'name'  => __( 'Custom Border Color', 'avia_framework' ),
  338.                             'desc'  => __( 'Select a custom border color. Leave empty to use the default', 'avia_framework' ),
  339.                             'id'    => 'custom_border',
  340.                             'type'  => 'colorpicker',
  341.                             'std'   => '',
  342.                             'container_class' => 'av_third',
  343.                             'lockable'  => true,
  344.                             'required'  => array( 'color', 'equals', 'custom' )
  345.                         )
  346.                 );
  347.            
  348.             $template = array(
  349.                             array( 
  350.                                 'type'          => 'template',
  351.                                 'template_id'   => 'toggle',
  352.                                 'title'         => __( 'Colors', 'avia_framework' ),
  353.                                 'content'       => $c
  354.                             ),
  355.                 );
  356.            
  357.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_colors' ), $template );
  358.            
  359.             $c = array(
  360.                         array(
  361.                             'name'          => __( 'Title Font Sizes', 'avia_framework' ),
  362.                             'desc'          => __( 'Select a custom font size for the title. Using non default values might need CSS styling.', 'avia_framework' ),
  363.                             'type'          => 'template',
  364.                             'template_id'   => 'font_sizes_icon_switcher',
  365.                             'lockable'      => true,
  366.                             'subtype'       => array(
  367.                                                 'default'   => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  368.                                                 'medium'    => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  369.                                                 'small'     => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  370.                                                 'mini'      => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' )
  371.                                             ),
  372.                             'id_sizes'      => array(
  373.                                                 'default'   => 'custom_title_size',
  374.                                                 'medium'    => 'av-medium-font-size-title',
  375.                                                 'small'     => 'av-small-font-size-title',
  376.                                                 'mini'      => 'av-mini-font-size-title'
  377.                                             )
  378.                         ),
  379.                
  380.                         array(
  381.                             'name'          => __( 'Content Font Sizes', 'avia_framework' ),
  382.                             'desc'          => __( 'Select a custom font size for the content.', 'avia_framework' ),
  383.                             'type'          => 'template',
  384.                             'template_id'   => 'font_sizes_icon_switcher',
  385.                             'lockable'      => true,
  386.                             'subtype'       => array(
  387.                                                 'default'   => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  388.                                                 'medium'    => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  389.                                                 'small'     => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  390.                                                 'mini'      => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' )
  391.                                             ),
  392.                             'id_sizes'      => array(
  393.                                                 'default'   => 'custom_content_size',
  394.                                                 'medium'    => 'av-medium-font-size',
  395.                                                 'small'     => 'av-small-font-size',
  396.                                                 'mini'      => 'av-mini-font-size'
  397.                                             )
  398.                         ),
  399.                
  400.                 );
  401.            
  402.             $template = array(
  403.                             array( 
  404.                                 'type'          => 'template',
  405.                                 'template_id'   => 'toggle',
  406.                                 'title'         => __( 'Font Sizes', 'avia_framework' ),
  407.                                 'content'       => $c
  408.                             ),
  409.                 );
  410.            
  411.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_font_sizes' ), $template );
  412.        
  413.            
  414.             /**
  415.              * Advanced Tab
  416.              * ============
  417.              */
  418.            
  419.             $c = array(
  420.                         array( 
  421.                             'type'              => 'template',
  422.                             'template_id'       => 'heading_tag',
  423.                             'theme_default'     => 'h3',
  424.                             'context'           => __CLASS__,
  425.                             'lockable'          => true
  426.                         ),
  427.                
  428.                 );
  429.            
  430.             $template = array(
  431.                             array( 
  432.                                 'type'          => 'template',
  433.                                 'template_id'   => 'toggle',
  434.                                 'title'         => __( 'Heading', 'avia_framework' ),
  435.                                 'content'       => $c
  436.                             ),
  437.                 );
  438.            
  439.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_heading' ), $template );
  440.            
  441.             $c = array(
  442.                         array( 
  443.                             'type'          => 'template',
  444.                             'template_id'   => 'linkpicker_toggle',
  445.                             'name'          => __( 'Title Link?', 'avia_framework' ),
  446.                             'desc'          => __( 'Do you want to apply a link to the title?', 'avia_framework' ),
  447.                             'lockable'      => true,
  448.                             'subtypes'      => array( 'no', 'manually', 'single', 'taxonomy' ),
  449.                             'no_toggle'     => true
  450.                         ),
  451.                
  452.                          array(
  453.                             'name'  => __( 'Apply link to icon', 'avia_framework' ),
  454.                             'desc'  => __( 'Do you want to apply the link to the icon?', 'avia_framework' ),
  455.                             'id'    => 'linkelement',
  456.                             'type'  => 'select',
  457.                             'std'   => '',
  458.                             'lockable'  => true,
  459.                             'required'  => array( 'link', 'not', '' ),
  460.                             'subtype'   => array(
  461.                                                 __( 'No, apply link to the title', 'avia_framework' )       => '',
  462.                                                 __( 'Yes, apply link to icon and title', 'avia_framework' ) => 'both',
  463.                                                 __( 'Yes, apply link to icon only', 'avia_framework' )      => 'only_icon'
  464.                         )
  465.                     ),
  466.                
  467.                 );
  468.            
  469.             $template = array(
  470.                             array( 
  471.                                 'type'          => 'template',
  472.                                 'template_id'   => 'toggle',
  473.                                 'title'         => __( 'Link Settings', 'avia_framework' ),
  474.                                 'content'       => $c
  475.                             ),
  476.                 );
  477.            
  478.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_link' ), $template );
  479.            
  480.            
  481.         }
  482.                
  483.  
  484.         /**
  485.          * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  486.          * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  487.          * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  488.          *
  489.          *
  490.          * @param array $params this array holds the default values for $content and $args.
  491.          * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  492.          */
  493.         function editor_element( $params )
  494.         {
  495.             $default = array();
  496.             $locked = array();
  497.             $attr = $params['args'];
  498.             $content = $params['content'];
  499.             Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode'], $default, $locked, $content );
  500.            
  501.             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'
  502.  
  503.             $inner  = "<div class='avia_iconbox avia_textblock avia_textblock_style' data-update_element_template='yes'>";
  504.             $inner .=       '<div ' . $this->class_by_arguments_lockable( 'position', $attr, $locked ) . '>';
  505.             $inner .=           '<span ' . $this->class_by_arguments_lockable( 'font', $font, $locked ) . '>';
  506.             $inner .=               '<span ' . $this->update_option_lockable( array( 'icon', 'icon_fakeArg' ), $locked ) . " class='avia_iconbox_icon'>{$display_char}</span>";
  507.             $inner .=           "</span>";
  508.             $inner .=           "<div class='avia_iconbox_content_wrap'>";
  509.             $inner .=               "<h4 class='avia_iconbox_title' " . $this->update_option_lockable( 'title', $locked ) . '>' . html_entity_decode( $attr['title'] ) . '</h4>';
  510.             $inner .=               "<div class='avia_iconbox_content' " . $this->update_option_lockable( 'content', $locked ) . '>' . stripslashes( wpautop( trim( html_entity_decode( $content ) ) ) ) . '</div>';
  511.             $inner .=           '</div>';
  512.             $inner .=       '</div>';
  513.             $inner .= '</div>';
  514.  
  515.             $params['innerHtml'] = $inner;
  516.             $params['class'] = '';
  517.  
  518.             return $params;
  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.             $default = array(
  532.                         'title'         => 'Title',
  533.                         'icon'          => 'ue800',
  534.                         'position'      => 'left',
  535.                         'link'          => '',
  536.                         'linktarget'    => '',
  537.                         'linkelement'   => '',
  538.                         'font'          => '',
  539.                         'boxed'         => '',
  540.                         'color'         => '',
  541.                         'custom_bg'     => '',
  542.                         'custom_border' => '',
  543.                         'custom_font'   => '',
  544.                         'font_color'    => '',
  545.                         'custom_title'  => '',
  546.                         'icon_style'    => '',
  547.                         'custom_content'        => '',
  548.                         'custom_title_size'     => '',
  549.                         'custom_content_size'   => ''
  550.                     );
  551.            
  552.             $locked = array();
  553.             Avia_Element_Templates()->set_locked_attributes( $atts, $this, $shortcodename, $default, $locked, $content );
  554.             Avia_Element_Templates()->add_template_class( $meta, $atts, $default );
  555.             $meta = aviaShortcodeTemplate::set_frontend_developer_heading_tag( $atts, $meta );
  556.            
  557.             extract( AviaHelper::av_mobile_sizes( $atts ) ); //return $av_font_classes, $av_title_font_classes and $av_display_classes
  558.            
  559.             $atts = shortcode_atts( $default, $atts, $this->config['shortcode'] );
  560.             extract( $atts );
  561.  
  562.             $display_char = av_icon( $icon, $font );
  563.             $display_char_wrapper = array();
  564.  
  565.             if( $position == 'top' && empty( $boxed ) )
  566.             {
  567.                 $position .= ' main_color';
  568.             }
  569.            
  570.             if( $position != 'top' )
  571.             {
  572.                 $boxed = '';
  573.             }
  574.  
  575.             $link = AviaHelper::get_url( $link );
  576.             $blank = AviaHelper::get_link_target( $linktarget );
  577.  
  578.             if( ! empty( $link ) )
  579.             {
  580.                 $linktitle = $title;
  581.  
  582.                 switch( $linkelement )
  583.                 {
  584.                     case 'both':
  585.                         if( $title )
  586.                         {
  587.                             $title = "<a href='{$link}' title='" . esc_attr( $linktitle ) . "' $blank>$linktitle</a>";
  588.                         }
  589.                        
  590.                         $display_char_wrapper['start'] = "a href='{$link}' title='"  . esc_attr($linktitle) . "' {$blank}";
  591.                         $display_char_wrapper['end'] = 'a';
  592.                         break;
  593.                     case 'only_icon':
  594.                         $display_char_wrapper['start'] = "a href='{$link}' title='" . esc_attr($linktitle) . "' {$blank}";
  595.                         $display_char_wrapper['end'] = 'a';
  596.                         break;
  597.                     default:
  598.                         if( $title )
  599.                         {
  600.                             $title = "<a href='{$link}' title='" . esc_attr( $linktitle ) . "' {$blank} >$linktitle</a>";
  601.                         }
  602.                        
  603.                         $display_char_wrapper['start'] = 'div';
  604.                         $display_char_wrapper['end'] = 'div';
  605.                         break;
  606.                 }
  607.             }
  608.  
  609.  
  610.             if( empty( $display_char_wrapper ) )
  611.             {
  612.                 $display_char_wrapper['start'] = 'div';
  613.                 $display_char_wrapper['end'] = 'div';
  614.             }
  615.  
  616.             $icon_html_styling = '';
  617.             $title_styling = '';
  618.             $content_styling = '';
  619.             $content_class = '';
  620.  
  621.             if( $color == 'custom' )
  622.             {
  623.                 $icon_html_styling .= ! empty( $custom_bg ) ? "background-color:{$custom_bg}; " : '';
  624.                 $icon_html_styling .= ! empty( $custom_border ) ? "border:1px solid {$custom_border}; " : '';
  625.                 $icon_html_styling .= ! empty( $custom_font ) ? "color:{$custom_font}; " : '';
  626.             }
  627.  
  628.             if( $font_color == 'custom' )
  629.             {
  630.                 $title_styling .= ! empty( $custom_title ) ? "color:{$custom_title}; " : '';
  631.                 $content_styling .= ! empty( $custom_content ) ? "color:{$custom_content}; " : '';
  632.  
  633.                 if( ! empty( $content_styling ) )
  634.                 {
  635.                     $content_class   = 'av_inherit_color';
  636.                 }
  637.             }
  638.            
  639.             if( ! empty( $custom_title_size ) )
  640.             {
  641.                 $title_styling .= "font-size:{$custom_title_size}px; ";
  642.             }
  643.            
  644.             if( ! empty( $custom_content_size ) )
  645.             {
  646.                 $content_styling .= "font-size:{$custom_content_size}px; ";
  647.             }
  648.            
  649.             if( ! empty( $title_styling ) )
  650.             {
  651.                 $title_styling = " style='{$title_styling}'" ;
  652.             }
  653.            
  654.             if( ! empty( $icon_html_styling ) )
  655.             {
  656.                 $icon_html_styling = " style='{$icon_html_styling}'" ;
  657.             }
  658.            
  659.             if( ! empty( $content_styling ) )
  660.             {
  661.                 $content_styling = " style='{$content_styling}'" ;
  662.             }
  663.            
  664.             $meta['el_class'] .= ' ' . $icon_style;
  665.                
  666.             $icon_html = '<' . $display_char_wrapper['start'] . ' class="iconbox_icon heading-color" ' . $display_char . ' ' . $icon_html_styling . ' ></' . $display_char_wrapper['end'] . '>';
  667.  
  668.             // add blockquotes to the content
  669.             $markup = avia_markup_helper( array( 'context' => 'entry', 'echo' => false, 'custom_markup' => $meta['custom_markup'] ) );
  670.             $aria_label = ! empty( $meta['aria_label'] ) ? " aria-label='{$meta['aria_label']}' " : ''; // added
  671.             $output  = '<article ' . $meta['custom_el_id'] . ' class="iconbox iconbox_' . $position . ' ' . $boxed . ' ' . $av_display_classes . ' ' . $meta['el_class'] . '" ' . $markup . ' ' . $aria_label . '>';
  672.  
  673.             if( $position == 'left_content' || $position == 'right_content' )
  674.             {
  675.                 $output .= $icon_html;
  676.                 $icon_html = '';
  677.             }
  678.  
  679.             $output .=      '<div class="iconbox_content">';
  680.             $output .=          '<header class="entry-content-header">';
  681.             $output .=          $icon_html;
  682.  
  683.             $markup = avia_markup_helper( array( 'context' => 'entry_title', 'echo' => false, 'custom_markup' => $meta['custom_markup'] ) );
  684.  
  685.  
  686.             $default_heading = ! empty( $meta['heading_tag'] ) ? $meta['heading_tag'] : 'h3';
  687.             $args = array(
  688.                         'heading'       => $default_heading,
  689.                         'extra_class'   => $meta['heading_class']
  690.                     );
  691.  
  692.             $extra_args = array( $this, $atts, $content, 'title' );
  693.  
  694.             /**
  695.              * @since 4.5.5
  696.              * @return array
  697.              */
  698.             $args = apply_filters( 'avf_customize_heading_settings', $args, __CLASS__, $extra_args );
  699.  
  700.             $heading = ! empty( $args['heading'] ) ? $args['heading'] : $default_heading;
  701.             $css = ! empty( $args['extra_class'] ) ? $args['extra_class'] : $meta['heading_class'];
  702.  
  703.             if( $title )
  704.             {
  705.                 $output .=          "<{$heading} class='iconbox_content_title {$css} {$av_title_font_classes}' {$markup} {$title_styling}>{$title}</{$heading}>";
  706.             }
  707.             $output .=          '</header>';
  708.  
  709.             $markup = avia_markup_helper( array( 'context' => 'entry_content', 'echo' => false, 'custom_markup' => $meta['custom_markup'] ) );
  710.            
  711.             $output .=          "<div class='iconbox_content_container {$content_class} {$av_font_classes}' {$markup} {$content_styling}>";
  712.             $output .=              ShortcodeHelper::avia_apply_autop( ShortcodeHelper::avia_remove_autop( $content ) );
  713.             $output .=          '</div>';
  714.  
  715.             $output .=          '</div>';
  716.             $output .=      '<footer class="entry-footer"></footer>';
  717.             $output .= '</article>';
  718.  
  719.             return $output;
  720.         }
  721.  
  722.     }
  723. }
  724.  
Advertisement
Add Comment
Please, Sign In to add comment