-
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
Template activation: merge new GB changes for Beta 2 #10425
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
| 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'; | ||
|
|
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.
It's great this is being removed. It caused issues due to wp_registered_template being longer than 20 characters, the max length for a post type. See PR comment.
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.
Wow, I didn't know there's a max length
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 file is missing phpdoc. We should add it at some point during beta.
| public function __construct() { | ||
| $this->rest_base = 'registered-templates'; | ||
| $this->namespace = 'wp/v2'; | ||
| } |
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.
PhpStorm is complaining about this not calling parent::__construct():
Maybe this class shouldn't be extending WP_REST_Templates_Controller but rather extend WP_REST_Controller?
Or should this be passing wp_temlate as the post type?
| public function __construct() { | |
| $this->rest_base = 'registered-templates'; | |
| $this->namespace = 'wp/v2'; | |
| } | |
| public function __construct() { | |
| $this->rest_base = 'registered-templates'; | |
| $this->namespace = 'wp/v2'; | |
| parent::__construct( 'wp_template' ); | |
| } |
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.
Otherwise, there are methods in WP_REST_Templates_Controller which are expecting $this->post_type to be set, but it is null at present.
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.
That's true, though I think none of these methods will be called. And yes, ideally we refactor this to not extend WP_REST_Templates_Controller at all. Perhaps I can just call the parent construct for now and look at this after Beta 2.
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.
Though parent::__construct( 'wp_template' ); will have to be called before setting the other properties or it will override those.
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.
Added the parent construct call. I'll avoid extending WP_REST_Templates_Controller in a follow-up.
bcef580 to
20415f4
Compare
| update_option( 'active_templates', $active_templates ); | ||
| } | ||
|
|
||
| function _wp_migrate_active_templates() { |
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.
priethor
left a comment
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.
Let's get this in for Beta2 and address any polishing in a follow-up.
Developed in #10425. See https://core.trac.wordpress.org/ticket/62755. * Rename new endpoints, WordPress/gutenberg#72700. * Remove fake post type for registered templates, WordPress/gutenberg#72674. * Remove the ability to deactivate registered templates, WordPress/gutenberg#72636, * Fix undefined array key PHP warning, WordPress/gutenberg#72729. * Add migration logic (to be refined), see https://core.trac.wordpress.org/ticket/64133 and #10418. Fixes #62755. Props ellatrix, priethor. git-svn-id: https://develop.svn.wordpress.org/trunk@61078 602fd350-edb4-49c9-b593-d223f7449a82
Developed in WordPress/wordpress-develop#10425. See https://core.trac.wordpress.org/ticket/62755. * Rename new endpoints, WordPress/gutenberg#72700. * Remove fake post type for registered templates, WordPress/gutenberg#72674. * Remove the ability to deactivate registered templates, WordPress/gutenberg#72636, * Fix undefined array key PHP warning, WordPress/gutenberg#72729. * Add migration logic (to be refined), see https://core.trac.wordpress.org/ticket/64133 and WordPress/wordpress-develop#10418. Fixes #62755. Props ellatrix, priethor. Built from https://develop.svn.wordpress.org/trunk@61078 git-svn-id: http://core.svn.wordpress.org/trunk@60414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Developed in WordPress/wordpress-develop#10425. See https://core.trac.wordpress.org/ticket/62755. * Rename new endpoints, WordPress/gutenberg#72700. * Remove fake post type for registered templates, WordPress/gutenberg#72674. * Remove the ability to deactivate registered templates, WordPress/gutenberg#72636, * Fix undefined array key PHP warning, WordPress/gutenberg#72729. * Add migration logic (to be refined), see https://core.trac.wordpress.org/ticket/64133 and WordPress/wordpress-develop#10418. Fixes #62755. Props ellatrix, priethor. Built from https://develop.svn.wordpress.org/trunk@61078 git-svn-id: https://core.svn.wordpress.org/trunk@60414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This merges the following changes from Gutenberg:
Trac ticket: https://core.trac.wordpress.org/ticket/62755
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.