Changeset 17636
- Timestamp:
- 04/13/2011 05:11:35 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r17614 r17636 29 29 function wptexturize($text) { 30 30 global $wp_cockneyreplace; 31 static $static_setup = false, $opening_quote, $closing_quote, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements; 32 $output = ''; 33 $curl = ''; 34 $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); 35 $stop = count($textarr); 36 37 // No need to set up these variables more than once 38 if (!$static_setup) { 31 static $opening_quote, $closing_quote, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements; 32 33 // No need to set up these static variables more than once 34 if ( empty( $opening_quote ) ) { 39 35 /* translators: opening curly quote */ 40 36 $opening_quote = _x('“', 'opening curly quote'); … … 59 55 $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/\'(\d)/', '/(\s|\A|[([{<]|")\'/', '/(\d)"/', '/(\d)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/'); 60 56 $dynamic_replacements = array('’$1','’$1', '$1‘', '$1″', '$1′', '$1’$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', '’$1', '$1×$2'); 61 62 $static_setup = true;63 57 } 64 58 … … 71 65 $no_texturize_shortcodes_stack = array(); 72 66 73 for ( $i = 0; $i < $stop; $i++ ) { 74 $curl = $textarr[$i]; 75 76 if ( !empty($curl) && '<' != $curl[0] && '[' != $curl[0] 77 && empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack)) { 78 // This is not a tag, nor is the texturization disabled 79 // static strings 67 $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); 68 69 foreach ( $textarr as &$curl ) { 70 if ( empty( $curl ) ) 71 continue; 72 73 // Only call _wptexturize_pushpop_element if first char is correct tag opening 74 $first = $curl[0]; 75 if ( '<' === $first ) { 76 _wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>'); 77 } elseif ( '[' === $first ) { 78 _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']'); 79 } elseif ( empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack) ) { 80 // This is not a tag, nor is the texturization disabled static strings 80 81 $curl = str_replace($static_characters, $static_replacements, $curl); 81 82 // regular expressions 82 83 $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); 83 } elseif (!empty($curl)) {84 /*85 * Only call _wptexturize_pushpop_element if first char is correct86 * tag opening87 */88 if ('<' == $curl[0])89 _wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>');90 elseif ('[' == $curl[0])91 _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']');92 84 } 93 94 85 $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl); 95 $output .= $curl; 96 } 97 98 return $output; 86 } 87 return implode( '', $textarr ); 99 88 } 100 89
Note: See TracChangeset
for help on using the changeset viewer.