WPFront User Role Editor - Version 1.3

Version Description

  • Assign multiple roles
  • Migrate users
Download this release

Release Info

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

Code changes from version 1.1 to 1.3

classes/class-wpfront-user-role-editor-add-edit.php CHANGED
@@ -118,7 +118,7 @@ if (!class_exists('WPFront_User_Role_Editor_Add_Edit')) {
118
  }
119
 
120
  if ($success) {
121
- printf('<script type="text/javascript">document.location="%s";</script>', $this->list_roles_url());
122
  } else {
123
  include($this->main->pluginDIR() . 'templates/add-edit-role.php');
124
  }
118
  }
119
 
120
  if ($success) {
121
+ printf('<script type="text/javascript">window.location.replace("%s");</script>', $this->list_roles_url());
122
  } else {
123
  include($this->main->pluginDIR() . 'templates/add-edit-role.php');
124
  }
classes/class-wpfront-user-role-editor-assign-roles.php ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if (!class_exists('WPFront_User_Role_Editor_Assign_Roles')) {
26
+
27
+ /**
28
+ * Assign Roles
29
+ *
30
+ * @author Syam Mohan <syam@wpfront.com>
31
+ * @copyright 2014 WPFront.com
32
+ */
33
+ class WPFront_User_Role_Editor_Assign_Roles {
34
+
35
+ const MENU_SLUG = 'wpfront-user-role-editor-assign-roles';
36
+ const SECONDARY_ROLE_COLUMN_KEY = 'secondary_roles';
37
+
38
+ private $main;
39
+ private $user = NULL;
40
+ private $userPrimaryRole = '';
41
+ private $userSecondaryRoles = array();
42
+ private $users;
43
+ private $migrateFromPrimaryRole = NULL;
44
+ private $migrateToPrimaryRole = NULL;
45
+ private $migrateToSecondaryRoles = array();
46
+ private $primary_roles;
47
+ private $secondary_roles;
48
+ private $result = NULL;
49
+
50
+ function __construct($main) {
51
+ $this->main = $main;
52
+
53
+ add_filter('manage_users_columns', array($this, 'manage_users_columns'));
54
+ add_action('manage_users_custom_column', array($this, 'manage_users_columns_content'), 10, 3);
55
+
56
+ add_filter('user_row_actions', array($this, 'user_row_actions'), 10, 2);
57
+ }
58
+
59
+ public function manage_users_columns($columns) {
60
+ $columns[self::SECONDARY_ROLE_COLUMN_KEY] = $this->__('Secondary Roles');
61
+
62
+ return $columns;
63
+ }
64
+
65
+ public function manage_users_columns_content($value, $column_name, $user_id) {
66
+ if ($column_name == self::SECONDARY_ROLE_COLUMN_KEY) {
67
+ $user = get_userdata($user_id);
68
+ return $this->get_secondary_role_list($user->roles);
69
+ }
70
+ return $value;
71
+ }
72
+
73
+ public function user_row_actions($actions, $user_object) {
74
+ if ($this->can_assign_roles() && $user_object->ID !== wp_get_current_user()->ID)
75
+ $actions['assign_roles'] = sprintf('<a href="%s">%s</a>', $this->get_assign_role_url($user_object), $this->__('Assign Roles'));
76
+ return $actions;
77
+ }
78
+
79
+ private function can_assign_roles() {
80
+ return current_user_can('promote_users') && current_user_can('list_users');
81
+ }
82
+
83
+ private function get_assign_role_url($user_object = NULL) {
84
+ if ($user_object == NULL)
85
+ return admin_url('users.php') . '?page=' . self::MENU_SLUG . '&assign_roles=';
86
+ return $this->get_assign_role_url() . $user_object->ID;
87
+ }
88
+
89
+ private function get_secondary_role_list($roles) {
90
+ $names = array();
91
+
92
+ global $wp_roles;
93
+
94
+ foreach ($roles as $value) {
95
+ if (array_key_exists($value, $wp_roles->role_names)) {
96
+ $names[] = $wp_roles->role_names[$value];
97
+ }
98
+ }
99
+
100
+ array_shift($names);
101
+ return implode(', ', $names);
102
+ }
103
+
104
+ private function __($s) {
105
+ return $this->main->__($s);
106
+ }
107
+
108
+ public function assign_roles() {
109
+ if (!$this->can_assign_roles()) {
110
+ $this->main->permission_denied();
111
+ return;
112
+ }
113
+
114
+ $this->users = get_users(array('exclude' => array(wp_get_current_user()->ID)));
115
+
116
+ $roles = get_editable_roles();
117
+
118
+ $this->primary_roles = array();
119
+ foreach ($roles as $key => $value) {
120
+ $this->primary_roles[$key] = $value['name'];
121
+ }
122
+ $this->primary_roles[''] = '&mdash;' . $this->__('No role for this site') . '&mdash;';
123
+
124
+ $this->secondary_roles = array();
125
+ foreach ($roles as $key => $value) {
126
+ if ($key != 'administrator')
127
+ $this->secondary_roles[$key] = $value['name'];
128
+ }
129
+
130
+ if (!empty($_POST['assignroles']) && !empty($_POST['assign-user'])) {
131
+ $this->main->verify_nonce();
132
+
133
+ $this->result = (OBJECT) array("success" => FALSE);
134
+
135
+ $this->user = get_userdata($_POST['assign-user']);
136
+ if ($this->user === FALSE || $this->user->ID === wp_get_current_user()->ID) {
137
+ $this->user = NULL;
138
+ $this->result->message = $this->__('Invalid user.');
139
+ }
140
+
141
+ if ($this->user != NULL) {
142
+ $primary_role = NULL;
143
+ if (isset($_POST['assign-primary-role'])) {
144
+ $primary_role = $_POST['assign-primary-role'];
145
+ if (!array_key_exists($primary_role, $this->primary_roles))
146
+ $primary_role = NULL;
147
+ }
148
+
149
+ if ($primary_role !== NULL) {
150
+ $secondary_roles = array();
151
+ if (!empty($_POST['assign-secondary-roles'])) {
152
+ $secondary_roles = $_POST['assign-secondary-roles'];
153
+ }
154
+ if (is_array($secondary_roles))
155
+ $secondary_roles = array_keys($secondary_roles);
156
+ else
157
+ $secondary_roles = array();
158
+
159
+ $this->user->set_role($primary_role);
160
+
161
+ foreach ($secondary_roles as $role) {
162
+ $this->user->add_role($role);
163
+ }
164
+
165
+ $this->result->success = TRUE;
166
+ $this->result->message = $this->__('Roles updated successfully.');
167
+ } else {
168
+ $this->result->message = $this->__('Invalid primary role specified.');
169
+ }
170
+ }
171
+ }
172
+
173
+ if (!empty($_POST['migrateroles'])) {
174
+ $this->main->verify_nonce();
175
+
176
+ $this->result = (OBJECT) array("success" => FALSE);
177
+
178
+ if (isset($_POST['migrate-from-primary-role'])) {
179
+ $this->migrateFromPrimaryRole = $_POST['migrate-from-primary-role'];
180
+ if (!array_key_exists($this->migrateFromPrimaryRole, $this->primary_roles)) {
181
+ $this->migrateFromPrimaryRole = NULL;
182
+ }
183
+ }
184
+
185
+ if ($this->migrateFromPrimaryRole === NULL) {
186
+ $this->result->message = $this->__('Invalid primary role.');
187
+ } else {
188
+ if (isset($_POST['migrate-primary-role'])) {
189
+ $this->migrateToPrimaryRole = $_POST['migrate-primary-role'];
190
+ if (!array_key_exists($this->migrateToPrimaryRole, $this->primary_roles)) {
191
+ $this->migrateToPrimaryRole = NULL;
192
+ }
193
+ }
194
+
195
+ if ($this->migrateToPrimaryRole === NULL) {
196
+ $this->result->message = $this->__('Invalid primary role.');
197
+ } else {
198
+ if (!empty($_POST['migrate-secondary-roles'])) {
199
+ $this->migrateToSecondaryRoles = $_POST['migrate-secondary-roles'];
200
+ if (is_array($this->migrateToSecondaryRoles))
201
+ $this->migrateToSecondaryRoles = array_keys($this->migrateToSecondaryRoles);
202
+ else
203
+ $this->migrateToSecondaryRoles = array();
204
+ }
205
+
206
+ $users = get_users(array('exclude' => array(wp_get_current_user()->ID), 'role' => $this->migrateFromPrimaryRole));
207
+ $users = array_filter($users, array($this, 'array_filter_user'));
208
+
209
+ foreach ($users as $user) {
210
+ $user->set_role($this->migrateToPrimaryRole);
211
+
212
+ foreach ($this->migrateToSecondaryRoles as $role) {
213
+ $user->add_role($role);
214
+ }
215
+ }
216
+
217
+ $this->result->success = TRUE;
218
+ $this->result->message = sprintf($this->__('%d user(s) migrated.'), count($users));
219
+ }
220
+ }
221
+ }
222
+
223
+ if ($this->user == NULL && !empty($_GET['assign_roles'])) {
224
+ $this->user = get_userdata($_GET['assign_roles']);
225
+ if ($this->user === FALSE || $this->user->ID === wp_get_current_user()->ID)
226
+ $this->user = NULL;
227
+ }
228
+
229
+ if ($this->user == NULL) {
230
+ if (!empty($this->users))
231
+ $this->user = $this->users[0];
232
+ }
233
+
234
+ if ($this->user != NULL) {
235
+ $roles = $this->user->roles;
236
+ $this->userPrimaryRole = array_shift($roles);
237
+ if ($this->userPrimaryRole === NULL)
238
+ $this->userPrimaryRole = '';
239
+ $this->userSecondaryRoles = $roles;
240
+ }
241
+
242
+ include($this->main->pluginDIR() . 'templates/assign-roles.php');
243
+ }
244
+
245
+ private function array_filter_user($user) {
246
+ if ($this->migrateFromPrimaryRole === '') {
247
+ if (empty($user->roles))
248
+ return TRUE;
249
+ }
250
+
251
+ if (empty($user->roles))
252
+ return FALSE;
253
+
254
+ $roles = $user->roles;
255
+ $role = array_shift($roles);
256
+ return $role === $this->migrateFromPrimaryRole;
257
+ }
258
+
259
+ private function primary_secondary_section($prefix, $selectPrimaryRole = NULL, $selectSecondaryRoles = array()) {
260
+ ?>
261
+ <tr>
262
+ <th scope="row">
263
+ <?php echo $this->__('Primary Role'); ?>
264
+ </th>
265
+ <td>
266
+ <select id="<?php echo $prefix; ?>_roles_list" name="<?php echo $prefix; ?>-primary-role">
267
+ <?php
268
+ foreach ($this->primary_roles as $key => $role) {
269
+ ?>
270
+ <option value="<?php echo $key; ?>" <?php echo $selectPrimaryRole === $key ? 'selected' : ''; ?>>
271
+ <?php echo $role; ?>
272
+
273
+ </option>
274
+ <?php
275
+ }
276
+ ?>
277
+ </select>
278
+ </td>
279
+ </tr>
280
+ <tr>
281
+ <th scope="row">
282
+ <?php echo $this->__('Secondary Roles'); ?>
283
+ </th>
284
+ <td>
285
+ <div class="role-list">
286
+ <?php
287
+ foreach ($this->secondary_roles as $key => $role) {
288
+ ?>
289
+ <div class="role-list-item">
290
+ <label>
291
+ <input type="checkbox" name="<?php echo $prefix; ?>-secondary-roles[<?php echo $key; ?>]" <?php echo in_array($key, $selectSecondaryRoles) ? 'checked' : ''; ?> />
292
+ <?php echo $role; ?>
293
+ </label>
294
+ </div>
295
+ <?php
296
+ }
297
+ ?>
298
+ </div>
299
+ </td>
300
+ </tr>
301
+ <?php
302
+ }
303
+
304
+ }
305
+
306
+ }
classes/class-wpfront-user-role-editor-delete.php CHANGED
@@ -79,7 +79,7 @@ if (!class_exists('WPFront_User_Role_Editor_Delete')) {
79
  remove_role($key);
80
  }
81
  }
82
- printf('<script type="text/javascript">document.location="%s";</script>', $this->list_roles_url());
83
  return;
84
  }
85
 
79
  remove_role($key);
80
  }
81
  }
82
+ printf('<script type="text/javascript">window.location.replace("%s");</script>', $this->list_roles_url());
83
  return;
84
  }
85
 
classes/class-wpfront-user-role-editor-list.php CHANGED
@@ -60,7 +60,7 @@ if (!class_exists('WPFront_User_Role_Editor_List')) {
60
 
61
  if (!empty($_GET['set_default_role'])) {
62
  $this->set_default_role($_GET['set_default_role']);
63
- printf('<script type="text/javascript">document.location="%s";</script>', $this->list_url());
64
  return;
65
  }
66
 
@@ -149,7 +149,7 @@ if (!class_exists('WPFront_User_Role_Editor_List')) {
149
 
150
  global $wp_roles;
151
  $roles = $wp_roles->role_names;
152
- asort($roles, SORT_STRING | SORT_FLAG_CASE);
153
 
154
  $editable_roles = get_editable_roles();
155
 
@@ -280,10 +280,10 @@ if (!class_exists('WPFront_User_Role_Editor_List')) {
280
  }
281
 
282
  private function get_search_term() {
283
- if (empty($_POST['search']))
284
  return '';
285
 
286
- return $_POST['search'];
287
  }
288
 
289
  private function get_list_filters() {
60
 
61
  if (!empty($_GET['set_default_role'])) {
62
  $this->set_default_role($_GET['set_default_role']);
63
+ printf('<script type="text/javascript">window.location.replace("%s");</script>', $this->list_url());
64
  return;
65
  }
66
 
149
 
150
  global $wp_roles;
151
  $roles = $wp_roles->role_names;
152
+ asort($roles, SORT_STRING);
153
 
154
  $editable_roles = get_editable_roles();
155
 
280
  }
281
 
282
  private function get_search_term() {
283
+ if (empty($_POST['s']))
284
  return '';
285
 
286
+ return $_POST['s'];
287
  }
288
 
289
  private function get_list_filters() {
classes/class-wpfront-user-role-editor-options.php CHANGED
@@ -40,6 +40,7 @@ if (!class_exists('WPFront_User_Role_Editor_Options')) {
40
  //add the options required for this plugin
41
  $this->addOption('display_deprecated', 'bit', FALSE)->__('Display Deprecated Capabilities');
42
  $this->addOption('enable_role_capabilities', 'bit', FALSE)->__('Add Role Capabilities');
 
43
  }
44
 
45
  }
40
  //add the options required for this plugin
41
  $this->addOption('display_deprecated', 'bit', FALSE)->__('Display Deprecated Capabilities');
42
  $this->addOption('enable_role_capabilities', 'bit', FALSE)->__('Add Role Capabilities');
43
+ $this->addOption('remove_nonstandard_capabilities_restore', 'bit', FALSE)->__('Remove Non-Standard Capabilities on Restore');
44
  }
45
 
46
  }
classes/class-wpfront-user-role-editor-restore.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
26
+ if (!class_exists('WPFront_User_Role_Editor_Restore')) {
27
+
28
+ /**
29
+ * Restore Role
30
+ *
31
+ * @author Syam Mohan <syam@wpfront.com>
32
+ * @copyright 2014 WPFront.com
33
+ */
34
+ class WPFront_User_Role_Editor_Restore {
35
+
36
+ const MENU_SLUG = 'wpfront-user-role-editor-restore';
37
+
38
+ private $main;
39
+ private $roles;
40
+
41
+ function __construct($main) {
42
+ $this->main = $main;
43
+ }
44
+
45
+ public function ajax_register() {
46
+ add_action('wp_ajax_wpfront_user_role_editor_restore_role', array($this, 'restore_role_callback'));
47
+ }
48
+
49
+ private function can_edit() {
50
+ return $this->main->current_user_can('edit_roles');
51
+ }
52
+
53
+ public function restore_role() {
54
+ if (!$this->can_edit()) {
55
+ $this->main->permission_denied();
56
+ return;
57
+ }
58
+
59
+ global $wp_roles;
60
+ $site_roles = $wp_roles->role_names;
61
+
62
+ foreach (WPFront_User_Role_Editor::$DEFAULT_ROLES as $value) {
63
+ $text = $this->__(ucfirst($value));
64
+ if (array_key_exists($value, $site_roles))
65
+ $text = $site_roles[$value];
66
+
67
+ $this->roles[$value] = $text;
68
+ }
69
+
70
+ include($this->main->pluginDIR() . 'templates/restore-role.php');
71
+ }
72
+
73
+ public function restore_role_callback() {
74
+ $result = FALSE;
75
+ $message = 'Unexpected error while restoring role.';
76
+
77
+ if (empty($_POST['role'])) {
78
+ $message = 'Role not found.';
79
+ } elseif (!$this->can_edit()) {
80
+ $message = 'Permission denied.';
81
+ } else {
82
+ $role_name = $_POST['role'];
83
+ if (!in_array($role_name, WPFront_User_Role_Editor::$DEFAULT_ROLES)) {
84
+ $message = 'Role not found.';
85
+ } else {
86
+ $role = get_role($role_name);
87
+ if ($role == NULL)
88
+ $role = add_role($role_name, $this->__(ucfirst($role_name)));
89
+ if ($role != NULL) {
90
+
91
+ foreach (WPFront_User_Role_Editor::$STANDARD_CAPABILITIES as $group => $caps) {
92
+ foreach ($caps as $cap => $roles) {
93
+ if (in_array($role->name, $roles))
94
+ $role->add_cap($cap);
95
+ else
96
+ $role->remove_cap($cap);
97
+ }
98
+ }
99
+
100
+ foreach (WPFront_User_Role_Editor::$DEPRECATED_CAPABILITIES as $group => $caps) {
101
+ foreach ($caps as $cap => $roles) {
102
+ if (in_array($role->name, $roles))
103
+ $role->add_cap($cap);
104
+ else
105
+ $role->remove_cap($cap);
106
+ }
107
+ }
108
+
109
+ if ($this->main->remove_nonstandard_capabilities_restore()) {
110
+ foreach (WPFront_User_Role_Editor::$ROLE_CAPS as $value) {
111
+ $role->remove_cap($value);
112
+ }
113
+
114
+ $this->main->get_capabilities();
115
+ foreach (WPFront_User_Role_Editor::$OTHER_CAPABILITIES as $group => $caps) {
116
+ foreach ($caps as $cap) {
117
+ $role->remove_cap($cap);
118
+ }
119
+ }
120
+ }
121
+
122
+ if ($role->name == 'administrator' && $this->main->enable_role_capabilities()) {
123
+ foreach (WPFront_User_Role_Editor::$ROLE_CAPS as $value) {
124
+ $role->add_cap($value);
125
+ }
126
+ }
127
+
128
+ $result = TRUE;
129
+ $message = '';
130
+ }
131
+ }
132
+ }
133
+
134
+ echo sprintf('{ "result": %s, "message": "%s" }', $result ? 'true' : 'false', $this->__('ERROR') . ': ' . $this->__($message));
135
+ die();
136
+ }
137
+
138
+ private function __($s) {
139
+ return $this->main->__($s);
140
+ }
141
+
142
+ private function image_url() {
143
+ return $this->main->pluginURL() . 'images/';
144
+ }
145
+
146
+ }
147
+
148
+ }
classes/class-wpfront-user-role-editor.php CHANGED
@@ -26,6 +26,8 @@ require_once("class-wpfront-user-role-editor-options.php");
26
  require_once("class-wpfront-user-role-editor-list.php");
27
  require_once("class-wpfront-user-role-editor-add-edit.php");
28
  require_once("class-wpfront-user-role-editor-delete.php");
 
 
29
 
30
  if (!class_exists('WPFront_User_Role_Editor')) {
31
 
@@ -38,7 +40,7 @@ if (!class_exists('WPFront_User_Role_Editor')) {
38
  class WPFront_User_Role_Editor extends WPFront_Base {
39
 
40
  //Constants
41
- const VERSION = '1.1';
42
  const OPTIONS_GROUP_NAME = 'wpfront-user-role-editor-options-group';
43
  const OPTION_NAME = 'wpfront-user-role-editor-options';
44
  const PLUGIN_SLUG = 'wpfront-user-role-editor';
@@ -47,93 +49,93 @@ if (!class_exists('WPFront_User_Role_Editor')) {
47
  public static $DEFAULT_ROLES = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
48
  public static $STANDARD_CAPABILITIES = array(
49
  'Dashboard' => array(
50
- 'read',
51
- 'edit_dashboard'
52
  ),
53
  'Posts' => array(
54
- 'publish_posts',
55
- 'edit_posts',
56
- 'delete_posts',
57
- 'edit_published_posts',
58
- 'delete_published_posts',
59
- 'edit_others_posts',
60
- 'delete_others_posts',
61
- 'read_private_posts',
62
- 'edit_private_posts',
63
- 'delete_private_posts',
64
- 'manage_categories'
65
  ),
66
  'Media' => array(
67
- 'upload_files',
68
- 'unfiltered_upload'
69
  ),
70
  'Pages' => array(
71
- 'publish_pages',
72
- 'edit_pages',
73
- 'delete_pages',
74
- 'edit_published_pages',
75
- 'delete_published_pages',
76
- 'edit_others_pages',
77
- 'delete_others_pages',
78
- 'read_private_pages',
79
- 'edit_private_pages',
80
- 'delete_private_pages'
81
  ),
82
  'Comments' => array(
83
- 'edit_comment',
84
- 'moderate_comments'
85
  ),
86
  'Themes' => array(
87
- 'switch_themes',
88
- 'edit_theme_options',
89
- 'edit_themes',
90
- 'delete_themes',
91
- 'install_themes',
92
- 'update_themes'
93
  ),
94
  'Plugins' => array(
95
- 'activate_plugins',
96
- 'edit_plugins',
97
- 'install_plugins',
98
- 'update_plugins',
99
- 'delete_plugins'
100
  ),
101
  'Users' => array(
102
- 'list_users',
103
- 'create_users',
104
- 'edit_users',
105
- 'delete_users',
106
- 'promote_users',
107
- 'add_users',
108
- 'remove_users'
109
  ),
110
  'Tools' => array(
111
- 'import',
112
- 'export'
113
  ),
114
  'Admin' => array(
115
- 'manage_options',
116
- 'update_core',
117
- 'unfiltered_html'
118
  ),
119
  'Links' => array(
120
- 'manage_links'
121
  )
122
  );
123
  public static $DEPRECATED_CAPABILITIES = array(
124
  'Deprecated' => array(
125
- 'edit_files',
126
- 'level_0',
127
- 'level_1',
128
- 'level_2',
129
- 'level_3',
130
- 'level_4',
131
- 'level_5',
132
- 'level_6',
133
- 'level_7',
134
- 'level_8',
135
- 'level_9',
136
- 'level_10'
137
  )
138
  );
139
  public static $OTHER_CAPABILITIES = array(
@@ -143,11 +145,20 @@ if (!class_exists('WPFront_User_Role_Editor')) {
143
  private static $CAPABILITIES = NULL;
144
  //Variables
145
  protected $options;
 
 
 
 
146
 
147
  function __construct() {
148
  parent::__construct(__FILE__, self::PLUGIN_SLUG);
149
 
150
  $this->add_menu($this->__('WPFront User Role Editor'), $this->__('User Role Editor'));
 
 
 
 
 
151
  }
152
 
153
  public function plugins_loaded() {
@@ -163,9 +174,9 @@ if (!class_exists('WPFront_User_Role_Editor')) {
163
  register_setting(self::OPTIONS_GROUP_NAME, self::OPTION_NAME);
164
 
165
  add_action('wp_ajax_wpfront_user_role_editor_update_options', array($this, 'update_options_callback'));
166
-
167
- $add_new = new WPFront_User_Role_Editor_Add_Edit($this);
168
- $add_new->ajax_register();
169
  }
170
 
171
  public function admin_menu() {
@@ -174,36 +185,45 @@ if (!class_exists('WPFront_User_Role_Editor')) {
174
  $menu_slug = WPFront_User_Role_Editor_List::MENU_SLUG;
175
  add_menu_page($this->__('Roles'), $this->__('Roles'), $this->get_capability_string('list'), $menu_slug, null, $this->pluginURL() . 'images/roles_menu.png', '69.9999');
176
 
177
- $page_hook_suffix = add_submenu_page($menu_slug, $this->__('Roles'), $this->__('All Roles'), $this->get_capability_string('list'), $menu_slug, array(new WPFront_User_Role_Editor_List($this), 'list_roles'));
178
- add_action('admin_print_scripts-' . $page_hook_suffix, array($this, 'enqueue_scripts'));
179
- add_action('admin_print_styles-' . $page_hook_suffix, array($this, 'enqueue_styles'));
 
 
 
 
180
 
181
- $page_hook_suffix = add_submenu_page($menu_slug, $this->__('Add New Role'), $this->__('Add New'), $this->get_capability_string('create'), WPFront_User_Role_Editor_Add_Edit::MENU_SLUG, array(new WPFront_User_Role_Editor_Add_Edit($this), 'add_edit_role'));
182
- add_action('admin_print_scripts-' . $page_hook_suffix, array($this, 'enqueue_scripts'));
183
- add_action('admin_print_styles-' . $page_hook_suffix, array($this, 'enqueue_styles'));
 
 
 
 
184
  }
185
 
186
  //add scripts
187
- public function enqueue_scripts() {
188
  // $jsRoot = $this->pluginURLRoot . 'js/';
189
 
190
  wp_enqueue_script('jquery');
191
  }
192
 
193
  //add styles
194
- public function enqueue_styles() {
 
195
  $styleRoot = $this->pluginURLRoot . 'css/';
196
  wp_enqueue_style('wpfront-user-role-editor-styles', $styleRoot . 'style.css', array(), self::VERSION);
197
  }
198
 
199
  //options page scripts
200
  public function enqueue_options_scripts() {
201
- $this->enqueue_scripts();
202
  }
203
 
204
  //options page styles
205
  public function enqueue_options_styles() {
206
- $this->enqueue_styles();
207
 
208
  $styleRoot = $this->pluginURLRoot . 'css/';
209
  wp_enqueue_style('wpfront-user-role-editor-options', $styleRoot . 'options.css', array(), self::VERSION);
@@ -309,11 +329,17 @@ if (!class_exists('WPFront_User_Role_Editor')) {
309
  self::$CAPABILITIES = array();
310
 
311
  foreach (self::$STANDARD_CAPABILITIES as $key => $value) {
312
- self::$CAPABILITIES[$key] = $value;
 
 
 
313
  }
314
 
315
  foreach (self::$DEPRECATED_CAPABILITIES as $key => $value) {
316
- self::$CAPABILITIES[$key] = $value;
 
 
 
317
  }
318
 
319
  if ($this->options->enable_role_capabilities())
@@ -350,6 +376,14 @@ if (!class_exists('WPFront_User_Role_Editor')) {
350
  return $this->options->display_deprecated();
351
  }
352
 
 
 
 
 
 
 
 
 
353
  }
354
 
355
  }
26
  require_once("class-wpfront-user-role-editor-list.php");
27
  require_once("class-wpfront-user-role-editor-add-edit.php");
28
  require_once("class-wpfront-user-role-editor-delete.php");
29
+ require_once("class-wpfront-user-role-editor-restore.php");
30
+ require_once("class-wpfront-user-role-editor-assign-roles.php");
31
 
32
  if (!class_exists('WPFront_User_Role_Editor')) {
33
 
40
  class WPFront_User_Role_Editor extends WPFront_Base {
41
 
42
  //Constants
43
+ const VERSION = '1.3';
44
  const OPTIONS_GROUP_NAME = 'wpfront-user-role-editor-options-group';
45
  const OPTION_NAME = 'wpfront-user-role-editor-options';
46
  const PLUGIN_SLUG = 'wpfront-user-role-editor';
49
  public static $DEFAULT_ROLES = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
50
  public static $STANDARD_CAPABILITIES = array(
51
  'Dashboard' => array(
52
+ 'read' => array('administrator', 'editor', 'author', 'contributor', 'subscriber'),
53
+ 'edit_dashboard' => array('administrator')
54
  ),
55
  'Posts' => array(
56
+ 'publish_posts' => array('administrator', 'editor', 'author'),
57
+ 'edit_posts' => array('administrator', 'editor', 'author', 'contributor'),
58
+ 'delete_posts' => array('administrator', 'editor', 'author', 'contributor'),
59
+ 'edit_published_posts' => array('administrator', 'editor', 'author'),
60
+ 'delete_published_posts' => array('administrator', 'editor', 'author'),
61
+ 'edit_others_posts' => array('administrator', 'editor'),
62
+ 'delete_others_posts' => array('administrator', 'editor'),
63
+ 'read_private_posts' => array('administrator', 'editor'),
64
+ 'edit_private_posts' => array('administrator', 'editor'),
65
+ 'delete_private_posts' => array('administrator', 'editor'),
66
+ 'manage_categories' => array('administrator', 'editor')
67
  ),
68
  'Media' => array(
69
+ 'upload_files' => array('administrator', 'editor', 'author'),
70
+ 'unfiltered_upload' => array('administrator')
71
  ),
72
  'Pages' => array(
73
+ 'publish_pages' => array('administrator', 'editor'),
74
+ 'edit_pages' => array('administrator', 'editor'),
75
+ 'delete_pages' => array('administrator', 'editor'),
76
+ 'edit_published_pages' => array('administrator', 'editor'),
77
+ 'delete_published_pages' => array('administrator', 'editor'),
78
+ 'edit_others_pages' => array('administrator', 'editor'),
79
+ 'delete_others_pages' => array('administrator', 'editor'),
80
+ 'read_private_pages' => array('administrator', 'editor'),
81
+ 'edit_private_pages' => array('administrator', 'editor'),
82
+ 'delete_private_pages' => array('administrator', 'editor')
83
  ),
84
  'Comments' => array(
85
+ 'edit_comment' => array(),
86
+ 'moderate_comments' => array('administrator', 'editor')
87
  ),
88
  'Themes' => array(
89
+ 'switch_themes' => array('administrator'),
90
+ 'edit_theme_options' => array('administrator'),
91
+ 'edit_themes' => array('administrator'),
92
+ 'delete_themes' => array('administrator'),
93
+ 'install_themes' => array('administrator'),
94
+ 'update_themes' => array('administrator')
95
  ),
96
  'Plugins' => array(
97
+ 'activate_plugins' => array('administrator'),
98
+ 'edit_plugins' => array('administrator'),
99
+ 'install_plugins' => array('administrator'),
100
+ 'update_plugins' => array('administrator'),
101
+ 'delete_plugins' => array('administrator')
102
  ),
103
  'Users' => array(
104
+ 'list_users' => array('administrator'),
105
+ 'create_users' => array('administrator'),
106
+ 'edit_users' => array('administrator'),
107
+ 'delete_users' => array('administrator'),
108
+ 'promote_users' => array('administrator'),
109
+ 'add_users' => array('administrator'),
110
+ 'remove_users' => array('administrator')
111
  ),
112
  'Tools' => array(
113
+ 'import' => array('administrator'),
114
+ 'export' => array('administrator')
115
  ),
116
  'Admin' => array(
117
+ 'manage_options' => array('administrator'),
118
+ 'update_core' => array('administrator'),
119
+ 'unfiltered_html' => array('administrator', 'editor')
120
  ),
121
  'Links' => array(
122
+ 'manage_links' => array('administrator', 'editor')
123
  )
124
  );
125
  public static $DEPRECATED_CAPABILITIES = array(
126
  'Deprecated' => array(
127
+ 'edit_files' => array('administrator'),
128
+ 'level_0' => array('administrator', 'editor', 'author', 'contributor', 'subscriber'),
129
+ 'level_1' => array('administrator', 'editor', 'author', 'contributor'),
130
+ 'level_2' => array('administrator', 'editor', 'author'),
131
+ 'level_3' => array('administrator', 'editor'),
132
+ 'level_4' => array('administrator', 'editor'),
133
+ 'level_5' => array('administrator', 'editor'),
134
+ 'level_6' => array('administrator', 'editor'),
135
+ 'level_7' => array('administrator', 'editor'),
136
+ 'level_8' => array('administrator'),
137
+ 'level_9' => array('administrator'),
138
+ 'level_10' => array('administrator')
139
  )
140
  );
141
  public static $OTHER_CAPABILITIES = array(
145
  private static $CAPABILITIES = NULL;
146
  //Variables
147
  protected $options;
148
+ protected $objList;
149
+ protected $objAddEdit;
150
+ protected $objRestore;
151
+ protected $objAssignUsers;
152
 
153
  function __construct() {
154
  parent::__construct(__FILE__, self::PLUGIN_SLUG);
155
 
156
  $this->add_menu($this->__('WPFront User Role Editor'), $this->__('User Role Editor'));
157
+
158
+ $this->objList = new WPFront_User_Role_Editor_List($this);
159
+ $this->objAddEdit = new WPFront_User_Role_Editor_Add_Edit($this);
160
+ $this->objRestore = new WPFront_User_Role_Editor_Restore($this);
161
+ $this->objAssignUsers = new WPFront_User_Role_Editor_Assign_Roles($this);
162
  }
163
 
164
  public function plugins_loaded() {
174
  register_setting(self::OPTIONS_GROUP_NAME, self::OPTION_NAME);
175
 
176
  add_action('wp_ajax_wpfront_user_role_editor_update_options', array($this, 'update_options_callback'));
177
+
178
+ $this->objAddEdit->ajax_register();
179
+ $this->objRestore->ajax_register();
180
  }
181
 
182
  public function admin_menu() {
185
  $menu_slug = WPFront_User_Role_Editor_List::MENU_SLUG;
186
  add_menu_page($this->__('Roles'), $this->__('Roles'), $this->get_capability_string('list'), $menu_slug, null, $this->pluginURL() . 'images/roles_menu.png', '69.9999');
187
 
188
+ $page_hook_suffix = add_submenu_page($menu_slug, $this->__('Roles'), $this->__('All Roles'), $this->get_capability_string('list'), $menu_slug, array($this->objList, 'list_roles'));
189
+ add_action('admin_print_scripts-' . $page_hook_suffix, array($this, 'enqueue_role_scripts'));
190
+ add_action('admin_print_styles-' . $page_hook_suffix, array($this, 'enqueue_role_styles'));
191
+
192
+ $page_hook_suffix = add_submenu_page($menu_slug, $this->__('Add New Role'), $this->__('Add New'), $this->get_capability_string('create'), WPFront_User_Role_Editor_Add_Edit::MENU_SLUG, array($this->objAddEdit, 'add_edit_role'));
193
+ add_action('admin_print_scripts-' . $page_hook_suffix, array($this, 'enqueue_role_scripts'));
194
+ add_action('admin_print_styles-' . $page_hook_suffix, array($this, 'enqueue_role_styles'));
195
 
196
+ $page_hook_suffix = add_submenu_page($menu_slug, $this->__('Restore Role'), $this->__('Restore'), $this->get_capability_string('edit'), WPFront_User_Role_Editor_Restore::MENU_SLUG, array($this->objRestore, 'restore_role'));
197
+ add_action('admin_print_scripts-' . $page_hook_suffix, array($this, 'enqueue_role_scripts'));
198
+ add_action('admin_print_styles-' . $page_hook_suffix, array($this, 'enqueue_role_styles'));
199
+
200
+ $page_hook_suffix = add_users_page($this->__('Assign Roles | Migrate Users'), $this->__('Assign / Migrate'), 'promote_user', WPFront_User_Role_Editor_Assign_Roles::MENU_SLUG, array($this->objAssignUsers, 'assign_roles'));
201
+ add_action('admin_print_scripts-' . $page_hook_suffix, array($this, 'enqueue_role_scripts'));
202
+ add_action('admin_print_styles-' . $page_hook_suffix, array($this, 'enqueue_role_styles'));
203
  }
204
 
205
  //add scripts
206
+ public function enqueue_role_scripts() {
207
  // $jsRoot = $this->pluginURLRoot . 'js/';
208
 
209
  wp_enqueue_script('jquery');
210
  }
211
 
212
  //add styles
213
+ public function enqueue_role_styles() {
214
+ wp_enqueue_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css', array(), '4.1.0');
215
  $styleRoot = $this->pluginURLRoot . 'css/';
216
  wp_enqueue_style('wpfront-user-role-editor-styles', $styleRoot . 'style.css', array(), self::VERSION);
217
  }
218
 
219
  //options page scripts
220
  public function enqueue_options_scripts() {
221
+ $this->enqueue_role_scripts();
222
  }
223
 
224
  //options page styles
225
  public function enqueue_options_styles() {
226
+ $this->enqueue_role_styles();
227
 
228
  $styleRoot = $this->pluginURLRoot . 'css/';
229
  wp_enqueue_style('wpfront-user-role-editor-options', $styleRoot . 'options.css', array(), self::VERSION);
329
  self::$CAPABILITIES = array();
330
 
331
  foreach (self::$STANDARD_CAPABILITIES as $key => $value) {
332
+ self::$CAPABILITIES[$key] = array();
333
+ foreach ($value as $cap => $roles) {
334
+ self::$CAPABILITIES[$key][] = $cap;
335
+ }
336
  }
337
 
338
  foreach (self::$DEPRECATED_CAPABILITIES as $key => $value) {
339
+ self::$CAPABILITIES[$key] = array();
340
+ foreach ($value as $cap => $roles) {
341
+ self::$CAPABILITIES[$key][] = $cap;
342
+ }
343
  }
344
 
345
  if ($this->options->enable_role_capabilities())
376
  return $this->options->display_deprecated();
377
  }
378
 
379
+ public function enable_role_capabilities() {
380
+ return $this->options->enable_role_capabilities();
381
+ }
382
+
383
+ public function remove_nonstandard_capabilities_restore() {
384
+ return $this->options->remove_nonstandard_capabilities_restore();
385
+ }
386
+
387
  }
388
 
389
  }
css/style.css CHANGED
@@ -95,4 +95,14 @@ div.role-add-new div.metabox-holder div.postbox div.main img.help {
95
 
96
  div.role-add-new div.footer {
97
  text-align: center;
98
- }
 
 
 
 
 
 
 
 
 
 
95
 
96
  div.role-add-new div.footer {
97
  text-align: center;
98
+ }
99
+
100
+ div.role-restore table.form-table td div.restore-role-button-container,
101
+ div.role-restore table.form-table td div.restore-role-loader,
102
+ div.role-restore table.form-table td div.restore-role-success {
103
+ display: none;
104
+ }
105
+
106
+ div.wrap.assign-roles div.role-list div.role-list-item {
107
+ padding-bottom: 5px;
108
+ }
images/loading.gif ADDED
Binary file
languages/wpfront-user-role-editor.mo CHANGED
Binary file
languages/wpfront-user-role-editor.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WPFront Notification Bar\n"
4
- "POT-Creation-Date: 2014-04-30 18:53-0700\n"
5
- "PO-Revision-Date: 2014-04-30 18:54-0700\n"
6
  "Last-Translator: \n"
7
  "Language-Team: WPFront <contact@wpfront.com>\n"
8
  "Language: en\n"
@@ -96,7 +96,7 @@ msgid "Activate"
96
  msgstr "Activate"
97
 
98
  #: ../classes/base/class-wpfront-base-menu.php:199
99
- #: ../classes/class-wpfront-user-role-editor.php:298
100
  msgid "Feedback"
101
  msgstr "Feedback"
102
 
@@ -109,7 +109,7 @@ msgid "All Plugins"
109
  msgstr "All Plugins"
110
 
111
  #: ../classes/base/class-wpfront-base.php:130
112
- #: ../classes/class-wpfront-user-role-editor.php:248
113
  msgid "You do not have sufficient permissions to access this page."
114
  msgstr "You do not have sufficient permissions to access this page."
115
 
@@ -142,13 +142,57 @@ msgid "Write Review"
142
  msgstr "Write Review"
143
 
144
  #: ../classes/base/class-wpfront-base.php:178
145
- msgid "Contact Me (syam@wpfront.com)"
146
- msgstr "Contact Me (syam@wpfront.com)"
147
 
148
- #: ../classes/base/class-wpfront-base.php:195
 
 
 
 
149
  msgid "Save Changes"
150
  msgstr "Save Changes"
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  #: ../classes/class-wpfront-user-role-editor-list.php:238
153
  #: ../templates/add-edit-role.php:111
154
  msgid "Select All"
@@ -230,35 +274,62 @@ msgstr "Display Deprecated Capabilities"
230
  msgid "Add Role Capabilities"
231
  msgstr "Add Role Capabilities"
232
 
233
- #: ../classes/class-wpfront-user-role-editor.php:150
 
 
 
 
 
 
 
 
 
234
  msgid "WPFront User Role Editor"
235
  msgstr "WPFront User Role Editor"
236
 
237
- #: ../classes/class-wpfront-user-role-editor.php:150
238
  msgid "User Role Editor"
239
  msgstr "User Role Editor"
240
 
241
- #: ../classes/class-wpfront-user-role-editor.php:175
242
- #: ../classes/class-wpfront-user-role-editor.php:177
243
  #: ../templates/list-roles.php:37
244
  msgid "Roles"
245
  msgstr "Roles"
246
 
247
- #: ../classes/class-wpfront-user-role-editor.php:177
248
  msgid "All Roles"
249
  msgstr "All Roles"
250
 
251
- #: ../classes/class-wpfront-user-role-editor.php:181
252
  #: ../templates/add-edit-role.php:35 ../templates/add-edit-role.php:154
253
  msgid "Add New Role"
254
  msgstr "Add New Role"
255
 
256
- #: ../classes/class-wpfront-user-role-editor.php:181
257
  #: ../templates/add-edit-role.php:37 ../templates/list-roles.php:40
258
  msgid "Add New"
259
  msgstr "Add New"
260
 
261
- #: ../classes/class-wpfront-user-role-editor.php:300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  msgid "Buy me a Beer"
263
  msgstr "Buy me a Beer"
264
 
@@ -266,10 +337,6 @@ msgstr "Buy me a Beer"
266
  msgid "Edit Role"
267
  msgstr "Edit Role"
268
 
269
- #: ../templates/add-edit-role.php:45 ../templates/add-edit-role.php:53
270
- msgid "ERROR"
271
- msgstr "ERROR"
272
-
273
  #: ../templates/add-edit-role.php:45
274
  msgid "This role already exists in this site."
275
  msgstr "This role already exists in this site."
@@ -298,6 +365,18 @@ msgstr "Select None"
298
  msgid "Update Role"
299
  msgstr "Update Role"
300
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  #: ../templates/delete-role.php:37
302
  msgid "Delete Roles"
303
  msgstr "Delete Roles"
@@ -334,6 +413,21 @@ msgstr "Default"
334
  msgid "WPFront User Role Editor Settings"
335
  msgstr "WPFront User Role Editor Settings"
336
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
  #~ msgid "Enabled"
338
  #~ msgstr "Enabled"
339
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WPFront Notification Bar\n"
4
+ "POT-Creation-Date: 2014-08-16 12:20-0700\n"
5
+ "PO-Revision-Date: 2014-08-16 12:20-0700\n"
6
  "Last-Translator: \n"
7
  "Language-Team: WPFront <contact@wpfront.com>\n"
8
  "Language: en\n"
96
  msgstr "Activate"
97
 
98
  #: ../classes/base/class-wpfront-base-menu.php:199
99
+ #: ../classes/class-wpfront-user-role-editor.php:318
100
  msgid "Feedback"
101
  msgstr "Feedback"
102
 
109
  msgstr "All Plugins"
110
 
111
  #: ../classes/base/class-wpfront-base.php:130
112
+ #: ../classes/class-wpfront-user-role-editor.php:268
113
  msgid "You do not have sufficient permissions to access this page."
114
  msgstr "You do not have sufficient permissions to access this page."
115
 
142
  msgstr "Write Review"
143
 
144
  #: ../classes/base/class-wpfront-base.php:178
145
+ msgid "Contact Me"
146
+ msgstr "Contact Me"
147
 
148
+ #: ../classes/base/class-wpfront-base.php:180
149
+ msgid "Buy me a Beer or Coffee"
150
+ msgstr "Buy me a Beer or Coffee"
151
+
152
+ #: ../classes/base/class-wpfront-base.php:197
153
  msgid "Save Changes"
154
  msgstr "Save Changes"
155
 
156
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:60
157
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:276
158
+ msgid "Secondary Roles"
159
+ msgstr "Secondary Roles"
160
+
161
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:75
162
+ #: ../templates/assign-roles.php:36
163
+ msgid "Assign Roles"
164
+ msgstr "Assign Roles"
165
+
166
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:122
167
+ msgid "No role for this site"
168
+ msgstr "No role for this site"
169
+
170
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:138
171
+ msgid "Invalid user."
172
+ msgstr "Invalid user."
173
+
174
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:164
175
+ msgid "Roles updated successfully."
176
+ msgstr "Roles updated successfully."
177
+
178
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:166
179
+ msgid "Invalid primary role specified."
180
+ msgstr "Invalid primary role specified."
181
+
182
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:184
183
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:194
184
+ msgid "Invalid primary role."
185
+ msgstr "Invalid primary role."
186
+
187
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:214
188
+ #, php-format
189
+ msgid "%d user(s) migrated."
190
+ msgstr "%d user(s) migrated."
191
+
192
+ #: ../classes/class-wpfront-user-role-editor-assign-roles.php:257
193
+ msgid "Primary Role"
194
+ msgstr "Primary Role"
195
+
196
  #: ../classes/class-wpfront-user-role-editor-list.php:238
197
  #: ../templates/add-edit-role.php:111
198
  msgid "Select All"
274
  msgid "Add Role Capabilities"
275
  msgstr "Add Role Capabilities"
276
 
277
+ #: ../classes/class-wpfront-user-role-editor-options.php:43
278
+ msgid "Remove Non-Standard Capabilities on Restore"
279
+ msgstr "Remove Non-Standard Capabilities on Restore"
280
+
281
+ #: ../classes/class-wpfront-user-role-editor-restore.php:134
282
+ #: ../templates/add-edit-role.php:45 ../templates/add-edit-role.php:53
283
+ msgid "ERROR"
284
+ msgstr "ERROR"
285
+
286
+ #: ../classes/class-wpfront-user-role-editor.php:156
287
  msgid "WPFront User Role Editor"
288
  msgstr "WPFront User Role Editor"
289
 
290
+ #: ../classes/class-wpfront-user-role-editor.php:156
291
  msgid "User Role Editor"
292
  msgstr "User Role Editor"
293
 
294
+ #: ../classes/class-wpfront-user-role-editor.php:186
295
+ #: ../classes/class-wpfront-user-role-editor.php:188
296
  #: ../templates/list-roles.php:37
297
  msgid "Roles"
298
  msgstr "Roles"
299
 
300
+ #: ../classes/class-wpfront-user-role-editor.php:188
301
  msgid "All Roles"
302
  msgstr "All Roles"
303
 
304
+ #: ../classes/class-wpfront-user-role-editor.php:192
305
  #: ../templates/add-edit-role.php:35 ../templates/add-edit-role.php:154
306
  msgid "Add New Role"
307
  msgstr "Add New Role"
308
 
309
+ #: ../classes/class-wpfront-user-role-editor.php:192
310
  #: ../templates/add-edit-role.php:37 ../templates/list-roles.php:40
311
  msgid "Add New"
312
  msgstr "Add New"
313
 
314
+ #: ../classes/class-wpfront-user-role-editor.php:196
315
+ #: ../templates/restore-role.php:34
316
+ msgid "Restore Role"
317
+ msgstr "Restore Role"
318
+
319
+ #: ../classes/class-wpfront-user-role-editor.php:196
320
+ #: ../templates/restore-role.php:46
321
+ msgid "Restore"
322
+ msgstr "Restore"
323
+
324
+ #: ../classes/class-wpfront-user-role-editor.php:200
325
+ msgid "Assign Roles | Migrate Users"
326
+ msgstr "Assign Roles | Migrate Users"
327
+
328
+ #: ../classes/class-wpfront-user-role-editor.php:200
329
+ msgid "Assign / Migrate"
330
+ msgstr "Assign / Migrate"
331
+
332
+ #: ../classes/class-wpfront-user-role-editor.php:320
333
  msgid "Buy me a Beer"
334
  msgstr "Buy me a Beer"
335
 
337
  msgid "Edit Role"
338
  msgstr "Edit Role"
339
 
 
 
 
 
340
  #: ../templates/add-edit-role.php:45
341
  msgid "This role already exists in this site."
342
  msgstr "This role already exists in this site."
365
  msgid "Update Role"
366
  msgstr "Update Role"
367
 
368
+ #: ../templates/assign-roles.php:62
369
+ msgid "User"
370
+ msgstr "User"
371
+
372
+ #: ../templates/assign-roles.php:93
373
+ msgid "Migrate Users"
374
+ msgstr "Migrate Users"
375
+
376
+ #: ../templates/assign-roles.php:103
377
+ msgid "From Primary Role"
378
+ msgstr "From Primary Role"
379
+
380
  #: ../templates/delete-role.php:37
381
  msgid "Delete Roles"
382
  msgstr "Delete Roles"
413
  msgid "WPFront User Role Editor Settings"
414
  msgstr "WPFront User Role Editor Settings"
415
 
416
+ #: ../templates/restore-role.php:48
417
+ msgid "Cancel"
418
+ msgstr "Cancel"
419
+
420
+ #: ../templates/restore-role.php:49
421
+ msgid "Confirm"
422
+ msgstr "Confirm"
423
+
424
+ #: ../templates/restore-role.php:57
425
+ msgid "Restored"
426
+ msgstr "Restored"
427
+
428
+ #~ msgid "Contact Me (syam@wpfront.com)"
429
+ #~ msgstr "Contact Me (syam@wpfront.com)"
430
+
431
  #~ msgid "Enabled"
432
  #~ msgstr "Enabled"
433
 
readme.txt CHANGED
@@ -3,15 +3,15 @@ Contributors: syammohanm
3
  Donate link: http://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
5
  Requires at least: 3.5
6
- Tested up to: 3.9.1
7
- Stable tag: 1.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
  Easily allows you to manage user roles. You can create, edit, delete and manage capabilities, also copy existing roles.
12
 
13
  == Description ==
14
- This plugin allows you to easily manage user roles within your wordpress site.
15
  You can create, edit or delete user roles and manage role capabilities.
16
 
17
  ### Features
@@ -21,6 +21,9 @@ You can create, edit or delete user roles and manage role capabilities.
21
  * Manage capabilities.
22
  * Allows you to add role capabilities.
23
  * Change default user role.
 
 
 
24
 
25
  Visit [WPFront User Role Editor](http://wpfront.com/user-role-editor-plugin/) page for screens and functionalities.
26
 
@@ -40,19 +43,26 @@ Visit [WPFront User Role Editor Settings](http://wpfront.com/user-role-editor-pl
40
 
41
  == Frequently Asked Questions ==
42
 
43
- = Unchecking “Add Role Capabilities” setting, what difference does it make? =
44
-
45
- “Add Role Capabilities” allows you add role capabilities to be set as part of the capabilities. Unchecking this setting will make the plugin work using the “user capabilities”, also it will remove all the role capabilities added to the existing roles. If you check this option again you will have to go back to each role and add the capabilities again, except for “Administrator” role.
46
 
47
  == Screenshots ==
48
 
49
- 1. Role list
50
  2. Add new role
51
  3. Edit role
52
- 4. Global settings
 
53
 
54
  == Changelog ==
55
 
 
 
 
 
 
 
 
 
56
  = 1.1 =
57
  * Edit deprecated capabilities
58
 
@@ -68,6 +78,13 @@ Visit [WPFront User Role Editor Settings](http://wpfront.com/user-role-editor-pl
68
 
69
  == Upgrade Notice ==
70
 
 
 
 
 
 
 
 
71
  = 1.1 =
72
  * Can edit deprecated capabilities now
73
 
3
  Donate link: http://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
5
  Requires at least: 3.5
6
+ Tested up to: 3.9.2
7
+ Stable tag: 1.3
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
  Easily allows you to manage user roles. You can create, edit, delete and manage capabilities, also copy existing roles.
12
 
13
  == Description ==
14
+ This plugin allows you to easily manage user roles within your WordPress site.
15
  You can create, edit or delete user roles and manage role capabilities.
16
 
17
  ### Features
21
  * Manage capabilities.
22
  * Allows you to add role capabilities.
23
  * Change default user role.
24
+ * Restore role.
25
+ * Assign multiple roles.
26
+ * Migrate users.
27
 
28
  Visit [WPFront User Role Editor](http://wpfront.com/user-role-editor-plugin/) page for screens and functionalities.
29
 
43
 
44
  == Frequently Asked Questions ==
45
 
46
+ Please visit [WPFront User Role Editor FAQ](http://wpfront.com/wordpress-plugins/user-role-editor-plugin/user-role-editor-plugin-faq/).
 
 
47
 
48
  == Screenshots ==
49
 
50
+ 1. Roles list
51
  2. Add new role
52
  3. Edit role
53
+ 4. Restore role
54
+ 5. Global settings
55
 
56
  == Changelog ==
57
 
58
+ = 1.3 =
59
+ * Assign multiple roles
60
+ * Migrate users
61
+
62
+ = 1.2 =
63
+ * Restore role
64
+ * Bug fixes
65
+
66
  = 1.1 =
67
  * Edit deprecated capabilities
68
 
78
 
79
  == Upgrade Notice ==
80
 
81
+ = 1.3 =
82
+ * Now you can assign multiple roles to a user
83
+ * Migrate users from role to role
84
+
85
+ = 1.2 =
86
+ * Now you can restore roles
87
+
88
  = 1.1 =
89
  * Can edit deprecated capabilities now
90
 
templates/assign-roles.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Template for WPFront User Role Editor List Roles
26
+ *
27
+ * @author Syam Mohan <syam@wpfront.com>
28
+ * @copyright 2014 WPFront.com
29
+ */
30
+ ?>
31
+
32
+ <?php $this->main->verify_nonce(); ?>
33
+
34
+ <div class="wrap assign-roles">
35
+ <h2 id="assign-roles">
36
+ <?php echo $this->__('Assign Roles'); ?>
37
+ </h2>
38
+
39
+ <?php
40
+ if ($this->result != NULL) {
41
+ if ($this->result->success) {
42
+ ?>
43
+ <div class="updated">
44
+ <p><?php echo $this->result->message; ?></p>
45
+ </div>
46
+ <?php } else { ?>
47
+
48
+ <div class="error">
49
+ <p><?php echo $this->result->message; ?></p>
50
+ </div>
51
+ <?php
52
+ }
53
+ }
54
+ ?>
55
+
56
+ <form method="POST">
57
+ <?php $this->main->create_nonce(); ?>
58
+ <table class="form-table">
59
+ <tbody>
60
+ <tr>
61
+ <th scope="row">
62
+ <?php echo $this->__('User'); ?>
63
+ </th>
64
+ <td>
65
+ <select id="assign_users_list" name="assign-user">
66
+ <?php
67
+ foreach ($this->users as $user) {
68
+ $select = FALSE;
69
+ if ($this->user != NULL && $this->user->ID == $user->ID)
70
+ $select = TRUE;
71
+ ?>
72
+ <option <?php echo $select ? 'selected' : ''; ?> value="<?php echo $user->ID; ?>">
73
+ <?php echo $user->display_name; ?>
74
+ </option>
75
+ <?php
76
+ }
77
+ ?>
78
+ </select>
79
+ </td>
80
+ </tr>
81
+
82
+ <?php $this->primary_secondary_section('assign', $this->userPrimaryRole, $this->userSecondaryRoles); ?>
83
+
84
+ </tbody>
85
+ </table>
86
+
87
+ <p class="submit">
88
+ <input type="submit" name="assignroles" id="assignroles" class="button button-primary" value="Assign Roles" />
89
+ </p>
90
+ </form>
91
+
92
+ <h2 id="migrate-users">
93
+ <?php echo $this->__('Migrate Users'); ?>
94
+ </h2>
95
+
96
+ <form method="POST">
97
+ <?php $this->main->create_nonce(); ?>
98
+
99
+ <table class="form-table">
100
+ <tbody>
101
+ <tr>
102
+ <th scope="row">
103
+ <?php echo $this->__('From Primary Role'); ?>
104
+ </th>
105
+ <td>
106
+ <select id="migrate_from_role" name="migrate-from-primary-role">
107
+ <?php
108
+ foreach ($this->primary_roles as $key => $role) {
109
+ ?>
110
+ <option value="<?php echo $key; ?>" <?php echo $this->migrateFromPrimaryRole === $key ? 'selected' : ''; ?>>
111
+ <?php echo $role; ?>
112
+ </option>
113
+ <?php
114
+ }
115
+ ?>
116
+ </select>
117
+ </td>
118
+ </tr>
119
+
120
+ <?php $this->primary_secondary_section('migrate', $this->migrateToPrimaryRole, $this->migrateToSecondaryRoles); ?>
121
+
122
+ </tbody>
123
+ </table>
124
+
125
+ <p class="submit">
126
+ <input type="submit" name="migrateroles" id="migrateroles" class="button button-primary" value="Migrate Users" />
127
+ </p>
128
+ </form>
129
+
130
+ </div>
131
+
132
+ <script type="text/javascript">
133
+
134
+ (function($) {
135
+
136
+ var page_url = '<?php echo $this->get_assign_role_url(); ?>';
137
+
138
+ $('#assign_users_list').change(function() {
139
+ window.location.replace(page_url + $(this).val());
140
+ });
141
+
142
+ $('#assign_roles_list, #migrate_roles_list').change(function() {
143
+ var $this = $(this);
144
+ if ($this.val() == '') {
145
+ $this.closest('table').find('div.role-list-item input').prop('disabled', true);
146
+ }
147
+ else {
148
+ $this.closest('table').find('div.role-list-item input').prop('disabled', false);
149
+ }
150
+ }).change();
151
+
152
+ })(jQuery);
153
+
154
+ </script>
templates/list-roles.php CHANGED
@@ -60,7 +60,7 @@
60
  <?php $this->main->create_nonce(); ?>
61
  <p class = "search-box">
62
  <label class = "screen-reader-text" for = "role-search-input"><?php echo $this->__('Search Roles') . ':'; ?></label>
63
- <input type="search" id="role-search-input" name="search" value="<?php echo $this->get_search_term(); ?>">
64
  <input type="submit" name="search-submit" id="search-submit" class="button" value="<?php echo $this->__('Search Roles'); ?>">
65
  </p>
66
  <?php $this->bulk_actions('top'); ?>
60
  <?php $this->main->create_nonce(); ?>
61
  <p class = "search-box">
62
  <label class = "screen-reader-text" for = "role-search-input"><?php echo $this->__('Search Roles') . ':'; ?></label>
63
+ <input type="search" id="role-search-input" name="s" value="<?php echo $this->get_search_term(); ?>">
64
  <input type="submit" name="search-submit" id="search-submit" class="button" value="<?php echo $this->__('Search Roles'); ?>">
65
  </p>
66
  <?php $this->bulk_actions('top'); ?>
templates/options-template.php CHANGED
@@ -48,6 +48,14 @@
48
  <input type="checkbox" name="<?php echo $this->options->enable_role_capabilities_name(); ?>" <?php echo $this->options->enable_role_capabilities() ? 'checked' : ''; ?> />
49
  </td>
50
  </tr>
 
 
 
 
 
 
 
 
51
  </table>
52
 
53
  <input type="hidden" name="nonce" value="<?php echo wp_create_nonce($_SERVER['REQUEST_URI']); ?>" />
48
  <input type="checkbox" name="<?php echo $this->options->enable_role_capabilities_name(); ?>" <?php echo $this->options->enable_role_capabilities() ? 'checked' : ''; ?> />
49
  </td>
50
  </tr>
51
+ <tr>
52
+ <th scope="row">
53
+ <?php echo $this->options->remove_nonstandard_capabilities_restore_label(); ?>
54
+ </th>
55
+ <td>
56
+ <input type="checkbox" name="<?php echo $this->options->remove_nonstandard_capabilities_restore_name(); ?>" <?php echo $this->options->remove_nonstandard_capabilities_restore() ? 'checked' : ''; ?> />
57
+ </td>
58
+ </tr>
59
  </table>
60
 
61
  <input type="hidden" name="nonce" value="<?php echo wp_create_nonce($_SERVER['REQUEST_URI']); ?>" />
templates/restore-role.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Template for WPFront User Role Editor Restore Role
26
+ *
27
+ * @author Syam Mohan <syam@wpfront.com>
28
+ * @copyright 2014 WPFront.com
29
+ */
30
+ ?>
31
+
32
+ <div class="wrap role-restore">
33
+ <h2 id="restore-role">
34
+ <?php echo $this->__('Restore Role'); ?>
35
+ </h2>
36
+
37
+ <table class="form-table">
38
+ <tbody>
39
+ <?php foreach ($this->roles as $key => $value) {
40
+ ?>
41
+ <tr class="form-field">
42
+ <th scope="row">
43
+ <?php echo $value; ?>
44
+ </th>
45
+ <td>
46
+ <button class="button button-primary restore-role" value="<?php echo $key; ?>"><?php echo $this->__('Restore'); ?></button>
47
+ <div class="restore-role-button-container">
48
+ <button class="button restore-role-cancel" value="<?php echo $key; ?>"><?php echo $this->__('Cancel'); ?></button>
49
+ <button class="button restore-role-confirm" value="<?php echo $key; ?>"><?php echo $this->__('Confirm'); ?></button>
50
+ </div>
51
+ <div class="restore-role-loader">
52
+ <img src="<?php echo $this->image_url() . 'loading.gif'; ?>" />
53
+ </div>
54
+ <div class="restore-role-success">
55
+ <button class="button button" disabled="true">
56
+ <i class="fa fa-check fa-1"></i>
57
+ <?php echo $this->__('Restored'); ?>
58
+ </button>
59
+ </div>
60
+ </td>
61
+ </tr>
62
+ <?php }
63
+ ?>
64
+
65
+ </tbody>
66
+ </table>
67
+ </div>
68
+
69
+ <script type="text/javascript">
70
+ (function($) {
71
+ $('button.restore-role').click(function() {
72
+ $(this).hide().next().show();
73
+ });
74
+
75
+ $('button.restore-role-cancel').click(function() {
76
+ $(this).parent().hide().prev().show();
77
+ });
78
+
79
+ $('button.restore-role-confirm').click(function() {
80
+ var _this = $(this).parent().hide().next().show();
81
+
82
+ var data = {
83
+ "action": "wpfront_user_role_editor_restore_role",
84
+ "role": $(this).val()
85
+ };
86
+
87
+ $.post(ajaxurl, data, function(response) {
88
+ _this.hide();
89
+ if (response.result)
90
+ _this.next().show();
91
+ else
92
+ _this.next().text(response.message).css('color', 'Red').show();
93
+ }, 'json');
94
+ });
95
+ })(jQuery);
96
+ </script>
wpfront-user-role-editor.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WPFront User Role Editor
4
  * Plugin URI: http://wpfront.com/user-role-editor-plugin/
5
  * Description: Allows you to manage user roles.
6
- * Version: 1.1
7
  * Author: Syam Mohan
8
  * Author URI: http://wpfront.com
9
  * License: GPL v3
3
  * Plugin Name: WPFront User Role Editor
4
  * Plugin URI: http://wpfront.com/user-role-editor-plugin/
5
  * Description: Allows you to manage user roles.
6
+ * Version: 1.3
7
  * Author: Syam Mohan
8
  * Author URI: http://wpfront.com
9
  * License: GPL v3