函数原型
get_url_in_content( string $content ): string|false
函数描述
Extracts and returns the first URL from passed content.
是否弃用
未弃用
函数参数
-
$content
string
Required - A string which might contain a URL.
函数返回值
string|false The found URL.
函数位置
File: wp-includes/formatting.php.
函数源码
function get_url_in_content( $content ) {
if ( empty( $content ) ) {
return false;
}
if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) {
return sanitize_url( $matches[2] );
}
return false;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.6.0 | Introduced. |

