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: |
|
| Powrót: |
|
| Zdefiniowane na: |
|
| Codex: |
Extracts and returns the first URL from passed content.
Powiązane Funkcje: get_the_content, get_user_count, get_shortcode_tags_in_content, get_link_to_edit, get_media_embedded_in_content
Źródło
function get_url_in_content( $content ) {
if ( empty( $content ) ) {
return false;
}
$processor = new WP_HTML_Tag_Processor( $content );
while ( $processor->next_tag( 'A' ) ) {
$href = $processor->get_attribute( 'href' );
if ( is_string( $href ) && '' !== $href ) {
return sanitize_url( $href );
}
}
return false;
}