Skip to content
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

Load FSE php files only if experiment is enabled #24182

Merged
merged 6 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';
noahtallen marked this conversation as resolved.
Show resolved Hide resolved
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;
noahtallen marked this conversation as resolved.
Show resolved Hide resolved
}

$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