Skip to content

Conversation

@ellatrix
Copy link
Member

@ellatrix ellatrix commented Oct 27, 2025

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.

@ellatrix ellatrix added the bug label Oct 27, 2025
@github-actions
Copy link

github-actions bot commented Oct 27, 2025

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props ellatrix, westonruter, priethor.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Comment on lines -266 to -274
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';

Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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.

Comment on lines 4 to 7
public function __construct() {
$this->rest_base = 'registered-templates';
$this->namespace = 'wp/v2';
}
Copy link
Member

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():

Image

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?

Suggested change
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' );
}

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

@ellatrix ellatrix force-pushed the sync/template-activation-beta-2 branch from bcef580 to 20415f4 Compare October 28, 2025 12:28
update_option( 'active_templates', $active_templates );
}

function _wp_migrate_active_templates() {
Copy link
Member Author

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.

Copy link

@priethor priethor left a 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.

pento pushed a commit that referenced this pull request Oct 28, 2025
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
@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61078
GitHub commit: 7dcb09c

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Oct 28, 2025
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Oct 28, 2025
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
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Oct 28, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants