diff --git a/lib/experimental/class-gutenberg-rest-template-revision-count.php b/lib/compat/wordpress-6.4/class-gutenberg-rest-templates-controller-6-4.php similarity index 91% rename from lib/experimental/class-gutenberg-rest-template-revision-count.php rename to lib/compat/wordpress-6.4/class-gutenberg-rest-templates-controller-6-4.php index 17fb34e05ecfe1..ec969519f9ac4f 100644 --- a/lib/experimental/class-gutenberg-rest-template-revision-count.php +++ b/lib/compat/wordpress-6.4/class-gutenberg-rest-templates-controller-6-4.php @@ -1,19 +1,19 @@ register_routes(); } add_action( 'rest_api_init', 'gutenberg_register_rest_block_patterns_routes' ); + + +if ( ! function_exists( 'wp_api_template_revision_args' ) ) { + /** + * Hook in to the template and template part post types and decorate + * the rest endpoint with the revision count. + * + * @param array $args Current registered post type args. + * @param string $post_type Name of post type. + * + * @return array + */ + function wp_api_template_revision_args( $args, $post_type ) { + if ( 'wp_template' === $post_type || 'wp_template_part' === $post_type ) { + $args['rest_controller_class'] = 'Gutenberg_REST_Templates_Controller_6_4'; + } + return $args; + } +} +add_filter( 'register_post_type_args', 'wp_api_template_revision_args', 10, 2 ); diff --git a/lib/experimental/rest-api.php b/lib/experimental/rest-api.php index 7c6a9bf74d7395..77f7d091d2655d 100644 --- a/lib/experimental/rest-api.php +++ b/lib/experimental/rest-api.php @@ -101,25 +101,3 @@ function gutenberg_auto_draft_get_sample_permalink( $permalink, $id, $title, $na return $permalink; } add_filter( 'get_sample_permalink', 'gutenberg_auto_draft_get_sample_permalink', 10, 5 ); - -if ( ! function_exists( 'wp_api_template_revision_args' ) ) { - /** - * Hook in to the template and template part post types and decorate - * the rest endpoint with the revision count. - * - * When merging to core, this can be removed once Gutenberg_REST_Template_Revision_Count is - * merged with WP_REST_Template_Controller. - * - * @param array $args Current registered post type args. - * @param string $post_type Name of post type. - * - * @return array - */ - function wp_api_template_revision_args( $args, $post_type ) { - if ( 'wp_template' === $post_type || 'wp_template_part' === $post_type ) { - $args['rest_controller_class'] = 'Gutenberg_REST_Template_Revision_Count'; - } - return $args; - } -} -add_filter( 'register_post_type_args', 'wp_api_template_revision_args', 10, 2 ); diff --git a/lib/load.php b/lib/load.php index 47d41fb50b3b5f..b111c8e0d79215 100644 --- a/lib/load.php +++ b/lib/load.php @@ -36,6 +36,7 @@ function gutenberg_is_experiment_enabled( $name ) { } // WordPress 6.4 compat. + require_once __DIR__ . '/compat/wordpress-6.4/class-gutenberg-rest-templates-controller-6-4.php'; require_once __DIR__ . '/compat/wordpress-6.4/class-gutenberg-rest-global-styles-revisions-controller-6-4.php'; require_once __DIR__ . '/compat/wordpress-6.4/class-gutenberg-rest-block-patterns-controller.php'; require_once __DIR__ . '/compat/wordpress-6.4/rest-api.php'; @@ -53,7 +54,6 @@ function gutenberg_is_experiment_enabled( $name ) { if ( ! class_exists( 'WP_Rest_Customizer_Nonces' ) ) { require_once __DIR__ . '/experimental/class-wp-rest-customizer-nonces.php'; } - require_once __DIR__ . '/experimental/class-gutenberg-rest-template-revision-count.php'; require_once __DIR__ . '/experimental/rest-api.php'; require_once __DIR__ . '/experimental/kses-allowed-html.php';