Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#15421 closed enhancement (fixed)

Make display_post_states easier to filter

Reported by: greenshady Owned by:
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.1
Component: Administration Keywords: has-patch commit 3.2-early
Focuses: Cc:


In wp-admin/includes/template.php, there's a filter hook on the post states array. This is a list appended to the post title in the edit posts list. Right now, you can filter display_post_states, but it's tough to change a single item.

Suppose I wanted to change the "Post format" text and do something a little different such as add an icon. Currently, I could filter the display_post_states array and get the array key by searching for something like the below:

'<span>[</span>' . get_post_format_string( get_post_format( $post->ID ) ) . '<span>]</span>';

This doesn't seem like the best way to go about it. One would need to do an array_search() or something similar to handle that.

Since the hook is on an array, it makes sense to provide specific array keys that can be overwritten with a filter. So, in my filter, I could do something like this:

$states['post_format'] = '<img src="#" alt="" />';

I'll attach a patch that makes this possible.

Attachments (2)

display-post-states.diff (1.3 KB) - added by greenshady 11 years ago.
Give specific array keys to post states array
15421.diff (1.1 KB) - added by kawauso 11 years ago.
No more $post_statespost_format?

Download all attachments as: .zip

Change History (7)

11 years ago

Give specific array keys to post states array

#1 @voyagerfan5761
11 years ago

  • Cc WordPress@… added

#2 @nacin
11 years ago

  • Keywords needs-refresh commit 3.2-early added
  • Milestone changed from Awaiting Review to Future Release

I like. Patch needs refresh. FYI, the post_format will likely be becoming a column in 3.2.

11 years ago

No more $post_statespost_format?

#3 @kawauso
11 years ago

  • Keywords needs-refresh removed

#4 @nacin
11 years ago

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

(In [17544]) Send an associative array to the display_post_states filter. props greenshady, kawauso, fixes #15421.

#5 @nacin
11 years ago

  • Milestone changed from Future Release to 3.2
Note: See TracTickets for help on using tickets.