You appear to be a bot. Output may be restricted
Description
Replaces common plain text characters into formatted entitiesAs an example,
- 'cause today's effort makes it worth tomorrow's "holiday" …
- ’cause today’s effort makes it worth tomorrow’s “holiday” …
Usage
$string = wptexturize_after_shortcodes( $text, $reset );
Parameters
- $text
- ( string ) required – The text to be formatted
- $reset
- ( bool ) optional – Set to true for unit testing. Translated patterns will reset.
Returns
string The string replaced with html entitiesSource
File name: oik-css/includes/formatting-later.phpLines:
201 to 274 of 274
. '\]?'; // Shortcodes may end with ]] $regex = '/(' // Capture the entire match. . '<' // Find start of element. . '(?(?=!--)' // Is this a comment? . $comment_regex // Find end of comment. . '|' . '[^>]+>' // Find end of element. . ')' //. '|' //. $shortcode_regex // Find shortcodes. . ')/s'; $textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); foreach ( $textarr as &$curl ) { // Only call _wptexturize_pushpop_element if $curl is a delimiter. $first = $curl[0]; if ( '<' === $first && '<!--' === substr( $curl, 0, 4 ) ) { // This is an HTML comment delimeter. continue; } 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 ); } } } $text = implode( '', $textarr ); // Replace each & with & unless it already looks like an entity. $text = preg_replace('/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $text); return $text; }View on GitHub View on Trac