Commit Graph

632 Commits

Author SHA1 Message Date
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
Scott Taylor
d6baca3c35 Fix an error in SQL generation when perm is set and an array is passed for post_status. Adds unit test.
Props oso96_2000.
Fixes #25523.


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


git-svn-id: http://core.svn.wordpress.org/trunk@26940 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-02 07:36:13 +00:00
Scott Taylor
d8db2e0cc7 Fix imperceptible whitespace cruff from [27017].
Built from https://develop.svn.wordpress.org/trunk@27018


git-svn-id: http://core.svn.wordpress.org/trunk@26895 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-22 22:35:12 +00:00
Scott Taylor
580d8ab0db Fix a bit of whitespace from [27016].
Built from https://develop.svn.wordpress.org/trunk@27017


git-svn-id: http://core.svn.wordpress.org/trunk@26894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-22 22:34:12 +00:00
Scott Taylor
a9c661c00e Let is_attachment() accept an $attachment parameter, similar to is_page() and is_single(). Adds Unit Tests for all 3.
Props alex-ye for the initial patch.
Fixes #24257.


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


git-svn-id: http://core.svn.wordpress.org/trunk@26893 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-22 22:31:12 +00:00
Sergey Biryukov
9572d2d001 Avoid a fatal error in wp_reset_postdata() if $wp_query global is not set.
see #26775 for trunk.
Built from https://develop.svn.wordpress.org/trunk@26932


git-svn-id: http://core.svn.wordpress.org/trunk@26813 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-11 23:57:14 +00:00
Scott Taylor
f3b433cec3 In WP_Query::get_queried_object(), move the check for $query['terms'] to a place where $query is actually set. This should be included if [26864] makes it into 3.8.1.
Props SergeyBiryukov.
See #26728, [26864], #26634, #26627.



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


git-svn-id: http://core.svn.wordpress.org/trunk@26758 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-27 19:30:10 +00:00
Scott Taylor
014007f029 Fix a regression for get_queried_object() by checking for category_name when cat isn't set - mainly is_category() being true for Uncategorized or when queried object is accessed in pre_get_posts. Also check for $query['terms'] when trying to assign a term as the queried object when is_tax() is true. Adds a unit test. See [26007] for how I originally broke this while fixing a bigger issue.
Props Chouby, jeremyfelt.
Fixes #26634, #26627.


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


git-svn-id: http://core.svn.wordpress.org/trunk@26750 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-22 18:31:12 +00:00
Andrew Nacin
ba55e433a4 Revert [26012] for now, which had fixed using paged with offset in WP_Query but introduced side effects for those working around it.
see #18897.

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


git-svn-id: http://core.svn.wordpress.org/trunk@26418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-02 16:26:10 +00:00
Scott Taylor
45deda0726 Fix canonical redirection of cat as described in #15256 by rolling the cat query var into tax_query, instead of category__in / category__not_in. Top-level categories were only redirecting properly if they had no children.
All unit tests pass. Tests marked for #15256 are no longer skipped.

Fixes #15256.
Props dd32.


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


git-svn-id: http://core.svn.wordpress.org/trunk@26008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-11 18:36:10 +00:00
Sergey Biryukov
8d659b278c Fix docblock formatting. fixes #25893.
Built from https://develop.svn.wordpress.org/trunk@26081


git-svn-id: http://core.svn.wordpress.org/trunk@26001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-11 13:32:10 +00:00
Sergey Biryukov
47151b3534 Add @return for WP_Query::parse_search(). props tivnet. fixes #25894.
Built from https://develop.svn.wordpress.org/trunk@26061


git-svn-id: http://core.svn.wordpress.org/trunk@25984 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-09 16:05:10 +00:00
Sergey Biryukov
297e714932 Declare the variable before using it. props tivnet. fixes #25895 for trunk.
Built from https://develop.svn.wordpress.org/trunk@26060


git-svn-id: http://core.svn.wordpress.org/trunk@25983 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-09 15:53:09 +00:00
Scott Taylor
a519007202 Respect paged when offset is used in WP_Query. Adds unit tests.
Props coffee2code.
Fixes #18897.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25943 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-05 01:35:10 +00:00
Scott Taylor
ca85591c3c Category and tag are typically checked before checking for a custom taxonomy. If the global query matches category or tag (even if it also has tax_query set), return category/tag as the queried object, instead of arbitrarily returning the first term in the tax_query stack (typically those added with 'pre_get_posts').
Real world example: http://www.emusic.com/17dots/topics/daily-download/ - "tag" page, regionalized for US-only content using `pre_get_posts` passing in the terms "US" and "ALL" for "region" (custom tax). All of the theme functions would output "ALL" as the term name. Even though it was a tag archive, the queried object was an arbitrary term from `tax_query`.

See [26006]. All unit tests pass.
Fixes #20767.



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


git-svn-id: http://core.svn.wordpress.org/trunk@25938 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-04 23:54:10 +00:00
Andrew Nacin
3b82280cb4 Query stopwords: Only eliminate single A-Z letters as search terms.
Stop trying to match any single letters that are not East Asian characters, as this requires PCRE with UTF-8 support; and because it doesn't actually work.

fixes #25709.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25913 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-27 20:51:10 +00:00
Andrew Nacin
c08aee70bb In search stopwords filtering, suppress possible PHP warnings when PCRE lacks UTF-8 support.
see #25709.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-26 05:59:09 +00:00
Andrew Nacin
70fd806759 Revert r25824:25875 from the core.svn.wordpress.org repository.
These commits were accidentally re-synced commits from develop.svn.wordpress.org due to a race condition. Thankfully, the history of this repository matters fairly little. It also happened only for trunk.


git-svn-id: http://core.svn.wordpress.org/trunk@25876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-25 02:29:52 +00:00
Andrew Nacin
93e54b6646 Always apply the posts_search filter. Restores 3.6 behavior.
props SergeyBiryukov.
fixes #25664.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25867 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-24 22:59:12 +00:00
Andrew Nacin
8ae8e01b67 Remove the old wp_auto_updates_maybe_update cron event. Schedule the new wp_maybe_auto_update event at 7 a.m. and 7 p.m. in the site's timezone.
see #27704.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-24 22:53:14 +00:00
Andrew Nacin
77ca1f202a Avoid notice with search feeds.
fixes #25677.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25801 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-23 20:55:10 +00:00
Andrew Nacin
6d97f53134 Always apply the posts_search filter. Restores 3.6 behavior.
props SergeyBiryukov.
fixes #25664.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25779 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-22 17:21:09 +00:00
Dominik Schilling
e483532553 Move get_current_user_id() call out of if-block, see [25669].
props layotte.
fixes #25372.
Built from https://develop.svn.wordpress.org/trunk@25689


git-svn-id: http://core.svn.wordpress.org/trunk@25605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-03 13:36:09 +00:00
Dominik Schilling
e4c8d56b76 Replace use of global $user_ID in favor of get_current_user_id(). fixes #25372.
Built from https://develop.svn.wordpress.org/trunk@25669


git-svn-id: http://core.svn.wordpress.org/trunk@25585 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-02 21:10:09 +00:00
Andrew Nacin
9e9093ab6d Don't order feeds of search results by relevance.
Allow for orderby=relevance to explicitly request relevance.

fixes #7394.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-02 21:05:08 +00:00
Scott Taylor
e3d58a5b23 Make url_to_postid() work for custom post type URLs. Use get_post_types() and get_taxonomies() instead of directly accessing globals. Adds unit test.
Props faishal, for the globals fix.
Fixes #19744.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25576 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-02 19:42:09 +00:00
Andrew Nacin
d7fc6d5d49 Order search results by relevance, rather than by date.
The ordering logic is as follows:
 * Full sentence matches in post titles.
 * All search terms in post titles.
 * Any search terms in post titles.
 * Full sentence matches in post content.

Each section and any remaining posts are then sorted by date.

Introduces some filters:
 * wp_search_stopwords, to filter stop words ignored in WHERE.
 * posts_search_orderby, to filter the ORDER BY when ordering search results.

props azaozz, wonderboymusic.
fixes #7394.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25549 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-27 17:34:09 +00:00
Andrew Nacin
dba857a39a When is_main_query() is called during the pre_get_posts hook, issue _doing_it_wrong().
The is_main_query() WP_Query method should be used in these instances instead.
see #23329.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-24 17:10:09 +00:00
Andrew Nacin
1fda14e76b Introduce a reset_postdata() method on the WP_Query object, which wp_reset_postdata() now wraps.
props ericlewis.
fixes #24785.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25518 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-24 15:53:09 +00:00
Scott Taylor
8bd9659d0d Move checks for post_type being an array inline. See [25291], [25292], #18614.
Built from https://develop.svn.wordpress.org/trunk@25312


git-svn-id: http://core.svn.wordpress.org/trunk@25274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-10 03:02:10 +00:00
Scott Taylor
7af06e7ab3 Add an action at the end of WP_Query::parse_tax_query() called (wait for it...) parse_tax_query which will enable developers to alter $this->tax_query->queries before SQL is generated. pre_get_posts is too early for many scenarios.
Built from https://develop.svn.wordpress.org/trunk@25311


git-svn-id: http://core.svn.wordpress.org/trunk@25273 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-10 02:36:09 +00:00
Scott Taylor
a67d551dac Ensure that the post type object is the queried object when a post type has been registered with has_archive => true. Ensure it is not stomped when decorated with tax_query. Adds unit tests.
Props nacin.
Fixes #18614.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-06 22:07:09 +00:00
Scott Taylor
d7cc1f506a Introduce wp_using_ext_object_cache() - mimic wp_suspend_cache_invalidation() and discourage direct access to $_wp_using_ext_object_cache, cleaning up importing of globals in functions and provides function to modify that global. Loads the packaged object cache when an external cache hasn't been loaded or doesn't contain wp_cache_init().
Fixes #21401.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-06 18:10:09 +00:00
Scott Taylor
bfdc55b24d Allow is_tag() to accept term_id, slug, 'term_name or array of any. Many other is_*()` funcs already do this. Adds unit tests.
Props ramiy.
Fixes #18746.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25251 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-06 17:27:08 +00:00
Scott Taylor
b22bc5e389 Check bad dates and redirect, instead of 404ing, as necessary and appropriate.
Adds query, conditional, and canonical Unit Tests.

Props kovshenin, SergeyBiryukov, DrewAPicture.
Fixes #10935.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-06 16:36:09 +00:00
Scott Taylor
8038d7f9e8 Move get_meta_type() into the WP_Meta_Query class as get_cast_for_type(). WP_Query can then access it like: $this->meta_query->get_cast_for_type().
See #21621, [25255].


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


git-svn-id: http://core.svn.wordpress.org/trunk@25235 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-05 23:32:09 +00:00
Scott Taylor
4be84bbdfb When meta_type is passed with orderby => meta_value, orderby must also use CAST() to avoid scenarios like: SELECTing by UNSIGNED and then ordering by CHAR. Adds unit test.
Fixes #21621.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25223 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-05 16:57:08 +00:00
Scott Taylor
aa480a25e2 Introduce author__in and author__not_in query vars. Fixes issue with multiple author exclusion when comma-separated string is passed for author. Adds a bunch of missing unit tests.
Props pollett for initial patch.
Fixes #16854.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25216 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-04 21:33:09 +00:00
Scott Taylor
4a2c4c8f01 Kill the query in the following edge case: post_type => 'any' but exclude_from_search => false returns no valid post types. Adds unit tests.
Props mitchoyoshitaka.
Fixes #19198.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-04 18:51:10 +00:00
Scott Taylor
3b1b03e4c4 Convert category__and to category__in (less expensive) and unset it when only one category is passed. Adds unit tests.
Fixes #24245.



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


git-svn-id: http://core.svn.wordpress.org/trunk@25208 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-04 18:17:09 +00:00
Andrew Nacin
41f1cd687b WP_Date_Query.
props Viper007Bond.
see #18694.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25119 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-27 16:39:09 +00:00
Andrew Nacin
7ff1bbea19 Don't cast the 'm' query variable to an integer as the value can exceed the range of a 32-bit signed integer.
props Viper007Bond.
fixes #24884.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25118 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-27 15:20:10 +00:00
Andrew Nacin
9ccc275d88 Correct phpdoc for WP_Query::$post. props lgedeon, fixes #25130.
Built from https://develop.svn.wordpress.org/trunk@25110


git-svn-id: http://core.svn.wordpress.org/trunk@25092 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-23 22:02:08 +00:00