WP_Customize_Manager::add_setting() WordPress Method

The WP_Customize_Manager::add_setting() method is used to add a new setting to the Customizer. This setting can be used to control any aspect of the Customizer, including its layout and behavior.

WP_Customize_Manager::add_setting( WP_Customize_Setting|string $id, array $args = array() ) #

Adds a customize setting.


Description

Top ↑

See also


Top ↑

Parameters

$id

(WP_Customize_Setting|string)(Required)Customize Setting object, or ID.

$args

(array)(Optional) Array of properties for the new Setting object. See WP_Customize_Setting::__construct() for information on accepted arguments.

Default value: array()


Top ↑

Return

(WP_Customize_Setting) The instance of the setting that was added.


Top ↑

Source

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

	public function add_setting( $id, $args = array() ) {
		if ( $id instanceof WP_Customize_Setting ) {
			$setting = $id;
		} else {
			$class = 'WP_Customize_Setting';

			/** This filter is documented in wp-includes/class-wp-customize-manager.php */
			$args = apply_filters( 'customize_dynamic_setting_args', $args, $id );

			/** This filter is documented in wp-includes/class-wp-customize-manager.php */
			$class = apply_filters( 'customize_dynamic_setting_class', $class, $id, $args );

			$setting = new $class( $this, $id, $args );
		}

		$this->settings[ $setting->id ] = $setting;
		return $setting;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.5.0Return added WP_Customize_Setting instance.
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.

Show More