-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Synchronize wp_is_block_theme and block-templates block support with Core #37218
Conversation
* Enable block templates (editor mode) for themes with theme.json. | ||
*/ | ||
function gutenberg_enable_block_templates() { | ||
if ( wp_is_block_theme() || WP_Theme_JSON_Resolver_Gutenberg::theme_has_support() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this function I added wp_is_block_theme
to auto-enable block-templates for block themes. It was already the case in the Gutenberg plugin because before this PR, the plugin used gutenberg_supports_block_templates
to check support but for core, if a block theme didn't have a "theme.json" file, block templates support would have been disabled. So this change here need to be backported into Core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you already made this change in Core so I'll do nothing 😀
@@ -208,7 +208,7 @@ function gutenberg_get_default_block_editor_settings() { | |||
} | |||
|
|||
$editor_settings = array( | |||
'__unstableEnableFullSiteEditingBlocks' => gutenberg_supports_block_templates(), | |||
'__unstableEnableFullSiteEditingBlocks' => current_theme_supports( 'block-templates' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that this __unstableEnableFullSiteEditingBlocks
flag is not set on Core at all, I'm not entirely sure what's the impact here but potentially we have a missing backport as well cc @noisysocks @gziolo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes there was a ticket for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually another flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I just saw that all the usage of __unstableEnableFullSiteEditingBlocks
is actually inside process.env.GUTENBERG_PHASE === 2
meaning it's not necessary at all to backport this to Core.
Co-authored-by: Ari Stathopoulos <aristath@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
Just noting that there are two backports to be done as a result of this PR so we don't forget :) |
I think this introduced a regression. I can no longer switch to block themes since this PR merged. |
@scruffian, I also noticed that. It should be fixed via #37226. |
…Core (#37218) Co-authored-by: Ari Stathopoulos <aristath@gmail.com>
In this PR I'm continuing the audit of the Gutenberg plugin php code and aligning behavior with Core.
See #37141 for the reasoning.