WP_Customize_Manager::_validate_external_header_video() WordPress Method

The WP_Customize_Manager::_validate_external_header_video() function is used to validate an external header video. This function is used when the 'external_header_video' setting is updated.

WP_Customize_Manager::_validate_external_header_video( WP_Error $validity, mixed $value ) #

Callback for validating the external_header_video value.


Description

Ensures that the provided URL is supported.


Top ↑

Parameters

$validity

(WP_Error)(Required)

$value

(mixed)(Required)


Top ↑

Return

(mixed)


Top ↑

Source

File: wp-includes/class-wp-customize-manager.php

	public function _validate_external_header_video( $validity, $value ) {
		$video = esc_url_raw( $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;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More