Used By
| Used By | Description |
|---|---|
| wp-includes/functions.php: do_enclose() | Check content for video and audio links to add as enclosures. |
| wp-includes/comment.php: pingback() | Pings back the links found in a post. |
Use RegEx to extract URLs from arbitrary content.
(string) (Required) Content to extract URLs from.
(string[]) Array of URLs found in passed string.
File: wp-includes/functions.php
function wp_extract_urls( $content ) {
preg_match_all(
"#([\"']?)("
. '(?:([\w-]+:)?//?)'
. '[^\s()<>]+'
. '[.]'
. '(?:'
. '\([\w\d]+\)|'
. '(?:'
. "[^`!()\[\]{};:'\".,<>«»“”‘’\s]|"
. '(?:[:]\d+)?/?'
. ')+'
. ')'
. ")\\1#",
$content,
$post_links
);
$post_links = array_unique( array_map( 'html_entity_decode', $post_links[2] ) );
return array_values( $post_links );
} | Version | Description |
|---|---|
| 3.7.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_extract_urls