User Role Editor - Version 4.51.3

Version Description

Download this release

Release Info

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

Code changes from version 4.51.2 to 4.51.3

changelog.txt CHANGED
@@ -1,6 +1,15 @@
1
  CHANGES LOG (full version).
2
  ===========================
3
 
 
 
 
 
 
 
 
 
 
4
  = [4.51.1] 15.06.2019 =
5
  * Fix: Superadmin could not revoke capabilities from 'administrator' role under WordPress multisite.
6
 
1
  CHANGES LOG (full version).
2
  ===========================
3
 
4
+ = [4.51.3] 02.09.2019 =
5
+ * Fix: line #281 at /includes/classes/view.php contained a call to the not existing class property.
6
+ * Fix: Roles have saved in alphabet order after any role update. Roles order in the database is not changed now. Sorting is made for a view purpose only.
7
+ * Update: Roles sorting inside WordPress roles dropdown lists is switched OFF by default. In order to switch WP roles dropdown lists sorting ON, return TRUE from 'ure_sort_wp_roles_list' filter.
8
+
9
+ = [4.51.2] 15.07.2019 =
10
+ * Fix: Dialog button labels inside User Role Editor ('Cancel' buttons especially) were shown with not correct translation or not translated at all. Thanks to @lucaboccianti for [this bug report](https://wordpress.org/support/topic/buttons-delete-role-cancel-dont-delete-role-inverted-functions-italian/).
11
+ * Update: Roles inside WordPress roles dropdown lists are sorted by alphabet.
12
+
13
  = [4.51.1] 15.06.2019 =
14
  * Fix: Superadmin could not revoke capabilities from 'administrator' role under WordPress multisite.
15
 
includes/classes/capability.php CHANGED
@@ -91,7 +91,6 @@ class URE_Capability {
91
 
92
  $cap_id = $data['cap_id'];
93
  $lib = URE_Lib::get_instance();
94
- $lib->get_user_roles();
95
  $full_capabilities = $lib->init_full_capabilities( $ure_object );
96
  if (!isset($full_capabilities[$cap_id])) {
97
  $admin_role = $lib->get_admin_role();
91
 
92
  $cap_id = $data['cap_id'];
93
  $lib = URE_Lib::get_instance();
 
94
  $full_capabilities = $lib->init_full_capabilities( $ure_object );
95
  if (!isset($full_capabilities[$cap_id])) {
96
  $admin_role = $lib->get_admin_role();
includes/classes/editor.php CHANGED
@@ -943,7 +943,7 @@ class URE_Editor {
943
  $roles_can_delete[$key] = $role['name'] . ' (' . $key . ')';
944
  }
945
  }
946
-
947
  return $roles_can_delete;
948
  }
949
  // end of get_roles_can_delete()
@@ -1184,8 +1184,9 @@ class URE_Editor {
1184
  protected function get_last_role_id() {
1185
 
1186
  // get the key of the last element in roles array
1187
- $keys = array_keys($this->roles);
1188
- $last_role_id = array_pop($keys);
 
1189
 
1190
  return $last_role_id;
1191
  }
943
  $roles_can_delete[$key] = $role['name'] . ' (' . $key . ')';
944
  }
945
  }
946
+
947
  return $roles_can_delete;
948
  }
949
  // end of get_roles_can_delete()
1184
  protected function get_last_role_id() {
1185
 
1186
  // get the key of the last element in roles array
1187
+ $keys = array_keys( $this->roles );
1188
+ asort( $keys );
1189
+ $last_role_id = array_pop( $keys );
1190
 
1191
  return $last_role_id;
1192
  }
includes/classes/grant-roles.php CHANGED
@@ -400,7 +400,8 @@ class URE_Grant_Roles {
400
  </span><br>
401
  <?php
402
  $show_admin_role = $this->lib->show_admin_role_allowed();
403
- $roles = $this->lib->get_all_editable_roles();
 
404
  foreach ($roles as $role_id => $role) {
405
  if (!$show_admin_role && $role_id=='administrator') {
406
  continue;
400
  </span><br>
401
  <?php
402
  $show_admin_role = $this->lib->show_admin_role_allowed();
403
+ $roles = $this->lib->get_all_editable_roles();
404
+ ksort( $roles );
405
  foreach ($roles as $role_id => $role) {
406
  if (!$show_admin_role && $role_id=='administrator') {
407
  continue;
includes/classes/lib.php CHANGED
@@ -212,10 +212,6 @@ class URE_Lib extends URE_Base_Lib {
212
  $roles = $wp_roles->roles;
213
  }
214
 
215
- if (is_array($roles) && count($roles) > 0) {
216
- ksort($roles);
217
- }
218
-
219
  return $roles;
220
  }
221
  // end of get_user_roles()
@@ -238,9 +234,7 @@ class URE_Lib extends URE_Base_Lib {
238
  if ($bbpress->is_active()) {
239
  add_filter('editable_roles', 'bbp_filter_blog_editable_roles');
240
  }
241
-
242
- ksort( $roles );
243
-
244
  return $roles;
245
  }
246
  // end of get_editable_user_roles()
212
  $roles = $wp_roles->roles;
213
  }
214
 
 
 
 
 
215
  return $roles;
216
  }
217
  // end of get_user_roles()
234
  if ($bbpress->is_active()) {
235
  add_filter('editable_roles', 'bbp_filter_blog_editable_roles');
236
  }
237
+
 
 
238
  return $roles;
239
  }
240
  // end of get_editable_user_roles()
includes/classes/role-view.php CHANGED
@@ -32,7 +32,8 @@ class URE_Role_View extends URE_View {
32
  if (!isset($roles) || !$roles) {
33
  // get roles data from database
34
  $roles = $this->lib->get_user_roles();
35
- }
 
36
 
37
  $caps_access_restrict_for_simple_admin = $this->lib->get_option('caps_access_restrict_for_simple_admin', 0);
38
  $show_admin_role = $this->lib->show_admin_role_allowed();
@@ -61,31 +62,32 @@ class URE_Role_View extends URE_View {
61
  // end of role_default_prepare_html()
62
 
63
 
64
- private function role_select_copy_prepare_html($select_width=200) {
65
 
66
  $current_user = wp_get_current_user();
67
  $key_capability = URE_Own_Capabilities::get_key_capability();
68
- $user_is_ure_admin = current_user_can($key_capability);
69
- $role_to_skip = ($user_is_ure_admin) ? '':$current_user->roles[0];
70
 
71
- $caps_access_restrict_for_simple_admin = $this->lib->get_option('caps_access_restrict_for_simple_admin', 0);
72
  $show_admin_role = $this->lib->show_admin_role_allowed();
73
  $this->role_to_copy_html = '<select id="user_role_copy_from" name="user_role_copy_from" style="width: '. $select_width .'px">
74
  <option value="none" selected="selected">' . esc_html__('None', 'user-role-editor') . '</option>';
75
  $this->role_select_html = '<select id="user_role" name="user_role" onchange="ure_role_change(this.value);">';
76
- $current_role = $this->editor->get('current_role');
77
- $all_roles = $this->editor->get('roles');
78
- $roles = $this->lib->get_editable_user_roles($all_roles);
 
79
  foreach ($roles as $key => $value) {
80
- if ($key===$role_to_skip) { // skip role of current user if he does not have full access to URE
81
  continue;
82
  }
83
- $selected1 = selected($key, $current_role, false);
84
- $disabled = ($key==='administrator' && $caps_access_restrict_for_simple_admin && !$this->lib->is_super_admin()) ? 'disabled' : '';
85
- if ($show_admin_role || $key != 'administrator') {
86
- $translated_name = esc_html__($value['name'], 'user-role-editor'); // get translation from URE language file, if exists
87
- if ($translated_name === $value['name']) { // get WordPress internal translation
88
- $translated_name = translate_user_role($translated_name);
89
  }
90
  $translated_name .= ' (' . $key . ')';
91
  $this->role_select_html .= '<option value="' . $key . '" ' . $selected1 .' '. $disabled .'>' . $translated_name . '</option>';
@@ -102,6 +104,7 @@ class URE_Role_View extends URE_View {
102
 
103
  $roles_can_delete = $this->editor->get_roles_can_delete();
104
  if ( is_array( $roles_can_delete ) && count( $roles_can_delete ) > 0) {
 
105
  $this->role_delete_html = '<select id="del_user_role" name="del_user_role" width="200" style="width: 200px">';
106
  foreach ($roles_can_delete as $key => $value) {
107
  $this->role_delete_html .= '<option value="' . $key . '">' . esc_html__($value, 'user-role-editor') . '</option>';
@@ -178,12 +181,12 @@ class URE_Role_View extends URE_View {
178
  // end of caps_to_remove_html()
179
 
180
 
181
- public function role_edit_prepare_html($select_width=200) {
182
 
183
- $this->role_select_copy_prepare_html($select_width);
184
- $multisite = $this->lib->get('multisite');
185
- if ($multisite && !is_network_admin()) {
186
- $this->role_default_prepare_html($select_width);
187
  }
188
  $this->role_delete_prepare_html();
189
 
32
  if (!isset($roles) || !$roles) {
33
  // get roles data from database
34
  $roles = $this->lib->get_user_roles();
35
+ }
36
+ ksort( $roles );
37
 
38
  $caps_access_restrict_for_simple_admin = $this->lib->get_option('caps_access_restrict_for_simple_admin', 0);
39
  $show_admin_role = $this->lib->show_admin_role_allowed();
62
  // end of role_default_prepare_html()
63
 
64
 
65
+ private function role_select_copy_prepare_html( $select_width=200 ) {
66
 
67
  $current_user = wp_get_current_user();
68
  $key_capability = URE_Own_Capabilities::get_key_capability();
69
+ $user_is_ure_admin = current_user_can( $key_capability );
70
+ $role_to_skip = ( $user_is_ure_admin ) ? '' : $current_user->roles[0];
71
 
72
+ $caps_access_restrict_for_simple_admin = $this->lib->get_option( 'caps_access_restrict_for_simple_admin', 0 );
73
  $show_admin_role = $this->lib->show_admin_role_allowed();
74
  $this->role_to_copy_html = '<select id="user_role_copy_from" name="user_role_copy_from" style="width: '. $select_width .'px">
75
  <option value="none" selected="selected">' . esc_html__('None', 'user-role-editor') . '</option>';
76
  $this->role_select_html = '<select id="user_role" name="user_role" onchange="ure_role_change(this.value);">';
77
+ $current_role = $this->editor->get( 'current_role' );
78
+ $all_roles = $this->editor->get( 'roles' );
79
+ $roles = $this->lib->get_editable_user_roles( $all_roles );
80
+ ksort( $roles );
81
  foreach ($roles as $key => $value) {
82
+ if ( $key===$role_to_skip ) { // skip role of current user if he does not have full access to URE
83
  continue;
84
  }
85
+ $selected1 = selected( $key, $current_role, false );
86
+ $disabled = ( $key==='administrator' && $caps_access_restrict_for_simple_admin && !$this->lib->is_super_admin()) ? 'disabled' : '';
87
+ if ( $show_admin_role || $key != 'administrator' ) {
88
+ $translated_name = esc_html__( $value['name'], 'user-role-editor' ); // get translation from URE language file, if exists
89
+ if ( $translated_name === $value['name'] ) { // get WordPress internal translation
90
+ $translated_name = translate_user_role( $translated_name );
91
  }
92
  $translated_name .= ' (' . $key . ')';
93
  $this->role_select_html .= '<option value="' . $key . '" ' . $selected1 .' '. $disabled .'>' . $translated_name . '</option>';
104
 
105
  $roles_can_delete = $this->editor->get_roles_can_delete();
106
  if ( is_array( $roles_can_delete ) && count( $roles_can_delete ) > 0) {
107
+ ksort( $roles_can_delete );
108
  $this->role_delete_html = '<select id="del_user_role" name="del_user_role" width="200" style="width: 200px">';
109
  foreach ($roles_can_delete as $key => $value) {
110
  $this->role_delete_html .= '<option value="' . $key . '">' . esc_html__($value, 'user-role-editor') . '</option>';
181
  // end of caps_to_remove_html()
182
 
183
 
184
+ public function role_edit_prepare_html( $select_width=200 ) {
185
 
186
+ $this->role_select_copy_prepare_html( $select_width );
187
+ $multisite = $this->lib->get( 'multisite' );
188
+ if ( $multisite && !is_network_admin() ) {
189
+ $this->role_default_prepare_html( $select_width );
190
  }
191
  $this->role_delete_prepare_html();
192
 
includes/classes/settings.php CHANGED
@@ -190,6 +190,7 @@ class URE_Settings {
190
  $lib = URE_Lib::get_instance();
191
  $other_default_roles = $lib->get_option('other_default_roles', array());
192
  $roles = $lib->get_user_roles();
 
193
  $wp_default_role = get_option('default_role');
194
  foreach ($roles as $role_id => $role) {
195
  if ( $role_id=='administrator' || $role_id==$wp_default_role ) {
190
  $lib = URE_Lib::get_instance();
191
  $other_default_roles = $lib->get_option('other_default_roles', array());
192
  $roles = $lib->get_user_roles();
193
+ ksort( $roles );
194
  $wp_default_role = get_option('default_role');
195
  foreach ($roles as $role_id => $role) {
196
  if ( $role_id=='administrator' || $role_id==$wp_default_role ) {
includes/classes/user-role-editor.php CHANGED
@@ -203,7 +203,7 @@ class User_Role_Editor {
203
 
204
  add_action('wp_ajax_ure_ajax', array($this, 'ure_ajax'));
205
 
206
- $sort_roles = apply_filters( 'ure_sort_wp_roles_list', true );
207
  if ( $sort_roles ) {
208
  add_filter( 'editable_roles', array( $this, 'sort_wp_roles_list' ), 11, 1 );
209
  }
@@ -836,6 +836,9 @@ class User_Role_Editor {
836
  public function sort_wp_roles_list( $roles ) {
837
 
838
  ksort( $roles );
 
 
 
839
  $roles = array_reverse( $roles );
840
 
841
  return $roles;
203
 
204
  add_action('wp_ajax_ure_ajax', array($this, 'ure_ajax'));
205
 
206
+ $sort_roles = apply_filters( 'ure_sort_wp_roles_list', false );
207
  if ( $sort_roles ) {
208
  add_filter( 'editable_roles', array( $this, 'sort_wp_roles_list' ), 11, 1 );
209
  }
836
  public function sort_wp_roles_list( $roles ) {
837
 
838
  ksort( $roles );
839
+ // wp-admin/includes/template/wp_dropdown_roles() showed roles in reversed order, #906:
840
+ // $editable_roles = array_reverse( get_editable_roles() );
841
+ // so we have to reverse them 1st, in order they will be reversed back to the ascending order
842
  $roles = array_reverse( $roles );
843
 
844
  return $roles;
includes/classes/view.php CHANGED
@@ -278,7 +278,7 @@ class URE_View {
278
 
279
  private function show_select_all() {
280
  $multisite = $this->lib->get('multisite');
281
- $current_role = $this->lib->get('current_role');
282
  $show = true;
283
  if ($multisite) {
284
  if ($current_role=='administrator' && !$this->lib->is_super_admin()) {
278
 
279
  private function show_select_all() {
280
  $multisite = $this->lib->get('multisite');
281
+ $current_role = $this->editor->get('current_role');
282
  $show = true;
283
  if ($multisite) {
284
  if ($current_role=='administrator' && !$this->lib->is_super_admin()) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=vladi
4
  Tags: user, role, editor, security, access, permission, capability
5
  Requires at least: 4.0
6
  Tested up to: 5.2.2
7
- Stable tag: 4.51.2
8
  Requires PHP: 5.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -81,6 +81,11 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
81
 
82
  == Changelog =
83
 
 
 
 
 
 
84
  = [4.51.2] 15.07.2019 =
85
  * Fix: Dialog button labels inside User Role Editor ('Cancel' buttons especially) were shown with not correct translation or not translated at all. Thanks to @lucaboccianti for [this bug report](https://wordpress.org/support/topic/buttons-delete-role-cancel-dont-delete-role-inverted-functions-italian/).
86
  * Update: Roles inside WordPress roles dropdown lists are sorted by alphabet.
@@ -88,27 +93,6 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
88
  = [4.51.1] 15.06.2019 =
89
  * Fix: Superadmin could not revoke capabilities from 'administrator' role under WordPress multisite.
90
 
91
- = [4.51] 21.05.2019 =
92
- * New: Bulk actions were added to the Users page: "Add Role", "Revoke Role". Select role from the related drop-down menu and add/revoke it to/from the list of pre-selected users.
93
- * Update: Bulk grant roles feature ("Grant roles" button at the "Users" page) and Bulk grant role to users without role ("Without role" button at the "Users" page) are protected by 'promote_users' capability instead of 'edit_users', exactly the same way as WordPress itself does for its "Change role to".
94
- * Update: 'load-users.php' action is used instead of 'admin_init' to load support code for "Without role" and "Grant roles" button at the "Users" page.
95
- * Update: URE ignores now a capability without ID in case it was added to the database somehow (other plugin bug, etc.). Such incorrect empty capability is removed from the capabilities list as a result after any role update.
96
-
97
- = [4.50.2] 01.04.2019 =
98
- * Fix: WordPress multisite: PHP Notice "wpmu_new_blog is deprecated since version 5.1.0! Use wp_insert_site instead." was removed. URE uses 'wp_initialize_site' action now instead of deprecated 'wpmu_new_blog'. This fix provides correct roles replication from the main blog/site to a new created blog/site.
99
-
100
- = [4.50.1] 16.03.2019 =
101
- * Fix: WP Multisite: Users->Capabilities->Update: "Fatal error: Uncaught Error: Call to undefined method URE_Editor::check_blog_user() in /wp-content/plugins/user-role-editor/includes/classes/editor.php on line 576" was fixed.
102
- * Fix: WooCommerce group was not shown under "Custom capabilities" section.
103
-
104
- = [4.50] 03.03.2019 =
105
- * PHP version 5.5 was marked as required.
106
- * Update: General code restructure and optimization.
107
- * Update: URE_Base_Lib::get_blog_ids() returns null, if it's called under WordPress single site (not multisite).
108
- * Update: URE_Editor::prepare_capabilities_to_save() : "Invalid argument supplied for foreach()" warning was excluded in case there was no valid data structures initialization.
109
- * Update: 'administrator' role protection was enhanced. URE always does not allow to revoke capability from 'administrator' role. That was possible earlier after the 'administrator' role update.
110
- * Update: 2 new actions 'ure_settings_tools_show' and 'ure_settings_tools_exec' allows to extends the list of sections available at the Settings->User Role Editor->Tools tab.
111
-
112
  File changelog.txt contains the full list of changes.
113
 
114
  == Additional Documentation ==
@@ -119,10 +103,7 @@ I am ready to answer on your questions about plugin usage. Use [plugin page comm
119
 
120
  == Upgrade Notice ==
121
 
122
- = [4.51.1] 15.06.2019 =
123
- * Fix: Superadmin could not revoke capabilities from 'administrator' role under WordPress multisite.
124
-
125
-
126
-
127
-
128
-
4
  Tags: user, role, editor, security, access, permission, capability
5
  Requires at least: 4.0
6
  Tested up to: 5.2.2
7
+ Stable tag: 4.51.3
8
  Requires PHP: 5.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
81
 
82
  == Changelog =
83
 
84
+ = [4.51.3] 02.09.2019 =
85
+ * Fix: line #281 at /includes/classes/view.php contained a call to the not existing class property.
86
+ * Fix: Roles have saved in alphabet order after any role update. Roles order in the database is not changed now. Sorting is made for a view purpose only.
87
+ * Update: Roles sorting inside WordPress roles dropdown lists is switched OFF by default. In order to switch WP roles dropdown lists sorting ON, return TRUE from 'ure_sort_wp_roles_list' filter.
88
+
89
  = [4.51.2] 15.07.2019 =
90
  * Fix: Dialog button labels inside User Role Editor ('Cancel' buttons especially) were shown with not correct translation or not translated at all. Thanks to @lucaboccianti for [this bug report](https://wordpress.org/support/topic/buttons-delete-role-cancel-dont-delete-role-inverted-functions-italian/).
91
  * Update: Roles inside WordPress roles dropdown lists are sorted by alphabet.
93
  = [4.51.1] 15.06.2019 =
94
  * Fix: Superadmin could not revoke capabilities from 'administrator' role under WordPress multisite.
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  File changelog.txt contains the full list of changes.
97
 
98
  == Additional Documentation ==
103
 
104
  == Upgrade Notice ==
105
 
106
+ = [4.51.3] 02.09.2019 =
107
+ * Fix: line #281 at /includes/classes/view.php contained a call to the not existing class property.
108
+ * Fix: Roles have saved in alphabet order after any role update. Roles order in the database is not changed now. Sorting is made for a view purpose only.
109
+ * Update: Roles sorting inside WordPress roles dropdown lists is switched OFF by default. In order to switch WP roles dropdown lists sorting ON, return TRUE from 'ure_sort_wp_roles_list' filter.
 
 
 
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.51.2
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.51.2' );
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.51.3
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.51.3' );
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__ ) );