WP_Customize_Manager::add_control()publicWP 3.4.0

Adds a customize control.

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

Хуков нет.


WP_Customize_Control. The instance of the control that was added.


$WP_Customize_Manager = new WP_Customize_Manager();
$WP_Customize_Manager->add_control( $id, $args );
$id(WP_Customize_Control|строка) (обязательный)
Customize Control object, or ID.
Array of properties for the new Control object. See WP_Customize_Control::__construct() for information on accepted arguments.
По умолчанию: empty array


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

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

Код WP_Customize_Manager::add_control() WP 6.1.1

public function add_control( $id, $args = array() ) {
	if ( $id instanceof WP_Customize_Control ) {
		$control = $id;
	} else {
		$control = new WP_Customize_Control( $this, $id, $args );

	$this->controls[ $control->id ] = $control;
	return $control;