Skip to content
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

Add: Template and template_lock to post types endpoint. #6864

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Jun 20, 2024

Trac: https://core.trac.wordpress.org/ticket/61477

Backports WordPress/gutenberg#62488 into the core.
Adds template and template_lock property of the post type to post types REST API endpoint.

This change allows to fix a bug where the template of a page is not respected when creating a new page on the site editor.

The update on the unit test is in progress and is still missing.

Testing

With the Gutenberg plugin disabled.
I added the following test code to a PHP file:

function myplugin_register_template() {
    $post_type_object = get_post_type_object( 'page' );
    $post_type_object->template = array(
        array( 'core/image' ),
    );
	$post_type_object->template_lock = 'all';
}
add_action( 'init', 'myplugin_register_template' );

I opened the site editor and pasted:
wp.data.select('core').getPostType( 'page' );

I verified the template and template_lock information was included.
I repeated the test with the Gutenberg plugin enabled to make sure things worked well together.

Copy link

Trac Ticket Missing

This pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac.

To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook.

@hubot hubot deleted the add/template-and-template-lock-to-post-types-endpoint branch June 20, 2024 11:05
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.

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.

1 participant