Changeset 45419
- Timestamp:
- 05/25/2019 10:26:22 PM (5 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/capabilities.php
r44976 r45419 8 8 9 9 /** 10 * Map meta capabilities to primitive capabilities. 10 * Maps meta capabilities to primitive capabilities. 11 * 12 * This function also accepts an ID of an object to map against if the capability is a meta capability. Meta 13 * capabilities such as `edit_post` and `edit_user` are capabilities used by this function to map to primitive 14 * capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`. 15 * 16 * Example usage: 17 * 18 * map_meta_cap( 'edit_posts', $user->ID ); 19 * map_meta_cap( 'edit_post', $user->ID, $post->ID ); 20 * map_meta_cap( 'edit_post_meta', $user->ID, $post->ID, $meta_key ); 11 21 * 12 22 * This does not actually compare whether the user ID has the actual capability, … … 19 29 * @global array $post_type_meta_caps Used to get post type meta capabilities. 20 30 * 21 * @param string $cap Capability name. 22 * @param int $user_id User ID. 23 * @param int $object_id Optional. ID of the specific object to check against if `$cap` is a "meta" cap. 24 * "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used 25 * by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts', 26 * 'edit_others_posts', etc. The parameter is accessed via func_get_args(). 31 * @param string $cap Capability name. 32 * @param int $user_id User ID. 33 * @param mixed ...$args Optional further parameters, typically starting with an object ID. 27 34 * @return array Actual capabilities for meta capability. 28 35 */ … … 616 623 617 624 /** 618 * Whether the current user has a specific capability. 625 * Returns whether the current user has the specified capability. 626 * 627 * This function also accepts an ID of an object to check against if the capability is a meta capability. Meta 628 * capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to 629 * map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`. 630 * 631 * Example usage: 632 * 633 * current_user_can( 'edit_posts' ); 634 * current_user_can( 'edit_post', $post->ID ); 635 * current_user_can( 'edit_post_meta', $post->ID, $meta_key ); 619 636 * 620 637 * While checking against particular roles in place of a capability is supported … … 629 646 * 630 647 * @param string $capability Capability name. 631 * @param int $object_id Optional. ID of the specific object to check against if `$capability` is a "meta" cap. 632 * "Meta" capabilities, e.g. 'edit_post', 'edit_user', etc., are capabilities used 633 * by map_meta_cap() to map to other "primitive" capabilities, e.g. 'edit_posts', 634 * 'edit_others_posts', etc. Accessed via func_get_args() and passed to WP_User::has_cap(), 635 * then map_meta_cap(). 648 * @param mixed ...$args Optional further parameters, typically starting with an object ID. 636 649 * @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is 637 650 * passed, whether the current user has the given meta capability for the given object. … … 651 664 652 665 /** 653 * Whether the current user has a specific capability for a given site. 666 * Returns whether the current user has the specified capability for a given site. 667 * 668 * This function also accepts an ID of an object to check against if the capability is a meta capability. Meta 669 * capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to 670 * map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`. 671 * 672 * Example usage: 673 * 674 * current_user_can_for_blog( $blog_id, 'edit_posts' ); 675 * current_user_can_for_blog( $blog_id, 'edit_post', $post->ID ); 676 * current_user_can_for_blog( $blog_id, 'edit_post_meta', $post->ID, $meta_key ); 654 677 * 655 678 * @since 3.0.0 … … 657 680 * @param int $blog_id Site ID. 658 681 * @param string $capability Capability name. 682 * @param mixed ...$args Optional further parameters, typically starting with an object ID. 659 683 * @return bool Whether the user has the given capability. 660 684 */ … … 684 708 685 709 /** 686 * Whether the author of the supplied post has a specific capability. 710 * Returns whether the author of the supplied post has the specified capability. 711 * 712 * This function also accepts an ID of an object to check against if the capability is a meta capability. Meta 713 * capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to 714 * map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`. 715 * 716 * Example usage: 717 * 718 * author_can( $post, 'edit_posts' ); 719 * author_can( $post, 'edit_post', $post->ID ); 720 * author_can( $post, 'edit_post_meta', $post->ID, $meta_key ); 687 721 * 688 722 * @since 2.9.0 … … 690 724 * @param int|WP_Post $post Post ID or post object. 691 725 * @param string $capability Capability name. 726 * @param mixed ...$args Optional further parameters, typically starting with an object ID. 692 727 * @return bool Whether the post author has the given capability. 693 728 */ … … 710 745 711 746 /** 712 * Whether a particular user has a specific capability. 747 * Returns whether a particular user has the specified capability. 748 * 749 * This function also accepts an ID of an object to check against if the capability is a meta capability. Meta 750 * capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to 751 * map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`. 752 * 753 * Example usage: 754 * 755 * user_can( $user->ID, 'edit_posts' ); 756 * user_can( $user->ID, 'edit_post', $post->ID ); 757 * user_can( $user->ID, 'edit_post_meta', $post->ID, $meta_key ); 713 758 * 714 759 * @since 3.1.0 … … 716 761 * @param int|WP_User $user User ID or object. 717 762 * @param string $capability Capability name. 763 * @param mixed ...$args Optional further parameters, typically starting with an object ID. 718 764 * @return bool Whether the user has the given capability. 719 765 */ -
trunk/src/wp-includes/class-wp-user.php
r45418 r45419 713 713 714 714 /** 715 * Whether the user has a specific capability. 715 * Returns whether the user has the specified capability. 716 * 717 * This function also accepts an ID of an object to check against if the capability is a meta capability. Meta 718 * capabilities such as `edit_post` and `edit_user` are capabilities used by the `map_meta_cap()` function to 719 * map to primitive capabilities that a user or role has, such as `edit_posts` and `edit_others_posts`. 720 * 721 * Example usage: 722 * 723 * $user->has_cap( 'edit_posts' ); 724 * $user->has_cap( 'edit_post', $post->ID ); 725 * $user->has_cap( 'edit_post_meta', $post->ID, $meta_key ); 716 726 * 717 727 * While checking against a role in place of a capability is supported in part, this practice is discouraged as it … … 722 732 * @see map_meta_cap() 723 733 * 724 * @param string $cap Capability name. 725 * @param int ...$object_id Optional. ID of a specific object to check against if `$cap` is a "meta" capability. 726 * Meta capabilities such as `edit_post` and `edit_user` are capabilities used by 727 * by the `map_meta_cap()` function to map to primitive capabilities that a user or 728 * role has, such as `edit_posts` and `edit_others_posts`. 729 * @return bool Whether the user has the given capability, or, if `$object_id` is passed, whether the user has 734 * @param string $cap Capability name. 735 * @param mixed ...$args Optional further parameters, typically starting with an object ID. 736 * @return bool Whether the user has the given capability, or, if an object ID is passed, whether the user has 730 737 * the given capability for that object. 731 738 */
Note: See TracChangeset
for help on using the changeset viewer.