Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#18447 closed enhancement (fixed)

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

Reported by: josephscott's profile josephscott Owned by: westi's profile 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 13 years ago.
comment-table.2.diff (637 bytes) - added by josephscott 13 years ago.

Download all attachments as: .zip

Change History (12)

#1 @westi
13 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.

#2 @josephscott
13 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'>

#3 @josephscott
13 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.

#4 follow-ups: @nacin
13 years ago

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

#5 in reply to: ↑ 4 @josephscott
13 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).

#6 @westi
13 years ago

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

#7 in reply to: ↑ 4 @westi
13 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.

#8 @westi
13 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.

#9 @westi
13 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 :(

#10 @westi
13 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.