diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index bc1d9fd25c..65d00d1e97 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -21,13 +21,22 @@ * Code within certain html blocks are skipped. * * @since 0.71 - * @uses $wp_cockneyreplace Array of formatted entities for certain common phrases + * + * @global array $wp_cockneyreplace Array of formatted entities for certain common phrases + * @global array $shortcode_tags + * @staticvar array $static_characters + * @staticvar array $static_replacements + * @staticvar array $dynamic_characters + * @staticvar array $dynamic_replacements + * @staticvar array $default_no_texturize_tags + * @staticvar array $default_no_texturize_shortcodes + * @staticvar bool $run_texturize * * @param string $text The text to be formatted - * @param bool $reset Set to true for unit testing. Translated patterns will reset. + * @param bool $reset Set to true for unit testing. Translated patterns will reset. * @return string The string replaced with html entities */ -function wptexturize($text, $reset = false) { +function wptexturize( $text, $reset = false ) { global $wp_cockneyreplace, $shortcode_tags; static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements, $default_no_texturize_tags, $default_no_texturize_shortcodes, $run_texturize = true; @@ -297,9 +306,7 @@ function wptexturize($text, $reset = false) { $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; + return preg_replace( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', '&', $text ); } /** @@ -313,10 +320,10 @@ function wptexturize($text, $reset = false) { * @access private * * @param string $text Text to check. Must be a tag like `` or `[shortcode]`. - * @param array $stack List of open tag elements. - * @param array $disabled_elements The tag names to match against. Spaces are not allowed in tag names. + * @param array $stack List of open tag elements. + * @param array $disabled_elements The tag names to match against. Spaces are not allowed in tag names. */ -function _wptexturize_pushpop_element($text, &$stack, $disabled_elements) { +function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) { // Is it an opening tag or closing tag? if ( '/' !== $text[1] ) { $opening_tag = true; @@ -370,7 +377,7 @@ function _wptexturize_pushpop_element($text, &$stack, $disabled_elements) { * after paragraphing. Default true. * @return string Text which has been converted into correct paragraph tags. */ -function wpautop($pee, $br = true) { +function wpautop( $pee, $br = true ) { $pre_tags = array(); if ( trim($pee) === '' ) @@ -419,7 +426,7 @@ function wpautop($pee, $br = true) { $pee = preg_replace('!(' . $allblocks . '>)!', "$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); // Collapse line breaks before and after
|', '', $pee); + $pee = preg_replace('|\s*
|', '', $pee); // Add a closinginside