diff -r c7c34916027a -r 177826044cd9 wp/wp-includes/formatting.php --- a/wp/wp-includes/formatting.php Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-includes/formatting.php Mon Oct 14 18:28:13 2019 +0200 @@ -50,23 +50,23 @@ */ function wptexturize( $text, $reset = false ) { global $wp_cockneyreplace, $shortcode_tags; - static $static_characters = null, - $static_replacements = null, - $dynamic_characters = null, - $dynamic_replacements = null, - $default_no_texturize_tags = null, + static $static_characters = null, + $static_replacements = null, + $dynamic_characters = null, + $dynamic_replacements = null, + $default_no_texturize_tags = null, $default_no_texturize_shortcodes = null, - $run_texturize = true, - $apos = null, - $prime = null, - $double_prime = null, - $opening_quote = null, - $closing_quote = null, - $opening_single_quote = null, - $closing_single_quote = null, - $open_q_flag = '', - $open_sq_flag = '', - $apos_flag = ''; + $run_texturize = true, + $apos = null, + $prime = null, + $double_prime = null, + $opening_quote = null, + $closing_quote = null, + $opening_single_quote = null, + $closing_single_quote = null, + $open_q_flag = '', + $open_sq_flag = '', + $apos_flag = ''; // If there's nothing to do, just stop. if ( empty( $text ) || false === $run_texturize ) { @@ -117,35 +117,52 @@ /* translators: em dash */ $em_dash = _x( '—', 'em dash' ); - $default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt'); - $default_no_texturize_shortcodes = array('code'); + $default_no_texturize_tags = array( 'pre', 'code', 'kbd', 'style', 'script', 'tt' ); + $default_no_texturize_shortcodes = array( 'code' ); // if a plugin has provided an autocorrect array, use it - if ( isset($wp_cockneyreplace) ) { - $cockney = array_keys( $wp_cockneyreplace ); + if ( isset( $wp_cockneyreplace ) ) { + $cockney = array_keys( $wp_cockneyreplace ); $cockneyreplace = array_values( $wp_cockneyreplace ); } else { /* translators: This is a comma-separated list of words that defy the syntax of quotations in normal use, * for example... 'We do not have enough words yet' ... is a typical quoted phrase. But when we write * lines of code 'til we have enough of 'em, then we need to insert apostrophes instead of quotes. */ - $cockney = explode( ',', _x( "'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em", - 'Comma-separated list of words to texturize in your language' ) ); - - $cockneyreplace = explode( ',', _x( '’tain’t,’twere,’twas,’tis,’twill,’til,’bout,’nuff,’round,’cause,’em', - 'Comma-separated list of replacement words in your language' ) ); + $cockney = explode( + ',', + _x( + "'tain't,'twere,'twas,'tis,'twill,'til,'bout,'nuff,'round,'cause,'em", + 'Comma-separated list of words to texturize in your language' + ) + ); + + $cockneyreplace = explode( + ',', + _x( + '’tain’t,’twere,’twas,’tis,’twill,’til,’bout,’nuff,’round,’cause,’em', + 'Comma-separated list of replacement words in your language' + ) + ); } - $static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney ); + $static_characters = array_merge( array( '...', '``', '\'\'', ' (tm)' ), $cockney ); $static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); - // Pattern-based replacements of characters. // Sort the remaining patterns into several arrays for performance tuning. - $dynamic_characters = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); - $dynamic_replacements = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); - $dynamic = array(); - $spaces = wp_spaces_regexp(); + $dynamic_characters = array( + 'apos' => array(), + 'quote' => array(), + 'dash' => array(), + ); + $dynamic_replacements = array( + 'apos' => array(), + 'quote' => array(), + 'dash' => array(), + ); + $dynamic = array(); + $spaces = wp_spaces_regexp(); // '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. if ( "'" !== $apos || "'" !== $closing_single_quote ) { @@ -157,7 +174,7 @@ // '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0. if ( "'" !== $apos ) { - $dynamic[ '/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/' ] = $apos_flag; + $dynamic['/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/'] = $apos_flag; } // Quoted Numbers like '0.42' @@ -175,9 +192,9 @@ $dynamic[ '/(?&/\[\]\x00-\x20=]++)@', $text, $matches ); - $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); + $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); $found_shortcodes = ! empty( $tagnames ); - $shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex( $tagnames ) : ''; - $regex = _get_wptexturize_split_regex( $shortcode_regex ); + $shortcode_regex = $found_shortcodes ? _get_wptexturize_shortcode_regex( $tagnames ) : ''; + $regex = _get_wptexturize_split_regex( $shortcode_regex ); $textarr = preg_split( $regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); @@ -249,7 +266,6 @@ _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; @@ -264,7 +280,6 @@ // 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. @@ -314,9 +329,9 @@ * @return string The $haystack value after primes and quotes replacements. */ function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quote ) { - $spaces = wp_spaces_regexp(); - $flag = ''; - $quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|>|" . $spaces . ")/"; + $spaces = wp_spaces_regexp(); + $flag = ''; + $quote_pattern = "/$needle(?=\\Z|[.,:;!?)}\\-\\]]|>|" . $spaces . ')/'; $prime_pattern = "/(?<=\\d)$needle/"; $flag_after_digit = "/(?<=\\d)$flag/"; $flag_no_digit = "/(?', $pee ); - $last_pee = array_pop($pee_parts); - $pee = ''; - $i = 0; + $last_pee = array_pop( $pee_parts ); + $pee = ''; + $i = 0; foreach ( $pee_parts as $pee_part ) { - $start = strpos($pee_part, ''; + $name = "
";
+			$pre_tags[ $name ] = substr( $pee_part, $start ) . '';
 
 			$pee .= substr( $pee_part, 0, $start ) . $name;
 			$i++;
@@ -474,21 +490,21 @@
 		$pee .= $last_pee;
 	}
 	// Change multiple 
s into two line breaks, which will turn into paragraphs. - $pee = preg_replace('|\s*|', "\n\n", $pee); + $pee = preg_replace( '|\s*|', "\n\n", $pee ); $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; // Add a double line break above block-level opening tags. - $pee = preg_replace('!(<' . $allblocks . '[\s/>])!', "\n\n$1", $pee); + $pee = preg_replace( '!(<' . $allblocks . '[\s/>])!', "\n\n$1", $pee ); // Add a double line break below block-level closing tags. - $pee = preg_replace('!()!', "$1\n\n", $pee); + $pee = preg_replace( '!()!', "$1\n\n", $pee ); // Standardize newline characters to "\n". - $pee = str_replace(array("\r\n", "\r"), "\n", $pee); + $pee = str_replace( array( "\r\n", "\r" ), "\n", $pee ); // Find newlines in all elements and add placeholders. - $pee = wp_replace_in_html_tags( $pee, array( "\n" => " " ) ); + $pee = wp_replace_in_html_tags( $pee, array( "\n" => ' ' ) ); // Collapse line breaks before and after