get_url_in_content

函数


get_url_in_content ( $content )
参数
  • (string)
    $content
    A string which might contain a URL.
    Required:
返回值
  • (string|false) The found URL.
定义位置
  • wp-includes/formatting.php
    , line 5655
引入
3.6.0
弃用

从传来的内容中提取并返回第一个URL。

function get_url_in_content( $content ) {
	if ( empty( $content ) ) {
		return false;
	}

	if ( preg_match( '/]*?href=(['"])(.+?)1/is', $content, $matches ) ) {
		return sanitize_url( $matches[2] );
	}

	return false;
}