User Role Editor - Version 4.52.2

Version Description

Download this release

Release Info

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

Code changes from version 4.52.1 to 4.52.2

changelog.txt CHANGED
@@ -1,6 +1,10 @@
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.
1
  CHANGES LOG (full version).
2
  ===========================
3
 
4
+ = [4.52.2] 26.12.2019 =
5
+ * Fix: Custom capabilities for custom post types was not created by URE automatically since version 4.52.1.
6
+ * Fix: 'administrator' role protection did not show to power users roles with 'administrator' word inside, like 'shop_administrator', etc.
7
+
8
  = [4.52.1] 11.11.2019 =
9
  * Update: URE requires PHP version 5.6.
10
  * 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.
includes/classes/capabilities.php CHANGED
@@ -167,8 +167,7 @@ class URE_Capabilities {
167
 
168
  foreach ( array_keys( $this->built_in_wp_caps ) as $cap ) {
169
  $this->add_capability_to_full_caps_list( $cap, $full_list );
170
- }
171
-
172
  }
173
  // end of add_wordpress_caps()
174
 
@@ -190,6 +189,10 @@ class URE_Capabilities {
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] ) ) {
@@ -215,8 +218,7 @@ class URE_Capabilities {
215
  if ( $attachment_post_type->cap->edit_posts!=='edit_posts' ) {
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,16 +226,13 @@ class URE_Capabilities {
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
  }
167
 
168
  foreach ( array_keys( $this->built_in_wp_caps ) as $cap ) {
169
  $this->add_capability_to_full_caps_list( $cap, $full_list );
170
+ }
 
171
  }
172
  // end of add_wordpress_caps()
173
 
189
  public static function add_cap_to_roles( $roles, $cap ) {
190
  global $wp_roles;
191
 
192
+ if ( !is_array( $roles ) || count( $roles )==0 ) {
193
+ return;
194
+ }
195
+
196
  foreach( $roles as $role ) {
197
  if ( isset( $wp_roles->role_objects[$role] ) &&
198
  !isset( $wp_roles->role_objects[$role]->capabilities[$cap] ) ) {
218
  if ( $attachment_post_type->cap->edit_posts!=='edit_posts' ) {
219
  $post_types['attachment'] = $attachment_post_type;
220
  }
221
+
 
222
  foreach( $post_types as $post_type ) {
223
  if ( !isset( $_post_types[$post_type->name] ) ) {
224
  continue;
226
  if ( !isset($post_type->cap) ) {
227
  continue;
228
  }
229
+ $cpt_editor_roles = apply_filters( 'ure_cpt_editor_roles', $cpt_editor_roles0, $post_type->name );
 
 
 
230
  foreach( $capabilities as $capability ) {
231
  if ( !isset( $post_type->cap->$capability ) ) {
232
  continue;
233
  }
234
  $cap_to_check = $post_type->cap->$capability;
235
+ $this->add_capability_to_full_caps_list( $cap_to_check, $full_list );
236
  self::add_cap_to_roles( $cpt_editor_roles, $cap_to_check );
237
  }
238
  }
includes/classes/protect-admin.php CHANGED
@@ -84,8 +84,8 @@ class URE_Protect_Admin {
84
  $query = $wpdb->prepare(
85
  "SELECT count(*)
86
  FROM {$wpdb->usermeta}
87
- WHERE user_id=%d AND meta_key=%s AND meta_value like %s",
88
- array($user_id, $meta_key, '%administrator%'));
89
  $has_admin_role = $wpdb->get_var($query);
90
  if ($has_admin_role > 0) {
91
  $result = true;
@@ -179,7 +179,7 @@ class URE_Protect_Admin {
179
  "SELECT user_id
180
  FROM {$wpdb->usermeta}
181
  WHERE user_id!=%d AND meta_key=%s AND meta_value like %s",
182
- array($current_user_id, $meta_key, '%administrator%'));
183
  $ids_arr = $wpdb->get_col($query);
184
  if (is_array($ids_arr) && count($ids_arr) > 0) {
185
  $ids = implode(',', $ids_arr);
84
  $query = $wpdb->prepare(
85
  "SELECT count(*)
86
  FROM {$wpdb->usermeta}
87
+ WHERE user_id=%d AND meta_key=%s AND meta_value LIKE %s",
88
+ array($user_id, $meta_key, '%"administrator"%') );
89
  $has_admin_role = $wpdb->get_var($query);
90
  if ($has_admin_role > 0) {
91
  $result = true;
179
  "SELECT user_id
180
  FROM {$wpdb->usermeta}
181
  WHERE user_id!=%d AND meta_key=%s AND meta_value like %s",
182
+ array($current_user_id, $meta_key, '%"administrator"%'));
183
  $ids_arr = $wpdb->get_col($query);
184
  if (is_array($ids_arr) && count($ids_arr) > 0) {
185
  $ids = implode(',', $ids_arr);
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.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,6 +81,10 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
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.
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.2
7
+ Stable tag: 4.52.2
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.2] 26.12.2019 =
85
+ * Fix: Custom capabilities for custom post types was not created by URE automatically since version 4.52.1.
86
+ * Fix: 'administrator' role protection did not show to power users roles with 'administrator' word inside, like 'shop_administrator', etc.
87
+
88
  = [4.52.1] 11.11.2019 =
89
  * Update: URE requires PHP version 5.6.
90
  * 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.
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.1
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.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__ ) );
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.2
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.2' );
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__ ) );