WP_Customize_Setting::set_root_value() WordPress Method

The WP_Customize_Setting::set_root_value() method is used to set the root value for a Customizer setting. This is the value that will be used when the setting is not overridden by a theme or plugin.

WP_Customize_Setting::set_root_value( mixed $value ) #

Set the root value for a setting, especially for multidimensional ones.


Parameters

$value

(mixed)(Required)Value to set as root of multidimensional setting.


Top ↑

Return

(bool) Whether the multidimensional root was updated successfully.


Top ↑

Source

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

	protected function set_root_value( $value ) {
		$id_base = $this->id_data['base'];
		if ( 'option' === $this->type ) {
			$autoload = true;
			if ( isset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] ) ) {
				$autoload = self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'];
			}
			return update_option( $id_base, $value, $autoload );
		} elseif ( 'theme_mod' === $this->type ) {
			set_theme_mod( $id_base, $value );
			return true;
		} else {
			/*
			 * Any WP_Customize_Setting subclass implementing aggregate multidimensional
			 * will need to override this method to obtain the data from the appropriate
			 * location.
			 */
			return false;
		}
	}


Top ↑

Changelog

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