Version Description
- Fixed Bug: Access Policy does not allow to use token in the param's value https://github.com/aamplugin/advanced-access-manager/issues/84
- Fixed Bug: Warning: count(): Parameter must be an array or an object that implements Countable https://github.com/aamplugin/advanced-access-manager/issues/82
- Fixed Bug: Fatal error: Call to undefined function get_main_site_id() https://github.com/aamplugin/advanced-access-manager/issues/81
- Fixed Bug: Plus Package add-on: Incorrect handling of tags with white space https://github.com/aamplugin/advanced-access-manager/issues/86
- Added New: Plus Package add-on: Define multiple default terms (including tags) https://github.com/aamplugin/advanced-access-manager/issues/83
Download this release
Release Info
Developer | vasyltech |
Plugin | Advanced Access Manager |
Version | 6.4.1 |
Comparing to | |
See all releases |
Code changes from version 6.4.0 to 6.4.1
- aam.php +2 -2
- application/Addon/Repository.php +12 -5
- application/Core/API.php +24 -0
- application/Core/Policy/Manager.php +141 -92
- application/Migration/2020_02_01-base.php +10 -4
- application/Service/Core.php +5 -3
- application/Service/Multisite.php +6 -4
- readme.txt +8 -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.4.
|
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.4.
|
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.4.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.4.1');
|
268 |
define('AAM_BASEDIR', __DIR__);
|
269 |
|
270 |
//load vendor
|
application/Addon/Repository.php
CHANGED
@@ -10,13 +10,14 @@
|
|
10 |
/**
|
11 |
* Addon repository
|
12 |
*
|
|
|
13 |
* @since 6.2.0 Bug fixing that is related to unwanted PHP notices
|
14 |
* @since 6.0.5 Refactored the license managements. Fixed couple bugs with license
|
15 |
* information displaying
|
16 |
* @since 6.0.0 Initial implementation of the class
|
17 |
*
|
18 |
* @package AAM
|
19 |
-
* @version 6.2
|
20 |
*/
|
21 |
class AAM_Addon_Repository
|
22 |
{
|
@@ -52,19 +53,20 @@ class AAM_Addon_Repository
|
|
52 |
*
|
53 |
* @return array
|
54 |
*
|
|
|
55 |
* @since 6.3.0 Fixed bug that causes PHP Notice about license index is missing.
|
56 |
* Optimized for Multisite setup
|
57 |
* @since 6.0.5 Added the $license_only argument
|
58 |
* @since 6.0.0 Initial implementation of the method
|
59 |
*
|
60 |
* @access public
|
61 |
-
* @version 6.
|
62 |
*/
|
63 |
public function getRegistry($license_only = false)
|
64 |
{
|
65 |
$response = array();
|
66 |
$registry = AAM_Core_API::getOption(
|
67 |
-
self::DB_OPTION, array(),
|
68 |
);
|
69 |
|
70 |
if ($license_only === true) {
|
@@ -101,8 +103,11 @@ class AAM_Addon_Repository
|
|
101 |
*
|
102 |
* @return boolean
|
103 |
*
|
|
|
|
|
|
|
104 |
* @access public
|
105 |
-
* @version 6.
|
106 |
*/
|
107 |
public function registerLicense($package, $license)
|
108 |
{
|
@@ -113,7 +118,9 @@ class AAM_Addon_Repository
|
|
113 |
);
|
114 |
|
115 |
// Update the registry
|
116 |
-
return AAM_Core_API::updateOption(
|
|
|
|
|
117 |
}
|
118 |
|
119 |
/**
|
10 |
/**
|
11 |
* Addon repository
|
12 |
*
|
13 |
+
* @since 6.4.2 Fixed https://github.com/aamplugin/advanced-access-manager/issues/81
|
14 |
* @since 6.2.0 Bug fixing that is related to unwanted PHP notices
|
15 |
* @since 6.0.5 Refactored the license managements. Fixed couple bugs with license
|
16 |
* information displaying
|
17 |
* @since 6.0.0 Initial implementation of the class
|
18 |
*
|
19 |
* @package AAM
|
20 |
+
* @version 6.4.2
|
21 |
*/
|
22 |
class AAM_Addon_Repository
|
23 |
{
|
53 |
*
|
54 |
* @return array
|
55 |
*
|
56 |
+
* @since 6.4.2 Fixed https://github.com/aamplugin/advanced-access-manager/issues/81
|
57 |
* @since 6.3.0 Fixed bug that causes PHP Notice about license index is missing.
|
58 |
* Optimized for Multisite setup
|
59 |
* @since 6.0.5 Added the $license_only argument
|
60 |
* @since 6.0.0 Initial implementation of the method
|
61 |
*
|
62 |
* @access public
|
63 |
+
* @version 6.4.2
|
64 |
*/
|
65 |
public function getRegistry($license_only = false)
|
66 |
{
|
67 |
$response = array();
|
68 |
$registry = AAM_Core_API::getOption(
|
69 |
+
self::DB_OPTION, array(), AAM_Core_API::getMainSiteId()
|
70 |
);
|
71 |
|
72 |
if ($license_only === true) {
|
103 |
*
|
104 |
* @return boolean
|
105 |
*
|
106 |
+
* @since 6.4.2 Fixed https://github.com/aamplugin/advanced-access-manager/issues/81
|
107 |
+
* @since 6.0.5 Initial implementation of the method
|
108 |
+
*
|
109 |
* @access public
|
110 |
+
* @version 6.4.2
|
111 |
*/
|
112 |
public function registerLicense($package, $license)
|
113 |
{
|
118 |
);
|
119 |
|
120 |
// Update the registry
|
121 |
+
return AAM_Core_API::updateOption(
|
122 |
+
self::DB_OPTION, $list, AAM_Core_API::getMainSiteId()
|
123 |
+
);
|
124 |
}
|
125 |
|
126 |
/**
|
application/Core/API.php
CHANGED
@@ -132,6 +132,30 @@ final class AAM_Core_API
|
|
132 |
return $roles;
|
133 |
}
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
/**
|
136 |
* Return max user level
|
137 |
*
|
132 |
return $roles;
|
133 |
}
|
134 |
|
135 |
+
/**
|
136 |
+
* Get main site id
|
137 |
+
*
|
138 |
+
* Compatibility method for sites that are under WP 4.9.0
|
139 |
+
*
|
140 |
+
* @return int
|
141 |
+
*
|
142 |
+
* @access public
|
143 |
+
* @version 6.4.2
|
144 |
+
*/
|
145 |
+
public static function getMainSiteId()
|
146 |
+
{
|
147 |
+
if (function_exists('get_main_site_id')) {
|
148 |
+
$id = get_main_site_id();
|
149 |
+
} elseif (is_multisite()) {
|
150 |
+
$network = get_network();
|
151 |
+
$id = ($network ? $network->site_id : 0);
|
152 |
+
} else {
|
153 |
+
$id = get_current_blog_id();
|
154 |
+
}
|
155 |
+
|
156 |
+
return $id;
|
157 |
+
}
|
158 |
+
|
159 |
/**
|
160 |
* Return max user level
|
161 |
*
|
application/Core/Policy/Manager.php
CHANGED
@@ -88,11 +88,12 @@ class AAM_Core_Policy_Manager
|
|
88 |
*
|
89 |
* @return mixed
|
90 |
*
|
|
|
91 |
* @since 6.4.0 Supporting "Value" to be an array
|
92 |
* @since 6.0.0 Initial implementation of the method
|
93 |
*
|
94 |
* @access public
|
95 |
-
* @version 6.
|
96 |
*/
|
97 |
public function getParam($id, $args = array())
|
98 |
{
|
@@ -102,15 +103,7 @@ class AAM_Core_Policy_Manager
|
|
102 |
$param = $this->tree['Param'][$id];
|
103 |
|
104 |
if ($this->isApplicable($param, $args)) {
|
105 |
-
|
106 |
-
&& preg_match_all('/(\$\{[^}]+\})/', $param['Value'], $match)
|
107 |
-
) {
|
108 |
-
$value = AAM_Core_Policy_Token::evaluate(
|
109 |
-
$param['Value'], $match[1]
|
110 |
-
);
|
111 |
-
} else {
|
112 |
-
$value = $param['Value'];
|
113 |
-
}
|
114 |
}
|
115 |
}
|
116 |
|
@@ -125,8 +118,11 @@ class AAM_Core_Policy_Manager
|
|
125 |
*
|
126 |
* @return array
|
127 |
*
|
|
|
|
|
|
|
128 |
* @access public
|
129 |
-
* @version 6.
|
130 |
*/
|
131 |
public function getParams($s, $args = array())
|
132 |
{
|
@@ -144,7 +140,7 @@ class AAM_Core_Policy_Manager
|
|
144 |
}
|
145 |
}
|
146 |
|
147 |
-
return $
|
148 |
}
|
149 |
|
150 |
/**
|
@@ -155,8 +151,11 @@ class AAM_Core_Policy_Manager
|
|
155 |
*
|
156 |
* @return array
|
157 |
*
|
|
|
|
|
|
|
158 |
* @access public
|
159 |
-
* @version 6.
|
160 |
*/
|
161 |
public function getResources($s, $args = array())
|
162 |
{
|
@@ -175,38 +174,7 @@ class AAM_Core_Policy_Manager
|
|
175 |
}
|
176 |
}
|
177 |
|
178 |
-
return $
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Replace all the dynamic tokens recursively
|
183 |
-
*
|
184 |
-
* @param array $data
|
185 |
-
*
|
186 |
-
* @return array
|
187 |
-
*
|
188 |
-
* @access protected
|
189 |
-
* @version 6.0.0
|
190 |
-
*/
|
191 |
-
protected function replaceTokens($data)
|
192 |
-
{
|
193 |
-
$replaced = array();
|
194 |
-
|
195 |
-
foreach($data as $key => $value) {
|
196 |
-
if (preg_match_all('/(\$\{[^}]+\})/', $key, $match)) {
|
197 |
-
$key = AAM_Core_Policy_Token::evaluate($key, $match[1]);
|
198 |
-
}
|
199 |
-
|
200 |
-
if (is_array($value)) {
|
201 |
-
$replaced[$key] = $this->replaceTokens($value);
|
202 |
-
} elseif (preg_match_all('/(\$\{[^}]+\})/', $value, $match)) {
|
203 |
-
$replaced[$key] = AAM_Core_Policy_Token::evaluate($value, $match[1]);
|
204 |
-
} else {
|
205 |
-
$replaced[$key] = $value;
|
206 |
-
}
|
207 |
-
}
|
208 |
-
|
209 |
-
return $replaced;
|
210 |
}
|
211 |
|
212 |
/**
|
@@ -222,8 +190,7 @@ class AAM_Core_Policy_Manager
|
|
222 |
* @since 6.0.0 Initial implementation of the method
|
223 |
*
|
224 |
* @access public
|
225 |
-
* @
|
226 |
-
* @version 6.0.0
|
227 |
*/
|
228 |
public function getOption($res, $option)
|
229 |
{
|
@@ -287,12 +254,13 @@ class AAM_Core_Policy_Manager
|
|
287 |
*
|
288 |
* @return void
|
289 |
*
|
|
|
290 |
* @since 6.3.1 Fixed bug https://github.com/aamplugin/advanced-access-manager/issues/49
|
291 |
* @since 6.2.0 Changed the way access policies are fetched
|
292 |
* @since 6.0.0 Initial implementation of the method
|
293 |
*
|
294 |
* @access public
|
295 |
-
* @version 6.
|
296 |
*/
|
297 |
public function initialize()
|
298 |
{
|
@@ -310,7 +278,7 @@ class AAM_Core_Policy_Manager
|
|
310 |
));
|
311 |
|
312 |
foreach ($policies as $policy) {
|
313 |
-
$this->updatePolicyTree($this->
|
314 |
}
|
315 |
|
316 |
$this->_cleanupTree();
|
@@ -422,23 +390,23 @@ class AAM_Core_Policy_Manager
|
|
422 |
/**
|
423 |
* Extend tree with additional statements and params
|
424 |
*
|
425 |
-
* @param array &$tree
|
426 |
* @param array $addition
|
427 |
*
|
428 |
* @return array
|
429 |
*
|
|
|
430 |
* @since 6.4.0 Supporting Param's Value to be more than just a scalar value
|
431 |
* @since 6.2.1 Typecasting param's value
|
432 |
* @since 6.1.0 Added support for the `=>` (map to) operator
|
433 |
* @since 6.0.0 Initial implementation of the method
|
434 |
*
|
435 |
* @access protected
|
436 |
-
* @version 6.4.
|
437 |
*/
|
438 |
-
protected function updatePolicyTree(
|
439 |
{
|
440 |
-
$stmts = &$tree['Statement'];
|
441 |
-
$params = &$tree['Param'];
|
442 |
|
443 |
// Step #1. If there are any statements, let's index them by resource:action
|
444 |
// and insert into the list of statements
|
@@ -447,25 +415,7 @@ class AAM_Core_Policy_Manager
|
|
447 |
$actions = (isset($stm['Action']) ? (array) $stm['Action'] : array(''));
|
448 |
|
449 |
foreach ($resources as $res) {
|
450 |
-
$
|
451 |
-
|
452 |
-
// Allow to build resource name dynamically.
|
453 |
-
if (preg_match('/^(.*)[\s]+(map to|=>)[\s]+(.*)$/i', $res, $match)) {
|
454 |
-
// e.g. "Term:category:%s:posts => ${USER_META.regions}"
|
455 |
-
$values = (array) AAM_Core_Policy_Token::getTokenValue($match[3]);
|
456 |
-
|
457 |
-
// Create the map of resources and replace
|
458 |
-
foreach($values as $value) {
|
459 |
-
$map[] = sprintf($match[1], $value);
|
460 |
-
}
|
461 |
-
} elseif (preg_match_all('/(\$\{[^}]+\})/', $res, $match)) {
|
462 |
-
// e.g. "Term:category:${USER_META.region}:posts"
|
463 |
-
$map = array(AAM_Core_Policy_Token::evaluate($res, $match[1]));
|
464 |
-
} else {
|
465 |
-
$map = array($res);
|
466 |
-
}
|
467 |
-
|
468 |
-
foreach($map as $resource) {
|
469 |
foreach ($actions as $act) {
|
470 |
$id = strtolower($resource . (!empty($act) ? ":{$act}" : ''));
|
471 |
|
@@ -482,34 +432,133 @@ class AAM_Core_Policy_Manager
|
|
482 |
// Step #2. If there are any params, let's index them and insert into the list
|
483 |
foreach ($addition['Param'] as $param) {
|
484 |
if (!empty($param['Key'])) {
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
$
|
489 |
-
|
490 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
|
493 |
-
//
|
494 |
-
if (
|
495 |
-
$
|
496 |
-
|
|
|
|
|
497 |
);
|
498 |
}
|
|
|
|
|
499 |
|
500 |
-
|
501 |
-
|
502 |
|
503 |
-
|
504 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
505 |
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
}
|
511 |
}
|
|
|
|
|
512 |
}
|
|
|
|
|
513 |
}
|
514 |
|
515 |
/**
|
88 |
*
|
89 |
* @return mixed
|
90 |
*
|
91 |
+
* @since 6.4.1 Fixed https://github.com/aamplugin/advanced-access-manager/issues/84
|
92 |
* @since 6.4.0 Supporting "Value" to be an array
|
93 |
* @since 6.0.0 Initial implementation of the method
|
94 |
*
|
95 |
* @access public
|
96 |
+
* @version 6.4.1
|
97 |
*/
|
98 |
public function getParam($id, $args = array())
|
99 |
{
|
103 |
$param = $this->tree['Param'][$id];
|
104 |
|
105 |
if ($this->isApplicable($param, $args)) {
|
106 |
+
$value = $param['Value'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
108 |
}
|
109 |
|
118 |
*
|
119 |
* @return array
|
120 |
*
|
121 |
+
* @since 6.4.1 Fixed https://github.com/aamplugin/advanced-access-manager/issues/84
|
122 |
+
* @since 6.0.0 Initial implementation of the method
|
123 |
+
*
|
124 |
* @access public
|
125 |
+
* @version 6.4.1
|
126 |
*/
|
127 |
public function getParams($s, $args = array())
|
128 |
{
|
140 |
}
|
141 |
}
|
142 |
|
143 |
+
return $params;
|
144 |
}
|
145 |
|
146 |
/**
|
151 |
*
|
152 |
* @return array
|
153 |
*
|
154 |
+
* @since 6.4.1 Fixed https://github.com/aamplugin/advanced-access-manager/issues/84
|
155 |
+
* @since 6.0.0 Initial implementation of the method
|
156 |
+
*
|
157 |
* @access public
|
158 |
+
* @version 6.4.1
|
159 |
*/
|
160 |
public function getResources($s, $args = array())
|
161 |
{
|
174 |
}
|
175 |
}
|
176 |
|
177 |
+
return $statements;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
179 |
|
180 |
/**
|
190 |
* @since 6.0.0 Initial implementation of the method
|
191 |
*
|
192 |
* @access public
|
193 |
+
* @version 6.0.4
|
|
|
194 |
*/
|
195 |
public function getOption($res, $option)
|
196 |
{
|
254 |
*
|
255 |
* @return void
|
256 |
*
|
257 |
+
* @since 6.4.1 Changed the way updatePolicyTree is invoked
|
258 |
* @since 6.3.1 Fixed bug https://github.com/aamplugin/advanced-access-manager/issues/49
|
259 |
* @since 6.2.0 Changed the way access policies are fetched
|
260 |
* @since 6.0.0 Initial implementation of the method
|
261 |
*
|
262 |
* @access public
|
263 |
+
* @version 6.4.1
|
264 |
*/
|
265 |
public function initialize()
|
266 |
{
|
278 |
));
|
279 |
|
280 |
foreach ($policies as $policy) {
|
281 |
+
$this->updatePolicyTree($this->parsePolicy($policy));
|
282 |
}
|
283 |
|
284 |
$this->_cleanupTree();
|
390 |
/**
|
391 |
* Extend tree with additional statements and params
|
392 |
*
|
|
|
393 |
* @param array $addition
|
394 |
*
|
395 |
* @return array
|
396 |
*
|
397 |
+
* @since 6.4.1 Simplified by removing &$tree first param
|
398 |
* @since 6.4.0 Supporting Param's Value to be more than just a scalar value
|
399 |
* @since 6.2.1 Typecasting param's value
|
400 |
* @since 6.1.0 Added support for the `=>` (map to) operator
|
401 |
* @since 6.0.0 Initial implementation of the method
|
402 |
*
|
403 |
* @access protected
|
404 |
+
* @version 6.4.1
|
405 |
*/
|
406 |
+
protected function updatePolicyTree($addition)
|
407 |
{
|
408 |
+
$stmts = &$this->tree['Statement'];
|
409 |
+
$params = &$this->tree['Param'];
|
410 |
|
411 |
// Step #1. If there are any statements, let's index them by resource:action
|
412 |
// and insert into the list of statements
|
415 |
$actions = (isset($stm['Action']) ? (array) $stm['Action'] : array(''));
|
416 |
|
417 |
foreach ($resources as $res) {
|
418 |
+
foreach($this->evaluatePolicyKey($res) as $resource) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
foreach ($actions as $act) {
|
420 |
$id = strtolower($resource . (!empty($act) ? ":{$act}" : ''));
|
421 |
|
432 |
// Step #2. If there are any params, let's index them and insert into the list
|
433 |
foreach ($addition['Param'] as $param) {
|
434 |
if (!empty($param['Key'])) {
|
435 |
+
$param['Value'] = $this->replaceTokens($param['Value'], true);
|
436 |
+
|
437 |
+
foreach($this->evaluatePolicyKey($param['Key']) as $key) {
|
438 |
+
if (!isset($params[$key]) || empty($params[$key]['Enforce'])) {
|
439 |
+
$params[$key] = $param;
|
440 |
+
|
441 |
+
// If "option:" - hooks to the WP core for override
|
442 |
+
if (strpos($key, 'option:') === 0) {
|
443 |
+
$name = substr($key, 7);
|
444 |
+
|
445 |
+
// Hook into the core
|
446 |
+
add_filter('pre_option_' . $name, $callback, 1, 2);
|
447 |
+
add_filter('pre_site_option_' . $name, $callback, 1, 2);
|
448 |
+
}
|
449 |
+
}
|
450 |
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
}
|
454 |
+
|
455 |
+
/**
|
456 |
+
* Evaluate resource name or param key
|
457 |
+
*
|
458 |
+
* The resource or param key may have tokens that build dynamic keys. This method
|
459 |
+
* covers 3 possible scenario:
|
460 |
+
* - Map To "=>" - the token should return array of values that are mapped to the
|
461 |
+
* key;
|
462 |
+
* - Token - returns scalar value;
|
463 |
+
* - Raw Value - returns as-is
|
464 |
+
*
|
465 |
+
* @param string $key
|
466 |
+
*
|
467 |
+
* @return array
|
468 |
+
*
|
469 |
+
* @access protected
|
470 |
+
* @version 6.4.1
|
471 |
+
*/
|
472 |
+
protected function evaluatePolicyKey($key)
|
473 |
+
{
|
474 |
+
$response = array();
|
475 |
+
|
476 |
+
// Allow to build resource name or param key dynamically.
|
477 |
+
if (preg_match('/^(.*)[\s]+(map to|=>)[\s]+(.*)$/i', $key, $match)) {
|
478 |
+
|
479 |
+
// e.g. "Term:category:%s:posts => ${USER_META.regions}"
|
480 |
+
// e.g. "%s:default:category => ${HTTP_POST.post_types}"
|
481 |
+
$values = (array) AAM_Core_Policy_Token::getTokenValue($match[3]);
|
482 |
+
|
483 |
+
// Create the map of resources/params and replace
|
484 |
+
foreach($values as $value) {
|
485 |
+
$response[] = sprintf($match[1], $value);
|
486 |
+
}
|
487 |
+
} elseif (preg_match_all('/(\$\{[^}]+\})/', $key, $match)) {
|
488 |
+
// e.g. "Term:category:${USER_META.region}:posts"
|
489 |
+
$response = array(AAM_Core_Policy_Token::evaluate($key, $match[1]));
|
490 |
+
} else {
|
491 |
+
$response = array($key);
|
492 |
+
}
|
493 |
+
|
494 |
+
return $response;
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
* Replace all the dynamic tokens recursively
|
499 |
+
*
|
500 |
+
* @param array $data
|
501 |
+
* @param boolean $type_cast
|
502 |
+
*
|
503 |
+
* @return array
|
504 |
+
*
|
505 |
+
* @since 6.4.1 Added type casting param
|
506 |
+
* @since 6.0.0 Initial implementation of the method
|
507 |
+
*
|
508 |
+
* @access protected
|
509 |
+
* @version 6.4.1
|
510 |
+
*/
|
511 |
+
protected function replaceTokens($data, $type_cast = false)
|
512 |
+
{
|
513 |
+
$replaced = array();
|
514 |
+
|
515 |
+
if (is_scalar($data)) {
|
516 |
+
$replaced = $this->_replaceTokensInString($data, $type_cast);
|
517 |
+
} else {
|
518 |
+
foreach($data as $key => $value) {
|
519 |
+
// Evaluate array's key and replace tokens
|
520 |
+
$key = $this->_replaceTokensInString($key);
|
521 |
|
522 |
+
// Evaluate array's value and replace tokens
|
523 |
+
if (is_array($value)) {
|
524 |
+
$replaced[$key] = $this->replaceTokens($value, $type_cast);
|
525 |
+
} else {
|
526 |
+
$replaced[$key] = $this->_replaceTokensInString(
|
527 |
+
$value, $type_cast
|
528 |
);
|
529 |
}
|
530 |
+
}
|
531 |
+
}
|
532 |
|
533 |
+
return $replaced;
|
534 |
+
}
|
535 |
|
536 |
+
/**
|
537 |
+
* Replace tokens is provided scalar string
|
538 |
+
*
|
539 |
+
* @param string $token
|
540 |
+
* @param boolean $type_cast
|
541 |
+
*
|
542 |
+
* @return mixed
|
543 |
+
*
|
544 |
+
* @access private
|
545 |
+
* @version 6.4.1
|
546 |
+
*/
|
547 |
+
private function _replaceTokensInString($token, $type_cast = false)
|
548 |
+
{
|
549 |
+
if (preg_match_all('/(\$\{[^}]+\})/', $token, $match)) {
|
550 |
+
$value = AAM_Core_Policy_Token::evaluate($token, $match[1]);
|
551 |
|
552 |
+
if ($type_cast === true) {
|
553 |
+
$replaced = AAM_Core_Policy_Typecast::execute($value);
|
554 |
+
} else {
|
555 |
+
$replaced = $value;
|
|
|
556 |
}
|
557 |
+
} else {
|
558 |
+
$replaced = $token;
|
559 |
}
|
560 |
+
|
561 |
+
return $replaced;
|
562 |
}
|
563 |
|
564 |
/**
|
application/Migration/2020_02_01-base.php
CHANGED
@@ -15,11 +15,12 @@ use AAM_Core_Migration,
|
|
15 |
/**
|
16 |
* This migration class that fixes potentially corrupted data with aam_addons option
|
17 |
*
|
|
|
18 |
* @since 6.4.0 Fixed bug with unsaved migration
|
19 |
* @since 6.3.1 Initial implementation of the method
|
20 |
*
|
21 |
* @package AAM
|
22 |
-
* @version 6.
|
23 |
*/
|
24 |
class Migration631 implements AAM_Core_Contract_MigrationInterface
|
25 |
{
|
@@ -27,21 +28,26 @@ class Migration631 implements AAM_Core_Contract_MigrationInterface
|
|
27 |
/**
|
28 |
* @inheritdoc
|
29 |
*
|
|
|
30 |
* @since 6.4.0 Fixed bug with unsaved migration
|
31 |
* @since 6.3.1 Initial implementation of the method
|
32 |
*
|
33 |
-
* @version 6.
|
34 |
*/
|
35 |
public function run()
|
36 |
{
|
37 |
$option = \AAM_Core_API::getOption(
|
38 |
-
\AAM_Addon_Repository::DB_OPTION,
|
|
|
|
|
39 |
);
|
40 |
|
41 |
if (is_string($option)) {
|
42 |
$option = maybe_unserialize($option);
|
43 |
\AAM_Core_API::updateOption(
|
44 |
-
\AAM_Addon_Repository::DB_OPTION,
|
|
|
|
|
45 |
);
|
46 |
}
|
47 |
|
15 |
/**
|
16 |
* This migration class that fixes potentially corrupted data with aam_addons option
|
17 |
*
|
18 |
+
* @since 6.4.2 Fixed https://github.com/aamplugin/advanced-access-manager/issues/81
|
19 |
* @since 6.4.0 Fixed bug with unsaved migration
|
20 |
* @since 6.3.1 Initial implementation of the method
|
21 |
*
|
22 |
* @package AAM
|
23 |
+
* @version 6.4.2
|
24 |
*/
|
25 |
class Migration631 implements AAM_Core_Contract_MigrationInterface
|
26 |
{
|
28 |
/**
|
29 |
* @inheritdoc
|
30 |
*
|
31 |
+
* @since 6.4.2 Fixed https://github.com/aamplugin/advanced-access-manager/issues/81
|
32 |
* @since 6.4.0 Fixed bug with unsaved migration
|
33 |
* @since 6.3.1 Initial implementation of the method
|
34 |
*
|
35 |
+
* @version 6.4.2
|
36 |
*/
|
37 |
public function run()
|
38 |
{
|
39 |
$option = \AAM_Core_API::getOption(
|
40 |
+
\AAM_Addon_Repository::DB_OPTION,
|
41 |
+
array(),
|
42 |
+
\AAM_Core_API::getMainSiteId()
|
43 |
);
|
44 |
|
45 |
if (is_string($option)) {
|
46 |
$option = maybe_unserialize($option);
|
47 |
\AAM_Core_API::updateOption(
|
48 |
+
\AAM_Addon_Repository::DB_OPTION,
|
49 |
+
$option,
|
50 |
+
\AAM_Core_API::getMainSiteId()
|
51 |
);
|
52 |
}
|
53 |
|
application/Service/Core.php
CHANGED
@@ -10,13 +10,14 @@
|
|
10 |
/**
|
11 |
* AAM core service
|
12 |
*
|
|
|
13 |
* @since 6.4.0 Added "Manage Access" toolbar item to single & multisite network
|
14 |
* @since 6.0.5 Making sure that only if user is allowed to manage other users
|
15 |
* @since 6.0.4 Bug fixing. Unwanted "Access Denied" metabox on the Your Profile page
|
16 |
* @since 6.0.0 Initial implementation of the class
|
17 |
*
|
18 |
* @package AAM
|
19 |
-
* @version 6.4.
|
20 |
*/
|
21 |
class AAM_Service_Core
|
22 |
{
|
@@ -35,6 +36,7 @@ class AAM_Service_Core
|
|
35 |
*
|
36 |
* @access protected
|
37 |
*
|
|
|
38 |
* @since 6.4.0 Added "Manage Access" toolbar item
|
39 |
* @since 6.0.5 Fixed bug when Access Manager metabox is rendered for users that
|
40 |
* have ability to manage other users
|
@@ -43,7 +45,7 @@ class AAM_Service_Core
|
|
43 |
* @since 6.0.0 Initial implementation of the method
|
44 |
*
|
45 |
* @return void
|
46 |
-
* @version 6.4.
|
47 |
*/
|
48 |
protected function __construct()
|
49 |
{
|
@@ -97,7 +99,7 @@ class AAM_Service_Core
|
|
97 |
add_action('admin_bar_menu', function($wp_admin_bar) {
|
98 |
$blog_count = count($wp_admin_bar->user->blogs);
|
99 |
|
100 |
-
if (
|
101 |
foreach((array) $wp_admin_bar->user->blogs as $blog) {
|
102 |
switch_to_blog($blog->userblog_id);
|
103 |
|
10 |
/**
|
11 |
* AAM core service
|
12 |
*
|
13 |
+
* @since 6.4.2 Fixed https://github.com/aamplugin/advanced-access-manager/issues/82
|
14 |
* @since 6.4.0 Added "Manage Access" toolbar item to single & multisite network
|
15 |
* @since 6.0.5 Making sure that only if user is allowed to manage other users
|
16 |
* @since 6.0.4 Bug fixing. Unwanted "Access Denied" metabox on the Your Profile page
|
17 |
* @since 6.0.0 Initial implementation of the class
|
18 |
*
|
19 |
* @package AAM
|
20 |
+
* @version 6.4.2
|
21 |
*/
|
22 |
class AAM_Service_Core
|
23 |
{
|
36 |
*
|
37 |
* @access protected
|
38 |
*
|
39 |
+
* @since 6.4.2 Fixed https://github.com/aamplugin/advanced-access-manager/issues/82
|
40 |
* @since 6.4.0 Added "Manage Access" toolbar item
|
41 |
* @since 6.0.5 Fixed bug when Access Manager metabox is rendered for users that
|
42 |
* have ability to manage other users
|
45 |
* @since 6.0.0 Initial implementation of the method
|
46 |
*
|
47 |
* @return void
|
48 |
+
* @version 6.4.2
|
49 |
*/
|
50 |
protected function __construct()
|
51 |
{
|
99 |
add_action('admin_bar_menu', function($wp_admin_bar) {
|
100 |
$blog_count = count($wp_admin_bar->user->blogs);
|
101 |
|
102 |
+
if ($blog_count > 0 || current_user_can('manage_network')) {
|
103 |
foreach((array) $wp_admin_bar->user->blogs as $blog) {
|
104 |
switch_to_blog($blog->userblog_id);
|
105 |
|
application/Service/Multisite.php
CHANGED
@@ -10,12 +10,13 @@
|
|
10 |
/**
|
11 |
* Multisite service
|
12 |
*
|
|
|
13 |
* @since 6.3.0 Rewrote the way options are synced across the network
|
14 |
* @since 6.2.2 Fixed the bug where reset settings was not synced across all sites
|
15 |
* @since 6.2.0 Initial implementation of the class
|
16 |
*
|
17 |
* @package AAM
|
18 |
-
* @version 6.
|
19 |
*/
|
20 |
class AAM_Service_Multisite
|
21 |
{
|
@@ -89,12 +90,13 @@ class AAM_Service_Multisite
|
|
89 |
*
|
90 |
* @return void
|
91 |
*
|
|
|
92 |
* @since 6.3.0 Optimized for Multisite setup
|
93 |
* @since 6.2.2 Hooks to the setting clearing and policy table list
|
94 |
* @since 6.2.0 Initial implementation of the method
|
95 |
*
|
96 |
* @access protected
|
97 |
-
* @version 6.
|
98 |
*/
|
99 |
protected function initializeHooks()
|
100 |
{
|
@@ -154,7 +156,7 @@ class AAM_Service_Multisite
|
|
154 |
isset($data['post_type'])
|
155 |
&& ($data['post_type'] === AAM_Service_AccessPolicy::POLICY_CPT)
|
156 |
) {
|
157 |
-
switch_to_blog(
|
158 |
}
|
159 |
|
160 |
return $data;
|
@@ -162,7 +164,7 @@ class AAM_Service_Multisite
|
|
162 |
|
163 |
add_action('aam_pre_policy_fetch_action', function() {
|
164 |
$this->switch_back_blog_id = get_current_blog_id();
|
165 |
-
switch_to_blog(
|
166 |
});
|
167 |
|
168 |
add_action('aam_post_policy_fetch_action', function() {
|
10 |
/**
|
11 |
* Multisite service
|
12 |
*
|
13 |
+
* @since 6.4.2 Fixed https://github.com/aamplugin/advanced-access-manager/issues/81
|
14 |
* @since 6.3.0 Rewrote the way options are synced across the network
|
15 |
* @since 6.2.2 Fixed the bug where reset settings was not synced across all sites
|
16 |
* @since 6.2.0 Initial implementation of the class
|
17 |
*
|
18 |
* @package AAM
|
19 |
+
* @version 6.4.2
|
20 |
*/
|
21 |
class AAM_Service_Multisite
|
22 |
{
|
90 |
*
|
91 |
* @return void
|
92 |
*
|
93 |
+
* @since 6.4.2 Fixed https://github.com/aamplugin/advanced-access-manager/issues/81
|
94 |
* @since 6.3.0 Optimized for Multisite setup
|
95 |
* @since 6.2.2 Hooks to the setting clearing and policy table list
|
96 |
* @since 6.2.0 Initial implementation of the method
|
97 |
*
|
98 |
* @access protected
|
99 |
+
* @version 6.4.2
|
100 |
*/
|
101 |
protected function initializeHooks()
|
102 |
{
|
156 |
isset($data['post_type'])
|
157 |
&& ($data['post_type'] === AAM_Service_AccessPolicy::POLICY_CPT)
|
158 |
) {
|
159 |
+
switch_to_blog(AAM_Core_API::getMainSiteId());
|
160 |
}
|
161 |
|
162 |
return $data;
|
164 |
|
165 |
add_action('aam_pre_policy_fetch_action', function() {
|
166 |
$this->switch_back_blog_id = get_current_blog_id();
|
167 |
+
switch_to_blog(AAM_Core_API::getMainSiteId());
|
168 |
});
|
169 |
|
170 |
add_action('aam_post_policy_fetch_action', function() {
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: access control, membership, backend menu, user role, restricted content, s
|
|
4 |
Requires at least: 4.7.0
|
5 |
Requires PHP: 5.6.0
|
6 |
Tested up to: 5.3.2
|
7 |
-
Stable tag: 6.4.
|
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,13 @@ We take security and privacy very seriously, that is why there are several non-n
|
|
91 |
|
92 |
== Changelog ==
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
= 6.4.0 =
|
95 |
* Fixed Bug: URI Access: Changing existing URI rule puts it in the end of the list [https://github.com/aamplugin/advanced-access-manager/issues/74](https://github.com/aamplugin/advanced-access-manager/issues/74)
|
96 |
* Fixed Bug: URI Access: Incorrect handling of the inherited rules [https://github.com/aamplugin/advanced-access-manager/issues/77](https://github.com/aamplugin/advanced-access-manager/issues/77)
|
4 |
Requires at least: 4.7.0
|
5 |
Requires PHP: 5.6.0
|
6 |
Tested up to: 5.3.2
|
7 |
+
Stable tag: 6.4.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.4.1 =
|
95 |
+
* Fixed Bug: Access Policy does not allow to use token in the param's value [https://github.com/aamplugin/advanced-access-manager/issues/84](https://github.com/aamplugin/advanced-access-manager/issues/84)
|
96 |
+
* Fixed Bug: Warning: count(): Parameter must be an array or an object that implements Countable [https://github.com/aamplugin/advanced-access-manager/issues/82](https://github.com/aamplugin/advanced-access-manager/issues/82)
|
97 |
+
* Fixed Bug: Fatal error: Call to undefined function get_main_site_id() [https://github.com/aamplugin/advanced-access-manager/issues/81](https://github.com/aamplugin/advanced-access-manager/issues/81)
|
98 |
+
* Fixed Bug: Plus Package add-on: Incorrect handling of tags with white space [https://github.com/aamplugin/advanced-access-manager/issues/86](https://github.com/aamplugin/advanced-access-manager/issues/86)
|
99 |
+
* Added New: Plus Package add-on: Define multiple default terms (including tags) [https://github.com/aamplugin/advanced-access-manager/issues/83](https://github.com/aamplugin/advanced-access-manager/issues/83)
|
100 |
+
|
101 |
= 6.4.0 =
|
102 |
* Fixed Bug: URI Access: Changing existing URI rule puts it in the end of the list [https://github.com/aamplugin/advanced-access-manager/issues/74](https://github.com/aamplugin/advanced-access-manager/issues/74)
|
103 |
* Fixed Bug: URI Access: Incorrect handling of the inherited rules [https://github.com/aamplugin/advanced-access-manager/issues/77](https://github.com/aamplugin/advanced-access-manager/issues/77)
|