WordPress开发者和主题制作者的搜索引擎



get_url_in_content ›

Since3.6.0
已弃用n/a
get_url_in_content ( $content )
参数:
  • (string) $content A string which might contain a URL.
    Required: Yes
返回:
  • (string|false) The found URL.
定义在:
文档:

Extract and return the first URL from passed content.



源码

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

	if ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) {
		return esc_url_raw( $matches[2] );
	}

	return false;
}