Commit Graph

674 Commits

Author SHA1 Message Date
Boone Gorges
51ddf2ca9c Correct some WP_Query metadata lazyloading docs.
Props dlh.
Fixes #34047.
Built from https://develop.svn.wordpress.org/trunk@34732


git-svn-id: http://core.svn.wordpress.org/trunk@34696 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-01 04:01:48 +00:00
Boone Gorges
80654eb17a s/add_action()/add_filter() in WP_Query metadata lazyloading.
Props dlh.
See #34047.
Built from https://develop.svn.wordpress.org/trunk@34731


git-svn-id: http://core.svn.wordpress.org/trunk@34695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-01 04:01:24 +00:00
Boone Gorges
654eeb3785 Improve lazyloading of comment meta in WP_Query loops.
Lazy-loading logic is moved to a method on `WP_Query`. This makes it possible
for comment feeds to take advantage of metadata lazyloading, in addition to
comments loaded via `comments_template()`.

This new technique parallels the termmeta lazyloading technique introduced in
[34704].

Fixes #34047.
Built from https://develop.svn.wordpress.org/trunk@34711


git-svn-id: http://core.svn.wordpress.org/trunk@34675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-30 01:35:26 +00:00
Boone Gorges
db880777f4 Improve lazyloading of term metadata in WP_Query loops.
[34529] introduced lazyloading for the metadata belonging to terms matching
posts in the main `WP_Query`. The current changeset improves this technique
in the following ways:

* Term meta lazyloading is now performed on the results of all `WP_Query` queries, not just the main query.
* Fewer global variable touches and greater encapsulation.
* The logic for looping through posts to identify terms is now only performed once per `WP_Query`.

Props dlh, boonebgorges.
See #34047.
Built from https://develop.svn.wordpress.org/trunk@34704


git-svn-id: http://core.svn.wordpress.org/trunk@34668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-29 22:00:24 +00:00
Boone Gorges
c36d4fb8a9 WP_Query should not ignore an offset of 0.
Props mazurstas.
Fixes #34060.
Built from https://develop.svn.wordpress.org/trunk@34697


git-svn-id: http://core.svn.wordpress.org/trunk@34661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-29 19:37:23 +00:00
Gary Pendergast
cf173408cd Permalinks: Add pretty permalinks for unattached attachments.
Previously, unattached attachments would have unsightly `/?attachment_id=1` URLs. As we've moved away from attachments being specifically attached to posts, instead being Media items, this has made the unattached URLs a more common occurrence.

We can breath easy once more, knowing that the world is a little bit safer from the horror of unnecessarily ugly URLs.

Props SergeyBiryukov, wonderboymusic, pento.

Fixes #1914.


Built from https://develop.svn.wordpress.org/trunk@34690


git-svn-id: http://core.svn.wordpress.org/trunk@34654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-29 09:42:26 +00:00
Gary Pendergast
1db89dd3bf Rewrite: Redirect attachment URLs when their slug changes.
Using the same logic that we use to redirect posts when their slug changes, we can provide the same functionality for attachments. Attachment pages are posts, too.

Props swissspdy.

Fixes #34043.


Built from https://develop.svn.wordpress.org/trunk@34685


git-svn-id: http://core.svn.wordpress.org/trunk@34649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-29 04:58:25 +00:00
Gary Pendergast
635d3bb34e Rewrite: When redirecting old slugs, include URL endpoints.
Historically, `wp_old_slug_redirect()` has only ever redirected the old slug of posts, it hasn't included URL endpoints, or worked with comment feed URLs. By adding support for these, we ensure a greater range of URLs aren't killed when the slug changes.

Props swissspdy.

Fixes #33920.


Built from https://develop.svn.wordpress.org/trunk@34659


git-svn-id: http://core.svn.wordpress.org/trunk@34623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-28 06:57:26 +00:00
Drew Jaynes
b818747870 Docs: Add more explicit optional parameter types and return descriptions in the DocBlocks for is_page(), is_single(), is_singular().
Also adds explicit types and return descriptions to the corresponding `WP_Query` methods: `WP_Query::is_page()`, `WP_Query::is_single()`, and `WP_Query::is_singular()`.

Props Shelob9 for the initial patch.
Fixes #33907.

Built from https://develop.svn.wordpress.org/trunk@34502


git-svn-id: http://core.svn.wordpress.org/trunk@34466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 16:18:24 +00:00
Scott Taylor
e19e604a74 Docs: is_main_query()'s _doing_it_wrong() notice suggests using WP_Query statically (WP_Query::is_main_query()). Use an alternate syntax: WP_Query->is_main_query(), to not confuse.
Props DrewAPicture, micahwave.
Fixes #25680.

Built from https://develop.svn.wordpress.org/trunk@34366


git-svn-id: http://core.svn.wordpress.org/trunk@34330 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-21 15:31:26 +00:00
Scott Taylor
cb54b8d5a7 WP Query: Avoid using HTML tags in translation strings, add translator strings.
Props ramiy.	
Fixes #31868.

Built from https://develop.svn.wordpress.org/trunk@34345


git-svn-id: http://core.svn.wordpress.org/trunk@34309 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-20 03:04:24 +00:00
Drew Jaynes
f93dcf9226 Docs: Add descriptions for $wp_query global phpDoc references in wp-includes/query.php, partially documented in [32620].
Fixes #32139.

Built from https://develop.svn.wordpress.org/trunk@34337


git-svn-id: http://core.svn.wordpress.org/trunk@34301 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-20 00:05:26 +00:00
Drew Jaynes
d870f4c9f9 Docs: Fix some syntactical issues in the DocBlock for set_query_var().
Adds descriptions for the global `WP_Query` instance and the `$value` parameter.

See #32246.

Built from https://develop.svn.wordpress.org/trunk@34287


git-svn-id: http://core.svn.wordpress.org/trunk@34251 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-18 10:29:25 +00:00
Drew Jaynes
18adeb92fa Docs: Fix some syntactical issues in the documentation for get_queried_object_id().
Adds descriptions for the global `WP_Query` instance and the return.

See #32246.

Built from https://develop.svn.wordpress.org/trunk@34286


git-svn-id: http://core.svn.wordpress.org/trunk@34250 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-18 10:27:24 +00:00
Drew Jaynes
7a73dfbfb6 Docs: Fix some syntactical isses in the DocBlock for get_queried_object().
Also add descriptions for the return and the `WP_Query` global.

See #32246.

Built from https://develop.svn.wordpress.org/trunk@34285


git-svn-id: http://core.svn.wordpress.org/trunk@34249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-18 10:21:26 +00:00
Drew Jaynes
05f4e52541 Docs: Add documentation to get_query_var() and WP_Query::get() for the optional $default argument, introduced in 3.9 in [27304].
Props swissspidy.
Fixes #33856.

Built from https://develop.svn.wordpress.org/trunk@34284


git-svn-id: http://core.svn.wordpress.org/trunk@34248 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-18 09:41:27 +00:00
Scott Taylor
af593128a7 Revert [33925], by-reference array manipulation is breaking comments in some themes.
This implementation is losing its shine.

See #16894.

Built from https://develop.svn.wordpress.org/trunk@34245


git-svn-id: http://core.svn.wordpress.org/trunk@34209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-16 18:14:25 +00:00
Boone Gorges
c0a0d4ba50 Use stricter sanitization for meta query clause keys.
By forcing all clause keys to be strings, we make it possible to use strict
comparison when validating values of 'orderby' as passed to `WP_Query`. This
eliminates situations where the presence of numeric clause keys could result
in an improperly validated 'orderby' value.

Props nikolov.tmw.
Fixes #32937.
Built from https://develop.svn.wordpress.org/trunk@34090


git-svn-id: http://core.svn.wordpress.org/trunk@34058 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-12 21:06:24 +00:00
Boone Gorges
fc884dc7ec Allow setup_postdata() to accept a post ID.
Previously, it accepted only a full post object.

Props sc0ttclark, mordauk, wonderboymusic.
Fixes #30970.
Built from https://develop.svn.wordpress.org/trunk@34089


git-svn-id: http://core.svn.wordpress.org/trunk@34057 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-12 20:58:23 +00:00
Boone Gorges
1a203b5328 Better default values in WP_Query::get_queried_object().
Setting the default value of the `queried_object_id` property to `0` meant
that, when called early enough in the WP bootstrap, `get_queried_object()`
could short-circuit the normal query by fooling it into thinking that the
request was for a page with id 0. Setting the default value to `null` instead
avoids this problem.

Props gradyetc, jazbek.
Fixes #31355.
Built from https://develop.svn.wordpress.org/trunk@34073


git-svn-id: http://core.svn.wordpress.org/trunk@34041 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-12 03:37:23 +00:00
Scott Taylor
d973339738 After [33891], get_comment() returns global $comment if no args are passed and the global is set (after setting the default to null here). This allows us to ditch global comment imports.
See #33638.

Built from https://develop.svn.wordpress.org/trunk@33963


git-svn-id: http://core.svn.wordpress.org/trunk@33932 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-09 02:51:24 +00:00
Scott Taylor
c231add9fe In wp_list_comments(), update the comment meta cache when the comments derive from WP_Query and the new ->comment_meta_cached prop is false.
There are no uses of `wp_list_comments()` in Core where `$comments` are passed as the 2nd argument.

Adds unit tests.

Props wonderboymusic, bradt.
Fixes #16894.

Built from https://develop.svn.wordpress.org/trunk@33925


git-svn-id: http://core.svn.wordpress.org/trunk@33894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-05 22:25:24 +00:00
Scott Taylor
e73ee5ac98 Introduce WP_Comment class to model/strongly-type rows from the comments database table. Inclusion of this class is a pre-req for some more general comment cleanup and sanity.
* Takes inspiration from `WP_Post` and adds sanity to comment caching. 
* Clarifies when the current global value for `$comment` is returned. The current implementation in `get_comment()` introduces side effects and an occasion stale global value for `$comment` when comment caches are cleaned.
* Strongly-types `@param` docs
* This class is marked `final` for now

Props wonderboymusic, nacin.

See #32619.

Built from https://develop.svn.wordpress.org/trunk@33891


git-svn-id: http://core.svn.wordpress.org/trunk@33860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-03 18:17:24 +00:00
Scott Taylor
ef87172270 foreach is a statement, not a function.
See #33491.

Built from https://develop.svn.wordpress.org/trunk@33734


git-svn-id: http://core.svn.wordpress.org/trunk@33702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-25 20:28:22 +00:00
Boone Gorges
8a95b13cab In WP_Query::parse_tax_query(), allow 'cat' and 'tag' querystrings to be formatted as arrays.
See [33095] #32454 for a previous fix related to custom taxonomies.

Props Veraxus.
Fixes #33532.
Built from https://develop.svn.wordpress.org/trunk@33724


git-svn-id: http://core.svn.wordpress.org/trunk@33691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-24 21:22:26 +00:00
Scott Taylor
d345a6012c WP_Query: add changelog for the title param after [33706]
Props dimadin.
Fixes #33074.

Built from https://develop.svn.wordpress.org/trunk@33722


git-svn-id: http://core.svn.wordpress.org/trunk@33689 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-24 20:10:26 +00:00
Scott Taylor
523b51a359 Query:
Add a query var, `title`, that allows you to query posts by `post_title`. To accomplish this now, you have to do something like:

{{{
$tacos = get_posts( [
  'post_type' => 'taco',
  's' => $name,
  'exact' => true,
  'sentence' => true,
  'post_status' => 'publish',
  'fields' => 'ids',
  'posts_per_page' => 1
] );
}}}

Adds unit tests.

Fixes #33074.

Built from https://develop.svn.wordpress.org/trunk@33706


git-svn-id: http://core.svn.wordpress.org/trunk@33673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-22 16:59:26 +00:00
Dominik Schilling
6d45b63562 WordPress 4.3 has just passed 2,222,222 downloads.
(Fix typo in [33653].)
Built from https://develop.svn.wordpress.org/trunk@33661


git-svn-id: http://core.svn.wordpress.org/trunk@33628 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 16:00:28 +00:00
Boone Gorges
7c0d3ab83a Introduce post_name__in parameter for WP_Query.
Props enshrined.
Fixes #33065.
Built from https://develop.svn.wordpress.org/trunk@33653


git-svn-id: http://core.svn.wordpress.org/trunk@33620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 02:19:25 +00:00
Boone Gorges
2096b451c7 In WP_Query::parse_tax_query(), allow taxonomy querystring to be formatted as an array.
Props Veraxus.
Fixes #32454.
Built from https://develop.svn.wordpress.org/trunk@33095


git-svn-id: http://core.svn.wordpress.org/trunk@33066 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-06 20:37:24 +00:00
Scott Taylor
1ef11d7789 Add missing doc blocks to query.php.
Clarify `@return` values where necessary.
Some wrapper functions don't need to return if the function they wrap doesn't return.

See #32444.

Built from https://develop.svn.wordpress.org/trunk@32620


git-svn-id: http://core.svn.wordpress.org/trunk@32590 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-27 18:15:25 +00:00
Dominik Schilling
64fc7294b6 Use HTTPS URLs for codex.wordpress.org.
see #27115.
Built from https://develop.svn.wordpress.org/trunk@32116


git-svn-id: http://core.svn.wordpress.org/trunk@32095 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-12 21:29:32 +00:00
Scott Taylor
bce851dcf2 Replace array_shift() with reset() where appropriate for performance.
Props SergeyBiryukov.
Fixes #31259.

Built from https://develop.svn.wordpress.org/trunk@31829


git-svn-id: http://core.svn.wordpress.org/trunk@31811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-19 03:56:27 +00:00
Boone Gorges
7dcb041d5a More careful type conversion in WP_Query is_*() methods.
`is_array( 1, '1-foo' )` returns true, which means that `is_page( 1 )`
was returning true when on a page with the slug '1-foo'. We avoid this odd
behavior by casting the queried object ID to a string before testing against
the value passed to the conditional function.

This also helps to avoid a problem where an arbitrary value for `$page` would
cause `is_page( $page )` to return true if the query had been manipulated by
a plugin to show that the current page's ID is 0.

Props boonebgorges, r-a-y, nunomorgadinho, wonderboymusic, clifgriffin.
Fixes #24674.
Built from https://develop.svn.wordpress.org/trunk@31458


git-svn-id: http://core.svn.wordpress.org/trunk@31439 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-14 02:09:25 +00:00
Boone Gorges
90639872e8 In WP_Query::get_queried_object(), avoid PHP notices when is_tax is paired with an empty tax_query.
It's possible to have an empty `tax_query` and `is_tax=true` when the initial
query contains a taxonomy var (and is processed as such during
`WP_Query::parse_query()`) but the taxonomy var is unset during a 'parse_query'
callback. While this kind of behavior is not necessarily something we need to
support, we should continue to avoid PHP notices in such cases, as we did prior
to WP 4.1.

Fixes #31246.
Built from https://develop.svn.wordpress.org/trunk@31366


git-svn-id: http://core.svn.wordpress.org/trunk@31347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-07 19:50:24 +00:00
Boone Gorges
7bde88d02e Modify `meta_query orderby syntax to use array keys as clause "handles".
The implementation of `meta_query` orderby introduced in [31312] put clause
identifiers into a 'name' parameter of the clause. For greater clarity, this
changeset updates the syntax to use the associative array key used when
defining `meta_query` parameters, instead of the 'name' parameter.

Props Funkatronic, DrewAPicture.
Fixes #31045.
Built from https://develop.svn.wordpress.org/trunk@31340


git-svn-id: http://core.svn.wordpress.org/trunk@31321 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-05 19:38:23 +00:00
Sergey Biryukov
7c97e59ed6 When using WP_Query's 'fields' => 'ids' (or 'fields' => 'id=>parent'), make sure the returned result is always an array of integers.
fixes #31194. see #27252.
Built from https://develop.svn.wordpress.org/trunk@31324


git-svn-id: http://core.svn.wordpress.org/trunk@31305 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-03 02:29:25 +00:00
Boone Gorges
55dafd966b When querying for a specific post, allow posts with a non-public status to be returned as long as that status is specified.
This makes it possible to, for example, retrieve a specific post using the
`p` parameter of `WP_Query`, even if the post is in the Trash, by including
the `post_status=trash` parameter.

Props ebinnion.
Fixes #29167.
Built from https://develop.svn.wordpress.org/trunk@31321


git-svn-id: http://core.svn.wordpress.org/trunk@31302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-01 20:26:25 +00:00
Boone Gorges
ca30c725a0 Improve support for ordering WP_Query results by postmeta.
`WP_Meta_Query` clauses now support a 'name' parameter. When building a
`WP_Query` object, the value of 'orderby' can reference this 'name', so that
it's possible to order by any clause in a meta_query, not just the first one
(as when using 'orderby=meta_value'). This improvement also makes it possible
to order by multiple meta query clauses (or by any other eligible field plus
a meta query clause), using the array syntax for 'orderby' introduced in [29027].

Props Funkatronic, boonebgorges.
Fixes #31045.
Built from https://develop.svn.wordpress.org/trunk@31312


git-svn-id: http://core.svn.wordpress.org/trunk@31293 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-31 15:48:24 +00:00
Scott Taylor
eeda68bbda Fix some erroneous @param annotations.
See #30799.

Built from https://develop.svn.wordpress.org/trunk@31219


git-svn-id: http://core.svn.wordpress.org/trunk@31200 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 22:44:25 +00:00
Scott Taylor
bc55996a0b @param cleanup:
* `get_metadata()` will return literally anything, needs to be `mixed`
* `wp()` and `WP_Query::__construct()` no longer just take a query string
* Clarify a few others

See #30799.

Built from https://develop.svn.wordpress.org/trunk@31212


git-svn-id: http://core.svn.wordpress.org/trunk@31193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 19:03:23 +00:00
Scott Taylor
eed3698c49 In WP_Query, only call magic method internals again whitelists of properties and methods, $compat_fields and $compat_methods. Remove __unset() since __set() is not implemented.
See #30891.

Built from https://develop.svn.wordpress.org/trunk@31151


git-svn-id: http://core.svn.wordpress.org/trunk@31132 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-11 22:41:24 +00:00
Scott Taylor
0a511680f4 Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value. Constructors do not have meaningful return values, anything that is returned from here is discarded.
See #30799.

Built from https://develop.svn.wordpress.org/trunk@31126


git-svn-id: http://core.svn.wordpress.org/trunk@31107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-10 06:54:23 +00:00
Scott Taylor
60b0cd7943 The keyword elseif should be used instead of else if so that all control keywords look like single words.
This was a mess, is now standardized across the codebase, except for a few 3rd-party libs. 

See #30799.

Built from https://develop.svn.wordpress.org/trunk@31090


git-svn-id: http://core.svn.wordpress.org/trunk@31071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-08 07:05:25 +00:00
Scott Taylor
80915aaf16 WP_Query->parse_tax_query() - for BC, this method is not marked as protected. See [28987]. It needs an access modifier, it shall have public. The comment remains.
See #30799.

Built from https://develop.svn.wordpress.org/trunk@31081


git-svn-id: http://core.svn.wordpress.org/trunk@31062 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-08 05:54:44 +00:00
Scott Taylor
786caa4d55 Correct the @param docs for arguments that are truthy/falsey.
See #30799.

Built from https://develop.svn.wordpress.org/trunk@30983


git-svn-id: http://core.svn.wordpress.org/trunk@30969 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-20 23:04:23 +00:00
Boone Gorges
7e69e5484f In WP_Query::get_queried_object(), use the new format for referencing tax query clauses.
`queried_terms`, rather than `queries`, is the tax_query property where a flat
index of terms is stored.

See [29901] for a similar fix in `redirect_canonical()`. See #29738.

Props dd32.
Fixes #30623.
Built from https://develop.svn.wordpress.org/trunk@30771


git-svn-id: http://core.svn.wordpress.org/trunk@30761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-07 14:58:22 +00:00
Scott Taylor
37a23b2c73 Improve various @param docs.
See #30224.

Built from https://develop.svn.wordpress.org/trunk@30682


git-svn-id: http://core.svn.wordpress.org/trunk@30672 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-01 02:17:21 +00:00
Scott Taylor
ba914c7df1 Improve various @param docs.
See #30224.

Built from https://develop.svn.wordpress.org/trunk@30673


git-svn-id: http://core.svn.wordpress.org/trunk@30663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 22:56:25 +00:00
Drew Jaynes
fdb0b54389 4.1 Docs Audit: Improve inline documentation for the new WP_Query::setup_postdata() method.
See #30469.

Built from https://develop.svn.wordpress.org/trunk@30620


git-svn-id: http://core.svn.wordpress.org/trunk@30610 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-28 12:18:22 +00:00
Boone Gorges
912cdc5978 Pass query object to 'the_post' filter.
Props tlovett1.
Fixes #30327.
Built from https://develop.svn.wordpress.org/trunk@30323


git-svn-id: http://core.svn.wordpress.org/trunk@30322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-13 02:25:22 +00:00
Drew Jaynes
66c47f29bb Correct references of @uses $wpdb in core documentation to use @global.
See #30191, [30105].
Fixes #30217.

Built from https://develop.svn.wordpress.org/trunk@30122


git-svn-id: http://core.svn.wordpress.org/trunk@30122 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-31 17:56:22 +00:00
Drew Jaynes
f8657d5890 Remove redundant and erroneous @uses tag from most core inline documentation.
Per our inline documentation standards, no further use of the `@uses` tag is recommended as used and used-by relationships can be derived through other means. This removes most uses of the tag in core documentation, with remaining tags to be converted to `@global` or `@see` as they apply.

Fixes #30191.

Built from https://develop.svn.wordpress.org/trunk@30105


git-svn-id: http://core.svn.wordpress.org/trunk@30105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-30 01:05:24 +00:00
Boone Gorges
d7a62c01c4 Improve global variable setting in setup_postdata().
`setup_postdata()` is responsible for setting a number of global variables
that are used for post pagination (`$pages`, `$page`, `$nextpage`) and the
generation of post excerpts (`$more`). These variables should be sensitive to
the currently running instance of `WP_Query` - rather than the main query -
so that these features work properly inside of secondary `WP_Query` loops.

This changeset moves the logic of `setup_postdata()` into a method on `WP_Query`,
and converts `setup_postdata()` to a wrapper.

Props boonebgorges, wonderboymusic.
See #25349.
Fixes #9256, #20904.
Built from https://develop.svn.wordpress.org/trunk@30085


git-svn-id: http://core.svn.wordpress.org/trunk@30085 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-29 02:32:24 +00:00
Boone Gorges
1470990892 Check that search value is scalar before parsing.
Prevents PHP notices when non-scalar values are passed.

Includes unit tests.

Props tivnet.
Fixes #29736.
Built from https://develop.svn.wordpress.org/trunk@29912


git-svn-id: http://core.svn.wordpress.org/trunk@29666 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-16 03:32:20 +00:00
Boone Gorges
0143196338 Introduce support for nested queries in WP_Tax_Query.
Previously, tax query arguments could be joined by a single AND or OR relation.
Now, these queries can be arbitrarily nested, allowing clauses to be linked
together with multiple relations.

In a few places, WP_Query runs through a list of clauses in a tax_query in order
to set certain query vars for backward compatibility. The necessary changes have
been made to WP_Query to support this feature with the new complex structure of
tax_query. Unit tests are included for these backward compatibility fixes.

Unit tests for the new nesting syntax are included.

Props boonebgorges.
Fixes #29718. See #29738.
Built from https://develop.svn.wordpress.org/trunk@29891


git-svn-id: http://core.svn.wordpress.org/trunk@29647 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 04:03:19 +00:00
Konstantin Kovshenin
5f17e0952d Use the primary meta_query clause when parsing orderby in WP_Query.
When using legacy `meta_key`, `meta_value`, etc. arguments in `WP_Query`,
they're converted into the first clause of a `meta_query`. By using that
clause instead of the original arguments, we make sure that behavior is
consistent between the two available formats.

props boonebgorges.
fixes #16814.

Built from https://develop.svn.wordpress.org/trunk@29855


git-svn-id: http://core.svn.wordpress.org/trunk@29618 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-08 15:12:20 +00:00
Scott Taylor
ee9d74dc05 Ordering by RAND():
The shortcode callbacks for `gallery` and `playlist` check for `'RAND' == $atts['order']`, which isn't a valid value for `order`. Remove those checks and update the docs.

In `WP_Query`, if the value of `orderby` is `rand`, `order` is irrelevant and should be unset.

Adds unit tests.

Fixes #29629.

Built from https://develop.svn.wordpress.org/trunk@29760


git-svn-id: http://core.svn.wordpress.org/trunk@29532 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-23 03:52:15 +00:00
Andrew Nacin
9718e8413a Query: Add comment to the parse_tax_query() method reflecting [28987].
see #28739.

Built from https://develop.svn.wordpress.org/trunk@29658


git-svn-id: http://core.svn.wordpress.org/trunk@29432 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-01 19:51:16 +00:00
Drew Jaynes
09c3fd98d0 Fix a couple of misplaced/misordered argument descriptions in the WP_Query arguments hash notation.
See #25367.

Built from https://develop.svn.wordpress.org/trunk@29578


git-svn-id: http://core.svn.wordpress.org/trunk@29352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-23 19:36:17 +00:00
Sergey Biryukov
358209baa7 Correct 'no_found_rows' parameter description.
see #25367.
Built from https://develop.svn.wordpress.org/trunk@29538


git-svn-id: http://core.svn.wordpress.org/trunk@29314 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-19 07:28:15 +00:00
Drew Jaynes
a8583d5f19 Fix some words that aren't words.
See #28885.

Built from https://develop.svn.wordpress.org/trunk@29454


git-svn-id: http://core.svn.wordpress.org/trunk@29232 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-09 19:30:17 +00:00
Sergey Biryukov
b3f6108438 Remove a redundant condition for comment feeds from WP_Query::get_posts().
props engelen.
fixes #28401.
Built from https://develop.svn.wordpress.org/trunk@29257


git-svn-id: http://core.svn.wordpress.org/trunk@29040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-21 15:38:14 +00:00
Drew Jaynes
66119947ee Fill out inline documentation for magic methods added to the WP_Query class in [28523].
See #27881, #22234 and #28885.

Built from https://develop.svn.wordpress.org/trunk@29141


git-svn-id: http://core.svn.wordpress.org/trunk@28925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-13 23:36:14 +00:00
John Blackbourn
5a43586db1 Add support for a full path parameter to is_page() and is_single(). Props Jesper800, engelen, johnbillion. Fixes #16802.
Built from https://develop.svn.wordpress.org/trunk@29039


git-svn-id: http://core.svn.wordpress.org/trunk@28827 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-09 16:04:16 +00:00
Scott Taylor
dc7c246da3 Allow an array() to be passed as the value for orderby to WP_Query. Allows for an independent order value for each key.
Example: `'orderby' => array( 'title' => 'DESC', 'menu_order' => 'ASC' )`.

Adds docs and unit tests.

Props wonderboymusic, johnbillion, DrewAPicture, dd32, andy.
See #17065.

Built from https://develop.svn.wordpress.org/trunk@29027


git-svn-id: http://core.svn.wordpress.org/trunk@28815 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-08 17:16:15 +00:00
Scott Taylor
9d123aa326 WP_Query::parse_tax_query() has always been documented as protected. Plugins should never have used it. However, it did not have a protected access modifier, so its visibility was public by default. If the access modifier had been present, accessing the method in a plugin would have produced a fatal error. The access modifier was added in [28523], along with magic methods to allow it to be accessed for BC. This one method is problematic because it expects to be passed a reference. The WP_Query::__call() logic does not go out of its way to fix this signature discrepancy, and so a warning is thrown: Parameter 1 to WP_Query::parse_tax_query() expected to be a reference, value given.
Remove the `protected` access modifier from `WP_Query::parse_tax_query()`.

Fixes #28739.

Built from https://develop.svn.wordpress.org/trunk@28987


git-svn-id: http://core.svn.wordpress.org/trunk@28776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-04 01:29:14 +00:00
Drew Jaynes
ff109ddc5a First-run documention of WP_Query argument defaults.
Props siobhan for some language tweaks. Props DrewAPicture.
See #25367.

Built from https://develop.svn.wordpress.org/trunk@28887


git-svn-id: http://core.svn.wordpress.org/trunk@28686 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-28 23:03:17 +00:00
Sergey Biryukov
aebf8f0fea Make sure the first number in LIMIT clause in WP_Query::get_posts() is always an integer.
fixes #23383.
Built from https://develop.svn.wordpress.org/trunk@28864


git-svn-id: http://core.svn.wordpress.org/trunk@28664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-27 00:04:16 +00:00
Sergey Biryukov
ab06b01eb8 Don't kill an empty search query.
see #11330.
Built from https://develop.svn.wordpress.org/trunk@28804


git-svn-id: http://core.svn.wordpress.org/trunk@28613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-23 13:34:15 +00:00
Sergey Biryukov
d2fc1773ae Prevent multiple hierarchical posts with the same slug from being displayed in single post template.
fixes #28611.
Built from https://develop.svn.wordpress.org/trunk@28803


git-svn-id: http://core.svn.wordpress.org/trunk@28612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-23 13:15:16 +00:00
Scott Taylor
22e5b6932a Revert [28613] and [28664]. A good idea, but too much BC baggage.
See #28099.


Built from https://develop.svn.wordpress.org/trunk@28783


git-svn-id: http://core.svn.wordpress.org/trunk@28596 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-20 16:21:17 +00:00
Scott Taylor
c1e7c2d1de Don't use variable variables in WP_Query::get_posts().
See #27881.

Built from https://develop.svn.wordpress.org/trunk@28737


git-svn-id: http://core.svn.wordpress.org/trunk@28551 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-11 17:50:16 +00:00
Scott Taylor
05eeb16e30 Replace all uses of like_escape() with $wpdb->esc_like().
Props miqrogroove.
See #10041.

Built from https://develop.svn.wordpress.org/trunk@28712


git-svn-id: http://core.svn.wordpress.org/trunk@28528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-10 00:44:15 +00:00
Sergey Biryukov
f598eaa89b Move is_admin check to a more appropriate place.
see #11330.
Built from https://develop.svn.wordpress.org/trunk@28668


git-svn-id: http://core.svn.wordpress.org/trunk@28486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-04 23:47:15 +00:00
Sergey Biryukov
b33c95079b Avoid a PHP notice when using WP_Query::get_queried_object() in pre_get_posts action.
props wpsmith.
fixes #28412.
Built from https://develop.svn.wordpress.org/trunk@28667


git-svn-id: http://core.svn.wordpress.org/trunk@28485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-04 23:43:15 +00:00
Scott Taylor
1aaa80f48e Prevent admin breakage for s in WP_Query after [28623].
See #11330.


Built from https://develop.svn.wordpress.org/trunk@28666


git-svn-id: http://core.svn.wordpress.org/trunk@28484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-04 20:03:15 +00:00
Scott Taylor
23a53beb7e After [28613], also kill queries that explicityly pass empty arrays to category__in, tag__in, tag_slug__in, and author__in to WP_Query.
Adds unit tests.
Fixes #28099.

Built from https://develop.svn.wordpress.org/trunk@28664


git-svn-id: http://core.svn.wordpress.org/trunk@28482 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-04 17:50:15 +00:00
Scott Taylor
ae3d1fccfb Simplify the logic for determining isset( $this->query['s'] ) after [28612], and don't limit this logic to just the main query.
Props SergeyBiryukov.
Fixes #11330.

Built from https://develop.svn.wordpress.org/trunk@28623


git-svn-id: http://core.svn.wordpress.org/trunk@28444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 20:50:15 +00:00
Scott Taylor
d0bdcc3e7a If post_status is passed to WP_Query as an array containing 'any' and anything else, don't exclude the other values if they match when running any's exclusion logic.
Adds unit tests.

Fixes #28007.

Built from https://develop.svn.wordpress.org/trunk@28622


git-svn-id: http://core.svn.wordpress.org/trunk@28443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 20:42:18 +00:00
Scott Taylor
c367eb71e5 If post__in or post_parent__in is passed to WP_Query as an empty array, nuke the query. Both vars are currently only checked for truthiness after which they are ignored. Setting these vars at all indicates explicit filtering being desired.
Adds unit test.

Fixes #28099.

Built from https://develop.svn.wordpress.org/trunk@28613


git-svn-id: http://core.svn.wordpress.org/trunk@28437 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 06:04:15 +00:00
Scott Taylor
dfb75f0833 When parsing the main query, if s is set to empty: ?s= and $this->is_main_query() && array_key_exists( 's', $this->query ) - kill the query instead of loading the homepage. This will load the search page with no results.
Fixes #11330.


Built from https://develop.svn.wordpress.org/trunk@28612


git-svn-id: http://core.svn.wordpress.org/trunk@28436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 05:48:14 +00:00
Scott Taylor
fa38396998 Allow users to sort posts by type in WP_Query.
Props DeBAAT.
Fixes #28214.

Built from https://develop.svn.wordpress.org/trunk@28605


git-svn-id: http://core.svn.wordpress.org/trunk@28429 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 00:24:14 +00:00
Scott Taylor
333083debe Apply order to each passed value for orderby in WP_Query:
* Since `orderby` in `WP_Query` can accept space-delimited sets, yet only one `order` value: when multiple values are passed (and `DESC` is the order), the default sort order `ASC` is being applied to all values before the last in the set.
* There is a unit test that sporadically fails since 3.6 in `tests/post/revision` due to multiple posts having the same `post_date` from being added so rapidly
* When ordering revisions in `wp_get_post_revisions()`, order by `post_date ID`
* Change the `order` value in `wp_get_post_revisions()` to `ASC`. This will produce SQL like: `ORDER BY $wpdb->posts.post_date ASC, $wpdb->posts.ID ASC`. Previously, this would have produced SQL like: `ORDER BY $wpdb->posts.post_date DESC`, and with the addition of ` ID`: `ORDER BY $wpdb->posts.post_date ASC, $wpdb->posts.ID DESC`. Clearly, wrong. The original SQL produced: `ORDER BY $wpdb->posts.post_date DESC`. As such, return the reversions in reverse order using `array_reverse()`. Not doing so would break "Preview Changes."
* Add unit tests to assert that all of this works.
* All existing unit tests pass with the change to ordering multiple `orderby`s in `WP_Query`.
* In the future, we should support independent `order` for each `orderby`, see #17065.

Props SergeyBiryukov, wonderboymusic.
Fixes #26042.

Built from https://develop.svn.wordpress.org/trunk@28541


git-svn-id: http://core.svn.wordpress.org/trunk@28367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-22 18:19:13 +00:00
Scott Taylor
affe27e5d1 WP_Query was only missing one access modifier.
Add access modifier (`public`) to applicable class methods/members of `WP_Rewrite`. I am not brave enough to set some of the `var`s to `private` without more testing.

See #27881, #22234.

Built from https://develop.svn.wordpress.org/trunk@28533


git-svn-id: http://core.svn.wordpress.org/trunk@28359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 17:41:13 +00:00
Scott Taylor
949cfd7a34 Add missing access modifiers to methods in WP_Query. Add magic methods for __get(), __set(), __isset(), __unset(), and __call().
Add unit test for magic methods.

See #27881, #22234.

Built from https://develop.svn.wordpress.org/trunk@28523


git-svn-id: http://core.svn.wordpress.org/trunk@28349 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 06:49:16 +00:00
Scott Taylor
5bc59586da In WP_Query, remove duplicate variable setting:
* In `->parse_search_order()`, a value is always set for `$search_orderby`, no need for empty initialization
* In `->get_posts()`, `$fields` is always set, no need for empty initialization

See #27882.

Built from https://develop.svn.wordpress.org/trunk@28333


git-svn-id: http://core.svn.wordpress.org/trunk@28161 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-06 21:43:20 +00:00
Andrew Nacin
88e3ebe05b Revert the conversion of adjacent post queries to WP_Query. Explanation on the ticket.
Reverts [27285], [27286], [27287], [27288], [27291], [27292], [27293], [27296], [27633], [27634], [27635], and [27692].

see #26937.

Built from https://develop.svn.wordpress.org/trunk@27836


git-svn-id: http://core.svn.wordpress.org/trunk@27670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-29 06:03:15 +00:00
Scott Taylor
a6b9d323c6 When using WP_Query's "fields" => "ids" (or "fields" => "id=>parent"), the returned values should be an array of integers, not array of integers represented by strings.
Adds unit tests. All other unit tests pass.

Props danielbachhuber.
Fixes #27252.


Built from https://develop.svn.wordpress.org/trunk@27686


git-svn-id: http://core.svn.wordpress.org/trunk@27525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-24 18:55:16 +00:00
Andrew Nacin
f75e5a023c WP_Query: allow split_the_query = false to avoid a split.
see #26937.

Built from https://develop.svn.wordpress.org/trunk@27633


git-svn-id: http://core.svn.wordpress.org/trunk@27476 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-20 02:54:15 +00:00
Scott Taylor
db1badfcab In WP_Query::get_queried_object(), account for pre_get_posts by checking for tag when tag_id isn't present. Tags still need to be rolled up into tax_query. Add a unit test confirming expected query vars during and after pre_get_posts.
Props mattonomics for a patch.
See #27362.


Built from https://develop.svn.wordpress.org/trunk@27511


git-svn-id: http://core.svn.wordpress.org/trunk@27354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-12 04:08:18 +00:00
Scott Taylor
c92f58a6d5 On second thought, allow posts_per_rss to be set in pre_get_posts to override the posts_per_rss option. There are backwards compatibility concerns otherwise.
Props nacin.
Partially reverts [27455]. Updates the unit test. See #25380.


Built from https://develop.svn.wordpress.org/trunk@27456


git-svn-id: http://core.svn.wordpress.org/trunk@27302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-07 18:59:14 +00:00
Scott Taylor
bc968895cc When setting posts_per_page in WP_Query::get_posts(), check for is_feed() in the same place where posts_per_page is set when it is not already set. Previously, when is_feed() was true, posts_per_page would be arbitrarily overwritten. This fix allows posts_per_page to be set during pre_get_posts when is_feed() is true and not be overwritten.
Adds unit test.

Props wokamoto.
Fixes #25380.


Built from https://develop.svn.wordpress.org/trunk@27455


git-svn-id: http://core.svn.wordpress.org/trunk@27301 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-07 18:33:15 +00:00
Andrew Nacin
1ff0aebf20 Add has_password and post_password query variables to WP_Query.
* has_password true means posts with passwords, false means posts without.
 * post_password can query for posts with a particular password.

props wonderboymusic, robmiller.
fixes #20308.

Built from https://develop.svn.wordpress.org/trunk@27395


git-svn-id: http://core.svn.wordpress.org/trunk@27243 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-04 07:45:14 +00:00
Andrew Nacin
1d06679518 Add a $default argument to get_query_var() and WP_Query::get(). fixes #16471.
Built from https://develop.svn.wordpress.org/trunk@27304


git-svn-id: http://core.svn.wordpress.org/trunk@27157 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-26 23:58:14 +00:00
Drew Jaynes
d8a52d7523 Remove now-unnecessary vanity spacing of various hooks in wp-includes/query.php.
See #25514.

Built from https://develop.svn.wordpress.org/trunk@27211


git-svn-id: http://core.svn.wordpress.org/trunk@27068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 17:59:13 +00:00
Drew Jaynes
9f9d3f8b8a Inline documentation hooks in wp-includes/query.php.
Covers documentation for the various remaining query hooks, notably including but not limited to:
* `parse_query`
* `parse_tax_query`
* `pre_get_posts`
* `posts_results`
* `the_posts`
* `found_posts`
* `the_post`

Props dougwollison, DrewAPicture.
See #25514.


Built from https://develop.svn.wordpress.org/trunk@27210


git-svn-id: http://core.svn.wordpress.org/trunk@27067 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 17:54:13 +00:00
Drew Jaynes
0469b382a3 Inline documentation for various SQL clause hooks in wp-includes/query.php.
Covers documentation for SQL clause hooks related to comment feeds, including:
* `comment_feed_join`
* `comment_feed_where`
* `comment_feed_groupby`
* `comment_feed_orderby`
* `comment_feed_limits`

Props dougwollison, DrewAPicture.
See #25514.


Built from https://develop.svn.wordpress.org/trunk@27208


git-svn-id: http://core.svn.wordpress.org/trunk@27065 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 17:46:13 +00:00
Drew Jaynes
6060a66451 Inline documentation for various SQL clause hooks in wp-includes/query.php.
Covers documentation for SQL clause hooks specified for use by caching plugins, including:
* `posts_selection`
* `posts_where_request`
* `posts_groupby_request`
* `posts_join_request`
* `posts_orderby_request`
* `posts_distinct_request`
* `posts_fields_request`
* `post_limits_request`
* `posts_clauses_request`

Props dougwollison, DrewAPicture.
See #25514.


Built from https://develop.svn.wordpress.org/trunk@27207


git-svn-id: http://core.svn.wordpress.org/trunk@27064 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 17:41:12 +00:00
Drew Jaynes
742c77fc6f Inline documentation for various SQL clause hooks in wp-includes/query.php.
Covers documentation for general SQL clause hooks, including:
* `posts_where`
* `posts_join`
* `posts_where_paged`
* `posts_groupby`
* `posts_join_paged`
* `posts_orderby`
* `posts_distinct`
* `post_limits`
* `posts_fields`
* `posts_clauses`

Props dougwollison, DrewAPicture.
See #25514.


Built from https://develop.svn.wordpress.org/trunk@27206


git-svn-id: http://core.svn.wordpress.org/trunk@27063 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-20 17:34:14 +00:00