-
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
Automatically enable FSE for FSE themes #26500
Changes from all commits
8624c19
08d4aa5
55618e1
ac827d9
be1528e
473a4a4
8735a3c
5c96d7a
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* Full Site Editing Utils | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Returns whether the current theme is an FSE theme or not. | ||
* | ||
* @return boolean Whether the current theme is an FSE theme or not. | ||
*/ | ||
function gutenberg_is_fse_theme() { | ||
return is_readable( STYLESHEETPATH . '/block-templates/index.html' ); | ||
} | ||
|
||
/** | ||
* Show a notice when a Full Site Editing theme is used. | ||
*/ | ||
function gutenberg_full_site_editing_notice() { | ||
if ( ! gutenberg_is_fse_theme() ) { | ||
return; | ||
} | ||
?> | ||
<div class="notice notice-warning"> | ||
<p><?php _e( 'You\'re using an experimental Full Site Editing theme. Full Site Editing is an experimental feature and potential API changes are to be expected!', 'gutenberg' ); ?></p> | ||
</div> | ||
<?php | ||
} | ||
add_action( 'admin_notices', 'gutenberg_full_site_editing_notice' ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,14 +101,12 @@ function gutenberg_is_experiment_enabled( $name ) { | |
require dirname( __FILE__ ) . '/compat.php'; | ||
require dirname( __FILE__ ) . '/utils.php'; | ||
|
||
// Include FSE related files only if the experiment is enabled. | ||
if ( gutenberg_is_experiment_enabled( 'gutenberg-full-site-editing' ) ) { | ||
require dirname( __FILE__ ) . '/templates.php'; | ||
require dirname( __FILE__ ) . '/template-parts.php'; | ||
require dirname( __FILE__ ) . '/template-loader.php'; | ||
require dirname( __FILE__ ) . '/edit-site-page.php'; | ||
require dirname( __FILE__ ) . '/edit-site-export.php'; | ||
} | ||
require dirname( __FILE__ ) . '/full-site-editing.php'; | ||
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. Will loading these all the time create any issues for non-FSE themes? Should we just do a conditional It seems easier than all of the bail early checks within the loaded files. 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. The 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. If I recall, I moved all of these to be conditionally loaded because if the WP_Template CPT exists, then certain template resolution code starts working automatically. This meant that anyone could create WP_Template CPT, and start using template resolution behavior on the front end regardless of whether the experiment was enabled, and regardless of the theme. Basically, are we sure that the new theme check prevents that scenario? 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. Yes, we're sure I tested but regardless, with the change here #26500 (comment) we can restore this. 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. It turns out that even with the new implementation, it's too early to call the function. I think it doesn't matter anyway since all the hooks do early returns if it's not an FSE theme. |
||
require dirname( __FILE__ ) . '/templates.php'; | ||
require dirname( __FILE__ ) . '/template-parts.php'; | ||
require dirname( __FILE__ ) . '/template-loader.php'; | ||
require dirname( __FILE__ ) . '/edit-site-page.php'; | ||
require dirname( __FILE__ ) . '/edit-site-export.php'; | ||
|
||
require dirname( __FILE__ ) . '/block-patterns.php'; | ||
require dirname( __FILE__ ) . '/blocks.php'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,16 +43,14 @@ function render_block_core_site_logo( $attributes ) { | |
* Registers the `core/site-logo` block on the server. | ||
*/ | ||
function register_block_core_site_logo() { | ||
if ( gutenberg_is_experiment_enabled( 'gutenberg-full-site-editing' ) ) { | ||
register_block_type_from_metadata( | ||
__DIR__ . '/site-logo', | ||
array( | ||
'render_callback' => 'render_block_core_site_logo', | ||
) | ||
); | ||
add_filter( 'pre_set_theme_mod_custom_logo', 'sync_site_logo_to_theme_mod' ); | ||
add_filter( 'theme_mod_custom_logo', 'override_custom_logo_theme_mod' ); | ||
} | ||
register_block_type_from_metadata( | ||
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. Note: This won't be exposed in the WordPress core until explicitly listed in here: |
||
__DIR__ . '/site-logo', | ||
array( | ||
'render_callback' => 'render_block_core_site_logo', | ||
) | ||
); | ||
add_filter( 'pre_set_theme_mod_custom_logo', 'sync_site_logo_to_theme_mod' ); | ||
add_filter( 'theme_mod_custom_logo', 'override_custom_logo_theme_mod' ); | ||
} | ||
add_action( 'init', 'register_block_core_site_logo' ); | ||
|
||
|
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.
Superfluous
array_merge
call :)