WPFront User Role Editor - Version 2.3

Version Description

  • Duplicator integration.
  • Performance fix. Thanks to Jezze.
Download this release

Release Info

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

Code changes from version 2.1 to 2.3

classes/class-wpfront-user-role-editor-add-edit.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /*
4
  WPFront User Role Editor Plugin
5
  Copyright (C) 2014, WPFront.com
@@ -200,7 +199,7 @@ if (!class_exists('WPFront_User_Role_Editor_Add_Edit')) {
200
  return TRUE;
201
  return FALSE;
202
  }
203
-
204
  protected function exclude_custom_post_types() {
205
  return FALSE;
206
  }
@@ -360,6 +359,53 @@ if (!class_exists('WPFront_User_Role_Editor_Add_Edit')) {
360
  );
361
  }
362
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
  }
364
 
365
  }
1
  <?php
 
2
  /*
3
  WPFront User Role Editor Plugin
4
  Copyright (C) 2014, WPFront.com
199
  return TRUE;
200
  return FALSE;
201
  }
202
+
203
  protected function exclude_custom_post_types() {
204
  return FALSE;
205
  }
359
  );
360
  }
361
 
362
+ protected function postbox_title($value) {
363
+ return '<label class="' . ($value->deprecated ? 'deprecated' : 'active') . '"><input id="' . $value->key . '" type="checkbox" class="select-all" ' . ($value->disabled ? 'disabled' : '') . ' />' . $value->display_name . '</label>';
364
+ }
365
+
366
+ public function postbox_render($context, $args) {
367
+ $value = $args['args'];
368
+ ?>
369
+ <div class="main <?php echo $value->deprecated ? 'deprecated' : 'active'; echo ' '; echo $value->hidden ? 'hidden' : 'visible'; ?>">
370
+ <?php
371
+ if ($value->caps === 'defaulted') {
372
+ ?>
373
+ <div class="no-capability">
374
+ <?php
375
+ echo $this->__("Uses 'Posts' capabilities.");
376
+ $upgrade_message = sprintf($this->__("%s to customize capabilites."), '<a href="https://wpfront.com/ureaddedit" target="_blank">' . $this->__('Upgrade to Pro') . '</a>');
377
+ $upgrade_message = apply_filters('wpfront_ure_custom_post_type_upgrade_message', $upgrade_message);
378
+ echo ' ' . $upgrade_message;
379
+ ?>
380
+ </div>
381
+ <?php
382
+ } else {
383
+ foreach ($value->caps as $cap) {
384
+ ?>
385
+ <div>
386
+ <input type="checkbox" id="<?php echo $cap; ?>" name="capabilities[<?php echo $cap; ?>]" <?php echo $value->disabled ? 'disabled' : '' ?> <?php echo $this->capability_checked($cap) ? 'checked' : '' ?> />
387
+ <label for="<?php echo $cap; ?>" title="<?php echo $cap; ?>"><?php echo $cap; ?></label>
388
+ <?php
389
+ if ($value->has_help) {
390
+ $help_url = $this->get_help_url($cap);
391
+ if ($help_url !== NULL) {
392
+ ?>
393
+ <a target="_blank" href="<?php echo $help_url; ?>">
394
+ <img class="help" src="<?php echo $this->image_url() . 'help.png'; ?>" />
395
+ </a>
396
+ <?php
397
+ }
398
+ }
399
+ ?>
400
+ </div>
401
+ <?php
402
+ }
403
+ }
404
+ ?>
405
+ </div>
406
+ <?php
407
+ }
408
+
409
  }
410
 
411
  }
classes/class-wpfront-user-role-editor-assign-roles.php CHANGED
@@ -53,6 +53,10 @@ if (!class_exists('WPFront_User_Role_Editor_Assign_Roles')) {
53
  add_filter('manage_users_custom_column', array($this, 'manage_users_columns_content'), 10, 3);
54
 
55
  add_filter('user_row_actions', array($this, 'user_row_actions'), 10, 2);
 
 
 
 
56
  }
57
 
58
  public function manage_users_columns($columns) {
@@ -75,9 +79,68 @@ if (!class_exists('WPFront_User_Role_Editor_Assign_Roles')) {
75
  return $actions;
76
  }
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  private function get_assign_role_url($user_object = NULL) {
79
- if ($user_object == NULL)
80
- return admin_url('users.php') . '?page=' . self::MENU_SLUG . '&assign_roles=';
 
 
 
 
 
 
 
81
  return $this->get_assign_role_url() . $user_object->ID;
82
  }
83
 
@@ -96,14 +159,7 @@ if (!class_exists('WPFront_User_Role_Editor_Assign_Roles')) {
96
  return implode(', ', $names);
97
  }
98
 
99
- public function assign_roles() {
100
- if (!$this->can_assign_roles()) {
101
- $this->main->permission_denied();
102
- return;
103
- }
104
-
105
- $this->users = get_users(array('exclude' => array(wp_get_current_user()->ID)));
106
-
107
  global $wp_roles;
108
  $roles = $wp_roles->get_names();
109
 
@@ -115,6 +171,16 @@ if (!class_exists('WPFront_User_Role_Editor_Assign_Roles')) {
115
  if ($key != 'administrator')
116
  $this->secondary_roles[$key] = $value;
117
  }
 
 
 
 
 
 
 
 
 
 
118
 
119
  if (!empty($_POST['assignroles']) && !empty($_POST['assign-user'])) {
120
  $this->main->verify_nonce();
@@ -288,7 +354,7 @@ if (!class_exists('WPFront_User_Role_Editor_Assign_Roles')) {
288
  </tr>
289
  <?php
290
  }
291
-
292
  protected function add_help_tab() {
293
  return array(
294
  array(
53
  add_filter('manage_users_custom_column', array($this, 'manage_users_columns_content'), 10, 3);
54
 
55
  add_filter('user_row_actions', array($this, 'user_row_actions'), 10, 2);
56
+
57
+ add_action('edit_user_profile', array($this, 'edit_user_profile'), 10, 1);
58
+ //add_action('edit_user_profile_update', array($this, 'edit_user_profile_update'), 1000, 1);
59
+ add_action('profile_update', array($this, 'edit_user_profile_update'), 1000, 1);
60
  }
61
 
62
  public function manage_users_columns($columns) {
79
  return $actions;
80
  }
81
 
82
+ public function edit_user_profile($user) {
83
+ if(is_multisite() && is_network_admin())
84
+ return;
85
+
86
+ if (!$this->can_assign_roles())
87
+ return;
88
+
89
+ if ($user->ID === wp_get_current_user()->ID)
90
+ return;
91
+
92
+ $this->populate_roles_array();
93
+ $roles = array_values($user->roles);
94
+ array_shift($roles);
95
+
96
+ //echo "<h3>{$this->__('Secondary Roles')}</h3>";
97
+ echo '<table class="form-table">';
98
+ echo '<tbody>';
99
+ echo '<tr>';
100
+ echo "<th>{$this->__('Secondary Roles')}</th>";
101
+ echo '<td>';
102
+ foreach ($this->secondary_roles as $key => $value) {
103
+ echo '<div style="min-width:200px;width:25%;float:left;">';
104
+ printf('<label><input type="checkbox" name="wpfront-secondary-roles[%s]" %s />%s</label>', $key, in_array($key, $roles) ? 'checked' : '', $value);
105
+ echo '</div>';
106
+ }
107
+ echo '</td>';
108
+ echo '</tr>';
109
+ echo '</tbody>';
110
+ echo '</table>';
111
+ }
112
+
113
+ public function edit_user_profile_update($user_id) {
114
+ if(is_multisite() && is_network_admin())
115
+ return;
116
+
117
+ if (!$this->can_assign_roles())
118
+ return;
119
+
120
+ if ($user_id === wp_get_current_user()->ID)
121
+ return;
122
+
123
+ $user = get_user_to_edit($user_id);
124
+ if (empty($user))
125
+ return;
126
+
127
+ $this->populate_roles_array();
128
+ foreach ($this->secondary_roles as $key => $value) {
129
+ if (!empty($_POST["wpfront-secondary-roles"][$key]))
130
+ $user->add_role($key);
131
+ }
132
+ }
133
+
134
  private function get_assign_role_url($user_object = NULL) {
135
+ if ($user_object == NULL) {
136
+ if (is_multisite() && is_network_admin()) {
137
+ $site_id = 1;
138
+ if (!empty($_GET['id']))
139
+ $site_id = $_GET['id'];
140
+ return get_admin_url($site_id, 'users.php') . '?page=' . self::MENU_SLUG . '&assign_roles=';
141
+ } else
142
+ return admin_url('users.php') . '?page=' . self::MENU_SLUG . '&assign_roles=';
143
+ }
144
  return $this->get_assign_role_url() . $user_object->ID;
145
  }
146
 
159
  return implode(', ', $names);
160
  }
161
 
162
+ private function populate_roles_array() {
 
 
 
 
 
 
 
163
  global $wp_roles;
164
  $roles = $wp_roles->get_names();
165
 
171
  if ($key != 'administrator')
172
  $this->secondary_roles[$key] = $value;
173
  }
174
+ }
175
+
176
+ public function assign_roles() {
177
+ if (!$this->can_assign_roles()) {
178
+ $this->main->permission_denied();
179
+ return;
180
+ }
181
+
182
+ $this->users = get_users(array('exclude' => array(wp_get_current_user()->ID)));
183
+ $this->populate_roles_array();
184
 
185
  if (!empty($_POST['assignroles']) && !empty($_POST['assign-user'])) {
186
  $this->main->verify_nonce();
354
  </tr>
355
  <?php
356
  }
357
+
358
  protected function add_help_tab() {
359
  return array(
360
  array(
classes/class-wpfront-user-role-editor-list.php CHANGED
@@ -129,12 +129,15 @@ if (!class_exists('WPFront_User_Role_Editor_List')) {
129
 
130
  $user_default = get_option('default_role');
131
 
 
 
 
132
  foreach ($roles as $key => $value) {
133
  $this->role_data[$key] = array(
134
  'role_name' => $key,
135
  'display_name' => $value,
136
  'is_default' => in_array($key, WPFront_User_Role_Editor::$DEFAULT_ROLES),
137
- 'user_count' => count(get_users(array('role' => $key))),
138
  'caps_count' => count(array_filter($wp_roles->roles[$key]['capabilities'])),
139
  'user_default' => $key == $user_default
140
  );
@@ -283,9 +286,12 @@ if (!class_exists('WPFront_User_Role_Editor_List')) {
283
  'count' => count($role_data)
284
  );
285
 
 
 
 
286
  $count = 0;
287
  foreach ($role_data as $key => $value) {
288
- if (count(get_users(array('role' => $key))) > 0)
289
  $count++;
290
  }
291
  $filter_data['haveusers'] = array(
129
 
130
  $user_default = get_option('default_role');
131
 
132
+ $count_users = count_users();
133
+ $count_users = $count_users['avail_roles'];
134
+
135
  foreach ($roles as $key => $value) {
136
  $this->role_data[$key] = array(
137
  'role_name' => $key,
138
  'display_name' => $value,
139
  'is_default' => in_array($key, WPFront_User_Role_Editor::$DEFAULT_ROLES),
140
+ 'user_count' => isset($count_users[$key]) ? $count_users[$key] : 0, //count(get_users(array('role' => $key))),
141
  'caps_count' => count(array_filter($wp_roles->roles[$key]['capabilities'])),
142
  'user_default' => $key == $user_default
143
  );
286
  'count' => count($role_data)
287
  );
288
 
289
+ $count_users = count_users();
290
+ $count_users = $count_users['avail_roles'];
291
+
292
  $count = 0;
293
  foreach ($role_data as $key => $value) {
294
+ if(isset($count_users[$key]) && $count_users[$key] > 0) //if (count(get_users(array('role' => $key))) > 0)
295
  $count++;
296
  }
297
  $filter_data['haveusers'] = array(
classes/class-wpfront-user-role-editor.php CHANGED
@@ -34,7 +34,7 @@ if (!class_exists('WPFront_User_Role_Editor')) {
34
  class WPFront_User_Role_Editor extends WPFront_Base_URE {
35
 
36
  //Constants
37
- const VERSION = '2.1';
38
  const OPTIONS_GROUP_NAME = 'wpfront-user-role-editor-options-group';
39
  const OPTION_NAME = 'wpfront-user-role-editor-options';
40
  const PLUGIN_SLUG = 'wpfront-user-role-editor';
@@ -187,7 +187,8 @@ if (!class_exists('WPFront_User_Role_Editor')) {
187
  if (isset($this->admin_menu[1000]))
188
  return;
189
 
190
- $this->add_submenu_page(1000, $this->__('Go Pro'), '<span class="wpfront-go-pro">' . $this->__('Go Pro') . '</span>', 'manage_options', WPFront_User_Role_Editor_Go_Pro::MENU_SLUG, array($this->objGoPro, 'go_pro'));
 
191
  }
192
 
193
  public function admin_menu() {
@@ -232,6 +233,8 @@ if (!class_exists('WPFront_User_Role_Editor')) {
232
  // $jsRoot = $this->pluginURLRoot . 'js/';
233
 
234
  wp_enqueue_script('jquery');
 
 
235
  }
236
 
237
  //add styles
@@ -351,13 +354,13 @@ if (!class_exists('WPFront_User_Role_Editor')) {
351
  reset(self::$OTHER_CAPABILITIES);
352
  $other_key = key(self::$OTHER_CAPABILITIES);
353
 
354
- if($exclude_custom_post_types) {
355
  foreach (self::$DYNAMIC_CAPS as $cap) {
356
  self::$ROLE_CAPS = array_diff(self::$ROLE_CAPS, array($cap));
357
  self::$OTHER_CAPABILITIES[$other_key][] = $cap;
358
  }
359
  }
360
-
361
  if ($this->enable_role_capabilities())
362
  self::$CAPABILITIES['Roles (WPFront)'] = self::$ROLE_CAPS;
363
 
@@ -396,7 +399,20 @@ if (!class_exists('WPFront_User_Role_Editor')) {
396
  self::$CUSTOM_POST_TYPES_DEFAULTED[$this->get_custom_post_type_label($post_type_object)] = array();
397
  } else {
398
  $caps = (OBJECT) $this->remove_meta_capabilities((ARRAY) $caps, $other_caps);
399
- self::$OTHER_CAPABILITIES[$this->get_custom_post_type_label($post_type_object)] = array_values((array) $caps);
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  }
401
  }
402
 
@@ -407,7 +423,8 @@ if (!class_exists('WPFront_User_Role_Editor')) {
407
  if (count($value) === 0)
408
  continue;
409
 
410
- self::$CAPABILITIES[$key] = $value;
 
411
 
412
  if ($key != $other_key) {
413
  foreach ($value as $cap) {
@@ -550,6 +567,7 @@ require_once(plugin_dir_path(__FILE__) . "class-wpfront-user-role-editor-delete.
550
  require_once(plugin_dir_path(__FILE__) . "class-wpfront-user-role-editor-restore.php");
551
  require_once(plugin_dir_path(__FILE__) . "class-wpfront-user-role-editor-assign-roles.php");
552
  require_once(plugin_dir_path(__FILE__) . "class-wpfront-user-role-editor-go-pro.php");
 
553
 
554
 
555
 
34
  class WPFront_User_Role_Editor extends WPFront_Base_URE {
35
 
36
  //Constants
37
+ const VERSION = '2.3';
38
  const OPTIONS_GROUP_NAME = 'wpfront-user-role-editor-options-group';
39
  const OPTION_NAME = 'wpfront-user-role-editor-options';
40
  const PLUGIN_SLUG = 'wpfront-user-role-editor';
187
  if (isset($this->admin_menu[1000]))
188
  return;
189
 
190
+ if (current_user_can('manage_options'))
191
+ $this->add_submenu_page(1000, $this->__('Go Pro'), '<span class="wpfront-go-pro">' . $this->__('Go Pro') . '</span>', 'manage_options', WPFront_User_Role_Editor_Go_Pro::MENU_SLUG, array($this->objGoPro, 'go_pro'));
192
  }
193
 
194
  public function admin_menu() {
233
  // $jsRoot = $this->pluginURLRoot . 'js/';
234
 
235
  wp_enqueue_script('jquery');
236
+ wp_enqueue_script('postbox');
237
+ wp_enqueue_script('jquery-ui-draggable');
238
  }
239
 
240
  //add styles
354
  reset(self::$OTHER_CAPABILITIES);
355
  $other_key = key(self::$OTHER_CAPABILITIES);
356
 
357
+ if ($exclude_custom_post_types) {
358
  foreach (self::$DYNAMIC_CAPS as $cap) {
359
  self::$ROLE_CAPS = array_diff(self::$ROLE_CAPS, array($cap));
360
  self::$OTHER_CAPABILITIES[$other_key][] = $cap;
361
  }
362
  }
363
+
364
  if ($this->enable_role_capabilities())
365
  self::$CAPABILITIES['Roles (WPFront)'] = self::$ROLE_CAPS;
366
 
399
  self::$CUSTOM_POST_TYPES_DEFAULTED[$this->get_custom_post_type_label($post_type_object)] = array();
400
  } else {
401
  $caps = (OBJECT) $this->remove_meta_capabilities((ARRAY) $caps, $other_caps);
402
+ $custom_caps = array();
403
+ foreach (self::$STANDARD_CAPABILITIES['Posts'] as $key => $value) {
404
+ if (isset($caps->$key)) {
405
+ $custom_caps[] = $caps->$key;
406
+ unset($caps->$key);
407
+ }
408
+ }
409
+ foreach ($caps as $key => $value) {
410
+ if (isset($caps->$key)) {
411
+ $custom_caps[] = $caps->$key;
412
+ unset($caps->$key);
413
+ }
414
+ }
415
+ self::$OTHER_CAPABILITIES[$this->get_custom_post_type_label($post_type_object)] = $custom_caps;
416
  }
417
  }
418
 
423
  if (count($value) === 0)
424
  continue;
425
 
426
+ //self::$CAPABILITIES[$key] = $value;
427
+ self::$CAPABILITIES[$key] = self::$OTHER_CAPABILITIES[$key];
428
 
429
  if ($key != $other_key) {
430
  foreach ($value as $cap) {
567
  require_once(plugin_dir_path(__FILE__) . "class-wpfront-user-role-editor-restore.php");
568
  require_once(plugin_dir_path(__FILE__) . "class-wpfront-user-role-editor-assign-roles.php");
569
  require_once(plugin_dir_path(__FILE__) . "class-wpfront-user-role-editor-go-pro.php");
570
+ require_once(plugin_dir_path(__FILE__) . "integration/plugins/class-wpfront-user-role-editor-plugin-integration.php");
571
 
572
 
573
 
classes/integration/plugins/class-wpfront-user-role-editor-plugin-integration.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ WPFront User Role Editor Plugin
5
+ Copyright (C) 2014, WPFront.com
6
+ Website: wpfront.com
7
+ Contact: syam@wpfront.com
8
+
9
+ WPFront User Role Editor Plugin is distributed under the GNU General Public License, Version 3,
10
+ June 2007. Copyright (C) 2007 Free Software Foundation, Inc., 51 Franklin
11
+ St, Fifth Floor, Boston, MA 02110, USA
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ if (!class_exists('WPFront_User_Role_Editor_Plugin_Integration')) {
26
+
27
+ /**
28
+ * Base class of Plugin Integration
29
+ *
30
+ * @author Syam Mohan <syam@wpfront.com>
31
+ * @copyright 2014 WPFront.com
32
+ */
33
+ abstract class WPFront_User_Role_Editor_Plugin_Integration {
34
+
35
+ private $initialized = FALSE;
36
+
37
+ protected abstract function init($params);
38
+
39
+ protected abstract function translate_capability($capability);
40
+
41
+ public function __construct($slug) {
42
+ add_action("wpfront_user_role_editor_{$slug}_init", array($this, '_init'));
43
+
44
+ add_filter("wpfront_user_role_editor_{$slug}_integration_ready", array($this, '_integration_ready'));
45
+ add_filter("wpfront_user_role_editor_{$slug}_translate_capability", array($this, '_translate_capability'));
46
+ }
47
+
48
+ public function _init($params) {
49
+ $this->initialized = TRUE;
50
+ $this->init($params);
51
+ }
52
+
53
+ public function _integration_ready() {
54
+ return TRUE;
55
+ }
56
+
57
+ public function _translate_capability($capability) {
58
+ if (!$this->initialized)
59
+ return $capability;
60
+
61
+ return $this->translate_capability($capability);
62
+ }
63
+
64
+ }
65
+
66
+ }
67
+
68
+ require_once(plugin_dir_path(__FILE__) . "duplicator/class-wpfront-user-role-editor-plugin-duplicator.php");
69
+
classes/integration/plugins/duplicator/class-wpfront-user-role-editor-plugin-duplicator.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if (!class_exists('WPFront_User_Role_Editor_Plugin_Duplicator')) {
25
+
26
+ /**
27
+ * Main class of Duplicator Integration
28
+ *
29
+ * @author Syam Mohan <syam@wpfront.com>
30
+ * @copyright 2014 WPFront.com
31
+ */
32
+ class WPFront_User_Role_Editor_Plugin_Duplicator extends WPFront_User_Role_Editor_Plugin_Integration {
33
+
34
+ private static $slug = 'duplicator';
35
+
36
+ public function __construct() {
37
+ parent::__construct(self::$slug);
38
+ }
39
+
40
+ protected function init($params) {
41
+ $admin_role = get_role('administrator');
42
+ $caps = array();
43
+ foreach($params as $value) {
44
+ $cap = $this->translate_capability($value);
45
+ $caps[$cap] = TRUE;
46
+ $admin_role->add_cap($cap);
47
+ }
48
+
49
+ add_role(self::$slug, 'Duplicator', $caps);
50
+ }
51
+
52
+ protected function translate_capability($capability) {
53
+ return self::$slug . '_' . $capability;
54
+ }
55
+
56
+ }
57
+
58
+ new WPFront_User_Role_Editor_Plugin_Duplicator();
59
+
60
+ }
61
+
css/style.css CHANGED
@@ -21,7 +21,7 @@
21
  */
22
 
23
  #adminmenu ul.wp-submenu li a span.wpfront-go-pro {
24
- color: #2EA2CC;
25
  }
26
 
27
  #adminmenu ul.wp-submenu li.current a.current span.wpfront-go-pro {
@@ -77,17 +77,21 @@ div.role-add-new form#createuser table.sub-head td.sub-head-controls input.selec
77
  width: 100px;
78
  }
79
 
 
 
 
 
80
  div.role-add-new div.metabox-holder div.postbox {
81
  margin-bottom: 8px;
82
  }
83
 
84
- div.role-add-new div.metabox-holder div.postbox.deprecated {
85
  filter: alpha(opacity=80);
86
  opacity: 0.8;
87
  }
88
 
89
  div.role-add-new div.metabox-holder div.postbox h3.hndle {
90
- cursor: default;
91
  }
92
 
93
  div.role-add-new div.metabox-holder div.postbox div.inside div.main div {
@@ -109,6 +113,10 @@ div.role-add-new div.metabox-holder div.postbox label {
109
  text-overflow: ellipsis;
110
  }
111
 
 
 
 
 
112
  div.role-add-new div.metabox-holder div.postbox div.main img.help {
113
  width: 12px;
114
  height: 12px;
21
  */
22
 
23
  #adminmenu ul.wp-submenu li a span.wpfront-go-pro {
24
+ color: #F18500;
25
  }
26
 
27
  #adminmenu ul.wp-submenu li.current a.current span.wpfront-go-pro {
77
  width: 100px;
78
  }
79
 
80
+ #wpbody-content div.role-add-new div.metabox-holder {
81
+ padding-top: 0px;
82
+ }
83
+
84
  div.role-add-new div.metabox-holder div.postbox {
85
  margin-bottom: 8px;
86
  }
87
 
88
+ div.role-add-new div.metabox-holder .deprecated {
89
  filter: alpha(opacity=80);
90
  opacity: 0.8;
91
  }
92
 
93
  div.role-add-new div.metabox-holder div.postbox h3.hndle {
94
+
95
  }
96
 
97
  div.role-add-new div.metabox-holder div.postbox div.inside div.main div {
113
  text-overflow: ellipsis;
114
  }
115
 
116
+ div.role-add-new div.metabox-holder div.postbox h3.hndle label {
117
+ max-width: 85%;
118
+ }
119
+
120
  div.role-add-new div.metabox-holder div.postbox div.main img.help {
121
  width: 12px;
122
  height: 12px;
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: syammohanm
3
  Donate link: https://wpfront.com/donate/
4
  Tags: user role editor, role editor, user role, role, user roles, roles, user roles editor, roles editor, role manager, roles manager, manage roles, manage role, access, capability, editor, 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: 3.5
6
- Tested up to: 4.0
7
- Stable tag: 2.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -32,6 +32,10 @@ You can create, edit or delete user roles and manage role capabilities.
32
 
33
  Compare [User Role Editor Pro](https://wpfront.com/ppro)
34
 
 
 
 
 
35
  == Installation ==
36
 
37
  1. Click Plugins/Add New from the WordPress admin panel
@@ -65,6 +69,20 @@ Please visit [WPFront User Role Editor FAQ](https://wpfront.com/user-role-editor
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  = 2.1 =
69
  * Custom post type permissions.
70
  * Bug fixes.
@@ -94,6 +112,16 @@ Please visit [WPFront User Role Editor FAQ](https://wpfront.com/user-role-editor
94
 
95
  == Upgrade Notice ==
96
 
 
 
 
 
 
 
 
 
 
 
97
  = 2.1 =
98
  * Manage custom post type permissions.
99
 
3
  Donate link: https://wpfront.com/donate/
4
  Tags: user role editor, role editor, user role, role, user roles, roles, user roles editor, roles editor, role manager, roles manager, manage roles, manage role, access, capability, editor, 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: 3.5
6
+ Tested up to: 4.1
7
+ Stable tag: 2.3
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
32
 
33
  Compare [User Role Editor Pro](https://wpfront.com/ppro)
34
 
35
+
36
+ Spanish tutorial
37
+ https://www.youtube.com/watch?v=YRZdWH-uukI
38
+
39
  == Installation ==
40
 
41
  1. Click Plugins/Add New from the WordPress admin panel
69
 
70
  == Changelog ==
71
 
72
+ = 2.3 =
73
+ * Duplicator integration.
74
+ * Performance fix. Thanks to Jezze.
75
+
76
+ = 2.2.1 =
77
+ * Extended permissions bug fix.
78
+
79
+ = 2.2 =
80
+ * Extended permissions enhanced with [Guest].
81
+ * User profile secondary roles added.
82
+ * UI enhancements.
83
+ * Menu editor bug fix. Thanks to Marcus.
84
+ * Multisite user assignment bug fix.
85
+
86
  = 2.1 =
87
  * Custom post type permissions.
88
  * Bug fixes.
112
 
113
  == Upgrade Notice ==
114
 
115
+ = 2.3 =
116
+ * Integrates with Duplicator plugin.
117
+ * Performance fix on list roles.
118
+
119
+ = 2.2.1 =
120
+ * Bug fixes.
121
+
122
+ = 2.2 =
123
+ * Various bug fixes and enhancements.
124
+
125
  = 2.1 =
126
  * Manage custom post type permissions.
127
 
templates/add-edit-role.php CHANGED
@@ -119,57 +119,17 @@
119
  <div class="metabox-holder">
120
  <?php
121
  foreach ($this->get_capability_groups() as $key => $value) {
122
- ?>
123
- <div class="postbox <?php echo $value->deprecated ? 'deprecated' : 'active' ?> <?php echo $value->hidden ? 'hidden' : '' ?>">
124
- <h3 class="hndle">
125
- <input type="checkbox" class="select-all" id="<?php echo $value->key ?>" <?php echo $value->disabled ? 'disabled' : '' ?> />
126
- <label for="<?php echo $value->key ?>"><?php echo $value->display_name; ?></label>
127
- </h3>
128
- <div class="inside">
129
- <div class="main">
130
- <?php
131
- if ($value->caps === 'defaulted') {
132
- ?>
133
- <div class="no-capability">
134
- <?php
135
- echo $this->__("Uses 'Posts' capabilities.");
136
- $upgrade_message = sprintf($this->__("%s to customize capabilites."), '<a href="https://wpfront.com/ureaddedit" target="_blank">' . $this->__('Upgrade to Pro') . '</a>');
137
- $upgrade_message = apply_filters('wpfront_ure_custom_post_type_upgrade_message', $upgrade_message);
138
- echo ' ' . $upgrade_message;
139
- ?>
140
- </div>
141
- <?php
142
- } else {
143
- foreach ($value->caps as $cap) {
144
- ?>
145
- <div>
146
- <input type="checkbox" id="<?php echo $cap; ?>" name="capabilities[<?php echo $cap; ?>]" <?php echo $value->disabled ? 'disabled' : '' ?> <?php echo $this->capability_checked($cap) ? 'checked' : '' ?> />
147
- <label for="<?php echo $cap; ?>" title="<?php echo $cap; ?>"><?php echo $cap; ?></label>
148
- <?php
149
- if ($value->has_help) {
150
- $help_url = $this->get_help_url($cap);
151
- if ($help_url !== NULL) {
152
- ?>
153
- <a target="_blank" href="<?php echo $help_url; ?>">
154
- <img class="help" src="<?php echo $this->image_url() . 'help.png'; ?>" />
155
- </a>
156
- <?php
157
- }
158
- }
159
- ?>
160
- </div>
161
- <?php
162
- }
163
- }
164
- ?>
165
- </div>
166
- </div>
167
- </div>
168
- <?php
169
  }
 
170
  ?>
171
  </div>
172
 
 
 
 
 
 
173
  <p class="submit">
174
  <input type="submit" name="createrole" id="createusersub" class="button button-primary" value="<?php echo $this->role == NULL ? $this->__('Add New Role') : $this->__('Update Role'); ?>" <?php echo $this->is_submit_disabled() ? 'disabled' : ''; ?> />
175
  </p>
@@ -190,13 +150,13 @@
190
  }
191
 
192
  $("div.role-add-new div.postbox input.select-all").click(function() {
193
- $(this).parent().next().find("input").prop("checked", $(this).prop("checked"));
 
 
194
  });
195
-
196
  $("div.role-add-new div.postbox div.main input").click(function() {
197
  change_select_all($(this));
198
  });
199
-
200
  $("div.role-add-new table.sub-head td.sub-head-controls input.chk-helpers").click(function() {
201
  if ($(this).hasClass('select-all')) {
202
  $("div.role-add-new div.postbox").find("input:not(:disabled)").prop("checked", true);
@@ -205,7 +165,6 @@
205
  $("div.role-add-new div.postbox").find("input:not(:disabled)").prop("checked", false);
206
  }
207
  });
208
-
209
  <?php
210
  if ($this->role == NULL) {
211
  ?>
@@ -214,7 +173,6 @@ if ($this->role == NULL) {
214
  return;
215
  $("#role_name").val($.trim($(this).val()).toLowerCase().replace(/ /g, "_").replace(/\W/g, ""));
216
  });
217
-
218
  $("#role_name").blur(function() {
219
  var ele = $(this);
220
  var str = $.trim(ele.val()).toLowerCase();
@@ -234,7 +192,6 @@ if ($this->role == NULL) {
234
  }
235
  $("#role_name").blur();
236
  });
237
-
238
  $("#createusersub").click(function() {
239
  var role_name = $("#role_name");
240
  var display_name = $("#display_name");
@@ -258,11 +215,9 @@ if ($this->role == NULL) {
258
 
259
  return true;
260
  });
261
-
262
  $("#cap_apply").click(function() {
263
  if ($(this).prev().val() == "")
264
  return;
265
-
266
  var button = $(this).prop("disabled", true);
267
  var data = {
268
  "action": "wpfront_user_role_editor_copy_capabilities",
@@ -289,5 +244,13 @@ if ($this->multisite) {
289
  $("div.role-add-new div.postbox div.main input:first-child").each(function() {
290
  change_select_all($(this));
291
  });
 
 
 
 
 
 
 
 
292
  })(jQuery);
293
  </script>
119
  <div class="metabox-holder">
120
  <?php
121
  foreach ($this->get_capability_groups() as $key => $value) {
122
+ add_meta_box("postbox-$key", $this->postbox_title($value), array($this, 'postbox_render'), self::MENU_SLUG, 'normal', 'default', $value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
+ do_meta_boxes(self::MENU_SLUG, 'normal', null);
125
  ?>
126
  </div>
127
 
128
+ <?php
129
+ wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
130
+ wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
131
+ ?>
132
+
133
  <p class="submit">
134
  <input type="submit" name="createrole" id="createusersub" class="button button-primary" value="<?php echo $this->role == NULL ? $this->__('Add New Role') : $this->__('Update Role'); ?>" <?php echo $this->is_submit_disabled() ? 'disabled' : ''; ?> />
135
  </p>
150
  }
151
 
152
  $("div.role-add-new div.postbox input.select-all").click(function() {
153
+ $(this).closest('div.postbox').find("input").prop("checked", $(this).prop("checked"));
154
+ }).parent().click(function(event) {
155
+ event.stopPropagation();
156
  });
 
157
  $("div.role-add-new div.postbox div.main input").click(function() {
158
  change_select_all($(this));
159
  });
 
160
  $("div.role-add-new table.sub-head td.sub-head-controls input.chk-helpers").click(function() {
161
  if ($(this).hasClass('select-all')) {
162
  $("div.role-add-new div.postbox").find("input:not(:disabled)").prop("checked", true);
165
  $("div.role-add-new div.postbox").find("input:not(:disabled)").prop("checked", false);
166
  }
167
  });
 
168
  <?php
169
  if ($this->role == NULL) {
170
  ?>
173
  return;
174
  $("#role_name").val($.trim($(this).val()).toLowerCase().replace(/ /g, "_").replace(/\W/g, ""));
175
  });
 
176
  $("#role_name").blur(function() {
177
  var ele = $(this);
178
  var str = $.trim(ele.val()).toLowerCase();
192
  }
193
  $("#role_name").blur();
194
  });
 
195
  $("#createusersub").click(function() {
196
  var role_name = $("#role_name");
197
  var display_name = $("#display_name");
215
 
216
  return true;
217
  });
 
218
  $("#cap_apply").click(function() {
219
  if ($(this).prev().val() == "")
220
  return;
 
221
  var button = $(this).prop("disabled", true);
222
  var data = {
223
  "action": "wpfront_user_role_editor_copy_capabilities",
244
  $("div.role-add-new div.postbox div.main input:first-child").each(function() {
245
  change_select_all($(this));
246
  });
247
+
248
+ //postbox
249
+ $(function() {
250
+ $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
251
+ postboxes.add_postbox_toggles('<?php echo self::MENU_SLUG; ?>');
252
+ $('div.postbox div.main.hidden').closest('div.postbox').addClass('hide-if-js');
253
+ $('div.postbox div.main.visible').closest('div.postbox').removeClass('hide-if-js');
254
+ });
255
  })(jQuery);
256
  </script>
templates/options-template.php CHANGED
@@ -71,7 +71,7 @@
71
  <?php if ($this->main->enable_pro_only_options() && !$this->multisite) { ?>
72
  <tr>
73
  <th scope="row">
74
- <?php echo $this->__('Customize permissions (custom post types)'); ?>
75
  </th>
76
  <td>
77
  <?php
71
  <?php if ($this->main->enable_pro_only_options() && !$this->multisite) { ?>
72
  <tr>
73
  <th scope="row">
74
+ <?php echo $this->__('Customize Permissions (custom post types)'); ?>
75
  </th>
76
  <td>
77
  <?php
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 user roles.
7
- * Version: 2.1
8
  * Author: Syam Mohan
9
  * Author URI: http://wpfront.com
10
  * License: GPL v3
4
  * Plugin Name: WPFront User Role Editor
5
  * Plugin URI: http://wpfront.com/user-role-editor-pro/
6
  * Description: Allows you to manage user roles.
7
+ * Version: 2.3
8
  * Author: Syam Mohan
9
  * Author URI: http://wpfront.com
10
  * License: GPL v3