-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Template activation: merge new GB changes for Beta 2 #10425
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
Changes from all commits
fa04cbc
a2d0e99
8dfcd52
73060b8
f8f44c7
33fa916
9892a04
20415f4
13c40c8
937f020
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -263,15 +263,6 @@ function rest_api_default_filters() { | |
| * @since 4.7.0 | ||
| */ | ||
| function create_initial_rest_routes() { | ||
| global $wp_post_types; | ||
|
|
||
| // Register the registered templates endpoint. For that we need to copy the | ||
| // wp_template post type so that it's available as an entity in core-data. | ||
| $wp_post_types['wp_registered_template'] = clone $wp_post_types['wp_template']; | ||
| $wp_post_types['wp_registered_template']->name = 'wp_registered_template'; | ||
| $wp_post_types['wp_registered_template']->rest_base = 'wp_registered_template'; | ||
| $wp_post_types['wp_registered_template']->rest_controller_class = 'WP_REST_Registered_Templates_Controller'; | ||
|
|
||
|
Comment on lines
-266
to
-274
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's great this is being removed. It caused issues due to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, I didn't know there's a max length |
||
| foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) { | ||
| $controller = $post_type->get_rest_controller(); | ||
|
|
||
|
|
@@ -298,11 +289,14 @@ function create_initial_rest_routes() { | |
| } | ||
| } | ||
|
|
||
| global $wp_post_types; | ||
|
|
||
| // Register the old templates endpoints. The WP_REST_Templates_Controller | ||
| // and sub-controllers used linked to the wp_template post type, but are no | ||
| // longer. They still require a post type object when contructing the class. | ||
| // To maintain backward and changes to these controller classes, we make use | ||
| // that the wp_template post type has the right information it needs. | ||
| $current_wp_template_rest_base = $wp_post_types['wp_template']->rest_base; | ||
| $wp_post_types['wp_template']->rest_base = 'templates'; | ||
| // Store the classes so they can be restored. | ||
| $original_rest_controller_class = $wp_post_types['wp_template']->rest_controller_class; | ||
|
|
@@ -328,7 +322,7 @@ function create_initial_rest_routes() { | |
| $wp_post_types['wp_template']->autosave_rest_controller_class = $original_autosave_rest_controller_class; | ||
| $wp_post_types['wp_template']->revisions_rest_controller_class = $original_revisions_rest_controller_class; | ||
| // Restore the original base. | ||
| $wp_post_types['wp_template']->rest_base = 'wp_template'; | ||
| $wp_post_types['wp_template']->rest_base = $current_wp_template_rest_base; | ||
|
|
||
| // Register the old routes. | ||
| $autosaves_controller->register_routes(); | ||
|
|
@@ -356,6 +350,10 @@ function create_initial_rest_routes() { | |
| ) | ||
| ); | ||
|
|
||
| // Registered templates. | ||
| $controller = new WP_REST_Registered_Templates_Controller(); | ||
| $controller->register_routes(); | ||
|
|
||
| // Post types. | ||
| $controller = new WP_REST_Post_Types_Controller(); | ||
| $controller->register_routes(); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is missing phpdoc. We should add it at some point during beta. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was forgotten before Beta 1. There's a follow-up PR, but it still unsure what the final migration should look like. In the meantime, let's merge the changes we have worked with so far in Gutenberg.