User Role Editor - Version 4.50.2

Version Description

Download this release

Release Info

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

Code changes from version 4.50.1 to 4.50.2

changelog.txt CHANGED
@@ -1,5 +1,13 @@
1
  CHANGES LOG (full version).
2
  ===========================
 
 
 
 
 
 
 
 
3
  = [4.50] 20.02.2019 =
4
  * Update: General code restructure and optimization.
5
  * Update: URE_Base_Lib::get_blog_ids() returns null, if it's called under WordPress single site (not multisite).
1
  CHANGES LOG (full version).
2
  ===========================
3
+
4
+ = [4.50.2] 01.04.2019 =
5
+ * Fix: WordPress multisite: PHP Notice "wpmu_new_blog is deprecated since version 5.1.0! Use wp_insert_site instead." was removed. URE uses 'wp_initialize_site' action now instead of deprecated 'wpmu_new_blog'. This fix provides correct roles replication from the main blog/site to a new created blog/site.
6
+
7
+ = [4.50.1] 16.03.2019 =
8
+ * Fix: WP Multisite: Users->Capabilities->Update: "Fatal error: Uncaught Error: Call to undefined method URE_Editor::check_blog_user() in /wp-content/plugins/user-role-editor/includes/classes/editor.php on line 576" was fixed.
9
+ * Fix: WooCommerce group was not shown under "Custom capabilities" section.
10
+
11
  = [4.50] 20.02.2019 =
12
  * Update: General code restructure and optimization.
13
  * Update: URE_Base_Lib::get_blog_ids() returns null, if it's called under WordPress single site (not multisite).
includes/classes/user-role-editor.php CHANGED
@@ -105,7 +105,7 @@ class User_Role_Editor {
105
  if ($multisite) {
106
  // new blog may be registered not at admin back-end only but automatically after new user registration, e.g.
107
  // Gravity Forms User Registration Addon does
108
- add_action( 'wpmu_new_blog', array($this, 'duplicate_roles_for_new_blog'), 10, 2);
109
  }
110
 
111
  // setup additional options hooks for the roles
@@ -397,34 +397,39 @@ class User_Role_Editor {
397
  * Every time when new blog is created - duplicate for it the roles from the main blog
398
  * @global wpdb $wpdb
399
  * @global WP_Roles $wp_roles
400
- * @param int $blog_id
401
  * @param int $user_id
402
  *
403
  */
404
- public function duplicate_roles_for_new_blog($blog_id) {
405
  global $wpdb, $wp_roles;
406
 
407
  // get Id of 1st (main) blog
408
  $main_blog_id = $this->lib->get_main_blog_id();
409
- if (empty($main_blog_id)) {
410
  return;
411
  }
412
  $current_blog = $wpdb->blogid;
413
- switch_to_blog($main_blog_id);
414
- $main_roles = new WP_Roles(); // get roles from primary blog
415
- $default_role = get_option('default_role'); // get default role from primary blog
416
- $addons_data = apply_filters('ure_get_addons_data_for_new_blog', array()); // load addons data - for internal use in a Pro version
 
 
417
 
418
- switch_to_blog($blog_id); // switch to the new created blog
 
419
  $main_roles->use_db = false; // do not touch DB
420
- $main_roles->add_cap('administrator', 'dummy_123456'); // just to save current roles into new blog
421
  $main_roles->role_key = $wp_roles->role_key;
422
  $main_roles->use_db = true; // save roles into new blog DB
423
- $main_roles->remove_cap('administrator', 'dummy_123456'); // remove unneeded dummy capability
424
- update_option('default_role', $default_role); // set default role for new blog as it set for primary one
425
- do_action('ure_set_addons_data_for_new_blog', $blog_id, $addons_data); // save addons data for new blog - for internal use in a Pro version
 
 
426
 
427
- switch_to_blog($current_blog); // return to blog where we were at the begin
428
  }
429
  // end of duplicate_roles_for_new_blog()
430
 
105
  if ($multisite) {
106
  // new blog may be registered not at admin back-end only but automatically after new user registration, e.g.
107
  // Gravity Forms User Registration Addon does
108
+ add_action( 'wp_initialize_site', array($this, 'duplicate_roles_for_new_blog'), 99, 1);
109
  }
110
 
111
  // setup additional options hooks for the roles
397
  * Every time when new blog is created - duplicate for it the roles from the main blog
398
  * @global wpdb $wpdb
399
  * @global WP_Roles $wp_roles
400
+ * @param WP_Site $site
401
  * @param int $user_id
402
  *
403
  */
404
+ public function duplicate_roles_for_new_blog( $site ) {
405
  global $wpdb, $wp_roles;
406
 
407
  // get Id of 1st (main) blog
408
  $main_blog_id = $this->lib->get_main_blog_id();
409
+ if ( empty( $main_blog_id ) ) {
410
  return;
411
  }
412
  $current_blog = $wpdb->blogid;
413
+ if ( $current_blog!=$main_blog_id ) {
414
+ switch_to_blog( $main_blog_id );
415
+ }
416
+ $main_roles = new WP_Roles(); // Get roles from primary blog
417
+ $default_role = get_option( 'default_role' ); // get default role from primary blog
418
+ $addons_data = apply_filters( 'ure_get_addons_data_for_new_blog', array() ); // Load addons data to replicate later for the new site - for internal use in a Pro version
419
 
420
+ $blog_id = $site->blog_id;
421
+ switch_to_blog( $blog_id ); // switch to the new created blog
422
  $main_roles->use_db = false; // do not touch DB
423
+ $main_roles->add_cap( 'administrator', 'dummy_123456' ); // just to save current roles into new blog
424
  $main_roles->role_key = $wp_roles->role_key;
425
  $main_roles->use_db = true; // save roles into new blog DB
426
+ $main_roles->remove_cap( 'administrator', 'dummy_123456' ); // remove unneeded dummy capability
427
+ update_option( 'default_role', $default_role ); // set default role for new blog as it set for primary one
428
+ if ( !empty($addons_data) ) {
429
+ do_action('ure_set_addons_data_for_new_blog', $blog_id, $addons_data); // save addons data from the main site/blog to the new site/blog - for internal use in a Pro version
430
+ }
431
 
432
+ switch_to_blog( $current_blog ); // return to blog where we were at the begin
433
  }
434
  // end of duplicate_roles_for_new_blog()
435
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=vladi
4
  Tags: user, role, editor, security, access, permission, capability
5
  Requires at least: 4.0
6
  Tested up to: 5.1.1
7
- Stable tag: 4.50
8
  Requires PHP: 5.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -80,6 +80,10 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
80
 
81
 
82
  == Changelog =
 
 
 
 
83
  = [4.50.1] 16.03.2019 =
84
  * Fix: WP Multisite: Users->Capabilities->Update: "Fatal error: Uncaught Error: Call to undefined method URE_Editor::check_blog_user() in /wp-content/plugins/user-role-editor/includes/classes/editor.php on line 576" was fixed.
85
  * Fix: WooCommerce group was not shown under "Custom capabilities" section.
@@ -115,8 +119,9 @@ You can find more information about "User Role Editor" plugin at [this page](htt
115
  I am ready to answer on your questions about plugin usage. Use [plugin page comments](http://www.shinephp.com/user-role-editor-wordpress-plugin/) for that.
116
 
117
  == Upgrade Notice ==
118
- = [4.47] 12.11.2018 =
119
- * Update: Code was restructured, optimized. Almost 100% of the code was covered by PHPUnit tests.
 
120
 
121
 
122
 
4
  Tags: user, role, editor, security, access, permission, capability
5
  Requires at least: 4.0
6
  Tested up to: 5.1.1
7
+ Stable tag: 4.50.2
8
  Requires PHP: 5.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
80
 
81
 
82
  == Changelog =
83
+
84
+ = [4.50.2] 01.04.2019 =
85
+ * Fix: WordPress multisite: PHP Notice "wpmu_new_blog is deprecated since version 5.1.0! Use wp_insert_site instead." was removed. URE uses 'wp_initialize_site' action now instead of deprecated 'wpmu_new_blog'. This fix provides correct roles replication from the main blog/site to a new created blog/site.
86
+
87
  = [4.50.1] 16.03.2019 =
88
  * Fix: WP Multisite: Users->Capabilities->Update: "Fatal error: Uncaught Error: Call to undefined method URE_Editor::check_blog_user() in /wp-content/plugins/user-role-editor/includes/classes/editor.php on line 576" was fixed.
89
  * Fix: WooCommerce group was not shown under "Custom capabilities" section.
119
  I am ready to answer on your questions about plugin usage. Use [plugin page comments](http://www.shinephp.com/user-role-editor-wordpress-plugin/) for that.
120
 
121
  == Upgrade Notice ==
122
+
123
+ = [4.50.2] 01.04.2019 =
124
+ * Fix: WordPress multisite: PHP Notice "wpmu_new_blog is deprecated since version 5.1.0! Use wp_insert_site instead." was removed. URE uses 'wp_initialize_site' action now instead of deprecated 'wpmu_new_blog'. This fix provides correct roles replication from the main blog/site to a new created blog/site.
125
 
126
 
127
 
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.50.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.50.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.50.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.50.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__ ) );