Handle no data / error case for preloaded endpoint data.

This commit is contained in:
Jeff Stieler 2019-06-13 14:54:10 -06:00
parent 1825c30b26
commit 489f740741
1 changed files with 6 additions and 1 deletions

View File

@ -530,7 +530,12 @@ class WC_Admin_Loader {
if ( ! empty( $preload_data_endpoints ) ) {
foreach ( $preload_data_endpoints as $key => $endpoint ) {
$settings['dataEndpoints'][ $key ] = $preload_data[ $endpoint ]['body'];
// Handle error case: rest_do_request() doesn't guarantee success.
if ( empty( $preload_data[ $endpoint ] ) ) {
$settings['dataEndpoints'][ $key ] = array();
} else {
$settings['dataEndpoints'][ $key ] = $preload_data[ $endpoint ]['body'];
}
}
}
$settings = self::get_custom_settings( $settings );