- // Only call _wptexturize_pushpop_element if first char is correct tag opening
- $first = $curl[0];
- if ( '<' === $first ) {
- _wptexturize_pushpop_element($curl, $no_texturize_tags_stack, $no_texturize_tags, '<', '>');
- } elseif ( '[' === $first ) {
- _wptexturize_pushpop_element($curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes, '[', ']');
- } elseif ( empty($no_texturize_shortcodes_stack) && empty($no_texturize_tags_stack) ) {
- // This is not a tag, nor is the texturization disabled static strings
- $curl = str_replace($static_characters, $static_replacements, $curl);
- // regular expressions
- $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
+ } elseif ( '<' === $first && '>' === substr( $curl, -1 ) ) {
+ // This is an HTML element delimiter.
+
+ _wptexturize_pushpop_element( $curl, $no_texturize_tags_stack, $no_texturize_tags );
+
+ } elseif ( '' === trim( $curl ) ) {
+ // This is a newline between delimiters. Performance improves when we check this.
+
+ continue;
+
+ } elseif ( '[' === $first && 1 === preg_match( '/^' . $shortcode_regex . '$/', $curl ) ) {
+ // This is a shortcode delimiter.
+
+ if ( '[[' !== substr( $curl, 0, 2 ) && ']]' !== substr( $curl, -2 ) ) {
+ // Looks like a normal shortcode.
+ _wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes );
+ } else {
+ // Looks like an escaped shortcode.
+ continue;
+ }
+
+ } elseif ( empty( $no_texturize_shortcodes_stack ) && empty( $no_texturize_tags_stack ) ) {
+ // This is neither a delimiter, nor is this content inside of no_texturize pairs. Do texturize.
+
+ $curl = str_replace( $static_characters, $static_replacements, $curl );
+
+ if ( false !== strpos( $curl, "'" ) ) {
+ $curl = preg_replace( $dynamic_characters['apos'], $dynamic_replacements['apos'], $curl );
+ }
+ if ( false !== strpos( $curl, '"' ) ) {
+ $curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl );
+ }
+ if ( false !== strpos( $curl, '-' ) ) {
+ $curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl );
+ }
+
+ // 9x9 (times), but never 0x9999
+ if ( 1 === preg_match( '/(?<=\d)x\d/', $curl ) ) {
+ // Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one!
+ $curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1×$2', $curl );
+ }