User Role Editor - Version 4.52.1

Version Description

Download this release

Release Info

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

Code changes from version 4.52 to 4.52.1

changelog.txt CHANGED
@@ -1,6 +1,11 @@
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
 
1
  CHANGES LOG (full version).
2
  ===========================
3
 
4
+ = [4.52.1] 11.11.2019 =
5
+ * Update: URE requires PHP version 5.6.
6
+ * ure_cpt_editor_roles filter was added. It takes 2 parameters: array $roles with 1 element 'administrator' by default and $post_type with post type name string. Add other role(s) to which you wish automatically add all user capabilities for custom post type $post_type. URE updates roles this way before opening "Users->User Role Editor" page.
7
+ * New user capability 'ure_nav_menus_access' was added. It's used at the User Role Editor Pro only.
8
+
9
  = [4.52] 07.10.2019 =
10
  * 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.
11
 
includes/classes/capabilities.php CHANGED
@@ -187,10 +187,26 @@ class URE_Capabilities {
187
  // end of add_create_caps_to_admin()
188
 
189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  protected function add_custom_post_type_caps( &$full_list ) {
191
  global $wp_roles;
192
 
193
  $multisite = $this->lib->get( 'multisite' );
 
 
194
  $capabilities = $this->lib->get_edit_post_capabilities();
195
  $post_types = get_post_types( array(), 'objects' );
196
  $_post_types = $this->lib->_get_post_types();
@@ -200,6 +216,7 @@ class URE_Capabilities {
200
  $post_types['attachment'] = $attachment_post_type;
201
  }
202
 
 
203
  foreach( $post_types as $post_type ) {
204
  if ( !isset( $_post_types[$post_type->name] ) ) {
205
  continue;
@@ -207,18 +224,17 @@ class URE_Capabilities {
207
  if ( !isset($post_type->cap) ) {
208
  continue;
209
  }
 
 
 
 
210
  foreach( $capabilities as $capability ) {
211
  if ( !isset( $post_type->cap->$capability ) ) {
212
  continue;
213
  }
214
  $cap_to_check = $post_type->cap->$capability;
215
  $this->add_capability_to_full_caps_list( $cap_to_check, $full_list );
216
- if ( !$multisite &&
217
- isset($wp_roles->role_objects['administrator']) &&
218
- !isset($wp_roles->role_objects['administrator']->capabilities[$cap_to_check])) {
219
- // admin should be capable to edit any posts
220
- $wp_roles->role_objects['administrator']->add_cap($cap_to_check, true);
221
- }
222
  }
223
  }
224
 
187
  // end of add_create_caps_to_admin()
188
 
189
 
190
+ public static function add_cap_to_roles( $roles, $cap ) {
191
+ global $wp_roles;
192
+
193
+ foreach( $roles as $role ) {
194
+ if ( isset( $wp_roles->role_objects[$role] ) &&
195
+ !isset( $wp_roles->role_objects[$role]->capabilities[$cap] ) ) {
196
+ $wp_roles->role_objects[$role]->add_cap( $cap, true );
197
+ }
198
+ }
199
+
200
+ }
201
+ // end of add_cap_to_roles()
202
+
203
+
204
  protected function add_custom_post_type_caps( &$full_list ) {
205
  global $wp_roles;
206
 
207
  $multisite = $this->lib->get( 'multisite' );
208
+ // admin should be capable to edit any posts
209
+ $cpt_editor_roles0 = !$multisite ? array('administrator') : array();
210
  $capabilities = $this->lib->get_edit_post_capabilities();
211
  $post_types = get_post_types( array(), 'objects' );
212
  $_post_types = $this->lib->_get_post_types();
216
  $post_types['attachment'] = $attachment_post_type;
217
  }
218
 
219
+
220
  foreach( $post_types as $post_type ) {
221
  if ( !isset( $_post_types[$post_type->name] ) ) {
222
  continue;
224
  if ( !isset($post_type->cap) ) {
225
  continue;
226
  }
227
+ $cpt_editor_roles = apply_filters( 'ure_cpt_editor_roles', $cpt_editor_roles0, $post_type->name );
228
+ if ( empty( $cpt_editor_roles ) || count( $cpt_editor_roles )==0 ) {
229
+ continue;
230
+ }
231
  foreach( $capabilities as $capability ) {
232
  if ( !isset( $post_type->cap->$capability ) ) {
233
  continue;
234
  }
235
  $cap_to_check = $post_type->cap->$capability;
236
  $this->add_capability_to_full_caps_list( $cap_to_check, $full_list );
237
+ self::add_cap_to_roles( $cpt_editor_roles, $cap_to_check );
 
 
 
 
 
238
  }
239
  }
240
 
includes/classes/own-capabilities.php CHANGED
@@ -36,7 +36,8 @@ class URE_Own_Capabilities {
36
  $ure_caps['ure_edit_posts_access'] = 1;
37
  $ure_caps['ure_plugins_activation_access'] = 1;
38
  $ure_caps['ure_view_posts_access'] = 1;
39
- $ure_caps['ure_front_end_menu_access'] = 1;
 
40
  $multisite = $lib->get('multisite');
41
  if ($multisite) {
42
  $ure_caps['ure_themes_access'] = 1;
36
  $ure_caps['ure_edit_posts_access'] = 1;
37
  $ure_caps['ure_plugins_activation_access'] = 1;
38
  $ure_caps['ure_view_posts_access'] = 1;
39
+ $ure_caps['ure_front_end_menu_access'] = 1;
40
+ $ure_caps['ure_nav_menus_access'] = 1;
41
  $multisite = $lib->get('multisite');
42
  if ($multisite) {
43
  $ure_caps['ure_themes_access'] = 1;
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.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,18 +81,14 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
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.
90
- * 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.
91
-
92
- = [4.51.2] 15.07.2019 =
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,5 +99,7 @@ I am ready to answer on your questions about plugin usage. Use [plugin page comm
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.
 
 
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.3
7
+ Stable tag: 4.52.1
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.1] 11.11.2019 =
85
+ * Update: URE requires PHP version 5.6.
86
+ * ure_cpt_editor_roles filter was added. It takes 2 parameters: array $roles with 1 element 'administrator' by default and $post_type with post type name string. Add other role(s) to which you wish automatically add all user capabilities for custom post type $post_type. URE updates roles this way before opening "Users->User Role Editor" page.
87
+ * New user capability 'ure_nav_menus_access' was added. It's used at the User Role Editor Pro only.
88
+
89
  = [4.52] 07.10.2019 =
90
  * 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.
91
 
 
 
 
 
 
 
 
 
 
92
  File changelog.txt contains the full list of changes.
93
 
94
  == Additional Documentation ==
99
 
100
  == Upgrade Notice ==
101
 
102
+ = [4.52.1] 11.11.2019 =
103
+ * Update: URE requires PHP version 5.6.
104
+ * ure_cpt_editor_roles filter was added. It takes 2 parameters: array $roles with 1 element 'administrator' by default and $post_type with post type name string. Add other role(s) to which you wish automatically add all user capabilities for custom post type $post_type. URE updates roles this way before opening "Users->User Role Editor" page.
105
+ * New user capability 'ure_nav_menus_access' was added. It's used at the User Role Editor Pro only.
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.52
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.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__ ) );
@@ -34,7 +34,7 @@ require_once( URE_PLUGIN_DIR.'includes/classes/base-lib.php' );
34
  require_once( URE_PLUGIN_DIR.'includes/classes/lib.php' );
35
 
36
  // check PHP version
37
- $ure_required_php_version = '5.4';
38
  $exit_msg = 'User Role Editor requires PHP '. $ure_required_php_version .' or newer. '.
39
  '<a href="http://wordpress.org/about/requirements/">Please update!</a>';
40
  URE_Lib::check_version( PHP_VERSION, $ure_required_php_version, $exit_msg, __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.1
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.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__ ) );
34
  require_once( URE_PLUGIN_DIR.'includes/classes/lib.php' );
35
 
36
  // check PHP version
37
+ $ure_required_php_version = '5.6';
38
  $exit_msg = 'User Role Editor requires PHP '. $ure_required_php_version .' or newer. '.
39
  '<a href="http://wordpress.org/about/requirements/">Please update!</a>';
40
  URE_Lib::check_version( PHP_VERSION, $ure_required_php_version, $exit_msg, __FILE__ );