in_sc_exec = false; parent::__construct( $builder ); } /** * @since 4.5.5 */ public function __destruct() { parent::__destruct(); } /** * Create the config array for the shortcode button */ protected function shortcode_insert_button() { $this->config['version'] = '1.0'; $this->config['self_closing'] = 'no'; $this->config['base_element'] = 'yes'; $this->config['name'] = __( 'Testimonials', 'avia_framework' ); $this->config['tab'] = __( 'Content Elements', 'avia_framework' ); $this->config['icon'] = AviaBuilder::$path['imagesURL'] . 'sc-testimonials.png'; $this->config['order'] = 20; $this->config['target'] = 'avia-target-insert'; $this->config['shortcode'] = 'av_testimonials'; $this->config['shortcode_nested'] = array( 'av_testimonial_single' ); $this->config['tooltip'] = __( 'Creates a Testimonial Grid', 'avia_framework' ); $this->config['preview'] = 'xlarge'; $this->config['disabling_allowed'] = true; $this->config['id_name'] = 'id'; $this->config['id_show'] = 'yes'; $this->config['alb_desc_id'] = 'alb_description'; $this->config['name_item'] = __( 'Testimonial Item', 'avia_framework' ); $this->config['tooltip_item'] = __( 'A Testimonial Element Item', 'avia_framework' ); } protected function extra_assets() { $ver = Avia_Builder()->get_theme_version(); $min_js = avia_minify_extension( 'js' ); $min_css = avia_minify_extension( 'css' ); //load css wp_enqueue_style( 'avia-module-slideshow', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/slideshow/slideshow{$min_css}.css", array( 'avia-layout' ), $ver ); wp_enqueue_style( 'avia-module-testimonials', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/testimonials/testimonials{$min_css}.css", array( 'avia-layout' ), $ver ); //load js wp_enqueue_script( 'avia-module-slideshow', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/slideshow/slideshow{$min_js}.js", array( 'avia-shortcodes' ), $ver, true ); wp_enqueue_script( 'avia-module-testimonials', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/testimonials/testimonials{$min_js}.js", array( 'avia-shortcodes' ), $ver, true ); } /** * Popup Elements * * If this function is defined in a child class the element automatically gets an edit button, that, when pressed * opens a modal window that allows to edit the element properties * * @return void */ protected function popup_elements() { $this->elements = array( array( 'type' => 'tab_container', 'nodescription' => true ), array( 'type' => 'tab', 'name' => __( 'Content', 'avia_framework' ), 'nodescription' => true ), array( 'type' => 'template', 'template_id' => $this->popup_key( 'content_testemonial' ) ), array( 'type' => 'tab_close', 'nodescription' => true ), array( 'type' => 'tab', 'name' => __( 'Styling', 'avia_framework' ), 'nodescription' => true ), array( 'type' => 'template', 'template_id' => 'toggle_container', 'templates_include' => array( $this->popup_key( 'styling_general' ), $this->popup_key( 'styling_controls' ), $this->popup_key( 'styling_nav_colors' ), $this->popup_key( 'styling_fonts' ), $this->popup_key( 'styling_colors' ) ), 'nodescription' => true ), array( 'type' => 'tab_close', 'nodescription' => true ), array( 'type' => 'tab', 'name' => __( 'Advanced', 'avia_framework' ), 'nodescription' => true ), array( 'type' => 'toggle_container', 'nodescription' => true ), array( 'type' => 'template', 'template_id' => $this->popup_key( 'advanced_animation_slider' ) ), array( 'type' => 'template', 'template_id' => 'screen_options_toggle', 'lockable' => true ), array( 'type' => 'template', 'template_id' => 'developer_options_toggle', 'args' => array( 'sc' => $this ) ), array( 'type' => 'toggle_container_close', 'nodescription' => true ), array( 'type' => 'tab_close', 'nodescription' => true ), array( 'type' => 'template', 'template_id' => 'element_template_selection_tab', 'args' => array( 'sc' => $this ) ), array( 'type' => 'tab_container_close', 'nodescription' => true ) ); } /** * Create and register templates for easier maintainance * * @since 4.6.4 */ protected function register_dynamic_templates() { $this->register_modal_group_templates(); /** * Content Tab * =========== */ $c = array( array( 'name' => __( 'Add/Edit Testimonial', 'avia_framework' ), 'desc' => __( 'Here you can add, remove and edit your Testimonials.', 'avia_framework' ), 'type' => 'modal_group', 'id' => 'content', 'modal_title' => __( 'Edit Testimonial', 'avia_framework' ), 'editable_item' => true, 'lockable' => true, 'tmpl_set_default' => false, 'std' => array( array( 'name' => __( 'Name', 'avia_framework' ), 'Subtitle' => '', 'check' => 'is_empty' ), ), 'subelements' => $this->create_modal() ) ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_testemonial' ), $c ); /** * Styling Tab * =========== */ $c = array( array( 'name' => __( 'Testimonial Style', 'avia_framework' ), 'desc' => __( 'Here you can select how to display the testimonials. You can either create a testimonial slider or a testimonial grid with multiple columns', 'avia_framework' ), 'id' => 'style', 'type' => 'select', 'std' => 'grid', 'lockable' => true, 'subtype' => array( __( 'Testimonial Grid', 'avia_framework' ) => 'grid', __( 'Testimonial Slider (Compact)', 'avia_framework' ) => 'slider', __( 'Testimonial Slider (Large)', 'avia_framework' ) => 'slider_large', ) ), array( 'name' => __( 'Testimonial Grid Columns', 'avia_framework' ), 'desc' => __( 'How many columns do you want to display', 'avia_framework' ), 'id' => 'columns', 'type' => 'select', 'std' => '2', 'lockable' => true, 'required' => array( 'style', 'equals', 'grid' ), 'subtype' => AviaHtmlHelper::number_array( 1, 4, 1 ) ), array( 'name' => __( 'Testimonial Grid Style', 'avia_framework' ), 'desc' => __( 'Set the styling for the testimonial grid', 'avia_framework' ), 'id' => 'grid_style', 'type' => 'select', 'std' => '', 'lockable' => true, 'required' => array( 'style', 'equals', 'grid' ), 'subtype' => array( __( 'Default Grid', 'avia_framework' ) => '', __( 'Minimal Grid', 'avia_framework' ) => 'av-minimal-grid-style', __( 'Boxed Grid', 'avia_framework' ) => 'av-minimal-grid-style av-boxed-grid-style', ) ) ); $template = array( array( 'type' => 'template', 'template_id' => 'toggle', 'title' => __( 'Slider Or Grid', 'avia_framework' ), 'content' => $c ), ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_general' ), $template ); $c = array( array( 'type' => 'template', 'template_id' => 'slideshow_controls', 'include' => array( 'arrows' ), 'lockable' => true, 'required' => array( 'style', 'contains', 'slider' ) ) ); $template = array( array( 'type' => 'template', 'template_id' => 'toggle', 'title' => __( 'Navigation Controls', 'avia_framework' ), 'content' => $c ), ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_controls' ), $template ); $c = array( array( 'type' => 'template', 'template_id' => 'slideshow_navigation_colors', 'include' => array( 'arrows' ), 'lockable' => true, 'required' => array( 'control_layout', 'parent_in_array', ',av-control-default' ), ) ); $template = array( array( 'type' => 'template', 'template_id' => 'toggle', 'title' => __( 'Navigation Control Colors', 'avia_framework' ), 'content' => $c ) ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_nav_colors' ), $template ); $c = array( array( 'name' => __( 'Testimonial Name Font Sizes', 'avia_framework' ), 'desc' => __( 'Select a custom font size for the testimonial name.', 'avia_framework' ), 'type' => 'template', 'template_id' => 'font_sizes_icon_switcher', 'lockable' => true, 'textfield' => true, 'subtype' => array( 'default' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ), 'desktop' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ), 'medium' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ), 'small' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ), 'mini' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ) ), 'id_sizes' => array( 'default' => 'size-name', 'desktop' => 'av-desktop-font-size-name', 'medium' => 'av-medium-font-size-name', 'small' => 'av-small-font-size-name', 'mini' => 'av-mini-font-size-name' ) ), array( 'name' => __( 'Testimonial Subtitle Font Sizes', 'avia_framework' ), 'desc' => __( 'Select a custom font size for the testimonial subtitle.', 'avia_framework' ), 'type' => 'template', 'template_id' => 'font_sizes_icon_switcher', 'lockable' => true, 'textfield' => true, 'subtype' => array( 'default' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ), 'desktop' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ), 'medium' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ), 'small' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ), 'mini' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ) ), 'id_sizes' => array( 'default' => 'size-subtitle', 'desktop' => 'av-desktop-font-size-subtitle', 'medium' => 'av-medium-font-size-subtitle', 'small' => 'av-small-font-size-subtitle', 'mini' => 'av-mini-font-size-subtitle' ) ), array( 'name' => __( 'Testimonial Content Font Sizes', 'avia_framework' ), 'desc' => __( 'Select a custom font size for the testimonial content.', 'avia_framework' ), 'type' => 'template', 'template_id' => 'font_sizes_icon_switcher', 'lockable' => true, 'textfield' => true, 'subtype' => array( 'default' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ), 'desktop' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '' ), 'px' ), 'medium' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ), 'small' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ), 'mini' => AviaHtmlHelper::number_array( 10, 50, 1, array( __( 'Use Default', 'avia_framework' ) => '', __( 'Hidden', 'avia_framework' ) => 'hidden' ), 'px' ) ), 'id_sizes' => array( 'default' => 'size-content', 'desktop' => 'av-desktop-font-size-content', 'medium' => 'av-medium-font-size-content', 'small' => 'av-small-font-size-content', 'mini' => 'av-mini-font-size-content' ) ) ); $template = array( array( 'type' => 'template', 'template_id' => 'toggle', 'title' => __( 'Font Sizes', 'avia_framework' ), 'content' => $c ), ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_fonts' ), $template ); $c = array( array( 'name' => __( 'Font Colors', 'avia_framework' ), 'desc' => __( 'Either use the themes default colors or apply some custom ones', 'avia_framework' ), 'id' => 'font_color', 'type' => 'select', 'std' => '', 'lockable' => true, 'subtype' => array( __( 'Default', 'avia_framework' ) => '', __( 'Define Custom Colors', 'avia_framework' ) => 'custom' ), ), array( 'name' => __( 'Name Font Color', 'avia_framework' ), 'desc' => __( 'Select a custom font color. Leave empty to use the default', 'avia_framework' ), 'id' => 'custom_title', 'type' => 'colorpicker', 'std' => '', 'rgba' => true, 'container_class' => 'av_half av_half_first', 'lockable' => true, 'required' => array( 'font_color', 'equals', 'custom' ) ), array( 'name' => __( 'Subtitle Font Color', 'avia_framework' ), 'desc' => __( 'Select a custom font color. Leave empty to use "Name Font Color"', 'avia_framework' ), 'id' => 'custom_sub', 'type' => 'colorpicker', 'std' => '', 'rgba' => true, 'container_class' => 'av_half', 'lockable' => true, 'required' => array( 'font_color', 'equals', 'custom' ) ), array( 'name' => __( 'Content Font Color', 'avia_framework' ), 'desc' => __( 'Select a custom font color. Leave empty to use the default', 'avia_framework' ), 'id' => 'custom_content', 'type' => 'colorpicker', 'std' => '', 'rgba' => true, 'container_class' => 'av_half av_half_first', 'lockable' => true, 'required' => array( 'font_color', 'equals', 'custom' ) ) ); $template = array( array( 'type' => 'template', 'template_id' => 'toggle', 'title' => __( 'Colors', 'avia_framework' ), 'content' => $c ), ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_colors' ), $template ); /** * Advanced Tab * =========== */ $c = array( array( 'type' => 'template', 'template_id' => 'slideshow_transition', 'desc' => __( 'Select the transition for your testimonials', 'avia_framework' ), 'required' => array( 'style', 'contains', 'slider' ), 'select_trans' => array( 'fade', 'slide' ), 'std_trans' => 'fade', 'lockable' => true ), array( 'type' => 'template', 'template_id' => 'slideshow_rotation', 'desc' => __( 'Select if the testimonials slider should rotate by default', 'avia_framework' ), 'std' => 'true', 'required' => array( 'style', 'contains', 'slider' ), 'required_manual' => array( 'style', 'contains', 'slider' ), 'stop_id' => 'autoplay_stopper', 'lockable' => true ) ); $template = array( array( 'type' => 'template', 'template_id' => 'toggle', 'title' => __( 'Slider Animation', 'avia_framework' ), 'content' => $c ), ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_animation_slider' ), $template ); } /** * Creates the modal popup for a single entry * * @since 4.6.4 * @return array */ protected function create_modal() { $elements = array( array( 'type' => 'tab_container', 'nodescription' => true ), array( 'type' => 'tab', 'name' => __( 'Content', 'avia_framework' ), 'nodescription' => true ), array( 'type' => 'template', 'template_id' => $this->popup_key( 'modal_content_tstemonial' ) ), array( 'type' => 'tab_close', 'nodescription' => true ), array( 'type' => 'tab', 'name' => __( 'Advanced', 'avia_framework' ), 'nodescription' => true ), array( 'type' => 'template', 'template_id' => $this->popup_key( 'modal_advanced_link' ) ), array( 'type' => 'tab_close', 'nodescription' => true ), array( 'type' => 'template', 'template_id' => 'element_template_selection_tab', 'args' => array( 'sc' => $this, 'modal_group' => true ) ), array( 'type' => 'tab_container_close', 'nodescription' => true ) ); return $elements; } /** * Register all templates for the modal group popup * * @since 4.6.4 */ protected function register_modal_group_templates() { /** * Content Tab * =========== */ $c = array( array( 'name' => __( 'Image', 'avia_framework' ), 'desc' => __( 'Either upload a new, or choose an existing image from your media library', 'avia_framework' ), 'id' => 'src', 'type' => 'image', 'fetch' => 'id', 'title' => __( 'Insert Image', 'avia_framework' ), 'button' => __( 'Insert', 'avia_framework' ), 'std' => '', 'lockable' => true ), array( 'name' => __( 'Name', 'avia_framework' ), 'desc' => __( 'Enter the Name of the Person to quote', 'avia_framework' ), 'id' => 'name', 'type' => 'input', 'std' => '', 'lockable' => true ), array( 'name' => __( 'Subtitle below name', 'avia_framework' ), 'desc' => __( 'Can be used for a job description', 'avia_framework' ), 'id' => 'subtitle', 'type' => 'input', 'std' => '', 'lockable' => true ), array( 'name' => __( 'Quote', 'avia_framework' ), 'desc' => __( 'Enter the testimonial here', 'avia_framework' ), 'id' => 'content', 'type' => 'tiny_mce', 'std' => '', 'lockable' => true ), ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_content_tstemonial' ), $c ); $c = array( array( 'name' => __( 'Website Link', 'avia_framework' ), 'desc' => __( 'Link to the Persons website', 'avia_framework' ), 'id' => 'link', 'type' => 'input', 'std' => 'http://', 'lockable' => true ), array( 'name' => __( 'Website Name', 'avia_framework' ), 'desc' => __( 'Linktext for the above Link', 'avia_framework' ), 'id' => 'linktext', 'type' => 'input', 'std' => '', 'lockable' => true ) ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_advanced_link' ), $c ); } /** * Editor Sub Element - this function defines the visual appearance of an element that is displayed within a modal window and on click opens its own modal window * Works in the same way as Editor Element * * @param array $params holds the default values for $content and $args. * @return array usually holds an innerHtml key that holds item specific markup. */ public function editor_sub_element( $params ) { $default = array(); $locked = array(); $attr = $params['args']; Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode_nested'][0], $default, $locked ); $template = $this->update_template_lockable( 'name', __( 'Testimonial by', 'avia_framework' ) . ': {{name}}', $locked ); $params['innerHtml'] = ''; $params['innerHtml'] .= "