PHP Class Kirki_Field, kirki

Mostra file Open project: aristath/kirki Class Usage Examples

Protected Properties

Property Type Description
$active_callback string | array A custom callback to determine if the field should be visible or not.
$capability string Thje capability required so that users can edit this field.
$choices array We're whitelisting the property here and suggest you validate this in a child class.
$default string | array The default value for this field.
$disable_output boolean Set to true if you want to disable all CSS output for this field.
$flex_height boolean Whether the height is flexible for cropped image.
$flex_width boolean Whether the width is flexible for cropped image.
$height integer Suggested height for cropped image.
$help string Whitelisting for backwards-compatibility.
$id string This is auto-calculated from the $settings argument.
$input_attrs array Vustom input attributes (defined as an array).
$js_vars array Not necessary to use if you use 'transport' => 'auto' and have already set an array for the 'output' argument.
$kirki_config string The ID of the kirki_config we're using.
$mime_type array Limit the Media library to a specific mime type
$mode string Whitelisting for backwards-compatibility.
$multiple integer Defines if this is a multi-select or not. If value is > 1, then the maximum number of selectable options is the number defined here.
$option_name string If we're using options instead of theme_mods and we want them serialized, this is the option that will saved in the db.
$option_type string Use "theme_mod" or "option".
$output array Use if you want to automatically generate CSS from this field's value.
$partial_refresh array Partial Refreshes array.
$priority integer Lower priority numbers move the control to the top.
$required array Define dependencies to show/hide this field based on the values of other fields.
$row_label array Contain the settings for the repeater rows labels
$sanitize_callback string | array A custom sanitize callback that will be used to properly save the values.
$section string Fields not assigned to a section will not be displayed in the customizer.
$settings string | array The name of this setting (id for the db).
$tooltip string Text that will be used in a tooltip to provide extra info for this field.
$transport string 'auto' will automatically geberate any 'js_vars' from the 'output' argument.
$type string The field type.
$variables array If you want to use a CSS compiler, then use this to set the variable names.
$width integer Suggested width for cropped image.

Public Methods

Method Description
__construct ( string $config_id = 'global', array $args = [] ) The class constructor.

Protected Methods

Method Description
set_active_callback ( ) Sets the active_callback If we're using the $required argument, Then this is where the switch is made to our evaluation method.
set_capability ( ) Checks the capability chosen is valid.
set_choices ( ) Sets the $choices.
set_default ( ) This allows us to process this on a field-basis by using sub-classes which can override this method.
set_disable_output ( ) Escapes the $disable_output.
set_field ( array $whitelisted_properties = [] ) Processes the field arguments
set_help ( ) This is a fallback method: $help has now become $tooltip, so this just migrates the data
set_id ( ) Sets the $id.
set_input_attrs ( ) Escape the $section.
set_js_vars ( ) Sets the $js_vars
set_kirki_config ( ) Escape $kirki_config.
set_multiple ( ) Sets the $multiple
set_option_name ( ) Escape $option_name.
set_option_type ( ) Make sure we're using the correct option_type
set_output ( ) Sets the $sanitize_callback
set_partial_refresh ( ) Modifications for partial refreshes.
set_priority ( ) Sets the $priority
set_required ( ) Sets the $required
set_sanitize_callback ( ) Sets the $sanitize_callback
set_section ( ) Escape the $section.
set_settings ( ) Sets the settings.
set_tooltip ( ) Escapes the tooltip messages.
set_transport ( ) Sets the $transport
set_type ( ) Sets the control type.
set_variables ( ) Sets the $variables

Method Details

__construct() public method

Parses and sanitizes all field arguments. Then it adds the field to Kirki::$fields.
public __construct ( string $config_id = 'global', array $args = [] )
$config_id string The ID of the config we want to use. Defaults to "global". Configs are handled by the Kirki_Config class.
$args array The arguments of the field.

set_active_callback() protected method

Sets the active_callback If we're using the $required argument, Then this is where the switch is made to our evaluation method.
protected set_active_callback ( )

set_capability() protected method

If not, then falls back to 'edit_theme_options'
protected set_capability ( )

set_choices() protected method

Sets the $choices.
protected set_choices ( )

set_default() protected method

This allows us to process this on a field-basis by using sub-classes which can override this method.
protected set_default ( )

set_disable_output() protected method

Escapes the $disable_output.
protected set_disable_output ( )

set_field() protected method

Processes the field arguments
protected set_field ( array $whitelisted_properties = [] )
$whitelisted_properties array Defines an array of arguments that will skip validation at this point.

set_help() protected method

This is a fallback method: $help has now become $tooltip, so this just migrates the data
protected set_help ( )

set_id() protected method

Setting the ID should happen after the 'settings' sanitization. This way we can also properly handle cases where the option_type is set to 'option' and we're using an array instead of individual options.
protected set_id ( )

set_input_attrs() protected method

Escape the $section.
protected set_input_attrs ( )

set_js_vars() protected method

Sets the $js_vars
protected set_js_vars ( )

set_kirki_config() protected method

Escape $kirki_config.
protected set_kirki_config ( )

set_multiple() protected method

Sets the $multiple
protected set_multiple ( )

set_option_name() protected method

Escape $option_name.
protected set_option_name ( )

set_option_type() protected method

Make sure we're using the correct option_type
protected set_option_type ( )

set_output() protected method

Sets the $sanitize_callback
protected set_output ( )

set_partial_refresh() protected method

Modifications for partial refreshes.
protected set_partial_refresh ( )

set_priority() protected method

Sets the $priority
protected set_priority ( )

set_required() protected method

Sets the $required
protected set_required ( )

set_sanitize_callback() protected method

Sets the $sanitize_callback
protected set_sanitize_callback ( )

set_section() protected method

Escape the $section.
protected set_section ( )

set_settings() protected method

If we're using serialized options it makes sure that settings are properly formatted. We'll also be escaping all setting names here for consistency.
protected set_settings ( )

set_tooltip() protected method

Escapes the tooltip messages.
protected set_tooltip ( )

set_transport() protected method

Sets the $transport
protected set_transport ( )

set_type() protected method

Sets the control type.
protected set_type ( )

set_variables() protected method

Sets the $variables
protected set_variables ( )

Property Details

$active_callback protected_oe property

A custom callback to determine if the field should be visible or not.
protected string|array $active_callback
return string | array

$capability protected_oe property

Thje capability required so that users can edit this field.
protected string $capability
return string

$choices protected_oe property

We're whitelisting the property here and suggest you validate this in a child class.
protected array $choices
return array

$default protected_oe property

The default value for this field.
protected string|array $default
return string | array

$disable_output protected_oe property

Set to true if you want to disable all CSS output for this field.
protected bool $disable_output
return boolean

$flex_height protected_oe property

Whether the height is flexible for cropped image.
protected bool $flex_height
return boolean

$flex_width protected_oe property

Whether the width is flexible for cropped image.
protected bool $flex_width
return boolean

$height protected_oe property

Suggested height for cropped image.
protected int $height
return integer

$help protected_oe property

Whitelisting for backwards-compatibility.
protected string $help
return string

$id protected_oe property

This is auto-calculated from the $settings argument.
protected string $id
return string

$input_attrs protected_oe property

Vustom input attributes (defined as an array).
protected array $input_attrs
return array

$js_vars protected_oe property

Not necessary to use if you use 'transport' => 'auto' and have already set an array for the 'output' argument.
See also: https://kirki.org/docs/arguments/js_vars
protected array $js_vars
return array

$kirki_config protected_oe property

The ID of the kirki_config we're using.
See also: Kirki_Config
protected string $kirki_config
return string

$mime_type protected_oe property

Limit the Media library to a specific mime type
protected array $mime_type
return array

$mode protected_oe property

Whitelisting for backwards-compatibility.
protected string $mode
return string

$multiple protected_oe property

Defines if this is a multi-select or not. If value is > 1, then the maximum number of selectable options is the number defined here.
protected int $multiple
return integer

$option_name protected_oe property

If we're using options instead of theme_mods and we want them serialized, this is the option that will saved in the db.
protected string $option_name
return string

$option_type protected_oe property

Use "theme_mod" or "option".
protected string $option_type
return string

$output protected_oe property

Use if you want to automatically generate CSS from this field's value.
See also: https://kirki.org/docs/arguments/output
protected array $output
return array

$partial_refresh protected_oe property

Partial Refreshes array.
protected array $partial_refresh
return array

$priority protected_oe property

Lower priority numbers move the control to the top.
protected int $priority
return integer

$required protected_oe property

Define dependencies to show/hide this field based on the values of other fields.
protected array $required
return array

$row_label protected_oe property

Contain the settings for the repeater rows labels
protected array $row_label
return array

$sanitize_callback protected_oe property

A custom sanitize callback that will be used to properly save the values.
protected string|array $sanitize_callback
return string | array

$section protected_oe property

Fields not assigned to a section will not be displayed in the customizer.
protected string $section
return string

$settings protected_oe property

The name of this setting (id for the db).
protected string|array $settings
return string | array

$tooltip protected_oe property

Text that will be used in a tooltip to provide extra info for this field.
protected string $tooltip
return string

$transport protected_oe property

'auto' will automatically geberate any 'js_vars' from the 'output' argument.
protected string $transport
return string

$type protected_oe property

The field type.
protected string $type
return string

$variables protected_oe property

If you want to use a CSS compiler, then use this to set the variable names.
See also: https://kirki.org/docs/arguments/variables
protected array $variables
return array

$width protected_oe property

Suggested width for cropped image.
protected int $width
return integer