Editor: Add emoji reactions as a comment type for Notes#10930
Editor: Add emoji reactions as a comment type for Notes#10930adamsilverstein wants to merge 6 commits intoWordPress:trunkfrom
Conversation
|
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. |
| } | ||
| } | ||
| }, | ||
| "authentication": [], |
There was a problem hiding this comment.
Why did this changed? Stale from a previous commit?
There was a problem hiding this comment.
yes, I ran the test_build_wp_api_client_fixtures test locally to regenerate fixtures and this was the result. I wrote that test so I'm confident this is correct, but happy to add in a separate PR since its unrelated to the current changes. ideally we should have a check similar to package lock that checks if running the regeneration changes the fixture and reject the merge if so.
| "properties": [], | ||
| "properties": { | ||
| "wp_pattern_sync_status": { | ||
| "type": "string", | ||
| "title": "", | ||
| "description": "", | ||
| "default": "", | ||
| "enum": [ | ||
| "partial", | ||
| "unsynced" | ||
| ] | ||
| } | ||
| }, |
There was a problem hiding this comment.
I guess this fixture wasn't updated correctly for a previous commit that introduced this?
There was a problem hiding this comment.
correct. you can verify by running the test_build_wp_api_client_fixtures test locally to regenerate fixtures. the file should match what you see in this PR. (I used WP_TESTS_DIR=/Users/adamsilverstein/repositories/wordpress-develop/tests/phpunit/ DB_PASSWORD=**** php ./vendor/bin/phpunit --verbose -c ./phpunit.xml.dist --filter=test_build_wp_api_client_fixture)
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. |
Introduce the `reaction` comment type to support emoji reactions on collaborative Notes, replacing the previous `_wp_note_reactions` meta approach. Changes include: - Add `reaction` to avatar comment types. - Exclude reactions from admin comment lists and comment counts. - Extend the REST API Comments Controller to handle reactions: permissions checks, validation (valid emoji slugs, parent must be a note, one emoji per user per note), auto-approval, and content allowed checks. - Add PHPUnit tests for reaction creation, validation, and counting. - Regenerate API fixtures. Props flavor flavor. See #63191. Co-Authored-By: Claude Opus 4.6 <[email protected]>
e8246a7 to
fe19243
Compare
|
I have updated this backport PR to apply the custom comment type approach for storage used in WordPress/gutenberg#75549 which replaces the meta based approach in WordPress/gutenberg#75144. |
Picks up new 'footnotes' meta registered on post types, plus site_logo and site_icon settings exposed via the REST API. Needed so 'git diff --exit-code' in the PHPUnit CI step passes after merging trunk into the backport branch.
…nt_types(). Per review feedback on PR WordPress#10930, introduce wp_get_internal_comment_types() in src/wp-includes/comment.php as the single source of truth for non-comment comment types ('note', 'reaction'). The new helper is filterable so future internal types can be added without touching every call site. Apply it across the existing 'note'/'reaction' guards: * WP_Comments_List_Table: comment_type filter and type__not_in. * get_pending_comments_num(): exclude internal types from pending counts. * wp_update_comment_count_now(): exclude internal types from approved counts. * WP_REST_Comments_Controller: get_items / permissions / prepare / links / duplicate-flood checks across multiple sites. * is_avatar_comment_type(): default avatar comment types. Props westonruter for the suggestion to centralize this list.
…omment_types(). Mirrors the change being proposed for core in WordPress/wordpress-develop#10930. Introduces a single helper that returns the list of internal comment types ('note', 'reaction'), filterable so future additions only need to update one place. Apply it across all the existing 'note'/'reaction' guards in the 7.1 compat layer: * gutenberg_update_get_avatar_comment_type_7_1() — avatar-eligible types. * gutenberg_exclude_block_comments_from_admin_7_1() — admin query exclude. * gutenberg_filter_comment_count_query_exclude_block_comments_7_1() — pending-count SQL guard. * gutenberg_hide_note_from_comment_list_table_7_1() — list table args. * gutenberg_exclude_notes_from_comment_count_7_1() — approved-count SQL. * Gutenberg_REST_Comment_Controller_7_1::is_note_or_reaction() — REST controller's per-request type check (used by permissions, prepare, validation, and links). Props westonruter for the suggestion to centralize this list.
Co-authored-by: Weston Ruter <[email protected]>
Summary
Introduces the
reactioncomment type to support emoji reactions on collaborative Notes, replacing the previous_wp_note_reactionsmeta approach from Gutenberg PR #75148 (now closed in favor of #75549).Each reaction is stored as a separate comment with
comment_type = 'reaction'rather than as serialized meta data on the note.Changes
reactionto the allowed avatar comment typesWP_REST_Comments_Controllerto handlereactiontype:edit_comment/edit_postinstead ofmoderate_comments)heart,celebration,smile,eyes,rocket), one emoji per user per notewp-api-generated.jsTrac ticket
See https://core.trac.wordpress.org/ticket/63191
Test plan
heartreaction to the note — should succeed (201)rocket) to the same note — should succeedphpunit --filter=test_create_reaction— all passphpunit tests/phpunit/tests/comment/wpUpdateCommentCountNow.php— all pass🤖 Generated with Claude Code