: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$color = sanitize_hex_color_no_hash( $color );
$color = get_theme_support( 'custom-header', 'default-text-color' );
* Callback for validating a background setting value.
* @param string $value Repeat value.
* @param WP_Customize_Setting $setting Setting.
* @return string|WP_Error Background value or validation error.
public function _sanitize_background_setting( $value, $setting ) {
if ( 'background_repeat' === $setting->id ) {
if ( ! in_array( $value, array( 'repeat-x', 'repeat-y', 'repeat', 'no-repeat' ), true ) ) {
return new WP_Error( 'invalid_value', __( 'Invalid value for background repeat.' ) );
} elseif ( 'background_attachment' === $setting->id ) {
if ( ! in_array( $value, array( 'fixed', 'scroll' ), true ) ) {
return new WP_Error( 'invalid_value', __( 'Invalid value for background attachment.' ) );
} elseif ( 'background_position_x' === $setting->id ) {
if ( ! in_array( $value, array( 'left', 'center', 'right' ), true ) ) {
return new WP_Error( 'invalid_value', __( 'Invalid value for background position X.' ) );
} elseif ( 'background_position_y' === $setting->id ) {
if ( ! in_array( $value, array( 'top', 'center', 'bottom' ), true ) ) {
return new WP_Error( 'invalid_value', __( 'Invalid value for background position Y.' ) );
} elseif ( 'background_size' === $setting->id ) {
if ( ! in_array( $value, array( 'auto', 'contain', 'cover' ), true ) ) {
return new WP_Error( 'invalid_value', __( 'Invalid value for background size.' ) );
} elseif ( 'background_preset' === $setting->id ) {
if ( ! in_array( $value, array( 'default', 'fill', 'fit', 'repeat', 'custom' ), true ) ) {
return new WP_Error( 'invalid_value', __( 'Invalid value for background size.' ) );
} elseif ( 'background_image' === $setting->id || 'background_image_thumb' === $setting->id ) {
$value = empty( $value ) ? '' : sanitize_url( $value );
return new WP_Error( 'unrecognized_setting', __( 'Unrecognized background setting.' ) );
* Exports header video settings to facilitate selective refresh.
* @param array $response Response.
* @param WP_Customize_Selective_Refresh $selective_refresh Selective refresh component.
* @param array $partials Array of partials.
public function export_header_video_settings( $response, $selective_refresh, $partials ) {
if ( isset( $partials['custom_header'] ) ) {
$response['custom_header_settings'] = get_header_video_settings();
* Callback for validating the header_video value.
* Ensures that the selected video is less than 8MB and provides an error message.
* @param WP_Error $validity
public function _validate_header_video( $validity, $value ) {
$video = get_attached_file( absint( $value ) );
$size = filesize( $video );
if ( $size > 8 * MB_IN_BYTES ) {
__( 'This video file is too large to use as a header video. Try a shorter video or optimize the compression settings and re-upload a file that is less than 8MB. Or, upload your video to YouTube and link it with the option below.' )
if ( ! str_ends_with( $video, '.mp4' ) && ! str_ends_with( $video, '.mov' ) ) { // Check for .mp4 or .mov format, which (assuming h.264 encoding) are the only cross-browser-supported formats.
/* translators: 1: .mp4, 2: .mov */
__( 'Only %1$s or %2$s files may be used for header video. Please convert your video file and try again, or, upload your video to YouTube and link it with the option below.' ),
* Callback for validating the external_header_video value.
* Ensures that the provided URL is supported.
* @param WP_Error $validity
public function _validate_external_header_video( $validity, $value ) {
$video = sanitize_url( $value );
if ( ! preg_match( '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#', $video ) ) {
$validity->add( 'invalid_url', __( 'Please enter a valid YouTube URL.' ) );
* Callback for sanitizing the external_header_video value.
* @param string $value URL.
* @return string Sanitized URL.
public function _sanitize_external_header_video( $value ) {
return sanitize_url( trim( $value ) );
* Callback for rendering the custom logo, used in the custom_logo partial.
* This method exists because the partial object and context data are passed
* into a partial's render_callback so we cannot use get_custom_logo() as
* the render_callback directly since it expects a blog ID as the first
* argument. When WP no longer supports PHP 5.3, this method can be removed
* in favor of an anonymous function.
* @see WP_Customize_Manager::register_controls()
* @return string Custom logo.
public function _render_custom_logo_partial() {
return get_custom_logo();