Advertisement
cipher87

Heading - Subtext Link

Jun 27th, 2023
803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 33.38 KB | Source Code | 0 0
  1. <?php
  2. /**
  3.  * Special Heading
  4.  *
  5.  * Creates a special Heading
  6.  */
  7.  
  8. // Don't load directly
  9. if( ! defined( 'ABSPATH' ) ) { exit; }
  10.  
  11.  
  12.  
  13. if( ! class_exists( 'avia_sc_heading', false ) )
  14. {
  15.     class avia_sc_heading extends aviaShortcodeTemplate
  16.     {
  17.  
  18.         /**
  19.          * Create the config array for the shortcode button
  20.          */
  21.         protected function shortcode_insert_button()
  22.         {
  23.             $this->config['version']        = '1.0';
  24.             $this->config['self_closing']   = 'no';
  25.             $this->config['base_element']   = 'yes';
  26.  
  27.             $this->config['name']           = __( 'Special Heading', 'avia_framework' );
  28.             $this->config['tab']            = __( 'Content Elements', 'avia_framework' );
  29.             $this->config['icon']           = AviaBuilder::$path['imagesURL'] . 'sc-heading.png';
  30.             $this->config['order']          = 93;
  31.             $this->config['target']         = 'avia-target-insert';
  32.             $this->config['shortcode']      = 'av_heading';
  33.             $this->config['modal_data']     = array( 'modal_class' => 'mediumscreen' );
  34.             $this->config['tooltip']        = __( 'Creates a special Heading', 'avia_framework' );
  35.             $this->config['preview']        = true;
  36.             $this->config['disabling_allowed'] = true;
  37.             $this->config['id_name']        = 'id';
  38.             $this->config['id_show']        = 'yes';
  39.             $this->config['hide_desktop_fonts'] = 'block';
  40.         }
  41.  
  42.         protected function extra_assets()
  43.         {
  44.             $ver = Avia_Builder()->get_theme_version();
  45.             $min_css = avia_minify_extension( 'css' );
  46.  
  47.             //load css
  48.             wp_enqueue_style( 'avia-module-heading', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/heading/heading{$min_css}.css", array( 'avia-layout' ), $ver );
  49.         }
  50.  
  51.  
  52.         /**
  53.          * Popup Elements
  54.          *
  55.          * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  56.          * opens a modal window that allows to edit the element properties
  57.          *
  58.          * @return void
  59.          */
  60.         protected function popup_elements()
  61.         {
  62.  
  63.             $this->elements = array(
  64.  
  65.                 array(
  66.                         'type'  => 'tab_container',
  67.                         'nodescription' => true
  68.                     ),
  69.  
  70.                 array(
  71.                         'type'  => 'tab',
  72.                         'name'  => __( 'Content', 'avia_framework' ),
  73.                         'nodescription' => true
  74.                     ),
  75.  
  76.                     array(
  77.                             'type'          => 'template',
  78.                             'template_id'   => $this->popup_key( 'content_heading' )
  79.                         ),
  80.  
  81.                 array(
  82.                         'type'  => 'tab_close',
  83.                         'nodescription' => true
  84.                     ),
  85.  
  86.                 array(
  87.                         'type'  => 'tab',
  88.                         'name'  => __( 'Styling', 'avia_framework' ),
  89.                         'nodescription' => true
  90.                     ),
  91.  
  92.                     array(
  93.                             'type'          => 'template',
  94.                             'template_id'   => 'toggle_container',
  95.                             'templates_include' => array(
  96.                                                     $this->popup_key( 'styling_fonts' ),
  97.                                                     $this->popup_key( 'styling_colors' ),
  98.                                                     $this->popup_key( 'styling_spacing' )
  99.                                                 ),
  100.                             'nodescription' => true
  101.                         ),
  102.  
  103.                 array(
  104.                         'type'  => 'tab_close',
  105.                         'nodescription' => true
  106.                     ),
  107.  
  108.                 array(
  109.                         'type'  => 'tab',
  110.                         'name'  => __( 'Advanced', 'avia_framework' ),
  111.                         'nodescription' => true
  112.                     ),
  113.  
  114.                     array(
  115.                             'type'  => 'toggle_container',
  116.                             'nodescription' => true
  117.                         ),
  118.  
  119.                         array(
  120.                                 'type'          => 'template',
  121.                                 'template_id'   => $this->popup_key( 'advanced_link' )
  122.                             ),
  123.  
  124.                         array(
  125.                                 'type'          => 'template',
  126.                                 'template_id'   => 'screen_options_toggle',
  127.                                 'lockable'      => true
  128.                             ),
  129.  
  130.                         array(
  131.                                 'type'          => 'template',
  132.                                 'template_id'   => 'developer_options_toggle',
  133.                                 'args'          => array( 'sc' => $this )
  134.                             ),
  135.  
  136.                     array(
  137.                             'type'  => 'toggle_container_close',
  138.                             'nodescription' => true
  139.                         ),
  140.  
  141.                 array(
  142.                         'type'  => 'tab_close',
  143.                         'nodescription' => true
  144.                     ),
  145.  
  146.                 array(
  147.                         'type'          => 'template',
  148.                         'template_id'   => 'element_template_selection_tab',
  149.                         'args'          => array( 'sc' => $this )
  150.                     ),
  151.  
  152.                 array(
  153.                         'type'  => 'tab_container_close',
  154.                         'nodescription' => true
  155.                     )
  156.  
  157.                 );
  158.  
  159.         }
  160.  
  161.         /**
  162.          * Create and register templates for easier maintainance
  163.          *
  164.          * @since 4.6.4
  165.          */
  166.         protected function register_dynamic_templates()
  167.         {
  168.  
  169.             /**
  170.              * Content Tab
  171.              * ===========
  172.              */
  173.  
  174.             $c = array(
  175.                         array(
  176.                             'name'      => __( 'Heading Text', 'avia_framework' ),
  177.                             'id'        => 'heading',
  178.                             'type'      => 'input',
  179.                             'std'       => __( 'Hello', 'avia_framework' ),
  180.                             'container_class' => 'avia-element-fullwidth',
  181.                             'lockable'  => true,
  182.                             'tmpl_set_default'  => false
  183.                         ),
  184.  
  185.                         array(
  186.                             'name'      => __( 'Heading Type', 'avia_framework' ),
  187.                             'desc'      => __( 'Select which kind of heading you want to display.', 'avia_framework' ),
  188.                             'id'        => 'tag',
  189.                             'type'      => 'select',
  190.                             'std'       => 'h3',
  191.                             'lockable'  => true,
  192.                             'subtype'   => array( 'H1' => 'h1', 'H2' => 'h2', 'H3' => 'h3', 'H4' => 'h4', 'H5' => 'h5', 'H6' => 'h6' )
  193.                         ),
  194.  
  195.                         array(
  196.                             'name'      => __( 'Heading Style', 'avia_framework' ),
  197.                             'desc'      => __( 'Select a heading style', 'avia_framework' ),
  198.                             'id'        => 'style',
  199.                             'type'      => 'select',
  200.                             'std'       => '',
  201.                             'lockable'  => true,
  202.                             'subtype'   => array(
  203.                                                 __( 'Default Style', 'avia_framework' )                                     => '',
  204.                                                 __( 'Heading Style Modern (left)', 'avia_framework' )                       => 'blockquote modern-quote' ,
  205.                                                 __( 'Heading Style Modern (centered)', 'avia_framework' )                   => 'blockquote modern-quote modern-centered',
  206.                                                 __( 'Heading Style Modern (right)', 'avia_framework' )                      => 'blockquote modern-quote modern-right',
  207.                                                 __( 'Heading Style Classic (left, italic)', 'avia_framework' )              => 'blockquote classic-quote classic-quote-left',
  208.                                                 __( 'Heading Style Classic (centered, italic)', 'avia_framework' )          => 'blockquote classic-quote',
  209.                                                 __( 'Heading Style Classic (right, italic)', 'avia_framework' )             => 'blockquote classic-quote classic-quote-right',
  210.                                                 __( 'Heading Style Elegant (centered, optional icon)', 'avia_framework' )   => 'blockquote elegant-quote elegant-centered'
  211.                                             )
  212.                         ),
  213.  
  214.                         array(
  215.                             'name'  => __( 'Subheading', 'avia_framework' ),
  216.                             'desc'  => __( 'Add an extra descriptive subheading above or below the actual heading', 'avia_framework' ),
  217.                             'id'    => 'subheading_active',
  218.                             'type'  => 'select',
  219.                             'std'   => '',
  220.                             'lockable'  => true,
  221.                             'required'  => array( 'style', 'not', '' ),
  222.                             'subtype'   => array(
  223.                                                 __( 'No Subheading', 'avia_framework' )             => '',
  224.                                                 __( 'Display subheading above', 'avia_framework' )  => 'subheading_above',
  225.                                                 __( 'Display subheading below', 'avia_framework' )  => 'subheading_below'
  226.                                             )
  227.                             ),
  228.  
  229.                         array(
  230.                             'name'  => __( 'Subheading Text', 'avia_framework' ),
  231.                             'desc'  => __( 'Add your subheading here', 'avia_framework' ),
  232.                             'id'    => 'content',
  233.                             'type'  => 'textarea',
  234.                             'std'   => '',
  235.                             'lockable'  => true,
  236.                             'tmpl_set_default'  => false,
  237.                             'required'  => array( 'subheading_active', 'not', '' )
  238.                         ),
  239.  
  240.                         array(
  241.                             'name'  => __( 'Icon', 'avia_framework' ),
  242.                             'desc'  => __( 'Select to show an additional icon above headline', 'avia_framework' ),
  243.                             'id'    => 'show_icon',
  244.                             'type'  => 'select',
  245.                             'std'   => '',
  246.                             'lockable'  => true,
  247.                             'required' => array( 'style', 'equals', 'blockquote elegant-quote elegant-centered' ),
  248.                             'subtype'   => array(
  249.                                                 __( 'No Icon', 'avia_framework' )       => '',
  250.                                                 __( 'Display Icon', 'avia_framework' )  => 'custom_icon'
  251.                                             )
  252.                         ),
  253.  
  254.                         array(
  255.                             'name'  => __( 'Icon', 'avia_framework' ),
  256.                             'desc'  => __( 'Select an icon to display above the headline', 'avia_framework' ),
  257.                             'id'    => 'icon',
  258.                             'type'  => 'iconfont',
  259.                             'std'   => '',
  260.                             'lockable'  => true,
  261.                             'locked'    => array( 'icon', 'font' ),
  262.                             'required'  => array( 'show_icon', 'equals', 'custom_icon' )
  263.                         )
  264.  
  265.                 );
  266.  
  267.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_heading' ), $c );
  268.  
  269.             /**
  270.              * Styling Tab
  271.              * ===========
  272.              */
  273.  
  274.             $font_size_array = array(
  275.                         __( 'Default Size', 'avia_framework' ) => '',
  276.                         __( 'Flexible font size (adjusts to screen width)' , 'avia_framework' ) => AviaHtmlHelper::number_array( 3, 7, 0.5, array(), 'vw', '', 'vw' ),
  277.                         __( 'Fixed font size' , 'avia_framework' )                              => AviaHtmlHelper::number_array( 10, 150, 1, array(), 'px', '', '' )
  278.                     );
  279.  
  280.             $c = array(
  281.                         array(
  282.                             'name'          => __( 'Heading Font Sizes', 'avia_framework' ),
  283.                             'desc'          => __( 'Select a custom font size for the heading.', 'avia_framework' ),
  284.                             'type'          => 'template',
  285.                             'template_id'   => 'font_sizes_icon_switcher',
  286.                             'textfield'     => true,
  287.                             'hide_desktop'  => true,
  288.                             'lockable'      => true,
  289.                             'required'      => array( 'style', 'not', '' ),
  290.                             'subtype'       => array(
  291.                                                 'default'   => $font_size_array,
  292.                                                 'desktop'   => $font_size_array,
  293.                                                 'medium'    => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  294.                                                 'small'     => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  295.                                                 'mini'      => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' )
  296.                                             ),
  297.                             'id_sizes'      => array(
  298.                                                 'default'   => 'size',
  299.                                                 'desktop'   => 'av-desktop-font-size-title',
  300.                                                 'medium'    => 'av-medium-font-size-title',
  301.                                                 'small'     => 'av-small-font-size-title',
  302.                                                 'mini'      => 'av-mini-font-size-title'
  303.                                             )
  304.                         ),
  305.  
  306.                         array(
  307.                             'name'          => __( 'Subheading Font Sizes', 'avia_framework' ),
  308.                             'desc'          => __( 'Select a custom font size for the subheading.', 'avia_framework' ),
  309.                             'type'          => 'template',
  310.                             'template_id'   => 'font_sizes_icon_switcher',
  311.                             'textfield'     => true,
  312.                             'hide_desktop'  => true,
  313.                             'lockable'      => true,
  314.                             'required'      => array( 'subheading_active', 'not', '' ),
  315.                             'subtype'       => array(
  316.                                                 'default'   => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  317.                                                 'desktop'   => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  318.                                                 'medium'    => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  319.                                                 'small'     => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  320.                                                 'mini'      => AviaHtmlHelper::number_array( 10, 40, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' )
  321.                                             ),
  322.                             'id_sizes'      => array(
  323.                                                 'default'   => 'subheading_size',
  324.                                                 'desktop'   => 'av-desktop-font-size',
  325.                                                 'medium'    => 'av-medium-font-size',
  326.                                                 'small'     => 'av-small-font-size',
  327.                                                 'mini'      => 'av-mini-font-size'
  328.                                             )
  329.                         ),
  330.  
  331.                         array(
  332.                             'name'          => __( 'Icon Font Size', 'avia_framework' ),
  333.                             'desc'          => __( 'Select a custom font size for the icon', 'avia_framework' ),
  334.                             'type'          => 'template',
  335.                             'template_id'   => 'font_sizes_icon_switcher',
  336.                             'textfield'     => true,
  337.                             'hide_desktop'  => true,
  338.                             'lockable'      => true,
  339.                             'required'      => array( 'show_icon', 'equals', 'custom_icon' ),
  340.                             'subtype'       => array(
  341.                                                 'default'   => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  342.                                                 'desktop'   => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  343.                                                 'medium'    => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  344.                                                 'small'     => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  345.                                                 'mini'      => AviaHtmlHelper::number_array( 10, 120, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' )
  346.                                             ),
  347.                             'id_sizes'      => array(
  348.                                                 'default'   => 'icon_size',
  349.                                                 'desktop'   => 'av-desktop-font-size-1',
  350.                                                 'medium'    => 'av-medium-font-size-1',
  351.                                                 'small'     => 'av-small-font-size-1',
  352.                                                 'mini'      => 'av-mini-font-size-1'
  353.                                             )
  354.                         )
  355.  
  356.                 );
  357.  
  358.             $template = array(
  359.                             array(
  360.                                 'type'          => 'template',
  361.                                 'template_id'   => 'toggle',
  362.                                 'title'         => __( 'Font Sizes', 'avia_framework' ),
  363.                                 'content'       => $c
  364.                             ),
  365.                     );
  366.  
  367.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_fonts' ), $template );
  368.  
  369.             $c = array(
  370.                         array(
  371.                             'name'      => __( 'Heading Color', 'avia_framework' ),
  372.                             'desc'      => __( 'Select a heading color', 'avia_framework' ),
  373.                             'id'        => 'color',
  374.                             'type'      => 'select',
  375.                             'std'       => '',
  376.                             'lockable'  => true,
  377.                             'subtype'   => array(
  378.                                                 __( 'Default Color', 'avia_framework' ) => '',
  379.                                                 __( 'Meta Color', 'avia_framework' )    => 'meta-heading',
  380.                                                 __( 'Custom Color', 'avia_framework' )  => 'custom-color-heading'
  381.                                             )
  382.                             ),
  383.  
  384.                         array(
  385.                             'name'      => __( 'Custom Font Color', 'avia_framework' ),
  386.                             'desc'      => __( 'Select a custom font color for your Heading here', 'avia_framework' ),
  387.                             'id'        => 'custom_font',
  388.                             'type'      => 'colorpicker',
  389.                             'std'       => '',
  390.                             'rgba'      => true,
  391.                             'lockable'  => true,
  392.                             'required'  => array( 'color', 'equals', 'custom-color-heading' )
  393.                         ),
  394.  
  395.                         array(
  396.                             'name'      => __( 'Custom Subheading Color', 'avia_framework' ),
  397.                             'desc'      => __( 'Select a custom color for your subheading here', 'avia_framework' ),
  398.                             'id'        => 'subheading_color',
  399.                             'type'      => 'colorpicker',
  400.                             'std'       => '',
  401.                             'rgba'      => true,
  402.                             'lockable'  => true,
  403.                             'required'  => array( 'color', 'equals', 'custom-color-heading' )
  404.                         ),
  405.  
  406.                         array(
  407.                             'name'      => __( 'Custom Seperator Line Color', 'avia_framework' ),
  408.                             'desc'      => __( 'Select a custom color for the seperator line beside the title here (only available on some styles)', 'avia_framework' ),
  409.                             'id'        => 'seperator_color',
  410.                             'type'      => 'colorpicker',
  411.                             'std'       => '',
  412.                             'rgba'      => true,
  413.                             'lockable'  => true,
  414.                             'required'  => array( 'color', 'equals', 'custom-color-heading' )
  415.                         ),
  416.  
  417.                         array(
  418.                             'name'      => __( 'Custom Icon Color', 'avia_framework' ),
  419.                             'desc'      => __( 'Select a custom icon color for your Heading here', 'avia_framework' ),
  420.                             'id'        => 'icon_color',
  421.                             'type'      => 'colorpicker',
  422.                             'std'       => '',
  423.                             'rgba'      => true,
  424.                             'lockable'  => true,
  425.                             'required'  => array( 'color', 'equals', 'custom-color-heading' )
  426.                         )
  427.  
  428.                 );
  429.  
  430.             $template = array(
  431.                             array(
  432.                                 'type'          => 'template',
  433.                                 'template_id'   => 'toggle',
  434.                                 'title'         => __( 'Colors', 'avia_framework' ),
  435.                                 'content'       => $c
  436.                             ),
  437.                     );
  438.  
  439.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_colors' ), $template );
  440.  
  441.  
  442.             $c = array(
  443.                         array(
  444.                                 'type'          => 'template',
  445.                                 'template_id'   => 'margin_padding',
  446.                                 'name'          => '',
  447.                                 'desc'          => '',
  448.                                 'content'       => 'margin',
  449.                                 'name_margin'   => __( 'Element Margin', 'avia_framework' ),
  450.                                 'desc_margin'   => __( 'Set the margin to other elements here. Valid CSS units are accepted, eg: 30px, 5&percnt;. px is used as default unit.', 'avia_framework' ),
  451.                                 'id_margin'     => 'margin',
  452.                                 'lockable'      => true
  453.                         ),
  454.  
  455.                         array(
  456.                             'type'          => 'template',
  457.                             'template_id'   => 'margin_padding',
  458.                             'name'          => '',
  459.                             'desc'          => '',
  460.                             'content'       => 'padding',
  461.                             'name_padding'  => __( 'Headline Text (And Icon) Padding', 'avia_framework' ),
  462.                             'desc_padding'  => __( 'Set a distance around the headline text and a possible icon. Valid CSS units are accepted, eg: 30px, 5&percnt;. px is used as default unit.', 'avia_framework' ),
  463.                             'id_padding'    => 'headline_padding',
  464.                             'lockable'      => true
  465.                         ),
  466.  
  467.                         array(
  468.                             'type'          => 'template',
  469.                             'template_id'   => 'margin_padding',
  470.                             'name'          => '',
  471.                             'desc'          => '',
  472.                             'content'       => 'padding',
  473.                             'sync_padding'  => false,
  474.                             'name_padding'  => __( 'Element Bottom Padding', 'avia_framework' ),
  475.                             'desc_padding'  => __( 'Set the bottom padding for the element. Valid CSS units are accepted, eg: 30px, 5&percnt;. px is used as default unit.', 'avia_framework' ),
  476.                             'id_padding'    => 'padding',
  477.                             'std_padding'   => '10',
  478.                             'lockable'      => true,
  479.                             'multi_padding' => array(
  480.                                                     'bottom'    => __( 'Bottom Padding', 'avia_framework' )
  481.                                                 )
  482.                         ),
  483.  
  484.                         array(
  485.                             'type'          => 'template',
  486.                             'template_id'   => 'margin_padding',
  487.                             'name'          => '',
  488.                             'desc'          => '',
  489.                             'content'       => 'padding',
  490.                             'sync_padding'  => false,
  491.                             'name_padding'  => __( 'Icon Bottom Padding', 'avia_framework' ),
  492.                             'desc_padding'  => __( 'Set the bottom padding for the icon. Valid CSS units are accepted, eg: 30px, 5&percnt;. px is used as default unit.', 'avia_framework' ),
  493.                             'id_padding'    => 'icon_padding',
  494.                             'std_padding'   => '10',
  495.                             'lockable'      => true,
  496.                             'required'      => array( 'show_icon', 'equals', 'custom_icon' ),
  497.                             'multi_padding' => array(
  498.                                                     'bottom'    => __( 'Bottom Padding', 'avia_framework' )
  499.                                                 )
  500.                         )
  501.                 );
  502.  
  503.             $template = array(
  504.                             array(
  505.                                 'type'          => 'template',
  506.                                 'template_id'   => 'toggle',
  507.                                 'title'         => __( 'Spacing', 'avia_framework' ),
  508.                                 'content'       => $c
  509.                             ),
  510.                     );
  511.  
  512.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_spacing' ), $template );
  513.  
  514.             /**
  515.              * Advanced Tab
  516.              * ===========
  517.              */
  518.  
  519.             $c = array(
  520.                         array(
  521.                             'type'          => 'template',
  522.                             'template_id'   => 'linkpicker_toggle',
  523.                             'name'          => __( 'Header Text Link?', 'avia_framework' ),
  524.                             'desc'          => __( 'Do you want to apply a link to the header text?', 'avia_framework' ),
  525.                             'lockable'      => true,
  526.                             'subtypes'      => array( 'no', 'manually', 'single', 'taxonomy' ),
  527.                             'target_id'     => 'link_target'
  528.                         ),
  529.                         array(
  530.                             'type'          => 'template',
  531.                             'template_id'   => 'linkpicker_toggle',
  532.                             'name'          => __( 'Sub Header Text Link?', 'avia_framework' ),
  533.                             'desc'          => __( 'Do you want to apply a link to the subheader text?', 'avia_framework' ),
  534.                             'lockable'      => true,
  535.                             'subtypes'      => array( 'no', 'manually', 'single', 'taxonomy' ),
  536.                             'target_id'     => 'sublink_target',
  537.                             'id'            => 'sublink'
  538.                         ),
  539.                 );
  540.  
  541.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_link' ), $c );
  542.  
  543.         }
  544.  
  545.         /**
  546.          * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  547.          * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  548.          * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  549.          *
  550.          * @param array $params         holds the default values for $content and $args.
  551.          * @return array                usually holds an innerHtml key that holds item specific markup.
  552.          */
  553.         public function editor_element( $params )
  554.         {
  555.             /**
  556.              * Fix a bug in 4.7 and 4.7.1 renaming option id (no longer backwards comp.) - can be removed in a future version again
  557.              */
  558.             if( isset( $params['args']['linktarget'] ) )
  559.             {
  560.                 $params['args']['link_target'] = $params['args']['linktarget'];
  561.             }
  562.  
  563.             if( isset( $params['args']['sublinktarget'] ) )
  564.             {
  565.                 $params['args']['sublink_target'] = $params['args']['sublinktarget'];
  566.             }
  567.  
  568.             $default = array();
  569.             $locked = array();
  570.             $attr = $params['args'];
  571.             $content = $params['content'];
  572.             Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode'], $default, $locked, $content );
  573.  
  574.             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'
  575.  
  576.             $content = stripslashes( wpautop( trim( html_entity_decode( $content ) ) ) );
  577.  
  578.  
  579.             $params['innerHtml']  = "<div class='avia_textblock avia_textblock_style avia-special-heading' data-update_element_template='yes'>";
  580.             $params['innerHtml'] .=     '<div ' . $this->class_by_arguments_lockable( 'tag, style, color, subheading_active, show_icon', $attr, $locked ) . '>';
  581.             $params['innerHtml'] .=         '<div ' . $this->update_option_lockable( 'content', $locked ) . " class='av-subheading-top av-subheading'>{$content}</div>";
  582.             $params['innerHtml'] .=         '<span class="avia-heading-icon">';
  583.             $params['innerHtml'] .=             '<span ' . $this->class_by_arguments_lockable( 'font', $font, $locked ) . '>';
  584.             $params['innerHtml'] .=                 '<span ' . $this->update_option_lockable( array( 'icon', 'icon_fakeArg' ), $locked ) . " class='avia_icon_char'>{$display_char}</span>";
  585.             $params['innerHtml'] .=             '</span>';
  586.             $params['innerHtml'] .=         '</span>';
  587.             $params['innerHtml'] .=         '<div ' . $this->update_option_lockable( 'heading', $locked ) . '>';
  588.             $params['innerHtml'] .=             stripslashes( trim( htmlspecialchars_decode( $attr['heading'] ) ) );
  589.             $params['innerHtml'] .=         '</div>';
  590.             $params['innerHtml'] .=         '<div ' . $this->update_option_lockable( 'content', $locked ) . " class='av-subheading-bottom av-subheading'>{$content}</div>";
  591.             $params['innerHtml'] .=     '</div>';
  592.             $params['innerHtml'] .= '</div>';
  593.  
  594.             $params['class'] = '';
  595.  
  596.             return $params;
  597.         }
  598.  
  599.         /**
  600.          * Create custom stylings
  601.          *
  602.          * @since 4.8.4
  603.          * @param array $args
  604.          * @return array
  605.          */
  606.         protected function get_element_styles( array $args )
  607.         {
  608.             $result = parent::get_element_styles( $args );
  609.  
  610.             extract( $result );
  611.  
  612.             /**
  613.              * Fix a bug in 4.7 and 4.7.1 renaming option id (no longer backwards comp.) - can be removed in a future version again
  614.              */
  615.             if( isset( $atts['linktarget'] ) )
  616.             {
  617.                 $atts['link_target'] = $atts['linktarget'];
  618.             }
  619.  
  620.             if( isset( $atts['sublinktarget'] ) )
  621.             {
  622.                 $atts['sublink_target'] = $atts['sublinktarget'];
  623.             }
  624.  
  625.             $default = array(
  626.                         'heading'           => '',
  627.                         'tag'               => 'h3',
  628.                         'link_apply'        => null,        //  backwards comp. < version 1.0
  629.                         'link'              => '',
  630.                         'link_target'       => '',
  631.                         'sublink_target'    => '',
  632.                         'style'             => '',
  633.                         'show_icon'         => '',
  634.                         'icon'              => '',
  635.                         'font'              => '',
  636.                         'icon_size'         => '',
  637.                         'icon_padding'      => 10,
  638.                         'icon_color'        => '',
  639.                         'size'              => '',
  640.                         'subheading_active' => '',
  641.                         'subheading_size'   => '',
  642.                         'margin'            => '',
  643.                         'padding'           => '5',
  644.                         'headline_padding'  => '',
  645.                         'color'             => '',
  646.                         'custom_font'       => '',
  647.                         'seperator_color'   => '',
  648.                         'subheading_color'  => ''
  649.                     );
  650.  
  651.             $default = $this->sync_sc_defaults_array( $default, 'no_modal_item', 'no_content' );
  652.  
  653.  
  654.             $locked = array();
  655.             Avia_Element_Templates()->set_locked_attributes( $atts, $this, $shortcodename, $default, $locked, $content );
  656.             Avia_Element_Templates()->add_template_class( $meta, $atts, $default );
  657.  
  658.             $atts = shortcode_atts( $default, $atts, $this->config['shortcode'] );
  659.  
  660.             if( empty( $atts['subheading_size'] ) )
  661.             {
  662.                 $atts['subheading_size'] = '15';
  663.             }
  664.  
  665.             if( empty( $atts['icon_size'] ) )
  666.             {
  667.                 $atts['icon_size'] = '25';
  668.             }
  669.  
  670.             //  backwards comp. - prepare responsive font sizes for media query
  671.             $atts['size-title'] = $atts['size'];
  672.             $atts['size'] = $atts['subheading_size'];
  673.             $atts['size-1'] = $atts['icon_size'];
  674.  
  675.             //  backwards comp. < version 1.0
  676.             if( ! is_null( $atts['link_apply'] ) )
  677.             {
  678.                 if( empty( $atts['link_apply'] ) )
  679.                 {
  680.                     $atts['link'] = '';
  681.                     $atts['link_target'] = '';
  682.                 }
  683.             }
  684.  
  685.             if( ! is_null( $atts['sublink_apply'] ) )
  686.             {
  687.                 if( empty( $atts['sublink_apply'] ) )
  688.                 {
  689.                     $atts['sublink'] = '';
  690.                     $atts['sublink_target'] = '';
  691.                 }
  692.             }
  693.  
  694.  
  695.             $element_styling->create_callback_styles( $atts );
  696.  
  697.             $classes = array(
  698.                         'av-special-heading',
  699.                         $element_id,
  700.                         'av-special-heading-' . $atts['tag']
  701.                     );
  702.  
  703.             $element_styling->add_classes( 'container', $classes );
  704.             $element_styling->add_classes_from_array( 'container', $atts, array( 'color', 'style' ) );
  705.             $element_styling->add_classes_from_array( 'container', $meta, 'el_class' );
  706.             $element_styling->add_responsive_classes( 'container', 'hide_element', $atts );
  707.  
  708.             $element_styling->add_responsive_font_sizes( 'heading-text', 'size-title', $atts, $this );
  709.             $element_styling->add_responsive_font_sizes( 'subheading', 'size', $atts, $this );
  710.             $element_styling->add_responsive_font_sizes( 'heading-icon', 'size-1', $atts, $this );
  711.  
  712.  
  713.             //if the heading contains a strong tag make apply a custom class that makes the rest of the font appear smaller for a better effect
  714.             if( strpos( $atts['heading'], '<strong>' ) !== false )
  715.             {
  716.                 $element_styling->add_classes( 'container', 'av-thin-font' );
  717.             }
  718.  
  719.             $element_styling->add_responsive_styles( 'container', 'margin', $atts, $this );
  720.             $element_styling->add_responsive_styles( 'heading-text', 'headline_padding', $atts, $this );
  721.             $element_styling->add_responsive_styles( 'container', 'padding', $atts, $this );
  722.  
  723.             // if the color is a custom hex value add the styling for both border and font
  724.             if( $atts['color'] == 'custom-color-heading' && $atts['custom_font'] )
  725.             {
  726.                 $element_styling->add_styles( 'container', array( 'color' => $atts['custom_font'] ) );
  727.                 $element_styling->add_styles( 'heading-border', array( 'border-color' => $atts['custom_font'] ) );
  728.                 $element_styling->add_classes( 'subheading', 'av_custom_color' );
  729.             }
  730.  
  731.             if( $atts['seperator_color'] != '' && 'custom-color-heading' == $atts['color'] )
  732.             {
  733.                 $element_styling->add_styles( 'heading-border', array( 'border-color' => $atts['seperator_color'] ) );
  734.                 $element_styling->add_styles( 'heading-before', array( 'border-color' => $atts['seperator_color'] ) );
  735.                 $element_styling->add_styles( 'heading-after', array( 'border-color' => $atts['seperator_color'] ) );
  736.             }
  737.  
  738.             // if a custom font size is set apply it to the container and also apply the inherit class so the actual heading uses the size
  739.             if( ! empty( $atts['style'] ) && ! empty( $atts['size-title'] ) )
  740.             {
  741.                 if( 'hidden' != $atts['size-title'] )
  742.                 {
  743.                     if( is_numeric( $atts['size-title'] ) )
  744.                     {
  745.                         $atts['size-title'] .= 'px';
  746.                     }
  747.  
  748.                     $element_styling->add_styles( 'container', array( 'font-size' => $atts['size-title'] ) );
  749.                     $element_styling->add_classes( 'container', 'av-inherit-size' );
  750.                 }
  751.  
  752.                 /**
  753.                  * responsive behaviour for "default" is font-size: 0.8em; - media query prior post css implementation
  754.                  * https://kriesi.at/support/topic/bug-new-typography-tools-clash-with-settings-on-the-page/
  755.                  *
  756.                  * @since 5.0.1
  757.                  */
  758.                 if( '' == $atts['av-small-font-size-title'] )
  759.                 {
  760.                     $element_styling->add_media_queries( 'heading-text', array( 'screen' => array( '480;767' => array( 'font-size' => '0.8em' ) ) ) );
  761.                 }
  762.  
  763.                 if( '' == $atts['av-mini-font-size-title'] )
  764.                 {
  765.                     $element_styling->add_media_queries( 'heading-text', array( 'screen' => array( '0;479' => array( 'font-size' => '0.8em' ) ) ) );
  766.                 }
  767.             }
  768.  
  769.             if( ! empty( $atts['link'] ) )
  770.             {
  771.                 $element_styling->add_classes( 'container', 'av-linked-heading' );
  772.             }
  773.  
  774.             //check subheading
  775.             $element_styling->add_classes( 'subheading', 'av-subheading' );
  776.             if( ! empty( $atts['subheading_active'] ) )
  777.             {
  778.                 $element_styling->add_classes( 'subheading', 'av-' . $atts['subheading_active'] );
  779.  
  780.                 if( ! empty( $atts['subheading_color'] ) && 'custom-color-heading' == $atts['color'] )
  781.                 {
  782.                     $element_styling->add_styles( 'subheading', array( 'color' => $atts['subheading_color'] ) );
  783.                 }
  784.             }
  785.  
  786.             // special styles for 'elegant' style
  787.             if( $atts['style'] == 'blockquote elegant-quote elegant-centered' )
  788.             {
  789.                 if( $atts['show_icon'] == 'custom_icon' && $atts['icon'] !== '' )
  790.                 {
  791.                     $element_styling->add_classes( 'container', 'av-icon' );
  792.  
  793.                     if( $atts['icon_color'] !== '' && 'custom-color-heading' == $atts['color'] )
  794.                     {
  795.                         $element_styling->add_styles( 'heading-icon', array( 'color' => $atts['icon_color'] ) );
  796.                     }
  797.  
  798.                     $element_styling->add_responsive_styles( 'heading-icon', 'icon_padding', $atts, $this );
  799.                 }
  800.             }
  801.  
  802.             $selectors = array(
  803.                         'container'         => "#top .av-special-heading.{$element_id}",
  804.                         'heading-icon'      => "body .av-special-heading.{$element_id} .av-special-heading-tag .heading-char",
  805.                         'heading-text'      => "#top #wrap_all .av-special-heading.{$element_id} .av-special-heading-tag",
  806.                         'heading-border'    => ".av-special-heading.{$element_id} .special-heading-inner-border",
  807.                         'subheading'        => ".av-special-heading.{$element_id} .av-subheading",
  808.                         'heading-before'    => "body .av-special-heading.{$element_id} .av-special-heading-tag .heading-wrap:before",
  809.                         'heading-after'     => "body .av-special-heading.{$element_id} .av-special-heading-tag .heading-wrap:after"
  810.                     );
  811.  
  812.             $element_styling->add_selectors( $selectors );
  813.  
  814.  
  815.             $result['default'] = $default;
  816.             $result['atts'] = $atts;
  817.             $result['content'] = $content;
  818.             $result['meta'] = $meta;
  819.  
  820.             return $result;
  821.         }
  822.  
  823.         /**
  824.          * Frontend Shortcode Handler
  825.          *
  826.          * @param array $atts array of attributes
  827.          * @param string $content text within enclosing form of shortcode element
  828.          * @param string $shortcodename the shortcode found, when == callback name
  829.          * @return string $output returns the modified html string
  830.          */
  831.         public function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' )
  832.         {
  833.             $result = $this->get_element_styles( compact( array( 'atts', 'content', 'shortcodename', 'meta' ) ) );
  834.  
  835.             extract( $result );
  836.  
  837.             $atts['link'] = trim( $atts['link'] );
  838.             if( ( 'manually,http://' == $atts['link'] ) || ( 'manually,https://' == $atts['link'] ) )
  839.             {
  840.                 $atts['link'] = '';
  841.                 $atts['link_target'] = '';
  842.             }
  843.  
  844.             $atts['sublink'] = trim( $atts['sublink'] );
  845.             if( ( 'manually,http://' == $atts['sublink'] ) || ( 'manually,https://' == $atts['sublink'] ) )
  846.             {
  847.                 $atts['sublink'] = '';
  848.                 $atts['sublink_target'] = '';
  849.             }
  850.  
  851.             extract( $atts );
  852.  
  853.             if( empty( $heading ) )
  854.             {
  855.                 return '';
  856.             }
  857.  
  858.             $before = '';
  859.             $after = '';
  860.             $link_before = '';
  861.             $link_after = '';
  862.  
  863.             // add seo markup
  864.             $markup = avia_markup_helper( array( 'context' => 'entry_title', 'echo' => false, 'custom_markup' => $meta['custom_markup'] ) );
  865.  
  866.             // filter heading for & symbol and convert them
  867.             $heading = apply_filters( 'avia_ampersand', wptexturize( $heading ) );
  868.  
  869.             //check if we need to apply a link
  870.             if( ! empty( $link ) )
  871.             {
  872.                 $link_before .= '<a class="av-heading-link" href="' . AviaHelper::get_url( $link ) . '"' . AviaHelper::get_link_target( $link_target ) . '>';
  873.                 $link_after .= '</a>';
  874.             }
  875.  
  876.             // special markup for 'elegant' style
  877.             if( $style == 'blockquote elegant-quote elegant-centered' )
  878.             {
  879.                 $output_before = '';
  880.  
  881.                 if( $show_icon == 'custom_icon' && $icon !== '' )
  882.                 {
  883.                     $display_char = av_icon( $icon, $font );
  884.                     $output_before = "<span class='heading-char avia-font-{$font}' {$display_char}></span>";
  885.                 }
  886.  
  887.                 $output_before .= '<span class="heading-wrap">';
  888.                 $output_after = '</span>';
  889.  
  890.                 $heading = $output_before . $heading . $output_after;
  891.             }
  892.  
  893.             //check if we got a subheading
  894.             if( ! empty( $style ) && ! empty( $subheading_active ) && ! empty( $content ) )
  895.             {
  896.                 if( ! empty( $sublink ) )
  897.                 {
  898.                     $sublink_before .= '<a class="av-heading-link" href="' . AviaHelper::get_url( $sublink ) . '"' . AviaHelper::get_link_target( $sublink_target ) . '>';
  899.                     $sublink_after .= '</a>';
  900.                 }
  901.  
  902.                 $subheading_class = $element_styling->get_class_string( 'subheading' );
  903.  
  904.                 $content = "<div class='{$subheading_class}'>" . ShortcodeHelper::avia_apply_autop( ShortcodeHelper::avia_remove_autop( $content ) ) . '</div>';
  905.  
  906.                 if( $subheading_active == 'subheading_above' )
  907.                 {
  908.                     $before = $sublink_before . $content . $sublink_after;
  909.                 }
  910.                 else
  911.                 {
  912.                     $after = $sublink_before . $content . $sublink_after;
  913.                 }
  914.             }
  915.  
  916.             $style_tag = $element_styling->get_style_tag( $element_id );
  917.             $container_class = $element_styling->get_class_string( 'container' );
  918.  
  919.             $output  = '';
  920.             $output .= $style_tag;
  921.             $output .= "<div {$meta['custom_el_id']} class='{$container_class}'>";
  922.             $output .=      $before;
  923.             $output .=      "<{$tag} class='av-special-heading-tag' $markup >{$link_before}{$heading}{$link_after}</{$tag}>";
  924.             $output .=      $after;
  925.             $output .=      '<div class="special-heading-border">';
  926.             $output .=          '<div class="special-heading-inner-border"></div>';
  927.             $output .=      '</div>';
  928.             $output .= '</div>';
  929.  
  930.             return $output;
  931.         }
  932.     }
  933. }
  934.  
Tags: Shortcode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement