WP_Customize_Setting::_preview_filter() WordPress Method

The WP_Customize_Setting::_preview_filter() WordPress method is used to filter the setting value for preview purposes. By default, this method returns the value passed to the method. However, it can be overridden by a child class to provide custom filtering of the setting value.

WP_Customize_Setting::_preview_filter( mixed $original ) #

Callback function to filter non-multidimensional theme mods and options.


Description

If switch_to_blog() was called after the preview() method, and the current site is now not the same site, then this method does a no-op and returns the original value.


Top ↑

Parameters

$original

(mixed)(Required)Old value.


Top ↑

Return

(mixed) New or old value.


Top ↑

Source

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

	public function _preview_filter( $original ) {
		if ( ! $this->is_current_blog_previewed() ) {
			return $original;
		}

		$undefined  = new stdClass(); // Symbol hack.
		$post_value = $this->post_value( $undefined );
		if ( $undefined !== $post_value ) {
			$value = $post_value;
		} else {
			/*
			 * Note that we don't use $original here because preview() will
			 * not add the filter in the first place if it has an initial value
			 * and there is no post value.
			 */
			$value = $this->default;
		}
		return $value;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.4.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.