WP_Customize_Setting::update()protectedWP 3.4.0

Save the value of the setting, using the related API.

Метод класса: WP_Customize_Setting{}

Хуки из метода

Возвращает

true|false. The result of saving the value.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->update( $value );
$value(разное) (обязательный)
The value to update.

Список изменений

С версии 3.4.0 Введена.

Код WP_Customize_Setting::update() WP 6.5.2

protected function update( $value ) {
	$id_base = $this->id_data['base'];
	if ( 'option' === $this->type || 'theme_mod' === $this->type ) {
		if ( ! $this->is_multidimensional_aggregated ) {
			return $this->set_root_value( $value );
		} else {
			$root = self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'];
			$root = $this->multidimensional_replace( $root, $this->id_data['keys'], $value );
			self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value'] = $root;
			return $this->set_root_value( $root );
		}
	} else {
		/**
		 * Fires when the WP_Customize_Setting::update() method is called for settings
		 * not handled as theme_mods or options.
		 *
		 * The dynamic portion of the hook name, `$this->type`, refers to the type of setting.
		 *
		 * @since 3.4.0
		 *
		 * @param mixed                $value   Value of the setting.
		 * @param WP_Customize_Setting $setting WP_Customize_Setting instance.
		 */
		do_action( "customize_update_{$this->type}", $value, $this );

		return has_action( "customize_update_{$this->type}" );
	}
}