Make WordPress Core

Changeset 51193


Ignore:
Timestamp:
06/22/2021 02:58:07 AM (3 years ago)
Author:
desrosj
Message:

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.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/customize.php

    r50931 r51193  
    185185            $compatible_wp  = is_wp_version_compatible( $wp_customize->theme()->get( 'RequiresWP' ) );
    186186            $compatible_php = is_php_version_compatible( $wp_customize->theme()->get( 'RequiresPHP' ) );
     187            $fse_safe       = true;
     188
     189            // Check if the theme requires the FSE to work correctly.
     190            $theme_tags = $wp_customize->theme()->get( 'Tags' );
     191
     192            if ( ! empty( $theme_tags ) && in_array( 'full-site-editing', $theme_tags, true ) && ! is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
     193                $fse_safe = false;
     194            }
    187195            ?>
    188             <?php if ( $compatible_wp && $compatible_php ) : ?>
     196            <?php if ( $compatible_wp && $compatible_php && $fse_safe ) : ?>
    189197                <?php $save_text = $wp_customize->is_theme_active() ? __( 'Publish' ) : __( 'Activate &amp; Publish' ); ?>
    190198                <div id="customize-save-button-wrapper" class="customize-save-button-wrapper" >
  • trunk/src/wp-includes/theme.php

    r51092 r51193  
    908908function validate_theme_requirements( $stylesheet ) {
    909909    $theme = wp_get_theme( $stylesheet );
     910
     911    // If the theme is a Full Site Editing theme, check for the presence of the Gutenberg plugin.
     912    $theme_tags = $theme->get( 'Tags' );
     913
     914    if ( ! empty( $theme_tags ) && in_array( 'full-site-editing', $theme_tags, true ) && ! is_plugin_active( 'gutenberg/gutenberg.php' ) ) {
     915        return new WP_Error(
     916            'theme_requires_fse',
     917            sprintf(
     918                    /* translators: %s: Theme name. */
     919                _x( '<strong>Error:</strong> This theme (%s) uses Full Site Editing, which requires the Gutenberg plugin to be activated.', 'theme' ),
     920                $theme->display( 'Name' )
     921            )
     922        );
     923    }
    910924
    911925    $requirements = array(
Note: See TracChangeset for help on using the changeset viewer.