WordPress at a glance
function is not described

WP_Customize_Manager::add_setting() public WP 3.4.0

Add a customize setting.

{} It's a method of the class: WP_Customize_Manager{}

Return

WP_Customize_Setting. The instance of the setting that was added.

Usage

$WP_Customize_Manager = new WP_Customize_Manager();
$WP_Customize_Manager->add_setting( $id, $args );
$id(WP_Customize_Setting/string) (required)
Customize Setting object, or ID.
$args(array)
Array of properties for the new Setting object. See WP_Customize_Setting::__construct() for information on accepted arguments.
Default: empty array

Notes

  • See: WP_Customize_Setting::__construct()

Changelog

Since 3.4.0 Introduced.
Since 4.5.0 Return added WP_Customize_Setting instance.

Code of WP_Customize_Manager::add_setting() WP 5.5.3

<?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;
}