Ticket #14602: user_can.diff
| File user_can.diff, 1.6 KB (added by simonwheatley, 3 years ago) |
|---|
-
wp-includes/capabilities.php
1061 1061 if ( empty( $current_user ) ) 1062 1062 return false; 1063 1063 1064 $args = array_slice( func_get_args(), 1 ); 1065 $args = array_merge( array( $capability ), $args ); 1066 1067 return call_user_func_array( array( &$current_user, 'has_cap' ), $args ); 1064 return user_can( $current_user, $capability ); 1068 1065 } 1069 1066 1070 1067 /** … … 1091 1088 // Set the blog id. @todo add blog id arg to WP_User constructor? 1092 1089 $user->for_blog( $blog_id ); 1093 1090 1094 $args = array_slice( func_get_args(), 2 ); 1095 $args = array_merge( array( $capability ), $args ); 1096 1097 return call_user_func_array( array( &$user, 'has_cap' ), $args ); 1091 return user_can( $user, $capability ); 1098 1092 } 1099 1093 1100 1094 /** … … 1110 1104 if ( !$post = get_post($post) ) 1111 1105 return false; 1112 1106 1113 $author = new WP_User( $post->post_author ); 1107 return user_can( $post->post_author, $capability ); 1108 } 1114 1109 1115 if ( empty( $author->ID ) ) 1110 /** 1111 * Whether a user has capability or role. 1112 * 1113 * @param int|object $user The ID for a user or a WP_User object 1114 * @param string $capability Capability or role name. 1115 * @return bool 1116 **/ 1117 function user_can( $user, $capability ) { 1118 if ( ! is_object( $user ) ) 1119 $user = new WP_User( $user ); 1120 1121 if ( ! $user || ! $user->ID ) 1116 1122 return false; 1117 1123 1118 1124 $args = array_slice( func_get_args(), 2 ); 1119 1125 $args = array_merge( array( $capability ), $args ); 1120 1126 1121 return call_user_func_array( array( &$ author, 'has_cap' ), $args );1127 return call_user_func_array( array( &$user, 'has_cap' ), $args ); 1122 1128 } 1123 1129 1124 1130 /**
