From 792d4554229d7c1ecc21045ab19f3950c359afc3 Mon Sep 17 00:00:00 2001 From: Gerardo Pacheco Date: Fri, 14 May 2021 17:59:17 +0200 Subject: [PATCH 1/2] Fix condition for global styles on mobile --- lib/class-wp-rest-block-editor-settings-controller.php | 2 +- lib/global-styles.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/class-wp-rest-block-editor-settings-controller.php b/lib/class-wp-rest-block-editor-settings-controller.php index 398457e4911e54..6c7aa8d77d2c48 100644 --- a/lib/class-wp-rest-block-editor-settings-controller.php +++ b/lib/class-wp-rest-block-editor-settings-controller.php @@ -146,7 +146,7 @@ public function get_item_schema() { 'context' => array( 'site-editor' ), ), - '__experimentalStyles' => array( + '__experimentalStyles' => array( 'description' => __( 'Styles consolidated from core, theme, and user origins.', 'gutenberg' ), 'type' => 'object', 'context' => array( 'mobile' ), diff --git a/lib/global-styles.php b/lib/global-styles.php index 8d5552e5e7244c..999e6a26d7b775 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -107,7 +107,7 @@ function_exists( 'gutenberg_is_edit_site_page' ) && } $consolidated = WP_Theme_JSON_Resolver::get_merged_data( $settings, $origin ); - if ( 'mobile' === $context ) { + if ( WP_Theme_JSON_Resolver::theme_has_support() && 'mobile' === $context ) { $settings['__experimentalStyles'] = $consolidated->get_raw_data()['styles']; } From cf9486eba8fc809026a5a72490d169998432ddbc Mon Sep 17 00:00:00 2001 From: Gerardo Pacheco Date: Tue, 18 May 2021 10:05:12 +0200 Subject: [PATCH 2/2] Set mobile context if theme has support --- lib/global-styles.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/global-styles.php b/lib/global-styles.php index 999e6a26d7b775..331649d5ba5a72 100644 --- a/lib/global-styles.php +++ b/lib/global-styles.php @@ -92,7 +92,8 @@ function_exists( 'gutenberg_is_edit_site_page' ) && defined( 'REST_REQUEST' ) && REST_REQUEST && isset( $_GET['context'] ) && - 'mobile' === $_GET['context'] + 'mobile' === $_GET['context'] && + WP_Theme_JSON_Resolver::theme_has_support() ) { $context = 'mobile'; } @@ -107,7 +108,7 @@ function_exists( 'gutenberg_is_edit_site_page' ) && } $consolidated = WP_Theme_JSON_Resolver::get_merged_data( $settings, $origin ); - if ( WP_Theme_JSON_Resolver::theme_has_support() && 'mobile' === $context ) { + if ( 'mobile' === $context ) { $settings['__experimentalStyles'] = $consolidated->get_raw_data()['styles']; }