Advanced Access Manager - Version 3.9

Version Description

  • Fixed UI bug with role list
  • Fixed core bug with max user level
  • Fixed bug with CodePinch installation page
  • Added native user switch functionality
Download this release

Release Info

Developer vasyl_m
Plugin Icon 128x128 Advanced Access Manager
Version 3.9
Comparing to
See all releases

Code changes from version 3.8.3 to 3.9

Application/Backend/Feature/ProductList.php CHANGED
@@ -102,12 +102,5 @@ return array(
102
  'type' => 'plugin',
103
  'description' => 'Development tool with an easy way to manage all your website custom settings. <a href="https://vasyltech.com/config-press" target="_blank">Read more.</a>',
104
  'status' => AAM_Core_Repository::getInstance()->pluginStatus('ConfigPress')
105
- ),
106
- array(
107
- 'title' => 'User Switching',
108
- 'id' => 'User Switching',
109
- 'type' => 'plugin',
110
- 'description' => 'Instant switching between user accounts in WordPress.',
111
- 'status' => AAM_Core_Repository::getInstance()->pluginStatus('User Switching')
112
  )
113
  );
102
  'type' => 'plugin',
103
  'description' => 'Development tool with an easy way to manage all your website custom settings. <a href="https://vasyltech.com/config-press" target="_blank">Read more.</a>',
104
  'status' => AAM_Core_Repository::getInstance()->pluginStatus('ConfigPress')
 
 
 
 
 
 
 
105
  )
106
  );
Application/Backend/Feature/User.php CHANGED
@@ -98,25 +98,16 @@ class AAM_Backend_Feature_User {
98
  protected function prepareRowActions(WP_User $user) {
99
  $max = AAM_Core_API::maxLevel(wp_get_current_user()->allcaps);
100
 
101
- if ($max < AAM_Core_API::maxLevel($user->allcaps)) {
102
- $actions = array('no-manage', 'no-lock', 'no-edit');
103
- } else {
104
  $actions = array('manage');
105
-
106
- $prefix = ($user->ID == get_current_user_id() ? 'no-' : '');
107
 
108
- $actions[] = $prefix . ($user->user_status ? 'unlock' : 'lock');
109
  $actions[] = 'edit';
110
- }
111
-
112
- if (class_exists('user_switching')) {
113
- $url = user_switching::maybe_switch_url($user);
114
-
115
- if (!in_array('edit', $actions) || empty($url)) {
116
- $actions[] = 'no-switch';
117
- } else {
118
- $actions[] = 'switch|' . $url;
119
- }
120
  }
121
 
122
  return $actions;
98
  protected function prepareRowActions(WP_User $user) {
99
  $max = AAM_Core_API::maxLevel(wp_get_current_user()->allcaps);
100
 
101
+ $allowed = ($max > AAM_Core_API::maxLevel($user->allcaps));
102
+
103
+ if ($allowed || ($user->ID == get_current_user_id())) {
104
  $actions = array('manage');
 
 
105
 
106
+ $actions[] = ($user->user_status ? 'unlock' : 'lock');
107
  $actions[] = 'edit';
108
+ $actions[] = 'switch';
109
+ } else {
110
+ $actions = array('no-manage', 'no-lock', 'no-edit' , 'no-switch');
 
 
 
 
 
 
 
111
  }
112
 
113
  return $actions;
Application/Backend/Manager.php CHANGED
@@ -32,6 +32,9 @@ class AAM_Backend_Manager {
32
  * @access protected
33
  */
34
  protected function __construct() {
 
 
 
35
  //print required JS & CSS
36
  add_action('admin_print_scripts', array($this, 'printJavascript'));
37
  add_action('admin_print_styles', array($this, 'printStylesheet'));
@@ -42,6 +45,7 @@ class AAM_Backend_Manager {
42
  add_action('network_admin_menu', array($this, 'adminMenu'), 999);
43
  } else {
44
  add_action('admin_menu', array($this, 'adminMenu'), 999);
 
45
  }
46
 
47
  //manager AAM Ajax Requests
@@ -83,6 +87,28 @@ class AAM_Backend_Manager {
83
  AAM_Backend_View_CodePinch::bootstrap(AAM_CODEPINCH_AFFILIATE_CODE);
84
  }
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  /**
87
  *
88
  */
@@ -129,6 +155,31 @@ class AAM_Backend_Manager {
129
  }
130
  }
131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  /**
133
  *
134
  */
32
  * @access protected
33
  */
34
  protected function __construct() {
35
+ //check if user switch is required
36
+ $this->checkUserSwitch();
37
+
38
  //print required JS & CSS
39
  add_action('admin_print_scripts', array($this, 'printJavascript'));
40
  add_action('admin_print_styles', array($this, 'printStylesheet'));
45
  add_action('network_admin_menu', array($this, 'adminMenu'), 999);
46
  } else {
47
  add_action('admin_menu', array($this, 'adminMenu'), 999);
48
+ add_action('all_admin_notices', array($this, 'notification'));
49
  }
50
 
51
  //manager AAM Ajax Requests
87
  AAM_Backend_View_CodePinch::bootstrap(AAM_CODEPINCH_AFFILIATE_CODE);
88
  }
89
 
90
+ /**
91
+ *
92
+ */
93
+ protected function checkUserSwitch() {
94
+ if (AAM_Core_Request::get('action') == 'aam-switch-back') {
95
+ $current = get_current_user_id();
96
+ $uid = AAM_Core_API::getOption('aam-user-switch-' . $current);
97
+ $redirect = admin_url('admin.php?page=aam&user=' . $current);
98
+
99
+ check_admin_referer('aam-switch-' . $uid);
100
+
101
+ wp_clear_auth_cookie();
102
+ wp_set_auth_cookie( $uid, true );
103
+ wp_set_current_user( $uid );
104
+
105
+ AAM_Core_API::deleteOption('aam-user-switch-' . $current);
106
+
107
+ wp_redirect($redirect);
108
+ exit;
109
+ }
110
+ }
111
+
112
  /**
113
  *
114
  */
155
  }
156
  }
157
 
158
+ /**
159
+ *
160
+ */
161
+ public function notification() {
162
+ $uid = AAM_Core_API::getOption('aam-user-switch-' . get_current_user_id());
163
+
164
+ if ($uid) {
165
+ //get user's name
166
+ $user = new WP_User($uid);
167
+ $name = $user->display_name ? $user->display_name : $user->user_nicename;
168
+
169
+ //generate switch back URL
170
+ $url = wp_nonce_url(
171
+ 'index.php?action=aam-switch-back', 'aam-switch-' . $uid
172
+ );
173
+
174
+ $style = 'padding: 10px; font-weight: 700; letter-spacing:0.5px;';
175
+
176
+ echo '<div class="updated notice">';
177
+ echo '<p style="' . $style . '">';
178
+ echo sprintf('Switch back to <a href="%s">%s</a>.', $url, $name);
179
+ echo '</p></div>';
180
+ }
181
+ }
182
+
183
  /**
184
  *
185
  */
Application/Backend/View.php CHANGED
@@ -185,6 +185,34 @@ class AAM_Backend_View {
185
  return json_encode(array('status' => ($result ? 'success' : 'failure')));
186
  }
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  /**
189
  * Get Subject
190
  *
185
  return json_encode(array('status' => ($result ? 'success' : 'failure')));
186
  }
187
 
188
+ /**
189
+ *
190
+ * @return type
191
+ */
192
+ public function switchToUser() {
193
+ $user = new WP_User(AAM_Core_Request::post('user'));
194
+ $max = AAM_Core_API::maxLevel(wp_get_current_user()->allcaps);
195
+
196
+ if ($max > AAM_Core_API::maxLevel($user->allcaps)) {
197
+ AAM_Core_API::updateOption(
198
+ 'aam-user-switch-' . $user->ID, get_current_user_id()
199
+ );
200
+
201
+ wp_clear_auth_cookie();
202
+ wp_set_auth_cookie( $user->ID, true );
203
+ wp_set_current_user( $user->ID );
204
+
205
+ $response = array('status' => 'success', 'redirect' => admin_url());
206
+ } else {
207
+ $response = array(
208
+ 'status' => 'failure',
209
+ 'reason' => 'You are not allowed to switch to this user'
210
+ );
211
+ }
212
+
213
+ return json_encode($response);
214
+ }
215
+
216
  /**
217
  * Get Subject
218
  *
Application/Backend/View/CodePinch.php CHANGED
@@ -27,6 +27,11 @@ class AAM_Backend_View_CodePinch {
27
  *
28
  */
29
  const PLUGIN_URL = 'https://downloads.wordpress.org/plugin/wp-error-fix.zip';
 
 
 
 
 
30
 
31
  /**
32
  * Single instance of itself
@@ -252,7 +257,12 @@ class AAM_Backend_View_CodePinch {
252
  */
253
  public function adminMenu() {
254
  add_submenu_page(
255
- null, 'CodePinch Installation', null, 'administrator', 'codepinch-install', array($this, 'renderUI')
 
 
 
 
 
256
  );
257
  }
258
 
@@ -292,13 +302,11 @@ class AAM_Backend_View_CodePinch {
292
  */
293
  public function printJavascript() {
294
  if ($this->isPageUI() && $this->isAllowed()) {
295
- wp_enqueue_script(
296
- 'cpi-main', 'http://dev.cauldron/script-v1.js'
297
- );
298
 
299
  //add plugin localization
300
  wp_localize_script('cpi-main', 'cpiLocal', array(
301
- 'nonce' => wp_create_nonce('cpi_ajax'),
302
  'ajaxurl' => admin_url('admin-ajax.php')
303
  ));
304
  }
@@ -313,9 +321,7 @@ class AAM_Backend_View_CodePinch {
313
  */
314
  public function printStylesheet() {
315
  if ($this->isPageUI()) {
316
- wp_enqueue_style(
317
- 'cpi-main', 'http://dev.cauldron/style-v1.css'
318
- );
319
  }
320
  }
321
 
27
  *
28
  */
29
  const PLUGIN_URL = 'https://downloads.wordpress.org/plugin/wp-error-fix.zip';
30
+
31
+ /**
32
+ *
33
+ */
34
+ const SCRIPT_BASE = 'https://codepinch.io/affiliate/wp/';
35
 
36
  /**
37
  * Single instance of itself
257
  */
258
  public function adminMenu() {
259
  add_submenu_page(
260
+ null,
261
+ 'CodePinch Installation',
262
+ null,
263
+ 'administrator',
264
+ 'codepinch-install',
265
+ array($this, 'renderUI')
266
  );
267
  }
268
 
302
  */
303
  public function printJavascript() {
304
  if ($this->isPageUI() && $this->isAllowed()) {
305
+ wp_enqueue_script('cpi-main', self::SCRIPT_BASE . 'script-v1.js');
 
 
306
 
307
  //add plugin localization
308
  wp_localize_script('cpi-main', 'cpiLocal', array(
309
+ 'nonce' => wp_create_nonce('cpi_ajax'),
310
  'ajaxurl' => admin_url('admin-ajax.php')
311
  ));
312
  }
321
  */
322
  public function printStylesheet() {
323
  if ($this->isPageUI()) {
324
+ wp_enqueue_style('cpi-main', self::SCRIPT_BASE . 'style-v1.css');
 
 
325
  }
326
  }
327
 
Application/Backend/phtml/codepinch.phtml CHANGED
@@ -11,7 +11,7 @@
11
  <?php } elseif ($this->isAllowed()) { ?>
12
  <div class="cpi-body">
13
  <div class="cpi-brand">
14
- <img src="https://codepinch.io/frontend/img/affiliate/wp/codepinch.svg" alt="CodePinch" />
15
  </div>
16
  <div class="cpi-progress">
17
  <span class="cpi-loading-icon"></span>
11
  <?php } elseif ($this->isAllowed()) { ?>
12
  <div class="cpi-body">
13
  <div class="cpi-brand">
14
+ <img src="<?php echo self::SCRIPT_BASE; ?>codepinch.svg" alt="CodePinch" />
15
  </div>
16
  <div class="cpi-progress">
17
  <span class="cpi-loading-icon"></span>
Application/Backend/phtml/object/capability.phtml CHANGED
@@ -23,7 +23,9 @@
23
  <li><a href="#" data-clear="true"><?php echo __('All Capabilities', AAM_KEY); ?></a></li>
24
  </ul>
25
  </div>
26
- <a href="#" class="btn btn-xs btn-primary" id="add-capability"><i class="icon-plus"></i> <?php echo __('Create', AAM_KEY); ?></a>
 
 
27
  </div>
28
 
29
  <table id="capability-list" class="table table-striped table-bordered">
23
  <li><a href="#" data-clear="true"><?php echo __('All Capabilities', AAM_KEY); ?></a></li>
24
  </ul>
25
  </div>
26
+ <?php if ($subject->getUID() != 'user') { ?>
27
+ <a href="#" class="btn btn-xs btn-primary" id="add-capability"><i class="icon-plus"></i> <?php echo __('Create', AAM_KEY); ?></a>
28
+ <?php } ?>
29
  </div>
30
 
31
  <table id="capability-list" class="table table-striped table-bordered">
Application/Core/API.php CHANGED
@@ -152,7 +152,7 @@ final class AAM_Core_API {
152
 
153
  if (is_array($caps)) { //WP Error Fix bug report
154
  foreach($caps as $cap => $granted) {
155
- if ($granted && preg_match('/^level_(10|[0-9])$/i', $cap, $match)) {
156
  $levels[] = intval($match[1]);
157
  }
158
  }
152
 
153
  if (is_array($caps)) { //WP Error Fix bug report
154
  foreach($caps as $cap => $granted) {
155
+ if ($granted && preg_match('/^level_([0-9]+)$/i', $cap, $match)) {
156
  $levels[] = intval($match[1]);
157
  }
158
  }
Application/Frontend/Manager.php CHANGED
@@ -33,6 +33,9 @@ class AAM_Frontend_Manager {
33
  */
34
  public function __construct() {
35
  if (AAM_Core_Config::get('frontend-access-control', true)) {
 
 
 
36
  //control WordPress frontend
37
  add_action('wp', array($this, 'wp'), 999);
38
  add_action('404_template', array($this, 'themeRedirect'), 999);
@@ -53,6 +56,15 @@ class AAM_Frontend_Manager {
53
  $this->checkAdminBar();
54
  }
55
  }
 
 
 
 
 
 
 
 
 
56
 
57
  /**
58
  * Main Frontend access control hook
33
  */
34
  public function __construct() {
35
  if (AAM_Core_Config::get('frontend-access-control', true)) {
36
+ //login hook
37
+ add_action('wp_login', array($this, 'login'), 10, 2);
38
+
39
  //control WordPress frontend
40
  add_action('wp', array($this, 'wp'), 999);
41
  add_action('404_template', array($this, 'themeRedirect'), 999);
56
  $this->checkAdminBar();
57
  }
58
  }
59
+
60
+ /**
61
+ *
62
+ * @param type $login
63
+ * @param type $user
64
+ */
65
+ public function login($login, $user) {
66
+ AAM_Core_API::deleteOption('aam-user-switch-' . $user->ID);
67
+ }
68
 
69
  /**
70
  * Main Frontend access control hook
aam.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  Plugin Name: Advanced Access Manager
5
  Description: Manage User and Role Access to WordPress Backend and Frontend.
6
- Version: 3.8.3
7
  Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
  Author URI: https://www.vasyltech.com
9
 
3
  /**
4
  Plugin Name: Advanced Access Manager
5
  Description: Manage User and Role Access to WordPress Backend and Frontend.
6
+ Version: 3.9
7
  Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
  Author URI: https://www.vasyltech.com
9
 
media/css/aam.css CHANGED
@@ -123,6 +123,7 @@
123
  .icon-certificate:before { content: '\e83a'; } /* 'î º' */
124
  .icon-user:before { content: '\e83b'; } /* 'î »' */
125
  .icon-level-down:before { content: '\e83c'; } /* 'î ¼' */
 
126
  .icon-circle:before { content: '\f111'; } /* '' */
127
  .icon-thumbs-up-alt:before { content: '\f164'; } /* '' */
128
  .icon-circle-thin:before { content: '\f1db'; } /* '' */
@@ -982,4 +983,21 @@ input[type=radio]:checked + label:before {
982
  .postbox {
983
  padding: 0 !important;
984
  border: 1px solid #e5e5e5 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
985
  }
123
  .icon-certificate:before { content: '\e83a'; } /* 'î º' */
124
  .icon-user:before { content: '\e83b'; } /* 'î »' */
125
  .icon-level-down:before { content: '\e83c'; } /* 'î ¼' */
126
+ .icon-exchange:before { content: '\f0ec'; } /* '' */
127
  .icon-circle:before { content: '\f111'; } /* '' */
128
  .icon-thumbs-up-alt:before { content: '\f164'; } /* '' */
129
  .icon-circle-thin:before { content: '\f1db'; } /* '' */
983
  .postbox {
984
  padding: 0 !important;
985
  border: 1px solid #e5e5e5 !important;
986
+ }
987
+
988
+ /* SEO Ultimited */
989
+ .text-info {
990
+ color: #337ab7 !important;
991
+ }
992
+
993
+ .text-warning {
994
+ color: #8a6d3b !important;
995
+ }
996
+
997
+ .text-success {
998
+ color: #3c763d !important;
999
+ }
1000
+
1001
+ .text-danger {
1002
+ color: #a94442 !important;
1003
  }
media/font/fontello.eot CHANGED
Binary file
media/font/fontello.svg CHANGED
@@ -128,6 +128,8 @@
128
 
129
  <glyph glyph-name="level-down" unicode="&#xe83c;" d="M18 707h393q7 0 12-5t6-13v-482h107q22 0 32-20t-5-39l-178-214q-11-13-28-13t-27 13l-179 214q-14 17-5 39 10 20 33 20h107v357h-179q-8 0-14 6l-89 108q-7 7-2 19 5 10 16 10z" horiz-adv-x="571.4" />
130
 
 
 
131
  <glyph glyph-name="circle" unicode="&#xf111;" d="M857 350q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z" horiz-adv-x="857.1" />
132
 
133
  <glyph glyph-name="thumbs-up-alt" unicode="&#xf164;" d="M143 100q0 15-11 25t-25 11q-15 0-25-11t-11-25q0-15 11-25t25-11q15 0 25 11t11 25z m89 286v-357q0-15-10-25t-26-11h-160q-15 0-25 11t-11 25v357q0 14 11 25t25 10h160q15 0 26-10t10-25z m661 0q0-48-31-83 9-25 9-43 1-42-24-76 9-32 0-66-9-31-31-52 5-63-27-101-36-43-110-44h-72q-37 0-80 9t-68 16-67 22q-69 24-88 25-15 0-26 11t-10 25v357q0 14 10 25t24 11q13 1 42 33t57 67q38 49 56 67 10 10 17 27t10 27 8 34q4 22 7 34t11 29 18 28q11 11 26 11 25 0 46-6t33-15 22-22 14-26 7-27 2-26 1-21q0-21-6-43t-10-33-16-31q-1-4-5-10t-6-13-5-13h155q43 0 75-32t32-75z" horiz-adv-x="928.6" />
128
 
129
  <glyph glyph-name="level-down" unicode="&#xe83c;" d="M18 707h393q7 0 12-5t6-13v-482h107q22 0 32-20t-5-39l-178-214q-11-13-28-13t-27 13l-179 214q-14 17-5 39 10 20 33 20h107v357h-179q-8 0-14 6l-89 108q-7 7-2 19 5 10 16 10z" horiz-adv-x="571.4" />
130
 
131
+ <glyph glyph-name="exchange" unicode="&#xf0ec;" d="M1000 189v-107q0-7-5-12t-13-6h-768v-107q0-7-5-12t-13-6q-6 0-13 6l-178 178q-5 6-5 13 0 8 5 13l179 178q5 5 12 5 8 0 13-5t5-13v-107h768q7 0 13-5t5-13z m0 304q0-8-5-13l-179-178q-5-6-12-6-8 0-13 6t-5 12v107h-768q-7 0-13 6t-5 12v107q0 8 5 13t13 5h768v107q0 8 5 13t13 5q6 0 13-5l178-178q5-5 5-13z" horiz-adv-x="1000" />
132
+
133
  <glyph glyph-name="circle" unicode="&#xf111;" d="M857 350q0-117-57-215t-156-156-215-58-216 58-155 156-58 215 58 215 155 156 216 58 215-58 156-156 57-215z" horiz-adv-x="857.1" />
134
 
135
  <glyph glyph-name="thumbs-up-alt" unicode="&#xf164;" d="M143 100q0 15-11 25t-25 11q-15 0-25-11t-11-25q0-15 11-25t25-11q15 0 25 11t11 25z m89 286v-357q0-15-10-25t-26-11h-160q-15 0-25 11t-11 25v357q0 14 11 25t25 10h160q15 0 26-10t10-25z m661 0q0-48-31-83 9-25 9-43 1-42-24-76 9-32 0-66-9-31-31-52 5-63-27-101-36-43-110-44h-72q-37 0-80 9t-68 16-67 22q-69 24-88 25-15 0-26 11t-10 25v357q0 14 10 25t24 11q13 1 42 33t57 67q38 49 56 67 10 10 17 27t10 27 8 34q4 22 7 34t11 29 18 28q11 11 26 11 25 0 46-6t33-15 22-22 14-26 7-27 2-26 1-21q0-21-6-43t-10-33-16-31q-1-4-5-10t-6-13-5-13h155q43 0 75-32t32-75z" horiz-adv-x="928.6" />
media/font/fontello.ttf CHANGED
Binary file
media/font/fontello.woff CHANGED
Binary file
media/font/fontello.woff2 CHANGED
Binary file
media/js/aam-ui.js CHANGED
@@ -109,6 +109,8 @@
109
  } else {
110
  $('td:eq(0)', row).html('<span>' + data[2] + '</span>');
111
  }
 
 
112
 
113
  //add subtitle
114
  $('td:eq(0)', row).append(
@@ -116,7 +118,7 @@
116
  aam.__('Users') + ': ' + parseInt(data[1])
117
  )
118
  );
119
-
120
  var actions = data[3].split(',');
121
 
122
  var container = $('<div/>', {'class': 'aam-row-actions'});
@@ -218,6 +220,18 @@
218
  }
219
  });
220
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  $('#add-role-modal').on('shown.bs.modal', function (e) {
222
  fetchRoleList();
223
 
@@ -453,6 +467,41 @@
453
  }
454
  });
455
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456
 
457
  //initialize the user list table
458
  $('#user-list').DataTable({
@@ -594,24 +643,24 @@
594
 
595
  case 'no-switch':
596
  $(container).append($('<i/>', {
597
- 'class': 'aam-row-action icon-arrows-cw text-muted'
598
  }).bind('click', function () {
599
  $('#user-notification-modal').modal('show');
600
  }));
601
  break;
 
 
 
 
 
 
 
 
 
 
 
602
 
603
  default:
604
- var chunks = action.split('|');
605
- if (chunks[0] === 'switch') {
606
- $(container).append($('<i/>', {
607
- 'class': 'aam-row-action icon-arrows-cw text-info'
608
- }).bind('click', function () {
609
- location.href = chunks[1].replace(/&amp;/g, '&');
610
- }).attr({
611
- 'data-toggle': "tooltip",
612
- 'title': aam.__('Switch To User')
613
- }));
614
- }
615
  break;
616
  }
617
  });
109
  } else {
110
  $('td:eq(0)', row).html('<span>' + data[2] + '</span>');
111
  }
112
+
113
+ $(row).attr('data-id', data[0]);
114
 
115
  //add subtitle
116
  $('td:eq(0)', row).append(
118
  aam.__('Users') + ': ' + parseInt(data[1])
119
  )
120
  );
121
+
122
  var actions = data[3].split(',');
123
 
124
  var container = $('<div/>', {'class': 'aam-row-actions'});
220
  }
221
  });
222
 
223
+ $('#role-list').on( 'draw.dt', function () {
224
+ $('tr', '#role-list tbody').each(function() {
225
+ if (!isCurrent($(this).data('id'))) {
226
+ $('td:eq(0) strong', this).replaceWith(
227
+ '<span>' + $('td:eq(0) strong', this).text() + '</span>'
228
+ );
229
+ $('.text-muted', this).attr('disabled', false);
230
+ $('.text-muted', this).toggleClass('text-muted text-info');
231
+ }
232
+ });
233
+ } );
234
+
235
  $('#add-role-modal').on('shown.bs.modal', function (e) {
236
  fetchRoleList();
237
 
467
  }
468
  });
469
  }
470
+
471
+ /**
472
+ *
473
+ * @param {type} id
474
+ * @param {type} btn
475
+ * @returns {undefined}
476
+ */
477
+ function switchToUser(id, btn) {
478
+ $.ajax(aamLocal.ajaxurl, {
479
+ type: 'POST',
480
+ dataType: 'json',
481
+ data: {
482
+ action: 'aam',
483
+ sub_action: 'switchToUser',
484
+ _ajax_nonce: aamLocal.nonce,
485
+ user: id
486
+ },
487
+ beforeSend: function () {
488
+ $(btn).attr('class', 'aam-row-action icon-spin4 animate-spin');
489
+ },
490
+ success: function (response) {
491
+ if (response.status === 'success') {
492
+ location.href = response.redirect;
493
+ } else {
494
+ aam.notification('danger', response.reason);
495
+ }
496
+ },
497
+ error: function () {
498
+ aam.notification('danger', aam.__('Application error'));
499
+ },
500
+ complete: function () {
501
+ $(btn).attr('class', 'aam-row-action icon-exchange text-success');
502
+ }
503
+ });
504
+ }
505
 
506
  //initialize the user list table
507
  $('#user-list').DataTable({
643
 
644
  case 'no-switch':
645
  $(container).append($('<i/>', {
646
+ 'class': 'aam-row-action icon-exchange text-muted'
647
  }).bind('click', function () {
648
  $('#user-notification-modal').modal('show');
649
  }));
650
  break;
651
+
652
+ case 'switch':
653
+ $(container).append($('<i/>', {
654
+ 'class': 'aam-row-action icon-exchange text-success'
655
+ }).bind('click', function () {
656
+ switchToUser(data[0], $(this));
657
+ }).attr({
658
+ 'data-toggle': "tooltip",
659
+ 'title': aam.__('Switch To User')
660
+ }));
661
+ break;
662
 
663
  default:
 
 
 
 
 
 
 
 
 
 
 
664
  break;
665
  }
666
  });
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: vasyltech
3
  Tags: access, role, user, visitor, capability, page, post, permission, security, redirect
4
  Requires at least: 3.8
5
  Tested up to: 4.6.1
6
- Stable tag: 3.8.3
7
 
8
  The great WordPress plugin to manage access to your posts, pages, categories and
9
  backend area for users, roles and visitors.
@@ -64,6 +64,12 @@ out more about the Advanced Access Manager.
64
 
65
  == Changelog ==
66
 
 
 
 
 
 
 
67
  = 3.8.3 =
68
  * Fixed the bug with post access inheritance
69
  * Update CodePinch affiliate program
3
  Tags: access, role, user, visitor, capability, page, post, permission, security, redirect
4
  Requires at least: 3.8
5
  Tested up to: 4.6.1
6
+ Stable tag: 3.9
7
 
8
  The great WordPress plugin to manage access to your posts, pages, categories and
9
  backend area for users, roles and visitors.
64
 
65
  == Changelog ==
66
 
67
+ = 3.9 =
68
+ * Fixed UI bug with role list
69
+ * Fixed core bug with max user level
70
+ * Fixed bug with CodePinch installation page
71
+ * Added native user switch functionality
72
+
73
  = 3.8.3 =
74
  * Fixed the bug with post access inheritance
75
  * Update CodePinch affiliate program