mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Auto-embedding:
- We already match URLs on their own line, add another regex to match URLs in their own paragraphs. - Always exclude the `\s<>"` characters when matching. - Add more unit tests. Props iseulde, azaozz. Fixes #25387. git-svn-id: https://develop.svn.wordpress.org/trunk@37627 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -334,8 +334,12 @@ class WP_Embed {
|
||||
// Replace line breaks from all HTML elements with placeholders.
|
||||
$content = wp_replace_in_html_tags( $content, array( "\n" => '<!-- wp-line-break -->' ) );
|
||||
|
||||
// Find URLs that are on their own line.
|
||||
$content = preg_replace_callback( '|^(\s*)(https?://[^\s"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content );
|
||||
if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) {
|
||||
// Find URLs on their own line.
|
||||
$content = preg_replace_callback( '|^(\s*)(https?://[^\s<>"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $content );
|
||||
// Find URLs in their own paragraph.
|
||||
$content = preg_replace_callback( '|(<p(?: [^>]*)?>\s*)(https?://[^\s<>"]+)(\s*<\/p>)|i', array( $this, 'autoembed_callback' ), $content );
|
||||
}
|
||||
|
||||
// Put the line breaks back.
|
||||
return str_replace( '<!-- wp-line-break -->', "\n", $content );
|
||||
|
||||
Reference in New Issue
Block a user