customize_validate_{$setting->id}
Filter HookDescription
Validates setting values. Validation is skipped for unregistered settings or for values that are already null since they will be skipped anyway. Sanitization is applied to values that pass validation, and values that become null or `WP_Error` after sanitizing are marked invalid. }Hook Information
File Location |
wp-includes/class-wp-customize-manager.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2375 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$setting_values
|
Mapping of setting IDs to values to validate and sanitize. |
array
|
$options
|
{ Options. |
Usage Examples
Basic Usage
<?php
// Hook into customize_validate_{$setting->id}
add_filter('customize_validate_{$setting->id}', 'my_custom_filter', 10, 2);
function my_custom_filter($setting_values, $options) {
// Your custom filtering logic here
return $setting_values;
}
Source Code Context
wp-includes/class-wp-customize-manager.php:2375
- How this hook is used in WordPress core
<?php
2370 }
2371 $validity = $setting->validate( $unsanitized_value );
2372 }
2373 if ( ! is_wp_error( $validity ) ) {
2374 /** This filter is documented in wp-includes/class-wp-customize-setting.php */
2375 $late_validity = apply_filters( "customize_validate_{$setting->id}", new WP_Error(), $unsanitized_value, $setting );
2376 if ( is_wp_error( $late_validity ) && $late_validity->has_errors() ) {
2377 $validity = $late_validity;
2378 }
2379 }
2380 if ( ! is_wp_error( $validity ) ) {
PHP Documentation
<?php
/**
* Validates setting values.
*
* Validation is skipped for unregistered settings or for values that are
* already null since they will be skipped anyway. Sanitization is applied
* to values that pass validation, and values that become null or `WP_Error`
* after sanitizing are marked invalid.
*
* @since 4.6.0
*
* @see WP_REST_Request::has_valid_params()
* @see WP_Customize_Setting::validate()
*
* @param array $setting_values Mapping of setting IDs to values to validate and sanitize.
* @param array $options {
* Options.
*
* @type bool $validate_existence Whether a setting's existence will be checked.
* @type bool $validate_capability Whether the setting capability will be checked.
* }
* @return array Mapping of setting IDs to return value of validate method calls, either `true` or `WP_Error`.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/class-wp-customize-manager.php
Related Hooks
Related hooks will be displayed here in future updates.