Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments: Generalize ping handling with an is_ping comment type flag (Trac #35214)#54

Open
adamsilverstein wants to merge 3 commits into
feature/comment-type-render-callbackfrom
feature/comment-type-ping-grouping
Open

Comments: Generalize ping handling with an is_ping comment type flag (Trac #35214)#54
adamsilverstein wants to merge 3 commits into
feature/comment-type-render-callbackfrom
feature/comment-type-ping-grouping

Conversation

@adamsilverstein

Copy link
Copy Markdown
Owner

Summary

This is item 4 of the Trac #35214 "below the hood" follow-up work: generalizing the hard-coded pingback/trackback handling so registered comment types can opt into ping behaviour.

Previously, pingbacks and trackbacks were singled out by hard-coded comment_type string comparisons:

  • separate_comments() bucketed 'pingback'/'trackback' into the 'pings' group via if ( 'trackback' === $type || 'pingback' === $type ).
  • Walker_Comment::start_el() rendered the compact ping markup via if ( ( 'pingback' === ... || 'trackback' === ... ) && $args['short_ping'] ).

Neither could be expressed by a registered comment type, so a plugin registering (say) a webmention type could not be grouped or rendered as a ping.

What changed

  • WP_Comment_Type::$is_ping (default false) - a new flag marking a type as a ping (a notification from another site) rather than a human-authored comment.
  • The built-in pingback and trackback types are registered with 'is_ping' => true.
  • separate_comments() now groups any registered ping type into the pings bucket.
  • Walker_Comment::start_el() now renders any registered ping type with the compact ping markup (reusing the comment type object it already looks up for render_callback).

Built-in behaviour is byte-for-byte unchanged: pingback/trackback still group and render exactly as before, and the default comment/note types are not pings.

Deliberately out of scope

  • WP_Comment_Query 'pings' meta-type expansion ('pings'['pingback','trackback']). That lives in the query layer, which is owned by PR #12310 (default_excluded_comment_types). is_ping is the natural future input to generalize it there.
  • check_comment() author/email validation skip for pings (a moderation-logic change with behaviour-regression risk). Left for a focused follow-up.

Testing

  • New tests/phpunit/tests/comment/separateComments.php covers default buckets, built-in ping grouping, a registered ping type grouping into pings, and a non-ping type staying out.
  • New Walker_Comment test renders a registered ping type with the compact ping markup.
  • WP_Comment_Type and built-in-type tests cover the new flag's default, storage, and built-in values.
  • Full --group comment suite passes (593 tests). PHPCS and PHPStan clean.

Stacking

Based on feature/comment-type-render-callback (fork PR #53) because it touches the same Walker_Comment::start_el() method. Retarget to trunk once the registration API (#12311) and the display-callback PR land.

See #35214.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8e8b0a24-4172-4d47-a39f-358451ccff44

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/comment-type-ping-grouping

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Pingbacks and trackbacks were singled out by hard-coded `comment_type`
string comparisons in `separate_comments()` and `Walker_Comment`, so the
"this is a ping, not a human comment" distinction could not be expressed
by a registered comment type.

Add an `is_ping` property to `WP_Comment_Type` (default false) and mark
the built-in `pingback` and `trackback` types with it. `separate_comments()`
now groups any registered ping type into the `pings` bucket, and
`Walker_Comment::start_el()` renders any ping type with the compact ping
markup. Built-in behaviour is unchanged.

See #35214.
Cover the new flag end to end: the `WP_Comment_Type` default and storage,
the built-in pingback/trackback types being marked as pings (and
comment/note not), `separate_comments()` grouping a registered ping type
into the `pings` bucket while leaving non-ping types out, and
`Walker_Comment` rendering a registered ping type with the compact ping
markup.

See #35214.
Add the complementary cases for the is_ping && short_ping guard: the
built-in pingback still renders as a compact ping (regression guard for
the move from hard-coded type strings to the is_ping flag), a ping type
renders its full markup when short_ping is off, and a non-ping type is
never rendered as a ping even with short_ping enabled.

See #35214.
@adamsilverstein adamsilverstein force-pushed the feature/comment-type-ping-grouping branch from 6c4b5b3 to 3a5a401 Compare June 25, 2026 06:33
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.

1 participant