Make WordPress Core

Opened 35 hours ago

Last modified 11 hours ago

#66307 new enhancement

Editor: Add author support to the wp_block post type

Reported by: fabiankaegy Owned by:
Priority: normal Milestone: Awaiting Review
Component: Editor Version:
Severity: normal Keywords: has-patch gutenberg-merge
Cc: Focuses:

Description

The wp_block post type doesn't register author support, so the REST API doesn't return a pattern's author. Patterns already store post_author, and the post type's capabilities already check it, so this only makes it visible to the editor.

The block inserter uses it to split the "My patterns" category into "Site patterns" (every pattern on the site) and "My patterns" (only the ones the current user created).

Gutenberg PR: ​https://github.com/WordPress/gutenberg/pull/84680
Core PR: ​https://github.com/WordPress/wordpress-develop/pull/14269

Change History (2)

This ticket was mentioned in ​PR #14269 on ​WordPress/wordpress-develop by ​@fabiankaegy.


35 hours ago
#1

Adds author support to the wp_block post type, so the REST API returns each pattern's author. The block inserter uses it to split the "My patterns" category into "Site patterns" (every pattern on the site) and "My patterns" (only the ones the current user created).

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: ​https://github.com/WordPress/gutenberg/pull/84680

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.

​@fabiankaegy commented on ​PR #14269:


11 hours ago
#2

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 without reassigning deletes their patterns, and reassigning moves them. Worth noting: only posts and pages go to the trash, so the patterns are deleted permanently. Happy to set delete_with_user to false instead if we'd rather keep today's behavior.
  • Regenerated the QUnit fixtures.
Note: See TracTickets for help on using tickets.