From 639e3180d390977bf1100275b56eaef78df1426c Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 5 Apr 2022 11:47:14 +0000 Subject: [PATCH] Block Editor: Synchronize global styles endpoint code with Gutenberg. This adds a missing fallback to ensure styles property is always defined in the returned data. Props gziolo. See #55505. git-svn-id: https://develop.svn.wordpress.org/trunk@53075 602fd350-edb4-49c9-b593-d223f7449a82 --- .../endpoints/class-wp-rest-global-styles-controller.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php index 5d0c4ede2b..37def7688e 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php @@ -582,9 +582,7 @@ class WP_REST_Global_Styles_Controller extends WP_REST_Controller { if ( rest_is_field_included( 'styles', $fields ) ) { $raw_data = $theme->get_raw_data(); - if ( isset( $raw_data['styles'] ) ) { - $data['styles'] = $raw_data['styles']; - } + $data['styles'] = isset( $raw_data['styles'] ) ? $raw_data['styles'] : array(); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view';