On this page
WP_Customize_Manager::prepare_setting_validity_for_js( true|WP_Error $validity ): true|array
Prepares setting validity for exporting to the client (JS).
Description
Converts WP_Error instance into array suitable for passing into the wp.customize.Notification JS model.
Parameters
$validitytrue|WP_Error Required-
Setting validity.
Return
true|array If $validity was a WP_Error, the error codes will be array-mapped to their respective message and data to pass into the wp.customize.Notification JS model.
Source
File: wp-includes/class-wp-customize-manager.php. View all references
public function prepare_setting_validity_for_js( $validity ) {
if ( is_wp_error( $validity ) ) {
$notification = array();
foreach ( $validity->errors as $error_code => $error_messages ) {
$notification[ $error_code ] = array(
'message' => implode( ' ', $error_messages ),
'data' => $validity->get_error_data( $error_code ),
);
}
return $notification;
} else {
return true;
}
}
Related
Uses
| Uses | Description |
|---|---|
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 4.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_customize_manager/prepare_setting_validity_for_js