Docs: Standardise documentation for capability-related variadic functions.
See #37402 Built from https://develop.svn.wordpress.org/trunk@45419 git-svn-id: http://core.svn.wordpress.org/trunk@45230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9c6393e967
commit
26d5e05b75
|
@ -7,7 +7,17 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map meta capabilities to primitive capabilities.
|
* Maps meta capabilities to primitive capabilities.
|
||||||
|
*
|
||||||
|
* This function also accepts an ID of an object to map against if the capability is a meta capability. Meta
|
||||||
|
* capabilities such as `edit_post` and `edit_user` are capabilities used by this function to map to primitive
|
||||||
|
* capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* map_meta_cap( 'edit_posts', $user->ID );
|
||||||
|
* map_meta_cap( 'edit_post', $user->ID, $post->ID );
|
||||||
|
* map_meta_cap( 'edit_post_meta', $user->ID, $post->ID, $meta_key );
|
||||||
*
|
*
|
||||||
* This does not actually compare whether the user ID has the actual capability,
|
* This does not actually compare whether the user ID has the actual capability,
|
||||||
* just what the capability or capabilities are. Meta capability list value can
|
* just what the capability or capabilities are. Meta capability list value can
|
||||||
|
@ -18,12 +28,9 @@
|
||||||
*
|
*
|
||||||
* @global array $post_type_meta_caps Used to get post type meta capabilities.
|
* @global array $post_type_meta_caps Used to get post type meta capabilities.
|
||||||
*
|
*
|
||||||
* @param string $cap Capability name.
|
* @param string $cap Capability name.
|
||||||
* @param int $user_id User ID.
|
* @param int $user_id User ID.
|
||||||
* @param int $object_id Optional. ID of the specific object to check against if `$cap` is a "meta" cap.
|
* @param mixed ...$args Optional further parameters, typically starting with an object ID.
|
||||||
* "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used
|
|
||||||
* by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts',
|
|
||||||
* 'edit_others_posts', etc. The parameter is accessed via func_get_args().
|
|
||||||
* @return array Actual capabilities for meta capability.
|
* @return array Actual capabilities for meta capability.
|
||||||
*/
|
*/
|
||||||
function map_meta_cap( $cap, $user_id ) {
|
function map_meta_cap( $cap, $user_id ) {
|
||||||
|
@ -615,7 +622,17 @@ function map_meta_cap( $cap, $user_id ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the current user has a specific capability.
|
* Returns whether the current user has the specified capability.
|
||||||
|
*
|
||||||
|
* This function also accepts an ID of an object to check against if the capability is a meta capability. Meta
|
||||||
|
* capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to
|
||||||
|
* map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* current_user_can( 'edit_posts' );
|
||||||
|
* current_user_can( 'edit_post', $post->ID );
|
||||||
|
* current_user_can( 'edit_post_meta', $post->ID, $meta_key );
|
||||||
*
|
*
|
||||||
* While checking against particular roles in place of a capability is supported
|
* While checking against particular roles in place of a capability is supported
|
||||||
* in part, this practice is discouraged as it may produce unreliable results.
|
* in part, this practice is discouraged as it may produce unreliable results.
|
||||||
|
@ -628,11 +645,7 @@ function map_meta_cap( $cap, $user_id ) {
|
||||||
* @see map_meta_cap()
|
* @see map_meta_cap()
|
||||||
*
|
*
|
||||||
* @param string $capability Capability name.
|
* @param string $capability Capability name.
|
||||||
* @param int $object_id Optional. ID of the specific object to check against if `$capability` is a "meta" cap.
|
* @param mixed ...$args Optional further parameters, typically starting with an object ID.
|
||||||
* "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used
|
|
||||||
* by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts',
|
|
||||||
* 'edit_others_posts', etc. Accessed via func_get_args() and passed to WP_User::has_cap(),
|
|
||||||
* then map_meta_cap().
|
|
||||||
* @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is
|
* @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is
|
||||||
* passed, whether the current user has the given meta capability for the given object.
|
* passed, whether the current user has the given meta capability for the given object.
|
||||||
*/
|
*/
|
||||||
|
@ -650,12 +663,23 @@ function current_user_can( $capability ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the current user has a specific capability for a given site.
|
* Returns whether the current user has the specified capability for a given site.
|
||||||
|
*
|
||||||
|
* This function also accepts an ID of an object to check against if the capability is a meta capability. Meta
|
||||||
|
* capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to
|
||||||
|
* map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* current_user_can_for_blog( $blog_id, 'edit_posts' );
|
||||||
|
* current_user_can_for_blog( $blog_id, 'edit_post', $post->ID );
|
||||||
|
* current_user_can_for_blog( $blog_id, 'edit_post_meta', $post->ID, $meta_key );
|
||||||
*
|
*
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*
|
*
|
||||||
* @param int $blog_id Site ID.
|
* @param int $blog_id Site ID.
|
||||||
* @param string $capability Capability name.
|
* @param string $capability Capability name.
|
||||||
|
* @param mixed ...$args Optional further parameters, typically starting with an object ID.
|
||||||
* @return bool Whether the user has the given capability.
|
* @return bool Whether the user has the given capability.
|
||||||
*/
|
*/
|
||||||
function current_user_can_for_blog( $blog_id, $capability ) {
|
function current_user_can_for_blog( $blog_id, $capability ) {
|
||||||
|
@ -683,12 +707,23 @@ function current_user_can_for_blog( $blog_id, $capability ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the author of the supplied post has a specific capability.
|
* Returns whether the author of the supplied post has the specified capability.
|
||||||
|
*
|
||||||
|
* This function also accepts an ID of an object to check against if the capability is a meta capability. Meta
|
||||||
|
* capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to
|
||||||
|
* map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* author_can( $post, 'edit_posts' );
|
||||||
|
* author_can( $post, 'edit_post', $post->ID );
|
||||||
|
* author_can( $post, 'edit_post_meta', $post->ID, $meta_key );
|
||||||
*
|
*
|
||||||
* @since 2.9.0
|
* @since 2.9.0
|
||||||
*
|
*
|
||||||
* @param int|WP_Post $post Post ID or post object.
|
* @param int|WP_Post $post Post ID or post object.
|
||||||
* @param string $capability Capability name.
|
* @param string $capability Capability name.
|
||||||
|
* @param mixed ...$args Optional further parameters, typically starting with an object ID.
|
||||||
* @return bool Whether the post author has the given capability.
|
* @return bool Whether the post author has the given capability.
|
||||||
*/
|
*/
|
||||||
function author_can( $post, $capability ) {
|
function author_can( $post, $capability ) {
|
||||||
|
@ -709,12 +744,23 @@ function author_can( $post, $capability ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether a particular user has a specific capability.
|
* Returns whether a particular user has the specified capability.
|
||||||
|
*
|
||||||
|
* This function also accepts an ID of an object to check against if the capability is a meta capability. Meta
|
||||||
|
* capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to
|
||||||
|
* map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* user_can( $user->ID, 'edit_posts' );
|
||||||
|
* user_can( $user->ID, 'edit_post', $post->ID );
|
||||||
|
* user_can( $user->ID, 'edit_post_meta', $post->ID, $meta_key );
|
||||||
*
|
*
|
||||||
* @since 3.1.0
|
* @since 3.1.0
|
||||||
*
|
*
|
||||||
* @param int|WP_User $user User ID or object.
|
* @param int|WP_User $user User ID or object.
|
||||||
* @param string $capability Capability name.
|
* @param string $capability Capability name.
|
||||||
|
* @param mixed ...$args Optional further parameters, typically starting with an object ID.
|
||||||
* @return bool Whether the user has the given capability.
|
* @return bool Whether the user has the given capability.
|
||||||
*/
|
*/
|
||||||
function user_can( $user, $capability ) {
|
function user_can( $user, $capability ) {
|
||||||
|
|
|
@ -712,7 +712,17 @@ class WP_User {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the user has a specific capability.
|
* Returns whether the user has the specified capability.
|
||||||
|
*
|
||||||
|
* This function also accepts an ID of an object to check against if the capability is a meta capability. Meta
|
||||||
|
* capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to
|
||||||
|
* map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`.
|
||||||
|
*
|
||||||
|
* Example usage:
|
||||||
|
*
|
||||||
|
* $user->has_cap( 'edit_posts' );
|
||||||
|
* $user->has_cap( 'edit_post', $post->ID );
|
||||||
|
* $user->has_cap( 'edit_post_meta', $post->ID, $meta_key );
|
||||||
*
|
*
|
||||||
* While checking against a role in place of a capability is supported in part, this practice is discouraged as it
|
* While checking against a role in place of a capability is supported in part, this practice is discouraged as it
|
||||||
* may produce unreliable results.
|
* may produce unreliable results.
|
||||||
|
@ -721,12 +731,9 @@ class WP_User {
|
||||||
*
|
*
|
||||||
* @see map_meta_cap()
|
* @see map_meta_cap()
|
||||||
*
|
*
|
||||||
* @param string $cap Capability name.
|
* @param string $cap Capability name.
|
||||||
* @param int ...$object_id Optional. ID of a specific object to check against if `$cap` is a "meta" capability.
|
* @param mixed ...$args Optional further parameters, typically starting with an object ID.
|
||||||
* Meta capabilities such as `edit_post` and `edit_user` are capabilities used by
|
* @return bool Whether the user has the given capability, or, if an object ID is passed, whether the user has
|
||||||
* by the `map_meta_cap()` function to map to primitive capabilities that a user or
|
|
||||||
* role has, such as `edit_posts` and `edit_others_posts`.
|
|
||||||
* @return bool Whether the user has the given capability, or, if `$object_id` is passed, whether the user has
|
|
||||||
* the given capability for that object.
|
* the given capability for that object.
|
||||||
*/
|
*/
|
||||||
public function has_cap( $cap ) {
|
public function has_cap( $cap ) {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.3-alpha-45418';
|
$wp_version = '5.3-alpha-45419';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
|
Loading…
Reference in New Issue