WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 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:

Description

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 3 years ago.
Give specific array keys to post states array
15421.diff (1.1 KB) - added by kawauso 3 years ago.
No more $post_statespost_format?

Download all attachments as: .zip

Change History (7)

greenshady3 years ago

Give specific array keys to post states array

comment:1 voyagerfan57613 years ago

  • Cc WordPress@… added

comment:2 nacin3 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.

kawauso3 years ago

No more $post_statespost_format?

comment:3 kawauso3 years ago

  • Keywords needs-refresh removed

comment:4 nacin3 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.

comment:5 nacin3 years ago

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