Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Styles: synchronize user CPT registration and UI visibility #35427

Merged
merged 5 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -231,17 +230,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() ) {
Copy link
Member Author

@oandregal oandregal Oct 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have avoided this change by using gutenberg_is_fse_theme directly is GS code. However, it feels like if the edit site & GS are connected "conceptually" as we're arguing, they should also be explicitly connected by code. So, when/if our future selves want to update this logic is clear what it affects to.

add_menu_page(
__( 'Site Editor (beta)', 'gutenberg' ),
sprintf(
Expand Down