WP_Customize_Widgets::capture_filter_pre_update_option() WordPress Method

The WP_Customize_Widgets::capture_filter_pre_update_option() method allows you to intercept and modify the value being updated for a particular setting. This can be useful for ensuring that a value is valid before it is saved to the database.

WP_Customize_Widgets::capture_filter_pre_update_option( mixed $new_value, string $option_name, mixed $old_value ) #

Pre-filters captured option values before updating.


Parameters

$new_value

(mixed)(Required)The new option value.

$option_name

(string)(Required)Name of the option.

$old_value

(mixed)(Required)The old option value.


Top ↑

Return

(mixed) Filtered option value.


Top ↑

Source

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

	public function capture_filter_pre_update_option( $new_value, $option_name, $old_value ) {
		if ( $this->is_option_capture_ignored( $option_name ) ) {
			return $new_value;
		}

		if ( ! isset( $this->_captured_options[ $option_name ] ) ) {
			add_filter( "pre_option_{$option_name}", array( $this, 'capture_filter_pre_get_option' ) );
		}

		$this->_captured_options[ $option_name ] = $new_value;

		return $old_value;
	}


Top ↑

Changelog

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