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