Commit Graph

576 Commits

Author SHA1 Message Date
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