Shortcodes: Improve the reliablity of shortcodes inside HTML tags.

Props miqrogroove.

See #15694.



git-svn-id: https://develop.svn.wordpress.org/trunk@33359 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2015-07-22 05:14:50 +00:00
parent 7439dd7354
commit 7b41adf712
6 changed files with 722 additions and 45 deletions

View File

@@ -59,7 +59,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;
@@ -318,6 +318,10 @@ 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" => " " ) );
// Find URLs that are on their own line.
return preg_replace_callback( '|^(\s*)(https?://[^\s"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content );
}