WordPress/wp-content/themes
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
..
twentyeleven Coding Standards: Add public visibility to methods in src directory. 2021-10-18 17:52:58 +00:00
twentyfifteen Bundled Themes: Bump bundled theme versions for WordPress 5.8. 2021-07-18 23:05:00 +00:00
twentyfourteen Role/Capability: Add support for capability queries in WP_User_Query. 2021-10-27 18:43:57 +00:00
twentynineteen Docs: Synchronize documentation for wp_get_attachment_image_attributes filter callbacks in bundled themes: 2021-08-12 19:30:57 +00:00
twentyseventeen Twenty Seventeen: Make blog header margin more specific on front page. 2021-09-14 10:19:01 +00:00
twentysixteen Docs: Synchronize documentation for wp_get_attachment_image_attributes filter callbacks in bundled themes: 2021-08-12 19:30:57 +00:00
twentyten Bundled Themes: Remove redundant semicolons after closing curly brackets. 2021-08-05 13:25:58 +00:00
twentythirteen Twenty Thirteen: Correct indentation in image.php template. 2021-08-05 14:38:57 +00:00
twentytwelve Bundled Themes: Version Bump 2010, 2011 and 2012. 2021-07-26 03:15:00 +00:00
twentytwenty Twenty Twenty: Remove duplicate class name from localized font-family elements. 2021-09-28 10:00:59 +00:00
twentytwentyone Twenty Twenty-One: Remove duplicate width and height values from social icons. 2021-10-06 15:39:05 +00:00
index.php Remove closing PHP tags from the rest of index.php files in wp-content, for consistency with wp-content/index.php. 2014-06-05 15:59:14 +00:00