wpcf7_mail_replace_tags()
Replaces all mail-tags within the given text content.
Хуков нет.
Возвращает
Строку
. Result of replacement.
Использование
wpcf7_mail_replace_tags( $content, $args );
- $content(строка) (обязательный)
- Text including mail-tags.
- $args(строка|массив)
- Output options.
По умолчанию: ''
Код wpcf7_mail_replace_tags() wpcf7 mail replace tags CF7 5.7.4
function wpcf7_mail_replace_tags( $content, $args = '' ) { $args = wp_parse_args( $args, array( 'html' => false, 'exclude_blank' => false, ) ); if ( is_array( $content ) ) { foreach ( $content as $key => $value ) { $content[$key] = wpcf7_mail_replace_tags( $value, $args ); } return $content; } $content = explode( "\n", $content ); foreach ( $content as $num => $line ) { $line = new WPCF7_MailTaggedText( $line, $args ); $replaced = $line->replace_tags(); if ( $args['exclude_blank'] ) { $replaced_tags = $line->get_replaced_tags(); if ( empty( $replaced_tags ) or array_filter( $replaced_tags, 'strlen' ) ) { $content[$num] = $replaced; } else { unset( $content[$num] ); // Remove a line. } } else { $content[$num] = $replaced; } } $content = implode( "\n", $content ); return $content; }