wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



get_url_in_content › WordPress Function

Desde3.6.0
Obsoleton/a
get_url_in_content ( $content )
Parâmetros:
  • (string) $content A string which might contain a URL.
    Required: Yes
Retorna:
  • (string|false) The found URL.
Definido em:
Codex:

Extracts and returns the first URL from passed content.



Fonte

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;
}