Editor: allow notes on the global styles post type. - #13030
Editor: allow notes on the global styles post type.#13030adamsilverstein wants to merge 1 commit into
Conversation
Notes anchor to a post, and within it to a block through that block's metadata.noteId attribute. Surfaces with neither are out of reach today: the Style Book has no post of its own, and its examples are generated fresh on every render, so there is no persisted block to record a note id on. Declare notes support on wp_global_styles so the theme's own styles record can carry those threads, and register a _wp_note_anchor comment meta holding an identifier the anchoring surface defines and resolves. The value is opaque to core and capped at 100 characters. Nothing in core reads the anchor yet; this is the storage half of the Style Book notes UI in Gutenberg. Two consequences worth noting: notes on global styles inherit that post type's capabilities, so writing one requires edit_theme_options, and because core keeps one global styles post per theme, the notes are theme-specific.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Trac Ticket MissingThis 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. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Trac ticket:
Being filed now, will be linked here once it has a number.
The core half of Style Book notes. Gutenberg PR: WordPress/gutenberg#81554, which fixes WordPress/gutenberg#73278.
Notes as they shipped in 6.9 anchor twice: to a post, through
comment_post_ID, and within that post to a block, through the block's ownmetadata.noteIdattribute. A surface with neither is out of reach today. The Style Book is exactly that surface - it has no post of its own, and its examples are generated fresh on every render, so there is no persisted block to record a note id on.Two small additions cover it.
wp_global_stylesdeclares notes support. The theme's user global styles post is the record the Styles UI already edits, so it is the natural home for feedback about that theme's styles. Nothing else about the post type changes.A
_wp_note_anchorcomment meta. A single string the anchoring surface defines and resolves, sanitized withsanitize_text_fieldand capped at 100 characters. Core never interprets it. For the Style Book it holds the example name -core/button,typography,theme-colors- which is deterministic and stable across sessions, users and reloads in a way block client ids are not.Nothing in core reads the anchor yet. This is the storage half; the UI lives in the Gutenberg PR above.
Two consequences worth stating plainly, since neither is obvious from the diff:
edit_theme_options. On most sites that means administrators only.How has this been tested
tests/phpunit/tests/rest-api/rest-global-styles-notes.phpadds 17 tests:WP_REST_Comments_Controller::check_post_type_supports_notes()actually reads, andpost_type_supports( 'wp_global_styles', 'editor' )still returning trueManual testing needs the Gutenberg PR for the UI. Its description has the steps.
Types of changes
'editor' => array( 'notes' => true )to thewp_global_stylessupports increate_initial_post_types()._wp_note_anchorcomment meta inwp_create_initial_comment_meta().Checklist:
@sincereferences.AI Use
Code and description both written with 🤖 Claude Code. I will review and test.