Skip to content

Commit

Permalink
Load FSE php files only if experiment is enabled (#24182)
Browse files Browse the repository at this point in the history
* Only load FSE php files if experiment enabled
  • Loading branch information
noahtallen authored Aug 7, 2020
1 parent 200acec commit 4719212
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
14 changes: 9 additions & 5 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,17 @@ 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__ ) . '/block-patterns.php';
require dirname( __FILE__ ) . '/blocks.php';
require dirname( __FILE__ ) . '/templates.php';
require dirname( __FILE__ ) . '/template-parts.php';
require dirname( __FILE__ ) . '/template-loader.php';
require dirname( __FILE__ ) . '/client-assets.php';
require dirname( __FILE__ ) . '/block-directory.php';
require dirname( __FILE__ ) . '/demo.php';
Expand All @@ -99,8 +105,6 @@ function gutenberg_is_experiment_enabled( $name ) {
require dirname( __FILE__ ) . '/navigation-page.php';
require dirname( __FILE__ ) . '/experiments-page.php';
require dirname( __FILE__ ) . '/customizer.php';
require dirname( __FILE__ ) . '/edit-site-page.php';
require dirname( __FILE__ ) . '/edit-site-export.php';
require dirname( __FILE__ ) . '/global-styles.php';
require dirname( __FILE__ ) . '/block-supports/index.php';
require dirname( __FILE__ ) . '/block-supports/align.php';
Expand Down
6 changes: 1 addition & 5 deletions lib/template-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ function get_template_types() {
* Adds necessary filters to use 'wp_template' posts instead of theme template files.
*/
function gutenberg_add_template_loader_filters() {
if ( ! post_type_exists( 'wp_template' ) ) {
return;
}

foreach ( get_template_types() as $template_type ) {
if ( 'embed' === $template_type ) { // Skip 'embed' for now because it is not a regular template type.
continue;
Expand Down Expand Up @@ -426,7 +422,7 @@ function gutenberg_strip_php_suffix( $template_file ) {
function gutenberg_template_loader_filter_block_editor_settings( $settings ) {
global $post;

if ( ! $post || ! post_type_exists( 'wp_template' ) || ! post_type_exists( 'wp_template_part' ) ) {
if ( ! $post ) {
return $settings;
}

Expand Down
4 changes: 0 additions & 4 deletions lib/template-parts.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* Registers block editor 'wp_template_part' post type.
*/
function gutenberg_register_template_part_post_type() {
if ( ! gutenberg_is_experiment_enabled( 'gutenberg-full-site-editing' ) ) {
return;
}

$labels = array(
'name' => __( 'Template Parts', 'gutenberg' ),
'singular_name' => __( 'Template Part', 'gutenberg' ),
Expand Down
4 changes: 0 additions & 4 deletions lib/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* Registers block editor 'wp_template' post type.
*/
function gutenberg_register_template_post_type() {
if ( ! gutenberg_is_experiment_enabled( 'gutenberg-full-site-editing' ) ) {
return;
}

$labels = array(
'name' => __( 'Templates', 'gutenberg' ),
'singular_name' => __( 'Template', 'gutenberg' ),
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function gutenberg_is_block_editor() {
(
$screen->is_block_editor() ||
'gutenberg_page_gutenberg-widgets' === $screen->id ||
gutenberg_is_edit_site_page( $screen->id )
( function_exists( 'gutenberg_is_edit_site_page' ) && gutenberg_is_edit_site_page( $screen->id ) )
);
}

Expand Down

0 comments on commit 4719212

Please sign in to comment.