WordPress wpautop
© Copyright Frank D. Kanu 2000-2008
The wpautop function (file formatting.php) is rather buggy: not all <p> have a </p> and vice versa. Duplicated <br /> get replaced with a single one.
The first is bad for obvious reasons, the second tampers with my formatting. I changed
Below is the changed function the way I use it:
No <p> and </p> but <br /> instead and leaving multiple line breaks (even when empty) intact.
You might also want to check
wpautop - bug
Missing close </p> tag in wpautop
Disable wpautop Plugin
Technorati (All Links are external): buggy formatting wordpress wpautop code review general it
The wpautop function (file formatting.php) is rather buggy: not all <p> have a </p> and vice versa. Duplicated <br /> get replaced with a single one.
The first is bad for obvious reasons, the second tampers with my formatting. I changed
Below is the changed function the way I use it:
No <p> and </p> but <br /> instead and leaving multiple line breaks (even when empty) intact.
You might also want to check
wpautop - bug
Missing close </p> tag in wpautop
Disable wpautop Plugin
function wpautop($pee, $br = 1) {
$pee = $pee . "n"; // just to make things a little easier, pad the end
$pee = preg_replace('|<br />s*<br />|', "nn", $pee);
// Space things out a little
$allblocks = '(?:caption|colgroup|div|dl|dd|dt|ul|ol|pre|select|form|address|math|style|script|object|input|param)';
$pee = preg_replace('!(</' . $allblocks . '>)!', "$1n", preg_replace('!(<' . $allblocks . '[^>]*>)!', "n$1", $pee));
$pee = str_replace('[<br />]*<br /><br /></blockquote>', '<br /><br /></blockquote>',
str_replace('</blockquote>', '<br /><br /></blockquote>', str_replace('<br>', '<br />', $pee)));
$pee = str_replace(array("rn", "r"), "n", $pee); // cross-platform newlines
if ($br) {
$pee = preg_replace('/<(script|style).*?</\1>/se', 'str_replace("n", "<WPPreserveNewline />", "\0")', $pee);
$pee = preg_replace('|(?<!<br />)n|', "<br />n", $pee); // optionally make line breaks
$pee = str_replace('<WPPreserveNewline />', "n", $pee);
}
if ( strstr( $pee, '<pre' ) )
$pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee);
return $pee;
}Tags:
buggy formatting wordpress wpautopTechnorati (All Links are external): buggy formatting wordpress wpautop code review general it








09:09 on Monday, April 7th, 2008