Version Description
Download this release
Release Info
Developer | shinephp |
Plugin | User Role Editor |
Version | 4.22 |
Comparing to | |
See all releases |
Code changes from version 4.21.1 to 4.22
- includes/class-ure-lib.php +30 -23
- includes/class-user-other-roles.php +9 -42
- includes/classes/bbpress.php +77 -0
- includes/loader.php +1 -0
- readme.txt +8 -2
- user-role-editor.php +2 -2
includes/class-ure-lib.php
CHANGED
@@ -35,6 +35,7 @@ class Ure_Lib extends Garvs_WP_Lib {
|
|
35 |
protected $capability_remove_html = '';
|
36 |
protected $advert = null;
|
37 |
protected $role_additional_options = null;
|
|
|
38 |
|
39 |
// when allow_edit_users_to_not_super_admin option is turned ON, we set this property to true
|
40 |
// when we raise single site admin permissions up to the superadmin for the 'Add new user' new-user.php page
|
@@ -54,6 +55,8 @@ class Ure_Lib extends Garvs_WP_Lib {
|
|
54 |
|
55 |
parent::__construct($options_id);
|
56 |
$this->debug = defined('URE_DEBUG') && (URE_DEBUG==1 || URE_DEBUG==true);
|
|
|
|
|
57 |
|
58 |
$this->upgrade();
|
59 |
}
|
@@ -761,28 +764,8 @@ if ($this->multisite && !is_network_admin()) {
|
|
761 |
$wp_roles = new WP_Roles();
|
762 |
}
|
763 |
|
764 |
-
if (
|
765 |
-
$this->roles =
|
766 |
-
$bbp_full_caps = bbp_get_caps_for_role(bbp_get_keymaster_role());
|
767 |
-
// exclude capabilities automatically added by bbPress bbp_dynamic_role_caps() and not bbPress related: read, level_0, all s2Member levels, e.g. access_s2member_level_0, etc.
|
768 |
-
$built_in_wp_caps = $this->get_built_in_wp_caps();
|
769 |
-
$bbp_only_caps = array();
|
770 |
-
foreach ($bbp_full_caps as $bbp_cap => $val) {
|
771 |
-
if (isset($built_in_wp_caps[$bbp_cap]) || substr($bbp_cap, 0, 15) == 'access_s2member') {
|
772 |
-
continue;
|
773 |
-
}
|
774 |
-
$bbp_only_caps[$bbp_cap] = $val;
|
775 |
-
}
|
776 |
-
// remove bbPress dynamically created capabilities from WordPress persistent roles in order to not save them to database with any role update
|
777 |
-
$cap_removed = false;
|
778 |
-
foreach ($bbp_only_caps as $bbp_cap => $val) {
|
779 |
-
foreach ($this->roles as &$role) {
|
780 |
-
if (isset($role['capabilities'][$bbp_cap])) {
|
781 |
-
unset($role['capabilities'][$bbp_cap]);
|
782 |
-
$cap_removed = true;
|
783 |
-
}
|
784 |
-
}
|
785 |
-
}
|
786 |
} else {
|
787 |
$this->roles = $wp_roles->roles;
|
788 |
}
|
@@ -955,6 +938,8 @@ if ($this->multisite && !is_network_admin()) {
|
|
955 |
* @return array
|
956 |
*/
|
957 |
public function get_built_in_wp_caps() {
|
|
|
|
|
958 |
$caps = array();
|
959 |
$caps['switch_themes'] = 1;
|
960 |
$caps['edit_themes'] = 1;
|
@@ -1011,7 +996,11 @@ if ($this->multisite && !is_network_admin()) {
|
|
1011 |
$caps['update_core'] = 1;
|
1012 |
$caps['list_users'] = 1;
|
1013 |
$caps['remove_users'] = 1;
|
1014 |
-
|
|
|
|
|
|
|
|
|
1015 |
$caps['promote_users'] = 1;
|
1016 |
$caps['edit_theme_options'] = 1;
|
1017 |
$caps['delete_themes'] = 1;
|
@@ -1579,6 +1568,23 @@ if ($this->multisite && !is_network_admin()) {
|
|
1579 |
// end of add_gravity_forms_caps()
|
1580 |
|
1581 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1582 |
/**
|
1583 |
* Provide compatibility with plugins and themes which define their custom user capabilities using
|
1584 |
* 'members_get_capabilities' filter from Members plugin
|
@@ -1708,6 +1714,7 @@ if ($this->multisite && !is_network_admin()) {
|
|
1708 |
$this->full_capabilities = array();
|
1709 |
$this->add_roles_caps();
|
1710 |
$this->add_gravity_forms_caps();
|
|
|
1711 |
$this->add_members_caps();
|
1712 |
$this->add_user_caps();
|
1713 |
$this->add_wordpress_caps();
|
35 |
protected $capability_remove_html = '';
|
36 |
protected $advert = null;
|
37 |
protected $role_additional_options = null;
|
38 |
+
protected $bbpress = null; // reference to the URE_bbPress class instance
|
39 |
|
40 |
// when allow_edit_users_to_not_super_admin option is turned ON, we set this property to true
|
41 |
// when we raise single site admin permissions up to the superadmin for the 'Add new user' new-user.php page
|
55 |
|
56 |
parent::__construct($options_id);
|
57 |
$this->debug = defined('URE_DEBUG') && (URE_DEBUG==1 || URE_DEBUG==true);
|
58 |
+
|
59 |
+
$this->bbpress = URE_bbPress::get_instance($this);
|
60 |
|
61 |
$this->upgrade();
|
62 |
}
|
764 |
$wp_roles = new WP_Roles();
|
765 |
}
|
766 |
|
767 |
+
if (!empty($this->bbpress)) { // bbPress plugin is active
|
768 |
+
$this->roles = $this->bbpress->get_roles();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
769 |
} else {
|
770 |
$this->roles = $wp_roles->roles;
|
771 |
}
|
938 |
* @return array
|
939 |
*/
|
940 |
public function get_built_in_wp_caps() {
|
941 |
+
$wp_version = get_bloginfo('version');
|
942 |
+
|
943 |
$caps = array();
|
944 |
$caps['switch_themes'] = 1;
|
945 |
$caps['edit_themes'] = 1;
|
996 |
$caps['update_core'] = 1;
|
997 |
$caps['list_users'] = 1;
|
998 |
$caps['remove_users'] = 1;
|
999 |
+
|
1000 |
+
if (version_compare($wp_version, '4.4', '<')) {
|
1001 |
+
$caps['add_users'] = 1; // removed from WP v. 4.4.
|
1002 |
+
}
|
1003 |
+
|
1004 |
$caps['promote_users'] = 1;
|
1005 |
$caps['edit_theme_options'] = 1;
|
1006 |
$caps['delete_themes'] = 1;
|
1568 |
// end of add_gravity_forms_caps()
|
1569 |
|
1570 |
|
1571 |
+
/**
|
1572 |
+
* Add bbPress plugin user capabilities (if available)
|
1573 |
+
*/
|
1574 |
+
protected function add_bbpress_caps() {
|
1575 |
+
|
1576 |
+
if (empty($this->bbpress)) {
|
1577 |
+
return;
|
1578 |
+
}
|
1579 |
+
|
1580 |
+
$caps = $this->bbpress->get_caps();
|
1581 |
+
foreach ($caps as $cap) {
|
1582 |
+
$this->add_capability_to_full_caps_list($cap);
|
1583 |
+
}
|
1584 |
+
}
|
1585 |
+
// end of add_bbpress_caps()
|
1586 |
+
|
1587 |
+
|
1588 |
/**
|
1589 |
* Provide compatibility with plugins and themes which define their custom user capabilities using
|
1590 |
* 'members_get_capabilities' filter from Members plugin
|
1714 |
$this->full_capabilities = array();
|
1715 |
$this->add_roles_caps();
|
1716 |
$this->add_gravity_forms_caps();
|
1717 |
+
$this->add_bbpress_caps();
|
1718 |
$this->add_members_caps();
|
1719 |
$this->add_user_caps();
|
1720 |
$this->add_wordpress_caps();
|
includes/class-user-other-roles.php
CHANGED
@@ -31,8 +31,6 @@ class URE_User_Other_Roles {
|
|
31 |
add_action( 'admin_enqueue_scripts', array($this, 'load_js' ) );
|
32 |
add_action( 'edit_user_profile', array($this, 'edit_user_profile_html'), 10, 1 );
|
33 |
add_action( 'user_new_form', array($this, 'user_new_form'), 10, 1 );
|
34 |
-
add_filter( 'manage_users_columns', array($this, 'user_role_column'), 10, 1 );
|
35 |
-
add_filter( 'manage_users_custom_column', array($this, 'user_role_row'), 10, 3 );
|
36 |
add_action( 'profile_update', array($this, 'update'), 10 );
|
37 |
}
|
38 |
if ($this->lib->multisite) {
|
@@ -211,6 +209,10 @@ class URE_User_Other_Roles {
|
|
211 |
if (!$this->lib->is_user_profile_extention_allowed()) {
|
212 |
return;
|
213 |
}
|
|
|
|
|
|
|
|
|
214 |
?>
|
215 |
<h3><?php esc_html_e('Additional Capabilities', 'user-role-editor'); ?></h3>
|
216 |
<?php
|
@@ -220,6 +222,11 @@ class URE_User_Other_Roles {
|
|
220 |
|
221 |
|
222 |
public function user_new_form($context) {
|
|
|
|
|
|
|
|
|
|
|
223 |
$user = new WP_User();
|
224 |
?>
|
225 |
<table>
|
@@ -231,47 +238,7 @@ class URE_User_Other_Roles {
|
|
231 |
}
|
232 |
// end of edit_user_profile_html()
|
233 |
|
234 |
-
|
235 |
-
/**
|
236 |
-
* add 'Other Roles' column to WordPress users list table
|
237 |
-
*
|
238 |
-
* @param array $columns WordPress users list table columns list
|
239 |
-
* @return array
|
240 |
-
*/
|
241 |
-
public function user_role_column($columns = array()) {
|
242 |
-
|
243 |
-
$columns['ure_roles'] = esc_html__('Other Roles', 'user-role-editor');
|
244 |
-
|
245 |
-
return $columns;
|
246 |
-
}
|
247 |
-
// end of user_role_column()
|
248 |
-
|
249 |
-
|
250 |
-
/**
|
251 |
-
* Return user's roles list for display in the WordPress Users list table
|
252 |
-
*
|
253 |
-
* @param string $retval
|
254 |
-
* @param string $column_name
|
255 |
-
* @param int $user_id
|
256 |
-
*
|
257 |
-
* @return string all user roles
|
258 |
-
*/
|
259 |
-
public function user_role_row($retval = '', $column_name = '', $user_id = 0) {
|
260 |
-
|
261 |
-
// Only looking for User Role Editor other user roles column
|
262 |
-
if ('ure_roles' == $column_name) {
|
263 |
-
$user = get_userdata($user_id);
|
264 |
-
// Get the users roles
|
265 |
-
$roles = $this->get_roles_array($user);
|
266 |
-
$retval = $this->lib->roles_text($roles);
|
267 |
-
}
|
268 |
-
|
269 |
-
// Pass retval through
|
270 |
-
return $retval;
|
271 |
-
}
|
272 |
-
// end of user_role_row()
|
273 |
|
274 |
-
|
275 |
// save additional user roles when user profile is updated, as WordPress itself doesn't know about them
|
276 |
public function update($user_id) {
|
277 |
|
31 |
add_action( 'admin_enqueue_scripts', array($this, 'load_js' ) );
|
32 |
add_action( 'edit_user_profile', array($this, 'edit_user_profile_html'), 10, 1 );
|
33 |
add_action( 'user_new_form', array($this, 'user_new_form'), 10, 1 );
|
|
|
|
|
34 |
add_action( 'profile_update', array($this, 'update'), 10 );
|
35 |
}
|
36 |
if ($this->lib->multisite) {
|
209 |
if (!$this->lib->is_user_profile_extention_allowed()) {
|
210 |
return;
|
211 |
}
|
212 |
+
$show = apply_filters('ure_show_additional_capabilities_section', true);
|
213 |
+
if (empty($show)) {
|
214 |
+
return;
|
215 |
+
}
|
216 |
?>
|
217 |
<h3><?php esc_html_e('Additional Capabilities', 'user-role-editor'); ?></h3>
|
218 |
<?php
|
222 |
|
223 |
|
224 |
public function user_new_form($context) {
|
225 |
+
$show = apply_filters('ure_show_additional_capabilities_section', true);
|
226 |
+
if (empty($show)) {
|
227 |
+
return;
|
228 |
+
}
|
229 |
+
|
230 |
$user = new WP_User();
|
231 |
?>
|
232 |
<table>
|
238 |
}
|
239 |
// end of edit_user_profile_html()
|
240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
|
|
|
242 |
// save additional user roles when user profile is updated, as WordPress itself doesn't know about them
|
243 |
public function update($user_id) {
|
244 |
|
includes/classes/bbpress.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Support for bbPress user roles and capabilities
|
4 |
+
*
|
5 |
+
* Project: User Role Editor WordPress plugin
|
6 |
+
* Author: Vladimir Garagulya
|
7 |
+
* Author email: vladimir@shinephp.com
|
8 |
+
* Author URI: http://shinephp.com
|
9 |
+
*
|
10 |
+
**/
|
11 |
+
|
12 |
+
class URE_bbPress {
|
13 |
+
|
14 |
+
public static $instance = null;
|
15 |
+
|
16 |
+
protected $lib = null;
|
17 |
+
|
18 |
+
|
19 |
+
protected function __construct(Ure_Lib $lib) {
|
20 |
+
|
21 |
+
$this->lib = $lib;
|
22 |
+
|
23 |
+
}
|
24 |
+
// end of __construct()
|
25 |
+
|
26 |
+
|
27 |
+
static public function get_instance(Ure_Lib $lib) {
|
28 |
+
if (!function_exists('bbp_filter_blog_editable_roles')) { // bbPress plugin is not active
|
29 |
+
return null;
|
30 |
+
}
|
31 |
+
|
32 |
+
if (self::$instance!==null) {
|
33 |
+
return self::$instance;
|
34 |
+
}
|
35 |
+
|
36 |
+
if ($lib->is_pro()) {
|
37 |
+
self::$instance = new URE_bbPress_Pro($lib);
|
38 |
+
} else {
|
39 |
+
self::$instance = new URE_bbPress($lib);
|
40 |
+
}
|
41 |
+
|
42 |
+
return self::$instance;
|
43 |
+
}
|
44 |
+
// end of get_instance()
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Exclude roles created by bbPress
|
49 |
+
*
|
50 |
+
* @global array $wp_roles
|
51 |
+
* @return array
|
52 |
+
*/
|
53 |
+
public function get_roles() {
|
54 |
+
|
55 |
+
global $wp_roles;
|
56 |
+
|
57 |
+
$roles = bbp_filter_blog_editable_roles($wp_roles->roles); // exclude bbPress roles
|
58 |
+
|
59 |
+
return $roles;
|
60 |
+
}
|
61 |
+
// end of get_roles()
|
62 |
+
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Get full list user capabilities created by bbPress
|
66 |
+
*
|
67 |
+
* @return array
|
68 |
+
*/
|
69 |
+
public function get_caps() {
|
70 |
+
$caps = array_keys(bbp_get_caps_for_role(bbp_get_keymaster_role()));
|
71 |
+
|
72 |
+
return $caps;
|
73 |
+
}
|
74 |
+
// end of get_caps()
|
75 |
+
|
76 |
+
}
|
77 |
+
// end of URE_bbPress class
|
includes/loader.php
CHANGED
@@ -10,6 +10,7 @@
|
|
10 |
|
11 |
require_once(URE_PLUGIN_DIR .'includes/define-constants.php');
|
12 |
require_once(URE_PLUGIN_DIR .'includes/misc-support-stuff.php');
|
|
|
13 |
require_once(URE_PLUGIN_DIR .'includes/class-assign-role.php');
|
14 |
require_once(URE_PLUGIN_DIR .'includes/class-user-other-roles.php');
|
15 |
require_once(URE_PLUGIN_DIR .'includes/class-protect-admin.php');
|
10 |
|
11 |
require_once(URE_PLUGIN_DIR .'includes/define-constants.php');
|
12 |
require_once(URE_PLUGIN_DIR .'includes/misc-support-stuff.php');
|
13 |
+
require_once(URE_PLUGIN_DIR .'includes/classes/bbpress.php');
|
14 |
require_once(URE_PLUGIN_DIR .'includes/class-assign-role.php');
|
15 |
require_once(URE_PLUGIN_DIR .'includes/class-user-other-roles.php');
|
16 |
require_once(URE_PLUGIN_DIR .'includes/class-protect-admin.php');
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: shinephp
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=vladimir%40shinephp%2ecom&lc=RU&item_name=ShinePHP%2ecom&item_number=User%20Role%20Editor%20WordPress%20plugin¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
|
4 |
Tags: user, role, editor, security, access, permission, capability
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to: 4.4
|
7 |
-
Stable tag: 4.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -76,6 +76,12 @@ If you wish to check available translations or help with plugin translation to y
|
|
76 |
https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
|
77 |
|
78 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
= [4.21.1] 16.12.2015 =
|
80 |
* Fix: 'Update' button did not work at User's Capabilities page due to confirmation dialog call error.
|
81 |
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=vladimir%40shinephp%2ecom&lc=RU&item_name=ShinePHP%2ecom&item_number=User%20Role%20Editor%20WordPress%20plugin¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
|
4 |
Tags: user, role, editor, security, access, permission, capability
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 4.4.1
|
7 |
+
Stable tag: 4.22
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
76 |
https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
|
77 |
|
78 |
== Changelog ==
|
79 |
+
= [4.22] 15.01.2016 =
|
80 |
+
* Unused 'add_users' capability was removed from the list of core capabilities as it was removed from WordPress starting from version 4.4
|
81 |
+
* bbPress user capabilities are supported for use in the non-bbPress roles. You can not edit roles created by bbPress, as bbPress re-creates them dynamically for every request to the server. Full support for bbPress roles editing will be included into User Role Editor Pro version 4.22.
|
82 |
+
* Self-added "Other Roles" column removed from "Users" list, as WordPress started to show all roles assigned to the user in its own "Role" column.
|
83 |
+
* 'ure_show_additional_capabilities_section' filter allows to hide 'Other Roles' section at the 'Add new user', 'Edit user' pages.
|
84 |
+
|
85 |
= [4.21.1] 16.12.2015 =
|
86 |
* Fix: 'Update' button did not work at User's Capabilities page due to confirmation dialog call error.
|
87 |
|
user-role-editor.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: User Role Editor
|
4 |
Plugin URI: https://www.role-editor.com
|
5 |
Description: Change/add/delete WordPress user roles and capabilities.
|
6 |
-
Version: 4.
|
7 |
Author: Vladimir Garagulya
|
8 |
Author URI: https://www.role-editor.com
|
9 |
Text Domain: ure
|
@@ -23,7 +23,7 @@ if (defined('URE_PLUGIN_URL')) {
|
|
23 |
wp_die('It seems that other version of User Role Editor is active. Please deactivate it before use this version');
|
24 |
}
|
25 |
|
26 |
-
define('URE_VERSION', '4.
|
27 |
define('URE_PLUGIN_URL', plugin_dir_url(__FILE__));
|
28 |
define('URE_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
29 |
define('URE_PLUGIN_BASE_NAME', plugin_basename(__FILE__));
|
3 |
Plugin Name: User Role Editor
|
4 |
Plugin URI: https://www.role-editor.com
|
5 |
Description: Change/add/delete WordPress user roles and capabilities.
|
6 |
+
Version: 4.22
|
7 |
Author: Vladimir Garagulya
|
8 |
Author URI: https://www.role-editor.com
|
9 |
Text Domain: ure
|
23 |
wp_die('It seems that other version of User Role Editor is active. Please deactivate it before use this version');
|
24 |
}
|
25 |
|
26 |
+
define('URE_VERSION', '4.22');
|
27 |
define('URE_PLUGIN_URL', plugin_dir_url(__FILE__));
|
28 |
define('URE_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
29 |
define('URE_PLUGIN_BASE_NAME', plugin_basename(__FILE__));
|