: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Retrieves mail-tags that have been replaced by this instance.
* @return array List of mail-tags replaced.
public function get_replaced_tags() {
return $this->replaced_tags;
* Replaces mail-tags based on regexp.
public function replace_tags() {
$regex = '/(\[?)\[[\t ]*'
. '([a-zA-Z_][0-9a-zA-Z:._-]*)' // [2] = name
. '((?:[\t ]+"[^"]*"|[\t ]+\'[^\']*\')*)' // [3] = values
return preg_replace_callback( $regex, $this->callback, $this->content );
* Callback function for replacement. For HTML message body.
private function replace_tags_callback_html( $matches ) {
return $this->replace_tags_callback( $matches, true );
* Callback function for replacement.
private function replace_tags_callback( $matches, $html = false ) {
// allow [[foo]] syntax for escaping a tag
and $matches[4] == ']' ) {
return substr( $matches[0], 1, -1 );
$mail_tag = new WPCF7_MailTag( $tag, $tagname, $values );
$field_name = $mail_tag->field_name();
$submission = WPCF7_Submission::get_instance();
? $submission->get_posted_data( $field_name )
if ( $mail_tag->get_option( 'do_not_heat' ) ) {
$submitted = wp_unslash( $_POST[$field_name] ?? '' );
if ( null !== $replaced ) {
if ( $format = $mail_tag->get_option( 'format' ) ) {
$replaced = $this->format( $replaced, $format );
$separator = ( 'body' === WPCF7_Mail::get_current_component_name() )
? wp_get_list_item_separator()
$replaced = wpcf7_flat_join( $replaced, array(
'separator' => $separator,
$replaced = esc_html( $replaced );
$replaced = wptexturize( $replaced );
if ( $form_tag = $mail_tag->corresponding_form_tag() ) {
$replaced = apply_filters(
"wpcf7_mail_tag_replaced_{$type}", $replaced,
$submitted, $html, $mail_tag
$replaced = apply_filters(
'wpcf7_mail_tag_replaced', $replaced,
$submitted, $html, $mail_tag
if ( null !== $replaced ) {
$replaced = trim( $replaced );
$this->replaced_tags[$tag] = $replaced;
$special = apply_filters( 'wpcf7_special_mail_tags', null,
$mail_tag->tag_name(), $html, $mail_tag
if ( null !== $special ) {
$this->replaced_tags[$tag] = $special;
* Formats string based on the formatting option in the form-tag.
public function format( $original, $format ) {
$original = (array) $original;
foreach ( $original as $key => $value ) {
if ( preg_match( '/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $value ) ) {
$datetime = date_create( $value, wp_timezone() );
if ( false !== $datetime ) {
$original[$key] = wp_date( $format, $datetime->getTimestamp() );