PHP Класс WP_Customize_Setting, wordpress

Handles saving and sanitizing of settings.
См. также: WP_Customize_Manager
С версии: 3.4.0
Наследование: extends WP_Fields_API_Field
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$capability string Capability required to edit this setting.
$default
$dirty boolean This is used to ensure that a setting will be sent from the pane to the preview when loading the Customizer. Normally a setting only is synced to the preview if it has been changed. This allows the setting to be sent from the start.
$id string Unique string identifier for the setting.
$manager WP_Customize_Manager
$sanitize_callback
$sanitize_js_callback
$theme_supports string Feature a theme is required to support to enable this setting.
$transport
$type string
$validate_callback callback Server-side sanitization callback for the setting's value.

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

Свойство Тип Описание
$_original_value mixed Original non-previewed value stored by the preview method.
$_previewed_blog_id integer The ID for the current site when the preview() method was called.
$aggregated_multidimensionals array Cache of multidimensional values to improve performance.
$id_data array
$is_multidimensional_aggregated boolean Whether the multidimensional setting is aggregated.
$is_previewed boolean Whether or not preview() was called.

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

Метод Описание
__construct ( WP_Customize_Manager $manager, string $id, array $args = [] ) Constructor.
_clear_aggregated_multidimensional_preview_applied_flag ( ) Clear out the previewed-applied flag for a multidimensional-aggregated value whenever its post value is updated.
_multidimensional_preview_filter ( mixed $original ) : mixed Callback function to filter multidimensional theme mods and options.
_preview_filter ( mixed $original ) : mixed Callback function to filter non-multidimensional theme mods and options.
check_capabilities ( ) : boolean Validate user capabilities whether the theme supports the setting.
id_data ( ) : array Get parsed ID data for multidimensional setting.
is_current_blog_previewed ( ) : boolean Return true if the current site is not the same as the previewed site.
js_value ( ) : mixed Sanitize the setting's value for use in JavaScript.
json ( ) : array Retrieves the data to export to the client via JSON.
post_value ( mixed $default = null ) : mixed Fetch and sanitize the $_POST value for the setting.
preview ( ) : boolean Add filters to supply the setting's value when accessed.
reset_aggregated_multidimensionals ( ) Reset $aggregated_multidimensionals static variable.
sanitize ( string | array $value ) : string | array | null | WP_Error Sanitize an input.
save ( ) : false | void Checks user capabilities and theme supports, and then saves the value of the setting.
validate ( mixed $value ) : true | WP_Error Validates an input.
value ( ) : mixed Fetch the value of the setting.

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

Метод Описание
_update_option ( ) Deprecated method.
_update_theme_mod ( ) Deprecated method.
aggregate_multidimensional ( ) Set up the setting for aggregated multidimensional values.
get_root_value ( mixed $default = null ) : mixed Get the root value for a setting, especially for multidimensional ones.
multidimensional ( &$root, $keys, boolean $create = false ) : array | void Multidimensional helper function.
multidimensional_get ( $root, $keys, mixed $default = null ) : mixed Will attempt to fetch a specific value from a multidimensional array.
multidimensional_isset ( $root, $keys ) : boolean Will attempt to check if a specific value in a multidimensional array is set.
multidimensional_replace ( $root, $keys, mixed $value ) : mixed Will attempt to replace a specific value in a multidimensional array.
set_root_value ( mixed $value ) : boolean Set the root value for a setting, especially for multidimensional ones.
update ( mixed $value ) : boolean Save the value of the setting, using the related API.

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

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

Any supplied $args override class property defaults.
С версии: 3.4.0
public __construct ( WP_Customize_Manager $manager, string $id, array $args = [] )
$manager WP_Customize_Manager
$id string An specific ID of the setting. Can be a theme mod or option name.
$args array Setting arguments.

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

This ensures that the new value will get sanitized and used the next time that WP_Customize_Setting::_multidimensional_preview_filter() is called for this setting.
См. также: WP_Customize_Manager::set_post_value()
См. также: WP_Customize_Setting::_multidimensional_preview_filter()
С версии: 4.4.0

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

For all multidimensional settings of a given type, the preview filter for the first setting previewed will be used to apply the values for the others.
См. также: WP_Customize_Setting::$aggregated_multidimensionals
С версии: 4.4.0
final public _multidimensional_preview_filter ( mixed $original ) : mixed
$original mixed Original root value.
Результат mixed New or old value.

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

If switch_to_blog() was called after the preview() method, and the current site is now not the same site, then this method does a no-op and returns the original value.
С версии: 3.4.0
public _preview_filter ( mixed $original ) : mixed
$original mixed Old value.
Результат mixed New or old value.

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

Deprecated method.
Устаревший: 4.4.0 Deprecated in favor of update() method.
С версии: 3.4.0
protected _update_option ( )

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

Deprecated method.
Устаревший: 4.4.0 Deprecated in favor of update() method.
С версии: 3.4.0
protected _update_theme_mod ( )

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

When a multidimensional setting gets aggregated, all of its preview and update calls get combined into one call, greatly improving performance.
С версии: 4.4.0

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

Validate user capabilities whether the theme supports the setting.
С версии: 3.4.0
final public check_capabilities ( ) : boolean
Результат boolean False if theme doesn't support the setting or user can't change setting, otherwise true.

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

Get the root value for a setting, especially for multidimensional ones.
С версии: 4.4.0
protected get_root_value ( mixed $default = null ) : mixed
$default mixed Value to return if root does not exist.
Результат mixed

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

Get parsed ID data for multidimensional setting.
С версии: 4.4.0
final public id_data ( ) : array
Результат array { ID data for multidimensional setting. @type string $base ID base @type array $keys Keys for multidimensional array. }

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

Return true if the current site is not the same as the previewed site.
С версии: 4.2.0
public is_current_blog_previewed ( ) : boolean
Результат boolean If preview() has been called.

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

Sanitize the setting's value for use in JavaScript.
С версии: 3.4.0
public js_value ( ) : mixed
Результат mixed The requested escaped value.

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

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

multidimensional() закрытый защищенный Метод

Multidimensional helper function.
С версии: 3.4.0
final protected multidimensional ( &$root, $keys, boolean $create = false ) : array | void
$root
$keys
$create boolean Default is false.
Результат array | void Keys are 'root', 'node', and 'key'.

multidimensional_get() закрытый защищенный Метод

Will attempt to fetch a specific value from a multidimensional array.
С версии: 3.4.0
final protected multidimensional_get ( $root, $keys, mixed $default = null ) : mixed
$root
$keys
$default mixed A default value which is used as a fallback. Default is null.
Результат mixed The requested value or the default value.

multidimensional_isset() закрытый защищенный Метод

Will attempt to check if a specific value in a multidimensional array is set.
С версии: 3.4.0
final protected multidimensional_isset ( $root, $keys ) : boolean
$root
$keys
Результат boolean True if value is set, false if not.

multidimensional_replace() закрытый защищенный Метод

Will attempt to replace a specific value in a multidimensional array.
С версии: 3.4.0
final protected multidimensional_replace ( $root, $keys, mixed $value ) : mixed
$root
$keys
$value mixed The value to update.
Результат mixed

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

During a save request prior to save, post_value() provides the new value while value() does not.
С версии: 3.4.0
final public post_value ( mixed $default = null ) : mixed
$default mixed A default value which is used as a fallback. Default is null.
Результат mixed The default value on failure, otherwise the sanitized and validated value.

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

If the setting already has a pre-existing value and there is no incoming post value for the setting, then this method will short-circuit since there is no change to preview.
С версии: 3.4.0
С версии: 4.4.0 Added boolean return value.
public preview ( ) : boolean
Результат boolean False when preview short-circuits due no change needing to be previewed.

reset_aggregated_multidimensionals() публичный статический Метод

This is intended only for use by unit tests.
С версии: 4.5.0

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

Sanitize an input.
С версии: 3.4.0
public sanitize ( string | array $value ) : string | array | null | WP_Error
$value string | array The value to sanitize.
Результат string | array | null | WP_Error Sanitized value, or `null`/`WP_Error` if invalid.

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

Checks user capabilities and theme supports, and then saves the value of the setting.
С версии: 3.4.0
final public save ( ) : false | void
Результат false | void False if cap check fails or value isn't set or is invalid.

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

Set the root value for a setting, especially for multidimensional ones.
С версии: 4.4.0
protected set_root_value ( mixed $value ) : boolean
$value mixed Value to set as root of multidimensional setting.
Результат boolean Whether the multidimensional root was updated successfully.

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

Save the value of the setting, using the related API.
С версии: 3.4.0
protected update ( mixed $value ) : boolean
$value mixed The value to update.
Результат boolean The result of saving the value.

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

Validates an input.
См. также: WP_REST_Request::has_valid_params()
С версии: 4.6.0
public validate ( mixed $value ) : true | WP_Error
$value mixed Value to validate.
Результат true | WP_Error True if the input was validated, otherwise WP_Error.

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

Fetch the value of the setting.
С версии: 3.4.0
public value ( ) : mixed
Результат mixed The value.

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

$_original_value защищенное свойство

Original non-previewed value stored by the preview method.
См. также: WP_Customize_Setting::preview()
С версии: 4.1.1
protected mixed $_original_value
Результат mixed

$_previewed_blog_id защищенное свойство

The ID for the current site when the preview() method was called.
С версии: 4.2.0
protected int $_previewed_blog_id
Результат integer

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

Cache of multidimensional values to improve performance.
С версии: 4.4.0
protected static array $aggregated_multidimensionals
Результат array

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

Capability required to edit this setting.
public string $capability
Результат string

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

public $default

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

This is used to ensure that a setting will be sent from the pane to the preview when loading the Customizer. Normally a setting only is synced to the preview if it has been changed. This allows the setting to be sent from the start.
С версии: 4.2.0
public bool $dirty
Результат boolean

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

Unique string identifier for the setting.
public string $id
Результат string

$id_data защищенное свойство

protected array $id_data
Результат array

$is_multidimensional_aggregated защищенное свойство

Whether the multidimensional setting is aggregated.
С версии: 4.4.0
protected bool $is_multidimensional_aggregated
Результат boolean

$is_previewed защищенное свойство

Whether or not preview() was called.
С версии: 4.4.0
protected bool $is_previewed
Результат boolean

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

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

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

public $sanitize_callback

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

public $sanitize_js_callback

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

Feature a theme is required to support to enable this setting.
public string $theme_supports
Результат string

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

public $transport

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

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

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

Server-side sanitization callback for the setting's value.
public callback $validate_callback
Результат callback