]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class-wp-embed.php
WordPress 4.2.4
[autoinstalls/wordpress.git] / wp-includes / class-wp-embed.php
index eda4467c45633659c4f630dae0dff4ada96bd34b..e3426ab8b10ccc3016e6952fcd57a063cb96a135 100644 (file)
@@ -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" => '<!-- wp-line-break -->' ) );
 
                // 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( '<!-- wp-line-break -->', "\n", $content );
        }
 
        /**