PHP Class WP_Customize_Control, wordpress

Afficher le fichier Open project: johnpbloch/wordpress Class Usage Examples

Méthodes publiques

Свойство Type Description
$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 Properties

Свойство Type Description
$instance_count integer Used when sorting two instances whose priorities are equal.

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
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.

Method Details

__construct() public méthode

Supplied $args override class property defaults. If $args['settings'] is not defined, use the $id as the setting ID.
Since: 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() final public méthode

Check whether control is active to current Customizer preview.
Since: 4.0.0
final public active ( ) : boolean
Résultat boolean Whether the control is active to the current preview.

active_callback() public méthode

Subclasses can override this with their specific logic, or they may provide an 'active_callback' argument to the constructor.
Since: 4.0.0
public active_callback ( ) : true
Résultat true Always true.

check_capabilities() final public méthode

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.
Since: 3.4.0
final public check_capabilities ( ) : boolean
Résultat boolean False if theme doesn't support the control or user doesn't have the required permissions, otherwise true.

content_template() protected méthode

Class variables for this control class are available in the data JS object; export custom variables by overriding WP_Customize_Control::to_json().
See also: WP_Customize_Control::print_template()
Since: 4.1.0
protected content_template ( )

enqueue() public méthode

Enqueue control related scripts/styles.
Since: 3.4.0
public enqueue ( )

get_content() final public méthode

Get the control's content for insertion into the Customizer pane.
Since: 4.1.0
final public get_content ( ) : string
Résultat string Contents of the control.

input_attrs() public méthode

Render the custom attributes for the control's input element.
Since: 4.0.0
public input_attrs ( )

json() public méthode

Get the data to export to the client via JSON.
Since: 4.1.0
public json ( ) : array
Résultat array Array of parameters passed to the JavaScript.

maybe_render() final public méthode

Check capabilities and render the control.
Since: 3.4.0
final public maybe_render ( )

print_template() final public méthode

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.
Since: 4.1.0
final public print_template ( )

render() protected méthode

Renders the control wrapper and calls $this->render_content() for the internals.
Since: 3.4.0
protected render ( )

render_content() protected méthode

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().
Since: 3.4.0
protected render_content ( )

to_json() public méthode

Refresh the parameters passed to the JavaScript via JSON.
Since: 3.4.0
public to_json ( )

value() final public méthode

Grabs the main setting by default.
Since: 3.4.0
final public value ( string $setting_key = 'default' ) : mixed
$setting_key string
Résultat mixed The requested setting's value, if the setting exists.

Property Details

$active_callback public_oe property

Callback.
See also: WP_Customize_Control::active()
Since: 4.0.0
public $active_callback

$allow_addition public_oe property

Show UI for adding new content, currently only used for the dropdown-pages control.
Since: 4.7.0
public bool $allow_addition
Résultat boolean

$capability public_oe property

Normally this is empty and the capability is derived from the capabilities of the associated $settings.
Since: 4.5.0
public string $capability
Résultat string

$choices public_oe property

public array $choices
Résultat array

$description public_oe property

public string $description
Résultat string

$id public_oe property

public string $id
Résultat string

$input_attrs public_oe property

public array $input_attrs
Résultat array

$instance_count protected_oe static_oe property

Used when sorting two instances whose priorities are equal.
Since: 4.1.0
protected static int $instance_count
Résultat integer

$instance_number public_oe property

Order in which this instance was created in relation to other instances.
Since: 4.1.0
public int $instance_number
Résultat integer

$json public_oe property

Deprecation: It is better to just call the json() method
public array $json
Résultat array

$label public_oe property

public string $label
Résultat string

$manager public_oe property

public WP_Customize_Manager $manager
Résultat WP_Customize_Manager

$priority public_oe property

public int $priority
Résultat integer

$section public_oe property

public string $section
Résultat string

$setting public_oe property

The primary setting for the control (if there is one).
public string $setting
Résultat string

$settings public_oe property

All settings tied to the control.
public array $settings
Résultat array

$type public_oe property

public string $type
Résultat string