Advertisement
Guenni007

buttons

Mar 21st, 2024
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 24.81 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Button
  4.  *
  5.  * Displays a colored button that links to any url of your choice
  6.  */
  7. if( ! defined( 'ABSPATH' ) ) {  exit;  }    // Exit if accessed directly
  8.  
  9.  
  10. if ( ! class_exists( 'avia_sc_button', false ) )
  11. {
  12.     class avia_sc_button extends aviaShortcodeTemplate
  13.     {
  14.         use \aviaBuilder\traits\scNamedColors;
  15.         use \aviaBuilder\traits\scButtonStyles;
  16.  
  17.         /**
  18.          * @since 4.8.4
  19.          * @param AviaBuilder $builder
  20.          */
  21.         public function __construct( AviaBuilder $builder )
  22.         {
  23.             parent::__construct( $builder );
  24.  
  25.             $this->_construct_scNamedColors();
  26.             $this->_construct_scButtonStyles();
  27.         }
  28.  
  29.         /**
  30.          * @since 4.8.4
  31.          */
  32.         public function __destruct()
  33.         {
  34.             $this->_destruct_scNamedColors();
  35.             $this->_destruct_scButtonStyles();
  36.  
  37.             parent::__destruct();
  38.         }
  39.  
  40.         /**
  41.          * Create the config array for the shortcode button
  42.          */
  43.         protected function shortcode_insert_button()
  44.         {
  45.             $this->config['version']        = '1.0';
  46.             $this->config['self_closing']   = 'yes';
  47.             $this->config['base_element']   = 'yes';
  48.  
  49.             $this->config['name']           = __( 'Button', 'avia_framework' );
  50.             $this->config['tab']            = __( 'Content Elements', 'avia_framework' );
  51.             $this->config['icon']           = AviaBuilder::$path['imagesURL'] . 'sc-button.png';
  52.             $this->config['order']          = 85;
  53.             $this->config['target']         = 'avia-target-insert';
  54.             $this->config['shortcode']      = 'av_button';
  55.             $this->config['tooltip']        = __( 'Creates a colored button', 'avia_framework' );
  56.             $this->config['tinyMCE']        = array( 'tiny_always' => true );
  57.             $this->config['preview']        = true;
  58.             $this->config['id_name']        = 'id';
  59.             $this->config['id_show']        = 'yes';
  60.         }
  61.  
  62.  
  63.         protected function extra_assets()
  64.         {
  65.             $ver = Avia_Builder()->get_theme_version();
  66.             $min_css = avia_minify_extension( 'css' );
  67.  
  68.             //load css
  69.             wp_enqueue_style( 'avia-module-button', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/buttons/buttons{$min_css}.css", array( 'avia-layout' ), $ver );
  70.         }
  71.  
  72.         /**
  73.          * Popup Elements
  74.          *
  75.          * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  76.          * opens a modal window that allows to edit the element properties
  77.          *
  78.          * @return void
  79.          */
  80.         protected function popup_elements()
  81.         {
  82.             $this->elements = array(
  83.  
  84.                 array(
  85.                         'type'  => 'tab_container',
  86.                         'nodescription' => true
  87.                     ),
  88.  
  89.                 array(
  90.                         'type'  => 'tab',
  91.                         'name'  => __( 'Content', 'avia_framework' ),
  92.                         'nodescription' => true
  93.                     ),
  94.  
  95.                     array(
  96.                             'type'          => 'template',
  97.                             'template_id'   => 'toggle_container',
  98.                             'templates_include' => array(
  99.                                                     $this->popup_key( 'content_button' ),
  100.                                                     $this->popup_key( 'content_link' )
  101.                                                 ),
  102.                             'nodescription' => true
  103.                         ),
  104.  
  105.                 array(
  106.                         'type'  => 'tab_close',
  107.                         'nodescription' => true
  108.                     ),
  109.  
  110.                 array(
  111.                         'type'  => 'tab',
  112.                         'name'  => __( 'Styling', 'avia_framework' ),
  113.                         'nodescription' => true
  114.                     ),
  115.  
  116.                     array(
  117.                             'type'          => 'template',
  118.                             'template_id'   => 'toggle_container',
  119.                             'templates_include' => array(
  120.                                                     $this->popup_key( 'styling_appearance' ),
  121.                                                     $this->popup_key( 'styling_fonts' ),
  122.                                                     $this->popup_key( 'styling_margin_padding' ),
  123.                                                     $this->popup_key( 'styling_colors' ),
  124.                                                     'border_toggle',
  125.                                                     'box_shadow_toggle'
  126.                                                 ),
  127.                             'nodescription' => true
  128.                         ),
  129.  
  130.                 array(
  131.                         'type'  => 'tab_close',
  132.                         'nodescription' => true
  133.                     ),
  134.  
  135.                 array(
  136.                         'type'  => 'tab',
  137.                         'name'  => __( 'Advanced', 'avia_framework' ),
  138.                         'nodescription' => true
  139.                     ),
  140.  
  141.                     array(
  142.                             'type'  => 'toggle_container',
  143.                             'nodescription' => true
  144.                         ),
  145.  
  146.                         array(
  147.                                 'type'          => 'template',
  148.                                 'template_id'   => $this->popup_key( 'advanced_animation' ),
  149.                             ),
  150.  
  151.                         array(
  152.                                 'type'          => 'template',
  153.                                 'template_id'   => 'effects_toggle',
  154.                                 'lockable'      => true,
  155.                                 'include'       => array( 'sonar_effect', 'hover_opacity' )
  156.                             ),
  157.  
  158.                         array(
  159.                                 'name'          => __( 'Button Position', 'avia_framework' ),
  160.                                 'desc'          => __( 'Set a position for the button', 'avia_framework' ),
  161.                                 'type'          => 'template',
  162.                                 'template_id'   => 'position',
  163.                                 'toggle'        => true,
  164.                                 'lockable'      => true
  165.                             ),
  166.  
  167.                         array(
  168.                                 'type'          => 'template',
  169.                                 'template_id'   => 'screen_options_toggle',
  170.                                 'lockable'      => true
  171.                             ),
  172.  
  173.                         array(
  174.                                 'type'          => 'template',
  175.                                 'template_id'   => 'developer_options_toggle',
  176.                                 'args'          => array( 'sc' => $this )
  177.                             ),
  178.  
  179.                     array(
  180.                             'type'  => 'toggle_container_close',
  181.                             'nodescription' => true
  182.                         ),
  183.  
  184.                 array(
  185.                         'type'  => 'tab_close',
  186.                         'nodescription' => true
  187.                     ),
  188.  
  189.                 array(
  190.                         'type'          => 'template',
  191.                         'template_id'   => 'element_template_selection_tab',
  192.                         'args'          => array( 'sc'  => $this )
  193.                     ),
  194.  
  195.                 array(
  196.                         'type'  => 'tab_container_close',
  197.                         'nodescription' => true
  198.                     )
  199.  
  200.  
  201.                 );
  202.  
  203.         }
  204.  
  205.         /**
  206.          * Create and register templates for easier maintainance
  207.          *
  208.          * @since 4.6.4
  209.          */
  210.         protected function register_dynamic_templates()
  211.         {
  212.  
  213.             /**
  214.              * Content Tab
  215.              * ===========
  216.              */
  217.  
  218.             $c = array(
  219.                         array(
  220.                             'name'  => __( 'Button Label', 'avia_framework' ),
  221.                             'desc'  => __( 'This is the text that appears on your button.', 'avia_framework' ),
  222.                             'id'    => 'label',
  223.                             'type'  => 'input',
  224.                             'std'   => __( 'Click me', 'avia_framework' ),
  225.                             'lockable'  => true
  226.                         ),
  227.  
  228.                         array(
  229.                             'name'  => __( 'Show Button Icon', 'avia_framework' ),
  230.                             'desc'  => __( 'Should an icon be displayed at the left or right side of the button', 'avia_framework' ),
  231.                             'id'    => 'icon_select',
  232.                             'type'  => 'select',
  233.                             'std'   => 'yes',
  234.                             'lockable'  => true,
  235.                             'subtype'   => array(
  236.                                                 __( 'No Icon', 'avia_framework' )                   => 'no',
  237.                                                 __( 'Display icon to the left', 'avia_framework' )  => 'yes' ,
  238.                                                 __( 'Display icon to the right', 'avia_framework' ) => 'yes-right-icon',
  239.                                             )
  240.                         ),
  241.  
  242.                         array(
  243.                             'name'  => __( 'Button Icon', 'avia_framework' ),
  244.                             'desc'  => __( 'Select an icon for your Button below', 'avia_framework' ),
  245.                             'id'    => 'icon',
  246.                             'type'  => 'iconfont',
  247.                             'std'   => '',
  248.                             'lockable'  => true,
  249.                             'locked'    => array( 'icon', 'font' ),
  250.                             'required'  => array( 'icon_select', 'not_empty_and', 'no' )
  251.                             ),
  252.  
  253.                         array(
  254.                             'name'  => __( 'Icon Visibility', 'avia_framework' ),
  255.                             'desc'  => __( 'Check to only display icon on hover', 'avia_framework' ),
  256.                             'id'    => 'icon_hover',
  257.                             'type'  => 'checkbox',
  258.                             'std'   => '',
  259.                             'lockable'  => true,
  260.                             'required'  => array( 'icon_select', 'not_empty_and', 'no' )
  261.                         )
  262.  
  263.                 );
  264.  
  265.             $template = array(
  266.                             array(
  267.                                 'type'          => 'template',
  268.                                 'template_id'   => 'toggle',
  269.                                 'title'         => __( 'Button', 'avia_framework' ),
  270.                                 'content'       => $c
  271.                             ),
  272.                     );
  273.  
  274.  
  275.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_button' ), $template );
  276.  
  277.             $c = array(
  278.                         array(
  279.                             'type'          => 'template',
  280.                             'template_id'   => 'linkpicker_toggle',
  281.                             'name'          => __( 'Button Link', 'avia_framework' ),
  282.                             'desc'          => __( 'Where should your button link to?', 'avia_framework' ),
  283.                             'subtypes'      => array( 'manually', 'single', 'taxonomy' ),
  284.                             'target_id'     => 'link_target',
  285.                             'lockable'      => true
  286.                         ),
  287.  
  288.                 );
  289.  
  290.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_link' ), $c );
  291.  
  292.             /**
  293.              * Styling Tab
  294.              * ===========
  295.              */
  296.  
  297.             $c = array(
  298.                         array(
  299.                             'name'  => __( 'Button Size', 'avia_framework' ),
  300.                             'desc'  => __( 'Choose the size of your button here.', 'avia_framework' ),
  301.                             'id'    => 'size',
  302.                             'type'  => 'select',
  303.                             'std'   => 'small',
  304.                             'lockable'  => true,
  305.                             'subtype'   => array(
  306.                                                 __( 'Small', 'avia_framework' )     => 'small',
  307.                                                 __( 'Medium', 'avia_framework' )    => 'medium',
  308.                                                 __( 'Large', 'avia_framework' )     => 'large',
  309.                                                 __( 'X Large', 'avia_framework' )   => 'x-large'
  310.                                             )
  311.                         ),
  312.  
  313.                         array(
  314.                             'name'  => __( 'Button Position', 'avia_framework' ),
  315.                             'desc'  => __( 'Choose the alignment of your button here', 'avia_framework' ),
  316.                             'id'    => 'position',
  317.                             'type'  => 'select',
  318.                             'std'   => 'center',
  319.                             'lockable'  => true,
  320.                             'subtype'   => array(
  321.                                                 __( 'Align Left', 'avia_framework' )    => 'left',
  322.                                                 __( 'Align Center', 'avia_framework' )  => 'center',
  323.                                                 __( 'Align Right', 'avia_framework' )   => 'right',
  324.                                             ),
  325.                             'required'  => array( 'size', 'not', 'fullwidth' )
  326.                         ),
  327.  
  328.                         array(
  329.                             'name'  => __( 'Button Label Display', 'avia_framework' ),
  330.                             'desc'  => __( 'Select how to display the label', 'avia_framework' ),
  331.                             'id'    => 'label_display',
  332.                             'type'  => 'select',
  333.                             'std'   => '',
  334.                             'lockable'  => true,
  335.                             'subtype'   => array(
  336.                                                 __( 'Always display', 'avia_framework' )    => '',
  337.                                                 __( 'Display on hover', 'avia_framework' )  => 'av-button-label-on-hover',
  338.                                             )
  339.                         ),
  340.  
  341.                         array(
  342.                             'name'      => __( 'Button Title Attribute', 'avia_framework' ),
  343.                             'desc'      => __( 'Add a title attribute for this button.', 'avia_framework' ),
  344.                             'id'        => 'title_attr',
  345.                             'type'      => 'input',
  346.                             'std'       => '',
  347.                             'required'  => array( 'label_display', 'equals', '' )
  348.                         ),
  349.  
  350.  
  351.                 );
  352.  
  353.             $template = array(
  354.                             array(
  355.                                 'type'          => 'template',
  356.                                 'template_id'   => 'toggle',
  357.                                 'title'         => __( 'Appearance', 'avia_framework' ),
  358.                                 'content'       => $c
  359.                             ),
  360.                     );
  361.  
  362.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_appearance' ), $template );
  363.  
  364.  
  365.             $c = array(
  366.  
  367.                         array(
  368.                             'name'          => __( 'Button Text Font Sizes', 'avia_framework' ),
  369.                             'desc'          => __( 'Select a custom font size for the button text.', 'avia_framework' ),
  370.                             'type'          => 'template',
  371.                             'template_id'   => 'font_sizes_icon_switcher',
  372.                             'textfield'     => true,
  373.                             'lockable'      => true,
  374.                             'subtype'       => array(
  375.                                                 'default'   => AviaHtmlHelper::number_array( 10, 90, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  376.                                                 'desktop'   => AviaHtmlHelper::number_array( 10, 90, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ),
  377.                                                 'medium'    => AviaHtmlHelper::number_array( 10, 90, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  378.                                                 'small'     => AviaHtmlHelper::number_array( 10, 90, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ),
  379.                                                 'mini'      => AviaHtmlHelper::number_array( 10, 90, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' )
  380.                                             ),
  381.                             'id_sizes'      => array(
  382.                                                 'default'   => 'size-text',
  383.                                                 'desktop'   => 'av-desktop-font-size-text',
  384.                                                 'medium'    => 'av-medium-font-size-text',
  385.                                                 'small'     => 'av-small-font-size-text',
  386.                                                 'mini'      => 'av-mini-font-size-text'
  387.                                             )
  388.                         )
  389.                 );
  390.  
  391.             $template = array(
  392.                             array(
  393.                                 'type'          => 'template',
  394.                                 'template_id'   => 'toggle',
  395.                                 'title'         => __( 'Font Sizes', 'avia_framework' ),
  396.                                 'content'       => $c
  397.                             )
  398.                     );
  399.  
  400.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_fonts' ), $template );
  401.  
  402.  
  403.             $c = array(
  404.                         array(
  405.                                 'type'          => 'template',
  406.                                 'template_id'   => 'margin_padding',
  407.                                 'toggle'        => true,
  408.                                 'name'          => __( 'Button Margin And Padding', 'avia_framework' ),
  409.                                 'desc'          => __( 'Set a responsive margin and a padding to text for the button.', 'avia_framework' ),
  410.                                 'lockable'      => true,
  411.                             )
  412.                 );
  413.  
  414.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_margin_padding' ), $c );
  415.  
  416.             $c = array(
  417.  
  418.                         array(
  419.                             'name'  => __( 'Button Colors Selection', 'avia_framework' ),
  420.                             'desc'  => __( 'Select the available options for button colors. Switching to advanced options for already existing buttons you need to set all options (color settings from basic options are ignored).', 'avia_framework' ),
  421.                             'id'    => 'color_options',
  422.                             'type'  => 'select',
  423.                             'std'   => '',
  424.                             'lockable'  => true,
  425.                             'subtype'   => array(
  426.                                                 __( 'Basic options only', 'avia_framework' )    => '',
  427.                                                 __( 'Advanced options', 'avia_framework' )      => 'color_options_advanced',
  428.                                             )
  429.                         ),
  430.  
  431.                         array(
  432.                             'type'          => 'template',
  433.                             'template_id'   => 'named_colors',
  434.                             'custom'        => true,
  435.                             'lockable'      => true,
  436.                             'required'      => array( 'color_options', 'equals', '' )
  437.                         ),
  438.  
  439.                         array(
  440.                             'name'  => __( 'Custom Background Color', 'avia_framework' ),
  441.                             'desc'  => __( 'Select a custom background color for your button here', 'avia_framework' ),
  442.                             'id'    => 'custom_bg',
  443.                             'type'  => 'colorpicker',
  444.                             'std'   => '#444444',
  445.                             'lockable'  => true,
  446.                             'required'  => array( 'color', 'equals', 'custom' )
  447.                         ),
  448.  
  449.                         array(
  450.                             'name'  => __( 'Custom Font Color', 'avia_framework' ),
  451.                             'desc'  => __( 'Select a custom font color for your button here', 'avia_framework' ),
  452.                             'id'    => 'custom_font',
  453.                             'type'  => 'colorpicker',
  454.                             'std'   => '#ffffff',
  455.                             'lockable'  => true,
  456.                             'required'  => array( 'color', 'equals', 'custom')
  457.                         ),
  458.  
  459.                         array(
  460.                             'type'          => 'template',
  461.                             'template_id'   => 'button_colors',
  462.                             'color_id'      => 'btn_color',
  463.                             'custom_id'     => 'btn_custom',
  464.                             'lockable'      => true,
  465.                             'required'      => array( 'color_options', 'not', '' )
  466.                         )
  467.  
  468.                 );
  469.  
  470.             $template = array(
  471.                             array(
  472.                                 'type'          => 'template',
  473.                                 'template_id'   => 'toggle',
  474.                                 'title'         => __( 'Colors', 'avia_framework' ),
  475.                                 'content'       => $c
  476.                             ),
  477.                     );
  478.  
  479.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_colors' ), $template );
  480.  
  481.  
  482.             /**
  483.              * Adcanced Tab
  484.              * ============
  485.              */
  486.  
  487.             $c = array(
  488.  
  489.                         array(
  490.                             'type'          => 'template',
  491.                             'template_id'   => 'animation',
  492.                             'lockable'      => true,
  493.                             'std_none'      => '',
  494.                             'name'          => __( 'Button Animation', 'avia_framework' ),
  495.                             'desc'          => __( 'Add a small animation to the button when the user first scrolls to the button position. This is only to add some &quot;spice&quot; to the site and only works in modern browsers and only on desktop computers to keep page rendering as fast as possible.', 'avia_framework' ),
  496.                             'groups'        => array( 'fade', 'slide', 'rotate', 'fade-adv', 'special' )
  497.                         )
  498.                 );
  499.  
  500.             $template = array(
  501.                             array(
  502.                                 'type'          => 'template',
  503.                                 'template_id'   => 'toggle',
  504.                                 'title'         => __( 'Animation', 'avia_framework' ),
  505.                                 'content'       => $c
  506.                             ),
  507.                     );
  508.  
  509.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_animation' ), $template );
  510.  
  511.         }
  512.  
  513.         /**
  514.          * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  515.          * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  516.          * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  517.          *
  518.          * @param array $params         this array holds the default values for $content and $args.
  519.          * @return array                the return array usually holds an innerHtml key that holds item specific markup.
  520.          */
  521.         public function editor_element( $params )
  522.         {
  523.             /**
  524.              * 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
  525.              */
  526.             if( isset( $params['args']['linktarget'] ) )
  527.             {
  528.                 $params['args']['link_target'] = $params['args']['linktarget'];
  529.             }
  530.  
  531.             $default = array();
  532.             $locked = array();
  533.             $attr = $params['args'];
  534.             Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode'], $default, $locked );
  535.  
  536.             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'
  537.  
  538.             $inner  = "<div class='avia_button_box avia_hidden_bg_box avia_textblock avia_textblock_style' data-update_element_template='yes'>";
  539.             $inner .=       '<div ' . $this->class_by_arguments_lockable( 'icon_select, color, size, position', $attr, $locked ) . '>';
  540.             $inner .=           '<span ' . $this->class_by_arguments_lockable( 'font', $font, $locked ) . '>';
  541.             $inner .=               '<span ' . $this->update_option_lockable( array( 'icon', 'icon_fakeArg' ), $locked ) . " class='avia_button_icon avia_button_icon_left'>{$display_char}</span>";
  542.             $inner .=           '</span> ';
  543.             $inner .=           '<span ' . $this->update_option_lockable( 'label', $locked ) . " class='avia_iconbox_title' >{$attr['label']}</span> ";
  544.             $inner .=           '<span ' . $this->class_by_arguments_lockable( 'font', $font, $locked ) . '>';
  545.             $inner .=               '<span ' . $this->update_option_lockable( array( 'icon', 'icon_fakeArg' ), $locked ) . " class='avia_button_icon avia_button_icon_right'>{$display_char}</span>";
  546.             $inner .=           '</span>';
  547.             $inner .=       '</div>';
  548.             $inner .= '</div>';
  549.  
  550.             $params['innerHtml'] = $inner;
  551.             $params['content'] = null;
  552.             $params['class'] = '';
  553.  
  554.             return $params;
  555.         }
  556.  
  557.         /**
  558.          * Create custom stylings
  559.          *
  560.          * @since 4.8.4
  561.          * @param array $args
  562.          * @return array
  563.          */
  564.         protected function get_element_styles( array $args )
  565.         {
  566.             $result = parent::get_element_styles( $args );
  567.  
  568.             extract( $result );
  569.  
  570.             /**
  571.              * 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
  572.              */
  573.             if( isset( $atts['linktarget'] ) )
  574.             {
  575.                 $atts['link_target'] = $atts['linktarget'];
  576.             }
  577.  
  578.             $default = $this->get_default_btn_atts();
  579.             $default = $this->sync_sc_defaults_array( $default );
  580.  
  581.             $locked = array();
  582.             Avia_Element_Templates()->set_locked_attributes( $atts, $this, $shortcodename, $default, $locked, $content );
  583.             Avia_Element_Templates()->add_template_class( $meta, $atts, $default );
  584.  
  585.             $atts = shortcode_atts( $default, $atts, $this->config['shortcode'] );
  586.  
  587.             if( $atts['icon_select'] == 'yes' )
  588.             {
  589.                 $atts['icon_select'] = 'yes-left-icon';
  590.             }
  591.  
  592.             $classes = array(
  593.                         'avia-button',
  594.                         $element_id
  595.                     );
  596.  
  597.             $element_styling->add_classes( 'container', $classes );
  598.             $element_styling->add_classes( 'container', $this->class_by_arguments( 'icon_select, size, position', $atts, true, 'array' ) );
  599.             $element_styling->add_responsive_classes( 'container', 'hide_element', $atts );
  600.             $element_styling->add_responsive_font_sizes( 'container', 'size-text', $atts, $this );
  601.  
  602.             $element_styling->add_classes( 'wrap', $element_id . '-wrap' );
  603.  
  604.             $this->set_button_styes( $element_styling, $atts );
  605.  
  606.             if( ! empty( $atts['css_position'] ) )
  607.             {
  608.                 $element_styling->add_responsive_styles( 'wrap', 'css_position', $atts, $this );
  609.             }
  610.  
  611.             $element_styling->add_responsive_styles( 'container', 'margin', $atts, $this );
  612.             $element_styling->add_responsive_styles( 'container', 'padding', $atts, $this );
  613.  
  614.  
  615.             if( ! in_array( $atts['animation'], array( 'no-animation', '' ) ) )
  616.             {
  617.                 if( false !== strpos( $atts['animation'], 'curtain-reveal-' ) )
  618.                 {
  619.                     $classes_curtain = array(
  620.                                 'avia-curtain-reveal-overlay',
  621.                                 'av-animated-when-visible-95',
  622.                                 'animate-all-devices',
  623.                                 $atts['animation']
  624.                             );
  625.  
  626.                     //  animate in preview window
  627.                     if( is_admin() )
  628.                     {
  629.                         $classes_curtain[] = 'avia-animate-admin-preview';
  630.                     }
  631.  
  632.                     $element_styling->add_classes( 'curtain', $classes_curtain );
  633.                     $element_styling->add_callback_styles( 'curtain', array( 'animation' ) );
  634.                 }
  635.                 else
  636.                 {
  637.                     $wrap_classes = array(
  638.                                         'avia_animated_button',
  639.                                         'av-animated-when-visible-95',
  640. //                                      'animate-all-devices',
  641.                                         $atts['animation']
  642.                                     );
  643.  
  644.                     if( is_admin() )
  645.                     {
  646.                         $wrap_classes[] = 'avia-animate-admin-preview';
  647.  
  648.                         $element_styling->add_callback_styles( 'wrap', array( 'animation' ) );
  649.                     }
  650.                     else
  651.                     {
  652.                         $element_styling->add_callback_styles( 'wrap-animation', array( 'animation' ) );
  653.                     }
  654.  
  655.                     $element_styling->add_classes( 'wrap', $wrap_classes );
  656.                 }
  657.             }
  658.  
  659.  
  660.             $selectors = array(
  661.                         'wrap'                      => ".avia-button-wrap.{$element_id}-wrap",
  662.                         'wrap-animation'            => ".avia_transform  .avia-button-wrap.{$element_id}-wrap",
  663.                         'container'                 => "#top #wrap_all .avia-button.{$element_id}",
  664.                         'container-hover'           => "#top #wrap_all .avia-button.{$element_id}:hover",
  665.                         'container-hover-overlay'   => "#top #wrap_all.avia-button.{$element_id}:hover .avia_button_background",
  666.                         'container-after'           => ".avia-button.{$element_id}.avia-sonar-shadow:after",
  667.                         'container-after-hover'     => ".avia-button.{$element_id}.avia-sonar-shadow:hover:after",
  668.                         'curtain'                   => ".avia-button-wrap.{$element_id}-wrap .avia-curtain-reveal-overlay",
  669.                     );
  670.  
  671.             $element_styling->add_selectors( $selectors );
  672.  
  673.  
  674.             $result['default'] = $default;
  675.             $result['atts'] = $atts;
  676.             $result['content'] = $content;
  677.             $result['element_styling'] = $element_styling;
  678.  
  679.             return $result;
  680.         }
  681.  
  682.         /**
  683.          * Frontend Shortcode Handler
  684.          *
  685.          * @param array $atts array of attributes
  686.          * @param string $content text within enclosing form of shortcode element
  687.          * @param string $shortcodename the shortcode found, when == callback name
  688.          * @return string $output returns the modified html string
  689.          */
  690.         public function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' )
  691.         {
  692.             $result = $this->get_element_styles( compact( array( 'atts', 'content', 'shortcodename', 'meta' ) ) );
  693.  
  694.             extract( $result );
  695.  
  696.             $data = '';
  697.             $background_hover = '';
  698.             $style_hover = '';
  699.  
  700.             $display_char = av_icon( $atts['icon'], $atts['font'] );
  701.  
  702.             if( '' != $atts['color_options'] )
  703.             {
  704.                 if( 'custom' != $atts['btn_color_bg_hover'] && 'btn_custom_grad' != $atts['btn_color_bg'] )
  705.                 {
  706.                     //  must be added otherwise we get a bottom border !!!
  707. //                  $style_hover = "style='background-color:{$atts['btn_color_bg_hover']};'";
  708.  
  709.                     if( $this->is_special_button_color( $atts['btn_color_bg_hover'] ) )
  710.                     {
  711.                         $background_hover = "<span class='avia_button_background avia-button avia-color-{$atts['btn_color_bg_hover']}' {$style_hover}></span>";
  712.                     }
  713.                 }
  714.             }
  715.  
  716.             if( ! empty( $atts['label_display'] ) && $atts['label_display'] == 'av-button-label-on-hover' )
  717.             {
  718.                 $data .= 'data-avia-tooltip="' . htmlspecialchars( $atts['label'] ) . '"';
  719.                 $atts['label'] = '';
  720.             }
  721.  
  722.             $blank = AviaHelper::get_link_target( $atts['link_target'] );
  723.             $link = AviaHelper::get_url( $atts['link'] );
  724.             $link = ( ( $link == 'http://' ) || ( $link == 'manually' ) ) ? '' : $link;
  725.  
  726.             $title_attr = ! empty( $atts['title_attr'] ) && empty( $atts['label_display'] ) ? 'title="' . esc_attr( $atts['title_attr'] ) . '"' : '';
  727.  
  728.  
  729.             $style_tag = $element_styling->get_style_tag( $element_id );
  730.             $wrap_class = $element_styling->get_class_string( 'wrap' );
  731.             $container_class = $element_styling->get_class_string( 'container' );
  732.  
  733.             $content_html = '';
  734.  
  735.             if( 'yes-left-icon' == $atts['icon_select'] )
  736.             {
  737.                 $content_html .= "<span class='avia_button_icon avia_button_icon_left' {$display_char}></span>";
  738.             }
  739.  
  740.             $content_html .= "<span class='avia_iconbox_title' >{$atts['label']}</span>";
  741.  
  742.             if( 'yes-right-icon' == $atts['icon_select'] )
  743.             {
  744.                 $content_html .= "<span class='avia_button_icon avia_button_icon_right' {$display_char}></span>";
  745.             }
  746.  
  747.             $curtain_reveal_overlay = '';
  748.  
  749.             if( false !== strpos( $atts['animation'], 'curtain-reveal-' ) )
  750.             {
  751.                 $curtain_class = $element_styling->get_class_string( 'curtain' );
  752.                 $curtain_reveal_overlay = "<div class='{$curtain_class}'></div>";
  753.             }
  754.  
  755.             $html  = '';
  756.             $html .= $style_tag;
  757.  
  758.             $html .=    "<a href='{$link}' {$data} class='{$container_class} {$meta['el_class']}-button' {$blank} {$title_attr}>";
  759.             $html .=        $curtain_reveal_overlay;
  760.             $html .=        $content_html;
  761.             $html .=        $background_hover;
  762.             $html .=    '</a>';
  763.  
  764.             $output  = "<div {$meta['custom_el_id']} class='avia-button-wrap {$wrap_class} avia-button-{$atts['position']} {$meta['el_class']}'>";
  765. //          $output .=      $curtain_reveal_overlay;
  766.             $output .=      $html;
  767.             $output .= '</div>';
  768.  
  769.             return $output;
  770.         }
  771.  
  772.     }
  773. }
  774.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement