[wp-trac] [WordPress Trac] #23833: Add a unique ID or NAME to target queries .
WordPress Trac
noreply at wordpress.org
Wed May 8 21:48:03 UTC 2013
#23833: Add a unique ID or NAME to target queries .
-------------------------+------------------------------
Reporter: krembo99 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Resolution:
Keywords: |
-------------------------+------------------------------
Comment (by MikeSchinkel):
Replying to [comment:9 prettyboymp]:
> I don't think wp_dropdown_categories() has a call to WP_Query in its
stack.
You are correct. Bad example on my part for `WP_Query`; I researched in
haste and was not paying enough attention to the specifics.
But still a good example for need of `'context'` argument. And there are
also good examples for need for `'context'` passed by WordPress core for
calls to `new WP_Query()` in:
- `wp_ajax_query_attachments()`
- `wp_link_query()`
- `wp_dashboard_quick_press()`
- `wp_dashboard_recent_drafts()`
- `WP_Widget_Recent_Posts->widget()`
- `wp_nav_menu_item_post_type_meta_box()`
- `wp_get_associated_nav_menu_items()`
- `get_popular_posts()`
- `delete_search_results_template()`
- `get_posts()`
- `wp_get_post_autosave()`
- `query_posts()`
- `url_to_postid()`
- `wp-settings.php`
Then of course there is the large number of places that `get_posts()` is
called as well, and several other functions that ultimately call `new
WP_Query()` and/or `WP_Query->get_posts()`.
''Not'' having an explicit context means that the plugin code has to
''"guess"'' at it's context using URL parameters, `$pagenow`, `$typenow`,
`$current_screen` and any number of other environmental clues that can
result in a false positive, the worst being `debug_backtrace()`. By
adding an explicit `'context'` for all calls to generic functions
throughout WordPress core plugin authors could precisely ''"scope"'' their
hooks to operate only when needed and not when they are ''"best guess"''
needed.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/23833#comment:10>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list