| 1 | --- wp-includes/formatting.php 27 Nov 2010 03:12:10 -0000 1.1 |
|---|
| 2 | +++ wp-includes/formatting.php 3 Dec 2010 05:54:41 -0000 |
|---|
| 3 | @@ -1829,7 +1829,9 @@ |
|---|
| 4 | |
|---|
| 5 | $text = apply_filters('the_content', $text); |
|---|
| 6 | $text = str_replace(']]>', ']]>', $text); |
|---|
| 7 | - $text = strip_tags($text); |
|---|
| 8 | +// jwz: do better tag stripping |
|---|
| 9 | +// $text = strip_tags($text); |
|---|
| 10 | + $text = wp_strip_all_tags($text); |
|---|
| 11 | $excerpt_length = apply_filters('excerpt_length', 55); |
|---|
| 12 | $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]'); |
|---|
| 13 | $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); |
|---|
| 14 | @@ -2770,6 +2772,16 @@ |
|---|
| 15 | */ |
|---|
| 16 | function wp_strip_all_tags($string, $remove_breaks = false) { |
|---|
| 17 | $string = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string ); |
|---|
| 18 | + |
|---|
| 19 | + // jwz: convert P and P-like block tags to \n\n. |
|---|
| 20 | + $string = preg_replace( '@</?\s*(P|UL|OL|DL|BLOCKQUOTE)\b[^>]*?>@si', |
|---|
| 21 | + "\n\n", $string ); |
|---|
| 22 | + // jwz: convert BR and other known block-display tags to \n. |
|---|
| 23 | + $string = preg_replace( '@<(BR|DIV|LI|DT|DD|TR|TD|H\d)\b[^>]*?>@si', |
|---|
| 24 | + "\n", $string ); |
|---|
| 25 | + // jwz: compress newlines |
|---|
| 26 | + $string = preg_replace( "@\n\n\n+@si", "\n\n", $string ); |
|---|
| 27 | + |
|---|
| 28 | $string = strip_tags($string); |
|---|
| 29 | |
|---|
| 30 | if ( $remove_breaks ) |
|---|