<?php /** * Support for bbPress user roles and capabilities * * Project: User Role Editor WordPress plugin * Author: Vladimir Garagulya * Author email: vladimir@shinephp.com * Author URI: http://shinephp.com * **/ class URE_bbPress { protected $bbpress_detected = false; public function __construct() { add_action('plugins_loaded', array($this, 'detect_bbpress'), 8 ); } // end of __construct() public function detect_bbpress() { $this->bbpress_detected = false; if ( function_exists('bbp_filter_blog_editable_roles') ) { $this->bbpress_detected = true; // bbPress plugin is installed and active } } // end of detect_bbpress() public function is_active() { return $this->bbpress_detected; } // end of is_active() /** * Exclude roles created by bbPress * * @global array $wp_roles * @return array */ public function get_roles() { $wp_roles = wp_roles(); if ($this->bbpress_detected) { $roles = bbp_filter_blog_editable_roles( $wp_roles->roles ); // exclude bbPress roles } else { $roles = $wp_roles->roles; } return $roles; } // end of get_roles() /** * Get full list user capabilities created by bbPress * * @return array */ public function get_caps() { if ( $this->bbpress_detected ) { $caps = array_keys( bbp_get_caps_for_role( bbp_get_keymaster_role() ) ); } else { $caps = array(); } return $caps; } // end of get_caps() /** * Return empty array in order do not include bbPress roles into selectable lists: supported by Pro version only * @return array */ public function get_bbp_editable_roles() { $all_bbp_roles = array(); return $all_bbp_roles; } // end of get_bbp_editable_roles() /** * Return bbPress roles found at $roles array. Used to exclude bbPress roles from processing as free version should not support them * * @param array $roles * @return array */ public function extract_bbp_roles($roles) { $user_bbp_roles = array(); if ( $this->bbpress_detected ) { $all_bbp_roles = array_keys( bbp_get_dynamic_roles() ); foreach( $roles as $role ) { if ( in_array( $role, $all_bbp_roles ) ) { $user_bbp_roles[] = $role; } } } return $user_bbp_roles; } // end of extract_bbp_roles() } // end of URE_bbPress class
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
admin-notice.php | File | 833 B | 0644 |
|
advertisement.php | File | 2.58 KB | 0644 |
|
ajax-processor.php | File | 10.92 KB | 0644 |
|
assign-role.php | File | 5.68 KB | 0644 |
|
base-lib.php | File | 11.04 KB | 0644 |
|
bbpress.php | File | 2.81 KB | 0644 |
|
capabilities-groups-manager.php | File | 17.76 KB | 0644 |
|
capabilities.php | File | 15.09 KB | 0644 |
|
capability.php | File | 8.14 KB | 0644 |
|
editor.php | File | 56.29 KB | 0644 |
|
grant-roles.php | File | 19.88 KB | 0644 |
|
known-js-css-compatibility-issues.php | File | 2.59 KB | 0644 |
|
lib.php | File | 17.6 KB | 0644 |
|
own-capabilities.php | File | 5.22 KB | 0644 |
|
protect-admin.php | File | 8.01 KB | 0644 |
|
role-additional-options.php | File | 4.02 KB | 0644 |
|
role-view.php | File | 17.06 KB | 0644 |
|
screen-help.php | File | 5.77 KB | 0644 |
|
settings.php | File | 9.03 KB | 0644 |
|
task-queue.php | File | 3.94 KB | 0644 |
|
tools.php | File | 3.77 KB | 0644 |
|
uninstall.php | File | 2.62 KB | 0644 |
|
user-other-roles.php | File | 13.59 KB | 0644 |
|
user-role-editor.php | File | 37.1 KB | 0644 |
|
user-view.php | File | 8.09 KB | 0644 |
|
view.php | File | 13.86 KB | 0644 |
|
woocommerce-capabilities.php | File | 5.8 KB | 0644 |
|