On this page
WP_Customize_Manager::_validate_external_header_video( WP_Error $validity, mixed $value ): mixed
Callback for validating the external_header_video value.
Description
Ensures that the provided URL is supported.
Parameters
$validityWP_Error Required$valuemixed Required
Return
mixed
Source
File: wp-includes/class-wp-customize-manager.php. View all references
public function _validate_external_header_video( $validity, $value ) {
$video = sanitize_url( $value );
if ( $video ) {
if ( ! preg_match( '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#', $video ) ) {
$validity->add( 'invalid_url', __( 'Please enter a valid YouTube URL.' ) );
}
}
return $validity;
}
Related
Uses
| Uses | Description |
|---|---|
| sanitize_url() wp-includes/formatting.php | Sanitizes a URL for database or redirect usage. |
| __() wp-includes/l10n.php | Retrieves the translation of $text. |
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_customize_manager/_validate_external_header_video