mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01: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. Built from https://develop.svn.wordpress.org/trunk@37627 git-svn-id: http://core.svn.wordpress.org/trunk@37595 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cedaaaf779
commit
26b1d5f927
@ -334,8 +334,12 @@ class WP_Embed {
|
|||||||
// Replace line breaks from all HTML elements with placeholders.
|
// Replace line breaks from all HTML elements with placeholders.
|
||||||
$content = wp_replace_in_html_tags( $content, array( "\n" => '<!-- wp-line-break -->' ) );
|
$content = wp_replace_in_html_tags( $content, array( "\n" => '<!-- wp-line-break -->' ) );
|
||||||
|
|
||||||
// Find URLs that are on their own line.
|
if ( preg_match( '#(^|\s|>)https?://#i', $content ) ) {
|
||||||
$content = preg_replace_callback( '|^(\s*)(https?://[^\s"]+)(\s*)$|im', array( $this, 'autoembed_callback' ), $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.
|
// Put the line breaks back.
|
||||||
return str_replace( '<!-- wp-line-break -->', "\n", $content );
|
return str_replace( '<!-- wp-line-break -->', "\n", $content );
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.6-alpha-37626';
|
$wp_version = '4.6-alpha-37627';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user