从传递的内容中提取并返回第一个URL。
原型
get_url_in_content( string $content )
参数
$content
(string)
(Required)
可能包含URL的字符串。
返回值
(string|false)
找到的网址。
源文件
路径:wp-includes/formatting.php
<?php
...
function get_url_in_content( $content ) {
if ( empty( $content ) ) {
return false;
}
if ( preg_match( '/<as[^>]*?href=(['"])(.+?)1/is', $content, $matches ) ) {
return esc_url_raw( $matches[2] );
}
return false;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_url_in_content/