User Role Editor - Version 4.1

Version Description

  • 03.07.2013
  • 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. While 'quick filter' is in action 'Select All', 'Unselect All', 'Inverse' buttons work with highlighted capabilities sub-set only. Read this post for more information:
  • Class property and method access modifiers fatal errors were fixed (http://wordpress.org/support/topic/fatalerror-1).
Download this release

Release Info

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

Code changes from version 4.0 to 4.1

images/user-role-editor-pro-728x90.jpg ADDED
Binary file
images/user-role-editor-pro.png DELETED
Binary file
images/vum-ebook-250-250.jpg ADDED
Binary file
images/vum-submit.jpg ADDED
Binary file
includes/class-advertisement.php CHANGED
@@ -21,9 +21,11 @@ class ure_Advertisement {
21
  $used[] = $index;
22
  $index = $this->rand_unique( $used );
23
  $this->slots[$index] = $this->manage_wp();
24
-
25
- $this->slots[] = $this->user_role_editor();
26
-
 
 
27
  }
28
  // end of __construct
29
 
@@ -78,21 +80,49 @@ class ure_Advertisement {
78
  // end of manage_wp()
79
 
80
 
81
- // content of User Role Editor advertisement slot
82
- private function user_role_editor() {
83
 
84
- $output = '
85
- <div style="text-align: center;">
86
- <a href="http://role-editor.com?utm_source=UserRoleEditor&utm_medium=banner&utm_campaign=Plugins " target="_new" >
87
- <img src="'. URE_PLUGIN_URL . 'images/user-role-editor-pro.png' .'" alt="User Role Editor Pro" title="More functionality and premium support with Pro version of User Role Editor."/>
88
- </a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  </div>
90
- ';
 
 
91
 
92
  return $output;
93
  }
94
- // end of user_role_editor()
95
-
96
 
97
  /**
98
  * Output all existed ads slots
21
  $used[] = $index;
22
  $index = $this->rand_unique( $used );
23
  $this->slots[$index] = $this->manage_wp();
24
+
25
+ $used[] = $index;
26
+ $index = $this->rand_unique( $used );
27
+ $this->slots[$index] = $this->video_user_manuals();
28
+
29
  }
30
  // end of __construct
31
 
80
  // end of manage_wp()
81
 
82
 
83
+ // content of Video User Manuals advertisement slot
84
+ private function video_user_manuals() {
85
 
86
+ ob_start();
87
+ ?>
88
+ <div style="margin-left: 3px; margin-bottom: 3px; text-align: center; background: url(<?php echo URE_PLUGIN_URL . 'images/vum-ebook-250-250.jpg'; ?>) left top no-repeat;">
89
+ <div style="width: 250px; height: 250px; position: relative; ">
90
+ <form accept-charset="utf-8" action="https://app.getresponse.com/add_contact_webform.html" method="post" onsubmit="return quickValidate()" target="_blank">
91
+ <div style="display: none;">
92
+ <input type="hidden" name="webform_id" value="430680" />
93
+ </div>
94
+ <input id="vum_sub_name" type="text" name="name" class="text" tabindex="500" value="Enter your name" style="border: 0; position: absolute; left:129px;top:91px;height: 18px; width: 90px;background-color: #fff; font-size: 11px;" onfocus="this.value='';" />
95
+ <input class="text" id="vum_sub_email" type="text" name="email" tabindex="501" value="Email" style="border: 0; position: absolute; left:129px;top:126px;height: 18px; width: 90px;background-color: #fff; font-size: 11px;" onfocus="this.value='';" />
96
+ <input name="submit" type="image" alt="submit" tabindex="502" src="<?php echo URE_PLUGIN_URL; ?>images/vum-submit.jpg" width="100" height="25" style="background: none; border: 0;position: absolute; left:121px;top:154px;" />
97
+ <a href="http://www.videousermanuals.com/blog/report/?utm_campaign=plugin-ads&utm_medium=plugin&utm_source=user-role-editor" target="_blank" style="position: absolute; left: 7px;top: 63px;width:102px;height:152px;border:0;text-decoration: none;">&nbsp;</a>
98
+ <a href="http://www.videousermanuals.com/blog/report/?utm_campaign=plugin-ads&utm_medium=plugin&utm_source=user-role-editor" target="_blank" style="position: absolute; left: 41px;top: 219px;width:163px;height:25px;border:0;text-decoration: none;">&nbsp;</a>
99
+ </form>
100
+ </div>
101
+ <script type="text/javascript">
102
+ function quickValidate() {
103
+ if ((!jQuery('#vum_sub_name').val()) || (jQuery('#vum_sub_name').val() == 'Enter your name') )
104
+ {
105
+ alert('Your Name is required');
106
+ return false;
107
+ }
108
+ if ((!jQuery('#vum_sub_email').val()) || (jQuery('#vum_sub_email').val() == 'Email') )
109
+ {
110
+ alert('Your Email is required');
111
+ return false;
112
+ }
113
+ return true;
114
+ }
115
+ </script>
116
+
117
  </div>
118
+ <?php
119
+ $output = ob_get_contents();
120
+ ob_end_clean();
121
 
122
  return $output;
123
  }
124
+ // end of video_user_manuals()
125
+
126
 
127
  /**
128
  * Output all existed ads slots
includes/class-ure-lib.php CHANGED
@@ -13,26 +13,28 @@
13
  */
14
  class Ure_Lib extends Garvs_WP_Lib {
15
 
16
- public $roles = null;
17
- public $notification = ''; // notification message to show on page
18
- public $apply_to_all = 0;
 
19
 
20
- private $capabilities_to_save = null;
21
- private $current_role = '';
22
- private $wp_default_role = '';
23
- private $current_role_name = '';
24
- private $user_to_edit = '';
25
- private $show_deprecated_caps = false;
26
- private $caps_readable = false;
27
- private $user_to_check = array(); // cached list of user IDs, who has Administrator role
28
- private $full_capabilities = false;
29
- private $ure_object = 'role'; // what to process, 'role' or 'user'
30
- private $role_default_html = '';
31
- private $role_to_copy_html = '';
32
- private $role_select_html = '';
33
- private $role_delete_html = '';
34
- private $capability_remove_html = '';
35
- private $integrate_with_gravity_forms = false;
 
36
 
37
 
38
  /** class constructor
@@ -91,8 +93,8 @@ class Ure_Lib extends Garvs_WP_Lib {
91
  private function advertisement() {
92
 
93
  if (!class_exists('User_Role_Editor_Pro')) {
94
- $ure_advert = new ure_Advertisement();
95
- $ure_advert->display();
96
  }
97
  }
98
  // end of advertisement()
@@ -184,10 +186,12 @@ class Ure_Lib extends Garvs_WP_Lib {
184
  ?>
185
  </div>
186
  </form>
187
- <?php
188
- if ($this->ure_object == 'role') {
189
- $this->output_role_edit_dialogs();
190
- }
 
 
191
  ?>
192
  </div>
193
  </div>
@@ -197,7 +201,36 @@ class Ure_Lib extends Garvs_WP_Lib {
197
  }
198
  // end of show_editor()
199
 
200
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  // validate information about user we intend to edit
202
  private function check_user_to_edit() {
203
 
@@ -335,6 +368,9 @@ class Ure_Lib extends Garvs_WP_Lib {
335
  $this->show_deprecated_caps = 1;
336
  }
337
  update_option('ure_show_deprecated_caps', $this->show_deprecated_caps);
 
 
 
338
  } else if ($action == 'add-new-capability') {
339
  $this->notification = $this->add_new_capability();
340
  } else if ($action == 'delete-user-capability') {
@@ -361,6 +397,7 @@ class Ure_Lib extends Garvs_WP_Lib {
361
  private function editor_init0() {
362
  $this->caps_readable = get_option('ure_caps_readable');
363
  $this->show_deprecated_caps = get_option('ure_show_deprecated_caps');
 
364
  $this->wp_default_role = get_option('default_role');
365
 
366
  // could be sent as by POST, as by GET
@@ -422,7 +459,7 @@ class Ure_Lib extends Garvs_WP_Lib {
422
  * @param int $user_id
423
  * @return boolean returns true is user has Role "Administrator"
424
  */
425
- private function has_administrator_role($user_id) {
426
  global $wpdb;
427
 
428
  if (empty($user_id) || !is_numeric($user_id)) {
@@ -941,7 +978,7 @@ class Ure_Lib extends Garvs_WP_Lib {
941
  }
942
  }
943
  $cap_id = str_replace(' ', URE_SPACE_REPLACER, $capability['inner']);
944
- echo '<input type="checkbox" name="' . $cap_id . '" id="' . $cap_id . '" value="' . $capability['inner'] . '" ' .
945
  $hidden_class . ' ' . $checked . ' ' . $disabled . ' ' . $onclick_for_admin . ' />';
946
  if (empty($hidden_class)) {
947
  if ($this->caps_readable) {
@@ -952,14 +989,14 @@ class Ure_Lib extends Garvs_WP_Lib {
952
  $cap_ind_alt = 'human';
953
  }
954
  echo '<label for="' . $cap_id . '" title="' . $capability[$cap_ind_alt] . '" ' . $labelStyle . ' > ' .
955
- $capability[$cap_ind] . '</label> ' . $this->capability_help_link($capability['inner']) . '<br/>';
956
  $printed_quant++;
957
  if ($printed_quant >= $quant_in_column) {
958
  $printed_quant = 0;
959
  echo '</td>
960
  <td style="vertical-align:top;">';
961
  }
962
- } // if ('hidden'
963
  }
964
  }
965
  // end of ure_show_capabilities()
13
  */
14
  class Ure_Lib extends Garvs_WP_Lib {
15
 
16
+ public $roles = null;
17
+ public $notification = ''; // notification message to show on page
18
+ public $apply_to_all = 0;
19
+ public $user_to_check = array(); // cached list of user IDs, who has Administrator role
20
 
21
+ private $capabilities_to_save = null;
22
+ private $current_role = '';
23
+ private $wp_default_role = '';
24
+ private $current_role_name = '';
25
+ private $user_to_edit = '';
26
+ private $show_deprecated_caps = false;
27
+ private $caps_readable = false;
28
+ private $hide_pro_banner = false;
29
+ private $full_capabilities = false;
30
+ private $ure_object = 'role'; // what to process, 'role' or 'user'
31
+ private $role_default_html = '';
32
+ private $role_to_copy_html = '';
33
+ private $role_select_html = '';
34
+ private $role_delete_html = '';
35
+ private $capability_remove_html = '';
36
+ private $integrate_with_gravity_forms = false;
37
+ private $advert = null;
38
 
39
 
40
  /** class constructor
93
  private function advertisement() {
94
 
95
  if (!class_exists('User_Role_Editor_Pro')) {
96
+ $this->advert = new ure_Advertisement();
97
+ $this->advert->display();
98
  }
99
  }
100
  // end of advertisement()
186
  ?>
187
  </div>
188
  </form>
189
+ <?php
190
+ $this->advertise_pro_version();
191
+
192
+ if ($this->ure_object == 'role') {
193
+ $this->output_role_edit_dialogs();
194
+ }
195
  ?>
196
  </div>
197
  </div>
201
  }
202
  // end of show_editor()
203
 
204
+
205
+ // content of User Role Editor Pro advertisement slot - for direct call
206
+ private function advertise_pro_version() {
207
+ if (class_exists('User_Role_Editor_Pro')) {
208
+ return;
209
+ }
210
+ ?>
211
+ <div id="ure_pro_advertisement" style="clear:left;display:block; float: left;">
212
+ <a href="http://role-editor.com?utm_source=UserRoleEditor&utm_medium=banner&utm_campaign=Plugins " target="_new" >
213
+ <?php
214
+ if ($this->hide_pro_banner) {
215
+ echo 'User Role Editor Pro: extended functionality, no advertisement - from $29.</a>';
216
+ } else {
217
+ ?>
218
+ <img src="<?php echo URE_PLUGIN_URL;?>images/user-role-editor-pro-728x90.jpg" alt="User Role Editor Pro"
219
+ title="More functionality and premium support with Pro version of User Role Editor."/>
220
+ </a><br />
221
+ <label for id="hide_ure_pro">
222
+ <input type="checkbox" name="hide_ure_pro_banner" id="ure_hide_pro_banner" onclick="ure_hide_pro_banner();"/>&nbsp;Thanks, hide this banner.
223
+ </label>
224
+ <?php
225
+ }
226
+ ?>
227
+ </div>
228
+ <?php
229
+
230
+ }
231
+ // end of user_role_editor()
232
+
233
+
234
  // validate information about user we intend to edit
235
  private function check_user_to_edit() {
236
 
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') {
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
459
  * @param int $user_id
460
  * @return boolean returns true is user has Role "Administrator"
461
  */
462
+ public function has_administrator_role($user_id) {
463
  global $wpdb;
464
 
465
  if (empty($user_id) || !is_numeric($user_id)) {
978
  }
979
  }
980
  $cap_id = str_replace(' ', URE_SPACE_REPLACER, $capability['inner']);
981
+ echo '<div id="ure_div_cap_'.$cap_id.'"><input type="checkbox" name="' . $cap_id . '" id="' . $cap_id . '" value="' . $capability['inner'] . '" ' .
982
  $hidden_class . ' ' . $checked . ' ' . $disabled . ' ' . $onclick_for_admin . ' />';
983
  if (empty($hidden_class)) {
984
  if ($this->caps_readable) {
989
  $cap_ind_alt = 'human';
990
  }
991
  echo '<label for="' . $cap_id . '" title="' . $capability[$cap_ind_alt] . '" ' . $labelStyle . ' > ' .
992
+ $capability[$cap_ind] . '</label> ' . $this->capability_help_link($capability['inner']) . '</div>';
993
  $printed_quant++;
994
  if ($printed_quant >= $quant_in_column) {
995
  $printed_quant = 0;
996
  echo '</td>
997
  <td style="vertical-align:top;">';
998
  }
999
+ } // if (empty($hidden_class
1000
  }
1001
  }
1002
  // end of ure_show_capabilities()
includes/class-user-role-editor.php CHANGED
@@ -140,7 +140,7 @@ class User_Role_Editor {
140
  } else {
141
  if (!isset($this->lib->user_to_check[$user_id])) {
142
  // check if user_id has Administrator role
143
- $access_deny = $this->has_administrator_role($user_id);
144
  } else {
145
  // user_id was checked already, get result from cash
146
  $access_deny = $this->lib->user_to_check[$user_id];
140
  } else {
141
  if (!isset($this->lib->user_to_check[$user_id])) {
142
  // check if user_id has Administrator role
143
+ $access_deny = $this->lib->has_administrator_role($user_id);
144
  } else {
145
  // user_id was checked already, get result from cash
146
  $access_deny = $this->lib->user_to_check[$user_id];
includes/ure-role-edit.php CHANGED
@@ -61,6 +61,10 @@ if (is_multisite() && is_main_site( get_current_blog_id() ) && is_super_admin())
61
  <br /><br />
62
  <hr />
63
  <?php _e('Core capabilities:', 'ure'); ?>
 
 
 
 
64
  <table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
65
  <tr>
66
  <td style="vertical-align:top;">
61
  <br /><br />
62
  <hr />
63
  <?php _e('Core capabilities:', 'ure'); ?>
64
+ <div style="display:table-inline; float: right; margin-right: 12px;">
65
+ <?php _e('Quick filter:', 'ure'); ?>&nbsp;
66
+ <input type="text" id="quick_filter" name="quick_filter" value="" size="20" onkeyup="ure_filter_capabilities(this.value);" />
67
+ </div>
68
  <table class="form-table" style="clear:none;" cellpadding="0" cellspacing="0">
69
  <tr>
70
  <td style="vertical-align:top;">
js/ure-js.js CHANGED
@@ -297,6 +297,7 @@ function turn_it_back(control) {
297
  */
298
  function ure_select_all(selected) {
299
 
 
300
  var form = document.getElementById('ure_form');
301
  for (i = 0; i < form.elements.length; i++) {
302
  el = form.elements[i];
@@ -307,11 +308,15 @@ function ure_select_all(selected) {
307
  el.name.substr(0, 8) === 'wp_role_') {
308
  continue;
309
  }
310
- if (selected >= 0) {
311
- form.elements[i].checked = selected;
312
- } else {
313
- form.elements[i].checked = !form.elements[i].checked;
314
- }
 
 
 
 
315
  }
316
 
317
  }
@@ -334,10 +339,11 @@ function ure_turn_caps_readable(user_id) {
334
 
335
  function ure_turn_deprecated_caps(user_id) {
336
 
 
337
  if (user_id === 0) {
338
- var ure_object = 'role';
339
  } else {
340
- var ure_object = 'user';
341
  }
342
  jQuery.ure_postGo(ure_data.page_url, {action: 'show-deprecated-caps', object: ure_object, user_id: user_id, ure_nonce: ure_data.wp_nonce});
343
 
@@ -350,4 +356,28 @@ function ure_role_change(role_name) {
350
  jQuery.ure_postGo(ure_data.page_url, {action: 'role-change', object: 'role', user_role: role_name, ure_nonce: ure_data.wp_nonce});
351
 
352
  }
353
- // end of ure_role_change()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  */
298
  function ure_select_all(selected) {
299
 
300
+ var qfilter = jQuery('#quick_filter').val();
301
  var form = document.getElementById('ure_form');
302
  for (i = 0; i < form.elements.length; i++) {
303
  el = form.elements[i];
308
  el.name.substr(0, 8) === 'wp_role_') {
309
  continue;
310
  }
311
+ if (qfilter!=='' && !form.elements[i].parentNode.ure_tag) {
312
+ continue;
313
+ }
314
+ if (selected >= 0) {
315
+ form.elements[i].checked = selected;
316
+ } else {
317
+ form.elements[i].checked = !form.elements[i].checked;
318
+ }
319
+
320
  }
321
 
322
  }
339
 
340
  function ure_turn_deprecated_caps(user_id) {
341
 
342
+ var ure_object = '';
343
  if (user_id === 0) {
344
+ ure_object = 'role';
345
  } else {
346
+ ure_object = 'user';
347
  }
348
  jQuery.ure_postGo(ure_data.page_url, {action: 'show-deprecated-caps', object: ure_object, user_id: user_id, ure_nonce: ure_data.wp_nonce});
349
 
356
  jQuery.ure_postGo(ure_data.page_url, {action: 'role-change', object: 'role', user_role: role_name, ure_nonce: ure_data.wp_nonce});
357
 
358
  }
359
+ // end of ure_role_change()
360
+
361
+
362
+ function ure_filter_capabilities(cap_id) {
363
+ var div_list = jQuery("div[id^='ure_div_cap_']");
364
+ for (i=0; i<div_list.length; i++) {
365
+ if (cap_id!=='' && div_list[i].id.substr(11).indexOf(cap_id)!==-1) {
366
+ div_list[i].ure_tag = true;
367
+ div_list[i].style.color = '#27CF27';
368
+ } else {
369
+ div_list[i].style.color = '#000000';
370
+ div_list[i].ure_tag = false;
371
+ }
372
+ };
373
+
374
+ }
375
+ // end of ure_filter_capabilities()
376
+
377
+
378
+ function ure_hide_pro_banner() {
379
+
380
+ jQuery.ure_postGo(ure_data.page_url, {action: 'hide-pro-banner', ure_nonce: ure_data.wp_nonce});
381
+
382
+ }
383
+ // end of ure_hide_this_banner()
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  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.2
6
  Tested up to: 3.5.2
7
  Stable tag: trunk
8
 
@@ -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.0 =
80
  * 30.06.2013
81
  * Pro version only: added 'Export/Import' functionality to 'export' all user roles to the local file and 'import' them then to other WordPress blog or other sites of muliti-site WordPress network, or just restore roles to previous state after playing with them with test purpose.
2
  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
 
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.
82
+ While 'quick filter' is in action 'Select All', 'Unselect All', 'Inverse' buttons work with highlighted capabilities sub-set only.
83
+ Read [this post](http://role-editor.com/user-role-editor-version-4-1-is-available/) for more information:
84
+ * Class property and method access modifiers fatal errors were fixed (http://wordpress.org/support/topic/fatalerror-1).
85
+
86
  = 4.0 =
87
  * 30.06.2013
88
  * Pro version only: added 'Export/Import' functionality to 'export' all user roles to the local file and 'import' them then to other WordPress blog or other sites of muliti-site WordPress network, or just restore roles to previous state after playing with them with test purpose.
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.0
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
7
  Author: Vladimir Garagulya
8
  Author URI: http://www.shinephp.com
9
  Text Domain: ure