wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



get_url_in_content › WordPress Function

Od3.6.0
Przestarzałyn/a
get_url_in_content ( $content )
Parametry:
  • (string) $content A string which might contain a URL.
    Wymagane: Tak
Powrót:
  • (string|false) The found URL.
Zdefiniowane na:
Codex:

Extracts and returns the first URL from passed content.



Źródło

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