: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// check all the required fields, generate error message if required field is empty
$field_value = isset( $_POST[ $value['field_id'] ] ) ? trim( $_POST[ $value['field_id'] ] ) : '';
if ( 'required' === $value['required_mark'] && empty( $field_value ) && ! is_numeric( $field_value ) ) {
$et_error_message .= sprintf( '<p class="et_pb_contact_error_text">%1$s</p>', esc_html__( 'Make sure you fill in all required fields.', 'et_builder' ) );
$et_contact_error = true;
// additional check for email field
if ( 'email' === $value['field_type'] && 'required' === $value['required_mark'] && ! empty( $field_value ) ) {
$contact_email = isset( $_POST[ $value['field_id'] ] ) ? sanitize_email( $_POST[ $value['field_id'] ] ) : '';
if ( ! empty( $contact_email ) && ! is_email( $contact_email ) ) {
$et_error_message .= sprintf( '<p class="et_pb_contact_error_text">%1$s</p>', esc_html__( 'Invalid Email.', 'et_builder' ) );
$et_contact_error = true;
// prepare the array of processed field values in convenient format
if ( false === $et_contact_error ) {
$processed_fields_values[ $value['original_id'] ]['value'] = $field_value;
$processed_fields_values[ $value['original_id'] ]['label'] = $value['field_label'];
// Check form's integrity by comparing fields structure (used for required fields check, etc)
// stored in the shortcode against submitted value generated using JS on the front end
// to prevent data being altered by modifying form markup.
$form_map = $this->get_form_map( $shortcode_content, $et_pb_contact_form_num, $hidden_form_fields );
if ( serialize( $submitted_form_map ) !== serialize( $form_map ) ) {
$et_error_message .= sprintf(
'<p class="et_pb_contact_error_text">%1$s</p>',
esc_html__( 'Invalid submission. Please refresh the page and try again.', 'et_builder' )
$et_contact_error = true;
$et_error_message .= sprintf( '<p class="et_pb_contact_error_text">%1$s</p>', esc_html__( 'Make sure you fill in all required fields.', 'et_builder' ) );
$et_contact_error = true;
if ( false === $nonce_result && isset( $_POST['et_pb_contactform_submit_' . $et_pb_contact_form_num] ) && empty( $_POST['et_pb_contact_et_number_' . $et_pb_contact_form_num] ) ) {
$et_error_message .= sprintf( '<p class="et_pb_contact_error_text">%1$s</p>', esc_html__( 'Please refresh the page and try again.', 'et_builder' ) );
$et_contact_error = true;
// generate digits for captcha
$et_pb_first_digit = rand( 1, 15 );
$et_pb_second_digit = rand( 1, 15 );
if ( ! $et_contact_error && $nonce_result ) {
$et_email_to = '' !== $email
: get_site_option( 'admin_email' );
$et_site_name = get_option( 'blogname' );
$contact_name = isset( $processed_fields_values['name'] ) ? stripslashes( sanitize_text_field( $processed_fields_values['name']['value'] ) ) : '';
if ( '' !== $custom_message ) {
// decode html entites to make sure HTML from the message pattern is rendered properly
$message_pattern = et_builder_convert_line_breaks( html_entity_decode( $custom_message ), "\r\n" );
// insert the data from contact form into the message pattern
foreach ( $processed_fields_values as $key => $value ) {
// strip all tags from each field. Don't strip tags from the entire message to allow using HTML in the pattern.
$message_pattern = str_ireplace( "%%{$key}%%", wp_strip_all_tags( $value['value'] ), $message_pattern );
if ( is_array( $hidden_form_fields ) ) {
foreach ( $hidden_form_fields as $hidden_field_label ) {
$message_pattern = str_ireplace( "%%{$hidden_field_label}%%", '', $message_pattern );
// use default message pattern if custom pattern is not defined
$message_pattern = isset( $processed_fields_values['message']['value'] ) ? $processed_fields_values['message']['value'] : '';
// Add all custom fields into the message body by default
foreach ( $processed_fields_values as $key => $value ) {
if ( ! in_array( $key, array( 'message', 'name', 'email' ) ) ) {
$message_pattern .= "\r\n";
$message_pattern .= sprintf(
'' !== $value['label'] ? $value['label'] : $key,
// strip all tags from the message content
$message_pattern = wp_strip_all_tags( $message_pattern );
$http_host = str_replace( 'www.', '', $_SERVER['HTTP_HOST'] );
$headers[] = "From: \"{$contact_name}\" <mail@{$http_host}>";
// Set `Reply-To` email header based on contact_name and contact_email values
if ( ! empty( $contact_email ) ) {
$contact_name = ! empty( $contact_name ) ? $contact_name : $contact_email;
$headers[] = "Reply-To: \"{$contact_name}\" <{$contact_email}>";
add_filter( 'et_get_safe_localization', 'et_allow_ampersand' );
// don't strip tags at this point to properly send the HTML from pattern. All the unwanted HTML stripped at this point.
$email_message = trim( stripslashes( $message_pattern ) );
wp_mail( apply_filters( 'et_contact_page_email_to', $et_email_to ),
et_get_safe_localization( sprintf(
__( 'New Message From %1$s%2$s', 'et_builder' ),
sanitize_text_field( html_entity_decode( $et_site_name, ENT_QUOTES, 'UTF-8' ) ),
( '' !== $title ? sprintf( _x( ' - %s', 'contact form title separator', 'et_builder' ), $title ) : '' )
! empty( $email_message ) ? $email_message : ' ',
apply_filters( 'et_contact_page_headers', $headers, $contact_name, $contact_email )
remove_filter( 'et_get_safe_localization', 'et_allow_ampersand' );
$et_error_message = sprintf( '<p>%1$s</p>', et_core_esc_previously( $success_message ) );
$current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$et_pb_captcha = sprintf( '
<div class="et_pb_contact_right">
<span class="et_pb_contact_captcha_question">%1$s</span> = <input type="text" size="2" class="input et_pb_contact_captcha" data-first_digit="%3$s" data-second_digit="%4$s" value="" name="et_pb_contact_captcha_%2$s" data-required_mark="required" autocomplete="off">
</div><!-- .et_pb_contact_right -->',
sprintf( '%1$s + %2$s', esc_html( $et_pb_first_digit ), esc_html( $et_pb_second_digit ) ),
esc_attr( $et_pb_contact_form_num ),
esc_attr( $et_pb_first_digit ),
esc_attr( $et_pb_second_digit )
if ( '' === trim( $content ) ) {
$content = do_shortcode( $this->predefined_child_modules() );
if ( $et_contact_error ) {
$multi_view_data_attr = $multi_view->render_attrs( array(
'content' => '{{submit_button_text}}',
<div class="et_pb_contact">
<form class="et_pb_contact_form clearfix" method="post" action="%1$s">
<input type="hidden" value="et_contact_proccess" name="et_pb_contactform_submit_%7$s"/>
<div class="et_contact_bottom_container">
<button type="submit" name="et_builder_submit_button" class="et_pb_contact_submit et_pb_button%6$s"%5$s%9$s%10$s%11$s>%3$s</button>
</div> <!-- .et_pb_contact -->',
( 'on' === $captcha && 'off' === $use_spam_service ? $et_pb_captcha : '' ),
esc_html( $multi_view->get_value( 'submit_button_text' ) ),
wp_nonce_field( 'et-pb-contact-form-submit', '_wpnonce-et-pb-contact-form-submitted-' . $et_pb_contact_form_num, true, false ),
'' !== $custom_icon && 'on' === $button_custom ? sprintf(
esc_attr( et_pb_process_font_icon( $custom_icon ) )
'' !== $custom_icon && 'on' === $button_custom ? ' et_pb_custom_button_icon' : '',
esc_attr( $et_pb_contact_form_num ),
'' !== $custom_icon_tablet && 'on' === $button_custom ? sprintf( ' data-icon-tablet="%1$s"', esc_attr( et_pb_process_font_icon( $custom_icon_tablet ) ) ) : '',
'' !== $custom_icon_phone && 'on' === $button_custom ? sprintf( ' data-icon-phone="%1$s"', esc_attr( et_pb_process_font_icon( $custom_icon_phone ) ) ) : '', // #10
$this->add_classname( array(
'et_pb_contact_form_container',
$this->get_text_orientation_classname(),
// Remove automatically added classname
$this->remove_classname( $render_slug );
// Contact form should always have the ID. Use saved ID or generate automatically
$module_id = '' !== $this->module_id(false) ? $this->module_id(false) : 'et_pb_contact_form_' . $et_pb_contact_form_num;
<div id="%4$s" class="%5$s" data-form_unique_num="%6$s"%7$s>
<div class="et-pb-contact-message">%2$s</div>
</div> <!-- .et_pb_contact_form_container -->
$this->module_classname( $render_slug ),
esc_attr( $et_pb_contact_form_num ),
'on' === $use_redirect && '' !== $redirect_url ? sprintf( ' data-redirect_url="%1$s"', esc_attr( $redirect_url ) ) : '',
$parallax_image_background
* Filter multi view value.
* @see ET_Builder_Module_Helper_MultiViewOptions::filter_value
* @param mixed $raw_value Props raw value.
* @type string $context Context param: content, attrs, visibility, classes.
* @type string $name Module options props name.
* @type string $mode Current data mode: desktop, hover, tablet, phone.
* @type string $attr_key Attribute key for attrs context data. Example: src, class, etc.
* @type string $attr_sub_key Attribute sub key that availabe when passing attrs value as array such as styes. Example: padding-top, margin-botton, etc.
* @param ET_Builder_Module_Helper_MultiViewOptions $multi_view Multiview object instance.
public function multi_view_filter_value( $raw_value, $args, $multi_view ) {
$name = isset( $args['name'] ) ? $args['name'] : '';
$mode = isset( $args['mode'] ) ? $args['mode'] : '';
$fields_need_escape = array(
if ( $raw_value && in_array( $name, $fields_need_escape, true ) ) {
return $this->_esc_attr( $multi_view->get_name_by_mode( $name, $mode ), 'none', $raw_value );
} else if ( 'submit_button_text' === $name ) {
if ( '' === trim( $raw_value ) ) {
$raw_value = __( 'Submit', 'et_builder' );
return esc_html( $raw_value );
new ET_Builder_Module_Contact_Form;