Themes: Prevent a Full Site Editing theme from being activated when Gutenberg is not active.

When a theme that uses the Full Site Editing feature is activated and the Gutenberg plugin is not present, the site will currently show a text notice on the front end. The user is not made aware of this unless they visit the front end of their site.

This adds a check that will prevent a theme from being activated when the `full-site-editing` tag is present in the theme’s `style.css` header and the Gutenberg plugin is not active to prevent this scenario.

These checks can be removed once Full Site Editing is completely merged into Core.

Props desrosj, marybaum, chanthaboune.
See #53410.
Built from https://develop.svn.wordpress.org/trunk@51193


git-svn-id: http://core.svn.wordpress.org/trunk@50802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2021-06-22 02:59:56 +00:00
parent 52e1e2cc2f
commit 94841ace05
3 changed files with 24 additions and 2 deletions

View File

@ -184,8 +184,16 @@ do_action( 'customize_controls_head' );
<?php
$compatible_wp = is_wp_version_compatible( $wp_customize->theme()->get( 'RequiresWP' ) );
$compatible_php = is_php_version_compatible( $wp_customize->theme()->get( 'RequiresPHP' ) );
$fse_safe = true;
// Check if the theme requires the FSE to work correctly.
$theme_tags = $wp_customize->theme()->get( 'Tags' );
if ( ! empty( $theme_tags ) && in_array( 'full-site-editing', $theme_tags, true ) && ! is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
$fse_safe = false;
}
?>
<?php if ( $compatible_wp && $compatible_php ) : ?>
<?php if ( $compatible_wp && $compatible_php && $fse_safe ) : ?>
<?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate &amp; Publish' ); ?>
<div id="customize-save-button-wrapper" class="customize-save-button-wrapper" >
<?php submit_button( $save_text, 'primary save', 'save', false ); ?>

View File

@ -908,6 +908,20 @@ function validate_current_theme() {
function validate_theme_requirements( $stylesheet ) {
$theme = wp_get_theme( $stylesheet );
// If the theme is a Full Site Editing theme, check for the presence of the Gutenberg plugin.
$theme_tags = $theme->get( 'Tags' );
if ( ! empty( $theme_tags ) && in_array( 'full-site-editing', $theme_tags, true ) && ! is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
return new WP_Error(
'theme_requires_fse',
sprintf(
/* translators: %s: Theme name. */
_x( '<strong>Error:</strong> This theme (%s) uses Full Site Editing, which requires the Gutenberg plugin to be activated.', 'theme' ),
$theme->display( 'Name' )
)
);
}
$requirements = array(
'requires' => ! empty( $theme->get( 'RequiresWP' ) ) ? $theme->get( 'RequiresWP' ) : '',
'requires_php' => ! empty( $theme->get( 'RequiresPHP' ) ) ? $theme->get( 'RequiresPHP' ) : '',

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8-beta2-51192';
$wp_version = '5.8-beta2-51193';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.