X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/38ac4bc40322ecdc4052db4263466573e01fa51f..6359b807ff8b4ffa151d8756cdefb861c6c1d4db:/wp-includes/class-wp-embed.php diff --git a/wp-includes/class-wp-embed.php b/wp-includes/class-wp-embed.php index eda4467c..e3426ab8 100644 --- a/wp-includes/class-wp-embed.php +++ b/wp-includes/class-wp-embed.php @@ -312,11 +312,14 @@ class WP_Embed { * @return string Potentially modified $content. */ public function autoembed( $content ) { - // Strip newlines from all elements. - $content = wp_replace_in_html_tags( $content, array( "\n" => " " ) ); + // Replace line breaks from all HTML elements with placeholders. + $content = wp_replace_in_html_tags( $content, array( "\n" => '' ) ); // Find URLs that are on their own line. - return preg_replace_callback( '|^(\s*)(https?://[^\s"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content ); + $content = preg_replace_callback( '|^(\s*)(https?://[^\s"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content ); + + // Put the line breaks back. + return str_replace( '', "\n", $content ); } /**