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

Plugin: Fix REST API class redeclaration #40265

Merged
merged 1 commit into from
Apr 12, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
* @since 6.0.0
*/

if ( class_exists( 'WP_REST_Block_Pattern_Categories_Controller' ) ) {
return;
}

/**
* Core class used to access block pattern categories via the REST API.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
* @since 6.0.0
*/

if ( class_exists( 'WP_REST_Block_Patterns_Controller' ) ) {
return;
}

/**
* Core class used to access block patterns via the REST API.
*
Expand Down
43 changes: 25 additions & 18 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,47 @@ function gutenberg_is_experiment_enabled( $name ) {
// These files only need to be loaded if within a rest server instance
// which this class will exist if that is the case.
if ( class_exists( 'WP_REST_Controller' ) ) {
// WordPress 5.9 compat.
require_once __DIR__ . '/compat/wordpress-5.9/class-gutenberg-rest-templates-controller.php';
require_once __DIR__ . '/compat/wordpress-5.9/class-wp-rest-global-styles-controller.php';
require_once __DIR__ . '/compat/wordpress-5.9/rest-active-global-styles.php';
if ( ! class_exists( 'WP_REST_Menus_Controller' ) ) {
require_once __DIR__ . '/compat/wordpress-5.9/class-wp-rest-menus-controller.php';
}
if ( ! class_exists( 'WP_REST_Menu_Items_Controller' ) ) {
require_once __DIR__ . '/compat/wordpress-5.9/class-wp-rest-menu-items-controller.php';
}
if ( ! class_exists( 'WP_REST_Block_Navigation_Areas_Controller' ) ) {
require_once __DIR__ . '/experimental/class-wp-rest-block-navigation-areas-controller.php';
}
if ( ! class_exists( 'WP_REST_Menu_Locations_Controller' ) ) {
require_once __DIR__ . '/compat/wordpress-5.9/class-wp-rest-menu-locations-controller.php';
}
if ( ! class_exists( 'WP_Rest_Customizer_Nonces' ) ) {
require_once __DIR__ . '/experimental/class-wp-rest-customizer-nonces.php';
}
require_once __DIR__ . '/compat/wordpress-5.9/class-gutenberg-rest-templates-controller.php';
if ( ! class_exists( 'WP_REST_Block_Editor_Settings_Controller' ) ) {
require_once __DIR__ . '/experimental/class-wp-rest-block-editor-settings-controller.php';
}

if ( ! class_exists( 'WP_REST_URL_Details_Controller' ) ) {
require_once __DIR__ . '/compat/wordpress-5.9/class-wp-rest-url-details-controller.php';
}
require_once __DIR__ . '/compat/wordpress-5.9/rest-api.php';

require __DIR__ . '/experimental/rest-api.php';
require __DIR__ . '/compat/wordpress-5.9/rest-api.php';
// WordPress 6.0 compat.
require_once __DIR__ . '/compat/wordpress-6.0/class-gutenberg-rest-global-styles-controller.php';
require_once __DIR__ . '/compat/wordpress-6.0/class-gutenberg-rest-pattern-directory-controller.php';
require_once __DIR__ . '/compat/wordpress-6.0/class-gutenberg-rest-edit-site-export-controller.php';
if ( ! class_exists( 'WP_REST_Block_Patterns_Controller' ) ) {
require_once __DIR__ . '/compat/wordpress-6.0/class-wp-rest-block-patterns-controller.php';
}
if ( ! class_exists( 'WP_REST_Block_Pattern_Categories_Controller' ) ) {
require_once __DIR__ . '/compat/wordpress-6.0/class-wp-rest-block-pattern-categories-controller.php';
}
require_once __DIR__ . '/compat/wordpress-6.0/rest-api.php';

// Experimental.
if ( ! class_exists( 'WP_Rest_Customizer_Nonces' ) ) {
require_once __DIR__ . '/experimental/class-wp-rest-customizer-nonces.php';
}
if ( ! class_exists( 'WP_REST_Block_Navigation_Areas_Controller' ) ) {
require_once __DIR__ . '/experimental/class-wp-rest-block-navigation-areas-controller.php';
}
require_once __DIR__ . '/experimental/rest-api.php';
}

require __DIR__ . '/compat/wordpress-5.9/block-gallery.php';
Expand Down Expand Up @@ -89,21 +104,13 @@ function gutenberg_is_experiment_enabled( $name ) {
require __DIR__ . '/compat/wordpress-5.9/block-template.php';
require __DIR__ . '/compat/wordpress-5.9/wp-theme-get-post-templates.php';
require __DIR__ . '/compat/wordpress-5.9/default-theme-supports.php';
require __DIR__ . '/compat/wordpress-5.9/class-wp-rest-global-styles-controller.php';
require __DIR__ . '/compat/wordpress-5.9/rest-active-global-styles.php';
require __DIR__ . '/compat/wordpress-5.9/move-theme-editor-menu-item.php';
require __DIR__ . '/compat/wordpress-6.0/post-lock.php';
require __DIR__ . '/compat/wordpress-6.0/blocks.php';
require __DIR__ . '/compat/wordpress-6.0/block-template-utils.php';
require __DIR__ . '/compat/wordpress-6.0/class-gutenberg-rest-global-styles-controller.php';
require __DIR__ . '/compat/wordpress-6.0/class-gutenberg-rest-pattern-directory-controller.php';
require __DIR__ . '/compat/wordpress-6.0/class-gutenberg-rest-edit-site-export-controller.php';
require __DIR__ . '/compat/wordpress-6.0/class-wp-rest-block-patterns-controller.php';
require __DIR__ . '/compat/wordpress-6.0/class-wp-rest-block-pattern-categories-controller.php';
require __DIR__ . '/compat/wordpress-6.0/functions.php';
require __DIR__ . '/compat/wordpress-6.0/class-wp-theme-json-gutenberg.php';
require __DIR__ . '/compat/wordpress-6.0/class-wp-theme-json-resolver-6-0.php';
require __DIR__ . '/compat/wordpress-6.0/rest-api.php';
require __DIR__ . '/compat/wordpress-6.0/block-patterns.php';
require __DIR__ . '/compat/wordpress-6.0/block-template.php';
require __DIR__ . '/compat/wordpress-6.0/edit-form-blocks.php';
Expand Down