User Role Editor - Version 4.52

Version Description

Download this release

Release Info

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

Code changes from version 4.51.3 to 4.52

changelog.txt CHANGED
@@ -1,6 +1,9 @@
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.
1
  CHANGES LOG (full version).
2
  ===========================
3
 
4
+ = [4.52] 07.10.2019 =
5
+ * New: Multisite: WordPress (tested up to version 5.2.3) shows "Change role to..." drop-down list at "Network Admin->Sites->selected site->Users tab" with roles filled from the main site, but should use roles list from the selected site. URE replaces this roles list with roles from the selected site and excludes error with message "Sorry, you are not allowed to give users that role.", when you try to grant to a user a role from the main site, which does not exist at the selected site.
6
+
7
  = [4.51.3] 02.09.2019 =
8
  * Fix: line #281 at /includes/classes/view.php contained a call to the not existing class property.
9
  * 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.
includes/classes/user-role-editor.php CHANGED
@@ -115,7 +115,7 @@ class User_Role_Editor {
115
  return;
116
  }
117
 
118
- add_action('admin_init', array($this, 'plugin_init'), 1);
119
 
120
  // Add the translation function after the plugins loaded hook.
121
  add_action('plugins_loaded', array($this, 'load_translation'));
@@ -123,9 +123,9 @@ class User_Role_Editor {
123
  // add own submenu
124
  add_action('admin_menu', array($this, 'plugin_menu'));
125
 
126
- if ($multisite) {
127
  // add own submenu
128
- add_action('network_admin_menu', array($this, 'network_plugin_menu'));
129
  }
130
 
131
 
@@ -189,6 +189,12 @@ class User_Role_Editor {
189
  add_filter('site_option_site_admins', array($this, 'allow_add_user_as_superadmin'));
190
  }
191
  }
 
 
 
 
 
 
192
  } else {
193
  $count_users_without_role = $this->lib->get_option('count_users_without_role', 0);
194
  if ($count_users_without_role) {
@@ -209,7 +215,7 @@ class User_Role_Editor {
209
  }
210
  }
211
  // end of plugin_init()
212
-
213
 
214
  /**
215
  * Allow non-superadmin user to add/create users to the site as superadmin does.
@@ -844,6 +850,39 @@ class User_Role_Editor {
844
  return $roles;
845
  }
846
  // end of sort_wp_roles_list()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
847
 
848
 
849
  // execute on plugin deactivation
115
  return;
116
  }
117
 
118
+ add_action( 'admin_init', array($this, 'plugin_init'), 1 );
119
 
120
  // Add the translation function after the plugins loaded hook.
121
  add_action('plugins_loaded', array($this, 'load_translation'));
123
  // add own submenu
124
  add_action('admin_menu', array($this, 'plugin_menu'));
125
 
126
+ if ( $multisite ) {
127
  // add own submenu
128
+ add_action( 'network_admin_menu', array($this, 'network_plugin_menu') );
129
  }
130
 
131
 
189
  add_filter('site_option_site_admins', array($this, 'allow_add_user_as_superadmin'));
190
  }
191
  }
192
+
193
+ if ( $pagenow=='site-users.php' ) {
194
+ // Try to execute before any other function linked to this filter
195
+ add_filter( 'editable_roles', array($this, 'fix_network_admin_roles_dropdown'), 9 );
196
+ }
197
+
198
  } else {
199
  $count_users_without_role = $this->lib->get_option('count_users_without_role', 0);
200
  if ($count_users_without_role) {
215
  }
216
  }
217
  // end of plugin_init()
218
+
219
 
220
  /**
221
  * Allow non-superadmin user to add/create users to the site as superadmin does.
850
  return $roles;
851
  }
852
  // end of sort_wp_roles_list()
853
+
854
+
855
+ /** Currently WordPress (tested up to version 5.2.3) shows "Change role to..." drop-down list at Network admin->Sites->selected site->Users with roles filled from the main site,
856
+ /* but should use roles list from the selected site. This function replaces roles list with roles from the selected site and
857
+ * excludes error messsage "Sorry, you are not allowed to give users that role.", when you try to grant to a user a role which does not exist at the selected site.
858
+ *
859
+ * @param array $roles
860
+ * @return array
861
+ */
862
+ public function fix_network_admin_roles_dropdown( $roles ) {
863
+
864
+ // get selected site ID
865
+ $selected_blog_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
866
+ if ( !$selected_blog_id ) {
867
+ return $roles;
868
+ }
869
+
870
+ $current_blog_id = get_current_blog_id();
871
+ if ( $current_blog_id!==$selected_blog_id ) {
872
+ switch_to_blog( $selected_blog_id );
873
+ }
874
+
875
+ remove_filter( 'editable_roles', array($this, 'fix_network_admin_roles_dropdown'), 9 );
876
+ $roles1 = get_editable_roles();
877
+ add_filter( 'editable_roles', array($this, 'fix_network_admin_roles_dropdown'), 9 );
878
+
879
+ if ( $current_blog_id!==$selected_blog_id ) {
880
+ restore_current_blog();
881
+ }
882
+
883
+ return $roles1;
884
+ }
885
+ // end of fix_network_admin_roles_dropdown()
886
 
887
 
888
  // execute on plugin deactivation
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.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,6 +81,9 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
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.
@@ -90,9 +93,6 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
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.
92
 
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,7 +103,5 @@ I am ready to answer on your questions about plugin usage. Use [plugin page comm
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.
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.3
7
+ Stable tag: 4.52
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.52] 07.10.2019 =
85
+ * New: Multisite: WordPress (tested up to version 5.2.3) shows "Change role to..." drop-down list at "Network Admin->Sites->selected site->Users tab" with roles filled from the main site, but should use roles list from the selected site. URE replaces this roles list with roles from the selected site and excludes error with message "Sorry, you are not allowed to give users that role.", when you try to grant to a user a role from the main site, which does not exist at the selected site.
86
+
87
  = [4.51.3] 02.09.2019 =
88
  * Fix: line #281 at /includes/classes/view.php contained a call to the not existing class property.
89
  * 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.
93
  * 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/).
94
  * Update: Roles inside WordPress roles dropdown lists are sorted by alphabet.
95
 
 
 
 
96
  File changelog.txt contains the full list of changes.
97
 
98
  == Additional Documentation ==
103
 
104
  == Upgrade Notice ==
105
 
106
+ = [4.52] 07.10.2019 =
107
+ * New: Multisite: WordPress (tested up to version 5.2.3) shows "Change role to..." drop-down list at "Network Admin->Sites->selected site->Users tab" with roles filled from the main site, but should use roles list from the selected site. URE replaces this roles list with roles from the selected site and excludes error with message "Sorry, you are not allowed to give users that role.", when you try to grant to a user a role from the main site, which does not exist at the selected site.
 
 
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.3
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.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__ ) );
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.52
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.52' );
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__ ) );