class ET_Builder_Module_Accordion extends ET_Builder_Module {
$this->name = esc_html__( 'Accordion', 'et_builder' );
$this->plural = esc_html__( 'Accordions', 'et_builder' );
$this->slug = 'et_pb_accordion';
$this->vb_support = 'on';
$this->child_slug = 'et_pb_accordion_item';
$this->main_css_element = '%%order_class%%.et_pb_accordion';
$this->settings_modal_toggles = array(
'icon' => esc_html__( 'Icon', 'et_builder' ),
'toggle_layout' => esc_html__( 'Toggle', 'et_builder' ),
'title' => et_builder_i18n( 'Text' ),
$this->advanced_fields = array(
'border_radii' => "{$this->main_css_element} .et_pb_accordion_item",
'border_styles' => "{$this->main_css_element} .et_pb_accordion_item",
'border_radii' => 'on||||',
'border_styles' => array(
'main' => '%%order_class%% .et_pb_toggle',
'label' => et_builder_i18n( 'Title' ),
'main' => "{$this->main_css_element} h5.et_pb_toggle_title, {$this->main_css_element} h1.et_pb_toggle_title, {$this->main_css_element} h2.et_pb_toggle_title, {$this->main_css_element} h3.et_pb_toggle_title, {$this->main_css_element} h4.et_pb_toggle_title, {$this->main_css_element} h6.et_pb_toggle_title",
'important' => 'plugin_only',
'options_priority' => array(
'toggle_text_color' => 9,
'closed_toggle' => array(
'label' => esc_html__( 'Closed Title', 'et_builder' ),
'main' => "{$this->main_css_element} .et_pb_toggle_close h5.et_pb_toggle_title, {$this->main_css_element} .et_pb_toggle_close h1.et_pb_toggle_title, {$this->main_css_element} .et_pb_toggle_close h2.et_pb_toggle_title, {$this->main_css_element} .et_pb_toggle_close h3.et_pb_toggle_title, {$this->main_css_element} .et_pb_toggle_close h4.et_pb_toggle_title, {$this->main_css_element} .et_pb_toggle_close h6.et_pb_toggle_title",
'important' => 'plugin_only',
'hide_text_color' => true,
'letter_spacing' => array(
'label' => et_builder_i18n( 'Body' ),
'main' => "{$this->main_css_element} .et_pb_toggle_content",
'limited_main' => "{$this->main_css_element} .et_pb_toggle_content, {$this->main_css_element} .et_pb_toggle_content p",
'line_height' => "{$this->main_css_element} .et_pb_toggle_content p",
'block_elements' => array(
'tabbed_subtoggles' => true,
'bb_icons_support' => true,
'margin_padding' => array(
'draggable_padding' => false,
'padding' => "{$this->main_css_element} .et_pb_toggle_content",
'margin' => $this->main_css_element,
'important' => array( 'custom_margin' ),
'scroll_effects' => array(
$this->custom_css_fields = array(
'label' => esc_html__( 'Toggle', 'et_builder' ),
'selector' => '.et_pb_toggle',
'label' => esc_html__( 'Open Toggle', 'et_builder' ),
'selector' => '.et_pb_toggle_open',
'label' => esc_html__( 'Toggle Title', 'et_builder' ),
'selector' => '.et_pb_toggle_title',
'label' => esc_html__( 'Toggle Icon', 'et_builder' ),
'selector' => '.et_pb_toggle_title:before',
'toggle_content' => array(
'label' => esc_html__( 'Toggle Content', 'et_builder' ),
'selector' => '.et_pb_toggle_content',
$this->help_videos = array(
'name' => esc_html__( 'An introduction to the Accordion module', 'et_builder' ),
'open_toggle_text_color' => array(
'label' => esc_html__( 'Open Title Text Color', 'et_builder' ),
'description' => esc_html__( 'You can pick unique text colors for toggle titles when they are open and closed. Choose the open state title color here.', 'et_builder' ),
'tab_slug' => 'advanced',
'toggle_slug' => 'toggle',
'mobile_options' => true,
'open_toggle_background_color' => array(
'label' => esc_html__( 'Open Toggle Background Color', 'et_builder' ),
'description' => esc_html__( 'You can pick unique background colors for toggles when they are in their open and closed states. Choose the open state background color here.', 'et_builder' ),
'tab_slug' => 'advanced',
'toggle_slug' => 'toggle_layout',
'mobile_options' => true,
'closed_toggle_text_color' => array(
'label' => esc_html__( 'Closed Title Text Color', 'et_builder' ),
'description' => esc_html__( 'You can pick unique text colors for toggle titles when they are open and closed. Choose the closed state title color here.', 'et_builder' ),
'tab_slug' => 'advanced',
'toggle_slug' => 'closed_toggle',
'mobile_options' => true,
'closed_toggle_background_color' => array(
'label' => esc_html__( 'Closed Toggle Background Color', 'et_builder' ),
'description' => esc_html__( 'You can pick unique background colors for toggles when they are in their open and closed states. Choose the closed state background color here.', 'et_builder' ),
'tab_slug' => 'advanced',
'toggle_slug' => 'toggle_layout',
'mobile_options' => true,
'label' => esc_html__( 'Icon Color', 'et_builder' ),
'description' => esc_html__( 'Here you can define a custom color for the toggle icon.', 'et_builder' ),
'tab_slug' => 'advanced',
'mobile_options' => true,
'use_icon_font_size' => array(
'label' => esc_html__( 'Use Icon Font Size', 'et_builder' ),
'description' => esc_html__( 'If you would like to control the size of the icon, you must first enable this option.', 'et_builder' ),
'type' => 'yes_no_button',
'off' => et_builder_i18n( 'No' ),
'on' => et_builder_i18n( 'Yes' ),
'default_on_front' => 'off',
'depends_show_if' => 'on',
'tab_slug' => 'advanced',
'option_category' => 'font_option',
'icon_font_size' => array(
'label' => esc_html__( 'Icon Font Size', 'et_builder' ),
'description' => esc_html__( 'Control the size of the icon by increasing or decreasing the font size.', 'et_builder' ),
'option_category' => 'font_option',
'tab_slug' => 'advanced',
'default_on_front' => '',
'range_settings' => array(
'mobile_options' => true,
'depends_show_if' => 'on',
public function get_transition_fields_css_props() {
$fields = parent::get_transition_fields_css_props();
$title = '%%order_class%% .et_pb_toggle .et_pb_toggle_title';
$fields['icon_color'] = array( 'color' => '%%order_class%% .et_pb_toggle .et_pb_toggle_title:before' );
$fields['icon_font_size'] = array(
'font-size' => '%%order_class%% .et_pb_toggle .et_pb_toggle_title:before',
'margin-top' => '%%order_class%% .et_pb_toggle .et_pb_toggle_title:before',
'right' => '%%order_class%% .et_pb_toggle .et_pb_toggle_title:before',
$fields['toggle_text_color'] = array( 'color' => $title );
$fields['toggle_font_size'] = array( 'font-size' => $title );
$fields['toggle_letter_spacing'] = array( 'letter-spacing' => $title );
$fields['toggle_line_height'] = array( 'line-height' => $title );
$fields['toggle_text_shadow_style'] = array( 'text-shadow' => $title );
$fields['closed_toggle_text_color'] = array( 'color' => '%%order_class%%.et_pb_accordion .et_pb_toggle_close .et_pb_toggle_title' );
$fields['closed_toggle_background_color'] = array( 'background-color' => '%%order_class%% .et_pb_toggle_close' );
$fields['open_toggle_text_color'] = array( 'color' => '%%order_class%%.et_pb_accordion .et_pb_toggle_open .et_pb_toggle_title' );
$fields['open_toggle_background_color'] = array( 'background-color' => '%%order_class%% .et_pb_toggle_open' );
function before_render() {
global $et_pb_accordion_item_number, $et_pb_accordion_header_level;
$et_pb_accordion_item_number = 1;
$et_pb_accordion_header_level = $this->props['toggle_level'];
* Renders the module output.
* @param array $attrs List of attributes.
* @param string $content Content being processed.
* @param string $render_slug Slug of module that is used for rendering output.
public function render( $attrs, $content, $render_slug ) {
global $et_pb_accordion_item_number;
$video_background = $this->video_background();
$parallax_image_background = $this->get_parallax_image_background();
// Open Toggle Background Color.
'render_slug' => $render_slug,
'base_attr_name' => 'open_toggle_background_color',
'css_property' => 'background-color',
'selector' => '%%order_class%% .et_pb_toggle_open',
// Closed Toggle Background Color.
'render_slug' => $render_slug,
'base_attr_name' => 'closed_toggle_background_color',
'css_property' => 'background-color',
'selector' => '%%order_class%% .et_pb_toggle_close',
// Open Toggle Text Color.
'render_slug' => $render_slug,
'base_attr_name' => 'open_toggle_text_color',
'css_property' => 'color',
'selector' => '%%order_class%%.et_pb_accordion .et_pb_toggle_open h5.et_pb_toggle_title, %%order_class%%.et_pb_accordion .et_pb_toggle_open h1.et_pb_toggle_title, %%order_class%%.et_pb_accordion .et_pb_toggle_open h2.et_pb_toggle_title, %%order_class%%.et_pb_accordion .et_pb_toggle_open h3.et_pb_toggle_title, %%order_class%%.et_pb_accordion .et_pb_toggle_open h4.et_pb_toggle_title, %%order_class%%.et_pb_accordion .et_pb_toggle_open h6.et_pb_toggle_title',
'hover_selector' => '%%order_class%%:hover .et_pb_toggle_open h5.et_pb_toggle_title, %%order_class%%:hover .et_pb_toggle_open h1.et_pb_toggle_title, %%order_class%%:hover .et_pb_toggle_open h2.et_pb_toggle_title, %%order_class%%:hover .et_pb_toggle_open h3.et_pb_toggle_title, %%order_class%%:hover .et_pb_toggle_open h4.et_pb_toggle_title, %%order_class%%:hover .et_pb_toggle_open h6.et_pb_toggle_title',
// Closed Toggle Text Color.
'render_slug' => $render_slug,
'base_attr_name' => 'closed_toggle_text_color',
'css_property' => 'color',
'selector' => '%%order_class%%.et_pb_accordion .et_pb_toggle_close h5.et_pb_toggle_title, %%order_class%%.et_pb_accordion .et_pb_toggle_close h1.et_pb_toggle_title, %%order_class%%.et_pb_accordion .et_pb_toggle_close h2.et_pb_toggle_title, %%order_class%%.et_pb_accordion .et_pb_toggle_close h3.et_pb_toggle_title, %%order_class%%.et_pb_accordion .et_pb_toggle_close h4.et_pb_toggle_title, %%order_class%%.et_pb_accordion .et_pb_toggle_close h6.et_pb_toggle_title',
'hover_selector' => '%%order_class%%:hover .et_pb_toggle_close h5.et_pb_toggle_title, %%order_class%%:hover .et_pb_toggle_close h1.et_pb_toggle_title, %%order_class%%:hover .et_pb_toggle_close h2.et_pb_toggle_title, %%order_class%%:hover .et_pb_toggle_close h3.et_pb_toggle_title, %%order_class%%:hover .et_pb_toggle_close h4.et_pb_toggle_title, %%order_class%%:hover .et_pb_toggle_close h6.et_pb_toggle_title',
$use_icon_font_size = $this->props['use_icon_font_size'];
$icon_font_size_values = et_pb_responsive_options()->get_property_values( $this->props, 'icon_font_size' );
$icon_font_size_any_values = et_pb_responsive_options()->get_property_values( $this->props, 'icon_font_size', '16px', true ); // 16px is default toggle icon size.
if ( 'off' !== $use_icon_font_size ) {
// Calculate icon font size and its right position.
'base_attr_name' => 'icon_font_size',
'selector' => '%%order_class%% .et_pb_toggle_title:before',
'hover_pseudo_selector_location' => 'suffix',
'sticky_pseudo_selector_location' => 'prefix',
'render_slug' => $render_slug,
'css_property' => 'font-size',
// processed attr value can't be directly assigned to single css property so
// custom processor is needed to render this attr.
'ET_Builder_Module_Helper_Style_Processor',
'process_toggle_title_icon_font_size',
'render_slug' => $render_slug,
'base_attr_name' => 'icon_color',
'css_property' => 'color',
'selector' => '%%order_class%% .et_pb_toggle_title:before',
'hover_pseudo_selector_location' => 'suffix',
'sticky_pseudo_selector_location' => 'prefix',
'priority' => ET_Builder_Element::DEFAULT_PRIORITY,
$this->add_classname( $this->get_text_orientation_classname() );
</div> <!-- .et_pb_accordion -->',
$this->module_classname( $render_slug ),
$parallax_image_background
public function add_new_child_text() {
return esc_html__( 'Add New Accordion Item', 'et_builder' );
new ET_Builder_Module_Accordion();