class ET_Builder_Module_Search extends ET_Builder_Module {
$this->name = esc_html__( 'Search', 'et_builder' );
$this->plural = esc_html__( 'Searches', 'et_builder' );
$this->slug = 'et_pb_search';
$this->vb_support = 'on';
$this->main_css_element = '%%order_class%%';
$this->settings_modal_toggles = array(
'main_content' => et_builder_i18n( 'Text' ),
'elements' => et_builder_i18n( 'Elements' ),
'exceptions' => esc_html__( 'Exceptions', 'et_builder' ),
'title' => et_builder_i18n( 'Text' ),
'title' => et_builder_i18n( 'Sizing' ),
$this->advanced_fields = array(
'label' => et_builder_i18n( 'Button' ),
'main' => "{$this->main_css_element} input.et_pb_searchsubmit",
'important' => array( 'line-height', 'text-shadow' ),
'letter_spacing' => array(
'hide_text_align' => true,
'margin_padding' => array(
'padding' => "{$this->main_css_element} input.et_pb_s",
'custom_padding' => array(
'default' => '0.715em|0.715em|0.715em|0.715em|false|false',
'main' => "{$this->main_css_element} input.et_pb_s",
'border_radii' => "{$this->main_css_element}.et_pb_search, {$this->main_css_element} input.et_pb_s",
'border_styles' => "{$this->main_css_element}.et_pb_search",
'border_radii' => 'on|3px|3px|3px|3px',
'border_styles' => array(
'use_background_layout' => true,
'main' => "{$this->main_css_element} input.et_pb_searchsubmit, {$this->main_css_element} input.et_pb_s",
'text_shadow' => "{$this->main_css_element} input.et_pb_searchsubmit, {$this->main_css_element} input.et_pb_s",
'text_orientation' => array(
'exclude_options' => array( 'justified' ),
'text_orientation' => array(
'background_layout' => array(
'label' => esc_html__( 'Field', 'et_builder' ),
'main' => '%%order_class%% form input.et_pb_s',
'hover' => '%%order_class%% form input.et_pb_s:hover',
'focus' => '%%order_class%% form input.et_pb_s:focus',
'focus_hover' => '%%order_class%% form input.et_pb_s:focus:hover',
'margin_padding' => false,
'border_styles' => false,
'%%order_class%% form input.et_pb_s',
'%%order_class%% form input.et_pb_s::placeholder',
'%%order_class%% form input.et_pb_s::-webkit-input-placeholder',
'%%order_class%% form input.et_pb_s::-ms-input-placeholder',
'%%order_class%% form input.et_pb_s::-moz-placeholder',
'important' => array( 'line-height', 'text-shadow' ),
'letter_spacing' => array(
$this->custom_css_fields = array(
'label' => esc_html__( 'Input Field', 'et_builder' ),
'selector' => 'input.et_pb_s',
'label' => et_builder_i18n( 'Button' ),
'selector' => 'input.et_pb_searchsubmit',
$this->help_videos = array(
'name' => esc_html__( 'An introduction to the Search module', 'et_builder' ),
'exclude_pages' => array(
'label' => esc_html__( 'Exclude Pages', 'et_builder' ),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'off' => et_builder_i18n( 'No' ),
'on' => et_builder_i18n( 'Yes' ),
'description' => esc_html__( 'Turning this on will exclude Pages from search results', 'et_builder' ),
'toggle_slug' => 'exceptions',
'exclude_posts' => array(
'label' => esc_html__( 'Exclude Posts', 'et_builder' ),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'off' => et_builder_i18n( 'No' ),
'on' => et_builder_i18n( 'Yes' ),
'description' => esc_html__( 'Turning this on will exclude Posts from search results', 'et_builder' ),
'toggle_slug' => 'exceptions',
'include_categories' => array(
'label' => esc_html__( 'Exclude Categories', 'et_builder' ),
'option_category' => 'basic_option',
'renderer_options' => array(
'depends_show_if' => 'off',
'description' => esc_html__( 'Choose which categories you would like to exclude from the search results.', 'et_builder' ),
'toggle_slug' => 'exceptions',
'label' => esc_html__( 'Show Button', 'et_builder' ),
'type' => 'yes_no_button',
'option_category' => 'configuration',
'on' => et_builder_i18n( 'Yes' ),
'off' => et_builder_i18n( 'No' ),
'toggle_slug' => 'elements',
'description' => esc_html__( 'Turn this on to show the Search button', 'et_builder' ),
'mobile_options' => true,
'label' => esc_html__( 'Input Placeholder', 'et_builder' ),
'description' => esc_html__( 'Type the text you want to use as placeholder for the search field.', 'et_builder' ),
'toggle_slug' => 'main_content',
'dynamic_content' => 'text',
'mobile_options' => true,
'label' => esc_html__( 'Button and Border Color', 'et_builder' ),
'tab_slug' => 'advanced',
'toggle_slug' => 'button',
'mobile_options' => true,
'placeholder_color' => array(
'label' => esc_html__( 'Placeholder Color', 'et_builder' ),
'description' => esc_html__( 'Pick a color to be used for the placeholder written inside input fields.', 'et_builder' ),
'tab_slug' => 'advanced',
'toggle_slug' => 'form_field',
'mobile_options' => true,
public function get_transition_fields_css_props() {
$fields = parent::get_transition_fields_css_props();
$fields['button_color'] = array(
'background-color' => '%%order_class%% input.et_pb_searchsubmit',
'%%order_class%% input.et_pb_searchsubmit',
'%%order_class%% input.et_pb_s',
$fields['placeholder_color'] = array(
'%%order_class%% form input.et_pb_s::placeholder',
'%%order_class%% form input.et_pb_s::-webkit-input-placeholder',
'%%order_class%% form input.et_pb_s::-ms-input-placeholder',
'%%order_class%% form input.et_pb_s::-moz-placeholder',
* 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 ) {
$multi_view = et_pb_multi_view_options( $this );
$exclude_categories = $this->props['include_categories'];
$exclude_posts = $this->props['exclude_posts'];
$exclude_pages = $this->props['exclude_pages'];
$show_button = $this->props['show_button'];
$placeholder = $multi_view->render_element(
'placeholder' => '{{placeholder}}',
$input_line_height = $this->props['form_field_line_height'];
$video_background = $this->video_background();
$parallax_image_background = $this->get_parallax_image_background();
$this->content = et_builder_replace_code_content_entities( $this->content );
'base_attr_name' => 'button_color',
'selector' => '%%order_class%% input.et_pb_searchsubmit',
'hover_pseudo_selector_location' => 'suffix',
'sticky_pseudo_selector_location' => 'prefix',
'css_property' => array( 'background-color', 'border-color' ),
'render_slug' => $render_slug,
'base_attr_name' => 'button_color',
'selector' => '%%order_class%% input.et_pb_s',
'hover_pseudo_selector_location' => 'suffix',
'sticky_pseudo_selector_location' => 'prefix',
'css_property' => 'border-color',
'render_slug' => $render_slug,
$placeholder_selectors = array(
'%%order_class%% form input.et_pb_s::-webkit-input-placeholder',
'%%order_class%% form input.et_pb_s::-moz-placeholder',
'%%order_class%% form input.et_pb_s:-ms-input-placeholder',
'base_attr_name' => 'placeholder_color',
'selector' => join( ', ', $placeholder_selectors ),
'hover_pseudo_selector_location' => 'suffix',
'sticky_pseudo_selector_location' => 'prefix',
'css_property' => 'color',
'render_slug' => $render_slug,
if ( '' !== $input_line_height ) {
'selector' => '%%order_class%% input.et_pb_s',
'declaration' => 'height: auto; min-height: 0;',
ET_Builder_Element::set_style( $render_slug, $el_style );
$this->get_text_orientation_classname( true ),
// Background layout class names.
$background_layout_class_names = et_pb_background_layout_options()->get_background_layout_class( $this->props );
$this->add_classname( $background_layout_class_names );
if ( 'on' !== $show_button ) {
$this->add_classname( 'et_pb_hide_search_button' );
// Background layout data attributes.
$data_background_layout = et_pb_background_layout_options()->get_background_layout_attrs( $this->props );
$multi_view_show_button_data_attr = $multi_view->render_attrs(
'et_pb_hide_search_button' => array(
'<div%3$s class="%2$s"%12$s%13$s>
<form role="search" method="get" class="et_pb_searchform" action="%1$s">
<label class="screen-reader-text" for="s">%8$s</label>
<input type="hidden" name="et_pb_searchform_submit" value="et_search_proccess" />
<input type="submit" value="%9$s" class="et_pb_searchsubmit">
</div> <!-- .et_pb_text -->',
esc_url( home_url( '/' ) ),
$this->module_classname( $render_slug ),
'' !== $exclude_categories ? sprintf( '<input type="hidden" name="et_pb_search_cat" value="%1$s" />', esc_attr( $exclude_categories ) ) : '',
'on' !== $exclude_posts ? '<input type="hidden" name="et_pb_include_posts" value="yes" />' : '', // #5
'on' !== $exclude_pages ? '<input type="hidden" name="et_pb_include_pages" value="yes" />' : '',
esc_html__( 'Search for:', 'et_builder' ),
esc_attr__( 'Search', 'et_builder' ),
$video_background, // #10
$parallax_image_background,
et_core_esc_previously( $data_background_layout ),
$multi_view_show_button_data_attr
new ET_Builder_Module_Search();