Skip to content

Editor: Add emoji reactions as a comment type for Notes#10930

Open
adamsilverstein wants to merge 6 commits intoWordPress:trunkfrom
adamsilverstein:backport-note-reactions-meta-70
Open

Editor: Add emoji reactions as a comment type for Notes#10930
adamsilverstein wants to merge 6 commits intoWordPress:trunkfrom
adamsilverstein:backport-note-reactions-meta-70

Conversation

@adamsilverstein
Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein commented Feb 14, 2026

Summary

Introduces the reaction comment type to support emoji reactions on collaborative Notes, replacing the previous _wp_note_reactions meta 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

  • Avatar support: Add reaction to the allowed avatar comment types
  • Admin exclusions: Exclude reactions from the admin comment list table and comment type filter
  • Comment counts: Exclude reactions from approved and pending comment count queries
  • REST API: Extend WP_REST_Comments_Controller to handle reaction type:
    • Permissions checks treat reactions like notes (edit_comment/edit_post instead of moderate_comments)
    • Validation: parent must be a note, content must be a valid emoji slug (heart, celebration, smile, eyes, rocket), one emoji per user per note
    • Auto-approve reactions (skip spam/flood checks)
    • Read permission and link embedding match note behavior
  • Tests: PHPUnit tests for reaction creation, invalid parent, invalid emoji, duplicate detection, different reactions on same note, login requirement, and comment count exclusion
  • Fixtures: Regenerated wp-api-generated.js

Trac ticket

See https://core.trac.wordpress.org/ticket/63191

Test plan

  • Create a note on a post via the REST API
  • Add a heart reaction to the note — should succeed (201)
  • Attempt a reaction on a regular comment — should fail (400)
  • Attempt an invalid emoji slug — should fail (400)
  • Attempt a duplicate reaction (same emoji, same user, same note) — should fail (409)
  • Add a different emoji (rocket) to the same note — should succeed
  • Verify reactions don't appear in wp-admin Comments list
  • Verify reactions don't affect post comment counts
  • Run phpunit --filter=test_create_reaction — all pass
  • Run phpunit tests/phpunit/tests/comment/wpUpdateCommentCountNow.php — all pass

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 14, 2026

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 adamsilverstein, westonruter, noruzzaman.

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

Comment thread src/wp-includes/comment.php Outdated
}
}
},
"authentication": [],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this changed? Stale from a previous commit?

Copy link
Copy Markdown
Member Author

@adamsilverstein adamsilverstein Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +4882 to +4887
"properties": [],
"properties": {
"wp_pattern_sync_status": {
"type": "string",
"title": "",
"description": "",
"default": "",
"enum": [
"partial",
"unsynced"
]
}
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this fixture wasn't updated correctly for a previous commit that introduced this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
@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.

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]>
@adamsilverstein adamsilverstein force-pushed the backport-note-reactions-meta-70 branch from e8246a7 to fe19243 Compare February 18, 2026 14:40
@adamsilverstein adamsilverstein changed the title Editor: Register emoji reactions comment meta for Notes Editor: Add emoji reactions as a comment type for Notes Feb 18, 2026
@adamsilverstein
Copy link
Copy Markdown
Member Author

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.

Comment thread src/wp-admin/includes/class-wp-comments-list-table.php Outdated
Comment thread src/wp-admin/includes/class-wp-comments-list-table.php Outdated
Comment thread src/wp-admin/includes/comment.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/link-template.php Outdated
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.
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
Comment thread src/wp-includes/comment.php Outdated
adamsilverstein added a commit to WordPress/gutenberg that referenced this pull request Apr 29, 2026
…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.
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