screen_options = array(); parent::__construct( $builder ); } /** * @since 4.5.5 */ public function __destruct() { parent::__destruct(); unset( $this->screen_options ); } /** * Create the config array for the shortcode button */ function shortcode_insert_button() { $this->config['version'] = '1.0'; $this->config['self_closing'] = 'no'; $this->config['base_element'] = 'yes'; $this->config['name'] = __( 'Tabs', 'avia_framework' ); $this->config['tab'] = __( 'Content Elements', 'avia_framework' ); $this->config['icon'] = AviaBuilder::$path['imagesURL'] . 'sc-tabs.png'; $this->config['order'] = 75; $this->config['target'] = 'avia-target-insert'; $this->config['shortcode'] = 'av_tab_container'; $this->config['shortcode_nested'] = array( 'av_tab' ); $this->config['tooltip'] = __( 'Creates a tabbed content area', 'avia_framework' ); $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'] = __( 'Tabs Item', 'avia_framework' ); $this->config['tooltip_item'] = __( 'A single tabs item', 'avia_framework' ); } function admin_assets() { $ver = AviaBuilder::VERSION; wp_register_script( 'avia_tab_toggle_js', AviaBuilder::$path['assetsURL'] . 'js/avia-tab-toggle.js', array( 'avia_modal_js' ), $ver, true ); Avia_Builder()->add_registered_admin_script( 'avia_tab_toggle_js' ); } function extra_assets() { //load css wp_enqueue_style( 'avia-module-tabs', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/tabs/tabs.css', array( 'avia-layout' ), false ); //load js wp_enqueue_script( 'avia-module-tabs', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/tabs/tabs.js', array( 'avia-shortcodes' ), false, 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 */ 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_tabs' ) ), array( 'type' => 'tab_close', 'nodescription' => true ), array( 'type' => 'tab', 'name' => __( 'Styling', 'avia_framework' ), 'nodescription' => true ), array( 'type' => 'template', 'template_id' => $this->popup_key( 'styling_tabs' ) ), 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' ) ), 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 Tabs', 'avia_framework' ), 'desc' => __( 'Here you can add, remove and edit the Tabs you want to display.', 'avia_framework' ), 'type' => 'modal_group', 'id' => 'content', 'modal_title' => __( 'Edit Form Element', 'avia_framework' ), 'container_class' => 'avia-element-fullwidth avia-tab-container', 'editable_item' => true, 'lockable' => true, 'tmpl_set_default' => false, 'std' => array( array( 'title' => __( 'Tab 1', 'avia_framework' ) ), array( 'title' => __( 'Tab 2', 'avia_framework' ) ), ), 'subelements' => $this->create_modal() ), array( 'name' => __( 'Initial Open', 'avia_framework' ), 'desc' => __( 'Enter the Number of the Tab that should be open initially.', 'avia_framework' ), 'id' => 'initial', 'type' => 'input', 'std' => '1', 'lockable' => true ) ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_tabs' ), $c ); /** * Content Tab * =========== */ $c = array( array( 'name' => __( 'Tab Position', 'avia_framework' ), 'desc' => __( 'Where should the tabs be displayed', 'avia_framework' ), 'id' => 'position', 'type' => 'select', 'std' => 'top_tab', 'container_class' => 'avia-element-fullwidth', 'target' => array( '#aviaTBcontent-form-container', 'class' ), 'lockable' => true, 'subtype' => array( __( 'Display tabs at the top', 'avia_framework' ) => 'top_tab', __( 'Display Tabs on the left', 'avia_framework' ) => 'sidebar_tab sidebar_tab_left', __( 'Display Tabs on the right', 'avia_framework' ) => 'sidebar_tab sidebar_tab_right' ) ), array( 'name' => __( 'Boxed Tabs', 'avia_framework' ), 'desc' => __( 'Do you want to display a border around your tabs or without border', 'avia_framework' ), 'id' => 'boxed', 'type' => 'select', 'std' => 'border_tabs', 'lockable' => true, 'required' => array( 'position', 'contains', 'sidebar_tab' ), 'subtype' => array( __( 'With border', 'avia_framework' ) => 'border_tabs', __( 'Without border', 'avia_framework' ) => 'noborder_tabs' ) ) ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_tabs' ), $c ); } /** * 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_tab' ) ), 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' => 'developer_options_toggle', 'args' => array( 'sc' => $this, 'nested' => 'av_tab' ) ), 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, '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' => __( 'Tab Title', 'avia_framework' ), 'desc' => __( 'Enter the tab title here (Better keep it short)', 'avia_framework' ), 'id' => 'title', 'type' => 'input', 'std' => 'Tab Title', 'lockable' => true ), array( 'name' => __( 'Tab Icon', 'avia_framework' ), 'desc' => __( 'Should an icon be displayed at the left side of the tab title?', 'avia_framework' ), 'id' => 'icon_select', 'type' => 'select', 'std' => 'no', 'lockable' => true, 'subtype' => array( __( 'No Icon', 'avia_framework' ) => 'no', __( 'Yes, display Icon', 'avia_framework' ) => 'yes' ) ), array( 'name' => __( 'Tab Icon','avia_framework' ), 'desc' => __( 'Select an icon for your tab title below', 'avia_framework' ), 'id' => 'icon', 'type' => 'iconfont', 'std' => '', 'lockable' => true, 'locked' => array( 'icon', 'font' ), 'required' => array( 'icon_select', 'equals', 'yes' ) ), array( 'name' => __( 'Tab Content', 'avia_framework' ), 'desc' => __( 'Enter some content here', 'avia_framework' ), 'id' => 'content', 'type' => 'tiny_mce', 'std' => __( 'Tab Content goes here', 'avia_framework' ), 'lockable' => true ), ); AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_content_tab' ), $c ); } /** * Return a config array for the nested shortcde * * @since 4.6.4 * @param string $nested_shortcode * @return array */ protected function get_nested_developer_elements( $nested_shortcode ) { $config = array(); if( 'av_tab' == $nested_shortcode ) { $config['id_name'] = 'custom_id'; $config['id_show'] = 'yes'; $config['custom_css_show'] = 'never'; } return $config; } /** * 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 this array holds the default values for $content and $args. * @return $params the return array usually holds an innerHtml key that holds item specific markup. */ function editor_sub_element( $params ) { $default = array(); $locked = array(); $attr = $params['args']; $content = $params['content']; Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode_nested'][0], $default, $locked, $content ); $title_templ = $this->update_option_lockable( 'title', $locked ); $content_templ = $this->update_option_lockable( 'content', $locked ); 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' $params['innerHtml'] = ''; $params['innerHtml'] .= "