From 1d3c2f7ada87a4c408fe56edc2889cc9eb8058f9 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Tue, 14 Feb 2023 19:06:27 +0000 Subject: [PATCH] Chore: Move Gutenberg_REST_Templates_Controller from 6.2 to 6.3 compatibility. (#48077) --- lib/compat/wordpress-6.2/rest-api.php | 15 --------------- ...s-gutenberg-rest-templates-controller-6-3.php} | 2 +- lib/compat/wordpress-6.3/rest-api.php | 15 +++++++++++++++ lib/load.php | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) rename lib/compat/{wordpress-6.2/class-gutenberg-rest-templates-controller-6-2.php => wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php} (97%) diff --git a/lib/compat/wordpress-6.2/rest-api.php b/lib/compat/wordpress-6.2/rest-api.php index 06780aceb245e3..a504be4dca2a6b 100644 --- a/lib/compat/wordpress-6.2/rest-api.php +++ b/lib/compat/wordpress-6.2/rest-api.php @@ -5,21 +5,6 @@ * @package gutenberg */ -/** - * Update `wp_template` and `wp_template-part` post types to use - * Gutenberg's REST controller. - * - * @param array $args Array of arguments for registering a post type. - * @param string $post_type Post type key. - */ -function gutenberg_update_templates_template_parts_rest_controller( $args, $post_type ) { - if ( in_array( $post_type, array( 'wp_template', 'wp_template-part' ), true ) ) { - $args['rest_controller_class'] = 'Gutenberg_REST_Templates_Controller_6_2'; - } - return $args; -} -add_filter( 'register_post_type_args', 'gutenberg_update_templates_template_parts_rest_controller', 10, 2 ); - /** * Registers the block pattern categories REST API routes. */ diff --git a/lib/compat/wordpress-6.2/class-gutenberg-rest-templates-controller-6-2.php b/lib/compat/wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php similarity index 97% rename from lib/compat/wordpress-6.2/class-gutenberg-rest-templates-controller-6-2.php rename to lib/compat/wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php index 16d38ac073e68d..f857cedd37f9a1 100644 --- a/lib/compat/wordpress-6.2/class-gutenberg-rest-templates-controller-6-2.php +++ b/lib/compat/wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php @@ -9,7 +9,7 @@ /** * Base Templates REST API Controller. */ -class Gutenberg_REST_Templates_Controller_6_2 extends Gutenberg_REST_Templates_Controller { +class Gutenberg_REST_Templates_Controller_6_3 extends Gutenberg_REST_Templates_Controller { /** * Registers the controllers routes. diff --git a/lib/compat/wordpress-6.3/rest-api.php b/lib/compat/wordpress-6.3/rest-api.php index 55a45df07d5932..93422289100dfa 100644 --- a/lib/compat/wordpress-6.3/rest-api.php +++ b/lib/compat/wordpress-6.3/rest-api.php @@ -13,3 +13,18 @@ function gutenberg_register_rest_pattern_directory() { $pattern_directory_controller->register_routes(); } add_action( 'rest_api_init', 'gutenberg_register_rest_pattern_directory' ); + +/** + * Update `wp_template` and `wp_template-part` post types to use + * Gutenberg's REST controller. + * + * @param array $args Array of arguments for registering a post type. + * @param string $post_type Post type key. + */ +function gutenberg_update_templates_template_parts_rest_controller( $args, $post_type ) { + if ( in_array( $post_type, array( 'wp_template', 'wp_template-part' ), true ) ) { + $args['rest_controller_class'] = 'Gutenberg_REST_Templates_Controller_6_3'; + } + return $args; +} +add_filter( 'register_post_type_args', 'gutenberg_update_templates_template_parts_rest_controller', 10, 2 ); diff --git a/lib/load.php b/lib/load.php index dc253408a92899..035fbe3740627f 100644 --- a/lib/load.php +++ b/lib/load.php @@ -44,13 +44,13 @@ function gutenberg_is_experiment_enabled( $name ) { require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-block-patterns-controller-6-2.php'; require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-block-pattern-categories-controller.php'; require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-pattern-directory-controller-6-2.php'; - require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-templates-controller-6-2.php'; require_once __DIR__ . '/compat/wordpress-6.2/rest-api.php'; require_once __DIR__ . '/compat/wordpress-6.2/block-patterns.php'; require_once __DIR__ . '/compat/wordpress-6.2/class-gutenberg-rest-global-styles-controller-6-2.php'; // WordPress 6.3 compat. require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-pattern-directory-controller-6-3.php'; + require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-templates-controller-6-3.php'; require_once __DIR__ . '/compat/wordpress-6.3/rest-api.php'; // Experimental.