name = esc_html__( 'Tab', 'et_builder' ); $this->type = 'child'; $this->child_title_var = 'title'; $this->main_css_element = '%%order_class%%'; $this->settings_modal_toggles = array( 'general' => array( 'toggles' => array( 'main_content' => esc_html__( 'Tab', 'et_builder' ), 'tab_content' => esc_html__( 'Content', 'et_builder' ), ), ), 'advanced' => array( 'toggles' => array( 'tab' => esc_html__( 'Tab', 'et_builder' ), 'tab_text' => array( 'sub_toggles' => array( 'title' => array( 'name' => et_builder_i18n( 'Title' ), ), 'subtitle' => array( 'name' => et_builder_i18n( 'Subtitle' ), ), ), 'tabbed_subtoggles' => true, 'title' => sprintf( '%1$s %2$s', esc_html__( 'Tab', 'et_builder' ), et_builder_i18n( 'Text' ) ), ), 'icon' => sprintf( '%1$s %2$s', esc_html__( 'Tab', 'et_builder' ), et_builder_i18n( 'Image & Icon' ) ), 'content_icon' => sprintf( '%1$s %2$s', esc_html__( 'Content', 'et_builder' ), esc_html__( 'Image & Icon', 'et_builder' ) ), 'title' => sprintf( '%1$s %2$s', esc_html__( 'Tab', 'et_builder' ), et_builder_i18n( 'Title' )), 'body' => array( 'title' => sprintf( '%1$s %2$s', esc_html__( 'Tab', 'et_builder' ), et_builder_i18n( 'Body' ) ), 'tabbed_subtoggles' => true, 'bb_icons_support' => true, 'sub_toggles' => array( 'p' => array( 'name' => 'P', 'icon' => 'text-left', ), 'a' => array( 'name' => 'A', 'icon' => 'text-link', ), 'ul' => array( 'name' => 'UL', 'icon' => 'list', ), 'ol' => array( 'name' => 'OL', 'icon' => 'numbered-list', ), 'quote' => array( 'name' => 'QUOTE', 'icon' => 'text-quote', ), ), ), ), ), ); $this->advanced_fields = array( 'borders' => array( 'default' => array( 'css' => array( 'important' => 'all', ), ), ), 'button' => array( 'button' => array( 'label' => et_builder_i18n( 'Button' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-content-button", 'alignment' => "{$this->main_css_element} .et_pb_button_module_wrapper", ), 'use_alignment' => true, 'box_shadow' => array( 'css' => array( 'main' => '%%order_class%% .ddb-content-button', ), ), 'toggle_slug' => 'button', ), ), 'fonts' => array( 'tab_title' => array( 'label' => et_builder_i18n( 'Title' ), 'css' => array( 'main' => ".dondivi_tabs {$this->main_css_element}_tab .ddb-tab-title", 'hover' => ".dondivi_tabs {$this->main_css_element}_tab.ddb-tab:hover .ddb-tab-title, .dondivi_tabs {$this->main_css_element}_tab.ddb-tab.active .ddb-tab-title", ), 'hide_text_align' => true, 'toggle_slug' => 'tab_text', 'sub_toggle' => 'title', ), 'subtitle' => array( 'label' => et_builder_i18n( 'Subtitle' ), 'css' => array( 'main' => ".dondivi_tabs {$this->main_css_element}_tab .ddb-tab-subtitle", 'hover' => ".dondivi_tabs {$this->main_css_element}_tab.ddb-tab:hover .ddb-tab-subtitle, .dondivi_tabs {$this->main_css_element}_tab.ddb-tab.active .ddb-tab-subtitle", ), 'hide_text_align' => true, 'toggle_slug' => 'tab_text', 'sub_toggle' => 'subtitle', ), 'title' => array( 'label' => et_builder_i18n( 'Title' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-content-title, {$this->main_css_element} .ddb-content-title a", ), 'header_level' => array( 'default' => 'h4', ), 'text_shadow' => array( 'show_if' => array( 'item_content' => 'custom' ) ), 'toggle_slug' => 'title', ), 'body' => array( 'label' => et_builder_i18n( 'Body' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-content-body", ), 'text_shadow' => array( 'show_if' => array( 'item_content' => 'custom' ) ), 'toggle_slug' => 'body', 'sub_toggle' => 'p', ), 'body_link' => array( 'label' => et_builder_i18n( 'Link' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-content-body a", ), 'text_shadow' => array( 'show_if' => array( 'item_content' => 'custom' ) ), 'toggle_slug' => 'body', 'sub_toggle' => 'a', ), 'body_ul' => array( 'label' => esc_html__( 'Unordered List', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-content-body ul li", 'item_indent' => "{$this->main_css_element} .ddb-content-body ul", ), 'text_shadow' => array( 'show_if' => array( 'item_content' => 'custom' ) ), 'toggle_slug' => 'body', 'sub_toggle' => 'ul', ), 'body_ol' => array( 'label' => esc_html__( 'Ordered List', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-content-body ol li", 'item_indent' => "{$this->main_css_element} .ddb-content-body ol", ), 'text_shadow' => array( 'show_if' => array( 'item_content' => 'custom' ) ), 'toggle_slug' => 'body', 'sub_toggle' => 'ol', ), 'body_quote' => array( 'label' => esc_html__( 'Blockquote', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-content-body blockquote", ), 'text_shadow' => array( 'show_if' => array( 'item_content' => 'custom' ) ), 'toggle_slug' => 'body', 'sub_toggle' => 'quote', ), ), 'image_icon' => array( 'image_icon' => array( 'label' => et_builder_i18n( 'Image/Icon' ), 'css' => array( 'main' => '%%order_class%% .ddb-content-image-icon', ), 'margin_padding' => array( 'use_padding' => false, ), 'toggle_slug' => 'content_icon', ), ), 'margin_padding' => array( 'css' => array( 'important' => 'all', ), ), 'text' => false, ); $this->custom_css_fields = array( 'tab' => array( 'label' => et_builder_i18n( 'Tab' ), 'selector' => '%%order_class%%_tab', ), 'tab_text' => array( 'label' => sprintf( '%1$s %2$s & %3$s', et_builder_i18n( 'Tab' ), et_builder_i18n( 'Title' ), et_builder_i18n( 'Subtitle' ) ), 'selector' => '%%order_class%%_tab .ddb-tab-text', ), 'tab_title' => array( 'label' => sprintf( '%1$s %2$s', et_builder_i18n( 'Tab' ), et_builder_i18n( 'Title' ) ), 'selector' => '%%order_class%%_tab .ddb-tab-title', ), 'tab_subtitle' => array( 'label' => sprintf( '%1$s %2$s', et_builder_i18n( 'Tab' ), et_builder_i18n( 'Subtitle' ) ), 'selector' => '%%order_class%%_tab .ddb-tab-subtitle', ), 'icon_css' => array( 'label' => sprintf( '%1$s %2$s',et_builder_i18n( 'Content' ), et_builder_i18n( 'Image/Icon' ) ), 'selector' => '%%order_class%% .ddb-content-image-icon', 'show_if' => array( 'item_content' => 'custom' ), ), 'title_css' => array( 'label' => sprintf( '%1$s %2$s',et_builder_i18n( 'Content' ), et_builder_i18n( 'Title' ) ), 'selector' => '%%order_class%% .ddb-custom-content .ddb-content-title', 'show_if' => array('item_content' => 'custom'), ), 'body_css' => array( 'label' => sprintf( '%1$s %2$s',et_builder_i18n( 'Content' ), et_builder_i18n( 'Body' ) ), 'selector' => '%%order_class%% .ddb-custom-content .ddb-content-body', 'show_if' => array('item_content' => 'custom'), ), ); } public function get_fields() { $helper = new DonDiviBuilderFields(); $fields = array( 'title' => array( 'label' => et_builder_i18n( 'Title' ), 'type' => 'text', 'dynamic_content' => 'text', 'mobile_options' => true, 'hover' => 'tabs', 'toggle_slug' => 'main_content', ), 'subtitle' => array( 'label' => et_builder_i18n( 'Subtitle' ), 'type' => 'text', 'dynamic_content' => 'text', 'mobile_options' => true, 'hover' => 'tabs', 'toggle_slug' => 'main_content' ), 'item_icon_image' => array( 'label' => et_builder_i18n( 'Image/Icon' ), 'type' => 'multiple_buttons', 'options' => array( 'none' => array( 'title' => esc_html__('None', 'et_builder') ), 'icon' => array( 'title' => esc_html__('Icon', 'et_builder') ), 'image' => array( 'title' => esc_html__('Image', 'et_builder') ), ), 'default' => 'none', 'toggle_slug' => 'main_content', ), 'item_font_icon' => array( 'label' => esc_html__( 'Icon', 'et_builder' ), 'type' => 'select_icon', 'class' => array( 'et-pb-font-icon' ), 'show_if' => array( 'item_icon_image' => 'icon' ), 'mobile_options' => true, 'hover' => 'tabs', 'toggle_slug' => 'main_content', ), 'item_image' => array( 'label' => esc_html__( 'Image', 'et_builder' ), 'type' => 'upload', 'upload_button_text'=> esc_attr__( 'Upload an image', 'et_builder' ), 'choose_text' => esc_attr__( 'Choose an Image', 'et_builder' ), 'update_text' => esc_attr__( 'Set As Image', 'et_builder' ), 'show_if' => array( 'item_icon_image' => 'image'), 'mobile_options' => true, 'hover' => 'tabs', 'dynamic_content' => 'image', 'toggle_slug' => 'main_content', ), 'item_icon_placement' => array( 'label' => esc_html__( 'Placement', 'et_builder' ), 'type' => 'select', 'options' => array( 'column' => esc_html__( 'Top', 'et_builder' ), 'row-reverse' => esc_html__( 'Right', 'et_builder' ), 'column-reverse' => esc_html__( 'Bottom', 'et_builder' ), 'row' => esc_html__( 'Left', 'et_builder' ), ), 'default' => 'column', 'show_if' => array( 'item_icon_image' => array( 'icon', 'image' ) ), 'mobile_options' => true, 'sticky' => true, 'toggle_slug' => 'main_content', ), 'item_content' => array( 'label' => et_builder_i18n( 'Content' ), 'type' => 'select', 'options' => array( 'custom' => esc_html__( 'Custom', 'et_builder' ), 'layout' => esc_html__( 'Divi Layout', 'dd_builder' ), ), 'default' => 'custom', 'toggle_slug' => 'tab_content', ), 'layout_id' => array( 'label' => esc_html__( 'Divi Layout', 'dd_builder' ), 'description' => esc_html__( 'Here you can choose the Divi Library saved layout.', 'dd_builder' ), 'type' => 'select', 'options' => $helper->get_all_layouts(), 'searchable' => true, 'displayRecent' => false, 'show_if' => array('item_content' => 'layout'), 'toggle_slug' => 'tab_content', ), 'content_hover' => array( 'label' => esc_html__( 'Show On Hover', 'dd_builder' ), 'type' => 'yes_no_button', 'options' => $helper->get_yes_no_button_options(), 'toggle_slug' => 'tab_content', ), '__layout' => array( 'type' => 'computed', 'computed_callback' => array( 'DonDiviBuilderHelper', 'render_divi_layout' ), 'computed_depends_on' => array( 'layout_id', ), 'computed_minimum' => array( 'layout_id', ), ), 'text_horizontal_align' => array( 'label' => esc_html__( 'Text Alignment', 'et_builder' ), 'type' => 'select', 'options' => array( 'flex-start' => et_builder_i18n( 'Left' ), 'center' => et_builder_i18n( 'Center' ), 'flex-end' => et_builder_i18n( 'Right' ), ), 'default' => 'flex-start', 'mobile_options' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'tab', ), 'text_vertical_align' => array( 'label' => esc_html__( 'Text Vertical Alignment', 'et_builder' ), 'type' => 'select', 'options' => array( 'flex-start' => et_builder_i18n( 'Top' ), 'center' => et_builder_i18n( 'Center' ), 'flex-end' => et_builder_i18n( 'Bottom' ), ), 'default' => 'flex-end', 'mobile_options' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'tab', ), 'item_icon_color' => array( 'label' => esc_html__( 'Icon Color', 'et_builder' ), 'description' => esc_html__( 'Here you can define a custom color for your icon.', 'et_builder' ), 'type' => 'color-alpha', 'default' => et_builder_accent_color(), 'show_if' => array( 'item_icon_image' => 'icon' ), 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'icon', ), 'item_icon_width' => array( 'label' => esc_html__( 'Icon Size', 'et_builder' ), 'description' => esc_html__( 'Here you can choose icon width.', 'et_builder' ), 'default' => '24px', 'type' => 'range', 'mobile_options' => true, 'default_unit' => 'px', 'allowed_units' => array( '%', 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ), 'show_if' => array( 'item_icon_image' => 'icon' ), 'mobile_options' => true, 'sticky' => true, 'hover' => 'tabs', 'tab_slug' => 'advanced', 'toggle_slug' => 'icon' ), 'item_image_width' => array( 'label' => esc_html__( 'Image Width', 'et_builder' ), 'type' => 'range', 'range_settings' => array( 'max' => 550, 'step' => 1 ), 'default' => '57px', 'allowed_values' => et_builder_get_acceptable_css_string_values( 'width' ), 'default_unit' => 'px', 'validate_unit' => true, 'show_if' => array( 'item_icon_image' => 'image' ), 'mobile_options' => true, 'sticky' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'icon', ), 'item_icon_alignment' => array( 'label' => esc_html__( 'Image/Icon Alignment', 'et_builder' ), 'description' => esc_html__( 'Align image/icon to the left, right or center.', 'et_builder' ), 'type' => 'align', 'options' => et_builder_get_text_orientation_options( array( 'justified' ) ), 'tab_slug' => 'advanced', 'show_if' => array( 'item_icon_image' => array('icon', 'image'), 'item_icon_placement' => array( 'column', 'column-reverse' ) ), 'toggle_slug' => 'icon', 'mobile_options' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'icon', ), 'item_icon_vertical_alignment' => array( 'label' => esc_html__( 'Image/Icon Vertical Alignment', 'dd_builder' ), 'type' => 'select', 'options' => array( 'flex-start' => et_builder_i18n( 'Top' ), 'center' => et_builder_i18n( 'Center' ), 'flex-end' => et_builder_i18n( 'Bottom' ), ), 'default' => 'center', 'tab_slug' => 'advanced', 'show_if' => array( 'item_icon_image' => array('icon', 'image'), 'item_icon_placement' => array( 'row', 'row-reverse' ) ), 'toggle_slug' => 'icon', 'mobile_options' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'icon', ), 'item_gap' => array( 'label' => sprintf( '%1$s %2$s', et_builder_i18n( 'Image/Icon' ), esc_html__( 'Distance', 'dd_builder' ) ), 'type' => 'range', 'default' => '5px', 'default_unit' => 'px', 'show_if' => array('item_icon_image' => array('icon', 'image')), 'mobile_options' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'icon', ), 'url_param' => array( 'label' => esc_html__( 'URL Parameter', 'dd_builder' ), 'description' => esc_html__( 'The URL yourwebsite/?ddbtab=yourvalue will open this tab.', 'dd_builder' ), 'type' => 'text', 'toggle_slug' => 'link_options', ), ); $fields['module_class'] = $helper->get_custom_class_field(); $fields['item_alt'] = $helper->get_alt_field( array( 'item_icon_image' => 'image'), 'Image Alt Text' ); $cc_settings = array( 'content_slug' => 'tab_content', 'link_slug' => 'link_options', 'icon' => true, 'icon_slug' => 'content_icon', 'button' => true, 'show_if_not' => array('item_content' => 'layout'), ); return array_merge( $fields, $helper->get_font_fields( 'body_ul', 'body_ol', 'body_quote', 'body'), $helper->get_custom_content_fields($cc_settings) ); } public function get_transition_fields_css_props() { $fields = parent::get_transition_fields_css_props(); $selector = ".{$this->get_module_order_class( $this->slug )}_tab"; $fields['item_icon_color'] = array( 'color' => $selector . ' > .ddb-icon', ); return $fields; } public function multi_view_filter_value( $raw_value, $args ) { $name = isset( $args['name'] ) ? $args['name'] : ''; if ( $raw_value && ( 'cc_icon' === $name || 'item_font_icon' === $name ) ) { return et_pb_get_extended_font_icon_value( $raw_value, true ); } return $raw_value; } public function render( $attrs, $content, $render_slug ) { global $ddbuilder_tabs, $ddbuilder_tab_active; $helper = DonDiviBuilderHelper::get(); $multi_view = et_pb_multi_view_options( $this ); $selector = ".{$this->get_module_order_class( $render_slug )}_tab"; $tab_classes = array("ddb-tab ddb-btn ddb-f ddb-p-m ddb-bss {$this->get_module_order_class( $render_slug )}_tab"); if ( $this->props['content_hover'] === 'on' ) { $tab_classes[]= ' ddb-show-hover'; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset($_GET['ddbtab']) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended if (strtoupper(sanitize_text_field($_GET['ddbtab'])) === strtoupper($this->props['url_param'])) { $ddbuilder_tab_active = count($ddbuilder_tabs); } } $title = $multi_view->render_element( array( 'tag' => 'div', 'content' => '{{title}}', 'attrs' => array( 'class' => 'ddb-tab-title', ), ) ); $subtitle = $multi_view->render_element( array( 'tag' => 'div', 'content' => '{{subtitle}}', 'attrs' => array( 'class' => 'ddb-tab-subtitle', ), ) ); $tab_text = ''; if ($title || $subtitle) { $tab_text = $multi_view->render_element( array( 'tag' => 'div', 'content' => $title . $subtitle, 'attrs' => array( 'class' => 'ddb-tab-text ddb-f ddb-column ddb-100', ), ) ); } $icon_image = ''; if ($this->props['item_icon_image'] === 'icon') { $icon_image = $helper->render_icon( array( 'module' => $this, 'icon_attr' => 'item_font_icon', 'color_attr' => 'item_icon_color', 'size_attr' => 'item_icon_width', 'selector' => $selector . ' .ddb-icon', 'hover_selector' => "{$selector}:hover .ddb-icon, {$selector}.active .ddb-icon", 'content_hover' => "{$selector} .ddb-icon.hover, {$selector} .ddb-icon.active", 'custom' => true, ) ); } else if ($this->props['item_icon_image'] === 'image') { $icon_image = $helper->render_image( array( 'module' => $this, 'img_attr' => 'item_image', 'alt_attr' => 'item_alt', 'custom' => true, ) ); $this->generate_styles( array( 'base_attr_name' => 'item_image_width', 'selector' => $selector . ' img', 'css_property' => 'width', 'render_slug' => $render_slug, ) ); } $this->generate_styles( array( 'base_attr_name' => 'text_horizontal_align', 'selector' => $selector . ' > .ddb-tab-text', 'css_property' => 'align-items', 'render_slug' => $render_slug, ) ); $this->generate_styles( array( 'base_attr_name' => 'text_vertical_align', 'selector' => $selector . ' > .ddb-tab-text', 'css_property' => 'justify-content', 'render_slug' => $render_slug, ) ); if ( $icon_image ) { $hali = et_pb_responsive_options()-> get_property_values($this->props, 'item_icon_alignment', $this->props['item_icon_alignment'], true); $this->generate_styles( array( 'base_attr_name' => 'item_gap', 'selector' => $selector, 'css_property' => 'gap', 'render_slug' => $render_slug, ) ); $this->generate_styles( array( 'base_attr_name' => 'item_icon_placement', 'selector' => $selector, 'css_property' => 'flex-direction', 'render_slug' => $render_slug, ) ); foreach ( et_pb_responsive_options()->get_modes() as $device ) { if ( $hali[$device] !== '') $helper->set_style( $render_slug, "{$selector} > span, {$selector} > img", $helper->set_margin_alignment( $hali[$device] ), substr( $device, 0, 1 ) ); } $this->generate_styles( array( 'base_attr_name' => 'item_icon_vertical_alignment', 'selector' => "{$selector} > span, {$selector} > img", 'css_property' => 'align-self', 'render_slug' => $render_slug, ) ); } $tab = $multi_view->render_element( array( 'tag' => 'div', 'content' => $icon_image . $tab_text, 'attrs' => array( 'class' => implode(' ', $tab_classes), 'data-content' => $this->get_module_order_class( $render_slug ), ), ) ); $ddbuilder_tabs[]= $tab; $tab_content = ''; if ($this->props['item_content'] === 'layout') { $tab_content = $helper->render_divi_layout( array('internal' => false, 'layout_id' => $this->props['layout_id']) ); } else { $tab_content = sprintf('
%s
', $helper->render_custom_content( $this ) ); } return sprintf( '
%s
', $tab_content ); } } new DDBUILDER_Tab_Module;