-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,3 +72,16 @@ function gutenberg_filter_wp_template_unique_post_slug( $override_slug, $slug, $ | |
// Remove 5.8 filter if existant. | ||
remove_filter( 'pre_wp_unique_post_slug', 'wp_filter_wp_template_unique_post_slug' ); | ||
add_filter( 'pre_wp_unique_post_slug', 'gutenberg_filter_wp_template_unique_post_slug', 10, 5 ); | ||
|
||
/** | ||
* 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 commentThe reason will be displayed to describe this comment to others. Learn more. In this function I added There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 😀 |
||
add_theme_support( 'block-templates' ); | ||
} | ||
} | ||
|
||
// Remove 5.8 filter if existant. | ||
remove_action( 'setup_theme', 'wp_enable_block_templates' ); | ||
add_action( 'setup_theme', 'gutenberg_enable_block_templates' ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* Additions to the WordPress theme.php file | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
if ( function_exists( 'wp_is_block_theme' ) ) { | ||
youknowriad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* Returns whether the current theme is an FSE theme or not. | ||
* | ||
* @return boolean Whether the current theme is an FSE theme or not. | ||
youknowriad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
function wp_is_block_theme() { | ||
return is_readable( get_theme_file_path( '/block-templates/index.html' ) ) || | ||
is_readable( get_theme_file_path( '/templates/index.html' ) ); | ||
} | ||
} |
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 @gzioloThere 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.
https://core.trac.wordpress.org/ticket/54583
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 insideprocess.env.GUTENBERG_PHASE === 2
meaning it's not necessary at all to backport this to Core.