User Role Editor - Version 4.1.1

Version Description

  • 15.07.2013
  • Issue when "users with "Editor" credentials were no longer able to change the author name in the drop down on each post to someone with administrative credentials" is fixed.
  • Limitation when user with 'Administrator' role could not edit/delete other users with 'Administrator' role is removed.
  • "Apply to All sites" checkbox is excluded from "Select All" operation.
  • Quick filter is added to the user's capabilities edit form. Capabilities selection buttons work is fixed after that.
Download this release

Release Info

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

Code changes from version 4.1 to 4.1.1

includes/class-ure-lib.php CHANGED
@@ -343,7 +343,7 @@ class Ure_Lib extends Garvs_WP_Lib {
343
  }
344
 
345
  $action = $_POST['action'];
346
- // restore roles capabilities from the backup record
347
  if ($action == 'reset') {
348
  $this->reset_user_roles();
349
  exit;
@@ -360,17 +360,20 @@ class Ure_Lib extends Garvs_WP_Lib {
360
  } else {
361
  $this->caps_readable = 1;
362
  }
363
- update_option('ure_caps_readable', $this->caps_readable);
 
364
  } else if ($action == 'show-deprecated-caps') {
365
  if ($this->show_deprecated_caps) {
366
  $this->show_deprecated_caps = 0;
367
  } else {
368
  $this->show_deprecated_caps = 1;
369
  }
370
- update_option('ure_show_deprecated_caps', $this->show_deprecated_caps);
 
371
  } else if ($action == 'hide-pro-banner') {
372
- update_option('ure_hide_pro_banner', true);
373
- $this->hide_pro_banner = true;
 
374
  } else if ($action == 'add-new-capability') {
375
  $this->notification = $this->add_new_capability();
376
  } else if ($action == 'delete-user-capability') {
@@ -395,9 +398,9 @@ class Ure_Lib extends Garvs_WP_Lib {
395
 
396
 
397
  private function editor_init0() {
398
- $this->caps_readable = get_option('ure_caps_readable');
399
- $this->show_deprecated_caps = get_option('ure_show_deprecated_caps');
400
- $this->hide_pro_banner = get_option('ure_hide_pro_banner', false);
401
  $this->wp_default_role = get_option('default_role');
402
 
403
  // could be sent as by POST, as by GET
@@ -656,7 +659,7 @@ class Ure_Lib extends Garvs_WP_Lib {
656
  // end of show_message()
657
 
658
 
659
- private function make_roles_backup()
660
  {
661
  global $wpdb;
662
 
343
  }
344
 
345
  $action = $_POST['action'];
346
+
347
  if ($action == 'reset') {
348
  $this->reset_user_roles();
349
  exit;
360
  } else {
361
  $this->caps_readable = 1;
362
  }
363
+ $this->put_option('ure_caps_readable', $this->caps_readable);
364
+ $this->flush_options();
365
  } else if ($action == 'show-deprecated-caps') {
366
  if ($this->show_deprecated_caps) {
367
  $this->show_deprecated_caps = 0;
368
  } else {
369
  $this->show_deprecated_caps = 1;
370
  }
371
+ $this->put_option('ure_show_deprecated_caps', $this->show_deprecated_caps);
372
+ $this->flush_options();
373
  } else if ($action == 'hide-pro-banner') {
374
+ $this->hide_pro_banner = 1;
375
+ $this->put_option('ure_hide_pro_banner', 1);
376
+ $this->flush_options();
377
  } else if ($action == 'add-new-capability') {
378
  $this->notification = $this->add_new_capability();
379
  } else if ($action == 'delete-user-capability') {
398
 
399
 
400
  private function editor_init0() {
401
+ $this->caps_readable = $this->get_option('ure_caps_readable');
402
+ $this->show_deprecated_caps = $this->get_option('ure_show_deprecated_caps');
403
+ $this->hide_pro_banner = $this->get_option('ure_hide_pro_banner', 0);
404
  $this->wp_default_role = get_option('default_role');
405
 
406
  // could be sent as by POST, as by GET
659
  // end of show_message()
660
 
661
 
662
+ public function make_roles_backup()
663
  {
664
  global $wpdb;
665
 
includes/class-user-role-editor.php CHANGED
@@ -11,6 +11,8 @@
11
  class User_Role_Editor {
12
  // common code staff, including options data processor
13
  protected $lib = null;
 
 
14
 
15
  /**
16
  * class constructor
@@ -24,10 +26,10 @@ class User_Role_Editor {
24
  }
25
 
26
  // activation action
27
- register_activation_hook(URE_PLUGIN_FILE, array(&$this, 'setup'));
28
 
29
  // deactivation action
30
- register_deactivation_hook(URE_PLUGIN_FILE, array(&$this, 'cleanup'));
31
 
32
  // get plugin specific library object
33
  $this->lib = Garvs_WP_Lib::get_library('ure');
@@ -169,6 +171,19 @@ class User_Role_Editor {
169
 
170
  global $wpdb;
171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  // get user_id of users with 'Administrator' role
173
  $tableName = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
174
  $meta_key = $wpdb->prefix . 'capabilities';
@@ -183,8 +198,7 @@ class User_Role_Editor {
183
  }
184
  }
185
  // end of exclude_administrators()
186
-
187
-
188
 
189
  /*
190
  * Exclude view of users with Administrator role
@@ -217,13 +231,7 @@ class User_Role_Editor {
217
  if (is_super_admin() ||
218
  (is_multisite() && defined('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE') && URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE == 1 &&
219
  current_user_can('administrator'))) {
220
- if (isset($user->caps['administrator'])) {
221
- if ($current_user->ID != $user->ID) {
222
- unset($actions['edit']);
223
- unset($actions['delete']);
224
- unset($actions['remove']);
225
- }
226
- } else if ($current_user->has_cap(URE_KEY_CAPABILITY)) {
227
  $actions['capabilities'] = '<a href="' .
228
  wp_nonce_url("users.php?page=".URE_PLUGIN_FILE."&object=user&amp;user_id={$user->ID}", "ure_user_{$user->ID}") .
229
  '">' . __('Capabilities', 'ure') . '</a>';
@@ -342,12 +350,10 @@ class User_Role_Editor {
342
 
343
 
344
  public function plugin_menu() {
345
-
346
- if (function_exists('add_submenu_page')) {
347
- $key_capability = $this->lib->get_key_capability();
348
- $ure_page = add_submenu_page('users.php', __('User Role Editor', 'ure'), __('User Role Editor', 'ure'), $key_capability,
349
- URE_PLUGIN_FILE, array(&$this, 'edit_roles'));
350
- add_action("admin_print_styles-$ure_page", array( &$this, 'admin_css_action' ) );
351
  }
352
  }
353
  // end of plugin_menu()
@@ -385,16 +391,26 @@ class User_Role_Editor {
385
  // end of edit_roles()
386
 
387
 
 
 
 
 
 
 
 
 
388
 
389
  /**
390
  * execute on plugin activation
391
  */
392
  function setup() {
393
 
394
- $this->lib->put_option( 'ure_caps_readable', 0 );
395
- $this->lib->put_option( 'ure_show_deprecated_caps', 1 );
 
396
  $this->lib->flush_options();
397
- $this->lib->make_roles_backup();
 
398
 
399
  }
400
  // end of setup()
11
  class User_Role_Editor {
12
  // common code staff, including options data processor
13
  protected $lib = null;
14
+
15
+ public $key_capability = 'administrator';
16
 
17
  /**
18
  * class constructor
26
  }
27
 
28
  // activation action
29
+ register_activation_hook(URE_PLUGIN_FULL_PATH, array(&$this, 'setup'));
30
 
31
  // deactivation action
32
+ register_deactivation_hook(URE_PLUGIN_FULL_PATH, array(&$this, 'cleanup'));
33
 
34
  // get plugin specific library object
35
  $this->lib = Garvs_WP_Lib::get_library('ure');
171
 
172
  global $wpdb;
173
 
174
+ $result = false;
175
+ $links_to_block = array('profile.php', 'users.php');
176
+ foreach ( $links_to_block as $key => $value ) {
177
+ $result = stripos($_SERVER['REQUEST_URI'], $value);
178
+ if ( $result !== false ) {
179
+ break;
180
+ }
181
+ }
182
+
183
+ if ( $result===false ) { // block the user edit stuff only
184
+ return;
185
+ }
186
+
187
  // get user_id of users with 'Administrator' role
188
  $tableName = (!is_multisite() && defined('CUSTOM_USER_META_TABLE')) ? CUSTOM_USER_META_TABLE : $wpdb->usermeta;
189
  $meta_key = $wpdb->prefix . 'capabilities';
198
  }
199
  }
200
  // end of exclude_administrators()
201
+
 
202
 
203
  /*
204
  * Exclude view of users with Administrator role
231
  if (is_super_admin() ||
232
  (is_multisite() && defined('URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE') && URE_ENABLE_SIMPLE_ADMIN_FOR_MULTISITE == 1 &&
233
  current_user_can('administrator'))) {
234
+ if ($current_user->has_cap(URE_KEY_CAPABILITY)) {
 
 
 
 
 
 
235
  $actions['capabilities'] = '<a href="' .
236
  wp_nonce_url("users.php?page=".URE_PLUGIN_FILE."&object=user&amp;user_id={$user->ID}", "ure_user_{$user->ID}") .
237
  '">' . __('Capabilities', 'ure') . '</a>';
350
 
351
 
352
  public function plugin_menu() {
353
+ $this->key_capability = $this->lib->get_key_capability();
354
+ if (function_exists('add_submenu_page')) {
355
+ $ure_page = add_submenu_page('users.php', __('User Role Editor', 'ure'), __('User Role Editor', 'ure'), $this->key_capability, URE_PLUGIN_FILE, array(&$this, 'edit_roles'));
356
+ add_action("admin_print_styles-$ure_page", array(&$this, 'admin_css_action'));
 
 
357
  }
358
  }
359
  // end of plugin_menu()
391
  // end of edit_roles()
392
 
393
 
394
+ // move old version option to the new storage 'user_role_editor' option, array, containing all URE options
395
+ private function convert_option($option_name) {
396
+
397
+ $option_value = get_option($option_name, 0);
398
+ delete_option($option_name);
399
+ $this->lib->put_option( $option_name, $option_value );
400
+
401
+ }
402
 
403
  /**
404
  * execute on plugin activation
405
  */
406
  function setup() {
407
 
408
+ $this->convert_option('ure_caps_readable');
409
+ $this->convert_option('ure_show_deprecated_caps');
410
+ $this->convert_option('ure_hide_pro_banner');
411
  $this->lib->flush_options();
412
+
413
+ $this->lib->make_roles_backup();
414
 
415
  }
416
  // end of setup()
includes/ure-user-edit.php CHANGED
@@ -98,6 +98,10 @@ if (function_exists('bbp_filter_blog_editable_roles') ) { // bbPress plugin is
98
  </td>
99
  <td style="padding-left: 5px; padding-top: 5px; border-top: 1px solid #ccc;">
100
  <span style="font-weight: bold;"><?php _e('Core capabilities:', 'ure'); ?></span>
 
 
 
 
101
  <table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
102
  <tr>
103
  <td style="vertical-align:top;">
98
  </td>
99
  <td style="padding-left: 5px; padding-top: 5px; border-top: 1px solid #ccc;">
100
  <span style="font-weight: bold;"><?php _e('Core capabilities:', 'ure'); ?></span>
101
+ <div style="display:table-inline; float: right; margin-right: 12px;">
102
+ <?php _e('Quick filter:', 'ure'); ?>&nbsp;
103
+ <input type="text" id="quick_filter" name="quick_filter" value="" size="20" onkeyup="ure_filter_capabilities(this.value);" />
104
+ </div>
105
  <table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
106
  <tr>
107
  <td style="vertical-align:top;">
js/ure-js.js CHANGED
@@ -304,8 +304,9 @@ function ure_select_all(selected) {
304
  if (el.type !== 'checkbox') {
305
  continue;
306
  }
307
- if (el.name === 'ure_caps_readable' || el.name === 'ure_show_deprecated_caps' || el.disabled ||
308
- el.name.substr(0, 8) === 'wp_role_') {
 
309
  continue;
310
  }
311
  if (qfilter!=='' && !form.elements[i].parentNode.ure_tag) {
304
  if (el.type !== 'checkbox') {
305
  continue;
306
  }
307
+ if (el.name === 'ure_caps_readable' || el.name === 'ure_show_deprecated_caps' ||
308
+ el.name === 'ure_apply_to_all' || el.disabled ||
309
+ el.name.substr(0, 8) === 'wp_role_') {
310
  continue;
311
  }
312
  if (qfilter!=='' && !form.elements[i].parentNode.ure_tag) {
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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: 3.5
6
- Tested up to: 3.5.2
7
  Stable tag: trunk
8
 
9
  User Role Editor WordPress plugin makes the role capabilities changing easy. You can change any standard WordPress user role.
@@ -76,6 +76,13 @@ Share with me new ideas about plugin further development and link to your site w
76
 
77
 
78
  == Changelog ==
 
 
 
 
 
 
 
79
  = 4.1 =
80
  * 03.07.2013
81
  * Quick Filter is added. Type part of any capability. All capabilities containing that word, e.g. 'edit' or 'users' will be highlighted by green color.
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: 3.5
6
+ Tested up to: 3.6
7
  Stable tag: trunk
8
 
9
  User Role Editor WordPress plugin makes the role capabilities changing easy. You can change any standard WordPress user role.
76
 
77
 
78
  == Changelog ==
79
+ = 4.1.1 =
80
+ * 15.07.2013
81
+ * Issue when "users with "Editor" credentials were no longer able to change the author name in the drop down on each post to someone with administrative credentials" is fixed.
82
+ * Limitation when user with 'Administrator' role could not edit/delete other users with 'Administrator' role is removed.
83
+ * "Apply to All sites" checkbox is excluded from "Select All" operation.
84
+ * Quick filter is added to the user's capabilities edit form. Capabilities selection buttons work is fixed after that.
85
+
86
  = 4.1 =
87
  * 03.07.2013
88
  * Quick Filter is added. Type part of any capability. All capabilities containing that word, e.g. 'edit' or 'users' will be highlighted by green color.
uninstall.php CHANGED
@@ -17,6 +17,8 @@ if (!is_multisite()) {
17
  delete_option($backup_option_name);
18
  delete_option('ure_caps_readable');
19
  delete_option('ure_show_deprecated_caps');
 
 
20
  } else {
21
  $old_blog = $wpdb->blogid;
22
  // Get all blog ids
@@ -27,8 +29,14 @@ if (!is_multisite()) {
27
  delete_option($backup_option_name);
28
  delete_option('ure_caps_readable');
29
  delete_option('ure_show_deprecated_caps');
 
 
30
  }
31
  switch_to_blog($old_blog);
32
  }
33
 
 
 
 
 
34
  ?>
17
  delete_option($backup_option_name);
18
  delete_option('ure_caps_readable');
19
  delete_option('ure_show_deprecated_caps');
20
+ delete_option('ure_hide_pro_banner');
21
+ delete_option('user_role_editor');
22
  } else {
23
  $old_blog = $wpdb->blogid;
24
  // Get all blog ids
29
  delete_option($backup_option_name);
30
  delete_option('ure_caps_readable');
31
  delete_option('ure_show_deprecated_caps');
32
+ delete_option('ure_hide_pro_banner');
33
+ delete_option('user_role_editor');
34
  }
35
  switch_to_blog($old_blog);
36
  }
37
 
38
+ if (file_exist('uninstall-pro.php')) {
39
+ include('uninstall-pro.php');
40
+ }
41
+
42
  ?>
user-role-editor.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: User Role Editor
4
  Plugin URI: http://role-editor.com
5
  Description: Change/add/delete WordPress user roles and capabilities.
6
- Version: 4.1
7
  Author: Vladimir Garagulya
8
  Author URI: http://www.shinephp.com
9
  Text Domain: ure
3
  Plugin Name: User Role Editor
4
  Plugin URI: http://role-editor.com
5
  Description: Change/add/delete WordPress user roles and capabilities.
6
+ Version: 4.1.1
7
  Author: Vladimir Garagulya
8
  Author URI: http://www.shinephp.com
9
  Text Domain: ure