PHP Класс WP_Customize_Control, wordpress

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$active_callback Callback.
$allow_addition boolean Show UI for adding new content, currently only used for the dropdown-pages control.
$capability string Normally this is empty and the capability is derived from the capabilities of the associated $settings.
$choices array
$description string
$id string
$input_attrs array
$instance_number integer Order in which this instance was created in relation to other instances.
$json array
$label string
$manager WP_Customize_Manager
$priority integer
$section string
$setting string The primary setting for the control (if there is one).
$settings array All settings tied to the control.
$type string

Защищенные свойства (Protected)

Свойство Тип Описание
$instance_count integer Used when sorting two instances whose priorities are equal.

Открытые методы

Метод Описание
__construct ( WP_Customize_Manager $manager, string $id, array $args = [] ) Constructor.
active ( ) : boolean Check whether control is active to current Customizer preview.
active_callback ( ) : true Default callback used when invoking WP_Customize_Control::active().
check_capabilities ( ) : boolean Checks if the user can use this control.
enqueue ( ) Enqueue control related scripts/styles.
get_content ( ) : string Get the control's content for insertion into the Customizer pane.
get_link ( string $setting_key = 'default' ) : string Get the data link attribute for a setting.
input_attrs ( ) Render the custom attributes for the control's input element.
json ( ) : array Get the data to export to the client via JSON.
link ( string $setting_key = 'default' ) Render the data link attribute for the control's input element.
maybe_render ( ) Check capabilities and render the control.
print_template ( ) Render the control's JS template.
to_json ( ) Refresh the parameters passed to the JavaScript via JSON.
value ( string $setting_key = 'default' ) : mixed Fetch a setting's value.

Защищенные методы

Метод Описание
content_template ( ) An Underscore (JS) template for this control's content (but not its container).
render ( ) Renders the control wrapper and calls $this->render_content() for the internals.
render_content ( ) Render the control's content.

Описание методов

__construct() публичный Метод

Supplied $args override class property defaults. If $args['settings'] is not defined, use the $id as the setting ID.
С версии: 3.4.0
public __construct ( WP_Customize_Manager $manager, string $id, array $args = [] )
$manager WP_Customize_Manager Customizer bootstrap instance.
$id string Control ID.
$args array { Optional. Arguments to override class property defaults. @type int $instance_number Order in which this instance was created in relation to other instances. @type WP_Customize_Manager $manager Customizer bootstrap instance. @type string $id Control ID. @type array $settings All settings tied to the control. If undefined, `$id` will be used. @type string $setting The primary setting for the control (if there is one). Default 'default'. @type int $priority Order priority to load the control. Default 10. @type string $section Section the control belongs to. Default empty. @type string $label Label for the control. Default empty. @type string $description Description for the control. Default empty. @type array $choices List of choices for 'radio' or 'select' type controls, where values are the keys, and labels are the values. Default empty array. @type array $input_attrs List of custom input attributes for control output, where attribute names are the keys and values are the values. Not used for 'checkbox', 'radio', 'select', 'textarea', or 'dropdown-pages' control types. Default empty array. @type array $json Deprecated. Use WP_Customize_Control::json() instead. @type string $type Control type. Core controls include 'text', 'checkbox', 'textarea', 'radio', 'select', and 'dropdown-pages'. Additional input types such as 'email', 'url', 'number', 'hidden', and 'date' are supported implicitly. Default 'text'. }

active() закрытый публичный Метод

Check whether control is active to current Customizer preview.
С версии: 4.0.0
final public active ( ) : boolean
Результат boolean Whether the control is active to the current preview.

active_callback() публичный Метод

Subclasses can override this with their specific logic, or they may provide an 'active_callback' argument to the constructor.
С версии: 4.0.0
public active_callback ( ) : true
Результат true Always true.

check_capabilities() закрытый публичный Метод

Returns false if the user cannot manipulate one of the associated settings, or if one of the associated settings does not exist. Also returns false if the associated section does not exist or if its capability check returns false.
С версии: 3.4.0
final public check_capabilities ( ) : boolean
Результат boolean False if theme doesn't support the control or user doesn't have the required permissions, otherwise true.

content_template() защищенный Метод

Class variables for this control class are available in the data JS object; export custom variables by overriding WP_Customize_Control::to_json().
См. также: WP_Customize_Control::print_template()
С версии: 4.1.0
protected content_template ( )

enqueue() публичный Метод

Enqueue control related scripts/styles.
С версии: 3.4.0
public enqueue ( )

get_content() закрытый публичный Метод

Get the control's content for insertion into the Customizer pane.
С версии: 4.1.0
final public get_content ( ) : string
Результат string Contents of the control.

input_attrs() публичный Метод

Render the custom attributes for the control's input element.
С версии: 4.0.0
public input_attrs ( )

json() публичный Метод

Get the data to export to the client via JSON.
С версии: 4.1.0
public json ( ) : array
Результат array Array of parameters passed to the JavaScript.

maybe_render() закрытый публичный Метод

Check capabilities and render the control.
С версии: 3.4.0
final public maybe_render ( )

print_template() закрытый публичный Метод

This function is only run for control types that have been registered with WP_Customize_Manager::register_control_type(). In the future, this will also print the template for the control's container element and be override-able.
С версии: 4.1.0
final public print_template ( )

render() защищенный Метод

Renders the control wrapper and calls $this->render_content() for the internals.
С версии: 3.4.0
protected render ( )

render_content() защищенный Метод

Allows the content to be overridden without having to rewrite the wrapper in $this::render(). Supports basic input types text, checkbox, textarea, radio, select and dropdown-pages. Additional input types such as email, url, number, hidden and date are supported implicitly. Control content can alternately be rendered in JS. See WP_Customize_Control::print_template().
С версии: 3.4.0
protected render_content ( )

to_json() публичный Метод

Refresh the parameters passed to the JavaScript via JSON.
С версии: 3.4.0
public to_json ( )

value() закрытый публичный Метод

Grabs the main setting by default.
С версии: 3.4.0
final public value ( string $setting_key = 'default' ) : mixed
$setting_key string
Результат mixed The requested setting's value, if the setting exists.

Описание свойств

$active_callback публичное свойство

Callback.
См. также: WP_Customize_Control::active()
С версии: 4.0.0
public $active_callback

$allow_addition публичное свойство

Show UI for adding new content, currently only used for the dropdown-pages control.
С версии: 4.7.0
public bool $allow_addition
Результат boolean

$capability публичное свойство

Normally this is empty and the capability is derived from the capabilities of the associated $settings.
С версии: 4.5.0
public string $capability
Результат string

$choices публичное свойство

public array $choices
Результат array

$description публичное свойство

public string $description
Результат string

$id публичное свойство

public string $id
Результат string

$input_attrs публичное свойство

public array $input_attrs
Результат array

$instance_count защищенное статическое свойство

Used when sorting two instances whose priorities are equal.
С версии: 4.1.0
protected static int $instance_count
Результат integer

$instance_number публичное свойство

Order in which this instance was created in relation to other instances.
С версии: 4.1.0
public int $instance_number
Результат integer

$json публичное свойство

Устаревший: It is better to just call the json() method
public array $json
Результат array

$label публичное свойство

public string $label
Результат string

$manager публичное свойство

public WP_Customize_Manager $manager
Результат WP_Customize_Manager

$priority публичное свойство

public int $priority
Результат integer

$section публичное свойство

public string $section
Результат string

$setting публичное свойство

The primary setting for the control (if there is one).
public string $setting
Результат string

$settings публичное свойство

All settings tied to the control.
public array $settings
Результат array

$type публичное свойство

public string $type
Результат string