Changeset 10356 for trunk/src/bp-core/bp-core-caps.php
- Timestamp:
- 11/15/2015 07:57:03 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-caps.php
r10108 r10356 25 25 global $wp_roles; 26 26 27 // Sanity check on roles global variable 27 // Sanity check on roles global variable. 28 28 $roles = isset( $wp_roles->roles ) 29 29 ? $wp_roles->roles … … 64 64 global $wp_roles; 65 65 66 // Load roles if not set 66 // Load roles if not set. 67 67 if ( ! isset( $wp_roles ) ) { 68 68 $wp_roles = new WP_Roles(); 69 69 } 70 70 71 // Loop through available roles and add them 71 // Loop through available roles and add them. 72 72 foreach( $wp_roles->role_objects as $role ) { 73 73 foreach ( bp_get_caps_for_role( $role->name ) as $cap ) { … … 100 100 global $wp_roles; 101 101 102 // Load roles if not set 102 // Load roles if not set. 103 103 if ( ! isset( $wp_roles ) ) { 104 104 $wp_roles = new WP_Roles(); 105 105 } 106 106 107 // Loop through available roles and remove them 107 // Loop through available roles and remove them. 108 108 foreach( $wp_roles->role_objects as $role ) { 109 109 foreach ( bp_get_caps_for_role( $role->name ) as $cap ) { … … 136 136 * @param int $user_id See {@link WP_User::has_cap()}. 137 137 * @param mixed $args See {@link WP_User::has_cap()}. 138 *139 138 * @return array Actual capabilities for meta capability. See {@link WP_User::has_cap()}. 140 139 */ … … 165 164 function bp_get_community_caps() { 166 165 167 // Forum meta caps 166 // Forum meta caps. 168 167 $caps = array(); 169 168 … … 186 185 * 187 186 * @param string $role The role for which you're loading caps. 188 *189 187 * @return array Capabilities for $role. 190 188 */ … … 194 192 switch ( $role ) { 195 193 196 // Administrator 194 // Administrator. 197 195 case 'administrator' : 198 196 $caps = array( 199 // Misc 197 // Misc. 200 198 'bp_moderate', 201 199 ); … … 203 201 break; 204 202 205 // All other default WordPress blog roles 203 // All other default WordPress blog roles. 206 204 case 'editor' : 207 205 case 'author' : … … 243 241 function bp_set_current_user_default_role() { 244 242 245 // Bail if not multisite or not root blog 243 // Bail if not multisite or not root blog. 246 244 if ( ! is_multisite() || ! bp_is_root_blog() ) { 247 245 return; 248 246 } 249 247 250 // Bail if user is not logged in or already a member 248 // Bail if user is not logged in or already a member. 251 249 if ( ! is_user_logged_in() || is_user_member_of_blog() ) { 252 250 return; 253 251 } 254 252 255 // Bail if user is not active 253 // Bail if user is not active. 256 254 if ( bp_is_user_inactive() ) { 257 255 return; 258 256 } 259 257 260 // Set the current users default role 258 // Set the current users default role. 261 259 buddypress()->current_user->set_role( bp_get_option( 'default_role', 'subscriber' ) ); 262 260 } … … 274 272 * @type mixed $a,... Optional. Extra arguments applicable to the capability check. 275 273 * } 276 *277 274 * @return bool True if the user has the cap for the given parameters. 278 275 */ … … 292 289 } 293 290 294 // Use root blog if no ID passed 291 // Use root blog if no ID passed. 295 292 if ( empty( $blog_id ) ) { 296 293 $blog_id = bp_get_root_blog_id(); … … 341 338 * @param int $user_id ID of the user being checked against. 342 339 * @param array $args Miscellaneous arguments passed to the user_has_cap filter. 343 *344 340 * @return array $allcaps The user's cap list, with 'bp_moderate' appended, if relevant. 345 341 */ 346 342 function _bp_enforce_bp_moderate_cap_for_admins( $caps = array(), $cap = '', $user_id = 0, $args = array() ) { 347 343 348 // Bail if not checking the 'bp_moderate' cap 344 // Bail if not checking the 'bp_moderate' cap. 349 345 if ( 'bp_moderate' !== $cap ) { 350 346 return $caps; 351 347 } 352 348 353 // Bail if BuddyPress is not network activated 349 // Bail if BuddyPress is not network activated. 354 350 if ( bp_is_network_activated() ) { 355 351 return $caps; 356 352 } 357 353 358 // Never trust inactive users 354 // Never trust inactive users. 359 355 if ( bp_is_user_inactive( $user_id ) ) { 360 356 return $caps; 361 357 } 362 358 363 // Only users that can 'manage_options' on this site can 'bp_moderate' 359 // Only users that can 'manage_options' on this site can 'bp_moderate'. 364 360 return array( 'manage_options' ); 365 361 }
Note: See TracChangeset
for help on using the changeset viewer.