Commit Graph

26 Commits

Author SHA1 Message Date
Gary Pendergast
1071dfb4ec User Query: Cast $user_total as an int.
The `$user_total` member of `WP_User_Query`, and corresponding `get_total()` method, have always been documented as returning an `int`. `$user_total`, however, is populated by `$wpdb->get_var()`, which returns 
a string (containing an integer value). Casting the return value from `get_var()` as an `int` rectifies this discrepency.

Props runciters.
Fixes #39297.


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


git-svn-id: http://core.svn.wordpress.org/trunk@39852 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-01-16 23:24:45 +00:00
Gary Pendergast
af69f4ab1a General: Restore usage of $wpdb, instead of $this->db.
Hiding the `$wpdb` global behind a property decreases the readability of the code, as well as causing irrelevant output when dumping an object.

Reverts [38275], [38278], [38279], [38280], [38387].
See #37699.


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


git-svn-id: http://core.svn.wordpress.org/trunk@38711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-10 06:38:31 +00:00
Boone Gorges
e96c617c03 Query: Add nicename and login params to user query.
New parameters are: `login`, `login__in`, `login__not_in`, `nicename`,
`nicename__in`, `nicename__not_in`.

`login__in` and `nicename__in` are also now valid values for the
'orderby' parameter.

Props ryanplas.
Fixes #36624.
Built from https://develop.svn.wordpress.org/trunk@38715


git-svn-id: http://core.svn.wordpress.org/trunk@38658 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-04 02:27:29 +00:00
Scott Taylor
e5225324a2 Multisite: use get_current_blog_id() where applicable, in lieu of plucking the $blog_id global from outer space.
See #37699.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-31 04:55:54 +00:00
Scott Taylor
e7ffad7fac Query: add a protected field, $db, (composition, as it were) to WP_*_Query classes to hold the value for the database abstraction, instead of importing the global $wpdb into every method that uses it. Reduces the number of global imports by 32.
See #37699.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38216 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-18 18:21:31 +00:00
Drew Jaynes
602b51a209 Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:15:28 +00:00
Drew Jaynes
b1804afeaf Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs.
Also use 'back-compat' in some inline comments where backward compatibility is the subject and shorthand feels more natural.

Note: 'backwards compatibility/compatibile' can also be considered correct, though it's primary seen in regular use in British English.

Props ocean90.
Fixes #36835.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-13 18:41:31 +00:00
Boone Gorges
2d37a0ee17 Users: The 'who' parameter should not interfere with 'meta_key' + 'meta_value' in WP_User_Query.
Props adrianosilvaferreira.
Fixes #36724.
Built from https://develop.svn.wordpress.org/trunk@37360


git-svn-id: http://core.svn.wordpress.org/trunk@37326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-04 18:57:28 +00:00
Eric Lewis
24adb71a56 Networks and sites: Replace "blog" usage with "site" in docs.
Multisite functions use the term "blog" to refer to what we now call a "site," e.g. `get_current_blog_id()`. These functions are here to stay because of our commitment to backwards compatibility. What we can do is set the documentation straight.

See #35417.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-28 03:51:26 +00:00
John Blackbourn
aace0e33c1 Correct some @param doc names in the WP_Tax_Query and WP_User_Query classes.
See #32246

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


git-svn-id: http://core.svn.wordpress.org/trunk@35880 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-14 02:50:27 +00:00
Boone Gorges
767518ffaa Correct documentation for 'fields' param of WP_User_Query.
[29843] introduced this documentation, and incorrectly stated that short
column names (eg 'login' instead of 'user_login') could be used.

Props birgire.
Fixes #34701.
Built from https://develop.svn.wordpress.org/trunk@35645


git-svn-id: http://core.svn.wordpress.org/trunk@35609 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-16 19:04:55 +00:00
Drew Jaynes
217b661703 Docs: Add missing descriptions for the $wpdb global in DocBlocks all the places.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35136 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-14 23:44:25 +00:00
Drew Jaynes
dc92982950 Users: Restore changes from [35114] accidentally reverted in [35135].
See #28631.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35103 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-13 15:45:25 +00:00
Drew Jaynes
cdd8891631 Docs: Add a changelog entry mentioning that the number argument now supports -1 (all).
Also fixes the argument description.

-1 support was added in [35114].

See #28631.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35100 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-13 15:16:24 +00:00
Scott Taylor
c9babc4cdd Users: allow -1 (no limit, use with extreme caution on large sites) as the value for number in WP_User_Query - similar to posts_per_page => -1 in WP_Query.
Adds unit tests.

Props mordauk, jesin, nofearinc.
Fixes #28631.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35079 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-13 02:40:24 +00:00
Boone Gorges
ff0b621719 Don't match partial roles in WP_User_Query.
Because 'role=ocean90' shouldn't match 'role=bocean901'.

Props bocean901, ocean90.
Fixes #22212.
Built from https://develop.svn.wordpress.org/trunk@35101


git-svn-id: http://core.svn.wordpress.org/trunk@35066 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-13 01:32:25 +00:00
Boone Gorges
c758468faf WP_User_Query role improvement redux.
It's back, and it's better than ever: an overhaul of role-related arguments
in `WP_User_Query`. This updated version of the previously-reverted [34875]
includes support for the use of `$blog_id` without specifying a `$role`, for
a 99.7% reduced chance of breaking wordpress.org and other large sites.

Props boonebgorges, swissspidy.
Fixes #22212.
Built from https://develop.svn.wordpress.org/trunk@34959


git-svn-id: http://core.svn.wordpress.org/trunk@34924 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-08 21:28:24 +00:00
Boone Gorges
99421d1799 Store SQL query string as a property on WP_User_Query.
In addition to better parity with other WP query classes, this also allows
testing of SQL strings, should anyone want to do something so foolish.

See #22212.
Built from https://develop.svn.wordpress.org/trunk@34956


git-svn-id: http://core.svn.wordpress.org/trunk@34921 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-08 21:06:23 +00:00
Aaron Jorbin
a93ec5244d Revert [34875] due to unintentional breaking change
WordPress.org was taken down due to as Otto42 describes:

The previous version of this function added the query piece for the meta key = blog_id.capabilities, regardless of whether or not a role was requested. This limits the users returned to those with some defined role on this particular multisite instance.

See #22212



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


git-svn-id: http://core.svn.wordpress.org/trunk@34845 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-06 20:58:24 +00:00
Boone Gorges
f233b37d07 Improve role-related arguments in WP_User_Query.
* 'role' now accepts an array or comma-separated list of role names. When passing multiple values for 'role', `WP_User_Query` will only match users that have all of the specified roles.
* 'role__in' accepts an array of role names, and allow the filtering of matched users to those with at least one of the specified roles.
* 'role__not_in' accepts an array of role names, and allows the filtering of matched users to those who have none of the specified roles.

Props swissspidy, mordauk, barrykooij, sirbrillig.
Fixes #22212.
Built from https://develop.svn.wordpress.org/trunk@34875


git-svn-id: http://core.svn.wordpress.org/trunk@34840 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-06 17:40:47 +00:00
Boone Gorges
198dee542d Ensure that WP_User_Query vars are filled after 'pre_get_users'.
This prevents notices from being thrown when a 'pre_get_users' callback
removes required values from the list of `query_vars`.

For backward compatibility with previous uses of 'pre_get_users', default
values are parsed both before and after the action is fired.

Fixes #33449.
Built from https://develop.svn.wordpress.org/trunk@34804


git-svn-id: http://core.svn.wordpress.org/trunk@34769 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-03 18:45:25 +00:00
Boone Gorges
37e4c2dbac Introduce 'paged' parameter for WP_User_Query.
This is an alternative to using 'offset', and manually calculating pagination.
Note that 'paged' works only in conjunction with 'number', the latter of which
provides the per-page value.

Props sebastian.pisula.
Fixes #25145.
Built from https://develop.svn.wordpress.org/trunk@34531


git-svn-id: http://core.svn.wordpress.org/trunk@34495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 04:26:29 +00:00
Drew Jaynes
35246a957f Docs: The User API is singular.
See #33701.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34357 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 12:31:26 +00:00
Drew Jaynes
e6764f3b19 Docs: Update the docs for WP_User_Query->prepare_query() for ordering by the value of the include argument, allowed since 4.1.
Also adds a changelog entry for the additionally-accepted value.

Props danielbachhuber.
Fixes #33937.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-21 00:47:25 +00:00
Drew Jaynes
e1e98b04b9 Docs: Add a missing file header for wp-includes/class-wp-user-query.php, introduced in [33749].
Also clarifies the class DocBlock summary for `WP_User_Query` to better describe its purpose.

See #33413. See #33701.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33864 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-04 01:26:25 +00:00
Scott Taylor
484331e492 Users: move WP_User_Query into its own file. user.php loads the new files, so this is 100% BC if someone is loading user.php directly (a lot of plugins do). New files created using svn cp.
Creates: 
`class-wp-user-query.php` 
`user-functions.php` 

`user.php` contains only top-level code. Class file only contains the class. Functions file only contains functions.

See #33413.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-26 04:20:21 +00:00