GC_Customize_Manager::prepare_setting_validity_for_js()
最后更新于:2021-11-27 01:11:42
GC_Customize_Manager::prepare_setting_validity_for_js( true|GC_Error$validity)Prepares setting validity for exporting to the client (JS).
参数
- $validity
-
(true|GC_Error) (Required) Setting validity.
响应
(true|array) If $validity
was a GC_Error, the error codes will be array-mapped to their respective message
and data
to pass into the gc.customize.Notification
JS model.
源文件
文件: gc-includes/class-gc-customize-manager.php
public function prepare_setting_validity_for_js( $validity ) {
if ( is_gc_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;
}
}