Advertisements

clean_pre

Definition:
function clean_pre($matches) {}

Accepts matches array from preg_replace_callback in wpautop() or a string.
Ensures that the contents of a <pre>…</pre> HTML block are not converted into paragraphs or line-breaks.

Parameters

  • array|string $matches: The array or string

Return values

returns:The pre block without paragraph/line-break conversion.

Source code

function clean_pre($matches) {

	if ( is_array($matches) )

		$text = $matches[1] . $matches[2] . "</pre>";

	else

		$text = $matches;



	$text = str_replace('<br />', '', $text);

	$text = str_replace('<p>', "\n", $text);

	$text = str_replace('</p>', '', $text);



	return $text;

}

629

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: