Ticket #6297: balance-tags-with-more-r7392.patch
File balance-tags-with-more-r7392.patch, 3.2 KB (added by , 17 years ago) |
---|
-
wp-includes/default-filters.php
69 69 } 70 70 71 71 // Places to balance tags on input 72 $filters = array(' content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content');72 $filters = array('excerpt_save_pre', 'comment_save_pre', 'pre_comment_content'); 73 73 foreach ( $filters as $filter ) { 74 74 add_filter( $filter, 'balanceTags', 50); 75 75 } 76 add_filter( 'content_save_pre', 'balanceTagsWithPages', 50 ); 76 77 77 78 // Format strings for display. 78 79 $filters = array('comment_author', 'term_name', 'link_name', 'link_description', -
wp-includes/post.php
124 124 * @param string $post {@internal Missing Description}} 125 125 * @return array {@internal Missing Description}} 126 126 */ 127 function get_extended($post ) {127 function get_extended($post, $strip_whitespace = true) { 128 128 //Match the new style more links 129 129 if ( preg_match('/<!--more(.*?)?-->/', $post, $matches) ) { 130 130 list($main, $extended) = explode($matches[0], $post, 2); 131 $delim = '<!--more' . $matches[1] . '-->'; 131 132 } else { 132 133 $main = $post; 133 134 $extended = ''; 135 $delim = ''; 134 136 } 135 137 136 138 // Strip leading and trailing whitespace 137 $main = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $main); 138 $extended = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $extended); 139 if ( $strip_whitespace ) { 140 $main = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $main); 141 $extended = preg_replace('/^[\s]*(.*)[\s]*$/', '\\1', $extended); 142 } 143 144 return array('main' => $main, 'extended' => $extended, 'delimiter' => $delim); 145 } 139 146 140 return array('main' => $main, 'extended' => $extended); 147 /** 148 * split_nextpage() - split post text into pages separated by <!--nextpage--> 149 * 150 * {@internal Missing Long Description}} 151 * 152 * @package WordPress 153 * @subpackage Post 154 * @since 2.5 155 * 156 * @param string $post {@internal Missing Description}} 157 * @return array {@internal Missing Description}} 158 */ 159 function split_nextpage($text, $include_delim = false) { 160 $flags = 0; 161 if ( $include_delim ) 162 $flags = PREG_SPLIT_DELIM_CAPTURE; 163 164 return preg_split('/(<!--nextpage-->)/', $text, -1, $flags); 141 165 } 142 166 143 167 /** -
wp-includes/formatting.php
436 436 return force_balance_tags( $text ); 437 437 } 438 438 439 // like balanceTags, but separately balance each portion (as split by the more and nextpage tags) 440 function balanceTagsWithPages( $text, $force = false ) { 441 if ( !$force && get_option('use_balanceTags') == 0 ) 442 return $text; 443 444 $parts = get_extended( $text, false ); 445 446 $slices = split_nextpage( $parts['main'], true ); 447 if ( $parts['delimiter'] ) 448 $slices[] = $parts['delimiter']; 449 $slices = array_merge( $slices, split_nextpage( $parts['extended'], true ) ); 450 451 $out = ''; 452 foreach ( $slices as $slice ) 453 $out .= force_balance_tags($slice); 454 455 return $out; 456 } 457 439 458 /* 440 459 force_balance_tags 441 460