Make display_post_states easier to filter
|Reported by:||greenshady||Owned by:|
|Severity:||normal||Keywords:||has-patch commit 3.2-early|
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.
Change History (7)
- Keywords needs-refresh commit 3.2-early added
- Milestone changed from Awaiting Review to Future Release