[wp-trac] [WordPress Trac] #17019: context arg for WP_Query filter application

WordPress Trac wp-trac at lists.automattic.com
Thu Apr 7 06:35:10 UTC 2011

#17019: context arg for WP_Query filter application
 Reporter:  kevinB       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Query        |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |

Comment (by nacin):

 Replying to [comment:12 kevinB]:
 > I'm not sure what filter you're referring to here. The whole point of
 this ticket is to make more wp-admin queries filterable, and scribu said
 to do that by running through get_posts().  That's good, but it also means
 every function which my plugin adds to a query-related hook will now be
 called multiple times via call_user_func_array() even if it only pertains
 to a specific case (like attachment orphan count filtering).  To avoid
 incurring the performance hit I'll end up hooking a single wrapper filter
 to 'posts_where', then look at the context property to decide the actual
 filter to apply.  Is that the direction you want WP plugin best practices
 to go?

 Adding a context filter to all hooks is going to be way worse performance
 wise than adding a filter only exactly when you want it.

 There are two tickets here: One to move these raw queries to WP_Query. The
 other is to add a context argument. This ticket should serve but one

 There is some pretty good reasoning out there to add contexts to core
 queries, but the lack of focus of this ticket doesn't really drive that
 point home.

Ticket URL: <http://core.trac.wordpress.org/ticket/17019#comment:13>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software

More information about the wp-trac mailing list