User Role Editor - Version 4.48

Version Description

Download this release

Release Info

Developer shinephp
Plugin Icon 128x128 User Role Editor
Version 4.48
Comparing to
See all releases

Code changes from version 4.47 to 4.48

changelog.txt CHANGED
@@ -1,5 +1,18 @@
1
  CHANGES LOG (full version).
2
  ===========================
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  = [4.46] 20.09.2018
4
  * Update: "Users" page, "Without role" button: underlying SQL queries were replaced with more robust versions (about 10 times faster).
5
  It is critical for sites with large quant of users.New query does not take into account though some cases with incorrect users data (usually imported from the external sources).
1
  CHANGES LOG (full version).
2
  ===========================
3
+
4
+ = [4.48] 03.01.2019 =
5
+ * Update: Multisite: Sites list is not requested from the database on every page opened in order to reduce server load.
6
+ * Update: URE plugin version update routine is called now at the wp-admin backend only.
7
+ * Update: Direct access to URE_Lib::bbpress property was excluded as a preparation to future code enhancements.
8
+
9
+ = [4.47] 12.11.2018 =
10
+ * Fix: "Users->User Role Editor": Capabilities view was not refreshed properly for new selected role in case "Granted Only" filter was turned ON before other role selection.
11
+ * Update: Unused code was removed from user-role-editor/includes/classes/bbpress.php
12
+ * Update: Prevent sudden revoke role 'administrator' from a user(s) during capability with the same ID ('administrator') deletion from roles.
13
+ * Update: Adding custom capability with ID 'administrator' was prohibited.
14
+ * Update: Marked as compatible with WordPress version 5.0
15
+
16
  = [4.46] 20.09.2018
17
  * Update: "Users" page, "Without role" button: underlying SQL queries were replaced with more robust versions (about 10 times faster).
18
  It is critical for sites with large quant of users.New query does not take into account though some cases with incorrect users data (usually imported from the external sources).
includes/classes/base-lib.php CHANGED
@@ -18,7 +18,6 @@ class URE_Base_Lib {
18
  protected $options = array(); // plugin options data
19
  protected $multisite = false;
20
  protected $active_for_network = false;
21
- protected $blog_ids = null;
22
  protected $main_blog_id = 0;
23
 
24
 
@@ -40,7 +39,6 @@ class URE_Base_Lib {
40
 
41
  $this->multisite = function_exists('is_multisite') && is_multisite();
42
  if ($this->multisite) {
43
- $this->blog_ids = $this->get_blog_ids();
44
  // get Id of the 1st (main) blog
45
  $this->main_blog_id = $this->get_main_site();
46
  }
@@ -183,6 +181,7 @@ class URE_Base_Lib {
183
  }
184
  // end of get_request_var()
185
 
 
186
  /**
187
  * returns option value for option with name in $option_name
188
  */
18
  protected $options = array(); // plugin options data
19
  protected $multisite = false;
20
  protected $active_for_network = false;
 
21
  protected $main_blog_id = 0;
22
 
23
 
39
 
40
  $this->multisite = function_exists('is_multisite') && is_multisite();
41
  if ($this->multisite) {
 
42
  // get Id of the 1st (main) blog
43
  $this->main_blog_id = $this->get_main_site();
44
  }
181
  }
182
  // end of get_request_var()
183
 
184
+
185
  /**
186
  * returns option value for option with name in $option_name
187
  */
includes/classes/lib.php CHANGED
@@ -52,17 +52,25 @@ class URE_Lib extends URE_Base_Lib {
52
  protected function __construct($options_id) {
53
 
54
  parent::__construct($options_id);
 
55
  $this->debug = defined('URE_DEBUG') && (URE_DEBUG==1 || URE_DEBUG==true);
56
-
57
- if ($this->is_pro()) {
58
- $this->bbpress = new URE_bbPress_Pro();
59
- } else {
 
 
 
 
 
 
60
  $this->bbpress = new URE_bbPress();
61
  }
62
 
63
- $this->upgrade();
 
64
  }
65
- // end of __construct()
66
 
67
 
68
  public static function get_instance($options_id = '') {
@@ -82,6 +90,10 @@ class URE_Lib extends URE_Base_Lib {
82
 
83
  protected function upgrade() {
84
 
 
 
 
 
85
  $ure_version = $this->get_option('ure_version', '0');
86
  if (version_compare( $ure_version, URE_VERSION, '<' ) ) {
87
  // put version upgrade stuff here
@@ -203,7 +215,7 @@ class URE_Lib extends URE_Base_Lib {
203
 
204
 
205
  /**
206
- * return front-end according to the context - role or user editor
207
  */
208
  public function editor() {
209
 
@@ -478,7 +490,9 @@ class URE_Lib extends URE_Base_Lib {
478
 
479
 
480
  public function get_default_role() {
 
481
  $this->wp_default_role = get_option('default_role');
 
482
  }
483
  // end of get_default_role()
484
 
@@ -584,8 +598,9 @@ class URE_Lib extends URE_Base_Lib {
584
  */
585
  public function get_user_roles() {
586
 
587
- if ($this->bbpress->is_active()) { // bbPress plugin is active
588
- $this->roles = $this->bbpress->get_roles();
 
589
  } else {
590
  $wp_roles = wp_roles();
591
  $this->roles = $wp_roles->roles;
@@ -609,11 +624,12 @@ class URE_Lib extends URE_Base_Lib {
609
  if (empty($this->roles)) {
610
  $this->get_user_roles();
611
  }
612
- if ($this->bbpress->is_active()) {
 
613
  remove_filter('editable_roles', 'bbp_filter_blog_editable_roles');
614
  }
615
  $roles = apply_filters('editable_roles', $this->roles);
616
- if ($this->bbpress->is_active()) {
617
  add_filter('editable_roles', 'bbp_filter_blog_editable_roles');
618
  }
619
 
@@ -942,11 +958,12 @@ class URE_Lib extends URE_Base_Lib {
942
  */
943
  protected function add_bbpress_caps() {
944
 
945
- if (!$this->bbpress->is_active()) {
 
946
  return;
947
  }
948
-
949
- $caps = $this->bbpress->get_caps();
950
  foreach ($caps as $cap) {
951
  $this->add_capability_to_full_caps_list($cap);
952
  }
@@ -1262,7 +1279,8 @@ class URE_Lib extends URE_Base_Lib {
1262
  }
1263
 
1264
  $serialized_roles = serialize($this->roles);
1265
- foreach ($this->blog_ids as $blog_id) {
 
1266
  $prefix = $wpdb->get_blog_prefix($blog_id);
1267
  $options_table_name = $prefix . 'options';
1268
  $option_name = $prefix . 'user_roles';
@@ -1300,7 +1318,8 @@ class URE_Lib extends URE_Base_Lib {
1300
 
1301
  $result = true;
1302
  $old_blog = $wpdb->blogid;
1303
- foreach ($this->blog_ids as $blog_id) {
 
1304
  switch_to_blog($blog_id);
1305
  $this->roles = $this->get_user_roles();
1306
  if (!isset($this->roles[$this->current_role])) { // add new role to this blog
52
  protected function __construct($options_id) {
53
 
54
  parent::__construct($options_id);
55
+
56
  $this->debug = defined('URE_DEBUG') && (URE_DEBUG==1 || URE_DEBUG==true);
57
+ $this->get_bbpress();
58
+ $this->upgrade();
59
+
60
+ }
61
+ // end of __construct()
62
+
63
+
64
+ protected function get_bbpress() {
65
+
66
+ if ($this->bbpress===null) {
67
  $this->bbpress = new URE_bbPress();
68
  }
69
 
70
+ return $this->bbpress;
71
+
72
  }
73
+ // end of get_bbpress()
74
 
75
 
76
  public static function get_instance($options_id = '') {
90
 
91
  protected function upgrade() {
92
 
93
+ if (!is_admin()) {
94
+ return;
95
+ }
96
+
97
  $ure_version = $this->get_option('ure_version', '0');
98
  if (version_compare( $ure_version, URE_VERSION, '<' ) ) {
99
  // put version upgrade stuff here
215
 
216
 
217
  /**
218
+ * Show main page according to the context - role or user editor
219
  */
220
  public function editor() {
221
 
490
 
491
 
492
  public function get_default_role() {
493
+
494
  $this->wp_default_role = get_option('default_role');
495
+
496
  }
497
  // end of get_default_role()
498
 
598
  */
599
  public function get_user_roles() {
600
 
601
+ $bbpress = $this->get_bbpress();
602
+ if ($bbpress->is_active()) { // bbPress plugin is active
603
+ $this->roles = $bbpress->get_roles();
604
  } else {
605
  $wp_roles = wp_roles();
606
  $this->roles = $wp_roles->roles;
624
  if (empty($this->roles)) {
625
  $this->get_user_roles();
626
  }
627
+ $bbpress = $this->get_bbpress();
628
+ if ($bbpress->is_active()) {
629
  remove_filter('editable_roles', 'bbp_filter_blog_editable_roles');
630
  }
631
  $roles = apply_filters('editable_roles', $this->roles);
632
+ if ($bbpress->is_active()) {
633
  add_filter('editable_roles', 'bbp_filter_blog_editable_roles');
634
  }
635
 
958
  */
959
  protected function add_bbpress_caps() {
960
 
961
+ $bbpress = $this->get_bbpress();
962
+ if (!$bbpress->is_active()) {
963
  return;
964
  }
965
+
966
+ $caps = $bbpress->get_caps();
967
  foreach ($caps as $cap) {
968
  $this->add_capability_to_full_caps_list($cap);
969
  }
1279
  }
1280
 
1281
  $serialized_roles = serialize($this->roles);
1282
+ $blog_ids = $this->get_blog_ids();
1283
+ foreach ($blog_ids as $blog_id) {
1284
  $prefix = $wpdb->get_blog_prefix($blog_id);
1285
  $options_table_name = $prefix . 'options';
1286
  $option_name = $prefix . 'user_roles';
1318
 
1319
  $result = true;
1320
  $old_blog = $wpdb->blogid;
1321
+ $blog_ids = $this->get_blog_ids();
1322
+ foreach ($blog_ids as $blog_id) {
1323
  switch_to_blog($blog_id);
1324
  $this->roles = $this->get_user_roles();
1325
  if (!isset($this->roles[$this->current_role])) { // add new role to this blog
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&currency_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: 5.0
7
- Stable tag: 4.47
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -79,6 +79,11 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
79
 
80
 
81
  == Changelog =
 
 
 
 
 
82
  = [4.47] 12.11.2018 =
83
  * Fix: "Users->User Role Editor": Capabilities view was not refreshed properly for new selected role in case "Granted Only" filter was turned ON before other role selection.
84
  * Update: Unused code was removed from user-role-editor/includes/classes/bbpress.php
@@ -95,43 +100,6 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
95
  * Update: URE settings page template: HTML helper checked() is used where applicable.
96
  * Fix: 2 spelling mistakes were fixed in the text labels.
97
 
98
- = [4.45] 18.08.2018 =
99
- * Fix: Capability checkbox was shown as turned ON incorrectly for not granted capability included into a role, JSON: "caps":{"sample_cap":"false"}. Bug took place after the changing a currently selected role.
100
- * Fix: Custom capabilities groups "User Role Editor" and "WooCommerce" were registered at the wrong 3rd tree level - changed to 2.
101
-
102
- = [4.44] 05.07.2018 =
103
- * Update: URE had executed 'profile_update' action after update of user permissions from the user permissions editor page: Users->selected user->Capabilities.
104
- It was replaced with 'ure_user_permissions_update' action now. It will allow to exclude conflicts with other plugins - "WP Members" [lost checkbox fields values](https://wordpress.org/support/topic/conflict-with-wp-members-2/), for example.
105
- * Update: Additional options for role (like "Hide admin bar" at the bottom of URE page) did not applied to the user with 'ure_edit_roles' capability. This conditon was removed.
106
- * Update: fix PHP notice 'Undefined offset: 0 in ...' at includes/classes/protect-admin.php, not_edit_admin(), where the 1st element of $caps array not always has index 0.
107
- * Update: PHP required version was increased up to 5.4.
108
-
109
- = [4.43] 05.06.2018 =
110
- * Update: references to non-existed roles are removed from the URE role additional options data storage after any role update.
111
- * Fix: Additional options section view for the current role was not refreshed properly after other current role selection.
112
-
113
- = [4.42] 16.05.2018 =
114
- * Fix: Type checking was added (URE_Lib::restore_visual_composer_caps()) to fix "Warning: Invalid argument supplied for foreach() in .../user-role-editor-pro/includes/classes/ure-lib.php on line 315".
115
-
116
- = [4.41] 07.05.2018 =
117
- * New: URE changes currently selected role via AJAX request, without full "Users->User Role Editor" page refresh.
118
- * Update: All [WPBakery Visual Composer](http://vc.wpbakery.com) plugin custom user capabilities (started from 'vc_access_rules_') were excluded from processing by User Role Editor. Visual Composer loses settings made via its own "Role Manager" after the role update by User Role Editor in other case. The reason - Visual Composer stores not boolean values with user capabilities granted to the roles via own "Role Manager". User Role Editor converted them to related boolean values during role(s) update.
119
-
120
- = [4.40.3] 05.04.2018 =
121
- * Update: bbPress detection and code for integration with it was updated to support multisite installations when URE is network activated but bbPress is activated on some sites of the network only. Free version does not support bbPress roles. It excludes them from processing as bbPress creates them dynamically.
122
-
123
- = [4.40.2] 04.04.2018 =
124
- * Update: Load required .php files from the active bbPress plugin directly, as in some cases URE code may be executed earlier than they are loaded by bbPress.
125
-
126
- = [4.40.1] 09.03.2018 =
127
- * Update: wp_roles() function (introduced with WP 4.3) was included conditionally to URE code for backward compatibility with WordPress 4.0+
128
- * Fix: WordPress multisite: bbPress plugin detection code was changed from checking bbPress API function existence to checking WordPress active plugins list. bbPress plugin activated for the site was not available yet for the network activated User Role Editor at the point of URE instance creation. URE did not work with bbPress roles as it should by design for that reason. URE (free version) should ignore bbPress roles and capabilities as the special efforts are required for this.
129
-
130
- = [4.40] 31.01.2018 =
131
- * Update: use wp_roles() function from WordPress API instead of initializing $wp_roles global variable directly.
132
- * Fix: Bug was introduced by version 4.37 with users recalculation for "All" tab after excluding users with "administrator" role. Code worked incorrectly for Japanese locale.
133
-
134
-
135
  For full list of changes applied to User Role Editor plugin look changelog.txt file.
136
 
137
 
@@ -142,9 +110,11 @@ You can find more information about "User Role Editor" plugin at [this page](htt
142
  I am ready to answer on your questions about plugin usage. Use [plugin page comments](http://www.shinephp.com/user-role-editor-wordpress-plugin/) for that.
143
 
144
  == Upgrade Notice ==
145
- = [4.43] 05.06.2018 =
146
- * Update: references to non-existed roles are removed from the URE role additional options data storage after any role update.
147
- * Fix: Additional options section view for the current role was not refreshed properly after other current role selection.
 
 
148
 
149
 
150
 
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&currency_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: 5.0.2
7
+ Stable tag: 4.48
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
79
 
80
 
81
  == Changelog =
82
+ = [4.48] 03.01.2019 =
83
+ * Update: Multisite: Sites list is not requested from the database on every page opened in order to reduce server load.
84
+ * Update: URE plugin version update routine is called now at the wp-admin backend only.
85
+ * Update: Direct access to URE_Lib::bbpress property was excluded as a preparation to future code enhancements.
86
+
87
  = [4.47] 12.11.2018 =
88
  * Fix: "Users->User Role Editor": Capabilities view was not refreshed properly for new selected role in case "Granted Only" filter was turned ON before other role selection.
89
  * Update: Unused code was removed from user-role-editor/includes/classes/bbpress.php
100
  * Update: URE settings page template: HTML helper checked() is used where applicable.
101
  * Fix: 2 spelling mistakes were fixed in the text labels.
102
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  For full list of changes applied to User Role Editor plugin look changelog.txt file.
104
 
105
 
110
  I am ready to answer on your questions about plugin usage. Use [plugin page comments](http://www.shinephp.com/user-role-editor-wordpress-plugin/) for that.
111
 
112
  == Upgrade Notice ==
113
+ = [4.48] 03.01.2019 =
114
+ * Update: Multisite: Sites list is not requested from the database on every page opened in order to reduce server load.
115
+ * Update: URE plugin version update routine is called now at the wp-admin backend only.
116
+ * Update: Direct access to URE_Lib::bbpress property was excluded as a preparation to future code enhancements.
117
+
118
 
119
 
120
 
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.47
7
  Author: Vladimir Garagulya
8
  Author URI: https://www.role-editor.com
9
  Text Domain: user-role-editor
@@ -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.47' );
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.48
7
  Author: Vladimir Garagulya
8
  Author URI: https://www.role-editor.com
9
  Text Domain: user-role-editor
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.48' );
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__ ) );