Advanced Access Manager - Version 6.9.1

Version Description

  • Fixed: Incorrectly stripped backslashes for Access Policy https://github.com/aamplugin/advanced-access-manager/issues/228
  • Fixed: PHP Notice: Function AAM_Backend_Subject::hasCapability was called incorrectly https://github.com/aamplugin/advanced-access-manager/issues/227
  • Fixed: PHP Notice: Undefined offset: -1 in https://github.com/aamplugin/advanced-access-manager/issues/226
  • Added New: Add the ability to hook into filter https://github.com/aamplugin/advanced-access-manager/issues/225
Download this release

Release Info

Developer vasyltech
Plugin Icon 128x128 Advanced Access Manager
Version 6.9.1
Comparing to
See all releases

Code changes from version 6.9.0 to 6.9.1

aam.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  * Plugin Name: Advanced Access Manager
5
  * Description: Collection of features to manage your WordPress website authentication, authorization and monitoring
6
- * Version: 6.9.0
7
  * Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
  * Author URI: https://vasyltech.com
9
  * Text Domain: advanced-access-manager
@@ -264,7 +264,7 @@ if (defined('ABSPATH')) {
264
  // Define few common constants
265
  define('AAM_MEDIA', plugins_url('/media', __FILE__));
266
  define('AAM_KEY', 'advanced-access-manager');
267
- define('AAM_VERSION', '6.9.0');
268
  define('AAM_BASEDIR', __DIR__);
269
 
270
  // Load vendor
3
  /**
4
  * Plugin Name: Advanced Access Manager
5
  * Description: Collection of features to manage your WordPress website authentication, authorization and monitoring
6
+ * Version: 6.9.1
7
  * Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
  * Author URI: https://vasyltech.com
9
  * Text Domain: advanced-access-manager
264
  // Define few common constants
265
  define('AAM_MEDIA', plugins_url('/media', __FILE__));
266
  define('AAM_KEY', 'advanced-access-manager');
267
+ define('AAM_VERSION', '6.9.1');
268
  define('AAM_BASEDIR', __DIR__);
269
 
270
  // Load vendor
application/Backend/tmpl/metabox/policy-metabox.php CHANGED
@@ -1,12 +1,13 @@
1
  <?php
2
  /**
 
3
  * @since 6.8.4 https://github.com/aamplugin/advanced-access-manager/issues/212
4
  * @since 6.2.2 Slightly changed the way errors are displayed
5
  * @since 6.2.0 Escaping backslashes to avoid issue with JSON validation
6
  * @since 6.1.1 Removing the backslashes before displaying the policy
7
  * @since 6.0.0 Initial implementation of the template
8
  *
9
- * @version 6.8.4
10
  */
11
  if (defined('AAM_KEY')) { ?>
12
  <div>
@@ -36,34 +37,12 @@ if (defined('AAM_KEY')) { ?>
36
  ?>
37
  </div>
38
 
39
- <textarea id="aam-policy-editor" name="aam-policy" class="policy-editor" style="border: 1px solid #CCCCCC; width: 100%" rows="10"><?php echo stripslashes($params->post->post_content); ?></textarea>
40
 
41
  <p class="aam-infobox">
42
  <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('To learn more about Access &amp; Security policy document, please check [%sAccess &amp; Security Policy%s] page.', 'b'), '<a href="https://aamplugin.com/reference/policy" target="_blank">', '</a>'); ?>
43
  </p>
44
 
45
  <script type='text/javascript' src="<?php echo AAM_MEDIA . '/js/vendor.js'; ?>"></script>
46
-
47
- <script type='text/javascript'>
48
- (function($) {
49
- $(document).ready(function() {
50
- $('form[name="post"]').bind('submit', function(event) {
51
- const json = $('#aam-policy-editor').val().replace(/\\/g, '\\\\');
52
-
53
- $('#policy-parsing-error').addClass('hidden');
54
-
55
- try {
56
- JSON.parse(json);
57
- } catch (e) {
58
- event.preventDefault();
59
-
60
- $('#policy-parsing-error').removeClass('hidden').html(
61
- '<b><?php echo __('Syntax Error', AAM_KEY); ?></b>: ' + e.message.replace('JSON.parse:', '')
62
- );
63
- }
64
- });
65
- });
66
- }(jQuery));
67
- </script>
68
  </div>
69
  <?php }
1
  <?php
2
  /**
3
+ * @since 6.9.1 https://github.com/aamplugin/advanced-access-manager/issues/228
4
  * @since 6.8.4 https://github.com/aamplugin/advanced-access-manager/issues/212
5
  * @since 6.2.2 Slightly changed the way errors are displayed
6
  * @since 6.2.0 Escaping backslashes to avoid issue with JSON validation
7
  * @since 6.1.1 Removing the backslashes before displaying the policy
8
  * @since 6.0.0 Initial implementation of the template
9
  *
10
+ * @version 6.9.1
11
  */
12
  if (defined('AAM_KEY')) { ?>
13
  <div>
37
  ?>
38
  </div>
39
 
40
+ <textarea id="aam-policy-editor" name="aam-policy" class="policy-editor" style="border: 1px solid #CCCCCC; width: 100%" rows="10"><?php echo $params->post->post_content; ?></textarea>
41
 
42
  <p class="aam-infobox">
43
  <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('To learn more about Access &amp; Security policy document, please check [%sAccess &amp; Security Policy%s] page.', 'b'), '<a href="https://aamplugin.com/reference/policy" target="_blank">', '</a>'); ?>
44
  </p>
45
 
46
  <script type='text/javascript' src="<?php echo AAM_MEDIA . '/js/vendor.js'; ?>"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  </div>
48
  <?php }
application/Core/ConfigPress/Evaluator.php DELETED
@@ -1,334 +0,0 @@
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
- * @version 6.0.0
10
- */
11
-
12
- /**
13
- * ConfigPress section evaluator
14
- *
15
- * Parse configuration section and evaluate an expression. At this point it
16
- * does not take in consideration the operator's precedence but you can force
17
- * the order with parentheses.
18
- *
19
- * @package AAM
20
- * @author Vasyl Martyniuk <vasyl@vasyltech.com>
21
- * @version 6.0.0
22
- */
23
- class AAM_Core_ConfigPress_Evaluator
24
- {
25
-
26
- /**
27
- * Accepted operators
28
- *
29
- * @var array
30
- *
31
- * @access private
32
- * @version 6.0.0
33
- */
34
- private $_operators = array(
35
- array('*', '/'), //the highest priority
36
- array('+', '-'),
37
- array('==', '!=', '===', '!==', '<', '>', '>=', '<=', '<>'),
38
- array('&&', '||'),
39
- array('as') //the lowest priority
40
- );
41
-
42
- /**
43
- * Expression to parse
44
- *
45
- * @var string
46
- *
47
- * @access protected
48
- * @version 6.0.0
49
- */
50
- protected $expression;
51
-
52
- /**
53
- * Parsing expression alias
54
- *
55
- * @var string
56
- *
57
- * @access protected
58
- * @version 6.0.0
59
- */
60
- protected $alias;
61
-
62
- /**
63
- * Current expression part index
64
- *
65
- * @var array
66
- *
67
- * @access protected
68
- * @version 6.0.0
69
- */
70
- protected $index = array(0);
71
-
72
- /**
73
- * Prepare expression evaluation
74
- *
75
- * @param string $expression
76
- *
77
- * @return void
78
- * @version 6.0.0
79
- */
80
- public function __construct($expression)
81
- {
82
- $this->alias = $expression;
83
-
84
- $regexp = '/(===|!==|==|>=|<=|<>|<|>|\+|\-|\*|\/|&&|\|\||\(|\)|\sas\s)/';
85
- $this->expression = preg_split(
86
- $regexp,
87
- $expression,
88
- -1,
89
- PREG_SPLIT_DELIM_CAPTURE
90
- );
91
- }
92
-
93
- /**
94
- * Evaluate the expression
95
- *
96
- * @return mixed
97
- *
98
- * @access public
99
- * @version 6.0.0
100
- */
101
- public function evaluate()
102
- {
103
- $queue = array();
104
-
105
- $index = &$this->index[count($this->index) - 1];
106
-
107
- for ($index; $index < count($this->expression); $index++) {
108
- $chunk = trim($this->expression[$index]);
109
-
110
- if (!empty($chunk)) {
111
- if ($chunk === '(') {
112
- $this->index[] = ++$index;
113
- $queue[] = $this->evaluate();
114
- } elseif ($chunk === ')') {
115
- array_pop($this->index);
116
- $this->index[count($this->index) - 1] = ++$index;
117
- break;
118
- } else { //evaluate operand or operator
119
- $queue[] = $this->evaluateOperand($chunk);
120
- }
121
- }
122
- }
123
-
124
- //compute the queue
125
- return $this->computeQueue($queue);
126
- }
127
-
128
- /**
129
- * Evaluate an operand
130
- *
131
- * @param string $operand
132
- *
133
- * @return mixed
134
- *
135
- * @access protected
136
- * @version 6.0.0
137
- */
138
- protected function evaluateOperand($operand)
139
- {
140
- if (strpos($operand, '$') === 0) { //variable
141
- $operand = $this->parseVariable(substr($operand, 1));
142
- } elseif (strpos($operand, '@') === 0) { //callback function
143
- $operand = $this->parseCallback(substr($operand, 1));
144
- }
145
-
146
- return $operand;
147
- }
148
-
149
- /**
150
- * Evaluate variable
151
- *
152
- * @param string $variable
153
- *
154
- * @return mixed
155
- *
156
- * @access protected
157
- * @version 6.0.0
158
- */
159
- protected function parseVariable($variable)
160
- {
161
- $value = null;
162
-
163
- $xpath = explode('.', $variable);
164
- $root = array_shift($xpath);
165
-
166
- if (isset($GLOBALS[$root])) {
167
- $value = $GLOBALS[$root];
168
- foreach ($xpath as $level) {
169
- if (is_array($value) && isset($value[$level])) {
170
- $value = $value[$level];
171
- } elseif (is_object($value) && property_exists($value, $level)) {
172
- $value = $value->{$level};
173
- } else {
174
- break;
175
- }
176
- }
177
- }
178
-
179
- return $value;
180
- }
181
-
182
- /**
183
- * Evaluate callback function
184
- *
185
- * @param string $callback
186
- *
187
- * @return mixed
188
- *
189
- * @access protected
190
- * @version 6.0.0
191
- */
192
- protected function parseCallback($callback)
193
- {
194
- $value = null;
195
-
196
- if (is_callable($callback)) {
197
- $value = call_user_func($callback);
198
- }
199
-
200
- return $value;
201
- }
202
-
203
- /**
204
- * Compute parsed expression
205
- *
206
- * @param array $queue
207
- *
208
- * @return mixed
209
- *
210
- * @access protected
211
- * @version 6.0.0
212
- */
213
- protected function computeQueue($queue)
214
- {
215
- $value = $queue[0]; //default value
216
-
217
- foreach ($this->_operators as $operators) {
218
- $i = 0;
219
- while ($i < count($queue)) {
220
- if (!is_bool($queue[$i]) && in_array($queue[$i], $operators, true)) {
221
- $value = $this->processOperation(
222
- $queue[$i],
223
- $queue[$i - 1],
224
- $queue[$i + 1]
225
- );
226
- //replace just calculated value
227
- array_splice($queue, --$i, 3, $value);
228
- } else {
229
- $i++;
230
- }
231
- }
232
- }
233
-
234
- return $value;
235
- }
236
-
237
- /**
238
- * Process the calculation
239
- *
240
- * @param string $operation
241
- * @param mixed $operandA
242
- * @param mixed $operandB
243
- *
244
- * @return mixed
245
- *
246
- * @access protected
247
- * @version 6.0.0
248
- */
249
- protected function processOperation($operation, $operandA, $operandB)
250
- {
251
- switch ($operation) {
252
- case '+':
253
- $operandA += $operandB;
254
- break;
255
-
256
- case '-':
257
- $operandA -= $operandB;
258
- break;
259
-
260
- case '*':
261
- $operandA *= $operandB;
262
- break;
263
-
264
- case '/';
265
- $operandA /= $operandB;
266
- break;
267
-
268
- case '==':
269
- $operandA = ($operandA == $operandB);
270
- break;
271
-
272
- case '===':
273
- $operandA = ($operandA === $operandB);
274
- break;
275
-
276
- case '!=':
277
- case '<>':
278
- $operandA = ($operandA != $operandB);
279
- break;
280
-
281
- case '!==':
282
- $operandA = ($operandA !== $operandB);
283
- break;
284
-
285
- case '<':
286
- $operandA = ($operandA < $operandB);
287
- break;
288
-
289
- case '>':
290
- $operandA = ($operandA > $operandB);
291
- break;
292
-
293
- case '<=':
294
- $operandA = ($operandA <= $operandB);
295
- break;
296
-
297
- case '>=':
298
- $operandA = ($operandA >= $operandB);
299
- break;
300
-
301
- case '&&':
302
- $operandA = ($operandA && $operandB);
303
- break;
304
-
305
- case '||':
306
- $operandA = ($operandA || $operandB);
307
- break;
308
-
309
- case 'as':
310
- $this->alias = $operandB;
311
- break;
312
-
313
- default:
314
- $operandA = false;
315
- break;
316
- }
317
-
318
- return $operandA;
319
- }
320
-
321
- /**
322
- * Get section alias
323
- *
324
- * @return string
325
- *
326
- * @access public
327
- * @version 6.0.0
328
- */
329
- public function getAlias()
330
- {
331
- return $this->alias;
332
- }
333
-
334
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
application/Core/ConfigPress/Reader.php CHANGED
@@ -5,8 +5,6 @@
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
- * @version 6.0.0
10
  */
11
 
12
  /**
@@ -14,8 +12,11 @@
14
  *
15
  * Parse configuration string
16
  *
 
 
 
17
  * @package AAM
18
- * @version 6.0.0
19
  */
20
  class AAM_Core_ConfigPress_Reader
21
  {
@@ -27,13 +28,6 @@ class AAM_Core_ConfigPress_Reader
27
  */
28
  const SEPARATOR = '.';
29
 
30
- /**
31
- * Default section inheritance indicator
32
- *
33
- * @version 6.0.0
34
- */
35
- const INHERIT_KEY = ':';
36
-
37
  /**
38
  * Parse INI config
39
  *
@@ -88,27 +82,18 @@ class AAM_Core_ConfigPress_Reader
88
  *
89
  * @return array
90
  *
 
 
 
91
  * @access protected
92
- * @version 6.0.0
93
  */
94
  protected function process(array $data)
95
  {
96
  $config = array();
97
 
98
  foreach ($data as $section => $block) {
99
- //check if section has parent section or property
100
- if (preg_match('/[\s\w]{1}' . self::INHERIT_KEY . '[\s\w]{1}/', $section)) {
101
- $section = $this->inherit($section, $config);
102
- } else {
103
- //evaluate the section and if not false move forward
104
- $evaluator = new AAM_Core_ConfigPress_Evaluator($section);
105
- if ($evaluator->evaluate()) {
106
- $section = $evaluator->getAlias();
107
- $config[$section] = array();
108
- } else {
109
- continue; //conditional section that did not meet condition
110
- }
111
- }
112
 
113
  if (is_array($block)) { //this is a INI section, build the nested tree
114
  $this->buildNestedSection($block, $config[$section]);
@@ -120,30 +105,6 @@ class AAM_Core_ConfigPress_Reader
120
  return $config;
121
  }
122
 
123
- /**
124
- * Inherit settings from different section
125
- *
126
- * @param string $section
127
- * @param array $config
128
- *
129
- * @return string
130
- *
131
- * @access protected
132
- * @version 6.0.0
133
- */
134
- protected function inherit($section, &$config)
135
- {
136
- $sections = explode(self::INHERIT_KEY, $section);
137
- $target = trim($sections[0]);
138
- $parent = trim($sections[1]);
139
-
140
- if (isset($config[$parent])) {
141
- $config[$target] = $config[$parent];
142
- }
143
-
144
- return $target;
145
- }
146
-
147
  /**
148
  * Build the nested config array
149
  *
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
  /**
12
  *
13
  * Parse configuration string
14
  *
15
+ * @since 6.9.1 https://github.com/aamplugin/advanced-access-manager/issues/226
16
+ * @since 6.0.0 Initial implementation of the class
17
+ *
18
  * @package AAM
19
+ * @version 6.9.1
20
  */
21
  class AAM_Core_ConfigPress_Reader
22
  {
28
  */
29
  const SEPARATOR = '.';
30
 
 
 
 
 
 
 
 
31
  /**
32
  * Parse INI config
33
  *
82
  *
83
  * @return array
84
  *
85
+ * @since 6.9.1 https://github.com/aamplugin/advanced-access-manager/issues/226
86
+ * @since 6.0.0 Initial implementation of the method
87
+ *
88
  * @access protected
89
+ * @version 6.9.1
90
  */
91
  protected function process(array $data)
92
  {
93
  $config = array();
94
 
95
  foreach ($data as $section => $block) {
96
+ $config[$section] = array();
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  if (is_array($block)) { //this is a INI section, build the nested tree
99
  $this->buildNestedSection($block, $config[$section]);
105
  return $config;
106
  }
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  /**
109
  * Build the nested config array
110
  *
application/Core/Subject.php CHANGED
@@ -266,6 +266,21 @@ abstract class AAM_Core_Subject
266
  return $this->_siblings;
267
  }
268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
269
  /**
270
  * Get AAM core object
271
  *
266
  return $this->_siblings;
267
  }
268
 
269
+ /**
270
+ * Default placeholder for the verifying capability
271
+ *
272
+ * @param string $cap
273
+ *
274
+ * @return boolean
275
+ *
276
+ * @access public
277
+ * @since 6.9.1
278
+ */
279
+ public function hasCapability($cap)
280
+ {
281
+ return false;
282
+ }
283
+
284
  /**
285
  * Get AAM core object
286
  *
application/Core/Subject/Role.php CHANGED
@@ -212,20 +212,20 @@ class AAM_Core_Subject_Role extends AAM_Core_Subject
212
  /**
213
  * Check if role has capability
214
  *
215
- * @param string $cap
216
  *
217
  * @return boolean
218
  *
219
  * @access public
220
  * @version 6.0.0
221
  */
222
- public function hasCapability($cap)
223
  {
224
  // If capability is the same as role ID, then capability exists
225
- if ($cap === $this->getId()) {
226
  $has = true;
227
  } else {
228
- $has = $this->has_cap($cap);
229
  }
230
 
231
  return $has;
212
  /**
213
  * Check if role has capability
214
  *
215
+ * @param string $capability
216
  *
217
  * @return boolean
218
  *
219
  * @access public
220
  * @version 6.0.0
221
  */
222
+ public function hasCapability($capability)
223
  {
224
  // If capability is the same as role ID, then capability exists
225
+ if ($capability === $this->getId()) {
226
  $has = true;
227
  } else {
228
+ $has = $this->has_cap($capability);
229
  }
230
 
231
  return $has;
application/Service/AccessPolicy.php CHANGED
@@ -10,6 +10,7 @@
10
  /**
11
  * Access Policy service
12
  *
 
13
  * @since 6.8.3 https://github.com/aamplugin/advanced-access-manager/issues/207
14
  * @since 6.4.0 Enhanced https://github.com/aamplugin/advanced-access-manager/issues/71
15
  * Added new hook `aam_post_read_action_conversion_filter`
@@ -22,7 +23,7 @@
22
  * @since 6.0.0 Initial implementation of the class
23
  *
24
  * @package AAM
25
- * @version 6.8.3
26
  */
27
  class AAM_Service_AccessPolicy
28
  {
@@ -181,8 +182,9 @@ class AAM_Service_AccessPolicy
181
  *
182
  * @return void
183
  *
 
184
  * @since 6.8.3 https://github.com/aamplugin/advanced-access-manager/issues/207
185
- * @since 6.4.0 Enhanced https://github.com/aamplugin/advanced-access-manager/issues/71
186
  * https://github.com/aamplugin/advanced-access-manager/issues/62
187
  * https://github.com/aamplugin/advanced-access-manager/issues/63
188
  * @since 6.2.1 Access support for custom-fields
@@ -191,7 +193,7 @@ class AAM_Service_AccessPolicy
191
  * @since 6.0.0 Initial implementation of the method
192
  *
193
  * @access protected
194
- * @version 6.8.3
195
  */
196
  protected function initializeHooks()
197
  {
@@ -229,15 +231,15 @@ class AAM_Service_AccessPolicy
229
  ));
230
  });
231
 
232
- add_action((is_admin() ? 'admin_init' : 'init'), function() {
233
- $manager = AAM::api()->getAccessPolicyManager();
234
- $found = $manager->getResources(AAM_Core_Policy_Resource::HOOK);
235
 
236
- foreach($found as $resource => $stm) {
237
- $parts = explode(':', $resource);
238
 
239
- if (count($parts) === 2) { // Currently support only name:priority
240
- if (isset($stm['Effect']) && $stm['Effect'] === 'deny') {
 
241
  $priority = apply_filters(
242
  'aam_hook_resource_priority', $parts[1]
243
  );
@@ -245,10 +247,14 @@ class AAM_Service_AccessPolicy
245
  if (is_bool($priority) || is_numeric($priority)) {
246
  remove_all_filters($parts[0], $priority);
247
  }
 
 
 
 
248
  }
249
  }
250
  }
251
- }, PHP_INT_MAX);
252
 
253
  // Hook into AAM core objects initialization
254
  add_filter('aam_menu_object_option_filter', array($this, 'applyAccessPolicyToObject'), 10, 2);
10
  /**
11
  * Access Policy service
12
  *
13
+ * @since 6.9.1 https://github.com/aamplugin/advanced-access-manager/issues/225
14
  * @since 6.8.3 https://github.com/aamplugin/advanced-access-manager/issues/207
15
  * @since 6.4.0 Enhanced https://github.com/aamplugin/advanced-access-manager/issues/71
16
  * Added new hook `aam_post_read_action_conversion_filter`
23
  * @since 6.0.0 Initial implementation of the class
24
  *
25
  * @package AAM
26
+ * @version 6.9.1
27
  */
28
  class AAM_Service_AccessPolicy
29
  {
182
  *
183
  * @return void
184
  *
185
+ * @since 6.9.1 https://github.com/aamplugin/advanced-access-manager/issues/225
186
  * @since 6.8.3 https://github.com/aamplugin/advanced-access-manager/issues/207
187
+ * @since 6.4.0 https://github.com/aamplugin/advanced-access-manager/issues/71
188
  * https://github.com/aamplugin/advanced-access-manager/issues/62
189
  * https://github.com/aamplugin/advanced-access-manager/issues/63
190
  * @since 6.2.1 Access support for custom-fields
193
  * @since 6.0.0 Initial implementation of the method
194
  *
195
  * @access protected
196
+ * @version 6.9.1
197
  */
198
  protected function initializeHooks()
199
  {
231
  ));
232
  });
233
 
234
+ $manager = AAM::api()->getAccessPolicyManager();
235
+ $found = $manager->getResources(AAM_Core_Policy_Resource::HOOK);
 
236
 
237
+ foreach($found as $resource => $stm) {
238
+ $parts = explode(':', $resource);
239
 
240
+ if (count($parts) === 2) { // Currently support only name:priority
241
+ if (isset($stm['Effect'])) {
242
+ if ($stm['Effect'] === 'deny') {
243
  $priority = apply_filters(
244
  'aam_hook_resource_priority', $parts[1]
245
  );
247
  if (is_bool($priority) || is_numeric($priority)) {
248
  remove_all_filters($parts[0], $priority);
249
  }
250
+ } else if ($stm['Effect'] === 'apply') {
251
+ add_filter($parts[0], function($response) use ($stm) {
252
+ return isset($stm['Response']) ? $stm['Response'] : $response;
253
+ }, intval($parts[1]));
254
  }
255
  }
256
  }
257
+ }
258
 
259
  // Hook into AAM core objects initialization
260
  add_filter('aam_menu_object_option_filter', array($this, 'applyAccessPolicyToObject'), 10, 2);
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: vasyltech
3
  Tags: access control, membership, backend menu, user role, restricted content, security, jwt
4
  Requires at least: 4.7.0
5
  Requires PHP: 5.6.0
6
- Tested up to: 6.0.2
7
- Stable tag: 6.9.0
8
 
9
  All you need to manage access to WordPress websites on the frontend, backend and API levels for any role, user or visitors.
10
 
@@ -91,6 +91,12 @@ We take security and privacy very seriously, that is why there are several non-n
91
 
92
  == Changelog ==
93
 
 
 
 
 
 
 
94
  = 6.9.0 =
95
  * Fixed: Revoking JWT token via UI causes current user to logout [https://github.com/aamplugin/advanced-access-manager/issues/224](https://github.com/aamplugin/advanced-access-manager/issues/224)
96
  * Fixed: Notice: Undefined variable: cache [https://github.com/aamplugin/advanced-access-manager/issues/223](https://github.com/aamplugin/advanced-access-manager/issues/223)
3
  Tags: access control, membership, backend menu, user role, restricted content, security, jwt
4
  Requires at least: 4.7.0
5
  Requires PHP: 5.6.0
6
+ Tested up to: 6.0.3
7
+ Stable tag: 6.9.1
8
 
9
  All you need to manage access to WordPress websites on the frontend, backend and API levels for any role, user or visitors.
10
 
91
 
92
  == Changelog ==
93
 
94
+ = 6.9.1 =
95
+ * Fixed: Incorrectly stripped backslashes for Access Policy [https://github.com/aamplugin/advanced-access-manager/issues/228](https://github.com/aamplugin/advanced-access-manager/issues/228)
96
+ * Fixed: PHP Notice: Function AAM_Backend_Subject::hasCapability was called incorrectly [https://github.com/aamplugin/advanced-access-manager/issues/227](https://github.com/aamplugin/advanced-access-manager/issues/227)
97
+ * Fixed: PHP Notice: Undefined offset: -1 in [https://github.com/aamplugin/advanced-access-manager/issues/226](https://github.com/aamplugin/advanced-access-manager/issues/226)
98
+ * Added New: Add the ability to hook into filter [https://github.com/aamplugin/advanced-access-manager/issues/225](https://github.com/aamplugin/advanced-access-manager/issues/225)
99
+
100
  = 6.9.0 =
101
  * Fixed: Revoking JWT token via UI causes current user to logout [https://github.com/aamplugin/advanced-access-manager/issues/224](https://github.com/aamplugin/advanced-access-manager/issues/224)
102
  * Fixed: Notice: Undefined variable: cache [https://github.com/aamplugin/advanced-access-manager/issues/223](https://github.com/aamplugin/advanced-access-manager/issues/223)