WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#18447 closed enhancement (fixed)

Include the comment type when showing the comment table list in wp-admin

Reported by: josephscott Owned by: westi
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.2.1
Component: Administration Keywords: westi-likes has-patch
Focuses: Cc:

Description

For Javascript that would like to enhance the comment table list in wp-admin ( wp-admin/edit-comments.php ) it would be really handy to have the comment type included in the HTML. This would allow Javascript to apply the changes to specific comment types easily.

I'm including a patch that does this by adding an attribute to the TR : data-commenttype. TR entries would look like:

<tr id='comment-191' class='unapproved' data-commenttype='pingback'>
<tr id='comment-190' class='approved' data-commenttype='comment'>

and so on.

I choose data-commenttype as the name to avoid the confusing rewrite situation that happens with data-* attributes. The other style that would have been safe would be data-comment_type, but I think that would be even more confusing.

Attachments (2)

comment-table.diff (779 bytes) - added by josephscott 4 years ago.
comment-table.2.diff (637 bytes) - added by josephscott 4 years ago.

Download all attachments as: .zip

Change History (12)

@josephscott4 years ago

comment:1 @westi4 years ago

Why not just add this information as css classes so that is can also easily be used for custom styling of the rows etc?

We should probably just be using comment_class() here.

comment:2 @josephscott4 years ago

I'm not a huge fan of overloading CSS class names, but that is something that could be done. I've uploaded a diff with that ( comment-table.2.diff ) using comment_class() and you end up with TRs that look like:

<tr id='comment-191' class='pingback even thread-even depth-1 unapproved'>
<tr id='comment-190' class='comment byuser comment-author-admin bypostauthor odd alt thread-odd thread-alt depth-1 approved'>

comment:3 @josephscott4 years ago

Nacin asked about a version using just comment_class(), something I'd done originally when working on the second version of the patch. You can see it here - http://pastebin.com/LGes0Siq - I ended up going with get_comment_class() because it felt like a cleaner change.

comment:4 follow-ups: @nacin4 years ago

comment-table.2.diff looks good, but what are the chances of those classes conflicting with core or plugin admin CSS?

comment:5 in reply to: ↑ 4 @josephscott4 years ago

Replying to nacin:

comment-table.2.diff looks good, but what are the chances of those classes conflicting with core or plugin admin CSS?

I'm not sure, another reason why I went with the data-* attribute, it avoids styling collisions.

That said, so far I haven't seen any issues for core. Plugins would be the great unknown (as usual).

comment:6 @westi4 years ago

  • Keywords westi-likes added
  • Milestone changed from Awaiting Review to 3.3
  • Owner set to westi
  • Status changed from new to accepted

comment:7 in reply to: ↑ 4 @westi4 years ago

Replying to nacin:

comment-table.2.diff looks good, but what are the chances of those classes conflicting with core or plugin admin CSS?

I think it is better practise to re-use the same classes as we make available on the front end.

We should probably do this in other places where we have a object_class function available too.

comment:8 @westi4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In [18594]:

Include all comment css classes when outputing the rows in the Comments admin page to allow for easy customisation by plugins. Fixes #18447 props josephscott.

comment:9 @westi4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

In my "minor" change to joseph's patch I broke the comment action links because they rely on the status global :(

comment:10 @westi4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In [18599]:

Fix the action links broken by [18594]. Fixes #18447.

Note: See TracTickets for help on using tickets.