Skip to content

Commit

Permalink
Use mobile context in settings request & global styles (#31819)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolosw authored May 14, 2021
1 parent cf7d722 commit be3f7ff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 8 additions & 2 deletions lib/class-wp-rest-block-editor-settings-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public function get_item_schema() {
),

'__experimentalFeatures' => array(
'description' => __( 'Active theme settings and default values.', 'gutenberg' ),
'description' => __( 'Settings consolidated from core, theme, and user origins.', 'gutenberg' ),
'type' => 'object',
'context' => array( 'post-editor', 'site-editor', 'widgets-editor' ),
'context' => array( 'post-editor', 'site-editor', 'widgets-editor', 'mobile' ),
),

'__experimentalGlobalStylesUserEntityId' => array(
Expand All @@ -146,6 +146,12 @@ public function get_item_schema() {
'context' => array( 'site-editor' ),
),

'__experimentalStyles' => array(
'description' => __( 'Styles consolidated from core, theme, and user origins.', 'gutenberg' ),
'type' => 'object',
'context' => array( 'mobile' ),
),

'alignWide' => array(
'description' => __( 'Enable/Disable Wide/Full Alignments.', 'gutenberg' ),
'type' => 'boolean',
Expand Down
13 changes: 9 additions & 4 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ function_exists( 'gutenberg_is_edit_site_page' ) &&
$context = 'site-editor';
}

if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
$context = 'rest-request';
if (
defined( 'REST_REQUEST' ) &&
REST_REQUEST &&
isset( $_GET['context'] ) &&
'mobile' === $_GET['context']
) {
$context = 'mobile';
}

$origin = 'theme';
Expand All @@ -102,7 +107,7 @@ function_exists( 'gutenberg_is_edit_site_page' ) &&
}
$consolidated = WP_Theme_JSON_Resolver::get_merged_data( $settings, $origin );

if ( 'rest-request' === $context ) {
if ( 'mobile' === $context ) {
$settings['__experimentalStyles'] = $consolidated->get_raw_data()['styles'];
}

Expand All @@ -116,7 +121,7 @@ function_exists( 'gutenberg_is_edit_site_page' ) &&

if (
'site-editor' !== $context &&
'rest-request' !== $context &&
'mobile' !== $context &&
( WP_Theme_JSON_Resolver::theme_has_support() || get_theme_support( 'experimental-link-color' ) )
) {
$block_styles = array( 'css' => gutenberg_experimental_global_styles_get_stylesheet( $consolidated, 'block_styles' ) );
Expand Down

0 comments on commit be3f7ff

Please sign in to comment.