User Role Editor - Version 4.19.1

Version Description

Download this release

Release Info

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

Code changes from version 4.19 to 4.19.1

images/wp-esignature.png ADDED
Binary file
includes/class-advertisement.php CHANGED
@@ -21,6 +21,11 @@ class ure_Advertisement {
21
  $used[] = $index;
22
  $index = $this->rand_unique( $used );
23
  $this->slots[$index] = $this->manage_wp();
 
 
 
 
 
24
 
25
  }
26
  // end of __construct
@@ -74,6 +79,22 @@ class ure_Advertisement {
74
  return $output;
75
  }
76
  // end of manage_wp()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
 
79
  /**
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->wp_esignature();
28
+
29
 
30
  }
31
  // end of __construct
79
  return $output;
80
  }
81
  // end of manage_wp()
82
+
83
+
84
+ // content of WP eSignature advertisement slot
85
+ private function wp_esignature() {
86
+
87
+ $output = '
88
+ <div style="text-align: center;">
89
+ <a title="WP E-Signature" href="https://www.approveme.me/?utm_source=role-editor&utm_medium=250x250&utm_term=get%20contracts%20signed%205x%20faster%20with%20wordpress&utm_content=v1&utm_campaign=role-editor" target="_new" >
90
+ <img width="250" height="250" alt="WP E-Signature" src="'. URE_PLUGIN_URL .'images/wp-esignature.png">
91
+ </a>
92
+ </div>
93
+ ';
94
+
95
+ return $output;
96
+ }
97
+ // end of manage_wp()
98
 
99
 
100
  /**
includes/class-ure-lib.php CHANGED
@@ -28,7 +28,7 @@ class Ure_Lib extends Garvs_WP_Lib {
28
  protected $hide_pro_banner = false;
29
  protected $full_capabilities = false;
30
  protected $ure_object = 'role'; // what to process, 'role' or 'user'
31
- public $role_default_html = '';
32
  protected $role_to_copy_html = '';
33
  protected $role_select_html = '';
34
  protected $role_delete_html = '';
@@ -1065,12 +1065,12 @@ class Ure_Lib extends Garvs_WP_Lib {
1065
  *
1066
  * @return string
1067
  */
1068
- protected function get_caps_to_remove_html() {
1069
 
1070
  $caps_to_remove = $this->get_caps_to_remove();
1071
  if (!empty($caps_to_remove) && is_array($caps_to_remove) && count($caps_to_remove) > 0) {
1072
  $html = '<select id="remove_user_capability" name="remove_user_capability" width="200" style="width: 200px">';
1073
- foreach ($caps_to_remove as $key => $value) {
1074
  $html .= '<option value="' . $key . '">' . $key . '</option>';
1075
  }
1076
  $html .= '</select>';
@@ -1078,9 +1078,9 @@ class Ure_Lib extends Garvs_WP_Lib {
1078
  $html = '';
1079
  }
1080
 
1081
- return $html;
1082
  }
1083
- // end of getCapsToRemoveHTML()
1084
 
1085
 
1086
  /**
@@ -2147,16 +2147,18 @@ class Ure_Lib extends Garvs_WP_Lib {
2147
  if (!empty($_POST['user_role_id'])) {
2148
  $user_role_id = $_POST['user_role_id'];
2149
  unset($_POST['user_role_id']);
2150
- $errorMessage = 'Error! ' . esc_html__('Error encountered during default role change operation', 'ure');
2151
  if (isset($wp_roles->role_objects[$user_role_id]) && $user_role_id !== 'administrator') {
2152
  $result = update_option('default_role', $user_role_id);
2153
  if (empty($result)) {
2154
- $mess = $errorMessage;
2155
  } else {
 
2156
  $mess = sprintf(esc_html__('Default role for new users is set to %s successfully', 'ure'), $wp_roles->role_names[$user_role_id]);
2157
  }
 
 
2158
  } else {
2159
- $mess = $errorMessage;
2160
  }
2161
  }
2162
 
@@ -2424,7 +2426,7 @@ class Ure_Lib extends Garvs_WP_Lib {
2424
  }
2425
  }
2426
 
2427
- $mess = sprintf(esc_html__('Capability %s is removed successfully', 'ure'), $capability_id);
2428
  }
2429
 
2430
  return $mess;
@@ -2535,7 +2537,8 @@ class Ure_Lib extends Garvs_WP_Lib {
2535
  // end of show_admin_role()
2536
 
2537
 
2538
- public function role_edit_prepare_html($select_width=200) {
 
2539
  $caps_access_restrict_for_simple_admin = $this->get_option('caps_access_restrict_for_simple_admin', 0);
2540
  $show_admin_role = $this->show_admin_role_allowed();
2541
  if ($select_width>0) {
@@ -2544,12 +2547,8 @@ class Ure_Lib extends Garvs_WP_Lib {
2544
  $select_style = '';
2545
  }
2546
  $this->role_default_html = '<select id="default_user_role" name="default_user_role" '. $select_style .'>';
2547
- $this->role_to_copy_html = '<select id="user_role_copy_from" name="user_role_copy_from" style="width: '. $select_width .'px">
2548
- <option value="none" selected="selected">' . esc_html__('None', 'ure') . '</option>';
2549
- $this->role_select_html = '<select id="user_role" name="user_role" onchange="ure_role_change(this.value);">';
2550
  foreach ($this->roles as $key => $value) {
2551
- $selected1 = $this->option_selected($key, $this->current_role);
2552
- $selected2 = $this->option_selected($key, $this->wp_default_role);
2553
  $disabled = ($key==='administrator' && $caps_access_restrict_for_simple_admin && !is_super_admin()) ? 'disabled' : '';
2554
  if ($show_admin_role || $key != 'administrator') {
2555
  $translated_name = esc_html__($value['name'], 'ure'); // get translation from URE language file, if exists
@@ -2557,15 +2556,16 @@ class Ure_Lib extends Garvs_WP_Lib {
2557
  $translated_name = translate_user_role($translated_name);
2558
  }
2559
  $translated_name .= ' (' . $key . ')';
2560
- $this->role_select_html .= '<option value="' . $key . '" ' . $selected1 .' '. $disabled .'>' . $translated_name . '</option>';
2561
- $this->role_default_html .= '<option value="' . $key . '" ' . $selected2 .' '. $disabled .'>' . $translated_name . '</option>';
2562
- $this->role_to_copy_html .= '<option value="' . $key .'" '. $disabled .'>' . $translated_name . '</option>';
2563
  }
2564
  }
2565
- $this->role_select_html .= '</select>';
2566
  $this->role_default_html .= '</select>';
2567
- $this->role_to_copy_html .= '</select>';
2568
-
 
 
 
 
2569
  $roles_can_delete = $this->get_roles_can_delete();
2570
  if ($roles_can_delete && count($roles_can_delete) > 0) {
2571
  $this->role_delete_html = '<select id="del_user_role" name="del_user_role" width="200" style="width: 200px">';
@@ -2577,8 +2577,41 @@ class Ure_Lib extends Garvs_WP_Lib {
2577
  } else {
2578
  $this->role_delete_html = '';
2579
  }
2580
-
2581
- $this->capability_remove_html = $this->get_caps_to_remove_html();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2582
  }
2583
  // end of role_edit_prepare_html()
2584
 
28
  protected $hide_pro_banner = false;
29
  protected $full_capabilities = false;
30
  protected $ure_object = 'role'; // what to process, 'role' or 'user'
31
+ public $role_default_html = '';
32
  protected $role_to_copy_html = '';
33
  protected $role_select_html = '';
34
  protected $role_delete_html = '';
1065
  *
1066
  * @return string
1067
  */
1068
+ protected function caps_to_remove_prepare_html() {
1069
 
1070
  $caps_to_remove = $this->get_caps_to_remove();
1071
  if (!empty($caps_to_remove) && is_array($caps_to_remove) && count($caps_to_remove) > 0) {
1072
  $html = '<select id="remove_user_capability" name="remove_user_capability" width="200" style="width: 200px">';
1073
+ foreach (array_keys($caps_to_remove) as $key) {
1074
  $html .= '<option value="' . $key . '">' . $key . '</option>';
1075
  }
1076
  $html .= '</select>';
1078
  $html = '';
1079
  }
1080
 
1081
+ $this->capability_remove_html = $html;
1082
  }
1083
+ // end of caps_to_remove_prepare_html()
1084
 
1085
 
1086
  /**
2147
  if (!empty($_POST['user_role_id'])) {
2148
  $user_role_id = $_POST['user_role_id'];
2149
  unset($_POST['user_role_id']);
 
2150
  if (isset($wp_roles->role_objects[$user_role_id]) && $user_role_id !== 'administrator') {
2151
  $result = update_option('default_role', $user_role_id);
2152
  if (empty($result)) {
2153
+ $mess = 'Error! ' . esc_html__('Error encountered during default role change operation', 'ure');
2154
  } else {
2155
+ $this->get_default_role();
2156
  $mess = sprintf(esc_html__('Default role for new users is set to %s successfully', 'ure'), $wp_roles->role_names[$user_role_id]);
2157
  }
2158
+ } elseif ($user_role_id === 'administrator') {
2159
+ $mess = 'Error! ' . esc_html__('Can not set Administrator role as a default one', 'ure');
2160
  } else {
2161
+ $mess = 'Error! ' . esc_html__('This role does not exist - ', 'ure') . esc_html($user_role_id);
2162
  }
2163
  }
2164
 
2426
  }
2427
  }
2428
 
2429
+ $mess = sprintf(esc_html__('Capability %s was removed successfully', 'ure'), $capability_id);
2430
  }
2431
 
2432
  return $mess;
2537
  // end of show_admin_role()
2538
 
2539
 
2540
+ private function role_default_prepare_html($select_width=200) {
2541
+
2542
  $caps_access_restrict_for_simple_admin = $this->get_option('caps_access_restrict_for_simple_admin', 0);
2543
  $show_admin_role = $this->show_admin_role_allowed();
2544
  if ($select_width>0) {
2547
  $select_style = '';
2548
  }
2549
  $this->role_default_html = '<select id="default_user_role" name="default_user_role" '. $select_style .'>';
 
 
 
2550
  foreach ($this->roles as $key => $value) {
2551
+ $selected = $this->option_selected($key, $this->wp_default_role);
 
2552
  $disabled = ($key==='administrator' && $caps_access_restrict_for_simple_admin && !is_super_admin()) ? 'disabled' : '';
2553
  if ($show_admin_role || $key != 'administrator') {
2554
  $translated_name = esc_html__($value['name'], 'ure'); // get translation from URE language file, if exists
2556
  $translated_name = translate_user_role($translated_name);
2557
  }
2558
  $translated_name .= ' (' . $key . ')';
2559
+ $this->role_default_html .= '<option value="' . $key . '" ' . $selected .' '. $disabled .'>' . $translated_name . '</option>';
 
 
2560
  }
2561
  }
 
2562
  $this->role_default_html .= '</select>';
2563
+
2564
+ }
2565
+ // end of role_default_prepare_html()
2566
+
2567
+
2568
+ private function role_delete_prepare_html() {
2569
  $roles_can_delete = $this->get_roles_can_delete();
2570
  if ($roles_can_delete && count($roles_can_delete) > 0) {
2571
  $this->role_delete_html = '<select id="del_user_role" name="del_user_role" width="200" style="width: 200px">';
2577
  } else {
2578
  $this->role_delete_html = '';
2579
  }
2580
+ }
2581
+ // end of role_delete_prepare_html()
2582
+
2583
+
2584
+ private function role_select_copy_prepare_html($select_width=200) {
2585
+ $caps_access_restrict_for_simple_admin = $this->get_option('caps_access_restrict_for_simple_admin', 0);
2586
+ $show_admin_role = $this->show_admin_role_allowed();
2587
+ $this->role_to_copy_html = '<select id="user_role_copy_from" name="user_role_copy_from" style="width: '. $select_width .'px">
2588
+ <option value="none" selected="selected">' . esc_html__('None', 'ure') . '</option>';
2589
+ $this->role_select_html = '<select id="user_role" name="user_role" onchange="ure_role_change(this.value);">';
2590
+ foreach ($this->roles as $key => $value) {
2591
+ $selected1 = $this->option_selected($key, $this->current_role);
2592
+ $disabled = ($key==='administrator' && $caps_access_restrict_for_simple_admin && !is_super_admin()) ? 'disabled' : '';
2593
+ if ($show_admin_role || $key != 'administrator') {
2594
+ $translated_name = esc_html__($value['name'], 'ure'); // get translation from URE language file, if exists
2595
+ if ($translated_name === $value['name']) { // get WordPress internal translation
2596
+ $translated_name = translate_user_role($translated_name);
2597
+ }
2598
+ $translated_name .= ' (' . $key . ')';
2599
+ $this->role_select_html .= '<option value="' . $key . '" ' . $selected1 .' '. $disabled .'>' . $translated_name . '</option>';
2600
+ $this->role_to_copy_html .= '<option value="' . $key .'" '. $disabled .'>' . $translated_name . '</option>';
2601
+ }
2602
+ }
2603
+ $this->role_select_html .= '</select>';
2604
+ $this->role_to_copy_html .= '</select>';
2605
+ }
2606
+ // end of role_select_copy_prepare_html()
2607
+
2608
+
2609
+ public function role_edit_prepare_html($select_width=200) {
2610
+
2611
+ $this->role_select_copy_prepare_html($select_width);
2612
+ $this->role_default_prepare_html($select_width);
2613
+ $this->role_delete_prepare_html();
2614
+ $this->caps_to_remove_prepare_html();
2615
  }
2616
  // end of role_edit_prepare_html()
2617
 
includes/class-user-other-roles.php CHANGED
@@ -17,23 +17,24 @@ class URE_User_Other_Roles {
17
  function __construct(Ure_Lib $lib) {
18
 
19
  $this->lib = $lib;
20
-
21
  }
22
  // end of $lib
23
 
24
 
25
  public function set_hooks() {
26
 
27
- add_filter( 'additional_capabilities_display', array($this, 'additional_capabilities_display'), 10, 1);
28
-
29
- add_action( 'admin_print_styles-user-edit.php', array($this, 'load_css') );
30
- add_action( 'admin_print_styles-user-new.php', array($this, 'load_css') );
31
- add_action( 'admin_enqueue_scripts', array($this, 'load_js' ) );
32
- add_action( 'edit_user_profile', array($this, 'edit_user_profile_html'), 10, 1 );
33
- add_action( 'user_new_form', array($this, 'user_new_form'), 10, 1 );
34
- add_filter( 'manage_users_columns', array($this, 'user_role_column'), 10, 1 );
35
- add_filter( 'manage_users_custom_column', array($this, 'user_role_row'), 10, 3 );
36
- add_action( 'profile_update', array($this, 'update'), 10 );
 
37
  if ($this->lib->multisite) {
38
  add_action( 'wpmu_activate_user', array($this, 'add_other_roles'), 10, 1 );
39
  } else {
17
  function __construct(Ure_Lib $lib) {
18
 
19
  $this->lib = $lib;
20
+ $this->set_hooks();
21
  }
22
  // end of $lib
23
 
24
 
25
  public function set_hooks() {
26
 
27
+ if (is_admin()) {
28
+ add_filter( 'additional_capabilities_display', array($this, 'additional_capabilities_display'), 10, 1);
29
+ add_action( 'admin_print_styles-user-edit.php', array($this, 'load_css') );
30
+ add_action( 'admin_print_styles-user-new.php', array($this, 'load_css') );
31
+ add_action( 'admin_enqueue_scripts', array($this, 'load_js' ) );
32
+ add_action( 'edit_user_profile', array($this, 'edit_user_profile_html'), 10, 1 );
33
+ add_action( 'user_new_form', array($this, 'user_new_form'), 10, 1 );
34
+ add_filter( 'manage_users_columns', array($this, 'user_role_column'), 10, 1 );
35
+ add_filter( 'manage_users_custom_column', array($this, 'user_role_row'), 10, 3 );
36
+ add_action( 'profile_update', array($this, 'update'), 10 );
37
+ }
38
  if ($this->lib->multisite) {
39
  add_action( 'wpmu_activate_user', array($this, 'add_other_roles'), 10, 1 );
40
  } else {
includes/class-user-role-editor.php CHANGED
@@ -120,8 +120,6 @@ class User_Role_Editor {
120
  add_action( 'admin_enqueue_scripts', array($this, 'admin_load_js' ) );
121
  add_action( 'user_row_actions', array($this, 'user_row'), 10, 2 );
122
  add_filter( 'all_plugins', array($this, 'exclude_from_plugins_list' ) );
123
-
124
- $this->user_other_roles->set_hooks();
125
 
126
  if ($this->lib->multisite) {
127
  $allow_edit_users_to_not_super_admin = $this->lib->get_option('allow_edit_users_to_not_super_admin', 0);
120
  add_action( 'admin_enqueue_scripts', array($this, 'admin_load_js' ) );
121
  add_action( 'user_row_actions', array($this, 'user_row'), 10, 2 );
122
  add_filter( 'all_plugins', array($this, 'exclude_from_plugins_list' ) );
 
 
123
 
124
  if ($this->lib->multisite) {
125
  $allow_edit_users_to_not_super_admin = $this->lib->get_option('allow_edit_users_to_not_super_admin', 0);
readme.txt CHANGED
@@ -86,8 +86,13 @@ Some translations may be outdated. If you have better translation for some phras
86
 
87
  == Changelog ==
88
 
 
 
 
 
 
89
  = 4.19 =
90
- * 30.07.2015
91
  * It is possible to assign to the user multiple roles directly through a user profile edit page.
92
  * Custom SQL-query (checked if the role is in use and slow on the huge data) was excluded and replaced with WordPress built-in function call. [Thanks to Aaron](https://wordpress.org/support/topic/poorly-scaling-queries).
93
  * Bulk role assignment to the users without role was rewritten for cases with a huge quant of users. It processes just 50 users without role for the one request to return the answer from the server in the short time. The related code was extracted to the separate class.
86
 
87
  == Changelog ==
88
 
89
+ = [4.19.1] 20.08.2015 =
90
+ * Default role value has not been refreshed automatically after change at the "Default Role" dialog - fixed.
91
+ * More detailed notice messages are shown after default role change - to reflect a possible error or problem.
92
+ * Other default roles (in addition to the primary role) has been assigned to a new registered user for requests from the admin back-end only. Now this feature works for the requests from the front-end user registration forms too.
93
+
94
  = 4.19 =
95
+ * 28.07.2015
96
  * It is possible to assign to the user multiple roles directly through a user profile edit page.
97
  * Custom SQL-query (checked if the role is in use and slow on the huge data) was excluded and replaced with WordPress built-in function call. [Thanks to Aaron](https://wordpress.org/support/topic/poorly-scaling-queries).
98
  * Bulk role assignment to the users without role was rewritten for cases with a huge quant of users. It processes just 50 users without role for the one request to return the answer from the server in the short time. The related code was extracted to the separate class.
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.19
7
  Author: Vladimir Garagulya
8
  Author URI: https://www.role-editor.com
9
  Text Domain: ure
@@ -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.19');
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.19.1
7
  Author: Vladimir Garagulya
8
  Author URI: https://www.role-editor.com
9
  Text Domain: ure
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.19.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__));