WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#18516 closed enhancement (fixed)

Add custom class to WP_Posts_List_Table->single_row() output

Reported by: brandondove Owned by: westi
Milestone: 3.3 Priority: normal
Severity: normal Version: 3.3
Component: General Keywords: westi-likes has-patch
Focuses: Cc:

Description

I am working on a custom post type implemention with some common custom meta information that I want to display in the post list. There is a need to indicate each post's status with a quick visual queue. Since there is no way to target a group of table rows that have certain characteristics, I resorted to highlighting the rows using jQuery.

Looking at the WP_Posts_List_Table class, it seems that this would be an easy problem to solve by simply adding a filter to the table row class list. I'm sure this same concept could also be extended to the other subclasses of WP_List_Table.

Attachments (3)

18516.diff (1.1 KB) - added by brandondove 3 years ago.
18516.2.diff (1.9 KB) - added by brandondove 3 years ago.
New patch based on feedback from nacin
test-wp-posts-list-table-patch.php (1.5 KB) - added by brandondove 3 years ago.
A simple plugin that adds a custom class to the single row on the post edit screen

Download all attachments as: .zip

Change History (14)

brandondove3 years ago

comment:1 brandondove3 years ago

  • Keywords has-patch added

comment:2 brandondove3 years ago

  • Cc brandondove added

comment:3 westi3 years ago

  • Owner changed from brandondove to westi
  • Status changed from new to reviewing

comment:4 jb5103 years ago

  • Cc jbrown510@… added

comment:5 follow-up: nacin3 years ago

It'd probably make sense for us to use post_class() here.

brandondove3 years ago

New patch based on feedback from nacin

brandondove3 years ago

A simple plugin that adds a custom class to the single row on the post edit screen

comment:6 brandondove3 years ago

The new patch uses get_post_class for WP_Posts_List_Table as nacin suggested. Duplicated classes on the table row were removed and author-(self|other) was moved into get_post_class for consistency.

comment:7 in reply to: ↑ 5 westi3 years ago

Replying to nacin:

It'd probably make sense for us to use post_class() here.

I'm sure I wrote this comment when I accepted the ticket ;)

comment:8 westi3 years ago

  • Keywords westi-likes added
  • Milestone changed from Awaiting Review to 3.3

comment:9 nacin3 years ago

We should keep the code out of get_post_class(), and instead pass in that value to get_post_class(), which takes an additional classes argument.

comment:10 nacin3 years ago

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

In [18706]:

Use get_post_class() in the posts list table. props brandondove, fixes #18516.

comment:11 anointed3 years ago

  • Cc anointed added
Note: See TracTickets for help on using tickets.