Expose allowed reaction emojis via REST API schema#75706
Expose allowed reaction emojis via REST API schema#75706adamsilverstein wants to merge 5 commits into
Conversation
The merge from add-notes-emoji-reactions left behind an add_action call for gutenberg_register_block_comment_reaction_metadata, which doesn't exist in this branch. This branch uses custom comment types instead of comment metadata for storing reactions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the PHP filter (note_reaction_emojis) and editor settings injection for customizing the reaction emoji set. The JS components now use the hardcoded REACTION_EMOJIS list directly again. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Makes the reaction comment type more generic and future-proof so emoji reactions can eventually be used elsewhere in WordPress, not just on notes. Aligns with the approach used by the React plugin (wordpress.org/plugins/react).
Add a filterable gutenberg_get_note_reaction_emojis() helper and expose the emoji list as a read-only reaction_emojis property in the comments REST API schema. The client-side useReactionEmojis() hook reads this from the OPTIONS response so the emoji picker and display render what the server actually allows. Validation in create_item() now uses the same filtered list, so custom emojis added via the gutenberg_note_reaction_emojis filter are accepted end-to-end. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
Size Change: +111 B (0%) Total Size: 2.99 MB
ℹ️ View Unchanged
|
|
Changes cherry-picked into #76767, which now includes both the custom comment type storage and the schema-based emoji extensibility. |
Summary
gutenberg_get_note_reaction_emojis()filterable helper that returns the default 5 reaction emojis and applies agutenberg_note_reaction_emojisfilterget_item_schema()in the 7.1 comment controller to expose a read-onlyreaction_emojisproperty with the filtered emoji list as itsdefault— available viaOPTIONS /wp/v2/commentscreate_item()validation to use the filterable helper instead of a hardcoded slug listuseReactionEmojis()React hook that fetches the emoji list from the REST API schema (with module-level caching and fallback to the hardcoded list)ReactionEmojiPickerandReactionDisplaycomponents to use the hook so the UI reflects server-defined emojisImplements the approach suggested by @Mamaduka to use the REST API schema as the source of truth for allowed reaction emojis.
Test plan
npm run test:unit:php -- --filter=WP_REST_Comments_Controller_Gutenberg_Testreaction_emojiswith default emoji listgutenberg_note_reaction_emojisfilter, verify it appears in picker and is accepted by validation🤖 Generated with Claude Code