WordPress/wp-admin
Pascal Birchler a225165010 Role/Capability: Add support for capability queries in WP_User_Query.
Similar to the existing `role`/`role__in`/`role__not_in` query arguments, this adds support for three new query arguments in `WP_User_Query`:

* `capability` 
* `capability__in`
* `capability__not_in`

These can be used to fetch users with (or without) a specific set of capabilities, for example to get all users
with the capability to edit a certain post type.

Under the hood, this will check all existing roles on the site and perform a `LIKE` query against the `capabilities` user meta field to find:

* all users with a role that has this capability
* all users with the capability being assigned directly

Note: In WordPress, not all capabilities are stored in the database. Capabilities can also be modified using filters like `map_meta_cap`. These new query arguments do NOT work for such capabilities.

The prime use case for capability queries is to get all "authors", i.e. users with the capability to edit a certain post type.

Until now, `'who' => 'authors'` was used for this, which relies on user levels. However, user levels were deprecated a long time ago and thus never added to custom roles. This led to constant frustration due to users with custom roles missing from places like author dropdowns.

This updates any usage of `'who' => 'authors'` in core to use capability queries instead.

Subsequently, `'who' => 'authors'` queries are being **deprecated** in favor of these new query arguments.

Also adds a new `capabilities` parameter (mapping to `capability__in` in `WP_User_Query`) to the REST API users controller.

Also updates `twentyfourteen_list_authors()` in Twenty Fourteen to make use of this new functionality, adding a new `twentyfourteen_list_authors_query_args` filter to make it easier to override this behavior.

Props scribu, lgladdly, boonebgorges, spacedmonkey, peterwilsoncc, SergeyBiryukov, swissspidy.
Fixes #16841.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51532 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-27 18:43:57 +00:00
..
css Accessibility: Privacy: Use red color for action buttons on the Erase Personal Data screen: 2021-10-05 20:32:05 +00:00
images Help/About: Update the About section for 5.8. 2021-07-06 18:38:57 +00:00
includes Role/Capability: Add support for capability queries in WP_User_Query. 2021-10-27 18:43:57 +00:00
js Media: Display the unsaved changes dialog in image edit form using jQuery .text() function. 2021-10-15 00:18:56 +00:00
maint
network Networks and Sites: Replace two remaining occurrences of "blog" with "site" in user-facing strings. 2021-07-28 10:02:00 +00:00
user
about.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
admin-ajax.php
admin-footer.php Coding Standards: Simplify a condition in wp-admin/admin-footer.php. 2021-06-01 11:30:57 +00:00
admin-functions.php
admin-header.php Docs: Document some more common names for dynamic hooks and standardise the phrasing used. 2021-09-21 18:21:00 +00:00
admin-post.php
admin.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
async-upload.php Media: Improve upload page media item layout on smaller screens. 2021-06-22 04:26:58 +00:00
authorize-application.php App Passwords: Remove placeholder from the app password name input field. 2021-10-01 13:49:00 +00:00
comment.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
credits.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
custom-background.php
custom-header.php
customize.php Customize: Add wp-embed-responsive class to body if using widgets block editor 2021-09-01 07:10:56 +00:00
edit-comments.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
edit-form-advanced.php
edit-form-blocks.php Coding Standards: Use static closures when not using $this. 2021-08-26 12:59:02 +00:00
edit-form-comment.php Comments: Escape comment author's email in the Edit Comment form. 2021-06-07 18:47:02 +00:00
edit-link-form.php
edit-tag-form.php Administration: Consistently escape admin_url() links. 2021-06-17 14:37:00 +00:00
edit-tags.php
edit.php General: Fix code quality issues which were identified by static analysis. 2021-09-22 21:01:00 +00:00
erase-personal-data.php Coding Standards: Remove wrapping HTML tags from translatable strings. 2021-07-08 17:07:58 +00:00
export-personal-data.php Coding Standards: Remove wrapping HTML tags from translatable strings. 2021-07-08 17:07:58 +00:00
export.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
freedoms.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
import.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
index.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
install-helper.php
install.php
link-add.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
link-manager.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
link-parse-opml.php
link.php Coding Standards: Apply some alignment fixes from composer format. 2021-07-27 19:01:59 +00:00
load-scripts.php
load-styles.php Block Editor: Load the WP_Theme_JSON_Resolver class in wp-admin/load-styles.php. 2021-06-01 23:09:58 +00:00
media-new.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
media-upload.php
media.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
menu-header.php
menu.php Themes: Display the number of available theme updates in the admin menu. 2021-05-26 01:17:57 +00:00
moderation.php
ms-admin.php
ms-delete-site.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
ms-edit.php
ms-options.php
ms-sites.php
ms-themes.php
ms-upgrade-network.php
ms-users.php
my-sites.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
nav-menus.php Menus: Save display locations for new menus. 2021-08-30 04:12:57 +00:00
network.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
options-discussion.php Coding Standards: Use strict comparisons in wp-admin/options-discussion.php. 2021-08-05 03:30:57 +00:00
options-general.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
options-head.php
options-media.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
options-permalink.php Permalinks: Move the Nginx documentation link to help sidebar in wp-admin/options-permalink.php. 2021-10-05 23:11:06 +00:00
options-privacy.php Coding Standards: Use static closures when not using $this. 2021-08-26 12:59:02 +00:00
options-reading.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
options-writing.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
options.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
plugin-editor.php Code Modernization: Check the return type of parse_url() on Plugin/Theme Editor screens. 2021-08-17 21:56:58 +00:00
plugin-install.php Docs: Document some more common names for dynamic hooks and standardise the phrasing used. 2021-09-21 18:21:00 +00:00
plugins.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
post-new.php
post.php
press-this.php
privacy-policy-guide.php Coding Standards: Use static closures when not using $this. 2021-08-26 12:59:02 +00:00
privacy.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
profile.php
revision.php Coding Standards: Apply some alignment fixes from composer format. 2021-07-27 19:01:59 +00:00
setup-config.php Upgrade/Install: Use consistent capitalization for "web host" in setup messages. 2021-08-14 12:06:59 +00:00
site-health-info.php
site-health.php Site Health: Improve readability of site titles. 2021-06-28 23:07:57 +00:00
term.php
theme-editor.php Code Modernization: Check the return type of parse_url() on Plugin/Theme Editor screens. 2021-08-17 21:56:58 +00:00
theme-install.php Coding Standards: Improve escaping in wp-admin/theme-install.php. 2021-10-20 19:18:01 +00:00
themes.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
tools.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
update-core.php Coding Standards: Consistently escape form action URL in wp-admin/update-core.php. 2021-10-17 20:31:02 +00:00
update.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
upgrade-functions.php
upgrade.php
upload.php Coding Standards: Use strict comparisons in wp-admin/upload.php. 2021-08-05 03:37:56 +00:00
user-edit.php App Passwords: Remove placeholder from the app password name input field. 2021-10-01 13:49:00 +00:00
user-new.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
users.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00
widgets-form-blocks.php Widgets: Pass correct context to get_block_categories() calls. 2021-08-31 13:38:58 +00:00
widgets-form.php Widgets: Revert [51705]. 2021-09-09 21:40:57 +00:00
widgets.php Docs: Add a comment about the $title global usage in various admin files. 2021-07-22 13:53:00 +00:00