Ticket #21120: map_meta_cap.patch
File map_meta_cap.patch, 1.3 KB (added by , 12 years ago) |
---|
-
wp-includes/capabilities.php
933 933 * 934 934 * @param string $cap Capability name. 935 935 * @param int $user_id User ID. 936 * @param bool $cache Cache the results 936 937 * @return array Actual capabilities for meta capability. 937 938 */ 938 function map_meta_cap( $cap, $user_id ) { 939 function map_meta_cap( $cap, $user_id, $cache = true ) { 940 static $_cache = array(); 941 if ( $cache && isset( $_cache[ $cap.$user_id ] ) ) 942 return $_cache[ $cap.$user_id ]; 943 939 944 $args = array_slice( func_get_args(), 2 ); 940 945 $caps = array(); 941 946 … … 1194 1199 $post_type_meta_caps = _post_type_meta_capabilities(); 1195 1200 if ( isset( $post_type_meta_caps[ $cap ] ) ) { 1196 1201 $args = array_merge( array( $post_type_meta_caps[ $cap ], $user_id ), $args ); 1197 return call_user_func_array( 'map_meta_cap', $args ); 1202 $_cache[ $cap.$user_id ] = call_user_func_array( 'map_meta_cap', $args ); 1203 return $_cache[ $cap.$user_id ]; 1198 1204 } 1199 1205 1200 1206 // If no meta caps match, return the original cap. 1201 1207 $caps[] = $cap; 1202 1208 } 1203 1209 1204 return apply_filters('map_meta_cap', $caps, $cap, $user_id, $args); 1210 $_cache[ $cap.$user_id ] = apply_filters('map_meta_cap', $caps, $cap, $user_id, $args); 1211 return $_cache[ $cap.$user_id ]; 1205 1212 } 1206 1213 1207 1214 /**