Un motore di ricerca WordPress per sviluppatori e autori di temi



get_url_in_content ›

Da3.6.0
Deprecaton/a
get_url_in_content ( $content )
Parametri:
  • (string) $content A string which might contain a URL.
    Richiesto:
Ritorna:
  • (string|false) The found URL.
Definito a:
Codex:

Extract and return the first URL from passed content.



Sorgenti

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