User Role Editor - Version 4.47

Version Description

Download this release

Release Info

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

Code changes from version 4.46 to 4.47

images/clearfy.jpg DELETED
Binary file
includes/classes/advertisement.php CHANGED
@@ -19,11 +19,7 @@ class URE_Advertisement {
19
  $index = $this->rand_unique( $used );
20
  $this->slots[$index] = $this->admin_menu_editor();
21
  $used[] = $index;
22
-
23
- $index = $this->rand_unique( $used );
24
- $this->slots[$index] = $this->clearfy();
25
- $used[] = $index;
26
-
27
  }
28
  // end of __construct
29
 
@@ -61,24 +57,7 @@ class URE_Advertisement {
61
  return $output;
62
  }
63
  // end of admin_menu_editor()
64
-
65
-
66
- // content of Clearfy advertisement slot
67
- private function clearfy() {
68
-
69
- $output = '
70
- <div style="text-align: center;">
71
- <a href="https://clearfy.pro/?utm_source=wordpress.org&utm_campaign=user-role-editor" target="_new" >
72
- <img src="'. URE_PLUGIN_URL . 'images/clearfy.jpg' .'" alt="Clearfy" title="Disable unused WordPress features"
73
- width="250" height="250" />
74
- </a>
75
- </div>
76
- ';
77
-
78
- return $output;
79
- }
80
- // end of clearfy()
81
-
82
 
83
  /**
84
  * Output all existed ads slots
19
  $index = $this->rand_unique( $used );
20
  $this->slots[$index] = $this->admin_menu_editor();
21
  $used[] = $index;
22
+
 
 
 
 
23
  }
24
  // end of __construct
25
 
57
  return $output;
58
  }
59
  // end of admin_menu_editor()
60
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  /**
63
  * Output all existed ads slots
includes/classes/base-lib.php CHANGED
@@ -41,7 +41,7 @@ class URE_Base_Lib {
41
  $this->multisite = function_exists('is_multisite') && is_multisite();
42
  if ($this->multisite) {
43
  $this->blog_ids = $this->get_blog_ids();
44
- // get Id of 1st (main) blog
45
  $this->main_blog_id = $this->get_main_site();
46
  }
47
 
@@ -348,4 +348,4 @@ class URE_Base_Lib {
348
  // end of __wakeup()
349
 
350
  }
351
- // end of Garvs_WP_Lib class
41
  $this->multisite = function_exists('is_multisite') && is_multisite();
42
  if ($this->multisite) {
43
  $this->blog_ids = $this->get_blog_ids();
44
+ // get Id of the 1st (main) blog
45
  $this->main_blog_id = $this->get_main_site();
46
  }
47
 
348
  // end of __wakeup()
349
 
350
  }
351
+ // end of URE_Base_Lib class
includes/classes/bbpress.php CHANGED
@@ -11,13 +11,10 @@
11
 
12
  class URE_bbPress {
13
 
14
- protected $lib = null;
15
  protected $bbpress_detected = false;
16
 
17
 
18
- public function __construct(URE_Lib $lib) {
19
-
20
- $this->lib = $lib;
21
 
22
  add_action('plugins_loaded', array($this, 'detect_bbpress'), 8);
23
  }
@@ -26,9 +23,6 @@ class URE_bbPress {
26
 
27
  public function detect_bbpress() {
28
 
29
- if (!function_exists('is_plugin_active')) {
30
- require_once(ABSPATH .'/wp-admin/includes/plugin.php');
31
- }
32
  $this->bbpress_detected = false;
33
  if (function_exists('bbp_filter_blog_editable_roles')) {
34
  $this->bbpress_detected = true; // bbPress plugin is installed and active
11
 
12
  class URE_bbPress {
13
 
 
14
  protected $bbpress_detected = false;
15
 
16
 
17
+ public function __construct() {
 
 
18
 
19
  add_action('plugins_loaded', array($this, 'detect_bbpress'), 8);
20
  }
23
 
24
  public function detect_bbpress() {
25
 
 
 
 
26
  $this->bbpress_detected = false;
27
  if (function_exists('bbp_filter_blog_editable_roles')) {
28
  $this->bbpress_detected = true; // bbPress plugin is installed and active
includes/classes/capability.php CHANGED
@@ -48,6 +48,13 @@ class URE_Capability {
48
  'cap_id'=>'do_not_allow');
49
  return $data;
50
  }
 
 
 
 
 
 
 
51
 
52
  $data = array(
53
  'result'=>true,
@@ -122,15 +129,19 @@ class URE_Capability {
122
  return $caps;
123
  }
124
  // end of get_caps_for_deletion_from_post()
125
-
126
-
127
 
128
  private static function revoke_caps_from_user($user_id, $caps) {
129
  $user = get_user_to_edit($user_id);
130
  foreach($caps as $cap_id) {
131
- if (isset($user->caps[$cap_id])) {
132
- $user->remove_cap($cap_id);
 
 
 
 
133
  }
 
134
  }
135
  }
136
  // end of revoke_caps_from_user()
48
  'cap_id'=>'do_not_allow');
49
  return $data;
50
  }
51
+ if ($cap_id=='administrator') {
52
+ $data = array(
53
+ 'result'=>false,
54
+ 'message'=>esc_html__('Error: this word is used by WordPress as a role ID', 'user-role-editor'),
55
+ 'cap_id'=>'administrator');
56
+ return $data;
57
+ }
58
 
59
  $data = array(
60
  'result'=>true,
129
  return $caps;
130
  }
131
  // end of get_caps_for_deletion_from_post()
132
+
 
133
 
134
  private static function revoke_caps_from_user($user_id, $caps) {
135
  $user = get_user_to_edit($user_id);
136
  foreach($caps as $cap_id) {
137
+ if (!isset($user->caps[$cap_id])) {
138
+ continue;
139
+ }
140
+ // Prevent sudden revoke role 'administrator' from a user during 'administrator' capability deletion.
141
+ if ($cap_id=='administrator') {
142
+ continue;
143
  }
144
+ $user->remove_cap($cap_id);
145
  }
146
  }
147
  // end of revoke_caps_from_user()
includes/classes/lib.php CHANGED
@@ -55,9 +55,9 @@ class URE_Lib extends URE_Base_Lib {
55
  $this->debug = defined('URE_DEBUG') && (URE_DEBUG==1 || URE_DEBUG==true);
56
 
57
  if ($this->is_pro()) {
58
- $this->bbpress = new URE_bbPress_Pro($this);
59
  } else {
60
- $this->bbpress = new URE_bbPress($this);
61
  }
62
 
63
  $this->upgrade();
55
  $this->debug = defined('URE_DEBUG') && (URE_DEBUG==1 || URE_DEBUG==true);
56
 
57
  if ($this->is_pro()) {
58
+ $this->bbpress = new URE_bbPress_Pro();
59
  } else {
60
+ $this->bbpress = new URE_bbPress();
61
  }
62
 
63
  $this->upgrade();
includes/classes/user-role-editor.php CHANGED
@@ -30,7 +30,7 @@ class User_Role_Editor {
30
 
31
 
32
  public static function get_instance() {
33
- if (self::$instance===null) {
34
  self::$instance = new User_Role_Editor();
35
  }
36
 
30
 
31
 
32
  public static function get_instance() {
33
+ if ( self::$instance===null ) {
34
  self::$instance = new User_Role_Editor();
35
  }
36
 
js/ure.js CHANGED
@@ -525,6 +525,13 @@ function ure_refresh_role_view(response) {
525
  return;
526
  }
527
 
 
 
 
 
 
 
 
528
  ure_current_role = response.role_id;
529
  ure_current_role_name = response.role_name;
530
  // Select capabilities granted to a newly selected role and exclude others
@@ -534,12 +541,7 @@ function ure_refresh_role_view(response) {
534
 
535
  // Recalculate granted capabilities for capabilities groups
536
  ure_count_caps_in_groups();
537
- ure_select_selectable_element(jQuery('#ure_caps_groups_list'), jQuery('#ure_caps_group_all'));
538
- var granted_only = jQuery('#granted_only').prop('checked');
539
- if (granted_only) {
540
- jQuery('#granted_only').prop('checked', false);
541
- ure_show_granted_caps_only();
542
- }
543
 
544
  // additional options section
545
  jQuery('#additional_options').find(':checkbox').each(function() { // go through all additional options checkboxes
@@ -567,7 +569,7 @@ function ure_role_change(role_name) {
567
 
568
  function ure_filter_capabilities(cap_id) {
569
  var div_list = jQuery('.ure-cap-div');
570
- for (i = 0; i < div_list.length; i++) {
571
  if (cap_id !== '' && div_list[i].id.substr(11).indexOf(cap_id) !== -1) {
572
  jQuery('#'+ div_list[i].id).addClass('ure_tag');
573
  div_list[i].style.color = '#27CF27';
@@ -576,7 +578,6 @@ function ure_filter_capabilities(cap_id) {
576
  jQuery('#'+ div_list[i].id).removeClass('ure_tag');
577
  }
578
  }
579
- ;
580
 
581
  }
582
  // end of ure_filter_capabilities()
@@ -648,13 +649,13 @@ function ure_caps_refresh(group) {
648
 
649
 
650
  function ure_validate_columns(columns) {
651
- if (columns==1 || ure_main.selected_group=='all') {
652
  return columns;
653
  }
654
 
655
  // Do not split list on columns in case it contains less then < 25 capabilities
656
- for (i=0; i<ure_main.caps_counter.length; i++) {
657
- if (ure_main.caps_counter[i].id==ure_main.selected_group) {
658
  if (ure_main.caps_counter[i].total<=25) {
659
  columns = 1;
660
  }
@@ -681,7 +682,7 @@ function ure_init_caps_counter() {
681
  ure_main.caps_counter = new Array();
682
  jQuery('#ure_caps_groups_list li').each(function() {
683
  var group_id = jQuery(this).attr('id').substr(15);
684
- group_counter = {'id': group_id, 'total': 0, 'granted':0};
685
  ure_main.caps_counter.push(group_counter);
686
  });
687
 
@@ -694,7 +695,7 @@ function ure_count_caps_in_groups() {
694
  jQuery('.ure-cap-div').each(function () {
695
  var cap_div = jQuery(this);
696
  var capability = cap_div.attr('id').substr(12);
697
- for (i=0; i<ure_main.caps_counter.length; i++) {
698
  if (cap_div.hasClass(ure_main.class_prefix + ure_main.caps_counter[i].id)) {
699
  ure_main.caps_counter[i].total++;
700
  if (jQuery('#'+ capability).is(':checked')) {
@@ -704,7 +705,7 @@ function ure_count_caps_in_groups() {
704
  }
705
  });
706
 
707
- for (i=0; i<ure_main.caps_counter.length; i++) {
708
  var el = jQuery('#ure_caps_group_'+ ure_main.caps_counter[i].id);
709
  var old_text = el.text();
710
  var key_pos = old_text.indexOf('('); // exclude (0/0) text if it is in string already
@@ -725,8 +726,8 @@ function ure_sizes_update() {
725
  }
726
 
727
 
728
- jQuery(window).resize(function() {
729
- ure_sizes_update();
730
  });
731
 
732
 
@@ -748,7 +749,7 @@ function ure_show_granted_caps_only() {
748
  cap_div.addClass('hidden');
749
  }
750
  } else {
751
- if (cap_div.hasClass('deprecated') && !show_deprecated) {
752
  return;
753
  }
754
  if (cap_div.hasClass('hidden')) {
525
  return;
526
  }
527
 
528
+ // remove "Granted Only" filter is it was set before current role change
529
+ var granted_only = jQuery('#granted_only').prop('checked');
530
+ if (granted_only) {
531
+ jQuery('#granted_only').prop('checked', false);
532
+ ure_show_granted_caps_only();
533
+ }
534
+
535
  ure_current_role = response.role_id;
536
  ure_current_role_name = response.role_name;
537
  // Select capabilities granted to a newly selected role and exclude others
541
 
542
  // Recalculate granted capabilities for capabilities groups
543
  ure_count_caps_in_groups();
544
+ ure_select_selectable_element(jQuery('#ure_caps_groups_list'), jQuery('#ure_caps_group_all'));
 
 
 
 
 
545
 
546
  // additional options section
547
  jQuery('#additional_options').find(':checkbox').each(function() { // go through all additional options checkboxes
569
 
570
  function ure_filter_capabilities(cap_id) {
571
  var div_list = jQuery('.ure-cap-div');
572
+ for (var i = 0; i < div_list.length; i++) {
573
  if (cap_id !== '' && div_list[i].id.substr(11).indexOf(cap_id) !== -1) {
574
  jQuery('#'+ div_list[i].id).addClass('ure_tag');
575
  div_list[i].style.color = '#27CF27';
578
  jQuery('#'+ div_list[i].id).removeClass('ure_tag');
579
  }
580
  }
 
581
 
582
  }
583
  // end of ure_filter_capabilities()
649
 
650
 
651
  function ure_validate_columns(columns) {
652
+ if (columns==1 || ure_main.selected_group==='all') {
653
  return columns;
654
  }
655
 
656
  // Do not split list on columns in case it contains less then < 25 capabilities
657
+ for (var i=0; i<ure_main.caps_counter.length; i++) {
658
+ if (ure_main.caps_counter[i].id===ure_main.selected_group) {
659
  if (ure_main.caps_counter[i].total<=25) {
660
  columns = 1;
661
  }
682
  ure_main.caps_counter = new Array();
683
  jQuery('#ure_caps_groups_list li').each(function() {
684
  var group_id = jQuery(this).attr('id').substr(15);
685
+ var group_counter = {'id': group_id, 'total': 0, 'granted':0};
686
  ure_main.caps_counter.push(group_counter);
687
  });
688
 
695
  jQuery('.ure-cap-div').each(function () {
696
  var cap_div = jQuery(this);
697
  var capability = cap_div.attr('id').substr(12);
698
+ for (var i=0; i<ure_main.caps_counter.length; i++) {
699
  if (cap_div.hasClass(ure_main.class_prefix + ure_main.caps_counter[i].id)) {
700
  ure_main.caps_counter[i].total++;
701
  if (jQuery('#'+ capability).is(':checked')) {
705
  }
706
  });
707
 
708
+ for (var i=0; i<ure_main.caps_counter.length; i++) {
709
  var el = jQuery('#ure_caps_group_'+ ure_main.caps_counter[i].id);
710
  var old_text = el.text();
711
  var key_pos = old_text.indexOf('('); // exclude (0/0) text if it is in string already
726
  }
727
 
728
 
729
+ jQuery(window).resize(function () {
730
+ ure_sizes_update();
731
  });
732
 
733
 
749
  cap_div.addClass('hidden');
750
  }
751
  } else {
752
+ if (cap_div.hasClass('ure-deprecated') && !show_deprecated) {
753
  return;
754
  }
755
  if (cap_div.hasClass('hidden')) {
lang/user-role-editor.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
  msgstr ""
4
  "Project-Id-Version: User Role Editor 4.19.2\n"
5
  "Report-Msgid-Bugs-To: \n"
6
- "POT-Creation-Date: 2018-09-24 10:33+0700\n"
7
  "PO-Revision-Date: \n"
8
  "Last-Translator: Vladimir Garagulya <vladimir@shinephp.com>\n"
9
  "Language-Team: https://www.role-editor.com <support@role-editor.com>\n"
@@ -88,34 +88,38 @@ msgstr ""
88
  msgid "Error: this capability is used internally by WordPress"
89
  msgstr ""
90
 
91
- #: ../includes/classes/capability.php:72 ../includes/classes/capability.php:179
 
 
 
 
92
  #: ../includes/classes/lib.php:1161 ../includes/classes/lib.php:1405
93
  #: ../includes/classes/lib.php:1520 ../includes/classes/lib.php:1567
94
  #: ../includes/classes/user-role-editor.php:641
95
  msgid "Insufficient permissions to work with User Role Editor"
96
  msgstr ""
97
 
98
- #: ../includes/classes/capability.php:94
99
  #, php-format
100
  msgid "Capability %s was added successfully"
101
  msgstr ""
102
 
103
- #: ../includes/classes/capability.php:96
104
  #, php-format
105
  msgid "Capability %s exists already"
106
  msgstr ""
107
 
108
- #: ../includes/classes/capability.php:186
109
- #: ../includes/classes/capability.php:191
110
  msgid "There are no capabilities available for deletion!"
111
  msgstr ""
112
 
113
- #: ../includes/classes/capability.php:197
114
  #, php-format
115
  msgid "Capability %s was removed successfully"
116
  msgstr ""
117
 
118
- #: ../includes/classes/capability.php:200
119
  msgid "capabilities were removed successfully"
120
  msgstr ""
121
 
3
  msgstr ""
4
  "Project-Id-Version: User Role Editor 4.19.2\n"
5
  "Report-Msgid-Bugs-To: \n"
6
+ "POT-Creation-Date: 2018-11-12 09:17+0700\n"
7
  "PO-Revision-Date: \n"
8
  "Last-Translator: Vladimir Garagulya <vladimir@shinephp.com>\n"
9
  "Language-Team: https://www.role-editor.com <support@role-editor.com>\n"
88
  msgid "Error: this capability is used internally by WordPress"
89
  msgstr ""
90
 
91
+ #: ../includes/classes/capability.php:54
92
+ msgid "Error: this word is used by WordPress as a role ID"
93
+ msgstr ""
94
+
95
+ #: ../includes/classes/capability.php:79 ../includes/classes/capability.php:190
96
  #: ../includes/classes/lib.php:1161 ../includes/classes/lib.php:1405
97
  #: ../includes/classes/lib.php:1520 ../includes/classes/lib.php:1567
98
  #: ../includes/classes/user-role-editor.php:641
99
  msgid "Insufficient permissions to work with User Role Editor"
100
  msgstr ""
101
 
102
+ #: ../includes/classes/capability.php:101
103
  #, php-format
104
  msgid "Capability %s was added successfully"
105
  msgstr ""
106
 
107
+ #: ../includes/classes/capability.php:103
108
  #, php-format
109
  msgid "Capability %s exists already"
110
  msgstr ""
111
 
112
+ #: ../includes/classes/capability.php:197
113
+ #: ../includes/classes/capability.php:202
114
  msgid "There are no capabilities available for deletion!"
115
  msgstr ""
116
 
117
+ #: ../includes/classes/capability.php:208
118
  #, php-format
119
  msgid "Capability %s was removed successfully"
120
  msgstr ""
121
 
122
+ #: ../includes/classes/capability.php:211
123
  msgid "capabilities were removed successfully"
124
  msgstr ""
125
 
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: 4.9.8
7
- Stable tag: 4.46
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -79,7 +79,14 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
79
 
80
 
81
  == Changelog =
82
- = [4.46] 25.09.2018
 
 
 
 
 
 
 
83
  * Update: "Users" page, "Without role" button: underlying SQL queries were replaced with more robust versions (about 10 times faster).
84
  It is critical for sites with large quant of users.New query does not take into account though some cases with incorrect users data (usually imported from the external sources).
85
  It's possible to use older (comprehensive but slower) query version defining a PHP constant: "define('URE_COUNT_USERS_WITHOUT_ROLE_THOROUGHLY', true);" or
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.0
7
+ Stable tag: 4.47
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
79
 
80
 
81
  == Changelog =
82
+ = [4.47] 12.11.2018 =
83
+ * Fix: "Users->User Role Editor": Capabilities view was not refreshed properly for new selected role in case "Granted Only" filter was turned ON before other role selection.
84
+ * Update: Unused code was removed from user-role-editor/includes/classes/bbpress.php
85
+ * Update: Prevent sudden revoke role 'administrator' from a user(s) during capability with the same ID ('administrator') deletion from roles.
86
+ * Update: Adding custom capability with ID 'administrator' was prohibited.
87
+ * Update: Marked as compatible with WordPress version 5.0
88
+
89
+ = [4.46] 25.09.2018 =
90
  * Update: "Users" page, "Without role" button: underlying SQL queries were replaced with more robust versions (about 10 times faster).
91
  It is critical for sites with large quant of users.New query does not take into account though some cases with incorrect users data (usually imported from the external sources).
92
  It's possible to use older (comprehensive but slower) query version defining a PHP constant: "define('URE_COUNT_USERS_WITHOUT_ROLE_THOROUGHLY', true);" or
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.46
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.46' );
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.47
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.47' );
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__ ) );