WPFront User Role Editor - Version 3.1.0

Version Description

  • Debug functionality added.
  • Assign/Migrate UI change.
  • Compatibility fixes.
  • Bug fixes.
Download this release

Release Info

Developer syammohanm
Plugin Icon 128x128 WPFront User Role Editor
Version 3.1.0
Comparing to
See all releases

Code changes from version 3.0.0 to 3.1.0

assets/css/roles.css CHANGED
@@ -133,6 +133,10 @@ div.role-add-new div.metabox-holder div.postbox div.main i.fa-question-circle-o
133
  font-size: 0.8em;
134
  }
135
 
 
 
 
 
136
  div.role-add-new div.footer {
137
  text-align: center;
138
  }
@@ -237,6 +241,15 @@ div.wrap.assign-roles div.role-list div.role-list-item,
237
  div.wrap.migrate-users div.role-list div.role-list-item {
238
  padding-bottom: 5px;
239
  }
 
 
 
 
 
 
 
 
 
240
  /* assign roles end */
241
 
242
  /* import roles start */
@@ -605,7 +618,7 @@ div.wrap.post-type-add-edit ul.chosen-choices {
605
  flex-wrap: wrap;
606
  }
607
 
608
- /* post type screen start */
609
 
610
  /* taxonomies screen start */
611
 
@@ -638,3 +651,21 @@ div.thickbox p.error {
638
  color: red;
639
  }
640
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  font-size: 0.8em;
134
  }
135
 
136
+ div.role-add-new div.metabox-holder div.postbox div.main label {
137
+ max-width: 205px;
138
+ }
139
+
140
  div.role-add-new div.footer {
141
  text-align: center;
142
  }
241
  div.wrap.migrate-users div.role-list div.role-list-item {
242
  padding-bottom: 5px;
243
  }
244
+
245
+ div.wrap.assign-roles input[name="assign-user"],
246
+ div.wrap.assign-roles select.primary-role,
247
+ div.wrap.migrate-users select.primary-role,
248
+ div.wrap.migrate-users select#migrate_from_role {
249
+ width: 100%;
250
+ max-width: 25em;
251
+ }
252
+
253
  /* assign roles end */
254
 
255
  /* import roles start */
618
  flex-wrap: wrap;
619
  }
620
 
621
+ /* post type screen end */
622
 
623
  /* taxonomies screen start */
624
 
651
  color: red;
652
  }
653
 
654
+ /* autocomplete start */
655
+
656
+ .ui-autocomplete .ui-menu-item {
657
+ padding: 0;
658
+ font-size: 15px;
659
+ line-height:1.5;
660
+ width: 100%;
661
+ }
662
+
663
+ .ui-autocomplete .ui-state-hover, .ui-autocomplete .ui-state-active {
664
+ color: #ffffff;
665
+ background-color: #3399ff;
666
+ font-weight: normal;
667
+ }
668
+
669
+ /* autocomplete end */
670
+
671
+
includes/add-remove-cap/class-add-remove-cap.php CHANGED
@@ -39,6 +39,8 @@ use WPFront\URE\WPFront_User_Role_Editor as WPFURE;
39
  use WPFront\URE\WPFront_User_Role_Editor_Utils as Utils;
40
  use WPFront\URE\WPFront_User_Role_Editor_Roles_Helper as RolesHelper;
41
  use WPFront\URE\Bulk_Edit\WPFront_User_Role_Editor_Bulk_Edit as BulkEdit;
 
 
42
 
43
  require_once dirname(__FILE__) . '/template-add-remove-cap.php';
44
 
@@ -75,6 +77,13 @@ if (!class_exists('\WPFront\URE\Bulk_Edit\WPFront_User_Role_Editor_Add_Remove_Ca
75
  }
76
 
77
  protected function _register($controllers) {
 
 
 
 
 
 
 
78
  if (!$this->in_admin_ui()) {
79
  return $controllers;
80
  }
39
  use WPFront\URE\WPFront_User_Role_Editor_Utils as Utils;
40
  use WPFront\URE\WPFront_User_Role_Editor_Roles_Helper as RolesHelper;
41
  use WPFront\URE\Bulk_Edit\WPFront_User_Role_Editor_Bulk_Edit as BulkEdit;
42
+ use \WPFront\URE\WPFront_User_Role_Editor_Debug;
43
+
44
 
45
  require_once dirname(__FILE__) . '/template-add-remove-cap.php';
46
 
77
  }
78
 
79
  protected function _register($controllers) {
80
+ $debug = WPFront_User_Role_Editor_Debug::instance();
81
+ $debug->add_setting('add-remove-cap', 'Add or Remove Capability');
82
+
83
+ if($debug->is_disabled('add-remove-cap')) {
84
+ return $controllers;
85
+ }
86
+
87
  if (!$this->in_admin_ui()) {
88
  return $controllers;
89
  }
includes/bulk-edit/class-bulk-edit.php CHANGED
@@ -37,6 +37,7 @@ if (!defined('ABSPATH')) {
37
  use WPFront\URE\WPFront_User_Role_Editor as WPFURE;
38
  use WPFront\URE\WPFront_User_Role_Editor_Utils as Utils;
39
  use WPFront\URE\WPFront_User_Role_Editor_Roles_Helper as RolesHelper;
 
40
 
41
  require_once dirname(__FILE__) . '/template-bulk-edit.php';
42
  require_once dirname(__FILE__) . '/class-bulk-edit-utils.php';
@@ -71,6 +72,13 @@ if (!class_exists('\WPFront\URE\Bulk_Edit\WPFront_User_Role_Editor_Bulk_Edit'))
71
  }
72
 
73
  protected function initialize() {
 
 
 
 
 
 
 
74
  if(!is_admin()) {
75
  return;
76
  }
37
  use WPFront\URE\WPFront_User_Role_Editor as WPFURE;
38
  use WPFront\URE\WPFront_User_Role_Editor_Utils as Utils;
39
  use WPFront\URE\WPFront_User_Role_Editor_Roles_Helper as RolesHelper;
40
+ use \WPFront\URE\WPFront_User_Role_Editor_Debug;
41
 
42
  require_once dirname(__FILE__) . '/template-bulk-edit.php';
43
  require_once dirname(__FILE__) . '/class-bulk-edit-utils.php';
72
  }
73
 
74
  protected function initialize() {
75
+ $debug = WPFront_User_Role_Editor_Debug::instance();
76
+ $debug->add_setting('bulk-edit', 'Bulk Edit');
77
+
78
+ if($debug->is_disabled('bulk-edit')) {
79
+ return;
80
+ }
81
+
82
  if(!is_admin()) {
83
  return;
84
  }
includes/class-controller.php CHANGED
@@ -110,6 +110,19 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor_Controller')) {
110
  }
111
  }
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  $key = static::class;
114
 
115
  $firstLevel = true;
@@ -151,7 +164,7 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor_Controller')) {
151
  protected function set_cap($cap) {
152
  $this->cap = $cap;
153
  }
154
-
155
  }
156
 
157
  }
110
  }
111
  }
112
 
113
+ if(method_exists(static::class, 'get_debug_setting')) {
114
+ $debug_values = call_user_func(array(static::class, 'get_debug_setting'));
115
+
116
+ $debug = WPFront_User_Role_Editor_Debug::instance();
117
+ $debug->add_setting($debug_values['key'], $debug_values['label']);
118
+
119
+ $disabled = $debug->is_disabled($debug_values['key']);
120
+
121
+ if($disabled) {
122
+ return;
123
+ }
124
+ }
125
+
126
  $key = static::class;
127
 
128
  $firstLevel = true;
164
  protected function set_cap($cap) {
165
  $this->cap = $cap;
166
  }
167
+
168
  }
169
 
170
  }
includes/class-debug.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ WPFront User Role Editor Plugin
4
+ Copyright (C) 2014, WPFront.com
5
+ Website: wpfront.com
6
+ Contact: syam@wpfront.com
7
+
8
+ WPFront User Role Editor Plugin is distributed under the GNU General Public License, Version 3,
9
+ June 2007. Copyright (C) 2007 Free Software Foundation, Inc., 51 Franklin
10
+ St, Fifth Floor, Boston, MA 02110, USA
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
16
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+ */
23
+
24
+ /**
25
+ * Controller for WPFront User Role Editor Debug
26
+ * @author Jinu Varghese
27
+ * @copyright 2014 WPFront.com
28
+ */
29
+
30
+ namespace WPFront\URE;
31
+
32
+ if (!defined('ABSPATH')) {
33
+ exit();
34
+ }
35
+
36
+ use \WPFront\URE\Options\iWPFront_User_Role_Editor_Settings_Controller;
37
+
38
+ /**
39
+ * Debug controller
40
+ *
41
+ * @author Jinu Varghese
42
+ * @copyright 2014 WPFront.com
43
+ */
44
+ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor_Debug')) {
45
+
46
+ class WPFront_User_Role_Editor_Debug implements iWPFront_User_Role_Editor_Settings_Controller {
47
+
48
+ protected static $instance = null;
49
+ protected $debug_keys = array();
50
+ protected $settings_key = 'debug-settings';
51
+ protected $settings_obj = null;
52
+ protected $options;
53
+
54
+ public static function instance() {
55
+ if (self::$instance === null) {
56
+ self::$instance = new WPFront_User_Role_Editor_Debug();
57
+ }
58
+
59
+ return self::$instance;
60
+ }
61
+
62
+ public static function init() {
63
+ if(!defined('WP_DEBUG') || !WP_DEBUG) {
64
+ return;
65
+ }
66
+
67
+ add_filter('wpfront_ure_settings_controllers', array(self::instance(), 'register_settings'), 10);
68
+ }
69
+
70
+ public function register_settings($controllers) {
71
+ if(is_multisite() && !is_network_admin()) {
72
+ return $controllers;
73
+ }
74
+
75
+ if (current_user_can('manage_options')) {
76
+ $controllers[] = self::instance();
77
+ }
78
+
79
+ return $controllers;
80
+ }
81
+
82
+ public function getKey() {
83
+ return 'debug';
84
+ }
85
+
86
+ public function getTitle() {
87
+ return __('Debug', 'wpfront-user-role-editor');
88
+ }
89
+
90
+ public function view_callback() {
91
+ $this->view_settings();
92
+ }
93
+
94
+ public function load_view_callback($parent) {
95
+ if (!empty($_POST['submit'])) {
96
+ $settings_obj = new \stdClass();
97
+ $settings = empty($_POST[$this->settings_key]) ? [] : $_POST[$this->settings_key];
98
+ foreach ($this->debug_keys as $key => $label) {
99
+ if(!empty($settings[$key])) {
100
+ $settings_obj->$key = true;
101
+ }
102
+ }
103
+
104
+ $this->get_options_obj()->set_network_option($this->settings_key, $settings_obj, '', false);
105
+
106
+ if (wp_safe_redirect($parent->getControllerUrl($this) . '&changes-saved=true')) {
107
+ exit();
108
+ }
109
+ }
110
+
111
+ $this->set_help_tab();
112
+ }
113
+
114
+ protected function set_help_tab() {
115
+
116
+ }
117
+
118
+ public function display_notices() {
119
+ if ((isset($_GET['changes-saved']) && $_GET['changes-saved'] == 'true')) {
120
+ \WPFront\URE\WPFront_User_Role_Editor_Utils::notice_updated(__('Debug settings saved.', 'wpfront-user-role-editor'));
121
+ }
122
+ }
123
+
124
+ protected function view_settings() {
125
+ ?>
126
+ <div id="wpfront-user-role-editor-debug">
127
+ <table class="form-table">
128
+ <?php $this->display_rows(); ?>
129
+ </table>
130
+ </div>
131
+ <?php
132
+ }
133
+
134
+ protected function display_rows() {
135
+ foreach ($this->debug_keys as $key => $label) {
136
+ $label = sprintf(__('Disable %s', 'wpfront-user-role-editor'), $label);
137
+
138
+ $disabled = $this->is_disabled($key);
139
+ $checked = $disabled ? 'checked' : '';
140
+ ?>
141
+ <tr>
142
+ <th scope="row">
143
+ <?php echo $label; ?>
144
+ </th>
145
+ <td>
146
+ <input type="checkbox" name="<?php echo esc_attr("{$this->settings_key}[$key]"); ?>" <?php echo $checked; ?> />
147
+ </td>
148
+ </tr>
149
+ <?php
150
+ }
151
+ }
152
+
153
+ public function add_setting($setting, $label = null) {
154
+ if(!defined('WP_DEBUG') || !WP_DEBUG) {
155
+ return false;
156
+ }
157
+
158
+ if (is_array($setting)) {
159
+ $key = $setting['key'];
160
+ $label = $setting['label'];
161
+ } else {
162
+ $key = $setting;
163
+ }
164
+
165
+ $this->debug_keys[$key] = $label;
166
+
167
+ return true;
168
+ }
169
+
170
+ public function is_disabled($key) {
171
+ if(!defined('WP_DEBUG') || !WP_DEBUG) {
172
+ return false;
173
+ }
174
+
175
+ $obj = $this->get_settings_obj();
176
+ return !empty($obj->$key);
177
+ }
178
+
179
+ protected function get_options_obj() {
180
+ if(empty($this->options)) {
181
+ $this->options = \WPFront\URE\Options\WPFront_User_Role_Editor_Options::instance();
182
+ }
183
+
184
+ return $this->options;
185
+ }
186
+
187
+ protected function get_settings_obj() {
188
+ if($this->settings_obj === null) {
189
+ $this->settings_obj = $this->get_options_obj()->get_network_option($this->settings_key, '');
190
+ }
191
+
192
+ return $this->settings_obj;
193
+ }
194
+ }
195
+
196
+ add_action('wpfront_ure_init', array(WPFront_User_Role_Editor_Debug::class, 'init'));
197
+ }
198
+
199
+
includes/login-redirect/class-login-redirect.php CHANGED
@@ -636,6 +636,9 @@ if (!class_exists('\WPFront\URE\Login_Redirect\WPFront_User_Role_Editor_Login_Re
636
  $this->UtilsClass::set_help_tab($tabs, $sidebar);
637
  }
638
 
 
 
 
639
  }
640
 
641
  WPFront_User_Role_Editor_Login_Redirect::load();
636
  $this->UtilsClass::set_help_tab($tabs, $sidebar);
637
  }
638
 
639
+ public static function get_debug_setting() {
640
+ return array('key' => 'login-redirect', 'label' => 'Login Redirect');
641
+ }
642
  }
643
 
644
  WPFront_User_Role_Editor_Login_Redirect::load();
includes/media/class-media-permissions.php CHANGED
@@ -119,6 +119,9 @@ if (!class_exists('\WPFront\URE\Media\WPFront_User_Role_Editor_Media_Permissions
119
  return RolesHelper::get_wpfront_help_link($cap);
120
  }
121
 
 
 
 
122
  }
123
 
124
  WPFront_User_Role_Editor_Media_Permissions::load();
119
  return RolesHelper::get_wpfront_help_link($cap);
120
  }
121
 
122
+ public static function get_debug_setting() {
123
+ return array('key' => 'media-permissions', 'label' => 'Media Permissions');
124
+ }
125
  }
126
 
127
  WPFront_User_Role_Editor_Media_Permissions::load();
includes/nav-menu/class-nav-menu-permissions.php CHANGED
@@ -451,6 +451,10 @@ if (!class_exists('\WPFront\URE\Nav_Menu\WPFront_User_Role_Editor_Nav_Menu_Permi
451
  delete_post_meta_by_key(self::$META_DATA_KEY);
452
  }
453
 
 
 
 
 
454
  }
455
 
456
  \WPFront\URE\WPFront_User_Role_Editor_Uninstall::register_callback('\WPFront\URE\Nav_Menu\WPFront_User_Role_Editor_Nav_Menu_Permissions::uninstall');
451
  delete_post_meta_by_key(self::$META_DATA_KEY);
452
  }
453
 
454
+ public static function get_debug_setting() {
455
+ return array('key' => 'nav-menu-permissions', 'label' => 'Navigation Menu Permissions');
456
+ }
457
+
458
  }
459
 
460
  \WPFront\URE\WPFront_User_Role_Editor_Uninstall::register_callback('\WPFront\URE\Nav_Menu\WPFront_User_Role_Editor_Nav_Menu_Permissions::uninstall');
includes/post-type/class-abstract-post-type-custom-cap.php CHANGED
@@ -38,6 +38,7 @@ if (!defined('ABSPATH')) {
38
  use WPFront\URE\Options\WPFront_User_Role_Editor_Options as Options;
39
  use WPFront\URE\WPFront_User_Role_Editor_Utils as Utils;
40
  use WPFront\URE\WPFront_User_Role_Editor_Roles_Helper as RolesHelper;
 
41
 
42
  if (!class_exists('\WPFront\URE\Post_Type\WPFront_User_Role_Editor_Post_Type_Custom_Capability')) {
43
 
@@ -81,7 +82,10 @@ if (!class_exists('\WPFront\URE\Post_Type\WPFront_User_Role_Editor_Post_Type_Cus
81
  protected abstract function role_default_value_cap($post_type);
82
 
83
  protected abstract function can_merge();
 
 
84
 
 
85
  public static function initialize($controller) {
86
  foreach (self::$custom_cap_objs as $key => $obj) {
87
  $obj->init($controller);
@@ -103,6 +107,14 @@ if (!class_exists('\WPFront\URE\Post_Type\WPFront_User_Role_Editor_Post_Type_Cus
103
  }
104
 
105
  public static function register($key, $objCustomCap) {
 
 
 
 
 
 
 
 
106
  self::$custom_cap_objs[$key] = $objCustomCap;
107
  }
108
 
@@ -139,6 +151,12 @@ if (!class_exists('\WPFront\URE\Post_Type\WPFront_User_Role_Editor_Post_Type_Cus
139
  $this->cap_names[$post_type] = [$cap, $plural_base];
140
 
141
  if($this->can_merge()) {
 
 
 
 
 
 
142
  $args['capabilities'] = array_merge($args['capabilities'], array($prefix . '_posts' => $cap));
143
  }
144
 
38
  use WPFront\URE\Options\WPFront_User_Role_Editor_Options as Options;
39
  use WPFront\URE\WPFront_User_Role_Editor_Utils as Utils;
40
  use WPFront\URE\WPFront_User_Role_Editor_Roles_Helper as RolesHelper;
41
+ use WPFront\URE\WPFront_User_Role_Editor_Debug;
42
 
43
  if (!class_exists('\WPFront\URE\Post_Type\WPFront_User_Role_Editor_Post_Type_Custom_Capability')) {
44
 
82
  protected abstract function role_default_value_cap($post_type);
83
 
84
  protected abstract function can_merge();
85
+
86
+ protected abstract function get_debug_setting();
87
 
88
+
89
  public static function initialize($controller) {
90
  foreach (self::$custom_cap_objs as $key => $obj) {
91
  $obj->init($controller);
107
  }
108
 
109
  public static function register($key, $objCustomCap) {
110
+ $debug_setting = $objCustomCap->get_debug_setting();
111
+ $debug = WPFront_User_Role_Editor_Debug::instance();
112
+ $debug->add_setting($debug_setting);
113
+
114
+ if($debug->is_disabled($debug_setting['key'])) {
115
+ return;
116
+ }
117
+
118
  self::$custom_cap_objs[$key] = $objCustomCap;
119
  }
120
 
151
  $this->cap_names[$post_type] = [$cap, $plural_base];
152
 
153
  if($this->can_merge()) {
154
+ if(!isset($args['map_meta_cap'])) {
155
+ if ( empty( $args['capabilities'] ) && in_array( $args_local['capability_type'], array( 'post', 'page' ), true ) ) {
156
+ $args['map_meta_cap'] = true;
157
+ }
158
+ }
159
+
160
  $args['capabilities'] = array_merge($args['capabilities'], array($prefix . '_posts' => $cap));
161
  }
162
 
includes/post-type/class-post-type.php CHANGED
@@ -172,10 +172,10 @@ if (!class_exists('\WPFront\URE\Post_Type\WPFront_User_Role_Editor_Post_Type'))
172
  $entity_all = $this->get_all_entities();
173
  $add_custom_caps = true;
174
  if (isset($entity_all[$post_type])) {
175
- if(empty($args['_builtin']) && $entity_all[$post_type]->status == self::STATUS_INACTIVE) {
176
  $add_custom_caps = false;
177
  }
178
-
179
  $saved = $entity_all[$post_type]->post_type_arg;
180
  $saved['taxonomies'] = $entity_all[$post_type]->taxonomies;
181
 
@@ -186,7 +186,7 @@ if (!class_exists('\WPFront\URE\Post_Type\WPFront_User_Role_Editor_Post_Type'))
186
  $args = array_merge($args, $saved);
187
  }
188
 
189
- if($add_custom_caps) {
190
  $args = WPFront_User_Role_Editor_Post_Type_Custom_Capability::register_post_type_args($this, $args, $post_type);
191
  }
192
 
@@ -1055,7 +1055,13 @@ if (!class_exists('\WPFront\URE\Post_Type\WPFront_User_Role_Editor_Post_Type'))
1055
  $data->source_type = $post_type_obj->_builtin ? self::SOURCE_TYPE_BUILTIN : self::SOURCE_TYPE_OTHER;
1056
  $taxes = get_object_taxonomies($post_type_obj->name);
1057
  $data->taxonomies = is_array($taxes) ? $taxes : [];
1058
- $data->post_type_arg = $this->post_type_args[$name];
 
 
 
 
 
 
1059
  $data->entity = null;
1060
 
1061
  $exiting[$name] = $data;
@@ -1354,6 +1360,10 @@ if (!class_exists('\WPFront\URE\Post_Type\WPFront_User_Role_Editor_Post_Type'))
1354
  parent::admin_print_styles();
1355
  wp_enqueue_style('wpfront-user-role-editor-post-types', WPFURE::instance()->get_asset_url('css/chosen/chosen.min.css'), array(), WPFURE::VERSION);
1356
  }
 
 
 
 
1357
 
1358
  }
1359
 
172
  $entity_all = $this->get_all_entities();
173
  $add_custom_caps = true;
174
  if (isset($entity_all[$post_type])) {
175
+ if (empty($args['_builtin']) && $entity_all[$post_type]->status == self::STATUS_INACTIVE) {
176
  $add_custom_caps = false;
177
  }
178
+
179
  $saved = $entity_all[$post_type]->post_type_arg;
180
  $saved['taxonomies'] = $entity_all[$post_type]->taxonomies;
181
 
186
  $args = array_merge($args, $saved);
187
  }
188
 
189
+ if ($add_custom_caps) {
190
  $args = WPFront_User_Role_Editor_Post_Type_Custom_Capability::register_post_type_args($this, $args, $post_type);
191
  }
192
 
1055
  $data->source_type = $post_type_obj->_builtin ? self::SOURCE_TYPE_BUILTIN : self::SOURCE_TYPE_OTHER;
1056
  $taxes = get_object_taxonomies($post_type_obj->name);
1057
  $data->taxonomies = is_array($taxes) ? $taxes : [];
1058
+
1059
+ if (isset($this->post_type_args[$name])) {
1060
+ $data->post_type_arg = $this->post_type_args[$name];
1061
+ } else {
1062
+ $data->post_type_arg = array();
1063
+ }
1064
+
1065
  $data->entity = null;
1066
 
1067
  $exiting[$name] = $data;
1360
  parent::admin_print_styles();
1361
  wp_enqueue_style('wpfront-user-role-editor-post-types', WPFURE::instance()->get_asset_url('css/chosen/chosen.min.css'), array(), WPFURE::VERSION);
1362
  }
1363
+
1364
+ public static function get_debug_setting() {
1365
+ return array('key' => 'post-type', 'label' => 'Post Types');
1366
+ }
1367
 
1368
  }
1369
 
includes/post-type/custom-caps/class-create-posts-capability.php CHANGED
@@ -75,6 +75,10 @@ if (!class_exists('\WPFront\URE\Post_Type\Custom_Caps\WPFront_User_Role_Editor_C
75
  protected function can_merge() {
76
  return false;
77
  }
 
 
 
 
78
 
79
  }
80
 
75
  protected function can_merge() {
76
  return false;
77
  }
78
+
79
+ protected function get_debug_setting() {
80
+ return array('key' => 'create-custom-capability', 'label' => '"create" Capability');
81
+ }
82
 
83
  }
84
 
includes/post-type/custom-caps/class-read-others-capability.php CHANGED
@@ -75,6 +75,10 @@ if (!class_exists('\WPFront\URE\Post_Type\Custom_Caps\WPFront_User_Role_Editor_R
75
  protected function can_merge() {
76
  return false;
77
  }
 
 
 
 
78
 
79
 
80
  }
75
  protected function can_merge() {
76
  return false;
77
  }
78
+
79
+ protected function get_debug_setting() {
80
+ return array('key' => 'read_others-custom-capability', 'label' => '"read_others" Capability');
81
+ }
82
 
83
 
84
  }
includes/restore/class-restore.php CHANGED
@@ -302,6 +302,9 @@ if (!class_exists('\WPFront\URE\Restore\WPFront_User_Role_Editor_Restore')) {
302
  return $this->Options->get_option_boolean('remove_nonstandard_capabilities_restore', true);
303
  }
304
 
 
 
 
305
  }
306
 
307
  WPFront_User_Role_Editor_Restore::load();
302
  return $this->Options->get_option_boolean('remove_nonstandard_capabilities_restore', true);
303
  }
304
 
305
+ public static function get_debug_setting() {
306
+ return array('key' => 'restore', 'label' => 'Restore');
307
+ }
308
  }
309
 
310
  WPFront_User_Role_Editor_Restore::load();
includes/roles/class-role-add-edit.php CHANGED
@@ -34,6 +34,8 @@ if (!defined('ABSPATH')) {
34
  exit();
35
  }
36
 
 
 
37
  require_once dirname(__FILE__) . '/template-role-add-edit.php';
38
 
39
  if (!class_exists('\WPFront\URE\Roles\WPFront_User_Role_Editor_Role_Add_Edit')) {
@@ -67,6 +69,15 @@ if (!class_exists('\WPFront\URE\Roles\WPFront_User_Role_Editor_Role_Add_Edit'))
67
  }
68
 
69
  protected function initialize() {
 
 
 
 
 
 
 
 
 
70
  add_action('wp_before_admin_bar_render', array($this, 'admin_bar_menu'), 1);
71
  add_action('admin_init', array($this, 'admin_init'));
72
 
34
  exit();
35
  }
36
 
37
+ use \WPFront\URE\WPFront_User_Role_Editor_Debug;
38
+
39
  require_once dirname(__FILE__) . '/template-role-add-edit.php';
40
 
41
  if (!class_exists('\WPFront\URE\Roles\WPFront_User_Role_Editor_Role_Add_Edit')) {
69
  }
70
 
71
  protected function initialize() {
72
+ $debug = WPFront_User_Role_Editor_Debug::instance();
73
+
74
+ $debug_setting = $this->RolesList->get_debug_setting();
75
+ $debug->add_setting($debug_setting);
76
+
77
+ if($debug->is_disabled($debug_setting['key'])) {
78
+ return;
79
+ }
80
+
81
  add_action('wp_before_admin_bar_render', array($this, 'admin_bar_menu'), 1);
82
  add_action('admin_init', array($this, 'admin_init'));
83
 
includes/roles/class-roles-list.php CHANGED
@@ -663,6 +663,9 @@ if (!class_exists('\WPFront\URE\Roles\WPFront_User_Role_Editor_Roles_List')) {
663
  $this->UtilsClass::set_help_tab($tabs, $sidebar);
664
  }
665
 
 
 
 
666
  }
667
 
668
  WPFront_User_Role_Editor_Roles_List::load();
663
  $this->UtilsClass::set_help_tab($tabs, $sidebar);
664
  }
665
 
666
+ public static function get_debug_setting() {
667
+ return array('key' => 'roles', 'label' => 'All Roles & Add New');
668
+ }
669
  }
670
 
671
  WPFront_User_Role_Editor_Roles_List::load();
includes/roles/template-role-add-edit.php CHANGED
@@ -554,9 +554,9 @@ if (!class_exists('WPFront\URE\Roles\WPFront_User_Role_Editor_Role_Add_Edit_View
554
 
555
  for (m in response) {
556
  if (response[m]) {
557
- allowed.push('.cap-label-' + m);
558
  } else {
559
- denied.push('.cap-label-' + m);
560
  }
561
  }
562
 
554
 
555
  for (m in response) {
556
  if (response[m]) {
557
+ allowed.push('.cap-label-' + $.escapeSelector(m));
558
  } else {
559
+ denied.push('.cap-label-' + $.escapeSelector(m));
560
  }
561
  }
562
 
includes/taxonomies/class-taxonomies.php CHANGED
@@ -124,7 +124,7 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
124
  if (isset($entity_all[$taxonomy])) {
125
  $entity = $entity_all[$taxonomy];
126
  $saved = $entity->taxonomy_arg;
127
- if(empty($saved)){
128
  $saved = array();
129
  }
130
 
@@ -151,7 +151,7 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
151
  }
152
  }
153
  }
154
-
155
  /**
156
  * To handle late post type registrations.
157
  *
@@ -161,7 +161,7 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
161
  $entity_all = $this->get_all_entities();
162
  foreach ($entity_all as $taxonomy => $entity) {
163
  $post_types = $entity->post_types;
164
- if(in_array($post_type, $post_types)) {
165
  register_taxonomy_for_object_type($taxonomy, $post_type);
166
  }
167
  }
@@ -176,9 +176,15 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
176
  * @return type
177
  */
178
  public function registered_taxonomy($taxonomy, $object_type, $args) {
179
- if (empty($this->taxonomy_args[$taxonomy])) {
180
  return;
181
  }
 
 
 
 
 
 
182
 
183
  if (!empty($this->taxonomy_args[$taxonomy]['labels']['singular_name'])) {
184
  return;
@@ -677,7 +683,7 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
677
  public function apply_active_list_filter() {
678
  $taxonomies = $this->get_all_taxonomies_data();
679
  $taxonomies = $this->sort_taxonomies_data($taxonomies);
680
-
681
  switch ($this->get_active_list_filter()) {
682
  case 'all':
683
  break;
@@ -759,10 +765,10 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
759
  $this->entities = $entity->get_all();
760
 
761
  $this->entities = $this->sanitize_pro_fields($this->entities);
762
-
763
  return $this->entities;
764
  }
765
-
766
  protected function sanitize_pro_fields($entities) {
767
  foreach ($entities as $post_type => $entity) {
768
  $entity->capability_type = null;
@@ -793,7 +799,7 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
793
 
794
  return $taxonomies;
795
  }
796
-
797
  protected function sort_taxonomies_data($taxonomies) {
798
  $built_in_taxonomies = array();
799
  $other_taxonomies = array();
@@ -913,7 +919,12 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
913
  $data->status = self::STATUS_ACTIVE;
914
  $data->source_type = $taxonomy_obj->_builtin ? self::SOURCE_TYPE_BUILTIN : self::SOURCE_TYPE_OTHER;
915
  $data->post_types = is_array($taxonomy_obj->object_type) ? $taxonomy_obj->object_type : [];
916
- $data->taxonomy_arg = $this->taxonomy_args[$name];
 
 
 
 
 
917
 
918
  if ($taxonomy_obj->_builtin) {
919
  $data->capability_type = null;
@@ -950,9 +961,9 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
950
  $data->post_types = $entity->post_types;
951
  $data->capability_type = $entity->capability_type;
952
  $data->entity = $entity;
953
-
954
  $data->taxonomy_arg = (empty($entity->taxonomy_arg) && isset($exiting[$name]->taxonomy_arg)) ? $exiting[$name]->taxonomy_arg : $entity->taxonomy_arg;
955
- if(empty($data->taxonomy_arg)) {
956
  $data->taxonomy_arg = array();
957
  }
958
 
@@ -962,11 +973,11 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
962
  //reset source types to intial state to take care of registration changing source type.
963
  $taxes = array_merge($exiting, $user_edited);
964
  foreach ($taxes as $name => $data) {
965
- if(isset($this->taxonomies_cache[$name])) {
966
  $data->source_type = $this->taxonomies_cache[$name]->source_type;
967
  }
968
  }
969
-
970
  $this->taxonomies_cache = $taxes;
971
 
972
  foreach ($this->taxonomies_cache as $name => $data) {
@@ -1137,10 +1148,10 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
1137
  }
1138
 
1139
  protected function is_valid_slug($slug) {
1140
- if(empty($slug)) {
1141
  return false;
1142
  }
1143
-
1144
  return sanitize_key($slug) === $slug;
1145
  }
1146
 
@@ -1204,6 +1215,10 @@ if (!class_exists('\WPFront\URE\Taxonomies\WPFront_User_Role_Editor_Taxonomies')
1204
  }
1205
  }
1206
 
 
 
 
 
1207
  }
1208
 
1209
  WPFront_User_Role_Editor_Taxonomies::load();
124
  if (isset($entity_all[$taxonomy])) {
125
  $entity = $entity_all[$taxonomy];
126
  $saved = $entity->taxonomy_arg;
127
+ if (empty($saved)) {
128
  $saved = array();
129
  }
130
 
151
  }
152
  }
153
  }
154
+
155
  /**
156
  * To handle late post type registrations.
157
  *
161
  $entity_all = $this->get_all_entities();
162
  foreach ($entity_all as $taxonomy => $entity) {
163
  $post_types = $entity->post_types;
164
+ if (in_array($post_type, $post_types)) {
165
  register_taxonomy_for_object_type($taxonomy, $post_type);
166
  }
167
  }
176
  * @return type
177
  */
178
  public function registered_taxonomy($taxonomy, $object_type, $args) {
179
+ if (!isset($this->taxonomy_args[$taxonomy])) {
180
  return;
181
  }
182
+
183
+ if(isset($this->taxonomy_args[$taxonomy]['labels'])) {
184
+ $this->taxonomy_args[$taxonomy]['labels'] = (array) $this->taxonomy_args[$taxonomy]['labels']; //fix if the param supplied is not array
185
+ } else {
186
+ $this->taxonomy_args[$taxonomy]['labels'] = array();
187
+ }
188
 
189
  if (!empty($this->taxonomy_args[$taxonomy]['labels']['singular_name'])) {
190
  return;
683
  public function apply_active_list_filter() {
684
  $taxonomies = $this->get_all_taxonomies_data();
685
  $taxonomies = $this->sort_taxonomies_data($taxonomies);
686
+
687
  switch ($this->get_active_list_filter()) {
688
  case 'all':
689
  break;
765
  $this->entities = $entity->get_all();
766
 
767
  $this->entities = $this->sanitize_pro_fields($this->entities);
768
+
769
  return $this->entities;
770
  }
771
+
772
  protected function sanitize_pro_fields($entities) {
773
  foreach ($entities as $post_type => $entity) {
774
  $entity->capability_type = null;
799
 
800
  return $taxonomies;
801
  }
802
+
803
  protected function sort_taxonomies_data($taxonomies) {
804
  $built_in_taxonomies = array();
805
  $other_taxonomies = array();
919
  $data->status = self::STATUS_ACTIVE;
920
  $data->source_type = $taxonomy_obj->_builtin ? self::SOURCE_TYPE_BUILTIN : self::SOURCE_TYPE_OTHER;
921
  $data->post_types = is_array($taxonomy_obj->object_type) ? $taxonomy_obj->object_type : [];
922
+
923
+ if (isset($this->taxonomy_args[$name])) {
924
+ $data->taxonomy_arg = $this->taxonomy_args[$name];
925
+ } else {
926
+ $data->taxonomy_arg = array();
927
+ }
928
 
929
  if ($taxonomy_obj->_builtin) {
930
  $data->capability_type = null;
961
  $data->post_types = $entity->post_types;
962
  $data->capability_type = $entity->capability_type;
963
  $data->entity = $entity;
964
+
965
  $data->taxonomy_arg = (empty($entity->taxonomy_arg) && isset($exiting[$name]->taxonomy_arg)) ? $exiting[$name]->taxonomy_arg : $entity->taxonomy_arg;
966
+ if (empty($data->taxonomy_arg)) {
967
  $data->taxonomy_arg = array();
968
  }
969
 
973
  //reset source types to intial state to take care of registration changing source type.
974
  $taxes = array_merge($exiting, $user_edited);
975
  foreach ($taxes as $name => $data) {
976
+ if (isset($this->taxonomies_cache[$name])) {
977
  $data->source_type = $this->taxonomies_cache[$name]->source_type;
978
  }
979
  }
980
+
981
  $this->taxonomies_cache = $taxes;
982
 
983
  foreach ($this->taxonomies_cache as $name => $data) {
1148
  }
1149
 
1150
  protected function is_valid_slug($slug) {
1151
+ if (empty($slug)) {
1152
  return false;
1153
  }
1154
+
1155
  return sanitize_key($slug) === $slug;
1156
  }
1157
 
1215
  }
1216
  }
1217
 
1218
+ public static function get_debug_setting() {
1219
+ return array('key' => 'taxonomies', 'label' => 'Taxonomies');
1220
+ }
1221
+
1222
  }
1223
 
1224
  WPFront_User_Role_Editor_Taxonomies::load();
includes/users/class-assign-migrate.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /*
3
  WPFront User Role Editor Plugin
4
  Copyright (C) 2014, WPFront.com
@@ -37,6 +38,7 @@ if (!defined('ABSPATH')) {
37
  use WPFront\URE\WPFront_User_Role_Editor as WPFURE;
38
  use WPFront\URE\WPFront_User_Role_Editor_Utils as Utils;
39
  use WPFront\URE\WPFront_User_Role_Editor_Roles_Helper as RolesHelper;
 
40
 
41
  require_once dirname(__FILE__) . '/template-assign-migrate.php';
42
 
@@ -49,6 +51,7 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
49
  * @copyright 2014 WPFront.com
50
  */
51
  class WPFront_User_Role_Editor_Assign_Migrate extends \WPFront\URE\WPFront_User_Role_Editor_View_Controller {
 
52
  const MENU_SLUG = 'wpfront-user-role-editor-assign-roles';
53
  const CAP = 'promote_users';
54
 
@@ -57,48 +60,72 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
57
  * @var \WP_User[]
58
  */
59
  private $users = null;
60
-
61
  /**
62
  *
63
  * @var string[]
64
  */
65
  private $primary_roles = null;
66
-
67
  /**
68
  *
69
  * @var string[] name => display
70
  */
71
  private $secondary_roles = null;
72
-
73
  /**
74
  *
75
  * @var string
76
  */
77
  private $error = null;
78
-
79
  protected function setUp() {
80
  $this->_setUp('promote_users', 'wpfront-user-role-editor-assign-roles');
81
  }
82
-
83
  /**
84
  * Hooks into wpfront_ure_init.
85
  */
86
  public function initialize() {
87
- if(!$this->in_admin_ui()) {
 
 
 
 
88
  return;
89
  }
90
 
 
 
 
 
 
 
91
  $this->set_admin_menu(__('Assign Roles | Migrate Users', 'wpfront-user-role-editor'), __('Assign / Migrate', 'wpfront-user-role-editor'));
92
-
93
  add_filter('user_row_actions', array($this, 'user_row_actions'), 10, 2);
94
  }
95
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  public function admin_menu() {
97
  $page_hook_suffix = add_users_page($this->menu_title, $this->menu_link, $this->get_cap(), $this->get_menu_slug(), array($this, 'view'));
98
-
99
  $this->add_menu_hooks($page_hook_suffix);
100
  }
101
-
102
  /**
103
  * Hooks into user_row_actions filter to add Assign Roles link.
104
  *
@@ -107,169 +134,169 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
107
  * @return string[]
108
  */
109
  public function user_row_actions($actions, $user) {
110
- if(current_user_can(self::CAP) && $user->ID !== wp_get_current_user()->ID && current_user_can('promote_user', $user->ID)) {
111
  $actions['assign_roles'] = sprintf('<a href="%s">%s</a>', $this->get_self_url($user->ID), __('Assign Roles', 'wpfront-user-role-editor'));
112
  }
113
-
114
  return $actions;
115
  }
116
-
117
  public function load_view() {
118
- if(!parent::load_view()) {
119
  return;
120
  }
121
-
122
- if(!empty($_POST['assign'])) {
123
  check_admin_referer('assign-roles');
124
-
125
- if(empty($_POST['assign-user'])) {
126
  $this->error = __('Invalid user.', 'wpfront-user-role-editor');
127
  return;
128
  }
129
-
130
- $user_id = $_POST['assign-user'];
131
  $user = get_userdata($user_id);
132
-
133
- if(empty($user)) {
134
  $this->error = __('Invalid user.', 'wpfront-user-role-editor');
135
  return;
136
  }
137
-
138
- if($user->ID === wp_get_current_user()->ID) {
139
  $this->error = __('Logged in user\'s role can not be changed.', 'wpfront-user-role-editor');
140
  return;
141
  }
142
-
143
  $primary_role = '';
144
- if(!empty($_POST['primary-role'])) {
145
  $primary_role = $_POST['primary-role'];
146
  }
147
-
148
  $primary_roles = $this->get_assign_roles_primary_roles();
149
- if(empty($primary_roles[$primary_role])) {
150
  $this->error = __('Invalid primary role specified.', 'wpfront-user-role-editor');
151
  return;
152
  }
153
-
154
  $secondary_roles = array();
155
- if(!empty($_POST['secondary-roles'])) {
156
  $secondary_roles = $_POST['secondary-roles'];
157
  }
158
-
159
  $allowed_secondary_roles = $this->get_assign_roles_secondary_roles();
160
  foreach ($secondary_roles as $name => $value) {
161
- if(empty($allowed_secondary_roles[$name])) {
162
  $this->error = __('Invalid secondary role specified.', 'wpfront-user-role-editor');
163
  return;
164
  }
165
  }
166
-
167
  $user->set_role($primary_role);
168
-
169
  foreach ($secondary_roles as $name => $value) {
170
  $user->add_role($name);
171
  }
172
-
173
  $url = $this->get_self_url($user_id) . '&roles-assigned=true';
174
  wp_safe_redirect($url);
175
  exit();
176
  }
177
-
178
- if(!empty($_POST['migrate'])) {
179
  check_admin_referer('migrate-users');
180
-
181
  $from_primary_role = '';
182
- if(!empty($_POST['migrate-from-primary-role'])) {
183
  $from_primary_role = $_POST['migrate-from-primary-role'];
184
  }
185
-
186
  $primary_roles = $this->get_migrate_from_primary_roles();
187
- if(empty($primary_roles[$from_primary_role])) {
188
  $this->error = __('Invalid primary role specified.', 'wpfront-user-role-editor');
189
  return;
190
  }
191
-
192
  $primary_role = '';
193
- if(!empty($_POST['primary-role'])) {
194
  $primary_role = $_POST['primary-role'];
195
  }
196
-
197
  $primary_roles = $this->get_migrate_to_primary_roles();
198
- if(empty($primary_roles[$primary_role])) {
199
  $this->error = __('Invalid primary role specified.', 'wpfront-user-role-editor');
200
  return;
201
  }
202
-
203
  $secondary_roles = array();
204
- if(!empty($_POST['secondary-roles'])) {
205
  $secondary_roles = $_POST['secondary-roles'];
206
  }
207
-
208
  $allowed_secondary_roles = $this->get_migrate_secondary_roles();
209
  foreach ($secondary_roles as $name => $value) {
210
- if(empty($allowed_secondary_roles[$name])) {
211
  $this->error = __('Invalid secondary role specified.', 'wpfront-user-role-editor');
212
  return;
213
  }
214
  }
215
-
216
  $users = $this->get_users();
217
  $count = 0;
218
  foreach ($users as $user) {
219
- if($user->ID === wp_get_current_user()->ID) {
220
  continue;
221
  }
222
-
223
  $roles = $user->roles;
224
  $user_primary = '';
225
- if(!empty($roles)) {
226
  $user_primary = reset($roles);
227
  }
228
-
229
- if($user_primary === $from_primary_role) {
230
  $user->set_role($primary_role);
231
  foreach ($secondary_roles as $name => $value) {
232
  $user->add_role($name);
233
  }
234
-
235
  $count++;
236
  }
237
  }
238
-
239
  $url = $this->get_self_url() . "&users-migrated=$count";
240
  wp_safe_redirect($url);
241
  exit();
242
  }
243
-
244
  $this->set_help_tab();
245
  }
246
-
247
  /**
248
  * Displays the login redirect view.
249
  */
250
  public function view() {
251
- if(!parent::view()) {
252
  return;
253
  }
254
-
255
  $objView = new WPFront_User_Role_Editor_Assign_Migrate_View();
256
  $objView->view();
257
  }
258
-
259
  /**
260
  * Returns array of user objects who can be assigned.
261
  *
262
  * @return \WP_User[]
263
  */
264
  public function get_users() {
265
- if($this->users === null) {
266
  $users = get_users(array('exclude' => array(wp_get_current_user()->ID)));
267
  $this->users = array_values(array_filter($users, array($this, 'filter_promote_user')));
268
  }
269
-
270
  return $this->users;
271
  }
272
-
273
  /**
274
  * Array filter function to find users who can be assigned.
275
  *
@@ -279,21 +306,21 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
279
  public function filter_promote_user($user) {
280
  return current_user_can('promote_user', $user->ID);
281
  }
282
-
283
  /**
284
  * Returns assignable primary roles.
285
  *
286
  * @return string[] name=>display
287
  */
288
  protected function get_primary_roles() {
289
- if($this->primary_roles === null) {
290
  $roles = RolesHelper::get_names();
291
  $this->primary_roles = $roles;
292
  }
293
-
294
  return $this->primary_roles;
295
  }
296
-
297
  /**
298
  * Returns primary roles after applying filter.
299
  *
@@ -306,7 +333,7 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
306
  $roles[''] = '&mdash;' . __('No role for this site', 'wpfront-user-role-editor') . '&mdash;';
307
  return $roles;
308
  }
309
-
310
  /**
311
  * Returns primary roles list for assign roles.
312
  *
@@ -315,7 +342,7 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
315
  public function get_assign_roles_primary_roles() {
316
  return $this->get_primary_roles_filtered('wpfront_ure_assign_user_roles_primary_roles');
317
  }
318
-
319
  /**
320
  * Returns from primary roles list for migrate users.
321
  *
@@ -324,7 +351,7 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
324
  public function get_migrate_from_primary_roles() {
325
  return $this->get_primary_roles_filtered('wpfront_ure_migrate_users_from_primary_roles');
326
  }
327
-
328
  /**
329
  * Returns to primary roles list for migrate users.
330
  *
@@ -333,22 +360,22 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
333
  public function get_migrate_to_primary_roles() {
334
  return $this->get_primary_roles_filtered('wpfront_ure_migrate_users_to_primary_roles');
335
  }
336
-
337
  /**
338
  * Returns assignable secondary roles.
339
  *
340
  * @return string[] name=>display
341
  */
342
  public function get_secondary_roles() {
343
- if($this->secondary_roles === null) {
344
  $roles = $this->get_primary_roles();
345
  unset($roles[RolesHelper::ADMINISTRATOR_ROLE_KEY]);
346
  $this->secondary_roles = $roles;
347
  }
348
-
349
  return $this->secondary_roles;
350
  }
351
-
352
  /**
353
  * Returns secondary roles list for assign roles.
354
  *
@@ -356,12 +383,12 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
356
  */
357
  public function get_assign_roles_secondary_roles() {
358
  $roles = $this->get_secondary_roles();
359
-
360
  $roles = apply_filters('wpfront_ure_assign_user_roles_secondary_roles', $roles);
361
-
362
  return $roles;
363
  }
364
-
365
  /**
366
  * Returns secondary roles list for assign roles.
367
  *
@@ -369,12 +396,12 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
369
  */
370
  public function get_migrate_secondary_roles() {
371
  $roles = $this->get_secondary_roles();
372
-
373
  $roles = apply_filters('wpfront_ure_migrate_users_to_secondary_roles', $roles);
374
-
375
  return $roles;
376
  }
377
-
378
  /**
379
  * Returns the current error.
380
  *
@@ -383,7 +410,7 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
383
  public function get_error_string() {
384
  return $this->error;
385
  }
386
-
387
  /**
388
  * Returns self url.
389
  *
@@ -392,14 +419,14 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
392
  */
393
  public function get_self_url($user_id = null) {
394
  $append = array();
395
-
396
- if(!empty($user_id)) {
397
  $append['user'] = $user_id;
398
  }
399
-
400
  return parent::get_self_url($append);
401
  }
402
-
403
  /**
404
  * Sets the help tab
405
  *
@@ -439,12 +466,41 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_M
439
  'assign-migrate-users/'
440
  )
441
  );
442
-
443
  Utils::set_help_tab($tabs, $sidebar);
444
  }
445
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  }
447
-
448
  add_action('wpfront_ure_init', '\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_Migrate::init');
449
-
450
  }
1
  <?php
2
+
3
  /*
4
  WPFront User Role Editor Plugin
5
  Copyright (C) 2014, WPFront.com
38
  use WPFront\URE\WPFront_User_Role_Editor as WPFURE;
39
  use WPFront\URE\WPFront_User_Role_Editor_Utils as Utils;
40
  use WPFront\URE\WPFront_User_Role_Editor_Roles_Helper as RolesHelper;
41
+ use \WPFront\URE\WPFront_User_Role_Editor_Debug;
42
 
43
  require_once dirname(__FILE__) . '/template-assign-migrate.php';
44
 
51
  * @copyright 2014 WPFront.com
52
  */
53
  class WPFront_User_Role_Editor_Assign_Migrate extends \WPFront\URE\WPFront_User_Role_Editor_View_Controller {
54
+
55
  const MENU_SLUG = 'wpfront-user-role-editor-assign-roles';
56
  const CAP = 'promote_users';
57
 
60
  * @var \WP_User[]
61
  */
62
  private $users = null;
63
+
64
  /**
65
  *
66
  * @var string[]
67
  */
68
  private $primary_roles = null;
69
+
70
  /**
71
  *
72
  * @var string[] name => display
73
  */
74
  private $secondary_roles = null;
75
+
76
  /**
77
  *
78
  * @var string
79
  */
80
  private $error = null;
81
+
82
  protected function setUp() {
83
  $this->_setUp('promote_users', 'wpfront-user-role-editor-assign-roles');
84
  }
85
+
86
  /**
87
  * Hooks into wpfront_ure_init.
88
  */
89
  public function initialize() {
90
+
91
+ $debug = WPFront_User_Role_Editor_Debug::instance();
92
+ $debug->add_setting('assign-migrate', 'Assign / Migrate');
93
+
94
+ if ($debug->is_disabled('assign-migrate')) {
95
  return;
96
  }
97
 
98
+ add_action('admin_init', array($this, 'admin_init'));
99
+
100
+ if (!$this->in_admin_ui()) {
101
+ return;
102
+ }
103
+
104
  $this->set_admin_menu(__('Assign Roles | Migrate Users', 'wpfront-user-role-editor'), __('Assign / Migrate', 'wpfront-user-role-editor'));
105
+
106
  add_filter('user_row_actions', array($this, 'user_row_actions'), 10, 2);
107
  }
108
+
109
+ /**
110
+ * Adds ajax functions on admin_init
111
+ */
112
+ public function admin_init() {
113
+ add_action('wp_ajax_wpfront_user_role_editor_assign_roles_user_autocomplete', array($this, 'assign_roles_user_autocomplete_callback'), 10, 0);
114
+ }
115
+
116
+ public function admin_print_scripts() {
117
+ parent::admin_print_scripts();
118
+
119
+ wp_enqueue_script('jquery-ui-core');
120
+ wp_enqueue_script('jquery-ui-autocomplete');
121
+ }
122
+
123
  public function admin_menu() {
124
  $page_hook_suffix = add_users_page($this->menu_title, $this->menu_link, $this->get_cap(), $this->get_menu_slug(), array($this, 'view'));
125
+
126
  $this->add_menu_hooks($page_hook_suffix);
127
  }
128
+
129
  /**
130
  * Hooks into user_row_actions filter to add Assign Roles link.
131
  *
134
  * @return string[]
135
  */
136
  public function user_row_actions($actions, $user) {
137
+ if (current_user_can(self::CAP) && $user->ID !== wp_get_current_user()->ID && current_user_can('promote_user', $user->ID)) {
138
  $actions['assign_roles'] = sprintf('<a href="%s">%s</a>', $this->get_self_url($user->ID), __('Assign Roles', 'wpfront-user-role-editor'));
139
  }
140
+
141
  return $actions;
142
  }
143
+
144
  public function load_view() {
145
+ if (!parent::load_view()) {
146
  return;
147
  }
148
+
149
+ if (!empty($_POST['assign'])) {
150
  check_admin_referer('assign-roles');
151
+
152
+ if (empty($_POST['assign-user'])) {
153
  $this->error = __('Invalid user.', 'wpfront-user-role-editor');
154
  return;
155
  }
156
+
157
+ $user_id = $_POST['assign-user-id'];
158
  $user = get_userdata($user_id);
159
+
160
+ if (empty($user)) {
161
  $this->error = __('Invalid user.', 'wpfront-user-role-editor');
162
  return;
163
  }
164
+
165
+ if ($user->ID === wp_get_current_user()->ID) {
166
  $this->error = __('Logged in user\'s role can not be changed.', 'wpfront-user-role-editor');
167
  return;
168
  }
169
+
170
  $primary_role = '';
171
+ if (!empty($_POST['primary-role'])) {
172
  $primary_role = $_POST['primary-role'];
173
  }
174
+
175
  $primary_roles = $this->get_assign_roles_primary_roles();
176
+ if (empty($primary_roles[$primary_role])) {
177
  $this->error = __('Invalid primary role specified.', 'wpfront-user-role-editor');
178
  return;
179
  }
180
+
181
  $secondary_roles = array();
182
+ if (!empty($_POST['secondary-roles'])) {
183
  $secondary_roles = $_POST['secondary-roles'];
184
  }
185
+
186
  $allowed_secondary_roles = $this->get_assign_roles_secondary_roles();
187
  foreach ($secondary_roles as $name => $value) {
188
+ if (empty($allowed_secondary_roles[$name])) {
189
  $this->error = __('Invalid secondary role specified.', 'wpfront-user-role-editor');
190
  return;
191
  }
192
  }
193
+
194
  $user->set_role($primary_role);
195
+
196
  foreach ($secondary_roles as $name => $value) {
197
  $user->add_role($name);
198
  }
199
+
200
  $url = $this->get_self_url($user_id) . '&roles-assigned=true';
201
  wp_safe_redirect($url);
202
  exit();
203
  }
204
+
205
+ if (!empty($_POST['migrate'])) {
206
  check_admin_referer('migrate-users');
207
+
208
  $from_primary_role = '';
209
+ if (!empty($_POST['migrate-from-primary-role'])) {
210
  $from_primary_role = $_POST['migrate-from-primary-role'];
211
  }
212
+
213
  $primary_roles = $this->get_migrate_from_primary_roles();
214
+ if (empty($primary_roles[$from_primary_role])) {
215
  $this->error = __('Invalid primary role specified.', 'wpfront-user-role-editor');
216
  return;
217
  }
218
+
219
  $primary_role = '';
220
+ if (!empty($_POST['primary-role'])) {
221
  $primary_role = $_POST['primary-role'];
222
  }
223
+
224
  $primary_roles = $this->get_migrate_to_primary_roles();
225
+ if (empty($primary_roles[$primary_role])) {
226
  $this->error = __('Invalid primary role specified.', 'wpfront-user-role-editor');
227
  return;
228
  }
229
+
230
  $secondary_roles = array();
231
+ if (!empty($_POST['secondary-roles'])) {
232
  $secondary_roles = $_POST['secondary-roles'];
233
  }
234
+
235
  $allowed_secondary_roles = $this->get_migrate_secondary_roles();
236
  foreach ($secondary_roles as $name => $value) {
237
+ if (empty($allowed_secondary_roles[$name])) {
238
  $this->error = __('Invalid secondary role specified.', 'wpfront-user-role-editor');
239
  return;
240
  }
241
  }
242
+
243
  $users = $this->get_users();
244
  $count = 0;
245
  foreach ($users as $user) {
246
+ if ($user->ID === wp_get_current_user()->ID) {
247
  continue;
248
  }
249
+
250
  $roles = $user->roles;
251
  $user_primary = '';
252
+ if (!empty($roles)) {
253
  $user_primary = reset($roles);
254
  }
255
+
256
+ if ($user_primary === $from_primary_role) {
257
  $user->set_role($primary_role);
258
  foreach ($secondary_roles as $name => $value) {
259
  $user->add_role($name);
260
  }
261
+
262
  $count++;
263
  }
264
  }
265
+
266
  $url = $this->get_self_url() . "&users-migrated=$count";
267
  wp_safe_redirect($url);
268
  exit();
269
  }
270
+
271
  $this->set_help_tab();
272
  }
273
+
274
  /**
275
  * Displays the login redirect view.
276
  */
277
  public function view() {
278
+ if (!parent::view()) {
279
  return;
280
  }
281
+
282
  $objView = new WPFront_User_Role_Editor_Assign_Migrate_View();
283
  $objView->view();
284
  }
285
+
286
  /**
287
  * Returns array of user objects who can be assigned.
288
  *
289
  * @return \WP_User[]
290
  */
291
  public function get_users() {
292
+ if ($this->users === null) {
293
  $users = get_users(array('exclude' => array(wp_get_current_user()->ID)));
294
  $this->users = array_values(array_filter($users, array($this, 'filter_promote_user')));
295
  }
296
+
297
  return $this->users;
298
  }
299
+
300
  /**
301
  * Array filter function to find users who can be assigned.
302
  *
306
  public function filter_promote_user($user) {
307
  return current_user_can('promote_user', $user->ID);
308
  }
309
+
310
  /**
311
  * Returns assignable primary roles.
312
  *
313
  * @return string[] name=>display
314
  */
315
  protected function get_primary_roles() {
316
+ if ($this->primary_roles === null) {
317
  $roles = RolesHelper::get_names();
318
  $this->primary_roles = $roles;
319
  }
320
+
321
  return $this->primary_roles;
322
  }
323
+
324
  /**
325
  * Returns primary roles after applying filter.
326
  *
333
  $roles[''] = '&mdash;' . __('No role for this site', 'wpfront-user-role-editor') . '&mdash;';
334
  return $roles;
335
  }
336
+
337
  /**
338
  * Returns primary roles list for assign roles.
339
  *
342
  public function get_assign_roles_primary_roles() {
343
  return $this->get_primary_roles_filtered('wpfront_ure_assign_user_roles_primary_roles');
344
  }
345
+
346
  /**
347
  * Returns from primary roles list for migrate users.
348
  *
351
  public function get_migrate_from_primary_roles() {
352
  return $this->get_primary_roles_filtered('wpfront_ure_migrate_users_from_primary_roles');
353
  }
354
+
355
  /**
356
  * Returns to primary roles list for migrate users.
357
  *
360
  public function get_migrate_to_primary_roles() {
361
  return $this->get_primary_roles_filtered('wpfront_ure_migrate_users_to_primary_roles');
362
  }
363
+
364
  /**
365
  * Returns assignable secondary roles.
366
  *
367
  * @return string[] name=>display
368
  */
369
  public function get_secondary_roles() {
370
+ if ($this->secondary_roles === null) {
371
  $roles = $this->get_primary_roles();
372
  unset($roles[RolesHelper::ADMINISTRATOR_ROLE_KEY]);
373
  $this->secondary_roles = $roles;
374
  }
375
+
376
  return $this->secondary_roles;
377
  }
378
+
379
  /**
380
  * Returns secondary roles list for assign roles.
381
  *
383
  */
384
  public function get_assign_roles_secondary_roles() {
385
  $roles = $this->get_secondary_roles();
386
+
387
  $roles = apply_filters('wpfront_ure_assign_user_roles_secondary_roles', $roles);
388
+
389
  return $roles;
390
  }
391
+
392
  /**
393
  * Returns secondary roles list for assign roles.
394
  *
396
  */
397
  public function get_migrate_secondary_roles() {
398
  $roles = $this->get_secondary_roles();
399
+
400
  $roles = apply_filters('wpfront_ure_migrate_users_to_secondary_roles', $roles);
401
+
402
  return $roles;
403
  }
404
+
405
  /**
406
  * Returns the current error.
407
  *
410
  public function get_error_string() {
411
  return $this->error;
412
  }
413
+
414
  /**
415
  * Returns self url.
416
  *
419
  */
420
  public function get_self_url($user_id = null) {
421
  $append = array();
422
+
423
+ if (!empty($user_id)) {
424
  $append['user'] = $user_id;
425
  }
426
+
427
  return parent::get_self_url($append);
428
  }
429
+
430
  /**
431
  * Sets the help tab
432
  *
466
  'assign-migrate-users/'
467
  )
468
  );
469
+
470
  Utils::set_help_tab($tabs, $sidebar);
471
  }
472
+
473
+ public function assign_roles_user_autocomplete_callback() {
474
+ $search_string = $_GET['term'];
475
+
476
+ $args = array(
477
+ 'search' => '*' . $search_string . '*',
478
+ 'search_columns' => array(
479
+ 'user_login',
480
+ 'user_nicename',
481
+ 'user_email',
482
+ 'display_name',
483
+ ),
484
+ 'orderby' => 'display_name',
485
+ 'number' => 10,
486
+ 'fields' => array('ID', 'display_name', 'user_email'),
487
+ 'exclude' => array(wp_get_current_user()->ID)
488
+ );
489
+ $users_found = get_users($args);
490
+
491
+ $user_details = array();
492
+ foreach ($users_found as $user) {
493
+ $user_details[] = array(
494
+ "label" => $user->display_name . '<' . $user->user_email . '>',
495
+ "value" => $user->ID
496
+ );
497
+ }
498
+
499
+ echo json_encode($user_details);
500
+ exit;
501
+ }
502
+
503
  }
504
+
505
  add_action('wpfront_ure_init', '\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_Migrate::init');
 
506
  }
includes/users/class-user-permissions.php CHANGED
@@ -118,6 +118,9 @@ if (!class_exists('\WPFront\URE\User_Permissions\WPFront_User_Role_Editor_User_P
118
  return RolesHelper::get_wpfront_help_link($cap);
119
  }
120
 
 
 
 
121
  }
122
 
123
  WPFront_User_Role_Editor_User_Permissions::load();
118
  return RolesHelper::get_wpfront_help_link($cap);
119
  }
120
 
121
+ public static function get_debug_setting() {
122
+ return array('key' => 'user-permissions', 'label' => 'User Permissions');
123
+ }
124
  }
125
 
126
  WPFront_User_Role_Editor_User_Permissions::load();
includes/users/class-user-profile.php CHANGED
@@ -447,6 +447,9 @@ if (!class_exists('\WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_User_Pro
447
  return $sec_roles;
448
  }
449
 
 
 
 
450
  }
451
 
452
  WPFront_User_Role_Editor_User_Profile::load();
447
  return $sec_roles;
448
  }
449
 
450
+ public static function get_debug_setting() {
451
+ return array('key' => 'user-profile', 'label' => 'User Profile Functions');
452
+ }
453
  }
454
 
455
  WPFront_User_Role_Editor_User_Profile::load();
includes/users/template-assign.php CHANGED
@@ -38,12 +38,12 @@ use WPFront\URE\WPFront_User_Role_Editor as URE;
38
  use WPFront\URE\WPFront_User_Role_Editor_Utils as Utils;
39
  use WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_Migrate as AssignMigrate;
40
 
41
- if(!class_exists('WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_View')) {
42
-
43
  class WPFront_User_Role_Editor_Assign_View extends WPFront_User_Role_Editor_Assign_Migrate_View {
44
-
45
  private $current_user_id = null;
46
-
47
  public function view() {
48
  ?>
49
  <div class="wrap assign-roles">
@@ -64,7 +64,7 @@ if(!class_exists('WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_Vie
64
  </div>
65
  <?php
66
  }
67
-
68
  protected function title() {
69
  ?>
70
  <h2>
@@ -72,16 +72,16 @@ if(!class_exists('WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_Vie
72
  </h2>
73
  <?php
74
  }
75
-
76
  protected function display_notices() {
77
  $error = AssignMigrate::instance()->get_error_string();
78
- if(!empty($error) && !empty($_POST['assign'])) {
79
  Utils::notice_error($error);
80
- } elseif(!empty($_GET['roles-assigned'])) {
81
  Utils::notice_updated(__('Roles updated successfully.', 'wpfront-user-role-editor'));
82
  }
83
  }
84
-
85
  protected function form_table() {
86
  ?>
87
  <table class="form-table">
@@ -93,7 +93,7 @@ if(!class_exists('WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_Vie
93
  </table>
94
  <?php
95
  }
96
-
97
  protected function user_list_row() {
98
  ?>
99
  <tr>
@@ -101,106 +101,137 @@ if(!class_exists('WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_Vie
101
  <?php echo __('User', 'wpfront-user-role-editor'); ?>
102
  </th>
103
  <td>
104
- <?php $this->user_list_dropdown(); ?>
105
  </td>
106
  </tr>
107
  <?php
108
  }
109
-
110
- protected function user_list_dropdown() {
 
 
 
 
 
 
 
 
111
  ?>
112
- <select id="assign-users-list" name="assign-user">
113
- <?php
114
- $users = AssignMigrate::instance()->get_users();
115
- $user_id = $this->get_current_user_id();
116
- foreach ($users as $user) {
117
- $selected = $user->ID == $user_id ? 'selected' : '';
118
- echo "<option $selected value='$user->ID'>$user->display_name [$user->user_login]</option>";
119
- }
120
- ?>
121
- </select>
122
  <?php
123
  }
124
-
125
  protected function assign_button() {
126
  submit_button(__('Assign Roles'), 'primary', 'assign');
127
  }
128
-
129
  protected function get_current_user_id() {
130
- if($this->current_user_id === null) {
131
- if(!empty($_POST['assign-user'])) {
132
  $this->current_user_id = $_POST['assign-user'];
133
  return $this->current_user_id;
134
  }
135
 
136
- if(!empty($_GET['user'])) {
137
  $this->current_user_id = $_GET['user'];
138
  return $this->current_user_id;
139
  }
140
 
141
  $users = AssignMigrate::instance()->get_users();
142
- if(!empty($users)) {
143
  $this->current_user_id = $users[0]->ID;
144
  return $this->current_user_id;
145
  }
146
  }
147
-
148
  return $this->current_user_id;
149
  }
150
-
151
  protected function get_current_primary_role() {
152
- if(!empty($_POST['primary-role'])) {
153
  return $_POST['primary-role'];
154
  }
155
-
156
  $user_id = $this->get_current_user_id();
157
  $user = get_userdata($user_id);
158
-
159
- if(!empty($user) && !empty($user->roles)) {
160
  $roles = $user->roles;
161
  return reset($roles);
162
  }
163
-
164
  return '';
165
  }
166
-
167
  protected function get_current_secondary_roles() {
168
- if(!empty($_POST['assign'])) {
169
- if(empty($_POST['secondary-roles'])) {
170
  return array();
171
  }
172
-
173
  return array_keys($_POST['secondary-roles']);
174
  }
175
-
176
  $user_id = $this->get_current_user_id();
177
  $user = get_userdata($user_id);
178
-
179
- if(!empty($user) && !empty($user->roles)) {
180
  $roles = array_values($user->roles);
181
  array_shift($roles);
182
  return $roles;
183
  }
184
-
185
  return array();
186
  }
187
-
188
  protected function scripts() {
189
  ?>
190
  <script type="text/javascript">
191
- (function($) {
192
- var page_url = <?php echo json_encode(AssignMigrate::instance()->get_self_url() . '&user=') ?>;
193
-
194
- $('#assign-users-list').change(function() {
195
- window.location.replace(page_url + $(this).val());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  });
 
197
  })(jQuery);
198
  </script>
 
199
  <?php
200
  parent::scripts();
201
  }
202
-
203
  }
204
-
205
  }
206
 
38
  use WPFront\URE\WPFront_User_Role_Editor_Utils as Utils;
39
  use WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_Migrate as AssignMigrate;
40
 
41
+ if (!class_exists('WPFront\URE\Assign_Migrate\WPFront_User_Role_Editor_Assign_View')) {
42
+
43
  class WPFront_User_Role_Editor_Assign_View extends WPFront_User_Role_Editor_Assign_Migrate_View {
44
+
45
  private $current_user_id = null;
46
+
47
  public function view() {
48
  ?>
49
  <div class="wrap assign-roles">
64
  </div>
65
  <?php
66
  }
67
+
68
  protected function title() {
69
  ?>
70
  <h2>
72
  </h2>
73
  <?php
74
  }
75
+
76
  protected function display_notices() {
77
  $error = AssignMigrate::instance()->get_error_string();
78
+ if (!empty($error) && !empty($_POST['assign'])) {
79
  Utils::notice_error($error);
80
+ } elseif (!empty($_GET['roles-assigned'])) {
81
  Utils::notice_updated(__('Roles updated successfully.', 'wpfront-user-role-editor'));
82
  }
83
  }
84
+
85
  protected function form_table() {
86
  ?>
87
  <table class="form-table">
93
  </table>
94
  <?php
95
  }
96
+
97
  protected function user_list_row() {
98
  ?>
99
  <tr>
101
  <?php echo __('User', 'wpfront-user-role-editor'); ?>
102
  </th>
103
  <td>
104
+ <?php $this->user_list_autocomplete(); ?>
105
  </td>
106
  </tr>
107
  <?php
108
  }
109
+
110
+ protected function user_list_autocomplete() {
111
+ if (!empty($_GET['user'])) {
112
+ $user_id = $_GET['user'];
113
+ $user = get_userdata($user_id);
114
+ $value = $user->display_name . '<' . $user->user_email . '>';
115
+ } else {
116
+ $value = '';
117
+ $user_id = '';
118
+ }
119
  ?>
120
+
121
+ <input type="text" id="assign-users-list" name="assign-user" placeholder="<?php echo __('Search User...', 'wpfront-user-role-editor'); ?>" value="<?php echo $value; ?>">
122
+ <input type="hidden" id="assign-users-list-hidden" name="assign-user-id" value="<?php echo $user_id; ?>">
123
+
 
 
 
 
 
 
124
  <?php
125
  }
126
+
127
  protected function assign_button() {
128
  submit_button(__('Assign Roles'), 'primary', 'assign');
129
  }
130
+
131
  protected function get_current_user_id() {
132
+ if ($this->current_user_id === null) {
133
+ if (!empty($_POST['assign-user'])) {
134
  $this->current_user_id = $_POST['assign-user'];
135
  return $this->current_user_id;
136
  }
137
 
138
+ if (!empty($_GET['user'])) {
139
  $this->current_user_id = $_GET['user'];
140
  return $this->current_user_id;
141
  }
142
 
143
  $users = AssignMigrate::instance()->get_users();
144
+ if (!empty($users)) {
145
  $this->current_user_id = $users[0]->ID;
146
  return $this->current_user_id;
147
  }
148
  }
149
+
150
  return $this->current_user_id;
151
  }
152
+
153
  protected function get_current_primary_role() {
154
+ if (!empty($_POST['primary-role'])) {
155
  return $_POST['primary-role'];
156
  }
157
+
158
  $user_id = $this->get_current_user_id();
159
  $user = get_userdata($user_id);
160
+
161
+ if (!empty($user) && !empty($user->roles)) {
162
  $roles = $user->roles;
163
  return reset($roles);
164
  }
165
+
166
  return '';
167
  }
168
+
169
  protected function get_current_secondary_roles() {
170
+ if (!empty($_POST['assign'])) {
171
+ if (empty($_POST['secondary-roles'])) {
172
  return array();
173
  }
174
+
175
  return array_keys($_POST['secondary-roles']);
176
  }
177
+
178
  $user_id = $this->get_current_user_id();
179
  $user = get_userdata($user_id);
180
+
181
+ if (!empty($user) && !empty($user->roles)) {
182
  $roles = array_values($user->roles);
183
  array_shift($roles);
184
  return $roles;
185
  }
186
+
187
  return array();
188
  }
189
+
190
  protected function scripts() {
191
  ?>
192
  <script type="text/javascript">
193
+ (function ($) {
194
+
195
+ $(function () {
196
+ $("#assign-users-list").autocomplete({
197
+ source: function (request, response) {
198
+ $.ajax({
199
+ url: ajaxurl,
200
+ dataType: "json",
201
+ data: {
202
+ action: "wpfront_user_role_editor_assign_roles_user_autocomplete",
203
+ term: request.term
204
+ },
205
+ success: function (data) {
206
+ response(data);
207
+ },
208
+ error: function (response) {
209
+ console.log(response.responseText);
210
+ },
211
+ });
212
+ },
213
+ select: function (event, ui) {
214
+ var page_url = <?php echo json_encode(AssignMigrate::instance()->get_self_url() . '&user=') ?>;
215
+ window.location.replace(page_url + ui.item.value);
216
+ return false;
217
+ },
218
+ change: function (event, ui) {
219
+ if (!ui.item) {
220
+ $(this).val('');
221
+ }
222
+ },
223
+ minLength: 3,
224
+ });
225
  });
226
+
227
  })(jQuery);
228
  </script>
229
+
230
  <?php
231
  parent::scripts();
232
  }
233
+
234
  }
235
+
236
  }
237
 
includes/widget/class-widget-permissions.php CHANGED
@@ -366,6 +366,10 @@ if (!class_exists('\WPFront\URE\Widget\WPFront_User_Role_Editor_Widget_Permissio
366
  }
367
  }
368
 
 
 
 
 
369
  }
370
 
371
  \WPFront\URE\WPFront_User_Role_Editor_Uninstall::register_callback('\WPFront\URE\Widget\WPFront_User_Role_Editor_Widget_Permissions::uninstall');
366
  }
367
  }
368
 
369
+ public static function get_debug_setting() {
370
+ return array('key' => 'widget-permissions', 'label' => 'Widget Permissions');
371
+ }
372
+
373
  }
374
 
375
  \WPFront\URE\WPFront_User_Role_Editor_Uninstall::register_callback('\WPFront\URE\Widget\WPFront_User_Role_Editor_Widget_Permissions::uninstall');
license.txt ADDED
@@ -0,0 +1,621 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: syammohanm
3
  Donate link: https://wpfront.com/donate/
4
  Tags: WordPress user role editor, user role editor, role editor, user role, role, WordPress user roles, user roles, roles, user roles editor, roles editor, role manager, roles manager, manage roles, manage role, capability, permission, role, security, user, capability editor, capability manager, custom post types, custom post type permissions, custom post type capabilities, post type permissions, post type capabilities, menu editor, role menu, role menu editor, multisite roles, multisite role editor, multisite user roles, import roles, export roles
5
  Requires at least: 5.0
6
- Tested up to: 5.8
7
  Requires PHP: 7.0
8
- Stable tag: 3.0.0
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -64,7 +64,7 @@ Please visit [WPFront User Role Editor FAQ](https://wpfront.com/user-role-editor
64
 
65
  = WPFront User Role Editor and GDPR compliance? =
66
 
67
- This plugin doesnt collect any personal information. For more information please visit [GDPR compliance](https://wpfront.com/wpfront-and-gdpr-compliance/).
68
 
69
  == Screenshots ==
70
 
@@ -90,6 +90,12 @@ This plugin doesn
90
 
91
  == Changelog ==
92
 
 
 
 
 
 
 
93
  = 3.0.0 =
94
  * Major update. Please test before upgrading.
95
  * Advanced extended permissions.
@@ -262,6 +268,9 @@ This plugin doesn
262
 
263
  == Upgrade Notice ==
264
 
 
 
 
265
  = 3.0.0 =
266
  * Major update.
267
 
3
  Donate link: https://wpfront.com/donate/
4
  Tags: WordPress user role editor, user role editor, role editor, user role, role, WordPress user roles, user roles, roles, user roles editor, roles editor, role manager, roles manager, manage roles, manage role, capability, permission, role, security, user, capability editor, capability manager, custom post types, custom post type permissions, custom post type capabilities, post type permissions, post type capabilities, menu editor, role menu, role menu editor, multisite roles, multisite role editor, multisite user roles, import roles, export roles
5
  Requires at least: 5.0
6
+ Tested up to: 5.8.1
7
  Requires PHP: 7.0
8
+ Stable tag: 3.1.0
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
64
 
65
  = WPFront User Role Editor and GDPR compliance? =
66
 
67
+ This plugin doesn't collect any personal information. For more information please visit [GDPR compliance](https://wpfront.com/wpfront-and-gdpr-compliance/).
68
 
69
  == Screenshots ==
70
 
90
 
91
  == Changelog ==
92
 
93
+ = 3.1.0 =
94
+ * Debug functionality added.
95
+ * Assign/Migrate UI change.
96
+ * Compatibility fixes.
97
+ * Bug fixes.
98
+
99
  = 3.0.0 =
100
  * Major update. Please test before upgrading.
101
  * Advanced extended permissions.
268
 
269
  == Upgrade Notice ==
270
 
271
+ = 3.1.0 =
272
+ * Compatibility and bug fixes.
273
+
274
  = 3.0.0 =
275
  * Major update.
276
 
wpfront-user-role-editor.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: WPFront User Role Editor
5
  * Plugin URI: http://wpfront.com/user-role-editor-pro/
6
  * Description: Allows you to manage your site's security using user role permissions.
7
- * Version: 3.0.0.10061
8
  * Requires at least: 5.0
9
  * Requires PHP: 7.0
10
  * Author: Syam Mohan
@@ -43,12 +43,12 @@ if (!defined('ABSPATH')) {
43
  }
44
 
45
  if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
46
-
47
  class WPFront_User_Role_Editor {
48
-
49
- const VERSION = '3.0.0.10061';
50
  const PLUGIN_SLUG = 'wpfront-user-role-editor';
51
-
52
  protected static $instance = null;
53
 
54
  protected $plugin_url = null;
@@ -73,13 +73,13 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
73
  * @return WPFront_User_Role_Editor
74
  */
75
  public static function instance() {
76
- if(self::$instance === null) {
77
  self::$instance = new WPFront_User_Role_Editor();
78
  }
79
-
80
  return self::$instance;
81
  }
82
-
83
  /**
84
  * Hooks into plugins_loaded.
85
  * Loads controller files and fires wpfront_ure_init.
@@ -89,11 +89,11 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
89
  self::instance()->includes();
90
  add_action('admin_enqueue_scripts', array(self::instance(), 'admin_enqueue_styles'));
91
  }
92
-
93
  public function plugins_loaded() {
94
  load_plugin_textdomain('wpfront-user-role-editor', false, basename($this->plugin_dir) . '/languages/');
95
  }
96
-
97
  /**
98
  * Loads controller files.
99
  */
@@ -105,6 +105,7 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
105
  require_once $this->includes_dir . 'class-entity.php';
106
  require_once $this->includes_dir . 'class-controller.php';
107
  require_once $this->includes_dir . 'settings/class-options.php';
 
108
  require_once $this->includes_dir . 'users/class-assign-migrate.php';
109
  require_once $this->includes_dir . 'users/class-user-profile.php';
110
  require_once $this->includes_dir . 'roles/class-roles-list.php';
@@ -117,22 +118,22 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
117
  require_once $this->includes_dir . 'widget/class-widget-permissions.php';
118
  require_once $this->includes_dir . 'users/class-user-permissions.php';
119
  require_once $this->includes_dir . 'media/class-media-permissions.php';
120
- require_once $this->includes_dir . 'shortcodes/class-shortcodes.php';
121
  require_once $this->includes_dir . 'post-type/class-post-type.php';
122
  require_once $this->includes_dir . 'taxonomies/class-taxonomies.php';
123
  require_once $this->includes_dir . 'go-pro/class-go-pro.php';
124
-
125
  require_once $this->includes_dir . 'integration/plugins/class-wpfront-user-role-editor-plugin-integration.php';
126
-
127
- if(file_exists($this->includes_dir . 'ppro/includes.php')) {
128
  require_once $this->includes_dir . 'ppro/includes.php';
129
  }
130
-
131
- if(file_exists($this->includes_dir . 'bpro/includes.php')) {
132
  require_once $this->includes_dir . 'bpro/includes.php';
133
  }
134
  }
135
-
136
  /**
137
  * Returns parent menu slug for sub menu items.
138
  * Also adds the parent menu on the very first call.
@@ -142,19 +143,19 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
142
  * @return string
143
  */
144
  public function get_parent_menu_slug($submenu_slug, $submenu_capability) {
145
- if($this->parent_menu_slug == null) {
146
  $this->parent_menu_slug = $submenu_slug;
147
- if(is_network_admin()) {
148
  $position = 9;
149
  } else {
150
  $position = 69;
151
  }
152
  add_menu_page(__('Roles', 'wpfront-user-role-editor'), __('Roles', 'wpfront-user-role-editor'), $submenu_capability, $submenu_slug, null, 'dashicons-groups', $position);
153
  }
154
-
155
  return $this->parent_menu_slug;
156
  }
157
-
158
  /**
159
  * Returns the includes directory path.
160
  *
@@ -163,7 +164,7 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
163
  public function get_includes_dir() {
164
  return $this->includes_dir;
165
  }
166
-
167
  /**
168
  * Returns the plugin directory path.
169
  *
@@ -172,7 +173,7 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
172
  public function get_plugin_dir() {
173
  return $this->plugin_dir;
174
  }
175
-
176
  /**
177
  * Returns the url of the asset passed.
178
  * Passed path should be relative to assets directory.
@@ -183,7 +184,7 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
183
  public function get_asset_url($relativePath) {
184
  return $this->plugin_url . 'assets/' . $relativePath;
185
  }
186
-
187
  /**
188
  * Returns the plugin base name.
189
  *
@@ -192,7 +193,7 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
192
  public function get_plugin_basename() {
193
  return $this->plugin_basename;
194
  }
195
-
196
  /**
197
  * Returns the plugin file.
198
  *
@@ -212,17 +213,16 @@ if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
212
  array('response' => 403, 'back_link' => true)
213
  );
214
  }
215
-
216
  /**
217
  * Hooks into admin_enqueue_scripts and enqueues wp-admin styles.
218
  */
219
  public function admin_enqueue_styles() {
220
  wp_enqueue_style('wpfront-user-role-editor-admin-css', $this->get_asset_url('css/admin.css'), array(), self::VERSION);
221
  }
222
-
223
  }
224
-
225
  WPFront_User_Role_Editor::init();
226
-
227
  }
228
 
4
  * Plugin Name: WPFront User Role Editor
5
  * Plugin URI: http://wpfront.com/user-role-editor-pro/
6
  * Description: Allows you to manage your site's security using user role permissions.
7
+ * Version: 3.1.0.10272
8
  * Requires at least: 5.0
9
  * Requires PHP: 7.0
10
  * Author: Syam Mohan
43
  }
44
 
45
  if (!class_exists('\WPFront\URE\WPFront_User_Role_Editor')) {
46
+
47
  class WPFront_User_Role_Editor {
48
+
49
+ const VERSION = '3.1.0.10272';
50
  const PLUGIN_SLUG = 'wpfront-user-role-editor';
51
+
52
  protected static $instance = null;
53
 
54
  protected $plugin_url = null;
73
  * @return WPFront_User_Role_Editor
74
  */
75
  public static function instance() {
76
+ if (self::$instance === null) {
77
  self::$instance = new WPFront_User_Role_Editor();
78
  }
79
+
80
  return self::$instance;
81
  }
82
+
83
  /**
84
  * Hooks into plugins_loaded.
85
  * Loads controller files and fires wpfront_ure_init.
89
  self::instance()->includes();
90
  add_action('admin_enqueue_scripts', array(self::instance(), 'admin_enqueue_styles'));
91
  }
92
+
93
  public function plugins_loaded() {
94
  load_plugin_textdomain('wpfront-user-role-editor', false, basename($this->plugin_dir) . '/languages/');
95
  }
96
+
97
  /**
98
  * Loads controller files.
99
  */
105
  require_once $this->includes_dir . 'class-entity.php';
106
  require_once $this->includes_dir . 'class-controller.php';
107
  require_once $this->includes_dir . 'settings/class-options.php';
108
+ require_once $this->includes_dir . 'class-debug.php';
109
  require_once $this->includes_dir . 'users/class-assign-migrate.php';
110
  require_once $this->includes_dir . 'users/class-user-profile.php';
111
  require_once $this->includes_dir . 'roles/class-roles-list.php';
118
  require_once $this->includes_dir . 'widget/class-widget-permissions.php';
119
  require_once $this->includes_dir . 'users/class-user-permissions.php';
120
  require_once $this->includes_dir . 'media/class-media-permissions.php';
121
+ require_once $this->includes_dir . 'shortcodes/class-shortcodes.php';
122
  require_once $this->includes_dir . 'post-type/class-post-type.php';
123
  require_once $this->includes_dir . 'taxonomies/class-taxonomies.php';
124
  require_once $this->includes_dir . 'go-pro/class-go-pro.php';
125
+
126
  require_once $this->includes_dir . 'integration/plugins/class-wpfront-user-role-editor-plugin-integration.php';
127
+
128
+ if (file_exists($this->includes_dir . 'ppro/includes.php')) {
129
  require_once $this->includes_dir . 'ppro/includes.php';
130
  }
131
+
132
+ if (file_exists($this->includes_dir . 'bpro/includes.php')) {
133
  require_once $this->includes_dir . 'bpro/includes.php';
134
  }
135
  }
136
+
137
  /**
138
  * Returns parent menu slug for sub menu items.
139
  * Also adds the parent menu on the very first call.
143
  * @return string
144
  */
145
  public function get_parent_menu_slug($submenu_slug, $submenu_capability) {
146
+ if ($this->parent_menu_slug == null) {
147
  $this->parent_menu_slug = $submenu_slug;
148
+ if (is_network_admin()) {
149
  $position = 9;
150
  } else {
151
  $position = 69;
152
  }
153
  add_menu_page(__('Roles', 'wpfront-user-role-editor'), __('Roles', 'wpfront-user-role-editor'), $submenu_capability, $submenu_slug, null, 'dashicons-groups', $position);
154
  }
155
+
156
  return $this->parent_menu_slug;
157
  }
158
+
159
  /**
160
  * Returns the includes directory path.
161
  *
164
  public function get_includes_dir() {
165
  return $this->includes_dir;
166
  }
167
+
168
  /**
169
  * Returns the plugin directory path.
170
  *
173
  public function get_plugin_dir() {
174
  return $this->plugin_dir;
175
  }
176
+
177
  /**
178
  * Returns the url of the asset passed.
179
  * Passed path should be relative to assets directory.
184
  public function get_asset_url($relativePath) {
185
  return $this->plugin_url . 'assets/' . $relativePath;
186
  }
187
+
188
  /**
189
  * Returns the plugin base name.
190
  *
193
  public function get_plugin_basename() {
194
  return $this->plugin_basename;
195
  }
196
+
197
  /**
198
  * Returns the plugin file.
199
  *
213
  array('response' => 403, 'back_link' => true)
214
  );
215
  }
216
+
217
  /**
218
  * Hooks into admin_enqueue_scripts and enqueues wp-admin styles.
219
  */
220
  public function admin_enqueue_styles() {
221
  wp_enqueue_style('wpfront-user-role-editor-admin-css', $this->get_asset_url('css/admin.css'), array(), self::VERSION);
222
  }
223
+
224
  }
225
+
226
  WPFront_User_Role_Editor::init();
 
227
  }
228