Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#18516 closed enhancement (fixed)

Add custom class to WP_Posts_List_Table->single_row() output

Reported by: brandondove's profile brandondove Owned by: westi's profile 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 13 years ago.
18516.2.diff (1.9 KB) - added by brandondove 13 years ago.
New patch based on feedback from nacin
test-wp-posts-list-table-patch.php (1.5 KB) - added by brandondove 13 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)

@brandondove
13 years ago

#1 @brandondove
13 years ago

  • Keywords has-patch added

#2 @brandondove
13 years ago

  • Cc brandondove added

#3 @westi
13 years ago

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

#4 @jb510
13 years ago

  • Cc jbrown510@… added

#5 follow-up: @nacin
13 years ago

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

@brandondove
13 years ago

New patch based on feedback from nacin

@brandondove
13 years ago

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

#6 @brandondove
13 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.

#7 in reply to: ↑ 5 @westi
13 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 ;)

#8 @westi
13 years ago

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

#9 @nacin
13 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.

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

#11 @anointed
13 years ago

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