Docs: Add a note that the who parameter in WP_User_Query is deprecated.

Any usage of `'who' => 'authors'` should be updated to use capability queries instead.

Includes documenting the capability query parameters in `wp_dropdown_users()`.

Follow-up to [51943].

Props kkmuffme, swissspidy, SergeyBiryukov.
See #61243.
Built from https://develop.svn.wordpress.org/trunk@58172


git-svn-id: http://core.svn.wordpress.org/trunk@57635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2024-05-19 19:53:19 +00:00
parent ff2929bf19
commit e59e190855
3 changed files with 83 additions and 65 deletions

View File

@ -142,6 +142,7 @@ class WP_User_Query {
* @since 5.1.0 Introduced the 'meta_compare_key' parameter. * @since 5.1.0 Introduced the 'meta_compare_key' parameter.
* @since 5.3.0 Introduced the 'meta_type_key' parameter. * @since 5.3.0 Introduced the 'meta_type_key' parameter.
* @since 5.9.0 Added 'capability', 'capability__in', and 'capability__not_in' parameters. * @since 5.9.0 Added 'capability', 'capability__in', and 'capability__not_in' parameters.
* Deprecated the 'who' parameter.
* @since 6.3.0 Added 'cache_results' parameter. * @since 6.3.0 Added 'cache_results' parameter.
* *
* @global wpdb $wpdb WordPress database abstraction object. * @global wpdb $wpdb WordPress database abstraction object.
@ -151,13 +152,13 @@ class WP_User_Query {
* Optional. Array or string of query parameters. * Optional. Array or string of query parameters.
* *
* @type int $blog_id The site ID. Default is the current site. * @type int $blog_id The site ID. Default is the current site.
* @type string|string[] $role An array or a comma-separated list of role names that users must match * @type string|string[] $role An array or a comma-separated list of role names that users
* to be included in results. Note that this is an inclusive list: users * must match to be included in results. Note that this is
* must match *each* role. Default empty. * an inclusive list: users must match *each* role. Default empty.
* @type string[] $role__in An array of role names. Matched users must have at least one of these * @type string[] $role__in An array of role names. Matched users must have at least one
* roles. Default empty array. * of these roles. Default empty array.
* @type string[] $role__not_in An array of role names to exclude. Users matching one or more of these * @type string[] $role__not_in An array of role names to exclude. Users matching one or more
* roles will not be included in results. Default empty array. * of these roles will not be included in results. Default empty array.
* @type string|string[] $meta_key Meta key or keys to filter by. * @type string|string[] $meta_key Meta key or keys to filter by.
* @type string|string[] $meta_value Meta value or values to filter by. * @type string|string[] $meta_value Meta value or values to filter by.
* @type string $meta_compare MySQL operator used for comparing the meta value. * @type string $meta_compare MySQL operator used for comparing the meta value.
@ -170,19 +171,19 @@ class WP_User_Query {
* See WP_Meta_Query::__construct() for accepted values and default value. * See WP_Meta_Query::__construct() for accepted values and default value.
* @type array $meta_query An associative array of WP_Meta_Query arguments. * @type array $meta_query An associative array of WP_Meta_Query arguments.
* See WP_Meta_Query::__construct() for accepted values. * See WP_Meta_Query::__construct() for accepted values.
* @type string|string[] $capability An array or a comma-separated list of capability names that users must match * @type string|string[] $capability An array or a comma-separated list of capability names that users
* to be included in results. Note that this is an inclusive list: users * must match to be included in results. Note that this is
* must match *each* capability. * an inclusive list: users must match *each* capability.
* Does NOT work for capabilities not in the database or filtered via {@see 'map_meta_cap'}. * Does NOT work for capabilities not in the database or filtered
* Default empty. * via {@see 'map_meta_cap'}. Default empty.
* @type string[] $capability__in An array of capability names. Matched users must have at least one of these * @type string[] $capability__in An array of capability names. Matched users must have at least one
* capabilities. * of these capabilities.
* Does NOT work for capabilities not in the database or filtered via {@see 'map_meta_cap'}. * Does NOT work for capabilities not in the database or filtered
* Default empty array. * via {@see 'map_meta_cap'}. Default empty array.
* @type string[] $capability__not_in An array of capability names to exclude. Users matching one or more of these * @type string[] $capability__not_in An array of capability names to exclude. Users matching one or more
* capabilities will not be included in results. * of these capabilities will not be included in results.
* Does NOT work for capabilities not in the database or filtered via {@see 'map_meta_cap'}. * Does NOT work for capabilities not in the database or filtered
* Default empty array. * via {@see 'map_meta_cap'}. Default empty array.
* @type int[] $include An array of user IDs to include. Default empty array. * @type int[] $include An array of user IDs to include. Default empty array.
* @type int[] $exclude An array of user IDs to exclude. Default empty array. * @type int[] $exclude An array of user IDs to exclude. Default empty array.
* @type string $search Search keyword. Searches for possible string matches on columns. * @type string $search Search keyword. Searches for possible string matches on columns.
@ -242,7 +243,8 @@ class WP_User_Query {
* - 'all' for all fields and loads user meta. * - 'all' for all fields and loads user meta.
* - 'all_with_meta' Deprecated. Use 'all'. * - 'all_with_meta' Deprecated. Use 'all'.
* Default 'all'. * Default 'all'.
* @type string $who Type of users to query. Accepts 'authors'. * @type string $who Deprecated, use `$capability` instead.
* Type of users to query. Accepts 'authors'.
* Default empty (all users). * Default empty (all users).
* @type bool|string[] $has_published_posts Pass an array of post types to filter results to users who have * @type bool|string[] $has_published_posts Pass an array of post types to filter results to users who have
* published posts in those post types. `true` is an alias for all * published posts in those post types. `true` is an alias for all

View File

@ -1540,54 +1540,70 @@ function setup_userdata( $for_user_id = 0 ) {
* *
* @since 2.3.0 * @since 2.3.0
* @since 4.5.0 Added the 'display_name_with_login' value for 'show'. * @since 4.5.0 Added the 'display_name_with_login' value for 'show'.
* @since 4.7.0 Added the `$role`, `$role__in`, and `$role__not_in` parameters. * @since 4.7.0 Added the 'role', 'role__in', and 'role__not_in' parameters.
* @since 5.9.0 Added the 'capability', 'capability__in', and 'capability__not_in' parameters.
* Deprecated the 'who' parameter.
* *
* @param array|string $args { * @param array|string $args {
* Optional. Array or string of arguments to generate a drop-down of users. * Optional. Array or string of arguments to generate a drop-down of users.
* See WP_User_Query::prepare_query() for additional available arguments. * See WP_User_Query::prepare_query() for additional available arguments.
* *
* @type string $show_option_all Text to show as the drop-down default (all). * @type string $show_option_all Text to show as the drop-down default (all).
* Default empty. * Default empty.
* @type string $show_option_none Text to show as the drop-down default when no * @type string $show_option_none Text to show as the drop-down default when no
* users were found. Default empty. * users were found. Default empty.
* @type int|string $option_none_value Value to use for $show_option_none when no users * @type int|string $option_none_value Value to use for `$show_option_none` when no users
* were found. Default -1. * were found. Default -1.
* @type string $hide_if_only_one_author Whether to skip generating the drop-down * @type string $hide_if_only_one_author Whether to skip generating the drop-down
* if only one user was found. Default empty. * if only one user was found. Default empty.
* @type string $orderby Field to order found users by. Accepts user fields. * @type string $orderby Field to order found users by. Accepts user fields.
* Default 'display_name'. * Default 'display_name'.
* @type string $order Whether to order users in ascending or descending * @type string $order Whether to order users in ascending or descending
* order. Accepts 'ASC' (ascending) or 'DESC' (descending). * order. Accepts 'ASC' (ascending) or 'DESC' (descending).
* Default 'ASC'. * Default 'ASC'.
* @type int[]|string $include Array or comma-separated list of user IDs to include. * @type int[]|string $include Array or comma-separated list of user IDs to include.
* Default empty. * Default empty.
* @type int[]|string $exclude Array or comma-separated list of user IDs to exclude. * @type int[]|string $exclude Array or comma-separated list of user IDs to exclude.
* Default empty. * Default empty.
* @type bool|int $multi Whether to skip the ID attribute on the 'select' element. * @type bool|int $multi Whether to skip the ID attribute on the 'select' element.
* Accepts 1|true or 0|false. Default 0|false. * Accepts 1|true or 0|false. Default 0|false.
* @type string $show User data to display. If the selected item is empty * @type string $show User data to display. If the selected item is empty
* then the 'user_login' will be displayed in parentheses. * then the 'user_login' will be displayed in parentheses.
* Accepts any user field, or 'display_name_with_login' to show * Accepts any user field, or 'display_name_with_login' to show
* the display name with user_login in parentheses. * the display name with user_login in parentheses.
* Default 'display_name'. * Default 'display_name'.
* @type int|bool $echo Whether to echo or return the drop-down. Accepts 1|true (echo) * @type int|bool $echo Whether to echo or return the drop-down. Accepts 1|true (echo)
* or 0|false (return). Default 1|true. * or 0|false (return). Default 1|true.
* @type int $selected Which user ID should be selected. Default 0. * @type int $selected Which user ID should be selected. Default 0.
* @type bool $include_selected Whether to always include the selected user ID in the drop- * @type bool $include_selected Whether to always include the selected user ID in the drop-
* down. Default false. * down. Default false.
* @type string $name Name attribute of select element. Default 'user'. * @type string $name Name attribute of select element. Default 'user'.
* @type string $id ID attribute of the select element. Default is the value of $name. * @type string $id ID attribute of the select element. Default is the value of `$name`.
* @type string $class Class attribute of the select element. Default empty. * @type string $class Class attribute of the select element. Default empty.
* @type int $blog_id ID of blog (Multisite only). Default is ID of the current blog. * @type int $blog_id ID of blog (Multisite only). Default is ID of the current blog.
* @type string $who Which type of users to query. Accepts only an empty string or * @type string $who Deprecated, use `$capability` instead.
* 'authors'. Default empty. * Which type of users to query. Accepts only an empty string or
* @type string|array $role An array or a comma-separated list of role names that users must * 'authors'. Default empty (all users).
* match to be included in results. Note that this is an inclusive * @type string|string[] $role An array or a comma-separated list of role names that users
* list: users must match *each* role. Default empty. * must match to be included in results. Note that this is
* @type string[] $role__in An array of role names. Matched users must have at least one of * an inclusive list: users must match *each* role. Default empty.
* these roles. Default empty array. * @type string[] $role__in An array of role names. Matched users must have at least one
* @type string[] $role__not_in An array of role names to exclude. Users matching one or more of * of these roles. Default empty array.
* these roles will not be included in results. Default empty array. * @type string[] $role__not_in An array of role names to exclude. Users matching one or more
* of these roles will not be included in results. Default empty array.
* @type string|string[] $capability An array or a comma-separated list of capability names that users
* must match to be included in results. Note that this is
* an inclusive list: users must match *each* capability.
* Does NOT work for capabilities not in the database or filtered
* via {@see 'map_meta_cap'}. Default empty.
* @type string[] $capability__in An array of capability names. Matched users must have at least one
* of these capabilities.
* Does NOT work for capabilities not in the database or filtered
* via {@see 'map_meta_cap'}. Default empty array.
* @type string[] $capability__not_in An array of capability names to exclude. Users matching one or more
* of these capabilities will not be included in results.
* Does NOT work for capabilities not in the database or filtered
* via {@see 'map_meta_cap'}. Default empty array.
* } * }
* @return string HTML dropdown list of users. * @return string HTML dropdown list of users.
*/ */

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.6-alpha-58171'; $wp_version = '6.6-alpha-58172';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.