Changeset 50490 for trunk/src/wp-includes/capabilities.php
- Timestamp:
- 03/04/2021 12:12:55 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/capabilities.php
r50138 r50490 680 680 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter 681 681 * by adding it to the function signature. 682 * @since 5.8.0 Converted to wrapper for the user_can() function. 682 683 * 683 684 * @see WP_User::has_cap() … … 690 691 */ 691 692 function current_user_can( $capability, ...$args ) { 692 $current_user = wp_get_current_user(); 693 694 if ( empty( $current_user ) ) { 695 return false; 696 } 697 698 return $current_user->has_cap( $capability, ...$args ); 693 return user_can( wp_get_current_user(), $capability, ...$args ); 699 694 } 700 695 … … 715 710 * @since 5.3.0 Formalized the existing and already documented `...$args` parameter 716 711 * by adding it to the function signature. 712 * @since 5.8.0 Wraps current_user_can() after switching to blog. 717 713 * 718 714 * @param int $blog_id Site ID. … … 724 720 $switched = is_multisite() ? switch_to_blog( $blog_id ) : false; 725 721 726 $current_user = wp_get_current_user(); 727 728 if ( empty( $current_user ) ) { 729 if ( $switched ) { 730 restore_current_blog(); 731 } 732 return false; 733 } 734 735 $can = $current_user->has_cap( $capability, ...$args ); 722 $can = current_user_can( $capability, ...$args ); 736 723 737 724 if ( $switched ) { … … 806 793 } 807 794 808 if ( ! $user || ! $user->exists() ) { 809 return false; 795 if ( empty( $user ) ) { 796 // User is logged out, create anonymous user object. 797 $user = new WP_User( 0 ); 798 $user->init( new stdClass ); 810 799 } 811 800
Note: See TracChangeset
for help on using the changeset viewer.