mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
Separate the removal of <p> wrapping from shortcodes into another function and apply it with different filter, props miqrogroove, props mdawaffe, see #11257, see #11249
git-svn-id: http://svn.automattic.com/wordpress/trunk@12302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bfd934032c
commit
31bc813a6d
@ -88,9 +88,10 @@ foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description',
|
||||
|
||||
// Format text area for display.
|
||||
foreach ( array( 'term_description' ) as $filter ) {
|
||||
add_filter( $filter, 'wptexturize' );
|
||||
add_filter( $filter, 'convert_chars' );
|
||||
add_filter( $filter, 'wpautop' );
|
||||
add_filter( $filter, 'wptexturize' );
|
||||
add_filter( $filter, 'convert_chars' );
|
||||
add_filter( $filter, 'wpautop' );
|
||||
add_filter( $filter, 'shortcode_unautop');
|
||||
}
|
||||
|
||||
// Format for RSS
|
||||
@ -107,13 +108,15 @@ add_filter( 'the_content', 'wptexturize' );
|
||||
add_filter( 'the_content', 'convert_smilies' );
|
||||
add_filter( 'the_content', 'convert_chars' );
|
||||
add_filter( 'the_content', 'wpautop' );
|
||||
add_filter( 'the_content', 'shortcode_unautop' );
|
||||
add_filter( 'the_content', 'prepend_attachment' );
|
||||
|
||||
add_filter( 'the_excerpt', 'wptexturize' );
|
||||
add_filter( 'the_excerpt', 'convert_smilies' );
|
||||
add_filter( 'the_excerpt', 'convert_chars' );
|
||||
add_filter( 'the_excerpt', 'wpautop' );
|
||||
add_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
|
||||
add_filter( 'the_excerpt', 'wptexturize' );
|
||||
add_filter( 'the_excerpt', 'convert_smilies' );
|
||||
add_filter( 'the_excerpt', 'convert_chars' );
|
||||
add_filter( 'the_excerpt', 'wpautop' );
|
||||
add_filter( 'the_excerpt', 'shortcode_unautop');
|
||||
add_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
|
||||
|
||||
add_filter( 'comment_text', 'wptexturize' );
|
||||
add_filter( 'comment_text', 'convert_chars' );
|
||||
|
@ -179,6 +179,7 @@ function clean_pre($matches) {
|
||||
* @return string Text which has been converted into correct paragraph tags.
|
||||
*/
|
||||
function wpautop($pee, $br = 1) {
|
||||
|
||||
if ( trim($pee) === '' )
|
||||
return '';
|
||||
$pee = $pee . "\n"; // just to make things a little easier, pad the end
|
||||
@ -216,7 +217,28 @@ function wpautop($pee, $br = 1) {
|
||||
if (strpos($pee, '<pre') !== false)
|
||||
$pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee );
|
||||
$pee = preg_replace( "|\n</p>$|", '</p>', $pee );
|
||||
$pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone
|
||||
|
||||
return $pee;
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't auto-p wrap shortcodes that stand alone
|
||||
*
|
||||
* Ensures that shortcodes are not wrapped in <<p>>...<</p>>.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param string $pee The content.
|
||||
* @return string The filtered content.
|
||||
*/
|
||||
function shortcode_unautop($pee) {
|
||||
global $shortcode_tags;
|
||||
|
||||
if ( !empty($shortcode_tags) && is_array($shortcode_tags) ) {
|
||||
$tagnames = array_keys($shortcode_tags);
|
||||
$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
|
||||
$pee = preg_replace('/<p>\\s*?(\\[(' . $tagregexp . ')\\b.*?\\/?\\](?:.+?\\[\\/\\2\\])?)\\s*<\\/p>/s', '$1', $pee);
|
||||
}
|
||||
|
||||
return $pee;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user