Index: /branches/4.1/src/wp-includes/class-wp-embed.php
===================================================================
--- /branches/4.1/src/wp-includes/class-wp-embed.php (revision 33520)
+++ /branches/4.1/src/wp-includes/class-wp-embed.php (revision 33521)
@@ -313,9 +313,12 @@
*/
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 );
}
Index: /branches/4.1/src/wp-includes/formatting.php
===================================================================
--- /branches/4.1/src/wp-includes/formatting.php (revision 33520)
+++ /branches/4.1/src/wp-includes/formatting.php (revision 33521)
@@ -411,6 +411,6 @@
$pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
- // Strip newlines from all elements.
- $pee = wp_replace_in_html_tags( $pee, array( "\n" => " " ) );
+ // Find newlines in all elements and add placeholders.
+ $pee = wp_replace_in_html_tags( $pee, array( "\n" => " " ) );
if ( strpos( $pee, '
+https://youtube.com/watch?v=TEST01YRHA0
+
+https://youtube.com/watch?v=TEST02YRHA0
+http://www.example.com/embed/TEST03YRHA0
+http://www.example.com/embed/TEST04YRHA0
+Stop.
+
+EOF;
+
+ $result = apply_filters( 'the_content', $content );
+ $this->assertEquals( $expected, $result );
+ }
+
+ /**
+ * @ticket 33016
+ */
+ function filter_wp_embed_shortcode_custom( $content, $url ) {
+ if ( 'https://www.example.com/?video=1' == $url ) {
+ $content = '@embed URL was replaced@';
+ }
+ return $content;
+ }
+
+ /**
+ * @ticket 33016
+ */
+ function test_oembed_explicit_media_link() {
+ global $wp_embed;
+ add_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10, 2 );
+
+ $content = <<autoembed( $content );
+ $this->assertEquals( $expected, $result );
+
+ $content = <<https://www.example.com/?video=1
+
+EOF;
+
+ $result = $wp_embed->autoembed( $content );
+ $this->assertEquals( $content, $result );
+
+ remove_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 );
+ }
}