Changeset 45622
- Timestamp:
- 07/11/2019 11:45:22 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/capabilities.php
r45590 r45622 34 34 * @return array Actual capabilities for meta capability. 35 35 */ 36 function map_meta_cap( $cap, $user_id ) { 37 $args = array_slice( func_get_args(), 2 ); 36 function map_meta_cap( $cap, $user_id, ...$args ) { 38 37 $caps = array(); 39 38 … … 650 649 * passed, whether the current user has the given meta capability for the given object. 651 650 */ 652 function current_user_can( $capability ) {651 function current_user_can( $capability, ...$args ) { 653 652 $current_user = wp_get_current_user(); 654 653 … … 657 656 } 658 657 659 $args = array_slice( func_get_args(), 1 ); 660 $args = array_merge( array( $capability ), $args ); 661 662 return call_user_func_array( array( $current_user, 'has_cap' ), $args ); 658 return $current_user->has_cap( $capability, ...$args ); 663 659 } 664 660 … … 683 679 * @return bool Whether the user has the given capability. 684 680 */ 685 function current_user_can_for_blog( $blog_id, $capability ) {681 function current_user_can_for_blog( $blog_id, $capability, ...$args ) { 686 682 $switched = is_multisite() ? switch_to_blog( $blog_id ) : false; 687 683 … … 695 691 } 696 692 697 $args = array_slice( func_get_args(), 2 ); 698 $args = array_merge( array( $capability ), $args ); 699 700 $can = call_user_func_array( array( $current_user, 'has_cap' ), $args ); 693 $can = $current_user->has_cap( $capability, ...$args ); 701 694 702 695 if ( $switched ) { … … 727 720 * @return bool Whether the post author has the given capability. 728 721 */ 729 function author_can( $post, $capability ) {722 function author_can( $post, $capability, ...$args ) { 730 723 $post = get_post( $post ); 731 724 if ( ! $post ) { … … 739 732 } 740 733 741 $args = array_slice( func_get_args(), 2 ); 742 $args = array_merge( array( $capability ), $args ); 743 744 return call_user_func_array( array( $author, 'has_cap' ), $args ); 734 return $author->has_cap( $capability, ...$args ); 745 735 } 746 736 … … 765 755 * @return bool Whether the user has the given capability. 766 756 */ 767 function user_can( $user, $capability ) {757 function user_can( $user, $capability, ...$args ) { 768 758 if ( ! is_object( $user ) ) { 769 759 $user = get_userdata( $user ); … … 774 764 } 775 765 776 $args = array_slice( func_get_args(), 2 ); 777 $args = array_merge( array( $capability ), $args ); 778 779 return call_user_func_array( array( $user, 'has_cap' ), $args ); 766 return $user->has_cap( $capability, ...$args ); 780 767 } 781 768
Note: See TracChangeset
for help on using the changeset viewer.