X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/7f1521bf193b382565eb753043c161f4cb3fcda7..f5fcdc7994bb67cce809bc4777944ae8b7fad4a4:/wp-includes/class-wp-embed.php?ds=sidebyside diff --git a/wp-includes/class-wp-embed.php b/wp-includes/class-wp-embed.php index 9569f38d..e3426ab8 100644 --- a/wp-includes/class-wp-embed.php +++ b/wp-includes/class-wp-embed.php @@ -57,7 +57,7 @@ class WP_Embed { add_shortcode( 'embed', array( $this, 'shortcode' ) ); // Do the shortcode (only the [embed] one is registered) - $content = do_shortcode( $content ); + $content = do_shortcode( $content, true ); // Put the original shortcodes back $shortcode_tags = $orig_shortcode_tags; @@ -312,7 +312,14 @@ class WP_Embed { * @return string Potentially modified $content. */ public function autoembed( $content ) { - return preg_replace_callback( '|^(\s*)(https?://[^\s"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content ); + // 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. + $content = preg_replace_callback( '|^(\s*)(https?://[^\s"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content ); + + // Put the line breaks back. + return str_replace( '', "\n", $content ); } /**