[wp-trac] [WordPress Trac] #15421: Make display_post_states easier to filter

WordPress Trac wp-trac at lists.automattic.com
Sun Nov 14 05:37:56 UTC 2010


#15421: Make display_post_states easier to filter
----------------------------+-----------------------------------------------
 Reporter:  greenshady      |       Owner:                 
     Type:  enhancement     |      Status:  new            
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Administration  |     Version:  3.1            
 Severity:  normal          |    Keywords:  has-patch      
----------------------------+-----------------------------------------------
 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.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15421>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list