WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Customize_Manager::add_setting() WP 3.4.0

Add a customize setting.

Это метод класса: WP_Customize_Manager

Возвращает

WP_Customize_Setting. The instance of the setting that was added.

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

$WP_Customize_Manager = new WP_Customize_Manager();
$var = $WP_Customize_Manager->add_setting( $id, $args );
$id(WP_Customize_Setting/строка) (обязательный)
Customize Setting object, or ID.
$args(массив)

Array of properties for the new WP_Customize_Setting.

  • $type (строка)
    Type of the setting.
    По умолчанию: 'theme_mod'

  • $capability (строка)
    Capability required for the setting.
    По умолчанию: 'edit_theme_options'

  • $theme_supports (строка/массив)
    Theme features required to support the panel.
    По умолчанию: none

  • $default (строка)
    Default value for the setting.
    По умолчанию: empty string

  • $transport (строка)
    Options for rendering the live preview of changes in Customizer. Using 'refresh' makes the change visible by reloading the whole preview. Using 'postMessage' allows a custom JavaScript to handle live changes.

По умолчанию: empty array

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

С версии 3.4.0 Введена.
С версии 4.5.0 Return added WP_Customize_Setting instance.

Код WP Customize Manager::add setting: wp-includes/class-wp-customize-manager.php WP 5.3.1

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