wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



get_url_in_content › WordPress Function

Depuis3.6.0
Dépréciéen/a
get_url_in_content ( $content )
Paramètres:
  • (string) $content A string which might contain a URL.
    Requis: Oui
Retourne:
  • (string|false) The found URL.
Défini(e) dans:
Codex:

Extracts and returns the first URL from passed content.



Source

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