Skip to content

Editor: Add author support to the wp_block post type - #14269

Draft
fabiankaegy wants to merge 4 commits into
WordPress:trunkfrom
fabiankaegy:wp-block-author-support
Draft

fabiankaegy wants to merge 4 commits into
WordPress:trunkfrom
fabiankaegy:wp-block-author-support

Conversation

@fabiankaegy

@fabiankaegy fabiankaegy commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Adds author support to the wp_block post type, so the REST API returns each pattern's author. The block inserter and the Site Editor's Patterns screen use it to filter patterns by author.

Sets delete_with_user to false, so deleting a user keeps their patterns, as they may be used across the site. Without it, author support would make wp_delete_user() delete them permanently.

Also renames the Site Editor's "My patterns" view to "Site patterns", since it lists every user-created pattern, not only the current user's.

The author is already stored on every pattern and the post type's capabilities already check it. This only makes it visible to the editor.

Gutenberg PR: WordPress/gutenberg#84680

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

Use of AI Tools

Drafted with Claude Code, reviewed by me.


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.

This exposes each pattern's author through the REST API, so the editor can tell the current user's patterns apart from the rest of the site's patterns.
@github-actions

Copy link
Copy Markdown

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

  • 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.

The view lists every user-created pattern, not only the current user's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Since adding author support changes the behavior of wp_block beyond the REST API, I think we should add some tests:

  • REST API: The blocks controller returns author in the response, and the author and author_exclude query parameters filter patterns by author.
  • REST API: A user without edit_others_posts can't change the author of a pattern.
  • Deleting a user: Deleting a user without reassigning their content also deletes their patterns, and reassigning moves them to the new user. This is the same behavior as templates and template parts, but it changes how patterns work today, so a test would document it as intended.
  • QUnit fixtures: The REST schema gets new author arguments, so the API fixtures probably need to be regenerated.

Covers the author in the blocks controller's response, filtering patterns by author, changing a pattern's author, and what happens to a user's patterns when the user is deleted. Regenerates the REST API client fixtures for the new author arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fabiankaegy

fabiankaegy commented Oct 15, 2026 •

Copy link
Copy Markdown
Member Author

Thanks @t-hamano! Added tests for all four:

  • The blocks controller returns author, and author / author_exclude filter patterns by author.
  • An author can't change a pattern's author (403), an editor can.
  • Deleting a user keeps their patterns, and reassigning moves them to the new user. Without delete_with_user, author support would have deleted the patterns permanently (only posts and pages go to the trash). Patterns may be used across the site, so I've set delete_with_user to false to keep today's behavior.
  • Regenerated the QUnit fixtures.

Patterns may be used across the site, so deleting a user shouldn't delete their patterns, now that the post type supports authors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants