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

WP_Customize_Setting::__construct() public WP 3.4.0

Constructor.

Any supplied $args override class property defaults.

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

Хуков нет.

Возвращает

Null. Ничего.

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

$WP_Customize_Setting = new WP_Customize_Setting();
$WP_Customize_Setting->__construct( $manager, $id, $args );
$manager(WP_Customize_Manager) (обязательный)
Customizer bootstrap instance.
$id(строка) (обязательный)
A specific ID of the setting. Can be a theme mod or option name.
$args(массив)

Array of properties for the new Setting object.

  • 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.
    По умолчанию: 'refresh'

  • validate_callback(callable)
    Server-side validation callback for the setting's value.

  • sanitize_callback(callable)
    Callback to filter a Customize setting value in un-slashed form.

  • sanitize_js_callback(callable)
    Callback to convert a Customize PHP setting value to a value that is JSON serializable.

  • dirty(true/false)
    Whether or not the setting is initially dirty when created.

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

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

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

Код WP_Customize_Setting::__construct() WP 5.5.3

<?php
public function __construct( $manager, $id, $args = array() ) {
	$keys = array_keys( get_object_vars( $this ) );
	foreach ( $keys as $key ) {
		if ( isset( $args[ $key ] ) ) {
			$this->$key = $args[ $key ];
		}
	}

	$this->manager = $manager;
	$this->id      = $id;

	// Parse the ID for array keys.
	$this->id_data['keys'] = preg_split( '/\[/', str_replace( ']', '', $this->id ) );
	$this->id_data['base'] = array_shift( $this->id_data['keys'] );

	// Rebuild the ID.
	$this->id = $this->id_data['base'];
	if ( ! empty( $this->id_data['keys'] ) ) {
		$this->id .= '[' . implode( '][', $this->id_data['keys'] ) . ']';
	}

	if ( $this->validate_callback ) {
		add_filter( "customize_validate_{$this->id}", $this->validate_callback, 10, 3 );
	}
	if ( $this->sanitize_callback ) {
		add_filter( "customize_sanitize_{$this->id}", $this->sanitize_callback, 10, 2 );
	}
	if ( $this->sanitize_js_callback ) {
		add_filter( "customize_sanitize_js_{$this->id}", $this->sanitize_js_callback, 10, 2 );
	}

	if ( 'option' === $this->type || 'theme_mod' === $this->type ) {
		// Other setting types can opt-in to aggregate multidimensional explicitly.
		$this->aggregate_multidimensional();

		// Allow option settings to indicate whether they should be autoloaded.
		if ( 'option' === $this->type && isset( $args['autoload'] ) ) {
			self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] = $args['autoload'];
		}
	}
}