Comments: Generalize ping handling with an is_ping comment type flag (Trac #35214)#54
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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.
6c4b5b3 to
3a5a401
Compare
Summary
This is item 4 of the Trac #35214 "below the hood" follow-up work: generalizing the hard-coded
pingback/trackbackhandling so registered comment types can opt into ping behaviour.Previously, pingbacks and trackbacks were singled out by hard-coded
comment_typestring comparisons:separate_comments()bucketed'pingback'/'trackback'into the'pings'group viaif ( 'trackback' === $type || 'pingback' === $type ).Walker_Comment::start_el()rendered the compact ping markup viaif ( ( 'pingback' === ... || 'trackback' === ... ) && $args['short_ping'] ).Neither could be expressed by a registered comment type, so a plugin registering (say) a
webmentiontype could not be grouped or rendered as a ping.What changed
WP_Comment_Type::$is_ping(defaultfalse) - a new flag marking a type as a ping (a notification from another site) rather than a human-authored comment.pingbackandtrackbacktypes are registered with'is_ping' => true.separate_comments()now groups any registered ping type into thepingsbucket.Walker_Comment::start_el()now renders any registered ping type with the compact ping markup (reusing the comment type object it already looks up forrender_callback).Built-in behaviour is byte-for-byte unchanged:
pingback/trackbackstill group and render exactly as before, and the defaultcomment/notetypes 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_pingis 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
tests/phpunit/tests/comment/separateComments.phpcovers default buckets, built-in ping grouping, a registered ping type grouping intopings, and a non-ping type staying out.Walker_Commenttest renders a registered ping type with the compact ping markup.WP_Comment_Typeand built-in-type tests cover the new flag's default, storage, and built-in values.--group commentsuite passes (593 tests). PHPCS and PHPStan clean.Stacking
Based on
feature/comment-type-render-callback(fork PR #53) because it touches the sameWalker_Comment::start_el()method. Retarget totrunkonce the registration API (#12311) and the display-callback PR land.See #35214.