Advanced Access Manager - Version 3.7.1

Version Description

  • Added AAM Role Hierarchy extension
  • Fixed bug with 404 page for frontend
  • Started CSS fixes for all known incompatible themes and plugins
Download this release

Release Info

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

Code changes from version 3.7 to 3.7.1

Application/Backend/Feature/ProductList.php CHANGED
@@ -9,88 +9,95 @@
9
 
10
  return array(
11
  array(
12
- 'title' => '<span class="aam-highlight">AAM Plus Package</span>',
13
- 'id' => 'AAM Plus Package',
14
- 'type' => 'commercial',
15
- 'cost' => '$30',
16
- 'currency' => 'USD',
17
- 'description' => __('Our best selling extension that allows you to setup access to unlimited number of posts, pages or custom post types as well as define default access to ALL posts, pages, custom post types, categories or custom taxonomies.', AAM_KEY) . ' <a href="https://vasyltech.com/blog/manage-access-to-posts-and-pages" target="_blank">Read more.</a>',
18
- 'storeURL' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FGAHULDEFZV4U',
19
- 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Plus Package'),
20
- 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Plus Package')
21
  ),
22
  array(
23
- 'title' => 'AAM Redirect',
24
- 'id' => 'AAM Redirect',
25
- 'type' => 'commercial',
26
- 'cost' => '$20',
27
- 'currency' => 'USD',
28
- 'new' => true,
29
- 'description' => __('With this extension you can define custom redirect or "Access Denied" message for each role, individual user or all visitors.', AAM_KEY). ' <a href="http://vasyltech.com/blog/aam-redirect-extension" target="_blank">Read more.</a>',
30
- 'storeURL' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QAM3P45X6PKUU',
31
- 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Redirect'),
32
- 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Redirect')
33
  ),
34
  array(
35
- 'title' => 'AAM Role Filter',
36
- 'id' => 'AAM Role Filter',
37
- 'type' => 'commercial',
38
- 'cost' => '$5',
39
- 'currency' => 'USD',
40
- 'description' => __('More advanced user and role administration. Based on user capabilities level, filter list of roles that user can manage. Also prevent from editing, promoting or deleting higher level users.', AAM_KEY),
41
- 'storeURL' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G9V4BT3T8WJSN',
42
- 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Role Filter'),
43
- 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Role Filter')
 
 
 
 
 
 
 
 
 
 
44
  ),
45
  array(
46
- 'title' => 'AAM Complete Package',
47
- 'id' => 'AAM Complete Package',
48
- 'type' => 'commercial',
49
- 'cost' => '$50',
50
- 'currency' => 'USD',
51
- 'new' => true,
52
- 'description' => __('Get list of all available premium extensions in one package and save $5 USD.', AAM_KEY),
53
- 'storeURL' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KLZ85ZZEQGNWJ',
54
- 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Complete Package'),
55
- 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Complete Package')
56
  ),
57
  array(
58
- 'title' => 'AAM Multisite',
59
- 'id' => 'AAM Multisite',
60
- 'type' => 'GNU',
61
- 'license' => 'AAMMULTISITE',
62
- 'description' => __('Convenient way to navigate between different sites in the Network Admin Panel. This extension adds additional widget to the AAM page that allows to switch between different sites.', AAM_KEY),
63
- 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Multisite'),
64
- 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Multisite')
65
  ),
66
  array(
67
- 'title' => 'AAM Post Filter',
68
- 'id' => 'AAM Post Filter',
69
- 'type' => 'GNU',
70
- 'license' => 'AAMPOSTFILTER',
71
  'description' => AAM_Backend_View_Helper::preparePhrase('[WARNING!] Please use with caution. This is a supportive exension for the post access option [LIST]. It adds additional post filtering to fix the issue with large amount of posts.', 'strong', 'strong'),
72
- 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Post Filter'),
73
- 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Post Filter')
74
  ),
75
  array(
76
- 'title' => 'CodePinch',
77
- 'id' => 'WP Error Fix',
78
- 'type' => 'plugin',
79
- 'description' => '<span class="aam-highlight">Highly recommended!</span> ' . __('Patent-pending technology that provides solutions to PHP errors within hours, preventing costly maintenance time and keeping your WordPress site error.', AAM_KEY) . ' <a href="http://codepinch.io" target="_blank">Read more.</a>',
80
- 'status' => AAM_Core_Repository::getInstance()->pluginStatus('WP Error Fix')
81
  ),
82
  array(
83
- 'title' => 'ConfigPress',
84
- 'id' => 'ConfigPress',
85
- 'type' => 'plugin',
86
- 'description' => __('Development tool with an easy way to manage all your website custom settings. ', AAM_KEY) . ' <a href="https://vasyltech.com/config-press" target="_blank">Read more.</a>',
87
- 'status' => AAM_Core_Repository::getInstance()->pluginStatus('ConfigPress')
88
  ),
89
  array(
90
- 'title' => 'User Switching',
91
- 'id' => 'User Switching',
92
- 'type' => 'plugin',
93
- 'description' => __('Instant switching between user accounts in WordPress.', AAM_KEY),
94
- 'status' => AAM_Core_Repository::getInstance()->pluginStatus('User Switching')
95
  )
96
  );
9
 
10
  return array(
11
  array(
12
+ 'title' => '<span class="aam-highlight">AAM Plus Package</span>',
13
+ 'id' => 'AAM Plus Package',
14
+ 'type' => 'commercial',
15
+ 'price' => '$30 <small>USD</small>',
16
+ 'description' => 'Our best selling extension that allows you to manage access to unlimited number of posts, pages or custom post types and define default access to ALL posts, pages, custom post types, categories or custom taxonomies. <a href="https://vasyltech.com/blog/manage-access-to-posts-and-pages" target="_blank">Read more.</a>',
17
+ 'storeURL' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FGAHULDEFZV4U',
18
+ 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Plus Package'),
19
+ 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Plus Package')
 
20
  ),
21
  array(
22
+ 'title' => 'AAM Redirect',
23
+ 'id' => 'AAM Redirect',
24
+ 'type' => 'commercial',
25
+ 'price' => '$20 <small>USD</small>',
26
+ 'new' => true,
27
+ 'description' => 'Define custom redirect or "Access Denied" message for each role, individual user or visitors. <a href="http://vasyltech.com/blog/aam-redirect-extension" target="_blank">Read more.</a>',
28
+ 'storeURL' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QAM3P45X6PKUU',
29
+ 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Redirect'),
30
+ 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Redirect')
 
31
  ),
32
  array(
33
+ 'title' => 'AAM Role Hierarchy',
34
+ 'id' => 'AAM Role Hierarchy',
35
+ 'type' => 'commercial',
36
+ 'price' => '$15 <small>USD</small>',
37
+ 'new' => true,
38
+ 'description' => 'Create complex role hierarchy and automatically inherit access settings from parent roles. <a href="https://vasyltech.com/blog/aam-role-hierarchy" target="_blank">Read more.</a>',
39
+ 'storeURL' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K8DMZ66SAW8VG',
40
+ 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Role Hierarchy'),
41
+ 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Role Hierarchy')
42
+ ),
43
+ array(
44
+ 'title' => 'AAM Role Filter',
45
+ 'id' => 'AAM Role Filter',
46
+ 'type' => 'commercial',
47
+ 'price' => '$5 <small>USD</small>',
48
+ 'description' => 'More advanced user and role administration. Based on user capabilities level, filter list of roles that user can manage. Also prevent from editing, promoting or deleting higher level users.',
49
+ 'storeURL' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G9V4BT3T8WJSN',
50
+ 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Role Filter'),
51
+ 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Role Filter')
52
  ),
53
  array(
54
+ 'title' => 'AAM Complete Package',
55
+ 'id' => 'AAM Complete Package',
56
+ 'type' => 'commercial',
57
+ 'price' => '$65 <small>USD</small>',
58
+ 'new' => true,
59
+ 'description' => 'Get list of all available premium extensions in one package and <strong>save $5 USD</strong>.',
60
+ 'storeURL' => 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AJ6JMQ4CGSS9E',
61
+ 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Complete Package'),
62
+ 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Complete Package')
 
63
  ),
64
  array(
65
+ 'title' => 'AAM Multisite',
66
+ 'id' => 'AAM Multisite',
67
+ 'type' => 'GNU',
68
+ 'license' => 'AAMMULTISITE',
69
+ 'description' => 'Convenient way to navigate between different sites in the Network Admin Panel.',
70
+ 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Multisite'),
71
+ 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Multisite')
72
  ),
73
  array(
74
+ 'title' => 'AAM Post Filter',
75
+ 'id' => 'AAM Post Filter',
76
+ 'type' => 'GNU',
77
+ 'license' => 'AAMPOSTFILTER',
78
  'description' => AAM_Backend_View_Helper::preparePhrase('[WARNING!] Please use with caution. This is a supportive exension for the post access option [LIST]. It adds additional post filtering to fix the issue with large amount of posts.', 'strong', 'strong'),
79
+ 'status' => AAM_Core_Repository::getInstance()->extensionStatus('AAM Post Filter'),
80
+ 'version' => AAM_Core_Repository::getInstance()->getExtensionVersion('AAM Post Filter')
81
  ),
82
  array(
83
+ 'title' => 'CodePinch',
84
+ 'id' => 'WP Error Fix',
85
+ 'type' => 'plugin',
86
+ 'description' => '<span class="aam-highlight">Highly recommended!</span> Patent-pending technology that provides solutions to PHP errors within hours, preventing costly maintenance time and keeping your WordPress site error. <a href="http://codepinch.io" target="_blank">Read more.</a>',
87
+ 'status' => AAM_Core_Repository::getInstance()->pluginStatus('WP Error Fix')
88
  ),
89
  array(
90
+ 'title' => 'ConfigPress',
91
+ 'id' => 'ConfigPress',
92
+ 'type' => 'plugin',
93
+ '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>',
94
+ 'status' => AAM_Core_Repository::getInstance()->pluginStatus('ConfigPress')
95
  ),
96
  array(
97
+ 'title' => 'User Switching',
98
+ 'id' => 'User Switching',
99
+ 'type' => 'plugin',
100
+ 'description' => 'Instant switching between user accounts in WordPress.',
101
+ 'status' => AAM_Core_Repository::getInstance()->pluginStatus('User Switching')
102
  )
103
  );
Application/Backend/Feature/Role.php CHANGED
@@ -47,23 +47,25 @@ class AAM_Backend_Feature_Role {
47
  $filtered = $this->fetchRoleList();
48
 
49
  $response = array(
50
- 'recordsTotal' => count(get_editable_roles()),
51
  'recordsFiltered' => count($filtered),
52
- 'draw' => AAM_Core_Request::request('draw'),
53
- 'data' => array(),
54
  );
55
 
56
- foreach ($filtered as $role => $data) {
57
- $uc = (isset($stats[$role]) ? $stats[$role] : 0);
 
 
58
  $response['data'][] = array(
59
- $role,
60
  $uc,
61
  translate_user_role($data['name']),
62
- 'manage,edit' . ($uc || !current_user_can('delete_users') ? ',no-delete' : ',delete')
63
  );
64
  }
65
 
66
- return json_encode($response);
67
  }
68
 
69
  /**
@@ -86,10 +88,13 @@ class AAM_Backend_Feature_Role {
86
  $response = array();
87
 
88
  //filter by name
89
- $search = trim(AAM_Core_Request::request('search.value'));
90
- $roles = get_editable_roles();
 
 
91
  foreach ($roles as $id => $role) {
92
- if (!$search || preg_match('/^' . $search . '/i', $role['name'])) {
 
93
  $response[$id] = $role;
94
  }
95
  }
@@ -105,22 +110,20 @@ class AAM_Backend_Feature_Role {
105
  * @access public
106
  */
107
  public function add() {
108
- $name = sanitize_text_field(AAM_Core_Request::post('name'));
109
- $roles = new WP_Roles;
110
  $role_id = strtolower($name);
 
111
  //if inherited role is set get capabilities from it
112
- $parent = trim(AAM_Core_Request::post('inherit'));
113
- if ($parent && $roles->get_role($parent)){
114
- $caps = $roles->get_role($parent)->capabilities;
115
- } else {
116
- $caps = array();
117
- }
118
 
119
- if ($roles->add_role($role_id, $name, $caps)) {
120
  $response = array(
121
  'status' => 'success',
122
- 'role' => $role_id
123
  );
 
124
  } else {
125
  $response = array('status' => 'failure');
126
  }
@@ -136,13 +139,12 @@ class AAM_Backend_Feature_Role {
136
  * @access public
137
  */
138
  public function edit() {
139
- $result = AAM_Backend_View::getSubject()->update(
140
- trim(AAM_Core_Request::post('name'))
141
- );
142
 
143
- return json_encode(
144
- array('status' => ($result ? 'success' : 'failure'))
145
- );
146
  }
147
 
148
  /**
47
  $filtered = $this->fetchRoleList();
48
 
49
  $response = array(
50
+ 'recordsTotal' => count(get_editable_roles()),
51
  'recordsFiltered' => count($filtered),
52
+ 'draw' => AAM_Core_Request::request('draw'),
53
+ 'data' => array(),
54
  );
55
 
56
+ foreach ($filtered as $id => $data) {
57
+ $uc = (isset($stats[$id]) ? $stats[$id] : 0);
58
+ $allow = current_user_can('delete_users');
59
+
60
  $response['data'][] = array(
61
+ $id,
62
  $uc,
63
  translate_user_role($data['name']),
64
+ 'manage,edit' . ($uc || !$allow ? ',no-delete' : ',delete')
65
  );
66
  }
67
 
68
+ return json_encode(apply_filters('aam-get-role-list-filter', $response));
69
  }
70
 
71
  /**
88
  $response = array();
89
 
90
  //filter by name
91
+ $search = trim(AAM_Core_Request::request('search.value'));
92
+ $exclude = trim(AAM_Core_Request::request('exclude'));
93
+
94
+ $roles = get_editable_roles();
95
  foreach ($roles as $id => $role) {
96
+ $match = preg_match('/^' . $search . '/i', $role['name']);
97
+ if (($exclude != $id) && (!$search || $match)) {
98
  $response[$id] = $role;
99
  }
100
  }
110
  * @access public
111
  */
112
  public function add() {
113
+ $name = sanitize_text_field(AAM_Core_Request::post('name'));
114
+ $roles = AAM_Core_API::getRoles();
115
  $role_id = strtolower($name);
116
+
117
  //if inherited role is set get capabilities from it
118
+ $parent = $roles->get_role(trim(AAM_Core_Request::post('inherit')));
119
+ $caps = ($parent ? $parent->capabilities : array());
 
 
 
 
120
 
121
+ if ($role = $roles->add_role($role_id, $name, $caps)) {
122
  $response = array(
123
  'status' => 'success',
124
+ 'role' => $role_id
125
  );
126
+ do_action('aam-post-add-role-action', $role, $parent);
127
  } else {
128
  $response = array('status' => 'failure');
129
  }
139
  * @access public
140
  */
141
  public function edit() {
142
+ $role = AAM_Backend_View::getSubject();
143
+ $role->update(trim(AAM_Core_Request::post('name')));
 
144
 
145
+ do_action('aam-post-update-role-action', $role);
146
+
147
+ return json_encode(array('status' => 'success'));
148
  }
149
 
150
  /**
Application/Backend/phtml/extension.phtml CHANGED
@@ -35,7 +35,7 @@
35
  <?php foreach ($this->getProductList('commercial') as $product) { ?>
36
  <tr>
37
  <td>
38
- <span class='aam-setting-title'><?php echo $product['title'], (!empty($product['new']) ? ' <span class="badge">NEW</span> ' : ''), (!empty($product['version']) ? ' <small class="text-muted">v' . $product['version'] . '</small>' : ''), ' - ' . ($product['cost'] . ' <small>' . $product['currency'] . '</small>'); ?></span>
39
  <p class="aam-extension-description">
40
  <?php echo $product['description']; ?>
41
  </p>
35
  <?php foreach ($this->getProductList('commercial') as $product) { ?>
36
  <tr>
37
  <td>
38
+ <span class='aam-setting-title'><?php echo $product['title'], (!empty($product['new']) ? ' <span class="badge">NEW</span> ' : ''), (!empty($product['version']) ? ' <small class="text-muted">v' . $product['version'] . '</small>' : ''), ' - ' . ($product['price']); ?></span>
39
  <p class="aam-extension-description">
40
  <?php echo $product['description']; ?>
41
  </p>
Application/Backend/phtml/index.phtml CHANGED
@@ -94,15 +94,10 @@
94
  </div>
95
  <div class="modal-body">
96
  <div class="form-group">
97
- <label for="new-role-name"><?php echo __('Role Name', AAM_KEY); ?><span class="aam-asterix">*</span></label>
98
- <input type="text" class="form-control" id="new-role-name" placeholder="<?php echo __('Enter Role Name', AAM_KEY); ?>" />
99
- </div>
100
- <div class="form-group">
101
- <label for="inherit-role-list"><?php echo __('Inherit Capabilities From', AAM_KEY); ?></label>
102
- <select class="form-control" id="inherit-role-list">
103
- <option value=""><?php echo __('Select Role', AAM_KEY); ?></option>
104
- </select>
105
  </div>
 
106
  </div>
107
  <div class="modal-footer">
108
  <button type="button" class="btn btn-success" id="add-role-btn"><?php echo __('Create', AAM_KEY); ?></button>
@@ -122,8 +117,9 @@
122
  <div class="modal-body">
123
  <div class="form-group">
124
  <label for="new-role-name"><?php echo __('Role Name', AAM_KEY); ?></label>
125
- <input type="text" class="form-control" id="edit-role-name" placeholder="<?php echo __('Enter Role Name', AAM_KEY); ?>" />
126
  </div>
 
127
  </div>
128
  <div class="modal-footer">
129
  <button type="button" class="btn btn-success" id="edit-role-btn"><?php echo __('Update', AAM_KEY); ?></button>
94
  </div>
95
  <div class="modal-body">
96
  <div class="form-group">
97
+ <label><?php echo __('Role Name', AAM_KEY); ?><span class="aam-asterix">*</span></label>
98
+ <input type="text" class="form-control" name="name" placeholder="<?php echo __('Enter Role Name', AAM_KEY); ?>" />
 
 
 
 
 
 
99
  </div>
100
+ <?php echo apply_filters('aam-add-role-ui-filter', AAM_Backend_View::getInstance()->loadPartial('role-inheritance.phtml')); ?>
101
  </div>
102
  <div class="modal-footer">
103
  <button type="button" class="btn btn-success" id="add-role-btn"><?php echo __('Create', AAM_KEY); ?></button>
117
  <div class="modal-body">
118
  <div class="form-group">
119
  <label for="new-role-name"><?php echo __('Role Name', AAM_KEY); ?></label>
120
+ <input type="text" class="form-control" id="edit-role-name" placeholder="<?php echo __('Enter Role Name', AAM_KEY); ?>" name="name" />
121
  </div>
122
+ <?php do_action('aam-edit-role-ui-action'); ?>
123
  </div>
124
  <div class="modal-footer">
125
  <button type="button" class="btn btn-success" id="edit-role-btn"><?php echo __('Update', AAM_KEY); ?></button>
Application/Backend/phtml/object/menu.phtml CHANGED
@@ -3,7 +3,7 @@
3
  <div class="row<?php echo ($this->isOverwritten() ? '' : ' hidden'); ?>">
4
  <div class="col-xs-12">
5
  <div class="aam-overwrite">
6
- <span><i class="icon-attention-circled"></i> <?php echo __('Settings may not be inherited', AAM_KEY); ?></span>
7
  <span><a href="#" id="menu-reset"><?php echo __('Reset', AAM_KEY); ?></a>
8
  </div>
9
  </div>
3
  <div class="row<?php echo ($this->isOverwritten() ? '' : ' hidden'); ?>">
4
  <div class="col-xs-12">
5
  <div class="aam-overwrite">
6
+ <span><i class="icon-attention-circled"></i> <?php echo __('Settings are overwritten', AAM_KEY); ?></span>
7
  <span><a href="#" id="menu-reset"><?php echo __('Reset', AAM_KEY); ?></a>
8
  </div>
9
  </div>
Application/Backend/phtml/object/metabox.phtml CHANGED
@@ -1,18 +1,18 @@
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="aam-feature" id="metabox-content">
 
 
 
 
3
  <div class="row<?php echo ($this->isOverwritten() ? '' : ' hidden'); ?>">
4
  <div class="col-xs-12">
5
  <div class="aam-overwrite">
6
- <span><i class="icon-attention-circled"></i> <?php echo __('Settings may not be inherited', AAM_KEY); ?></span>
7
  <span><a href="#" id="metabox-reset"><?php echo __('Reset', AAM_KEY); ?></a>
8
  </div>
9
  </div>
10
  </div>
11
 
12
- <div class="aam-feature-top-actions text-right">
13
- <a href="#" class="btn btn-xs btn-primary" id="refresh-metabox-list"><i class="icon-arrows-cw"></i> <?php echo __('Refresh', AAM_KEY); ?></a>
14
- </div>
15
-
16
  <?php
17
  global $wp_post_types;
18
 
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="aam-feature" id="metabox-content">
3
+ <div class="aam-feature-top-actions text-right">
4
+ <a href="#" class="btn btn-xs btn-primary" id="refresh-metabox-list"><i class="icon-arrows-cw"></i> <?php echo __('Refresh', AAM_KEY); ?></a>
5
+ </div>
6
+
7
  <div class="row<?php echo ($this->isOverwritten() ? '' : ' hidden'); ?>">
8
  <div class="col-xs-12">
9
  <div class="aam-overwrite">
10
+ <span><i class="icon-attention-circled"></i> <?php echo __('Settings are overwritten', AAM_KEY); ?></span>
11
  <span><a href="#" id="metabox-reset"><?php echo __('Reset', AAM_KEY); ?></a>
12
  </div>
13
  </div>
14
  </div>
15
 
 
 
 
 
16
  <?php
17
  global $wp_post_types;
18
 
Application/Backend/phtml/partial/role-inheritance.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php if (defined('AAM_KEY')) { ?>
2
+ <div class="form-group">
3
+ <label><?php echo __('Inherit Capabilities From', AAM_KEY); ?></label>
4
+ <select class="form-control inherit-role-list" name="inherit">
5
+ <option value=""><?php echo __('Select Role', AAM_KEY); ?></option>
6
+ </select>
7
+ </div>
8
+ <?php }
Application/Core/Subject/Role.php CHANGED
@@ -179,7 +179,14 @@ class AAM_Core_Subject_Role extends AAM_Core_Subject {
179
  * @inheritdoc
180
  */
181
  public function getParent() {
182
- return null;
 
 
 
 
 
 
 
183
  }
184
 
185
- }
179
  * @inheritdoc
180
  */
181
  public function getParent() {
182
+ return apply_filters('aam-parent-role-filter', null, $this);
183
+ }
184
+
185
+ /**
186
+ * @inheritdoc
187
+ */
188
+ public function hasParent() {
189
+ return ($this->getParent() ? true : false);
190
  }
191
 
192
+ }
Application/Frontend/Manager.php CHANGED
@@ -35,6 +35,7 @@ class AAM_Frontend_Manager {
35
  if (AAM_Core_Config::get('frontend-access-control', true)) {
36
  //control WordPress frontend
37
  add_action('wp', array($this, 'wp'), 999);
 
38
  //filter navigation pages & taxonomies
39
  add_filter('get_pages', array($this, 'getPages'));
40
  add_filter('wp_get_nav_menu_items', array($this, 'getNavigationMenu'));
@@ -60,23 +61,61 @@ class AAM_Frontend_Manager {
60
  public function wp() {
61
  global $post;
62
 
63
- $user = AAM::getUser();
64
  if ((is_single() || is_page()) && is_object($post)) {
65
- $object = $user->getObject('post', $post->ID);
66
- $read = $object->has('frontend.read');
67
- $others = $object->has('frontend.read_others');
68
-
69
- if ($read || ($others && !$this->isAuthor($post))) {
70
- AAM_Core_API::reject(
71
- 'frontend',
72
- array('object' => $object, 'action' => 'frontend.read')
73
- );
74
- }
75
- //trigger any action that is listeting
76
- do_action('aam-wp-action', $object);
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
 
 
78
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
 
 
 
 
 
 
 
 
 
 
80
  /**
81
  * Filter Pages that should be excluded in frontend
82
  *
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);
39
  //filter navigation pages & taxonomies
40
  add_filter('get_pages', array($this, 'getPages'));
41
  add_filter('wp_get_nav_menu_items', array($this, 'getNavigationMenu'));
61
  public function wp() {
62
  global $post;
63
 
 
64
  if ((is_single() || is_page()) && is_object($post)) {
65
+ $this->checkPostReadAccess($post);
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Theme redirect
71
+ *
72
+ * Super important function that cover the 404 redirect that triggered by theme
73
+ * when page is not found. This covers the scenario when page is restricted from
74
+ * listing and read.
75
+ *
76
+ * @global type $wp_query
77
+ *
78
+ * @param type $template
79
+ *
80
+ * @return string
81
+ *
82
+ * @access public
83
+ */
84
+ public function themeRedirect($template) {
85
+ global $wp_query;
86
+
87
+ $object = (isset($wp_query->queried_object) ? $wp_query->queried_object : 0);
88
+ if ($object && is_a($object, 'WP_Post')) {
89
+ $this->checkPostReadAccess($object);
90
  }
91
+
92
+ return $template;
93
  }
94
+
95
+ /**
96
+ * Check post read access
97
+ *
98
+ * @param WP_Post $post
99
+ *
100
+ * @return void
101
+ *
102
+ * @access protected
103
+ */
104
+ protected function checkPostReadAccess($post) {
105
+ $object = AAM::getUser()->getObject('post', $post->ID);
106
+ $read = $object->has('frontend.read');
107
+ $others = $object->has('frontend.read_others');
108
 
109
+ if ($read || ($others && !$this->isAuthor($post))) {
110
+ AAM_Core_API::reject(
111
+ 'frontend',
112
+ array('object' => $object, 'action' => 'frontend.read')
113
+ );
114
+ }
115
+ //trigger any action that is listeting
116
+ do_action('aam-wp-action', $object);
117
+ }
118
+
119
  /**
120
  * Filter Pages that should be excluded in frontend
121
  *
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.7
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.7.1
7
  Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
  Author URI: https://www.vasyltech.com
9
 
media/css/aam.css CHANGED
@@ -392,6 +392,12 @@ input[type=checkbox] { /* to hide the checkbox itself */
392
  display:none;
393
  }
394
 
 
 
 
 
 
 
395
  input[type=checkbox] + label {
396
  width: 1.2em;
397
  font-weight: normal;
@@ -896,4 +902,15 @@ input[type=radio]:checked + label:before {
896
  .toggle-off.btn-sm{padding-left:20px}
897
  .toggle.btn-xs{min-width:35px;min-height:22px}
898
  .toggle-on.btn-xs{padding-right:12px}
899
- .toggle-off.btn-xs{padding-left:12px}
 
 
 
 
 
 
 
 
 
 
 
392
  display:none;
393
  }
394
 
395
+ /* overwrite for bootstrap rule */
396
+ .checkbox input[type="checkbox"] {
397
+ display: inline-block;
398
+ margin-top: 1px;
399
+ }
400
+
401
  input[type=checkbox] + label {
402
  width: 1.2em;
403
  font-weight: normal;
902
  .toggle-off.btn-sm{padding-left:20px}
903
  .toggle.btn-xs{min-width:35px;min-height:22px}
904
  .toggle-on.btn-xs{padding-right:12px}
905
+ .toggle-off.btn-xs{padding-left:12px}
906
+
907
+
908
+ /* COVER KNOWN CSS ISSUES CASED BY OTHER PLUGINS OR THEMES */
909
+
910
+ /* Bridge theme */
911
+ .radio small, .form-group small, .panel-title small,
912
+ .aam-table-group small, .aam-setting-title small {
913
+ display: inline !important;
914
+ float: none !important;
915
+ width: auto !important;
916
+ }
media/js/aam-ui.js CHANGED
@@ -36,22 +36,26 @@
36
  data: {
37
  action: 'aam',
38
  sub_action: 'Role.getList',
39
- _ajax_nonce: aamLocal.nonce
 
40
  },
41
  beforeSend: function () {
42
- $('#inherit-role-list').html(
43
  '<option value="">' + aam.__('Loading...') + '</option>'
44
  );
45
  },
46
  success: function (response) {
47
- $('#inherit-role-list').html(
48
  '<option value="">' + aam.__('Select Role') + '</option>'
49
  );
50
  for (var i in response) {
51
- $('#inherit-role-list').append(
52
  '<option value="' + i + '">' + response[i].name + '</option>'
53
  );
54
  }
 
 
 
55
  }
56
  });
57
  }
@@ -59,7 +63,7 @@
59
  //initialize the role list table
60
  $('#role-list').DataTable({
61
  autoWidth: false,
62
- ordering: true,
63
  dom: 'ftrip',
64
  pagingType: 'simple',
65
  processing: true,
@@ -74,8 +78,7 @@
74
  }
75
  },
76
  columnDefs: [
77
- {visible: false, targets: [0, 1]},
78
- {sorting: false, targets: [0, 1, 3]}
79
  ],
80
  language: {
81
  search: '_INPUT_',
@@ -90,14 +93,8 @@
90
  }).html('<i class="icon-plus"></i> ' + aam.__('Create'))
91
  .bind('click', function (event) {
92
  event.preventDefault();
93
-
94
- //clear add role form first
95
- $('#new-role-name', '#add-role-modal').val('');
96
- fetchRoleList();
97
-
98
- $('#add-role-modal').modal('show').on('shown.bs.modal', function (e) {
99
- $('#new-role-name', '#add-role-modal').focus();
100
- });
101
  });
102
 
103
  $('.dataTables_filter', '#role-list_wrapper').append(create);
@@ -123,25 +120,29 @@
123
  switch (action) {
124
  case 'manage':
125
  $(container).append($('<i/>', {
126
- 'class': 'aam-row-action icon-cog text-info'
127
  }).bind('click', function () {
128
- aam.setSubject('role', data[0], data[2]);
129
- $('td:eq(0) span', row).replaceWith(
130
- '<strong>' + data[2] + '</strong>'
131
- );
132
- $('i.icon-cog', container).attr(
 
 
 
133
  'class', 'aam-row-action icon-spin4 animate-spin'
134
- );
135
- aam.fetchContent();
136
- $('i.icon-spin4', container).attr(
137
- 'class', 'aam-row-action icon-cog text-info'
138
- );
139
- //Show add capability that may be hidden after manager user
140
- $('#add-capability').show();
 
141
  }).attr({
142
  'data-toggle': "tooltip",
143
  'title': aam.__('Manage Role')
144
- }));
145
  break;
146
 
147
  case 'edit':
@@ -150,9 +151,9 @@
150
  }).bind('click', function () {
151
  $('#edit-role-btn').data('role', data[0]);
152
  $('#edit-role-name').val(data[2]);
153
- $('#edit-role-modal').modal('show').on('shown.bs.modal', function () {
154
- $('#edit-role-name').focus();
155
- });
156
  }).attr({
157
  'data-toggle': "tooltip",
158
  'title': aam.__('Edit Role Name')
@@ -191,8 +192,28 @@
191
  }
192
  });
193
  $('td:eq(1)', row).html(container);
 
 
 
 
 
194
  }
195
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
  //add role button
198
  $('#add-role-btn').bind('click', function (event) {
@@ -200,22 +221,27 @@
200
 
201
  var _this = this;
202
 
203
- $('#new-role-name', '#add-role-modal').parent().removeClass('has-error');
204
 
205
- var name = $.trim($('#new-role-name', '#add-role-modal').val());
206
- var inherit = $.trim($('#inherit-role-list', '#add-role-modal').val());
 
 
 
 
 
 
 
 
 
 
 
207
 
208
- if (name) {
209
  $.ajax(aamLocal.ajaxurl, {
210
  type: 'POST',
211
  dataType: 'json',
212
- data: {
213
- action: 'aam',
214
- sub_action: 'Role.add',
215
- _ajax_nonce: aamLocal.nonce,
216
- name: name,
217
- inherit: inherit
218
- },
219
  beforeSend: function () {
220
  $(_this).text(aam.__('Saving...')).attr('disabled', true);
221
  },
@@ -226,7 +252,7 @@
226
  } else {
227
  aam.notification(
228
  'danger', aam.__('Failed to add new role')
229
- );
230
  }
231
  },
232
  error: function () {
@@ -237,7 +263,7 @@
237
  }
238
  });
239
  } else {
240
- $('#new-role-name').focus().parent().addClass('has-error');
241
  }
242
  });
243
 
@@ -246,20 +272,24 @@
246
  var _this = this;
247
 
248
  $('#edit-role-name').parent().removeClass('has-error');
249
- var name = $.trim($('#edit-role-name').val());
 
 
 
 
 
 
 
 
 
 
 
250
 
251
- if (name) {
252
  $.ajax(aamLocal.ajaxurl, {
253
  type: 'POST',
254
  dataType: 'json',
255
- data: {
256
- action: 'aam',
257
- sub_action: 'Role.edit',
258
- _ajax_nonce: aamLocal.nonce,
259
- subject: 'role',
260
- subjectId: $(_this).data('role'),
261
- name: name
262
- },
263
  beforeSend: function () {
264
  $(_this).text(aam.__('Saving...')).attr('disabled', true);
265
  },
@@ -325,6 +355,8 @@
325
  $('tbody tr', '#role-list').each(function () {
326
  if ($('strong', $(this)).length) {
327
  var highlight = $('strong', $(this));
 
 
328
  highlight.replaceWith($('<span/>').text(highlight.text()));
329
  }
330
  });
@@ -976,6 +1008,10 @@
976
  }
977
  });
978
  });
 
 
 
 
979
 
980
  $('#add-capability').bind('click', function (event) {
981
  event.preventDefault();
@@ -1008,7 +1044,7 @@
1008
  } else {
1009
  aam.notification(
1010
  'danger', aam.__('Failed to add new capability')
1011
- );
1012
  }
1013
  },
1014
  error: function () {
36
  data: {
37
  action: 'aam',
38
  sub_action: 'Role.getList',
39
+ _ajax_nonce: aamLocal.nonce,
40
+ exclude: aam.getSubject().id
41
  },
42
  beforeSend: function () {
43
+ $('.inherit-role-list').html(
44
  '<option value="">' + aam.__('Loading...') + '</option>'
45
  );
46
  },
47
  success: function (response) {
48
+ $('.inherit-role-list').html(
49
  '<option value="">' + aam.__('Select Role') + '</option>'
50
  );
51
  for (var i in response) {
52
+ $('.inherit-role-list').append(
53
  '<option value="' + i + '">' + response[i].name + '</option>'
54
  );
55
  }
56
+ aam.triggerHook('post-get-role-list', {
57
+ list : response
58
+ });
59
  }
60
  });
61
  }
63
  //initialize the role list table
64
  $('#role-list').DataTable({
65
  autoWidth: false,
66
+ ordering: false,
67
  dom: 'ftrip',
68
  pagingType: 'simple',
69
  processing: true,
78
  }
79
  },
80
  columnDefs: [
81
+ {visible: false, targets: [0, 1]}
 
82
  ],
83
  language: {
84
  search: '_INPUT_',
93
  }).html('<i class="icon-plus"></i> ' + aam.__('Create'))
94
  .bind('click', function (event) {
95
  event.preventDefault();
96
+
97
+ $('#add-role-modal').modal('show');
 
 
 
 
 
 
98
  });
99
 
100
  $('.dataTables_filter', '#role-list_wrapper').append(create);
120
  switch (action) {
121
  case 'manage':
122
  $(container).append($('<i/>', {
123
+ 'class': 'aam-row-action icon-cog ' + (isCurrent(data[0]) ? 'text-muted': 'text-info')
124
  }).bind('click', function () {
125
+ if (!$(this).prop('disabled')) {
126
+ $(this).prop('disabled', true);
127
+ var title = $('td:eq(0) span', row).html();
128
+ aam.setSubject('role', data[0], title);
129
+ $('td:eq(0) span', row).replaceWith(
130
+ '<strong>' + title + '</strong>'
131
+ );
132
+ $('i.icon-cog', container).attr(
133
  'class', 'aam-row-action icon-spin4 animate-spin'
134
+ );
135
+ aam.fetchContent();
136
+ $('i.icon-spin4', container).attr(
137
+ 'class', 'aam-row-action icon-cog text-muted'
138
+ );
139
+ //Show add capability that may be hidden after manager user
140
+ $('#add-capability').show();
141
+ }
142
  }).attr({
143
  'data-toggle': "tooltip",
144
  'title': aam.__('Manage Role')
145
+ }).prop('disabled', (isCurrent(data[0]) ? true: false)));
146
  break;
147
 
148
  case 'edit':
151
  }).bind('click', function () {
152
  $('#edit-role-btn').data('role', data[0]);
153
  $('#edit-role-name').val(data[2]);
154
+ $('#edit-role-modal').modal('show');
155
+ //TODO - Rerwite JavaScript to support $.aam
156
+ $.aamEditRole = data;
157
  }).attr({
158
  'data-toggle': "tooltip",
159
  'title': aam.__('Edit Role Name')
192
  }
193
  });
194
  $('td:eq(1)', row).html(container);
195
+
196
+ aam.triggerHook('decorate-role-row', {
197
+ row : row,
198
+ data: data
199
+ });
200
  }
201
  });
202
+
203
+ $('#add-role-modal').on('shown.bs.modal', function (e) {
204
+ fetchRoleList();
205
+ //TODO - Rerwite JavaScript to support $.aam
206
+ $.aamEditRole = null;
207
+
208
+ //clear add role form first
209
+ $('input[name="name"]', '#add-role-modal').val('');
210
+ $('input[name="name"]', '#add-role-modal').focus();
211
+ });
212
+
213
+ $('#edit-role-modal').on('shown.bs.modal', function (e) {
214
+ fetchRoleList();
215
+ $('input[name="name"]', '#edit-role-modal').focus();
216
+ });
217
 
218
  //add role button
219
  $('#add-role-btn').bind('click', function (event) {
221
 
222
  var _this = this;
223
 
224
+ $('input[name="name"]', '#add-role-modal').parent().removeClass('has-error');
225
 
226
+ var data = {
227
+ action: 'aam',
228
+ sub_action: 'Role.add',
229
+ _ajax_nonce: aamLocal.nonce
230
+ };
231
+
232
+ $('input,select', '#add-role-modal .modal-body').each(function() {
233
+ if ($(this).attr('type') === 'checkbox') {
234
+ data[$(this).attr('name')] = $(this).prop('checked') ? 1 : 0;
235
+ } else {
236
+ data[$(this).attr('name')] = $.trim($(this).val());
237
+ }
238
+ });
239
 
240
+ if (data.name) {
241
  $.ajax(aamLocal.ajaxurl, {
242
  type: 'POST',
243
  dataType: 'json',
244
+ data: data,
 
 
 
 
 
 
245
  beforeSend: function () {
246
  $(_this).text(aam.__('Saving...')).attr('disabled', true);
247
  },
252
  } else {
253
  aam.notification(
254
  'danger', aam.__('Failed to add new role')
255
+ );
256
  }
257
  },
258
  error: function () {
263
  }
264
  });
265
  } else {
266
+ $('input,select', '#add-role-modal .modal-body').focus().parent().addClass('has-error');
267
  }
268
  });
269
 
272
  var _this = this;
273
 
274
  $('#edit-role-name').parent().removeClass('has-error');
275
+
276
+ var data = {
277
+ action: 'aam',
278
+ sub_action: 'Role.edit',
279
+ _ajax_nonce: aamLocal.nonce,
280
+ subject: 'role',
281
+ subjectId: $(_this).data('role')
282
+ };
283
+
284
+ $('input,select', '#edit-role-modal .modal-body').each(function() {
285
+ data[$(this).attr('name')] = $.trim($(this).val());
286
+ });
287
 
288
+ if (data.name) {
289
  $.ajax(aamLocal.ajaxurl, {
290
  type: 'POST',
291
  dataType: 'json',
292
+ data: data,
 
 
 
 
 
 
 
293
  beforeSend: function () {
294
  $(_this).text(aam.__('Saving...')).attr('disabled', true);
295
  },
355
  $('tbody tr', '#role-list').each(function () {
356
  if ($('strong', $(this)).length) {
357
  var highlight = $('strong', $(this));
358
+ $('.icon-cog', $(this)).toggleClass('text-muted text-info');
359
+ $('.icon-cog', $(this)).prop('disabled', false);
360
  highlight.replaceWith($('<span/>').text(highlight.text()));
361
  }
362
  });
1008
  }
1009
  });
1010
  });
1011
+
1012
+ $('#add-capability-modal').on('shown.bs.modal', function (e) {
1013
+ $('#new-capability-name').val('');
1014
+ });
1015
 
1016
  $('#add-capability').bind('click', function (event) {
1017
  event.preventDefault();
1044
  } else {
1045
  aam.notification(
1046
  'danger', aam.__('Failed to add new capability')
1047
+ );
1048
  }
1049
  },
1050
  error: function () {
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.5.3
6
- Stable tag: 3.7
7
 
8
  One of the best tools in WordPress repository to manage access to your posts,
9
  pages, categories and backend area for users, roles and visitors.
@@ -60,6 +60,11 @@ out more about the Advanced Access Manager.
60
 
61
  == Changelog ==
62
 
 
 
 
 
 
63
  = 3.7 =
64
  * Introduced Redirect feature
65
  * Added CodePinch widget
3
  Tags: access, role, user, visitor, capability, page, post, permission, security, redirect
4
  Requires at least: 3.8
5
  Tested up to: 4.5.3
6
+ Stable tag: 3.7.1
7
 
8
  One of the best tools in WordPress repository to manage access to your posts,
9
  pages, categories and backend area for users, roles and visitors.
60
 
61
  == Changelog ==
62
 
63
+ = 3.7.1 =
64
+ * Added AAM Role Hierarchy extension
65
+ * Fixed bug with 404 page for frontend
66
+ * Started CSS fixes for all known incompatible themes and plugins
67
+
68
  = 3.7 =
69
  * Introduced Redirect feature
70
  * Added CodePinch widget