Advanced Access Manager - Version 4.9

Version Description

  • Fixed bug with Login Redirect duplicate settings saving
  • Added ability to hide license key with aam_display_license capability
  • Added ability to export/import AAM settings
  • Improved AAM UI
  • Added ability to restrict access to the Hope page
  • Added ability to manage access to frontend ajax calls with allow_ajax_calls cap
Download this release

Release Info

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

Code changes from version 4.8.1 to 4.9

Application/Backend/Feature/Extension.php CHANGED
@@ -118,6 +118,20 @@ class AAM_Backend_Feature_Extension extends AAM_Backend_Feature_Abstract {
118
  return $response;
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  /**
122
  * Install extension failure response
123
  *
118
  return $response;
119
  }
120
 
121
+ /**
122
+ *
123
+ * @return type
124
+ */
125
+ public function canShowLicense() {
126
+ $result = true;
127
+
128
+ if (AAM_Core_API::capabilityExists('aam_display_license')) {
129
+ $result = !empty(AAM::getUser()->allcaps['aam_display_license']);
130
+ }
131
+
132
+ return $result;
133
+ }
134
+
135
  /**
136
  * Install extension failure response
137
  *
Application/Backend/Feature/Utility.php CHANGED
@@ -76,6 +76,31 @@ class AAM_Backend_Feature_Utility extends AAM_Backend_Feature_Abstract {
76
  return json_encode(array('status' => 'success'));
77
  }
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  /**
80
  * Clear all AAM settings
81
  *
@@ -141,7 +166,9 @@ class AAM_Backend_Feature_Utility extends AAM_Backend_Feature_Abstract {
141
  'capability' => $cap,
142
  'subjects' => array(
143
  'AAM_Core_Subject_Role',
144
- 'AAM_Core_Subject_Visitor'
 
 
145
  ),
146
  'view' => __CLASS__
147
  ));
76
  return json_encode(array('status' => 'success'));
77
  }
78
 
79
+ /**
80
+ *
81
+ * @return type
82
+ */
83
+ public function export() {
84
+ $exporter = new AAM_Core_Exporter(AAM_Core_Config::get(
85
+ 'export', array('system' => 'roles,utilities,configpress')
86
+ ));
87
+
88
+ return json_encode(array(
89
+ 'status' => 'success',
90
+ 'content' => base64_encode($exporter->run())
91
+ ));
92
+ }
93
+
94
+ /**
95
+ *
96
+ * @return type
97
+ */
98
+ public function import() {
99
+ $importer = new AAM_Core_Importer(filter_input(INPUT_POST, 'json'));
100
+
101
+ return json_encode(array('status' => $importer->run()));
102
+ }
103
+
104
  /**
105
  * Clear all AAM settings
106
  *
166
  'capability' => $cap,
167
  'subjects' => array(
168
  'AAM_Core_Subject_Role',
169
+ 'AAM_Core_Subject_User',
170
+ 'AAM_Core_Subject_Visitor',
171
+ 'AAM_Core_Subject_Default'
172
  ),
173
  'view' => __CLASS__
174
  ));
Application/Backend/Manager.php CHANGED
@@ -144,8 +144,18 @@ class AAM_Backend_Manager {
144
  $uid = get_current_user_id();
145
 
146
  if ($uid && AAM_Core_API::capabilityExists('access_dashboard')) {
147
- if (empty(AAM::getUser()->allcaps['access_dashboard'])) {
148
- AAM_Core_API::reject('backend', array('hook' => 'access_dashboard'));
 
 
 
 
 
 
 
 
 
 
149
  }
150
  }
151
  }
144
  $uid = get_current_user_id();
145
 
146
  if ($uid && AAM_Core_API::capabilityExists('access_dashboard')) {
147
+ $caps = AAM::getUser()->allcaps;
148
+ if (empty($caps['access_dashboard'])) {
149
+ //also additionally check for AJAX calls
150
+ if (defined('DOING_AJAX') && empty($caps['allow_ajax_calls'])) {
151
+ AAM_Core_API::reject(
152
+ 'backend', array('hook' => 'access_dashboard')
153
+ );
154
+ } elseif (!defined('DOING_AJAX')) {
155
+ AAM_Core_API::reject(
156
+ 'backend', array('hook' => 'access_dashboard')
157
+ );
158
+ }
159
  }
160
  }
161
  }
Application/Backend/View.php CHANGED
@@ -41,13 +41,15 @@ class AAM_Backend_View {
41
  * @access protected
42
  */
43
  protected function __construct() {
44
- $classname = 'AAM_Core_Subject_' . ucfirst(
45
- AAM_Core_Request::request('subject')
46
- );
47
- if (class_exists($classname)) {
48
- $this->setSubject(new $classname(
49
- stripslashes(AAM_Core_Request::request('subjectId'))
50
- ));
 
 
51
  }
52
 
53
  //register default features
41
  * @access protected
42
  */
43
  protected function __construct() {
44
+ if (AAM_Core_Request::request('subject')) {
45
+ $classname = 'AAM_Core_Subject_' . ucfirst(
46
+ AAM_Core_Request::request('subject')
47
+ );
48
+ if (class_exists($classname)) {
49
+ $this->setSubject(new $classname(
50
+ stripslashes(AAM_Core_Request::request('subjectId'))
51
+ ));
52
+ }
53
  }
54
 
55
  //register default features
Application/Backend/phtml/extension.phtml CHANGED
@@ -43,7 +43,7 @@
43
  <tr>
44
  <td>
45
  <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>' : ''); ?></span>
46
- <?php if (!empty($product['license'])) { ?><small class="aam-license-key"><b>License:</b> <?php echo $product['license'] . (!empty($product['expire']) ? " (expires {$product['expire']})" : ''); ?></small><?php } ?>
47
  <p class="aam-extension-description">
48
  <?php echo $product['description']; ?>
49
  </p>
@@ -110,6 +110,10 @@
110
  <li><?php echo AAM_Backend_View_Helper::preparePhrase('Create [aam/extension] folder inside [wp-content] and make sure it is writable by your server', 'b', 'b'); ?>;</li>
111
  <li><?php echo AAM_Backend_View_Helper::preparePhrase('Unzip downloaded archive and upload the folder inside the [wp-content/aam/extension] folder', 'b'); ?>.</li>
112
  </ul>
 
 
 
 
113
  </div>
114
  <div class="modal-footer">
115
  <button type="button" class="btn btn-success" id="download-extension"><?php echo __('Download', AAM_KEY); ?></button>
43
  <tr>
44
  <td>
45
  <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>' : ''); ?></span>
46
+ <?php if (!empty($product['license']) && $this->canShowLicense()) { ?><small class="aam-license-key"><b>License:</b> <?php echo $product['license'] . (!empty($product['expire']) ? " (expires {$product['expire']})" : ''); ?></small><?php } ?>
47
  <p class="aam-extension-description">
48
  <?php echo $product['description']; ?>
49
  </p>
110
  <li><?php echo AAM_Backend_View_Helper::preparePhrase('Create [aam/extension] folder inside [wp-content] and make sure it is writable by your server', 'b', 'b'); ?>;</li>
111
  <li><?php echo AAM_Backend_View_Helper::preparePhrase('Unzip downloaded archive and upload the folder inside the [wp-content/aam/extension] folder', 'b'); ?>.</li>
112
  </ul>
113
+
114
+ <p class="aam-notification hidden" id="safari-download-notification">
115
+ <?php echo AAM_Backend_View_Helper::preparePhrase('[PLEASE NOTE!] Your browser may not support the latest HTML5 attribures and if downloaded file is not .ZIP archive, simply rename the file by adding .zip extension.', 'b'); ?>
116
+ </p>
117
  </div>
118
  <div class="modal-footer">
119
  <button type="button" class="btn btn-success" id="download-extension"><?php echo __('Download', AAM_KEY); ?></button>
Application/Backend/phtml/index.phtml CHANGED
@@ -253,10 +253,6 @@
253
  <i class="icon-star"></i>
254
  <span>Reviews</span>
255
  </a>
256
- <a target="_blank" href="https://twitter.com/aamplugin">
257
- <i class="icon-twitter"></i>
258
- <span>Twitter</span>
259
- </a>
260
  <a target="_blank" href="https://aamplugin.com">
261
  <i class="icon-home"></i>
262
  <span>Website</span>
253
  <i class="icon-star"></i>
254
  <span>Reviews</span>
255
  </a>
 
 
 
 
256
  <a target="_blank" href="https://aamplugin.com">
257
  <i class="icon-home"></i>
258
  <span>Website</span>
Application/Backend/phtml/utility.phtml CHANGED
@@ -49,6 +49,29 @@
49
  <div role="tabpanel" class="tab-pane" id="utility-tools">
50
  <table class="table table-striped table-bordered">
51
  <tbody>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  <tr>
53
  <td>
54
  <span class='aam-setting-title'><?php echo __('Clear Cache', AAM_KEY); ?></span>
@@ -57,14 +80,14 @@
57
  </p>
58
  </td>
59
  <td>
60
- <a href="#" class="btn btn-warning btn-block" id="clear-cache">Clear</a>
61
  </td>
62
  </tr>
63
  <tr>
64
  <td>
65
  <span class='aam-setting-title'><?php echo __('Clear All Settings', AAM_KEY); ?></span>
66
  <p class="aam-setting-description">
67
- <?php echo __('Remove all the settings related to AAM (including all extension licenses).', AAM_KEY); ?>
68
  </p>
69
  </td>
70
  <td>
49
  <div role="tabpanel" class="tab-pane" id="utility-tools">
50
  <table class="table table-striped table-bordered">
51
  <tbody>
52
+ <tr>
53
+ <td>
54
+ <span class='aam-setting-title'><?php echo __('Export AAM Settings', AAM_KEY); ?></span>
55
+ <p class="aam-setting-description">
56
+ <?php echo sprintf(__('Export selected AAM settings to the file. For more information about this feature check %sHow to export and import AAM settings%s article.', AAM_KEY), '<a href="https://aamplugin.com/help/how-to-export-and-import-aam-settings" target="_blank">', '</a>'); ?>
57
+ </p>
58
+ </td>
59
+ <td>
60
+ <a href="#" class="btn btn-success btn-block" id="export-aam">Export</a>
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>
65
+ <span class='aam-setting-title'><?php echo __('Import AAM Settings', AAM_KEY); ?></span>
66
+ <p class="aam-setting-description">
67
+ <?php echo __('Import AAM settings from the file.', AAM_KEY); ?>
68
+ </p>
69
+ </td>
70
+ <td>
71
+ <div class="hidden"><input type="file" id="aam-import-file" /></div>
72
+ <a href="#" class="btn btn-warning btn-block" id="import-aam">Import</a>
73
+ </td>
74
+ </tr>
75
  <tr>
76
  <td>
77
  <span class='aam-setting-title'><?php echo __('Clear Cache', AAM_KEY); ?></span>
80
  </p>
81
  </td>
82
  <td>
83
+ <a href="#" class="btn btn-primary btn-block" id="clear-cache">Clear</a>
84
  </td>
85
  </tr>
86
  <tr>
87
  <td>
88
  <span class='aam-setting-title'><?php echo __('Clear All Settings', AAM_KEY); ?></span>
89
  <p class="aam-setting-description">
90
+ <?php echo __('Remove all the settings related to AAM from the database.', AAM_KEY); ?>
91
  </p>
92
  </td>
93
  <td>
Application/Core/Exporter.php ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * ======================================================================
5
+ * LICENSE: This file is subject to the terms and conditions defined in *
6
+ * file 'license.txt', which is part of this source code package. *
7
+ * ======================================================================
8
+ */
9
+
10
+ /**
11
+ * AAM Exporter
12
+ *
13
+ * @package AAM
14
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
+ */
16
+ class AAM_Core_Exporter {
17
+
18
+ /**
19
+ *
20
+ * @var type
21
+ */
22
+ protected $config = array();
23
+
24
+ /**
25
+ *
26
+ * @var type
27
+ */
28
+ protected $output = array();
29
+
30
+ /**
31
+ *
32
+ * @var type
33
+ */
34
+ protected $cache = array();
35
+
36
+ /**
37
+ *
38
+ * @param type $config
39
+ */
40
+ public function __construct($config) {
41
+ $this->config = $config;
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @return type
47
+ */
48
+ public function run() {
49
+ $this->output = array(
50
+ 'version' => AAM_Core_API::version(),
51
+ 'plugin' => AAM_KEY,
52
+ 'datetime' => date('Y-m-d H:i:s'),
53
+ 'metadata' => $this->config,
54
+ 'dataset' => array()
55
+ );
56
+
57
+ foreach($this->config as $backet => $features) {
58
+ $method = 'export' . ucfirst($backet);
59
+
60
+ if (method_exists($this, $method)) {
61
+ call_user_func(array($this, $method), explode(',', $features));
62
+ } else {
63
+ $this->output = apply_filters(
64
+ 'aam-export', $this->output, $backet, $this->config
65
+ );
66
+ }
67
+ }
68
+
69
+ return json_encode($this->output);
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @global type $wpdb
75
+ * @param type $features
76
+ */
77
+ protected function exportSystem($features) {
78
+ global $wpdb;
79
+
80
+ foreach($features as $feature) {
81
+ if ($feature == 'roles') {
82
+ $this->add('_user_roles', serialize(
83
+ AAM_Core_API::getOption($wpdb->get_blog_prefix() . 'user_roles')
84
+ ));
85
+ } elseif ($feature == 'utilities') {
86
+ $this->add(AAM_Core_Config::OPTION, serialize(AAM_Core_API::getOption(
87
+ AAM_Core_Config::OPTION
88
+ )));
89
+ } else {
90
+ do_action('aam-export', 'system', $feature, $this);
91
+ }
92
+ }
93
+ }
94
+
95
+ /**
96
+ *
97
+ * @param type $features
98
+ */
99
+ protected function exportRoles($features) {
100
+ foreach($features as $feature) {
101
+ if ($feature == 'menu') {
102
+ $this->pushData('options', '/^aam_menu_role/');
103
+ } elseif ($feature == 'metabox') {
104
+ $this->pushData('options', '/^aam_metabox_role/');
105
+ } elseif ($feature == 'post') {
106
+ $this->pushData('options', '/^aam_type_post_role/');
107
+ $this->pushData('options', '/^aam_term_[\d]+\|.+_role/');
108
+ $this->pushData('postmeta', '/^aam-post-access-role/');
109
+ } elseif ($feature == 'redirect') {
110
+ $this->pushData('options', '/^aam_redirect_role/');
111
+ $this->pushData('options', '/^aam_loginredirect_role/');
112
+ $this->pushData('options', '/^aam_logoutredirect_role/');
113
+ }
114
+ }
115
+ }
116
+
117
+ /**
118
+ *
119
+ * @param type $features
120
+ */
121
+ protected function exportUsers($features) {
122
+ global $wpdb;
123
+
124
+ foreach($features as $feature) {
125
+ if ($feature == 'menu') {
126
+ $this->pushData('usermeta', '/^' . $wpdb->prefix . 'aam_menu/');
127
+ } elseif ($feature == 'metabox') {
128
+ $this->pushData('usermeta', '/^' . $wpdb->prefix . 'aam_metabox/');
129
+ } elseif ($feature == 'post') {
130
+ $this->pushData('usermeta', '/^' . $wpdb->prefix . 'aam_type_post/');
131
+ $this->pushData('usermeta', '/^' . $wpdb->prefix . 'aam_term_[\d]+\|/');
132
+ $this->pushData('postmeta', '/^aam-post-access-user/');
133
+ } elseif ($feature == 'redirect') {
134
+ $this->pushData('usermeta', '/^' . $wpdb->prefix . 'aam_redirect/');
135
+ $this->pushData('usermeta', '/^' . $wpdb->prefix . 'aam_loginredirect/');
136
+ $this->pushData('usermeta', '/^' . $wpdb->prefix . 'aam_logoutredirect/');
137
+ } elseif ($feature == 'capability') {
138
+ $this->pushData('usermeta', '/^' . $wpdb->prefix . 'aam_capability/');
139
+ }
140
+ }
141
+ }
142
+
143
+ /**
144
+ *
145
+ * @param type $features
146
+ */
147
+ protected function exportVisitor($features) {
148
+ foreach($features as $feature) {
149
+ if ($feature == 'metabox') {
150
+ $this->pushData('options', '/^aam_visitor_metabox/');
151
+ } elseif ($feature == 'post') {
152
+ $this->pushData('options', '/^aam_visitor_type_post/');
153
+ $this->pushData('options', '/^aam_visitor_term_/');
154
+ $this->pushData('postmeta', '/^aam-post-access-visitor/');
155
+ } elseif ($feature == 'redirect') {
156
+ $this->pushData('options', '/^aam_visitor_redirect/');
157
+ }
158
+ }
159
+ }
160
+
161
+ /**
162
+ *
163
+ * @param type $features
164
+ */
165
+ protected function exportDefault($features) {
166
+ foreach($features as $feature) {
167
+ if ($feature == 'menu') {
168
+ $this->pushData('options', '/^aam_menu_default/');
169
+ } elseif ($feature == 'metabox') {
170
+ $this->pushData('options', '/^aam_metabox_default/');
171
+ } elseif ($feature == 'post') {
172
+ $this->pushData('options', '/^aam_type_post_default/');
173
+ $this->pushData('options', '/^aam_term_[\d]+\|.+_default/');
174
+ $this->pushData('postmeta', '/^aam-post-access-default/');
175
+ } elseif ($feature == 'redirect') {
176
+ $this->pushData('options', '/^aam_redirect_default/');
177
+ $this->pushData('options', '/^aam_loginredirect_default/');
178
+ $this->pushData('options', '/^aam_logoutredirect_default/');
179
+ }
180
+ }
181
+ }
182
+
183
+ /**
184
+ *
185
+ * @param type $group
186
+ * @param type $regexp
187
+ */
188
+ public function pushData($group, $regexp) {
189
+ $cache = $this->getCache();
190
+
191
+ if (is_array($cache[$group])) {
192
+ foreach($cache[$group] as $option) {
193
+ if (isset($option->user_id)) {
194
+ $id = $option->user_id;
195
+ } elseif (isset($option->post_id)) {
196
+ $id = $option->post_id;
197
+ } else {
198
+ $id = null;
199
+ }
200
+
201
+ if (isset($option->option_name)) {
202
+ if (preg_match($regexp, $option->option_name)) {
203
+ $this->add(
204
+ $this->stripPrefix($option->option_name),
205
+ $option->option_value,
206
+ '_' . $group,
207
+ $id
208
+ );
209
+ }
210
+ } elseif (isset($option->meta_key)) {
211
+ if (preg_match($regexp, $option->meta_key)) {
212
+ $this->add(
213
+ $this->stripPrefix($option->meta_key),
214
+ $option->meta_value,
215
+ '_' . $group,
216
+ $id
217
+ );
218
+ }
219
+ }
220
+ }
221
+ }
222
+ }
223
+
224
+ /**
225
+ *
226
+ * @global type $wpdb
227
+ * @param type $key
228
+ * @return type
229
+ */
230
+ public function stripPrefix($key) {
231
+ global $wpdb;
232
+
233
+ return preg_replace('/^' . $wpdb->prefix . '/', '_', $key);
234
+ }
235
+
236
+ /**
237
+ *
238
+ * @param type $key
239
+ * @param type $value
240
+ * @param type $group
241
+ */
242
+ public function add($key, $value, $group = '_options', $id = null) {
243
+ if (is_null($id)) {
244
+ $this->output['dataset'][$group][$key] = $value;
245
+ } else {
246
+ $this->output['dataset'][$group][$id][$key] = $value;
247
+ }
248
+ }
249
+
250
+ /**
251
+ *
252
+ * @global type $wpdb
253
+ * @return type
254
+ */
255
+ protected function getCache() {
256
+ global $wpdb;
257
+
258
+ if (empty($this->cache)) {
259
+ $query = "SELECT option_name, option_value FROM {$wpdb->options} ";
260
+ $query .= "WHERE option_name LIKE 'aam%'";
261
+
262
+ $this->cache['options'] = $wpdb->get_results($query);
263
+
264
+ $query = "SELECT user_id, meta_key, meta_value FROM {$wpdb->usermeta} ";
265
+ $query .= "WHERE meta_key LIKE '{$wpdb->prefix}aam%'";
266
+
267
+ $this->cache['usermeta'] = $wpdb->get_results($query);
268
+
269
+ $query = "SELECT post_id, meta_key, meta_value FROM {$wpdb->postmeta} ";
270
+ $query .= "WHERE meta_key LIKE 'aam%'";
271
+
272
+ $this->cache['postmeta'] = $wpdb->get_results($query);
273
+ }
274
+
275
+ return $this->cache;
276
+ }
277
+
278
+ }
Application/Core/Importer.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * ======================================================================
5
+ * LICENSE: This file is subject to the terms and conditions defined in *
6
+ * file 'license.txt', which is part of this source code package. *
7
+ * ======================================================================
8
+ */
9
+
10
+ /**
11
+ * AAM Importer
12
+ *
13
+ * @package AAM
14
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
+ */
16
+ class AAM_Core_Importer {
17
+
18
+ /**
19
+ *
20
+ * @var type
21
+ */
22
+ protected $input = null;
23
+
24
+ /**
25
+ *
26
+ * @param type $input
27
+ */
28
+ public function __construct($input) {
29
+ $this->input = json_decode($input);
30
+ }
31
+
32
+ /**
33
+ *
34
+ * @return type
35
+ */
36
+ public function run() {
37
+ foreach($this->input->dataset as $table => $data) {
38
+ if ($table == '_options') {
39
+ $this->insertOptions($data);
40
+ } elseif ($table == '_postmeta') {
41
+ $this->insertPostmeta($data);
42
+ } elseif ($table == '_usermeta') {
43
+ $this->insertUsermeta($data);
44
+ } else {
45
+ do_action('aam-import', $table, $data);
46
+ }
47
+ }
48
+
49
+ return 'success';
50
+ }
51
+
52
+ protected function insertOptions($data) {
53
+ global $wpdb;
54
+
55
+ foreach($data as $key => $value) {
56
+ update_option(
57
+ preg_replace('/^_/', $wpdb->prefix, $key),
58
+ $this->prepareValue($value)
59
+ );
60
+ }
61
+ }
62
+
63
+ protected function insertUsermeta($data) {
64
+ global $wpdb;
65
+
66
+ foreach($data as $id => $set) {
67
+ foreach($set as $key => $value) {
68
+ update_user_meta(
69
+ $id,
70
+ preg_replace('/^_/', $wpdb->prefix, $key),
71
+ $this->prepareValue($value)
72
+ );
73
+ }
74
+ }
75
+ }
76
+
77
+ protected function insertPostmeta($data) {
78
+ global $wpdb;
79
+
80
+ foreach($data as $id => $set) {
81
+ foreach($set as $key => $value) {
82
+ update_post_meta(
83
+ $id,
84
+ preg_replace('/^_/', $wpdb->prefix, $key),
85
+ $this->prepareValue($value)
86
+ );
87
+ }
88
+ }
89
+ }
90
+
91
+ protected function prepareValue($value) {
92
+ if (is_serialized($value)) {
93
+ $value = unserialize($value);
94
+ }
95
+
96
+ return $value;
97
+ }
98
+
99
+ }
Application/Frontend/Manager.php CHANGED
@@ -376,7 +376,8 @@ class AAM_Frontend_Manager {
376
  AAM_Core_Config::get("frontend.404redirect.{$type}")
377
  );
378
  }
379
- } elseif ($wp_query->is_single || $wp_query->is_page) {
 
380
  $post = $this->getCurrentPost();
381
 
382
  if (is_a($post, 'WP_Post')) {
376
  AAM_Core_Config::get("frontend.404redirect.{$type}")
377
  );
378
  }
379
+ } elseif ($wp_query->is_single || $wp_query->is_page
380
+ || $wp_query->is_posts_page || $wp_query->is_home) {
381
  $post = $this->getCurrentPost();
382
 
383
  if (is_a($post, 'WP_Post')) {
aam.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  Plugin Name: Advanced Access Manager
5
  Description: All you need to manage access to your WordPress website
6
- Version: 4.8.1
7
  Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
  Author URI: https://vasyltech.com
9
 
3
  /**
4
  Plugin Name: Advanced Access Manager
5
  Description: All you need to manage access to your WordPress website
6
+ Version: 4.9
7
  Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
  Author URI: https://vasyltech.com
9
 
media/css/aam.css CHANGED
@@ -264,6 +264,10 @@ div.error {
264
  border-radius: 0;
265
  }
266
 
 
 
 
 
267
  .list-group li {
268
  cursor: pointer;
269
  font-size: 1.1em;
264
  border-radius: 0;
265
  }
266
 
267
+ .form-control.highlight {
268
+ border: 2px solid #f0ad4e;
269
+ }
270
+
271
  .list-group li {
272
  cursor: pointer;
273
  font-size: 1.1em;
media/js/aam-interface.js CHANGED
@@ -1584,6 +1584,15 @@
1584
  infoFiltered: '',
1585
  lengthMenu: '_MENU_'
1586
  },
 
 
 
 
 
 
 
 
 
1587
  rowCallback: function (row, data) {
1588
  //object type icon
1589
  switch (data[2]) {
@@ -2094,7 +2103,7 @@
2094
  });
2095
  });
2096
 
2097
- $('input,select,textarea', container).each(function () {
2098
  $(this).bind('change', function () {
2099
  if ($(this).is('input[type="checkbox"]')) {
2100
  var val = $(this).prop('checked') ? $(this).val() : 0;
@@ -2491,6 +2500,10 @@
2491
  );
2492
  $('#extension-notification-modal').modal('hide');
2493
  });
 
 
 
 
2494
  }
2495
 
2496
  aam.addHook('init', initialize);
@@ -2585,6 +2598,96 @@
2585
  }
2586
  });
2587
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2588
  }
2589
 
2590
  aam.addHook('init', initialize);
1584
  infoFiltered: '',
1585
  lengthMenu: '_MENU_'
1586
  },
1587
+ initComplete: function () {
1588
+ $('#post-list_filter .form-control').bind('change', function() {
1589
+ if ($(this).val()) {
1590
+ $(this).addClass('highlight');
1591
+ } else {
1592
+ $(this).removeClass('highlight');
1593
+ }
1594
+ });
1595
+ },
1596
  rowCallback: function (row, data) {
1597
  //object type icon
1598
  switch (data[2]) {
2103
  });
2104
  });
2105
 
2106
+ $('input[type="text"],select,textarea', container).each(function () {
2107
  $(this).bind('change', function () {
2108
  if ($(this).is('input[type="checkbox"]')) {
2109
  var val = $(this).prop('checked') ? $(this).val() : 0;
2500
  );
2501
  $('#extension-notification-modal').modal('hide');
2502
  });
2503
+
2504
+ if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) {
2505
+ $('#safari-download-notification').removeClass('hidden');
2506
+ }
2507
  }
2508
 
2509
  aam.addHook('init', initialize);
2598
  }
2599
  });
2600
  });
2601
+
2602
+ $('#export-aam').bind('click', function () {
2603
+ $.ajax(aamLocal.ajaxurl, {
2604
+ type: 'POST',
2605
+ dataType: 'json',
2606
+ data: {
2607
+ action: 'aam',
2608
+ sub_action: 'Utility.export',
2609
+ _ajax_nonce: aamLocal.nonce
2610
+ },
2611
+ beforeSend: function () {
2612
+ $('#export-aam').attr('data-lable', $('#export-aam').text());
2613
+ $('#export-aam').html('<i class="icon-spin4 animate-spin"></i>');
2614
+ },
2615
+ success: function(response) {
2616
+ if (response.status === 'success') {
2617
+ download(
2618
+ 'data:text/plain;base64,' + response.content,
2619
+ 'aam-export.json',
2620
+ 'text/plain'
2621
+ );
2622
+ }
2623
+ },
2624
+ error: function () {
2625
+ aam.notification('danger', aam.__('Application Error'));
2626
+ },
2627
+ complete: function () {
2628
+ $('#export-aam').html($('#export-aam').attr('data-lable'));
2629
+ }
2630
+ });
2631
+ });
2632
+
2633
+ $('#import-aam').bind('click', function () {
2634
+ if (typeof FileReader !== 'undefined') {
2635
+ $('#aam-import-file').trigger('click');
2636
+ } else {
2637
+ aam.notification('danger', 'Your browser does not support FileReader functionality');
2638
+ }
2639
+ });
2640
+
2641
+ $('#aam-import-file').bind('change', function () {
2642
+ var file = $(this)[0].files[0];
2643
+ var json = null;
2644
+
2645
+ var reader = new FileReader();
2646
+ reader.onload = function(e) {
2647
+ json = reader.result;
2648
+
2649
+ try {
2650
+ //validate the content
2651
+ var loaded = JSON.parse(json);
2652
+ if (loaded.plugin && loaded.plugin == 'advanced-access-manager') {
2653
+ $.ajax(aamLocal.ajaxurl, {
2654
+ type: 'POST',
2655
+ dataType: 'json',
2656
+ data: {
2657
+ action: 'aam',
2658
+ sub_action: 'Utility.import',
2659
+ _ajax_nonce: aamLocal.nonce,
2660
+ json: json
2661
+ },
2662
+ beforeSend: function () {
2663
+ $('#import-aam').attr('data-lable', $('#import-aam').text());
2664
+ $('#import-aam').html('<i class="icon-spin4 animate-spin"></i>');
2665
+ },
2666
+ success: function(response) {
2667
+ if (response.status === 'success') {
2668
+ aam.notification('success', 'Data Imported Successfully');
2669
+ // location.reload();
2670
+ } else {
2671
+ aam.notification('danger', aam.__('Invalid data format'));
2672
+ }
2673
+ },
2674
+ error: function () {
2675
+ aam.notification('danger', aam.__('Application Error'));
2676
+ },
2677
+ complete: function () {
2678
+ $('#import-aam').html($('#import-aam').attr('data-lable'));
2679
+ }
2680
+ });
2681
+ } else {
2682
+ throw 'Invalid format';
2683
+ }
2684
+ } catch (e) {
2685
+ aam.notification('danger', 'Invalid file format');
2686
+ }
2687
+ };
2688
+ reader.readAsText(file);
2689
+
2690
+ });
2691
  }
2692
 
2693
  aam.addHook('init', initialize);
media/js/vendor.js CHANGED
@@ -215,5 +215,5 @@ type:"inline"}};var m=e.fn.dataTable.Api;m.register("responsive()",function(){re
215
  h.version="1.0.7";e.fn.dataTable.Responsive=h;e.fn.DataTable.Responsive=h;e(p).on("init.dt.dtr",function(d,a){if("dt"===d.namespace&&(e(a.nTable).hasClass("responsive")||e(a.nTable).hasClass("dt-responsive")||a.oInit.responsive||k.defaults.responsive)){var c=a.oInit.responsive;!1!==c&&new h(a,e.isPlainObject(c)?c:{})}});return h};"function"===typeof define&&define.amd?define(["jquery","datatables"],o):"object"===typeof exports?o(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.Responsive&&
216
  o(jQuery,jQuery.fn.dataTable)})(window,document);
217
 
218
- //download.js v3.1, by dandavis; 2008-2015. [CCBY2] see http://danml.com/download.html for tests/usage
219
- (function(f,a){"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?module.exports=a():f.download=a()})(this,function(){return function(f,a,b){function n(l){var a=l.split(/[:;,]/);l=a[1];var a=("base64"==a[2]?atob:decodeURIComponent)(a.pop()),c=a.length,b=0,d=new Uint8Array(c);for(b;b<c;++b)d[b]=a.charCodeAt(b);return new g([d],{type:l})}function k(a,b){if("download"in d)return d.href=a,d.setAttribute("download",m),d.innerHTML="downloading...",h.body.appendChild(d),setTimeout(function(){d.click(),h.body.removeChild(d),!0===b&&setTimeout(function(){e.URL.revokeObjectURL(d.href)},250)},66),!0;if("undefined"!=typeof safari)return a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream"),!window.open(a)&&confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=a),!0;var c=h.createElement("iframe");h.body.appendChild(c),b||(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),c.src=a,setTimeout(function(){h.body.removeChild(c)},333)}var e=window;b=b||"application/octet-stream";var c=f,h=document,d=h.createElement("a");f=function(a){return String(a)};var g=e.Blob||e.MozBlob||e.WebKitBlob||f,g=g.call?g.bind(e):Blob,m=a||"download";"true"===String(this)&&(c=[c,b],b=c[0],c=c[1]);if(String(c).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/))return navigator.msSaveBlob?navigator.msSaveBlob(n(c),m):k(c);a=c instanceof g?c:new g([c],{type:b});if(navigator.msSaveBlob)return navigator.msSaveBlob(a,m);if(e.URL)k(e.URL.createObjectURL(a),!0);else{if("string"==typeof a||a.constructor===f)try{return k("data:"+b+";base64,"+e.btoa(a))}catch(p){return k("data:"+b+","+encodeURIComponent(a))}b=new FileReader,b.onload=function(a){k(this.result)},b.readAsDataURL(a)}return!0}});
215
  h.version="1.0.7";e.fn.dataTable.Responsive=h;e.fn.DataTable.Responsive=h;e(p).on("init.dt.dtr",function(d,a){if("dt"===d.namespace&&(e(a.nTable).hasClass("responsive")||e(a.nTable).hasClass("dt-responsive")||a.oInit.responsive||k.defaults.responsive)){var c=a.oInit.responsive;!1!==c&&new h(a,e.isPlainObject(c)?c:{})}});return h};"function"===typeof define&&define.amd?define(["jquery","datatables"],o):"object"===typeof exports?o(require("jquery"),require("datatables")):jQuery&&!jQuery.fn.dataTable.Responsive&&
216
  o(jQuery,jQuery.fn.dataTable)})(window,document);
217
 
218
+ //download.js v4.2, by dandavis; 2008-2017. [MIT] see http://danml.com/download.html for tests/usage
219
+ ;(function(r,l){"function"==typeof define&&define.amd?define([],l):"object"==typeof exports?module.exports=l():r.download=l()})(this,function(){return function l(a,e,k){function q(a){var h=a.split(/[:;,]/);a=h[1];var h=("base64"==h[2]?atob:decodeURIComponent)(h.pop()),d=h.length,b=0,c=new Uint8Array(d);for(b;b<d;++b)c[b]=h.charCodeAt(b);return new f([c],{type:a})}function m(a,b){if("download"in d)return d.href=a,d.setAttribute("download",n),d.className="download-js-link",d.innerHTML="downloading...",d.style.display="none",document.body.appendChild(d),setTimeout(function(){d.click(),document.body.removeChild(d),!0===b&&setTimeout(function(){g.URL.revokeObjectURL(d.href)},250)},66),!0;if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent))return/^data:/.test(a)&&(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),!window.open(a)&&confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=a),!0;var c=document.createElement("iframe");document.body.appendChild(c),!b&&/^data:/.test(a)&&(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),c.src=a,setTimeout(function(){document.body.removeChild(c)},333)}var g=window,b=k||"application/octet-stream",c=!e&&!k&&a,d=document.createElement("a");k=function(a){return String(a)};var f=g.Blob||g.MozBlob||g.WebKitBlob||k,n=e||"download",f=f.call?f.bind(g):Blob;"true"===String(this)&&(a=[a,b],b=a[0],a=a[1]);if(c&&2048>c.length&&(n=c.split("/").pop().split("?")[0],d.href=c,-1!==d.href.indexOf(c))){var p=new XMLHttpRequest;return p.open("GET",c,!0),p.responseType="blob",p.onload=function(a){l(a.target.response,n,"application/octet-stream")},setTimeout(function(){p.send()},0),p}if(/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(a)){if(!(2096103.424<a.length&&f!==k))return navigator.msSaveBlob?navigator.msSaveBlob(q(a),n):m(a);a=q(a),b=a.type||"application/octet-stream"}else if(/([\x80-\xff])/.test(a)){e=0;var c=new Uint8Array(a.length),t=c.length;for(e;e<t;++e)c[e]=a.charCodeAt(e);a=new f([c],{type:b})}a=a instanceof f?a:new f([a],{type:b});if(navigator.msSaveBlob)return navigator.msSaveBlob(a,n);if(g.URL)m(g.URL.createObjectURL(a),!0);else{if("string"==typeof a||a.constructor===k)try{return m("data:"+b+";base64,"+g.btoa(a))}catch(h){return m("data:"+b+","+encodeURIComponent(a))}b=new FileReader,b.onload=function(a){m(this.result)},b.readAsDataURL(a)}return!0}});
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: vasyltech
3
  Tags: access, role, user, capability, page access, post access, comments, security, login redirect, brute force attack, double authentication, membership, backend lockdown, wp-admin, 404, activity tracking
4
  Requires at least: 3.8
5
  Tested up to: 4.8
6
- Stable tag: 4.8.1
7
 
8
  Manage access to your website for any user, role or visitors for both frontend and backend.
9
 
@@ -110,6 +110,14 @@ Check our [help page](https://aamplugin.com/help) to find out more about AAM.
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
 
 
113
  = 4.8.1 =
114
  * Added ability to control post_password_expires with post.password.expires config
115
  * Improved media access
3
  Tags: access, role, user, capability, page access, post access, comments, security, login redirect, brute force attack, double authentication, membership, backend lockdown, wp-admin, 404, activity tracking
4
  Requires at least: 3.8
5
  Tested up to: 4.8
6
+ Stable tag: 4.9
7
 
8
  Manage access to your website for any user, role or visitors for both frontend and backend.
9
 
110
 
111
  == Changelog ==
112
 
113
+ = 4.9 =
114
+ * Fixed bug with Login Redirect duplicate settings saving
115
+ * Added ability to hide license key with aam_display_license capability
116
+ * Added ability to export/import AAM settings
117
+ * Improved AAM UI
118
+ * Added ability to restrict access to the Hope page
119
+ * Added ability to manage access to frontend ajax calls with allow_ajax_calls cap
120
+
121
  = 4.8.1 =
122
  * Added ability to control post_password_expires with post.password.expires config
123
  * Improved media access