On this page
get_header_video_url(): string|false
Retrieves header video URL for custom header.
Description
Uses a local video if present, or falls back to an external video.
Return
string|false Header video URL or false if there is no video.
Source
File: wp-includes/theme.php. View all references
function get_header_video_url() {
$id = absint( get_theme_mod( 'header_video' ) );
if ( $id ) {
// Get the file URL from the attachment ID.
$url = wp_get_attachment_url( $id );
} else {
$url = get_theme_mod( 'external_header_video' );
}
/**
* Filters the header video URL.
*
* @since 4.7.3
*
* @param string $url Header video URL, if available.
*/
$url = apply_filters( 'get_header_video_url', $url );
if ( ! $id && ! $url ) {
return false;
}
return sanitize_url( set_url_scheme( $url ) );
}
Hooks
- apply_filters( 'get_header_video_url',
string $url ) -
Filters the header video URL.
Related
Uses
| Uses | Description |
|---|---|
| get_theme_mod() wp-includes/theme.php | Retrieves theme modification value for the active theme. |
| sanitize_url() wp-includes/formatting.php | Sanitizes a URL for database or redirect usage. |
| set_url_scheme() wp-includes/link-template.php | Sets the scheme for a URL. |
| wp_get_attachment_url() wp-includes/post.php | Retrieves the URL for an attachment. |
| absint() wp-includes/functions.php | Converts a value to non-negative integer. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| has_header_video() wp-includes/theme.php | Checks whether a header video is set or not. |
| the_header_video_url() wp-includes/theme.php | Displays header video URL. |
| get_header_video_settings() wp-includes/theme.php | Retrieves header video settings. |
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_header_video_url