WP_Customize_Setting
- Since
- 3.4.0
- Source
wp-includes/class-wp-customize-setting.php:25
Customize Setting class.
Description
Handles saving and sanitizing of settings.
Compatibility
- WordPress
- since 3.4.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 8
Every hook that fires from inside WP_Customize_Setting, in the order it appears in the class, grouped by the method that fires it.
WP_Customize_Setting::preview()
- do_action( customize_preview_{$this->id} )action line 405
- do_action( customize_preview_{$this->type} )action line 417
Properties · 17
$managerWP_Customize_Managerpublic- Customizer bootstrap instance.
$idstringpublic- Unique string identifier for the setting.
$typestringpublic- Type of customize settings.
$capabilitystring|arraypublic- Capability required to edit this setting.
$theme_supportsstring|string[]public- Theme features required to support the setting.
$defaultstringpublic- The default value for the setting.
$transportstringpublic- Options for rendering the live preview of changes in Customizer.
$validate_callbackcallablepublic- Server-side validation callback for the setting's value.
$sanitize_callbackcallablepublic- Callback to filter a Customize setting value in un-slashed form.
$sanitize_js_callbackcallablepublic- Callback to convert a Customize PHP setting value to a value that is JSON serializable.
$dirtyboolpublic- Whether or not the setting is initially dirty when created.
$id_dataarrayprotected- ID Data.
$is_previewedboolprotected- Whether or not preview() was called.
$aggregated_multidimensionalsarrayprotected static- Cache of multidimensional values to improve performance.
$is_multidimensional_aggregatedboolprotected- Whether the multidimensional setting is aggregated.
$_previewed_blog_idintprotected- The ID for the current site when the preview() method was called.
$_original_valuemixedprotected- Original non-previewed value stored by the preview method.
Methods · 26
- __construct()Constructor.
- id_data()Get parsed ID data for multidimensional setting.
- aggregate_multidimensional()Set up the setting for aggregated multidimensional values.
- reset_aggregated_multidimensionals()Reset `$aggregated_multidimensionals` static variable.
- is_current_blog_previewed()Return true if the current site is not the same as the previewed site.
- preview()Add filters to supply the setting's value when accessed.
- _clear_aggregated_multidimensional_preview_applied_flag()Clear out the previewed-applied flag for a multidimensional-aggregated value whenever its post value is updated.
- _preview_filter()Callback function to filter non-multidimensional theme mods and options.
- _multidimensional_preview_filter()Callback function to filter multidimensional theme mods and options.
- save()Checks user capabilities and theme supports, and then saves the value of the setting.
- post_value()Fetch and sanitize the $_POST value for the setting.
- sanitize()Sanitize an input.
- validate()Validates an input.
- get_root_value()Get the root value for a setting, especially for multidimensional ones.
- set_root_value()Set the root value for a setting, especially for multidimensional ones.
- update()Save the value of the setting, using the related API.
- _update_theme_mod()Deprecated method.
- _update_option()Deprecated method.
- value()Fetch the value of the setting.
- js_value()Sanitize the setting's value for use in JavaScript.
- json()Retrieves the data to export to the client via JSON.
- check_capabilities()Validate user capabilities whether the theme supports the setting.
- multidimensional()Multidimensional helper function.
- multidimensional_replace()Will attempt to replace a specific value in a multidimensional array.
- multidimensional_get()Will attempt to fetch a specific value from a multidimensional array.
- multidimensional_isset()Will attempt to check if a specific value in a multidimensional array is set.
Source code
#[AllowDynamicProperties]class WP_Customize_Setting { /** * Customizer bootstrap instance. * * @since 3.4.0 * @var WP_Customize_Manager */ public $manager; /** * Unique string identifier for the setting. * * @since 3.4.0 * @var string */ public $id; /** * Type of customize settings. * * @since 3.4.0 * @var string */ public $type = 'theme_mod'; /** * Capability required to edit this setting. * * @since 3.4.0 * @var string|array */ public $capability = 'edit_theme_options'; /** * Theme features required to support the setting. * * @since 3.4.0 * @var string|string[] */ public $theme_supports = ''; /** * The default value for the setting. * * @since 3.4.0 * @var string */ public $default = ''; /** * Options for rendering the live preview of changes in Customizer. * * Set this value to 'postMessage' to enable a custom JavaScript handler to render changes to this setting * as opposed to reloading the whole page. * * @since 3.4.0 * @var string */ public $transport = 'refresh'; /** * Server-side validation callback for the setting's value. * * @since 4.6.0 * @var callable */ public $validate_callback = ''; /** * Callback to filter a Customize setting value in un-slashed form. * * @since 3.4.0 * @var callable */ public $sanitize_callback = ''; /** * Callback to convert a Customize PHP setting value to a value that is JSON serializable. *Changelog
Introduced in 3.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp-customize-setting.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.