Skip to content

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

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

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>

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

Regardless of whether WordPress/gutenberg#84680 is merged, I believe it is worth including this PR in 7.2. As mentioned here, this PR exposes the UI to change the author of a block pattern, which I think is a valuable enhancement. cc @peterwilsoncc @Mamaduka

@fabiankaegy
fabiankaegy marked this pull request as ready for review October 16, 2026 16:39
@github-actions

Copy link
Copy Markdown

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 fabiankaegy, wildworks.

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

),
array(
'title' => __( 'My patterns' ),
'title' => __( 'Site patterns' ),

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.

I was wondering if we should include it in this PR. It feels unusual when testing because this depends on Gutenberg changes.

I think probably the easiest thing is to keep it in this PR, and if for some reason the gutenberg changes don't make it into 7.2, we can revert this change before 7.2 is shipped.

@talldan talldan 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.

This is working well for me. I tested a some different scenarios with different users. Deleting a user that owns patterns worked correctly in my testing, the patterns are kept so continue to render.

wporg-sync pushed a commit that referenced this pull request Oct 19, 2026
The REST API now returns each pattern's author, so the block inserter and the Site Editor's Patterns screen can filter patterns by author. Patterns already store `post_author` and their capabilities already check it.

Sets `delete_with_user` to `false`, so deleting a user keeps their patterns, as they may be used across the site.

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.

Developed in #14269.
Synced from WordPress/gutenberg#84680.

Props fabiankaegy, wildworks, talldanwp, jameskoster, mamaduka, fcoveram.
Fixes #66307.


git-svn-id: https://develop.svn.wordpress.org/trunk@64499 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

Copy link
Copy Markdown

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

SVN changeset: 64499
GitHub commit: 1f93570

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 19, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 19, 2026
The REST API now returns each pattern's author, so the block inserter and the Site Editor's Patterns screen can filter patterns by author. Patterns already store `post_author` and their capabilities already check it.

Sets `delete_with_user` to `false`, so deleting a user keeps their patterns, as they may be used across the site.

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.

Developed in WordPress/wordpress-develop#14269.
Synced from WordPress/gutenberg#84680.

Props fabiankaegy, wildworks, talldanwp, jameskoster, mamaduka, fcoveram.
Fixes #66307.

Built from https://develop.svn.wordpress.org/trunk@64499


git-svn-id: http://core.svn.wordpress.org/trunk@63649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@fabiankaegy
fabiankaegy deleted the wp-block-author-support branch October 19, 2026 10:58
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.

3 participants