X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/fa6ee2c363cdfdebcb4b76e4d9c4347a4cb19065..refs/tags/wordpress-4.2:/wp-includes/class-wp-embed.php diff --git a/wp-includes/class-wp-embed.php b/wp-includes/class-wp-embed.php index a10024a7..9569f38d 100644 --- a/wp-includes/class-wp-embed.php +++ b/wp-includes/class-wp-embed.php @@ -77,11 +77,9 @@ class WP_Embed { ?> maybe_make_link()` can return false on failure. */ public function shortcode( $attr, $url = '' ) { $post = get_post(); @@ -135,6 +134,7 @@ class WP_Embed { $url = $attr['src']; } + if ( empty( $url ) ) return ''; @@ -312,7 +312,7 @@ 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 ); + return preg_replace_callback( '|^(\s*)(https?://[^\s"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content ); } /** @@ -324,10 +324,10 @@ class WP_Embed { public function autoembed_callback( $match ) { $oldval = $this->linkifunknown; $this->linkifunknown = false; - $return = $this->shortcode( array(), $match[1] ); + $return = $this->shortcode( array(), $match[2] ); $this->linkifunknown = $oldval; - return "\n$return\n"; + return $match[1] . $return . $match[3]; } /**