Skip to content

Commit

Permalink
Global Styles: synchronize user CPT registration and UI visibility (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Oct 11, 2021
1 parent 32da4ed commit 4b1baf5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
20 changes: 13 additions & 7 deletions lib/global-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ function gutenberg_experimental_global_styles_settings( $settings ) {
is_callable( 'get_current_screen' ) &&
function_exists( 'gutenberg_is_edit_site_page' ) &&
gutenberg_is_edit_site_page( get_current_screen()->id ) &&
WP_Theme_JSON_Resolver_Gutenberg::theme_has_support() &&
gutenberg_supports_block_templates()
gutenberg_experimental_is_site_editor_available()
) {
$context = 'site-editor';
}
Expand Down Expand Up @@ -227,17 +226,24 @@ function_exists( 'gutenberg_is_edit_site_page' ) &&
return $settings;
}

/**
* Whether or not the Site Editor is available.
*
* @return boolean
*/
function gutenberg_experimental_is_site_editor_available() {
return gutenberg_is_fse_theme();
}

/**
* Register CPT to store/access user data.
*
* @return array|undefined
* @return void
*/
function gutenberg_experimental_global_styles_register_user_cpt() {
if ( ! WP_Theme_JSON_Resolver_Gutenberg::theme_has_support() ) {
return;
if ( gutenberg_experimental_is_site_editor_available() ) {
WP_Theme_JSON_Resolver_Gutenberg::register_user_custom_post_type();
}

WP_Theme_JSON_Resolver_Gutenberg::register_user_custom_post_type();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function gutenberg_menu() {
* @since 9.4.0
*/
function gutenberg_site_editor_menu() {
if ( gutenberg_is_fse_theme() ) {
if ( gutenberg_experimental_is_site_editor_available() ) {
add_menu_page(
__( 'Site Editor (beta)', 'gutenberg' ),
sprintf(
Expand Down

0 comments on commit 4b1baf5

Please sign in to comment.