Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/includes/builder/module
File: Search.php
<?php
[0] Fix | Delete
[1] Fix | Delete
class ET_Builder_Module_Search extends ET_Builder_Module {
[2] Fix | Delete
function init() {
[3] Fix | Delete
$this->name = esc_html__( 'Search', 'et_builder' );
[4] Fix | Delete
$this->plural = esc_html__( 'Searches', 'et_builder' );
[5] Fix | Delete
$this->slug = 'et_pb_search';
[6] Fix | Delete
$this->vb_support = 'on';
[7] Fix | Delete
[8] Fix | Delete
$this->main_css_element = '%%order_class%%';
[9] Fix | Delete
[10] Fix | Delete
$this->settings_modal_toggles = array(
[11] Fix | Delete
'general' => array(
[12] Fix | Delete
'toggles' => array(
[13] Fix | Delete
'main_content' => et_builder_i18n( 'Text' ),
[14] Fix | Delete
'elements' => et_builder_i18n( 'Elements' ),
[15] Fix | Delete
'exceptions' => esc_html__( 'Exceptions', 'et_builder' ),
[16] Fix | Delete
),
[17] Fix | Delete
),
[18] Fix | Delete
'advanced' => array(
[19] Fix | Delete
'toggles' => array(
[20] Fix | Delete
'text' => array(
[21] Fix | Delete
'title' => et_builder_i18n( 'Text' ),
[22] Fix | Delete
'priority' => 49,
[23] Fix | Delete
),
[24] Fix | Delete
'width' => array(
[25] Fix | Delete
'title' => et_builder_i18n( 'Sizing' ),
[26] Fix | Delete
'priority' => 65,
[27] Fix | Delete
),
[28] Fix | Delete
),
[29] Fix | Delete
),
[30] Fix | Delete
);
[31] Fix | Delete
$this->advanced_fields = array(
[32] Fix | Delete
'fonts' => array(
[33] Fix | Delete
'button' => array(
[34] Fix | Delete
'label' => et_builder_i18n( 'Button' ),
[35] Fix | Delete
'css' => array(
[36] Fix | Delete
'main' => "{$this->main_css_element} input.et_pb_searchsubmit",
[37] Fix | Delete
'important' => array( 'line-height', 'text-shadow' ),
[38] Fix | Delete
),
[39] Fix | Delete
'line_height' => array(
[40] Fix | Delete
'default' => '1em',
[41] Fix | Delete
),
[42] Fix | Delete
'font_size' => array(
[43] Fix | Delete
'default' => '14px',
[44] Fix | Delete
),
[45] Fix | Delete
'letter_spacing' => array(
[46] Fix | Delete
'default' => '0px',
[47] Fix | Delete
),
[48] Fix | Delete
'hide_text_align' => true,
[49] Fix | Delete
),
[50] Fix | Delete
),
[51] Fix | Delete
'margin_padding' => array(
[52] Fix | Delete
'css' => array(
[53] Fix | Delete
'padding' => "{$this->main_css_element} input.et_pb_s",
[54] Fix | Delete
'important' => 'all',
[55] Fix | Delete
),
[56] Fix | Delete
'custom_padding' => array(
[57] Fix | Delete
'default' => '0.715em|0.715em|0.715em|0.715em|false|false',
[58] Fix | Delete
),
[59] Fix | Delete
),
[60] Fix | Delete
'background' => array(
[61] Fix | Delete
'css' => array(
[62] Fix | Delete
'main' => "{$this->main_css_element} input.et_pb_s",
[63] Fix | Delete
),
[64] Fix | Delete
),
[65] Fix | Delete
'borders' => array(
[66] Fix | Delete
'default' => array(
[67] Fix | Delete
'css' => array(
[68] Fix | Delete
'main' => array(
[69] Fix | Delete
'border_radii' => "{$this->main_css_element}.et_pb_search, {$this->main_css_element} input.et_pb_s",
[70] Fix | Delete
'border_styles' => "{$this->main_css_element}.et_pb_search",
[71] Fix | Delete
),
[72] Fix | Delete
),
[73] Fix | Delete
'defaults' => array(
[74] Fix | Delete
'border_radii' => 'on|3px|3px|3px|3px',
[75] Fix | Delete
'border_styles' => array(
[76] Fix | Delete
'width' => '1px',
[77] Fix | Delete
'color' => '#dddddd',
[78] Fix | Delete
'style' => 'solid',
[79] Fix | Delete
),
[80] Fix | Delete
),
[81] Fix | Delete
),
[82] Fix | Delete
),
[83] Fix | Delete
'text' => array(
[84] Fix | Delete
'use_background_layout' => true,
[85] Fix | Delete
'css' => array(
[86] Fix | Delete
'main' => "{$this->main_css_element} input.et_pb_searchsubmit, {$this->main_css_element} input.et_pb_s",
[87] Fix | Delete
'text_shadow' => "{$this->main_css_element} input.et_pb_searchsubmit, {$this->main_css_element} input.et_pb_s",
[88] Fix | Delete
),
[89] Fix | Delete
'text_orientation' => array(
[90] Fix | Delete
'exclude_options' => array( 'justified' ),
[91] Fix | Delete
),
[92] Fix | Delete
'options' => array(
[93] Fix | Delete
'text_orientation' => array(
[94] Fix | Delete
'default' => 'left',
[95] Fix | Delete
),
[96] Fix | Delete
'background_layout' => array(
[97] Fix | Delete
'default' => 'light',
[98] Fix | Delete
'hover' => 'tabs',
[99] Fix | Delete
),
[100] Fix | Delete
),
[101] Fix | Delete
),
[102] Fix | Delete
'button' => false,
[103] Fix | Delete
'link_options' => false,
[104] Fix | Delete
'form_field' => array(
[105] Fix | Delete
'form_field' => array(
[106] Fix | Delete
'label' => esc_html__( 'Field', 'et_builder' ),
[107] Fix | Delete
'css' => array(
[108] Fix | Delete
'main' => '%%order_class%% form input.et_pb_s',
[109] Fix | Delete
'hover' => '%%order_class%% form input.et_pb_s:hover',
[110] Fix | Delete
'focus' => '%%order_class%% form input.et_pb_s:focus',
[111] Fix | Delete
'focus_hover' => '%%order_class%% form input.et_pb_s:focus:hover',
[112] Fix | Delete
),
[113] Fix | Delete
'placeholder' => false,
[114] Fix | Delete
'margin_padding' => false,
[115] Fix | Delete
'box_shadow' => false,
[116] Fix | Delete
'border_styles' => false,
[117] Fix | Delete
'font_field' => array(
[118] Fix | Delete
'css' => array(
[119] Fix | Delete
'main' => implode(
[120] Fix | Delete
', ',
[121] Fix | Delete
array(
[122] Fix | Delete
'%%order_class%% form input.et_pb_s',
[123] Fix | Delete
'%%order_class%% form input.et_pb_s::placeholder',
[124] Fix | Delete
'%%order_class%% form input.et_pb_s::-webkit-input-placeholder',
[125] Fix | Delete
'%%order_class%% form input.et_pb_s::-ms-input-placeholder',
[126] Fix | Delete
'%%order_class%% form input.et_pb_s::-moz-placeholder',
[127] Fix | Delete
)
[128] Fix | Delete
),
[129] Fix | Delete
'placeholder' => true,
[130] Fix | Delete
'important' => array( 'line-height', 'text-shadow' ),
[131] Fix | Delete
),
[132] Fix | Delete
'line_height' => array(
[133] Fix | Delete
'default' => '1em',
[134] Fix | Delete
),
[135] Fix | Delete
'font_size' => array(
[136] Fix | Delete
'default' => '14px',
[137] Fix | Delete
),
[138] Fix | Delete
'letter_spacing' => array(
[139] Fix | Delete
'default' => '0px',
[140] Fix | Delete
),
[141] Fix | Delete
),
[142] Fix | Delete
),
[143] Fix | Delete
),
[144] Fix | Delete
'overflow' => array(
[145] Fix | Delete
'default' => 'hidden',
[146] Fix | Delete
),
[147] Fix | Delete
);
[148] Fix | Delete
[149] Fix | Delete
$this->custom_css_fields = array(
[150] Fix | Delete
'input_field' => array(
[151] Fix | Delete
'label' => esc_html__( 'Input Field', 'et_builder' ),
[152] Fix | Delete
'selector' => 'input.et_pb_s',
[153] Fix | Delete
),
[154] Fix | Delete
'button' => array(
[155] Fix | Delete
'label' => et_builder_i18n( 'Button' ),
[156] Fix | Delete
'selector' => 'input.et_pb_searchsubmit',
[157] Fix | Delete
),
[158] Fix | Delete
);
[159] Fix | Delete
[160] Fix | Delete
$this->help_videos = array(
[161] Fix | Delete
array(
[162] Fix | Delete
'id' => 'HNmb20Mdvno',
[163] Fix | Delete
'name' => esc_html__( 'An introduction to the Search module', 'et_builder' ),
[164] Fix | Delete
),
[165] Fix | Delete
);
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
function get_fields() {
[169] Fix | Delete
$fields = array(
[170] Fix | Delete
'exclude_pages' => array(
[171] Fix | Delete
'label' => esc_html__( 'Exclude Pages', 'et_builder' ),
[172] Fix | Delete
'type' => 'yes_no_button',
[173] Fix | Delete
'option_category' => 'configuration',
[174] Fix | Delete
'options' => array(
[175] Fix | Delete
'off' => et_builder_i18n( 'No' ),
[176] Fix | Delete
'on' => et_builder_i18n( 'Yes' ),
[177] Fix | Delete
),
[178] Fix | Delete
'description' => esc_html__( 'Turning this on will exclude Pages from search results', 'et_builder' ),
[179] Fix | Delete
'toggle_slug' => 'exceptions',
[180] Fix | Delete
),
[181] Fix | Delete
'exclude_posts' => array(
[182] Fix | Delete
'label' => esc_html__( 'Exclude Posts', 'et_builder' ),
[183] Fix | Delete
'type' => 'yes_no_button',
[184] Fix | Delete
'option_category' => 'configuration',
[185] Fix | Delete
'options' => array(
[186] Fix | Delete
'off' => et_builder_i18n( 'No' ),
[187] Fix | Delete
'on' => et_builder_i18n( 'Yes' ),
[188] Fix | Delete
),
[189] Fix | Delete
'default' => 'off',
[190] Fix | Delete
'affects' => array(
[191] Fix | Delete
'include_categories',
[192] Fix | Delete
),
[193] Fix | Delete
'description' => esc_html__( 'Turning this on will exclude Posts from search results', 'et_builder' ),
[194] Fix | Delete
'toggle_slug' => 'exceptions',
[195] Fix | Delete
),
[196] Fix | Delete
'include_categories' => array(
[197] Fix | Delete
'label' => esc_html__( 'Exclude Categories', 'et_builder' ),
[198] Fix | Delete
'type' => 'categories',
[199] Fix | Delete
'option_category' => 'basic_option',
[200] Fix | Delete
'renderer_options' => array(
[201] Fix | Delete
'use_terms' => false,
[202] Fix | Delete
),
[203] Fix | Delete
'depends_show_if' => 'off',
[204] Fix | Delete
'description' => esc_html__( 'Choose which categories you would like to exclude from the search results.', 'et_builder' ),
[205] Fix | Delete
'toggle_slug' => 'exceptions',
[206] Fix | Delete
),
[207] Fix | Delete
'show_button' => array(
[208] Fix | Delete
'label' => esc_html__( 'Show Button', 'et_builder' ),
[209] Fix | Delete
'type' => 'yes_no_button',
[210] Fix | Delete
'option_category' => 'configuration',
[211] Fix | Delete
'options' => array(
[212] Fix | Delete
'on' => et_builder_i18n( 'Yes' ),
[213] Fix | Delete
'off' => et_builder_i18n( 'No' ),
[214] Fix | Delete
),
[215] Fix | Delete
'default' => 'on',
[216] Fix | Delete
'toggle_slug' => 'elements',
[217] Fix | Delete
'description' => esc_html__( 'Turn this on to show the Search button', 'et_builder' ),
[218] Fix | Delete
'mobile_options' => true,
[219] Fix | Delete
'hover' => 'tabs',
[220] Fix | Delete
),
[221] Fix | Delete
'placeholder' => array(
[222] Fix | Delete
'label' => esc_html__( 'Input Placeholder', 'et_builder' ),
[223] Fix | Delete
'type' => 'text',
[224] Fix | Delete
'description' => esc_html__( 'Type the text you want to use as placeholder for the search field.', 'et_builder' ),
[225] Fix | Delete
'toggle_slug' => 'main_content',
[226] Fix | Delete
'dynamic_content' => 'text',
[227] Fix | Delete
'mobile_options' => true,
[228] Fix | Delete
'hover' => 'tabs',
[229] Fix | Delete
),
[230] Fix | Delete
'button_color' => array(
[231] Fix | Delete
'label' => esc_html__( 'Button and Border Color', 'et_builder' ),
[232] Fix | Delete
'type' => 'color-alpha',
[233] Fix | Delete
'custom_color' => true,
[234] Fix | Delete
'tab_slug' => 'advanced',
[235] Fix | Delete
'toggle_slug' => 'button',
[236] Fix | Delete
'hover' => 'tabs',
[237] Fix | Delete
'mobile_options' => true,
[238] Fix | Delete
'sticky' => true,
[239] Fix | Delete
),
[240] Fix | Delete
'placeholder_color' => array(
[241] Fix | Delete
'label' => esc_html__( 'Placeholder Color', 'et_builder' ),
[242] Fix | Delete
'description' => esc_html__( 'Pick a color to be used for the placeholder written inside input fields.', 'et_builder' ),
[243] Fix | Delete
'type' => 'color-alpha',
[244] Fix | Delete
'custom_color' => true,
[245] Fix | Delete
'tab_slug' => 'advanced',
[246] Fix | Delete
'toggle_slug' => 'form_field',
[247] Fix | Delete
'hover' => 'tabs',
[248] Fix | Delete
'mobile_options' => true,
[249] Fix | Delete
'sticky' => true,
[250] Fix | Delete
),
[251] Fix | Delete
);
[252] Fix | Delete
[253] Fix | Delete
return $fields;
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
public function get_transition_fields_css_props() {
[257] Fix | Delete
$fields = parent::get_transition_fields_css_props();
[258] Fix | Delete
[259] Fix | Delete
$fields['button_color'] = array(
[260] Fix | Delete
'background-color' => '%%order_class%% input.et_pb_searchsubmit',
[261] Fix | Delete
'border-color' => array(
[262] Fix | Delete
'%%order_class%% input.et_pb_searchsubmit',
[263] Fix | Delete
'%%order_class%% input.et_pb_s',
[264] Fix | Delete
),
[265] Fix | Delete
);
[266] Fix | Delete
[267] Fix | Delete
$fields['placeholder_color'] = array(
[268] Fix | Delete
'color' => array(
[269] Fix | Delete
'%%order_class%% form input.et_pb_s::placeholder',
[270] Fix | Delete
'%%order_class%% form input.et_pb_s::-webkit-input-placeholder',
[271] Fix | Delete
'%%order_class%% form input.et_pb_s::-ms-input-placeholder',
[272] Fix | Delete
'%%order_class%% form input.et_pb_s::-moz-placeholder',
[273] Fix | Delete
),
[274] Fix | Delete
);
[275] Fix | Delete
[276] Fix | Delete
return $fields;
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
/**
[280] Fix | Delete
* Renders the module output.
[281] Fix | Delete
*
[282] Fix | Delete
* @param array $attrs List of attributes.
[283] Fix | Delete
* @param string $content Content being processed.
[284] Fix | Delete
* @param string $render_slug Slug of module that is used for rendering output.
[285] Fix | Delete
*
[286] Fix | Delete
* @return string
[287] Fix | Delete
*/
[288] Fix | Delete
public function render( $attrs, $content, $render_slug ) {
[289] Fix | Delete
$multi_view = et_pb_multi_view_options( $this );
[290] Fix | Delete
$exclude_categories = $this->props['include_categories'];
[291] Fix | Delete
$exclude_posts = $this->props['exclude_posts'];
[292] Fix | Delete
$exclude_pages = $this->props['exclude_pages'];
[293] Fix | Delete
$show_button = $this->props['show_button'];
[294] Fix | Delete
$placeholder = $multi_view->render_element(
[295] Fix | Delete
array(
[296] Fix | Delete
'tag' => 'input',
[297] Fix | Delete
'attrs' => array(
[298] Fix | Delete
'type' => 'text',
[299] Fix | Delete
'name' => 's',
[300] Fix | Delete
'class' => 'et_pb_s',
[301] Fix | Delete
'placeholder' => '{{placeholder}}',
[302] Fix | Delete
),
[303] Fix | Delete
)
[304] Fix | Delete
);
[305] Fix | Delete
$input_line_height = $this->props['form_field_line_height'];
[306] Fix | Delete
$video_background = $this->video_background();
[307] Fix | Delete
$parallax_image_background = $this->get_parallax_image_background();
[308] Fix | Delete
[309] Fix | Delete
$this->content = et_builder_replace_code_content_entities( $this->content );
[310] Fix | Delete
[311] Fix | Delete
// Button Color.
[312] Fix | Delete
$this->generate_styles(
[313] Fix | Delete
array(
[314] Fix | Delete
'base_attr_name' => 'button_color',
[315] Fix | Delete
'selector' => '%%order_class%% input.et_pb_searchsubmit',
[316] Fix | Delete
'hover_pseudo_selector_location' => 'suffix',
[317] Fix | Delete
'sticky_pseudo_selector_location' => 'prefix',
[318] Fix | Delete
'css_property' => array( 'background-color', 'border-color' ),
[319] Fix | Delete
'important' => true,
[320] Fix | Delete
'render_slug' => $render_slug,
[321] Fix | Delete
'type' => 'color',
[322] Fix | Delete
)
[323] Fix | Delete
);
[324] Fix | Delete
[325] Fix | Delete
$this->generate_styles(
[326] Fix | Delete
array(
[327] Fix | Delete
'base_attr_name' => 'button_color',
[328] Fix | Delete
'selector' => '%%order_class%% input.et_pb_s',
[329] Fix | Delete
'hover_pseudo_selector_location' => 'suffix',
[330] Fix | Delete
'sticky_pseudo_selector_location' => 'prefix',
[331] Fix | Delete
'css_property' => 'border-color',
[332] Fix | Delete
'important' => true,
[333] Fix | Delete
'render_slug' => $render_slug,
[334] Fix | Delete
'type' => 'color',
[335] Fix | Delete
)
[336] Fix | Delete
);
[337] Fix | Delete
[338] Fix | Delete
// Placeholder Color.
[339] Fix | Delete
$placeholder_selectors = array(
[340] Fix | Delete
'%%order_class%% form input.et_pb_s::-webkit-input-placeholder',
[341] Fix | Delete
'%%order_class%% form input.et_pb_s::-moz-placeholder',
[342] Fix | Delete
'%%order_class%% form input.et_pb_s:-ms-input-placeholder',
[343] Fix | Delete
);
[344] Fix | Delete
[345] Fix | Delete
$this->generate_styles(
[346] Fix | Delete
array(
[347] Fix | Delete
'base_attr_name' => 'placeholder_color',
[348] Fix | Delete
'selector' => join( ', ', $placeholder_selectors ),
[349] Fix | Delete
'hover_pseudo_selector_location' => 'suffix',
[350] Fix | Delete
'sticky_pseudo_selector_location' => 'prefix',
[351] Fix | Delete
'css_property' => 'color',
[352] Fix | Delete
'important' => true,
[353] Fix | Delete
'render_slug' => $render_slug,
[354] Fix | Delete
'type' => 'color',
[355] Fix | Delete
)
[356] Fix | Delete
);
[357] Fix | Delete
[358] Fix | Delete
if ( '' !== $input_line_height ) {
[359] Fix | Delete
$el_style = array(
[360] Fix | Delete
'selector' => '%%order_class%% input.et_pb_s',
[361] Fix | Delete
'declaration' => 'height: auto; min-height: 0;',
[362] Fix | Delete
);
[363] Fix | Delete
ET_Builder_Element::set_style( $render_slug, $el_style );
[364] Fix | Delete
}
[365] Fix | Delete
[366] Fix | Delete
// Module classnames
[367] Fix | Delete
$this->add_classname(
[368] Fix | Delete
array(
[369] Fix | Delete
$this->get_text_orientation_classname( true ),
[370] Fix | Delete
)
[371] Fix | Delete
);
[372] Fix | Delete
[373] Fix | Delete
// Background layout class names.
[374] Fix | Delete
$background_layout_class_names = et_pb_background_layout_options()->get_background_layout_class( $this->props );
[375] Fix | Delete
$this->add_classname( $background_layout_class_names );
[376] Fix | Delete
[377] Fix | Delete
if ( 'on' !== $show_button ) {
[378] Fix | Delete
$this->add_classname( 'et_pb_hide_search_button' );
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
// Background layout data attributes.
[382] Fix | Delete
$data_background_layout = et_pb_background_layout_options()->get_background_layout_attrs( $this->props );
[383] Fix | Delete
[384] Fix | Delete
$multi_view_show_button_data_attr = $multi_view->render_attrs(
[385] Fix | Delete
array(
[386] Fix | Delete
'classes' => array(
[387] Fix | Delete
'et_pb_hide_search_button' => array(
[388] Fix | Delete
'show_button' => 'off',
[389] Fix | Delete
),
[390] Fix | Delete
),
[391] Fix | Delete
)
[392] Fix | Delete
);
[393] Fix | Delete
[394] Fix | Delete
$output = sprintf(
[395] Fix | Delete
'<div%3$s class="%2$s"%12$s%13$s>
[396] Fix | Delete
%11$s
[397] Fix | Delete
%10$s
[398] Fix | Delete
<form role="search" method="get" class="et_pb_searchform" action="%1$s">
[399] Fix | Delete
<div>
[400] Fix | Delete
<label class="screen-reader-text" for="s">%8$s</label>
[401] Fix | Delete
%7$s
[402] Fix | Delete
<input type="hidden" name="et_pb_searchform_submit" value="et_search_proccess" />
[403] Fix | Delete
%4$s
[404] Fix | Delete
%5$s
[405] Fix | Delete
%6$s
[406] Fix | Delete
<input type="submit" value="%9$s" class="et_pb_searchsubmit">
[407] Fix | Delete
</div>
[408] Fix | Delete
</form>
[409] Fix | Delete
</div> <!-- .et_pb_text -->',
[410] Fix | Delete
esc_url( home_url( '/' ) ),
[411] Fix | Delete
$this->module_classname( $render_slug ),
[412] Fix | Delete
$this->module_id(),
[413] Fix | Delete
'' !== $exclude_categories ? sprintf( '<input type="hidden" name="et_pb_search_cat" value="%1$s" />', esc_attr( $exclude_categories ) ) : '',
[414] Fix | Delete
'on' !== $exclude_posts ? '<input type="hidden" name="et_pb_include_posts" value="yes" />' : '', // #5
[415] Fix | Delete
'on' !== $exclude_pages ? '<input type="hidden" name="et_pb_include_pages" value="yes" />' : '',
[416] Fix | Delete
$placeholder,
[417] Fix | Delete
esc_html__( 'Search for:', 'et_builder' ),
[418] Fix | Delete
esc_attr__( 'Search', 'et_builder' ),
[419] Fix | Delete
$video_background, // #10
[420] Fix | Delete
$parallax_image_background,
[421] Fix | Delete
et_core_esc_previously( $data_background_layout ),
[422] Fix | Delete
$multi_view_show_button_data_attr
[423] Fix | Delete
);
[424] Fix | Delete
[425] Fix | Delete
return $output;
[426] Fix | Delete
}
[427] Fix | Delete
}
[428] Fix | Delete
[429] Fix | Delete
new ET_Builder_Module_Search();
[430] Fix | Delete
[431] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function