wpcf7_autop()
Replaces double line breaks with paragraph elements.
Хуков нет.
Возвращает
Строку. Text which has been converted into correct paragraph tags.
Использование
wpcf7_autop( $input, $br );
- $input(строка) (обязательный)
- The text which has to be formatted.
- $br(true|false)
- If set, this will convert all remaining line breaks after paragraphing.
По умолчанию:true
Код wpcf7_autop() wpcf7 autop CF7 6.1.5
function wpcf7_autop( $input, $br = true ) {
$placeholders = array();
// Replace non-HTML embedded elements with placeholders.
$input = preg_replace_callback(
'/<(math|svg).*?<\/\1>/is',
static function ( $matches ) use ( &$placeholders ) {
$placeholder = sprintf(
'<%1$s id="%2$s" />',
WPCF7_HTMLFormatter::placeholder_inline,
hash( 'sha256', $matches[0] )
);
list( $placeholder ) =
WPCF7_HTMLFormatter::normalize_start_tag( $placeholder );
$placeholders[$placeholder] = $matches[0];
return $placeholder;
},
$input
);
$formatter = new WPCF7_HTMLFormatter( array(
'auto_br' => $br,
'allowed_html' => null,
) );
$chunks = $formatter->separate_into_chunks( $input );
$output = $formatter->format( $chunks );
// Restore from placeholders.
$output = str_replace(
array_keys( $placeholders ),
array_values( $placeholders ),
$output
);
return $output;
}