User Role Editor - Version 4.51.2

Version Description

Download this release

Release Info

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

Code changes from version 4.51.1 to 4.51.2

css/ure-admin.css CHANGED
@@ -203,8 +203,17 @@ input.warning:hover, a.warning:hover {
203
  display: none;
204
  }
205
 
 
 
 
 
206
  #ure_admin_menu_access_table tr:hover {
207
- background-color: #2ea2cc;
 
 
 
 
 
208
  color: #ffffff;
209
  }
210
 
203
  display: none;
204
  }
205
 
206
+ #ure_admin_menu_access_table td {
207
+ cursor: pointer;
208
+ }
209
+
210
  #ure_admin_menu_access_table tr:hover {
211
+ background-color: #04a4cc;
212
+ color: #ffffff;
213
+ }
214
+
215
+ .ure_table_row_selected {
216
+ background-color: #04a4cc;
217
  color: #ffffff;
218
  }
219
 
includes/classes/lib.php CHANGED
@@ -213,7 +213,7 @@ class URE_Lib extends URE_Base_Lib {
213
  }
214
 
215
  if (is_array($roles) && count($roles) > 0) {
216
- asort($roles);
217
  }
218
 
219
  return $roles;
@@ -225,7 +225,7 @@ class URE_Lib extends URE_Base_Lib {
225
  * Respect 'editable_roles' filter, when needed
226
  * @return array
227
  */
228
- public function get_editable_user_roles($roles) {
229
 
230
  if (empty($roles)) {
231
  $roles = $this->get_user_roles();
@@ -239,6 +239,8 @@ class URE_Lib extends URE_Base_Lib {
239
  add_filter('editable_roles', 'bbp_filter_blog_editable_roles');
240
  }
241
 
 
 
242
  return $roles;
243
  }
244
  // end of get_editable_user_roles()
@@ -535,8 +537,12 @@ class URE_Lib extends URE_Base_Lib {
535
  */
536
  public function get_all_editable_roles() {
537
 
538
- $roles = get_editable_roles(); // WordPress roles
539
-
 
 
 
 
540
  return $roles;
541
  }
542
  // end of get_all_roles()
213
  }
214
 
215
  if (is_array($roles) && count($roles) > 0) {
216
+ ksort($roles);
217
  }
218
 
219
  return $roles;
225
  * Respect 'editable_roles' filter, when needed
226
  * @return array
227
  */
228
+ public function get_editable_user_roles( $roles ) {
229
 
230
  if (empty($roles)) {
231
  $roles = $this->get_user_roles();
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()
537
  */
538
  public function get_all_editable_roles() {
539
 
540
+ $roles = get_editable_roles(); // WordPress roles
541
+ if ( has_filter( 'editable_roles', array( User_Role_Editor::get_instance(), 'sort_wp_roles_list') ) ) {
542
+ // to show roles in the accending order
543
+ $roles = array_reverse( $roles );
544
+ }
545
+
546
  return $roles;
547
  }
548
  // end of get_all_roles()
includes/classes/protect-admin.php CHANGED
@@ -55,10 +55,10 @@ class URE_Protect_Admin {
55
  * @param string $roles
56
  * @return array
57
  */
58
- public function exclude_admin_role($roles) {
59
 
60
- if ($this->is_protection_applicable() && isset($roles['administrator'])) {
61
- unset($roles['administrator']);
62
  }
63
 
64
  return $roles;
55
  * @param string $roles
56
  * @return array
57
  */
58
+ public function exclude_admin_role( $roles ) {
59
 
60
+ if ( $this->is_protection_applicable() && isset( $roles['administrator'] ) ) {
61
+ unset( $roles['administrator'] );
62
  }
63
 
64
  return $roles;
includes/classes/user-other-roles.php CHANGED
@@ -96,28 +96,28 @@ class URE_User_Other_Roles {
96
  * @param type $user WP_User from wp-includes/capabilities.php
97
  * @return array
98
  */
99
- public function get_roles_array($user) {
100
 
101
- if (!is_array($user->roles) || count($user->roles) <= 1) {
102
  return array();
103
  }
104
 
105
  // get bbPress assigned user role
106
- if (function_exists('bbp_filter_blog_editable_roles')) {
107
- $bb_press_role = bbp_get_user_role($user->ID);
108
  } else {
109
  $bb_press_role = '';
110
  }
111
 
112
  $roles = array();
113
- foreach ($user->roles as $key => $value) {
114
- if (!empty($bb_press_role) && $bb_press_role === $value) {
115
  // exclude bbPress assigned role
116
  continue;
117
  }
118
- $roles[] = $value;
119
  }
120
- array_shift($roles); // exclude primary role which is shown by WordPress itself
121
 
122
  return $roles;
123
  }
@@ -129,7 +129,8 @@ class URE_User_Other_Roles {
129
 
130
  $user_roles = $user->roles;
131
  $primary_role = array_shift($user_roles);
132
- $roles = apply_filters('editable_roles', $wp_roles->roles); // exclude restricted roles if any
 
133
  if (isset($roles[$primary_role])) { // exclude role assigned to the user as a primary role
134
  unset($roles[$primary_role]);
135
  }
96
  * @param type $user WP_User from wp-includes/capabilities.php
97
  * @return array
98
  */
99
+ public function get_roles_array( $user ) {
100
 
101
+ if ( !is_array( $user->roles ) || count( $user->roles )<=1 ) {
102
  return array();
103
  }
104
 
105
  // get bbPress assigned user role
106
+ if ( function_exists( 'bbp_filter_blog_editable_roles' ) ) {
107
+ $bb_press_role = bbp_get_user_role( $user->ID );
108
  } else {
109
  $bb_press_role = '';
110
  }
111
 
112
  $roles = array();
113
+ foreach ( $user->roles as $role) {
114
+ if (!empty($bb_press_role) && $bb_press_role === $role) {
115
  // exclude bbPress assigned role
116
  continue;
117
  }
118
+ $roles[] = $role;
119
  }
120
+ array_shift( $roles ); // exclude primary role which is shown by WordPress itself
121
 
122
  return $roles;
123
  }
129
 
130
  $user_roles = $user->roles;
131
  $primary_role = array_shift($user_roles);
132
+ $roles = apply_filters('editable_roles', $wp_roles->roles); // exclude restricted roles if any
133
+ $roles = array_reverse( $roles );
134
  if (isset($roles[$primary_role])) { // exclude role assigned to the user as a primary role
135
  unset($roles[$primary_role]);
136
  }
includes/classes/user-role-editor.php CHANGED
@@ -202,6 +202,11 @@ class User_Role_Editor {
202
  }
203
 
204
  add_action('wp_ajax_ure_ajax', array($this, 'ure_ajax'));
 
 
 
 
 
205
  }
206
  // end of plugin_init()
207
 
@@ -821,6 +826,21 @@ class User_Role_Editor {
821
 
822
  }
823
  // end of set_role_additional_options_hooks()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
824
 
825
 
826
  // execute on plugin deactivation
202
  }
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
+ }
210
  }
211
  // end of plugin_init()
212
 
826
 
827
  }
828
  // end of set_role_additional_options_hooks()
829
+
830
+
831
+ /**
832
+ * Sort roles array alphabetically
833
+ * @param array $roles
834
+ * @return array
835
+ */
836
+ public function sort_wp_roles_list( $roles ) {
837
+
838
+ ksort( $roles );
839
+ $roles = array_reverse( $roles );
840
+
841
+ return $roles;
842
+ }
843
+ // end of sort_wp_roles_list()
844
 
845
 
846
  // execute on plugin deactivation
js/ure.js CHANGED
@@ -83,7 +83,7 @@ var ure_main = {
83
  jQuery('#ure_remove_caps_form').submit();
84
  jQuery(this).dialog('close');
85
  },
86
- Cancel: function () {
87
  jQuery(this).dialog('close');
88
  }
89
  }
@@ -91,7 +91,7 @@ var ure_main = {
91
  // translate buttons caption
92
  jQuery('.ui-dialog-buttonpane button:contains("Delete Capability")').attr('id', 'dialog-delete-capability-button');
93
  jQuery('#dialog-delete-capability-button').html(ure_ui_button_text(ure_data.delete_capability));
94
- jQuery('.ui-dialog-buttonpane button:contains("Cancel")').attr('id', 'delete-capability-dialog-cancel-button');
95
  jQuery('#delete-capability-dialog-cancel-button').html(ure_ui_button_text(ure_data.cancel));
96
  jQuery('#ure_remove_caps_select_all').click(this.remove_caps_auto_select);
97
  },
@@ -195,7 +195,7 @@ jQuery(function ($) {
195
  {action: 'add-new-role', user_role_id: role_id, user_role_name: role_name, user_role_copy_from: role_copy_from,
196
  ure_nonce: ure_data.wp_nonce});
197
  },
198
- Cancel: function () {
199
  $(this).dialog('close');
200
  return false;
201
  }
@@ -203,8 +203,8 @@ jQuery(function ($) {
203
  });
204
  $('.ui-dialog-buttonpane button:contains("Add Role")').attr('id', 'dialog-add-role-button');
205
  $('#dialog-add-role-button').html(ure_ui_button_text(ure_data.add_role));
206
- $('.ui-dialog-buttonpane button:contains("Cancel")').attr('id', 'add-role-dialog-cancel-button');
207
- $('#add-role-dialog-cancel-button').html(ure_ui_button_text(ure_data.cancel));
208
 
209
  }
210
 
@@ -237,7 +237,7 @@ jQuery(function ($) {
237
  {action: 'rename-role', user_role_id: role_id, user_role_name: role_name, ure_nonce: ure_data.wp_nonce}
238
  );
239
  },
240
- Cancel: function () {
241
  $(this).dialog('close');
242
  return false;
243
  }
@@ -245,7 +245,7 @@ jQuery(function ($) {
245
  });
246
  $('.ui-dialog-buttonpane button:contains("Rename Role")').attr('id', 'dialog-rename-role-button');
247
  $('#dialog-rename-role-button').html(ure_ui_button_text(ure_data.rename_role));
248
- $('.ui-dialog-buttonpane button:contains("Cancel")').attr('id', 'rename-role-dialog-cancel-button');
249
  $('#rename-role-dialog-cancel-button').html(ure_ui_button_text(ure_data.cancel));
250
  $('#ren_user_role_id').val(ure_current_role);
251
  $('#ren_user_role_name').val(ure_current_role_name);
@@ -288,16 +288,16 @@ jQuery(function ($) {
288
  $.ure_postGo(ure_data.page_url,
289
  {action: 'delete-role', user_role_id: user_role_id, ure_nonce: ure_data.wp_nonce});
290
  },
291
- Cancel: function () {
292
  $(this).dialog('close');
293
  }
294
  }
295
  });
296
  // translate buttons caption
297
- $('.ui-dialog-buttonpane button:contains("Delete Role")').attr('id', 'dialog-delete-button');
298
- $('#dialog-delete-button').html(ure_ui_button_text(ure_data.delete_role));
299
- $('.ui-dialog-buttonpane button:contains("Cancel")').attr('id', 'delete-role-dialog-cancel-button');
300
- $('#delete-role-dialog-cancel-button').html(ure_ui_button_text(ure_data.cancel));
301
  }
302
 
303
 
@@ -335,14 +335,14 @@ jQuery(function ($) {
335
  $.ure_postGo(ure_data.page_url,
336
  {action: 'add-new-capability', capability_id: capability_id, ure_nonce: ure_data.wp_nonce});
337
  },
338
- Cancel: function () {
339
  $(this).dialog('close');
340
  }
341
  }
342
  });
343
  $('.ui-dialog-buttonpane button:contains("Add Capability")').attr('id', 'dialog-add-capability-button');
344
  $('#dialog-add-capability-button').html(ure_ui_button_text(ure_data.add_capability));
345
- $('.ui-dialog-buttonpane button:contains("Cancel")').attr('id', 'add-capability-dialog-cancel-button');
346
  $('#add-capability-dialog-cancel-button').html(ure_ui_button_text(ure_data.cancel));
347
 
348
  }
@@ -383,7 +383,7 @@ jQuery(function ($) {
383
  $.ure_postGo(ure_data.page_url,
384
  {action: 'change-default-role', user_role_id: user_role_id, ure_nonce: ure_data.wp_nonce});
385
  },
386
- Cancel: function () {
387
  $(this).dialog('close');
388
  }
389
  }
@@ -391,7 +391,7 @@ jQuery(function ($) {
391
  // translate buttons caption
392
  $('.ui-dialog-buttonpane button:contains("Set New Default Role")').attr('id', 'dialog-default-role-button');
393
  $('#dialog-default-role-button').html(ure_ui_button_text(ure_data.set_new_default_role));
394
- $('.ui-dialog-buttonpane button:contains("Cancel")').attr('id', 'default-role-dialog-cancel-button');
395
  $('#default-role-dialog-cancel-button').html(ure_ui_button_text(ure_data.cancel));
396
  }
397
 
83
  jQuery('#ure_remove_caps_form').submit();
84
  jQuery(this).dialog('close');
85
  },
86
+ CancelDeleteCapability: function () {
87
  jQuery(this).dialog('close');
88
  }
89
  }
91
  // translate buttons caption
92
  jQuery('.ui-dialog-buttonpane button:contains("Delete Capability")').attr('id', 'dialog-delete-capability-button');
93
  jQuery('#dialog-delete-capability-button').html(ure_ui_button_text(ure_data.delete_capability));
94
+ jQuery('.ui-dialog-buttonpane button:contains("CancelDeleteCapability")').attr('id', 'delete-capability-dialog-cancel-button');
95
  jQuery('#delete-capability-dialog-cancel-button').html(ure_ui_button_text(ure_data.cancel));
96
  jQuery('#ure_remove_caps_select_all').click(this.remove_caps_auto_select);
97
  },
195
  {action: 'add-new-role', user_role_id: role_id, user_role_name: role_name, user_role_copy_from: role_copy_from,
196
  ure_nonce: ure_data.wp_nonce});
197
  },
198
+ CancelAddRole: function () {
199
  $(this).dialog('close');
200
  return false;
201
  }
203
  });
204
  $('.ui-dialog-buttonpane button:contains("Add Role")').attr('id', 'dialog-add-role-button');
205
  $('#dialog-add-role-button').html(ure_ui_button_text(ure_data.add_role));
206
+ $('.ui-dialog-buttonpane button:contains("CancelAddRole")').attr('id', 'dialog-add-role-cancel-button');
207
+ $('#dialog-add-role-cancel-button').html(ure_ui_button_text(ure_data.cancel));
208
 
209
  }
210
 
237
  {action: 'rename-role', user_role_id: role_id, user_role_name: role_name, ure_nonce: ure_data.wp_nonce}
238
  );
239
  },
240
+ CancelRenameRole: function () {
241
  $(this).dialog('close');
242
  return false;
243
  }
245
  });
246
  $('.ui-dialog-buttonpane button:contains("Rename Role")').attr('id', 'dialog-rename-role-button');
247
  $('#dialog-rename-role-button').html(ure_ui_button_text(ure_data.rename_role));
248
+ $('.ui-dialog-buttonpane button:contains("CancelRenameRole")').attr('id', 'rename-role-dialog-cancel-button');
249
  $('#rename-role-dialog-cancel-button').html(ure_ui_button_text(ure_data.cancel));
250
  $('#ren_user_role_id').val(ure_current_role);
251
  $('#ren_user_role_name').val(ure_current_role_name);
288
  $.ure_postGo(ure_data.page_url,
289
  {action: 'delete-role', user_role_id: user_role_id, ure_nonce: ure_data.wp_nonce});
290
  },
291
+ CancelDeleteRole: function () {
292
  $(this).dialog('close');
293
  }
294
  }
295
  });
296
  // translate buttons caption
297
+ $('.ui-dialog-buttonpane button:contains("Delete Role")').attr('id', 'dialog-delete-role-button');
298
+ $('#dialog-delete-role-button').html( ure_ui_button_text( ure_data.delete_role ) );
299
+ $('.ui-dialog-buttonpane button:contains("CancelDeleteRole")').attr('id', 'dialog-delete-role-cancel-button');
300
+ $('#dialog-delete-role-cancel-button').html( ure_ui_button_text( ure_data.cancel ) );
301
  }
302
 
303
 
335
  $.ure_postGo(ure_data.page_url,
336
  {action: 'add-new-capability', capability_id: capability_id, ure_nonce: ure_data.wp_nonce});
337
  },
338
+ CancelAddCapability: function () {
339
  $(this).dialog('close');
340
  }
341
  }
342
  });
343
  $('.ui-dialog-buttonpane button:contains("Add Capability")').attr('id', 'dialog-add-capability-button');
344
  $('#dialog-add-capability-button').html(ure_ui_button_text(ure_data.add_capability));
345
+ $('.ui-dialog-buttonpane button:contains("CancelAddCapability")').attr('id', 'add-capability-dialog-cancel-button');
346
  $('#add-capability-dialog-cancel-button').html(ure_ui_button_text(ure_data.cancel));
347
 
348
  }
383
  $.ure_postGo(ure_data.page_url,
384
  {action: 'change-default-role', user_role_id: user_role_id, ure_nonce: ure_data.wp_nonce});
385
  },
386
+ CancelDefaultRole: function () {
387
  $(this).dialog('close');
388
  }
389
  }
391
  // translate buttons caption
392
  $('.ui-dialog-buttonpane button:contains("Set New Default Role")').attr('id', 'dialog-default-role-button');
393
  $('#dialog-default-role-button').html(ure_ui_button_text(ure_data.set_new_default_role));
394
+ $('.ui-dialog-buttonpane button:contains("CancelDefaultRole")').attr('id', 'default-role-dialog-cancel-button');
395
  $('#default-role-dialog-cancel-button').html(ure_ui_button_text(ure_data.cancel));
396
  }
397
 
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.2.1
7
- Stable tag: 4.51.1
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,10 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
81
 
82
  == Changelog =
83
 
 
 
 
 
84
  = [4.51.1] 15.06.2019 =
85
  * Fix: Superadmin could not revoke capabilities from 'administrator' role under WordPress multisite.
86
 
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.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
 
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.
87
+
88
  = [4.51.1] 15.06.2019 =
89
  * Fix: Superadmin could not revoke capabilities from 'administrator' role under WordPress multisite.
90
 
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.1
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.1' );
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.2
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.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__ ) );