Don't force newlines around URLs in WP_Embed::autoembed().
props chipx86, sgrant. fixes #23776. git-svn-id: https://develop.svn.wordpress.org/trunk@31066 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2fcd588983
commit
4fdc7c7a0b
@ -311,7 +311,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 );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -323,10 +323,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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,6 +132,40 @@ CAP;
|
||||
$this->assertContains( 'https://www.youtube.com/embed/zHjMoNQN7s0?feature=oembed', $out );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 23776
|
||||
*/
|
||||
function test_autoembed_empty() {
|
||||
global $wp_embed;
|
||||
|
||||
$content = '';
|
||||
|
||||
$result = $wp_embed->autoembed( $content );
|
||||
$this->assertEquals( $content, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 23776
|
||||
*/
|
||||
function test_autoembed_no_paragraphs_around_urls() {
|
||||
global $wp_embed;
|
||||
|
||||
$content = <<<EOF
|
||||
$ my command
|
||||
First line.
|
||||
|
||||
http://example.com/1/
|
||||
http://example.com/2/
|
||||
Last line.
|
||||
|
||||
<pre>http://some.link/
|
||||
http://some.other.link/</pre>
|
||||
EOF;
|
||||
|
||||
$result = $wp_embed->autoembed( $content );
|
||||
$this->assertEquals( $content, $result );
|
||||
}
|
||||
|
||||
function test_wp_prepare_attachment_for_js() {
|
||||
// Attachment without media
|
||||
$id = wp_insert_attachment(array(
|
||||
|
Loading…
Reference in New Issue
Block a user