Version Description
- Fixed Bug: Access Policy UI - the "Attach to Default" button was not rendering correctly
- Fixed Bug: Role Management UI - the PHP notice where
Undefined variable: parent
- Fixed Bug: AAM UI page - improperly compressed HTML response if server config does not match PHP executable INI settings
- Fixed Bug: Login Redirect Settings - incorrectly merged settings for multi-role support
- Fixed Bug: Logout Redirect Settings - incorrectly merged settings for multi-role support
- Fixed Bug: Access Denied Redirect Settings - incorrectly merged settings for multi-role support
- Fixed Bug: API Route Settings - incorrectly halted inheritance mechanism
- Fixed Bug: Admin Toolbar Settings - incorrectly halted inheritance mechanism
- Fixed Bug: URI Access Settings - incorrectly halted inheritance mechanism
- Fixed Bug: Content Visibility Settings - incorrectly merged settings for multi-role support
- Fixed Bug: Access Policy Core - incorrectly managed internal cache
- Fixed Bug: AAM Core - incorrectly managed internal object cache
- Fixed Bug: Content Service - incorrectly mapped
do_not_allow
capability if any of the registered post types have it - Fixed Bug: Content Service - fatal error
Cannot use object of type Closure as array
https://forum.aamplugin.com/d/354-php-fatal-error-cannot-use-object-of-type-closure-as-array - Fixed Bug: The
aam_show_toolbar
capability was not taken in consideration - Fixed Bug: Logout Redirect Service - White screen occurs if "Default" option is explicitly selected https://wordpress.org/support/topic/blank-log-out-page-on-6-0-5/
- Change: Refactored internal inheritance mechanism where AAM objects no longer responsible to check for inheritance flag. This eliminates several constrains that we discovered recently.
- Change: Multiple minor changes to the codebase to consume internal AAM API in more consistent way
- Change: JWT & Secure Login Services - enriched RESTful API error responses with more details about an error
- Change: Content Service - optimization improvements
- Added New: Implemented new filter
aam_token_typecast_filter
for Access Policy for custom type casting - Added New: Implemented support for the
=>
(map to) operator for the Access Policy - Added New: Implemented support for the AAM_CONFIG marker for the Access Policy
Download this release
Release Info
Developer | vasyltech |
Plugin | Advanced Access Manager |
Version | 6.1.0 |
Comparing to | |
See all releases |
Code changes from version 6.0.5 to 6.1.0
- aam.php +2 -2
- application/Backend/Feature/Main/Policy.php +10 -8
- application/Backend/Feature/Subject/Role.php +9 -4
- application/Backend/Manager.php +10 -6
- application/Backend/tmpl/partial/visitor-principal-subject-tab.php +15 -4
- application/Core/Gateway.php +13 -6
- application/Core/Jwt/Issuer.php +12 -4
- application/Core/Object.php +87 -66
- application/Core/Object/LoginRedirect.php +21 -3
- application/Core/Object/LogoutRedirect.php +21 -3
- application/Core/Object/Post.php +26 -19
- application/Core/Object/Redirect.php +21 -3
- application/Core/Object/Route.php +10 -7
- application/Core/Object/Toolbar.php +10 -7
- application/Core/Object/Uri.php +10 -7
- application/Core/Object/Visibility.php +64 -26
- application/Core/Policy/Condition.php +21 -10
- application/Core/Policy/Factory.php +18 -8
- application/Core/Policy/Manager.php +40 -13
- application/Core/Policy/Token.php +38 -14
- application/Core/Subject.php +14 -7
- application/Service/AccessPolicy.php +59 -26
- application/Service/Content.php +24 -9
- application/Service/ExtendedCapabilities.php +28 -22
- application/Service/Jwt.php +36 -22
- application/Service/LogoutRedirect.php +7 -3
- application/Service/SecureLogin.php +23 -20
- application/Service/Uri.php +7 -2
- lang/advanced-access-manager-en_US.po +53 -54
- readme.txt +28 -3
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.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.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.1.0
|
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.1.0');
|
268 |
define('AAM_BASEDIR', __DIR__);
|
269 |
|
270 |
//load vendor
|
application/Backend/Feature/Main/Policy.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* Access Policy UI manager
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Backend_Feature_Main_Policy
|
19 |
extends AAM_Backend_Feature_Abstract implements AAM_Backend_Feature_ISubjectAware
|
@@ -47,8 +48,12 @@ extends AAM_Backend_Feature_Abstract implements AAM_Backend_Feature_ISubjectAwar
|
|
47 |
*
|
48 |
* @return void
|
49 |
*
|
|
|
|
|
|
|
|
|
50 |
* @access public
|
51 |
-
* @version 6.
|
52 |
*/
|
53 |
public function __construct()
|
54 |
{
|
@@ -68,10 +73,7 @@ extends AAM_Backend_Feature_Abstract implements AAM_Backend_Feature_ISubjectAwar
|
|
68 |
}, 10, 2);
|
69 |
|
70 |
add_filter('aam_default_subject_tab_filter', function ($content, $params) {
|
71 |
-
|
72 |
-
|
73 |
-
if (is_a($post, 'WP_Post')
|
74 |
-
&& ($post->post_type === AAM_Service_AccessPolicy::POLICY_CPT)) {
|
75 |
$content = AAM_Backend_View::getInstance()->loadPartial(
|
76 |
'default-principal-subject-tab',
|
77 |
$params
|
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 |
* Access Policy UI manager
|
12 |
*
|
13 |
+
* @since 6.1.0 Fixed bug with "Attach to Default" button
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
class AAM_Backend_Feature_Main_Policy
|
20 |
extends AAM_Backend_Feature_Abstract implements AAM_Backend_Feature_ISubjectAware
|
48 |
*
|
49 |
* @return void
|
50 |
*
|
51 |
+
* @since 6.1.0 Fixed the bug where "Attach to Default" button was not showing at
|
52 |
+
* all
|
53 |
+
* @since 6.0.0 Initial implementation of the method
|
54 |
+
*
|
55 |
* @access public
|
56 |
+
* @version 6.1.0
|
57 |
*/
|
58 |
public function __construct()
|
59 |
{
|
73 |
}, 10, 2);
|
74 |
|
75 |
add_filter('aam_default_subject_tab_filter', function ($content, $params) {
|
76 |
+
if ($this->getFromQuery('aamframe') === 'principal') {
|
|
|
|
|
|
|
77 |
$content = AAM_Backend_View::getInstance()->loadPartial(
|
78 |
'default-principal-subject-tab',
|
79 |
$params
|
application/Backend/Feature/Subject/Role.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* Role view manager
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Backend_Feature_Subject_Role
|
19 |
{
|
@@ -178,8 +179,11 @@ class AAM_Backend_Feature_Subject_Role
|
|
178 |
*
|
179 |
* @return array
|
180 |
*
|
|
|
|
|
|
|
181 |
* @access private
|
182 |
-
* @version 6.
|
183 |
*/
|
184 |
private function _create()
|
185 |
{
|
@@ -200,6 +204,7 @@ class AAM_Backend_Feature_Subject_Role
|
|
200 |
$caps = ($parent ? $parent->capabilities : array());
|
201 |
} else {
|
202 |
$caps = array();
|
|
|
203 |
}
|
204 |
|
205 |
if ($role = $roles->add_role($role_id, $name, $caps)) {
|
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 |
* Role view manager
|
12 |
*
|
13 |
+
* @since 6.1.0 Fixed bug with role creation process that caused PHP warning
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
class AAM_Backend_Feature_Subject_Role
|
20 |
{
|
179 |
*
|
180 |
* @return array
|
181 |
*
|
182 |
+
* @since 6.1.0 Fixed the PHP notice where `Undefined variable: parent`
|
183 |
+
* @since 6.0.0 Initial implementation of the method
|
184 |
+
*
|
185 |
* @access private
|
186 |
+
* @version 6.1.0
|
187 |
*/
|
188 |
private function _create()
|
189 |
{
|
204 |
$caps = ($parent ? $parent->capabilities : array());
|
205 |
} else {
|
206 |
$caps = array();
|
207 |
+
$parent = null;
|
208 |
}
|
209 |
|
210 |
if ($role = $roles->add_role($role_id, $name, $caps)) {
|
application/Backend/Manager.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* Backend manager
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Backend_Manager
|
19 |
{
|
@@ -307,8 +308,12 @@ class AAM_Backend_Manager
|
|
307 |
*
|
308 |
* @return void
|
309 |
*
|
|
|
|
|
|
|
|
|
310 |
* @access public
|
311 |
-
* @version 6.
|
312 |
*/
|
313 |
public function renderContent()
|
314 |
{
|
@@ -325,13 +330,12 @@ class AAM_Backend_Manager
|
|
325 |
$accept = AAM_Core_Request::server('HTTP_ACCEPT_ENCODING');
|
326 |
header('Content-Type: text/html; charset=UTF-8');
|
327 |
|
328 |
-
$zlib = strtolower(ini_get('zlib.output_compression'));
|
329 |
$compressed = count(array_intersect(
|
330 |
array('zlib output compression', 'ob_gzhandler'),
|
331 |
ob_list_handlers()
|
332 |
)) > 0;
|
333 |
|
334 |
-
if (
|
335 |
header('Vary: Accept-Encoding'); // Handle proxies
|
336 |
|
337 |
if (false !== stripos($accept, 'gzip') && function_exists('gzencode')) {
|
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 |
* Backend manager
|
12 |
*
|
13 |
+
* @since 6.1.0 Fixed bug with HTML compression
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
class AAM_Backend_Manager
|
20 |
{
|
308 |
*
|
309 |
* @return void
|
310 |
*
|
311 |
+
* @since 6.1.0 Fixed bug with improper response if server config does not match
|
312 |
+
* PHP executable INI settings
|
313 |
+
* @since 6.0.0 Initial implementation of the method
|
314 |
+
*
|
315 |
* @access public
|
316 |
+
* @version 6.1.0
|
317 |
*/
|
318 |
public function renderContent()
|
319 |
{
|
330 |
$accept = AAM_Core_Request::server('HTTP_ACCEPT_ENCODING');
|
331 |
header('Content-Type: text/html; charset=UTF-8');
|
332 |
|
|
|
333 |
$compressed = count(array_intersect(
|
334 |
array('zlib output compression', 'ob_gzhandler'),
|
335 |
ob_list_handlers()
|
336 |
)) > 0;
|
337 |
|
338 |
+
if (!empty($accept)) {
|
339 |
header('Vary: Accept-Encoding'); // Handle proxies
|
340 |
|
341 |
if (false !== stripos($accept, 'gzip') && function_exists('gzencode')) {
|
application/Backend/tmpl/partial/visitor-principal-subject-tab.php
CHANGED
@@ -1,13 +1,24 @@
|
|
1 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
<?php if (defined('AAM_KEY')) { ?>
|
4 |
<div class="visitor-message">
|
5 |
<span class="aam-bordered"><?php echo __('Attach current access & security policy to visitors (any user that is not authenticated)', AAM_KEY); ?>.</span>
|
6 |
<?php
|
7 |
-
$
|
8 |
-
|
|
|
|
|
9 |
$btnStatus = $hasPolicy ? 'detach' : 'attach';
|
10 |
-
|
|
|
11 |
<?php if ($hasPolicy) { ?>
|
12 |
<button class="btn btn-primary btn-block" id="attach-policy-visitor" data-has="1" <?php echo ($btnStatus ? '' : ' disabled'); ?>><?php echo __('Detach Policy From Visitors', AAM_KEY); ?></button>
|
13 |
<?php } else { ?>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
*
|
4 |
+
* @since 6.1.0 Switched to use AAM API to obtain visitor subject
|
5 |
+
* @since 6.0.0 Initial implementation of the template
|
6 |
+
*
|
7 |
+
* @version 6.1.0
|
8 |
+
* */
|
9 |
+
?>
|
10 |
|
11 |
<?php if (defined('AAM_KEY')) { ?>
|
12 |
<div class="visitor-message">
|
13 |
<span class="aam-bordered"><?php echo __('Attach current access & security policy to visitors (any user that is not authenticated)', AAM_KEY); ?>.</span>
|
14 |
<?php
|
15 |
+
$hasPolicy = AAM::api()->getVisitor()->getObject(
|
16 |
+
AAM_Core_Object_Policy::OBJECT_TYPE
|
17 |
+
)->has($params->policyId);
|
18 |
+
|
19 |
$btnStatus = $hasPolicy ? 'detach' : 'attach';
|
20 |
+
?>
|
21 |
+
|
22 |
<?php if ($hasPolicy) { ?>
|
23 |
<button class="btn btn-primary btn-block" id="attach-policy-visitor" data-has="1" <?php echo ($btnStatus ? '' : ' disabled'); ?>><?php echo __('Detach Policy From Visitors', AAM_KEY); ?></button>
|
24 |
<?php } else { ?>
|
application/Core/Gateway.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* AAM core API gateway
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
final class AAM_Core_Gateway
|
19 |
{
|
@@ -176,20 +177,26 @@ final class AAM_Core_Gateway
|
|
176 |
* Prepare Access Policy manager but only if service is enabled
|
177 |
*
|
178 |
* @param AAM_Core_Subject $subject
|
|
|
179 |
*
|
180 |
* @return AAM_Core_Policy_Manager|null
|
181 |
*
|
|
|
|
|
|
|
182 |
* @access public
|
183 |
-
* @version 6.
|
184 |
*/
|
185 |
-
public function getAccessPolicyManager(
|
|
|
|
|
186 |
{
|
187 |
if (is_null($subject)) {
|
188 |
$subject = AAM::getUser();
|
189 |
}
|
190 |
|
191 |
if (AAM_Core_Config::get(AAM_Service_AccessPolicy::FEATURE_FLAG, true)) {
|
192 |
-
$manager = AAM_Core_Policy_Factory::get($subject);
|
193 |
} else {
|
194 |
$manager = null;
|
195 |
}
|
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 core API gateway
|
12 |
*
|
13 |
+
* @since 6.1.0 Significant improvement of the inheritance mechanism
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
final class AAM_Core_Gateway
|
20 |
{
|
177 |
* Prepare Access Policy manager but only if service is enabled
|
178 |
*
|
179 |
* @param AAM_Core_Subject $subject
|
180 |
+
* @param boolean $skipInheritance
|
181 |
*
|
182 |
* @return AAM_Core_Policy_Manager|null
|
183 |
*
|
184 |
+
* @since 6.1.0 Added $skipInheritance flag to insure proper settings inheritance
|
185 |
+
* @since 6.0.0 Initial implementation of the method
|
186 |
+
*
|
187 |
* @access public
|
188 |
+
* @version 6.1.0
|
189 |
*/
|
190 |
+
public function getAccessPolicyManager(
|
191 |
+
AAM_Core_Subject $subject = null, $skipInheritance = false
|
192 |
+
)
|
193 |
{
|
194 |
if (is_null($subject)) {
|
195 |
$subject = AAM::getUser();
|
196 |
}
|
197 |
|
198 |
if (AAM_Core_Config::get(AAM_Service_AccessPolicy::FEATURE_FLAG, true)) {
|
199 |
+
$manager = AAM_Core_Policy_Factory::get($subject, $skipInheritance);
|
200 |
} else {
|
201 |
$manager = null;
|
202 |
}
|
application/Core/Jwt/Issuer.php
CHANGED
@@ -10,11 +10,13 @@
|
|
10 |
/**
|
11 |
* AAM JWT Issuer
|
12 |
*
|
|
|
13 |
* @since 6.0.4 Bug fixing. Timezone was handled incorrectly and ttl did not take in
|
14 |
* consideration numeric "in seconds" value
|
15 |
* @since 6.0.0 Initial implementation of the class
|
|
|
16 |
* @package AAM
|
17 |
-
* @version 6.0
|
18 |
*/
|
19 |
class AAM_Core_Jwt_Issuer
|
20 |
{
|
@@ -28,11 +30,12 @@ class AAM_Core_Jwt_Issuer
|
|
28 |
*
|
29 |
* @return object
|
30 |
*
|
|
|
31 |
* @since 6.0.4 Making sure that JWT expiration is checked with UTC timezone
|
32 |
* @since 6.0.0 Initial implementation of the method
|
33 |
*
|
34 |
* @access public
|
35 |
-
* @version 6.0
|
36 |
*/
|
37 |
public function validateToken($token)
|
38 |
{
|
@@ -66,15 +69,20 @@ class AAM_Core_Jwt_Issuer
|
|
66 |
);
|
67 |
|
68 |
if (!is_array($tokens) || !in_array($token, $tokens, true)) {
|
69 |
-
throw new Exception(
|
|
|
|
|
|
|
70 |
}
|
71 |
}
|
72 |
|
73 |
$response->isValid = true;
|
74 |
} catch (Exception $ex) {
|
|
|
75 |
$response = array(
|
76 |
'isValid' => false,
|
77 |
-
'reason' => $ex->getMessage()
|
|
|
78 |
);
|
79 |
}
|
80 |
|
10 |
/**
|
11 |
* AAM JWT Issuer
|
12 |
*
|
13 |
+
* @since 6.1.0 Enriched error response with more details
|
14 |
* @since 6.0.4 Bug fixing. Timezone was handled incorrectly and ttl did not take in
|
15 |
* consideration numeric "in seconds" value
|
16 |
* @since 6.0.0 Initial implementation of the class
|
17 |
+
*
|
18 |
* @package AAM
|
19 |
+
* @version 6.1.0
|
20 |
*/
|
21 |
class AAM_Core_Jwt_Issuer
|
22 |
{
|
30 |
*
|
31 |
* @return object
|
32 |
*
|
33 |
+
* @since 6.1.0 Enriched error response with more details
|
34 |
* @since 6.0.4 Making sure that JWT expiration is checked with UTC timezone
|
35 |
* @since 6.0.0 Initial implementation of the method
|
36 |
*
|
37 |
* @access public
|
38 |
+
* @version 6.1.0
|
39 |
*/
|
40 |
public function validateToken($token)
|
41 |
{
|
69 |
);
|
70 |
|
71 |
if (!is_array($tokens) || !in_array($token, $tokens, true)) {
|
72 |
+
throw new Exception(
|
73 |
+
__('Token has been revoked', AAM_KEY),
|
74 |
+
410
|
75 |
+
);
|
76 |
}
|
77 |
}
|
78 |
|
79 |
$response->isValid = true;
|
80 |
} catch (Exception $ex) {
|
81 |
+
$status = $ex->getCode();
|
82 |
$response = array(
|
83 |
'isValid' => false,
|
84 |
+
'reason' => $ex->getMessage(),
|
85 |
+
'status' => (!empty($status) ? $status : 400)
|
86 |
);
|
87 |
}
|
88 |
|
application/Core/Object.php
CHANGED
@@ -8,13 +8,22 @@
|
|
8 |
*/
|
9 |
|
10 |
/**
|
11 |
-
* Abstract object
|
12 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
* @since 6.0.5 Added `getExplicitOption` method
|
14 |
* @since 6.0.0 Initial implementation of the class
|
15 |
*
|
16 |
* @package AAM
|
17 |
-
* @version 6.0
|
18 |
*/
|
19 |
abstract class AAM_Core_Object
|
20 |
{
|
@@ -22,6 +31,8 @@ abstract class AAM_Core_Object
|
|
22 |
/**
|
23 |
* Core object slug
|
24 |
*
|
|
|
|
|
25 |
* @version 6.0.0
|
26 |
*/
|
27 |
const OBJECT_TYPE = null;
|
@@ -29,6 +40,8 @@ abstract class AAM_Core_Object
|
|
29 |
/**
|
30 |
* Subject
|
31 |
*
|
|
|
|
|
32 |
* @var AAM_Core_Subject
|
33 |
*
|
34 |
* @access private
|
@@ -39,7 +52,11 @@ abstract class AAM_Core_Object
|
|
39 |
/**
|
40 |
* Object Id
|
41 |
*
|
42 |
-
*
|
|
|
|
|
|
|
|
|
43 |
*
|
44 |
* @access private
|
45 |
* @version 6.0.0
|
@@ -47,7 +64,11 @@ abstract class AAM_Core_Object
|
|
47 |
private $_id = null;
|
48 |
|
49 |
/**
|
50 |
-
* Object options
|
|
|
|
|
|
|
|
|
51 |
*
|
52 |
* @var array
|
53 |
*
|
@@ -59,6 +80,11 @@ abstract class AAM_Core_Object
|
|
59 |
/**
|
60 |
* Explicit options (not inherited from parent subjects)
|
61 |
*
|
|
|
|
|
|
|
|
|
|
|
62 |
* @var array
|
63 |
*
|
64 |
* @access private
|
@@ -79,43 +105,29 @@ abstract class AAM_Core_Object
|
|
79 |
*/
|
80 |
private $_overwritten = false;
|
81 |
|
82 |
-
/**
|
83 |
-
* Suppress any filters that may alter option
|
84 |
-
*
|
85 |
-
* This is used to suppress the inheritance chain that invokes when object has
|
86 |
-
* hierarchical relationships.
|
87 |
-
*
|
88 |
-
* @var boolean
|
89 |
-
*
|
90 |
-
* @access private
|
91 |
-
* @version 6.0.0
|
92 |
-
*/
|
93 |
-
private $_suppressFilters = false;
|
94 |
-
|
95 |
/**
|
96 |
* Constructor
|
97 |
*
|
98 |
-
* @param AAM_Core_Subject $subject
|
99 |
-
* @param mixed $id
|
100 |
-
* @param boolean $setSuppressFilters
|
101 |
*
|
102 |
* @return void
|
103 |
*
|
|
|
|
|
|
|
104 |
* @access public
|
105 |
* @version 6.0.0
|
106 |
*/
|
107 |
-
public function __construct(
|
108 |
-
|
109 |
-
) {
|
110 |
$this->setSubject($subject);
|
111 |
$this->setId($id);
|
112 |
-
$this->setSuppressFilters($suppressFilters);
|
113 |
-
|
114 |
$this->initialize();
|
115 |
}
|
116 |
|
117 |
/**
|
118 |
-
* Initialize access
|
119 |
*
|
120 |
* @return void
|
121 |
*
|
@@ -127,19 +139,26 @@ abstract class AAM_Core_Object
|
|
127 |
/**
|
128 |
* Fallback to avoid any issues with previous versions
|
129 |
*
|
130 |
-
*
|
131 |
-
*
|
|
|
|
|
|
|
132 |
*
|
133 |
* @return void
|
134 |
*
|
|
|
|
|
|
|
|
|
135 |
* @access public
|
136 |
-
* @version 6.
|
137 |
*/
|
138 |
public function __call($function, $args)
|
139 |
{
|
140 |
_doing_it_wrong(
|
141 |
$function,
|
142 |
-
sprintf(
|
143 |
AAM_VERSION
|
144 |
);
|
145 |
}
|
@@ -241,7 +260,7 @@ abstract class AAM_Core_Object
|
|
241 |
* @return mixed
|
242 |
*
|
243 |
* @access public
|
244 |
-
* @version
|
245 |
*/
|
246 |
public function get($property, $default = null)
|
247 |
{
|
@@ -289,12 +308,16 @@ abstract class AAM_Core_Object
|
|
289 |
*
|
290 |
* @return AAM_Core_Object
|
291 |
*
|
|
|
|
|
|
|
|
|
292 |
* @access public
|
293 |
-
* @version 6.
|
294 |
*/
|
295 |
public function updateOptionItem($item, $value)
|
296 |
{
|
297 |
-
$option = $this->
|
298 |
|
299 |
if (isset($option[$item]) && is_array($option[$item])) {
|
300 |
$option[$item] = array_replace_recursive($option[$item], $value);
|
@@ -302,7 +325,10 @@ abstract class AAM_Core_Object
|
|
302 |
$option[$item] = $value;
|
303 |
}
|
304 |
|
305 |
-
|
|
|
|
|
|
|
306 |
|
307 |
return $this;
|
308 |
}
|
@@ -314,13 +340,17 @@ abstract class AAM_Core_Object
|
|
314 |
*
|
315 |
* @return void
|
316 |
*
|
|
|
|
|
|
|
|
|
317 |
* @access public
|
318 |
-
* @version 6.
|
319 |
*/
|
320 |
public function determineOverwritten($option)
|
321 |
{
|
322 |
$this->_overwritten = !empty($option);
|
323 |
-
$this->
|
324 |
}
|
325 |
|
326 |
/**
|
@@ -369,6 +399,21 @@ abstract class AAM_Core_Object
|
|
369 |
return $this->_explicitOption;
|
370 |
}
|
371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
/**
|
373 |
* Check if options are overwritten
|
374 |
*
|
@@ -387,13 +432,17 @@ abstract class AAM_Core_Object
|
|
387 |
*
|
388 |
* @return boolean
|
389 |
*
|
|
|
|
|
|
|
|
|
390 |
* @access public
|
391 |
-
* @version 6.
|
392 |
*/
|
393 |
public function save()
|
394 |
{
|
395 |
return $this->getSubject()->updateOption(
|
396 |
-
$this->
|
397 |
static::OBJECT_TYPE,
|
398 |
$this->getId()
|
399 |
);
|
@@ -415,32 +464,4 @@ abstract class AAM_Core_Object
|
|
415 |
);
|
416 |
}
|
417 |
|
418 |
-
/**
|
419 |
-
* Suppress filters flag
|
420 |
-
*
|
421 |
-
* @param boolean $setSuppressFilters
|
422 |
-
*
|
423 |
-
* @return void
|
424 |
-
*
|
425 |
-
* @access protected
|
426 |
-
* @version 6.0.0
|
427 |
-
*/
|
428 |
-
protected function setSuppressFilters($setSuppressFilters)
|
429 |
-
{
|
430 |
-
$this->_suppressFilters = $setSuppressFilters;
|
431 |
-
}
|
432 |
-
|
433 |
-
/**
|
434 |
-
* Get suppress filters flag
|
435 |
-
*
|
436 |
-
* @return boolean
|
437 |
-
*
|
438 |
-
* @access public
|
439 |
-
* @version 6.0.0
|
440 |
-
*/
|
441 |
-
public function suppressFilters()
|
442 |
-
{
|
443 |
-
return $this->_suppressFilters;
|
444 |
-
}
|
445 |
-
|
446 |
}
|
8 |
*/
|
9 |
|
10 |
/**
|
11 |
+
* Abstract class that represents AAM object concept
|
12 |
*
|
13 |
+
* AAM Object is a website resource that you manage access to for users, roles or
|
14 |
+
* visitors. For example, it can be any website post, page, term, backend menu etc.
|
15 |
+
*
|
16 |
+
* On another hand, AAM Object is a “container” with specific settings for any user,
|
17 |
+
* role or visitor. For example login, logout redirect, default category or access
|
18 |
+
* denied redirect rules.
|
19 |
+
*
|
20 |
+
* @since 6.1.0 Significant improvement to the inheritance mechanism. Documented
|
21 |
+
* the class
|
22 |
* @since 6.0.5 Added `getExplicitOption` method
|
23 |
* @since 6.0.0 Initial implementation of the class
|
24 |
*
|
25 |
* @package AAM
|
26 |
+
* @version 6.1.0
|
27 |
*/
|
28 |
abstract class AAM_Core_Object
|
29 |
{
|
31 |
/**
|
32 |
* Core object slug
|
33 |
*
|
34 |
+
* The slug should be unique identifier for the type of object (e.g. menu, post)
|
35 |
+
*
|
36 |
* @version 6.0.0
|
37 |
*/
|
38 |
const OBJECT_TYPE = null;
|
40 |
/**
|
41 |
* Subject
|
42 |
*
|
43 |
+
* Current subject access settings belong to
|
44 |
+
*
|
45 |
* @var AAM_Core_Subject
|
46 |
*
|
47 |
* @access private
|
52 |
/**
|
53 |
* Object Id
|
54 |
*
|
55 |
+
* Some objects may have unique identifier like each post or term has unique
|
56 |
+
* auto-incremented ID, or post type - unique slug. Other objects, like menu,
|
57 |
+
* toolbar, do not have unique.
|
58 |
+
*
|
59 |
+
* @var int|string|null
|
60 |
*
|
61 |
* @access private
|
62 |
* @version 6.0.0
|
64 |
private $_id = null;
|
65 |
|
66 |
/**
|
67 |
+
* Object access options
|
68 |
+
*
|
69 |
+
* Array of access options or settings. Depending on object, the structure of
|
70 |
+
* options may vary. Typically it is an associated array of key/value pairs,
|
71 |
+
* however in some cases it is multi-dimensional array of settings.
|
72 |
*
|
73 |
* @var array
|
74 |
*
|
80 |
/**
|
81 |
* Explicit options (not inherited from parent subjects)
|
82 |
*
|
83 |
+
* When object is obtained through AAM_Core_Subject::getObject method, it already
|
84 |
+
* contains the final set of the settings, inherited from the parent subjects.
|
85 |
+
* This properly contains access settings that are explicitly defined for current
|
86 |
+
* subject.
|
87 |
+
*
|
88 |
* @var array
|
89 |
*
|
90 |
* @access private
|
105 |
*/
|
106 |
private $_overwritten = false;
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
/**
|
109 |
* Constructor
|
110 |
*
|
111 |
+
* @param AAM_Core_Subject $subject Requested subject
|
112 |
+
* @param mixed $id Object ID if applicable
|
|
|
113 |
*
|
114 |
* @return void
|
115 |
*
|
116 |
+
* @since 6.1.0 Removed $suppressFilters param
|
117 |
+
* @since 6.0.0 Initial implementation of the method
|
118 |
+
*
|
119 |
* @access public
|
120 |
* @version 6.0.0
|
121 |
*/
|
122 |
+
public function __construct(AAM_Core_Subject $subject, $id = null)
|
123 |
+
{
|
|
|
124 |
$this->setSubject($subject);
|
125 |
$this->setId($id);
|
|
|
|
|
126 |
$this->initialize();
|
127 |
}
|
128 |
|
129 |
/**
|
130 |
+
* Initialize access options
|
131 |
*
|
132 |
* @return void
|
133 |
*
|
139 |
/**
|
140 |
* Fallback to avoid any issues with previous versions
|
141 |
*
|
142 |
+
* If DEBUG mode is enabled, the error message states that invoking method does
|
143 |
+
* not exist
|
144 |
+
*
|
145 |
+
* @param string $function Invoking method
|
146 |
+
* @param array $args Method's arguments
|
147 |
*
|
148 |
* @return void
|
149 |
*
|
150 |
+
* @since 6.1.0 Do not localize internal error message
|
151 |
+
* @since 6.0.0 Initial implementation of the method
|
152 |
+
*
|
153 |
+
* @see _doing_it_wrong
|
154 |
* @access public
|
155 |
+
* @version 6.1.0
|
156 |
*/
|
157 |
public function __call($function, $args)
|
158 |
{
|
159 |
_doing_it_wrong(
|
160 |
$function,
|
161 |
+
sprintf('AAM object function %s is not defined', $function),
|
162 |
AAM_VERSION
|
163 |
);
|
164 |
}
|
260 |
* @return mixed
|
261 |
*
|
262 |
* @access public
|
263 |
+
* @version 6.0.0
|
264 |
*/
|
265 |
public function get($property, $default = null)
|
266 |
{
|
308 |
*
|
309 |
* @return AAM_Core_Object
|
310 |
*
|
311 |
+
* @since 6.1.0 Using explicitOptions to add new access setting instead of
|
312 |
+
* final options
|
313 |
+
* @since 6.0.0 Initial implementation of the method
|
314 |
+
*
|
315 |
* @access public
|
316 |
+
* @version 6.1.0
|
317 |
*/
|
318 |
public function updateOptionItem($item, $value)
|
319 |
{
|
320 |
+
$option = $this->getExplicitOption();
|
321 |
|
322 |
if (isset($option[$item]) && is_array($option[$item])) {
|
323 |
$option[$item] = array_replace_recursive($option[$item], $value);
|
325 |
$option[$item] = $value;
|
326 |
}
|
327 |
|
328 |
+
// Override current set of final options to keep consistency
|
329 |
+
$this->setOption(array_replace_recursive($this->getOption(), $option));
|
330 |
+
|
331 |
+
$this->setExplicitOption($option);
|
332 |
|
333 |
return $this;
|
334 |
}
|
340 |
*
|
341 |
* @return void
|
342 |
*
|
343 |
+
* @since 6.1.0 Using explicitOptions to determine override flag instead of
|
344 |
+
* final options
|
345 |
+
* @since 6.0.0 Initial implementation of the method
|
346 |
+
*
|
347 |
* @access public
|
348 |
+
* @version 6.1.0
|
349 |
*/
|
350 |
public function determineOverwritten($option)
|
351 |
{
|
352 |
$this->_overwritten = !empty($option);
|
353 |
+
$this->setExplicitOption(is_array($option) ? $option : array());
|
354 |
}
|
355 |
|
356 |
/**
|
399 |
return $this->_explicitOption;
|
400 |
}
|
401 |
|
402 |
+
/**
|
403 |
+
* Set explicit object option
|
404 |
+
*
|
405 |
+
* @param array $option
|
406 |
+
*
|
407 |
+
* @return void
|
408 |
+
*
|
409 |
+
* @access protected
|
410 |
+
* @version 6.1.0
|
411 |
+
*/
|
412 |
+
protected function setExplicitOption($option)
|
413 |
+
{
|
414 |
+
$this->_explicitOption = $option;
|
415 |
+
}
|
416 |
+
|
417 |
/**
|
418 |
* Check if options are overwritten
|
419 |
*
|
432 |
*
|
433 |
* @return boolean
|
434 |
*
|
435 |
+
* @since 6.1.0 Using explicitOptions to save access setting instead of
|
436 |
+
* final options
|
437 |
+
* @since 6.0.0 Initial implementation of the method
|
438 |
+
*
|
439 |
* @access public
|
440 |
+
* @version 6.1.0
|
441 |
*/
|
442 |
public function save()
|
443 |
{
|
444 |
return $this->getSubject()->updateOption(
|
445 |
+
$this->getExplicitOption(),
|
446 |
static::OBJECT_TYPE,
|
447 |
$this->getId()
|
448 |
);
|
464 |
);
|
465 |
}
|
466 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
467 |
}
|
application/Core/Object/LoginRedirect.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* Login redirect object
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Core_Object_LoginRedirect extends AAM_Core_Object
|
19 |
{
|
@@ -40,4 +41,21 @@ class AAM_Core_Object_LoginRedirect extends AAM_Core_Object
|
|
40 |
$this->setOption(is_array($option) ? $option : array());
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
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 |
* Login redirect object
|
12 |
*
|
13 |
+
* @since 6.1.0 Fixed bug with incorrectly merged settings
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
class AAM_Core_Object_LoginRedirect extends AAM_Core_Object
|
20 |
{
|
41 |
$this->setOption(is_array($option) ? $option : array());
|
42 |
}
|
43 |
|
44 |
+
/**
|
45 |
+
* Merge settings
|
46 |
+
*
|
47 |
+
* The last subject overrides previous
|
48 |
+
*
|
49 |
+
* @param array $options
|
50 |
+
*
|
51 |
+
* @return array
|
52 |
+
*
|
53 |
+
* @access public
|
54 |
+
* @version 6.1.0
|
55 |
+
*/
|
56 |
+
public function mergeOption($options)
|
57 |
+
{
|
58 |
+
return array_replace_recursive($options, $this->getOption());
|
59 |
+
}
|
60 |
+
|
61 |
}
|
application/Core/Object/LogoutRedirect.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* Logout redirect object
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Core_Object_LogoutRedirect extends AAM_Core_Object
|
19 |
{
|
@@ -40,4 +41,21 @@ class AAM_Core_Object_LogoutRedirect extends AAM_Core_Object
|
|
40 |
$this->setOption(is_array($option) ? $option : array());
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
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 |
* Logout redirect object
|
12 |
*
|
13 |
+
* @since 6.1.0 Fixed bug with incorrectly merged settings
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
class AAM_Core_Object_LogoutRedirect extends AAM_Core_Object
|
20 |
{
|
41 |
$this->setOption(is_array($option) ? $option : array());
|
42 |
}
|
43 |
|
44 |
+
/**
|
45 |
+
* Merge settings
|
46 |
+
*
|
47 |
+
* The last subject overrides previous
|
48 |
+
*
|
49 |
+
* @param array $options
|
50 |
+
*
|
51 |
+
* @return array
|
52 |
+
*
|
53 |
+
* @access public
|
54 |
+
* @version 6.1.0
|
55 |
+
*/
|
56 |
+
public function mergeOption($options)
|
57 |
+
{
|
58 |
+
return array_replace_recursive($options, $this->getOption());
|
59 |
+
}
|
60 |
+
|
61 |
}
|
application/Core/Object/Post.php
CHANGED
@@ -10,12 +10,13 @@
|
|
10 |
/**
|
11 |
* Post object
|
12 |
*
|
|
|
13 |
* @since 6.0.1 Added new method isDefined that is used to determine if access option
|
14 |
* is defined
|
15 |
* @since 6.0.0 Initial implementation of the class
|
16 |
*
|
17 |
* @package AAM
|
18 |
-
* @version 6.0
|
19 |
*/
|
20 |
class AAM_Core_Object_Post extends AAM_Core_Object
|
21 |
{
|
@@ -42,18 +43,18 @@ class AAM_Core_Object_Post extends AAM_Core_Object
|
|
42 |
*
|
43 |
* @param AAM_Core_Subject $subject
|
44 |
* @param WP_Post|Int $post
|
45 |
-
* @param boolean $suppressFilters
|
46 |
*
|
47 |
* @return void
|
48 |
*
|
|
|
|
|
|
|
49 |
* @access public
|
50 |
-
* @version 6.
|
51 |
*/
|
52 |
-
public function __construct(
|
53 |
-
|
54 |
-
) {
|
55 |
$this->setSubject($subject);
|
56 |
-
$this->setSuppressFilters($suppressFilters);
|
57 |
|
58 |
// Make sure that we are dealing with WP_Post object
|
59 |
// This is done to remove redundant calls to the database on the backend view
|
@@ -93,7 +94,11 @@ class AAM_Core_Object_Post extends AAM_Core_Object
|
|
93 |
|
94 |
/**
|
95 |
* @inheritDoc
|
96 |
-
*
|
|
|
|
|
|
|
|
|
97 |
*/
|
98 |
protected function initialize()
|
99 |
{
|
@@ -105,15 +110,12 @@ class AAM_Core_Object_Post extends AAM_Core_Object
|
|
105 |
|
106 |
$this->determineOverwritten($option);
|
107 |
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
// Finally set the option for this object
|
116 |
-
$this->setOption($option);
|
117 |
}
|
118 |
|
119 |
/**
|
@@ -234,13 +236,18 @@ class AAM_Core_Object_Post extends AAM_Core_Object
|
|
234 |
*
|
235 |
* @return boolean
|
236 |
*
|
|
|
|
|
|
|
237 |
* @access public
|
238 |
-
* @version 6.
|
239 |
*/
|
240 |
public function save()
|
241 |
{
|
242 |
return $this->getSubject()->updateOption(
|
243 |
-
$this->
|
|
|
|
|
244 |
);
|
245 |
}
|
246 |
|
10 |
/**
|
11 |
* Post object
|
12 |
*
|
13 |
+
* @since 6.1.0 Removed support for the $suppressFilters flag
|
14 |
* @since 6.0.1 Added new method isDefined that is used to determine if access option
|
15 |
* is defined
|
16 |
* @since 6.0.0 Initial implementation of the class
|
17 |
*
|
18 |
* @package AAM
|
19 |
+
* @version 6.1.0
|
20 |
*/
|
21 |
class AAM_Core_Object_Post extends AAM_Core_Object
|
22 |
{
|
43 |
*
|
44 |
* @param AAM_Core_Subject $subject
|
45 |
* @param WP_Post|Int $post
|
|
|
46 |
*
|
47 |
* @return void
|
48 |
*
|
49 |
+
* @since 6.1.0 Removed support for the $suppressFilters flag
|
50 |
+
* @since 6.0.0 Initial implementation of the method
|
51 |
+
*
|
52 |
* @access public
|
53 |
+
* @version 6.1.0
|
54 |
*/
|
55 |
+
public function __construct(AAM_Core_Subject $subject, $post)
|
56 |
+
{
|
|
|
57 |
$this->setSubject($subject);
|
|
|
58 |
|
59 |
// Make sure that we are dealing with WP_Post object
|
60 |
// This is done to remove redundant calls to the database on the backend view
|
94 |
|
95 |
/**
|
96 |
* @inheritDoc
|
97 |
+
*
|
98 |
+
* @since 6.1.0 Removed support for the $suppressFilters flag
|
99 |
+
* @since 6.0.0 Initial implementation of the method
|
100 |
+
*
|
101 |
+
* @version 6.1.0
|
102 |
*/
|
103 |
protected function initialize()
|
104 |
{
|
110 |
|
111 |
$this->determineOverwritten($option);
|
112 |
|
113 |
+
// Trigger custom functionality that may populate the post access options
|
114 |
+
// after initial setup. Typically is used by third party functionality and
|
115 |
+
// premium AAM plugins.
|
116 |
+
$this->setOption(
|
117 |
+
apply_filters('aam_post_object_option_filter', $option, $this)
|
118 |
+
);
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
/**
|
236 |
*
|
237 |
* @return boolean
|
238 |
*
|
239 |
+
* @since 6.1.0 Using explicit options to store settings
|
240 |
+
* @since 6.0.0 Initial implementation of the method
|
241 |
+
*
|
242 |
* @access public
|
243 |
+
* @version 6.1.0
|
244 |
*/
|
245 |
public function save()
|
246 |
{
|
247 |
return $this->getSubject()->updateOption(
|
248 |
+
$this->getExplicitOption(),
|
249 |
+
self::OBJECT_TYPE,
|
250 |
+
$this->ID . '|' . $this->post_type
|
251 |
);
|
252 |
}
|
253 |
|
application/Core/Object/Redirect.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* Access denied redirect object
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Core_Object_Redirect extends AAM_Core_Object
|
19 |
{
|
@@ -56,4 +57,21 @@ class AAM_Core_Object_Redirect extends AAM_Core_Object
|
|
56 |
return isset($option[$param]) ? $option[$param] : $default;
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
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 |
* Access denied redirect object
|
12 |
*
|
13 |
+
* @since 6.1.0 Fixed bug with incorrectly merged settings
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
class AAM_Core_Object_Redirect extends AAM_Core_Object
|
20 |
{
|
57 |
return isset($option[$param]) ? $option[$param] : $default;
|
58 |
}
|
59 |
|
60 |
+
/**
|
61 |
+
* Merge settings
|
62 |
+
*
|
63 |
+
* The last subject overrides previous
|
64 |
+
*
|
65 |
+
* @param array $options
|
66 |
+
*
|
67 |
+
* @return array
|
68 |
+
*
|
69 |
+
* @access public
|
70 |
+
* @version 6.1.0
|
71 |
+
*/
|
72 |
+
public function mergeOption($options)
|
73 |
+
{
|
74 |
+
return array_replace_recursive($options, $this->getOption());
|
75 |
+
}
|
76 |
+
|
77 |
}
|
application/Core/Object/Route.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* API route object
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Core_Object_Route extends AAM_Core_Object
|
19 |
{
|
@@ -27,7 +28,11 @@ class AAM_Core_Object_Route extends AAM_Core_Object
|
|
27 |
|
28 |
/**
|
29 |
* @inheritdoc
|
30 |
-
*
|
|
|
|
|
|
|
|
|
31 |
*/
|
32 |
protected function initialize()
|
33 |
{
|
@@ -37,9 +42,7 @@ class AAM_Core_Object_Route extends AAM_Core_Object
|
|
37 |
|
38 |
// Trigger custom functionality that may populate the menu options. For
|
39 |
// example, this hooks is used by Access Policy service
|
40 |
-
|
41 |
-
$option = apply_filters('aam_route_object_option_filter', $option, $this);
|
42 |
-
}
|
43 |
|
44 |
$this->setOption(is_array($option) ? $option : array());
|
45 |
}
|
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 |
* API route object
|
12 |
*
|
13 |
+
* @since 6.1.0 Fixed bug with incorrectly halted inheritance mechanism
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
class AAM_Core_Object_Route extends AAM_Core_Object
|
20 |
{
|
28 |
|
29 |
/**
|
30 |
* @inheritdoc
|
31 |
+
*
|
32 |
+
* @since 6.1.0 Fixed bug with incorrectly halted inheritance mechanism
|
33 |
+
* @since 6.0.0 Initial implementation of the method
|
34 |
+
*
|
35 |
+
* @version 6.1.0
|
36 |
*/
|
37 |
protected function initialize()
|
38 |
{
|
42 |
|
43 |
// Trigger custom functionality that may populate the menu options. For
|
44 |
// example, this hooks is used by Access Policy service
|
45 |
+
$option = apply_filters('aam_route_object_option_filter', $option, $this);
|
|
|
|
|
46 |
|
47 |
$this->setOption(is_array($option) ? $option : array());
|
48 |
}
|
application/Core/Object/Toolbar.php
CHANGED
@@ -12,8 +12,11 @@
|
|
12 |
/**
|
13 |
* Admin toolbar object
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Core_Object_Toolbar extends AAM_Core_Object
|
19 |
{
|
@@ -27,7 +30,11 @@ class AAM_Core_Object_Toolbar extends AAM_Core_Object
|
|
27 |
|
28 |
/**
|
29 |
* @inheritdoc
|
30 |
-
*
|
|
|
|
|
|
|
|
|
31 |
*/
|
32 |
protected function initialize()
|
33 |
{
|
@@ -37,11 +44,7 @@ class AAM_Core_Object_Toolbar extends AAM_Core_Object
|
|
37 |
|
38 |
// Trigger custom functionality that may populate the menu options. For
|
39 |
// example, this hooks is used by Access Policy service
|
40 |
-
|
41 |
-
$option = apply_filters(
|
42 |
-
'aam_toolbar_object_option_filter', $option, $this
|
43 |
-
);
|
44 |
-
}
|
45 |
|
46 |
$this->setOption(is_array($option) ? $option : array());
|
47 |
}
|
12 |
/**
|
13 |
* Admin toolbar object
|
14 |
*
|
15 |
+
* @since 6.1.0 Fixed bug with incorrectly halted inheritance mechanism
|
16 |
+
* @since 6.0.0 Initial implementation of the class
|
17 |
+
*
|
18 |
* @package AAM
|
19 |
+
* @version 6.1.0
|
20 |
*/
|
21 |
class AAM_Core_Object_Toolbar extends AAM_Core_Object
|
22 |
{
|
30 |
|
31 |
/**
|
32 |
* @inheritdoc
|
33 |
+
*
|
34 |
+
* @since 6.1.0 Fixed bug with incorrectly halted inheritance mechanism
|
35 |
+
* @since 6.0.0 Initial implementation of the method
|
36 |
+
*
|
37 |
+
* @version 6.1.0
|
38 |
*/
|
39 |
protected function initialize()
|
40 |
{
|
44 |
|
45 |
// Trigger custom functionality that may populate the menu options. For
|
46 |
// example, this hooks is used by Access Policy service
|
47 |
+
$option = apply_filters('aam_toolbar_object_option_filter', $option, $this);
|
|
|
|
|
|
|
|
|
48 |
|
49 |
$this->setOption(is_array($option) ? $option : array());
|
50 |
}
|
application/Core/Object/Uri.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* URI object
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Core_Object_Uri extends AAM_Core_Object
|
19 |
{
|
@@ -27,7 +28,11 @@ class AAM_Core_Object_Uri extends AAM_Core_Object
|
|
27 |
|
28 |
/**
|
29 |
* @inheritdoc
|
30 |
-
*
|
|
|
|
|
|
|
|
|
31 |
*/
|
32 |
protected function initialize()
|
33 |
{
|
@@ -37,9 +42,7 @@ class AAM_Core_Object_Uri extends AAM_Core_Object
|
|
37 |
|
38 |
// Trigger custom functionality that may populate the menu options. For
|
39 |
// example, this hooks is used by Access Policy service
|
40 |
-
|
41 |
-
$option = apply_filters('aam_uri_object_option_filter', $option, $this);
|
42 |
-
}
|
43 |
|
44 |
$this->setOption(is_array($option) ? $option : array());
|
45 |
}
|
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 |
* URI object
|
12 |
*
|
13 |
+
* @since 6.1.0 Fixed bug with incorrectly halted inheritance mechanism
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
class AAM_Core_Object_Uri extends AAM_Core_Object
|
20 |
{
|
28 |
|
29 |
/**
|
30 |
* @inheritdoc
|
31 |
+
*
|
32 |
+
* @since 6.1.0 Fixed bug with incorrectly halted inheritance mechanism
|
33 |
+
* @since 6.0.0 Initial implementation of the method
|
34 |
+
*
|
35 |
+
* @version 6.1.0
|
36 |
*/
|
37 |
protected function initialize()
|
38 |
{
|
42 |
|
43 |
// Trigger custom functionality that may populate the menu options. For
|
44 |
// example, this hooks is used by Access Policy service
|
45 |
+
$option = apply_filters('aam_uri_object_option_filter', $option, $this);
|
|
|
|
|
46 |
|
47 |
$this->setOption(is_array($option) ? $option : array());
|
48 |
}
|
application/Core/Object/Visibility.php
CHANGED
@@ -5,15 +5,17 @@
|
|
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 |
* Post visibility object
|
14 |
*
|
|
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Core_Object_Visibility extends AAM_Core_Object
|
19 |
{
|
@@ -40,19 +42,19 @@ class AAM_Core_Object_Visibility extends AAM_Core_Object
|
|
40 |
*
|
41 |
* @param AAM_Core_Subject $subject
|
42 |
* @param mixed $id
|
43 |
-
* @param boolean $setSuppressFilters
|
44 |
*
|
45 |
* @return void
|
46 |
*
|
|
|
|
|
|
|
47 |
* @access public
|
48 |
-
* @version 6.
|
49 |
*/
|
50 |
-
public function __construct(
|
51 |
-
|
52 |
-
) {
|
53 |
$this->setSubject($subject);
|
54 |
$this->setId($id);
|
55 |
-
$this->setSuppressFilters($suppressFilters);
|
56 |
|
57 |
// Determine post access properties that are responsible for the post
|
58 |
// visibility
|
@@ -66,7 +68,11 @@ class AAM_Core_Object_Visibility extends AAM_Core_Object
|
|
66 |
|
67 |
/**
|
68 |
* @inheritDoc
|
69 |
-
*
|
|
|
|
|
|
|
|
|
70 |
*/
|
71 |
protected function initialize()
|
72 |
{
|
@@ -76,11 +82,9 @@ class AAM_Core_Object_Visibility extends AAM_Core_Object
|
|
76 |
$this->pushOptions('post', $id, $settings);
|
77 |
}
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
do_action('aam_visibility_object_init_action', $this);
|
83 |
-
}
|
84 |
}
|
85 |
|
86 |
/**
|
@@ -92,8 +96,12 @@ class AAM_Core_Object_Visibility extends AAM_Core_Object
|
|
92 |
*
|
93 |
* @return array
|
94 |
*
|
|
|
|
|
|
|
|
|
95 |
* @access public
|
96 |
-
* @version 6.
|
97 |
*/
|
98 |
public function pushOptions($object, $id, $options)
|
99 |
{
|
@@ -113,10 +121,12 @@ class AAM_Core_Object_Visibility extends AAM_Core_Object
|
|
113 |
);
|
114 |
}
|
115 |
|
116 |
-
if (!isset($option[$object
|
117 |
-
$option[$object
|
118 |
} else {
|
119 |
-
$option[$object
|
|
|
|
|
120 |
}
|
121 |
$this->setOption($option);
|
122 |
|
@@ -130,14 +140,24 @@ class AAM_Core_Object_Visibility extends AAM_Core_Object
|
|
130 |
*
|
131 |
* @return array
|
132 |
*
|
|
|
|
|
|
|
|
|
133 |
* @access public
|
134 |
-
* @version 6.
|
135 |
*/
|
136 |
public function getSegment($segment)
|
137 |
{
|
138 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
-
return
|
141 |
}
|
142 |
|
143 |
/**
|
@@ -147,14 +167,32 @@ class AAM_Core_Object_Visibility extends AAM_Core_Object
|
|
147 |
*
|
148 |
* @return array
|
149 |
*
|
|
|
|
|
|
|
|
|
150 |
* @access public
|
151 |
-
* @version 6.
|
152 |
*/
|
153 |
public function mergeOption($options)
|
154 |
{
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
}
|
159 |
|
160 |
}
|
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 |
* Post visibility object
|
12 |
*
|
13 |
+
* @since 6.1.0 Refactored implementation to fix merging bugs and improve inheritance
|
14 |
+
* mechanism
|
15 |
+
* @since 6.0.0 Initial implementation of the class
|
16 |
+
*
|
17 |
* @package AAM
|
18 |
+
* @version 6.1.0
|
19 |
*/
|
20 |
class AAM_Core_Object_Visibility extends AAM_Core_Object
|
21 |
{
|
42 |
*
|
43 |
* @param AAM_Core_Subject $subject
|
44 |
* @param mixed $id
|
|
|
45 |
*
|
46 |
* @return void
|
47 |
*
|
48 |
+
* @since 6.1.0 Removed support for the $suppressFilters flag
|
49 |
+
* @since 6.0.0 Initial implementation of the method
|
50 |
+
*
|
51 |
* @access public
|
52 |
+
* @version 6.1.0
|
53 |
*/
|
54 |
+
public function __construct(AAM_Core_Subject $subject, $id = null)
|
55 |
+
{
|
|
|
56 |
$this->setSubject($subject);
|
57 |
$this->setId($id);
|
|
|
58 |
|
59 |
// Determine post access properties that are responsible for the post
|
60 |
// visibility
|
68 |
|
69 |
/**
|
70 |
* @inheritDoc
|
71 |
+
*
|
72 |
+
* @since 6.1.0 Removed support for the $suppressFilters flag
|
73 |
+
* @since 6.0.0 Initial implementation of the method
|
74 |
+
*
|
75 |
+
* @version 6.1.0
|
76 |
*/
|
77 |
protected function initialize()
|
78 |
{
|
82 |
$this->pushOptions('post', $id, $settings);
|
83 |
}
|
84 |
|
85 |
+
// Initialize post visibility option. This hooks is used by Access Policy
|
86 |
+
// service as well as Plus Package to populate visibility list
|
87 |
+
do_action('aam_visibility_object_init_action', $this);
|
|
|
|
|
88 |
}
|
89 |
|
90 |
/**
|
96 |
*
|
97 |
* @return array
|
98 |
*
|
99 |
+
* @since 6.1.0 Changed the way visibility options are indexed (used to be as
|
100 |
+
* multi-dimensional array and now it is key/value pairs)
|
101 |
+
* @since 6.0.0 Initial implementation of the method
|
102 |
+
*
|
103 |
* @access public
|
104 |
+
* @version 6.1.0
|
105 |
*/
|
106 |
public function pushOptions($object, $id, $options)
|
107 |
{
|
121 |
);
|
122 |
}
|
123 |
|
124 |
+
if (!isset($option["{$object}/{$id}"])) {
|
125 |
+
$option["{$object}/{$id}"] = $filtered;
|
126 |
} else {
|
127 |
+
$option["{$object}/{$id}"] = array_replace(
|
128 |
+
$filtered, $option["{$object}/{$id}"]
|
129 |
+
);
|
130 |
}
|
131 |
$this->setOption($option);
|
132 |
|
140 |
*
|
141 |
* @return array
|
142 |
*
|
143 |
+
* @since 6.1.0 Changed the way visibility options are fetched (used to be as
|
144 |
+
* multi-dimensional array and now it is key/value pairs)
|
145 |
+
* @since 6.0.0 Initial implementation of the method
|
146 |
+
*
|
147 |
* @access public
|
148 |
+
* @version 6.1.0
|
149 |
*/
|
150 |
public function getSegment($segment)
|
151 |
{
|
152 |
+
$response = array();
|
153 |
+
|
154 |
+
foreach($this->getOption() as $key => $value) {
|
155 |
+
if (strpos($key, "{$segment}/") === 0) {
|
156 |
+
$response[str_replace("{$segment}/", '', $key)] = $value;
|
157 |
+
}
|
158 |
+
}
|
159 |
|
160 |
+
return $response;
|
161 |
}
|
162 |
|
163 |
/**
|
167 |
*
|
168 |
* @return array
|
169 |
*
|
170 |
+
* @since 6.1.0 Fixed bug with incorrectly merged settings for users with multiple
|
171 |
+
* roles
|
172 |
+
* @since 6.0.0 Initial implementation of the method
|
173 |
+
*
|
174 |
* @access public
|
175 |
+
* @version 6.1.0
|
176 |
*/
|
177 |
public function mergeOption($options)
|
178 |
{
|
179 |
+
$these_options = $this->getOption();
|
180 |
+
$keys = array_unique(array_merge(
|
181 |
+
array_keys($options), array_keys($this->getOption())
|
182 |
+
));
|
183 |
+
|
184 |
+
$merged = array();
|
185 |
+
|
186 |
+
// Iterate over each unique key end merge settings accordingly
|
187 |
+
foreach($keys as $key) {
|
188 |
+
$merged[$key] = AAM::api()->mergeSettings(
|
189 |
+
(isset($options[$key]) ? $options[$key] : array()),
|
190 |
+
(isset($these_options[$key]) ? $these_options[$key] : array()),
|
191 |
+
AAM_Core_Object_Post::OBJECT_TYPE
|
192 |
+
);
|
193 |
+
}
|
194 |
+
|
195 |
+
return $merged;
|
196 |
}
|
197 |
|
198 |
}
|
application/Core/Policy/Condition.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* AAM core policy condition evaluator
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Core_Policy_Condition
|
19 |
{
|
@@ -382,10 +383,13 @@ class AAM_Core_Policy_Condition
|
|
382 |
*
|
383 |
* @return mixed Prepared part of the condition or false on failure
|
384 |
*
|
|
|
|
|
|
|
385 |
* @access protected
|
386 |
-
* @version 6.
|
387 |
*/
|
388 |
-
|
389 |
{
|
390 |
if (is_scalar($exp)) {
|
391 |
if (preg_match_all('/(\$\{[^}]+\})/', $exp, $match)) {
|
@@ -394,9 +398,12 @@ class AAM_Core_Policy_Condition
|
|
394 |
|
395 |
$types = 'string|ip|int|boolean|bool|array|null';
|
396 |
|
397 |
-
//
|
|
|
|
|
|
|
398 |
if (preg_match('/^\(\*(' . $types . ')\)(.*)/i', $exp, $scale)) {
|
399 |
-
$exp = $this->
|
400 |
}
|
401 |
} elseif (is_array($exp) || is_object($exp)) {
|
402 |
foreach ($exp as &$value) {
|
@@ -417,10 +424,14 @@ class AAM_Core_Policy_Condition
|
|
417 |
*
|
418 |
* @return mixed
|
419 |
*
|
|
|
|
|
|
|
|
|
420 |
* @access protected
|
421 |
-
* @version 6.
|
422 |
*/
|
423 |
-
|
424 |
{
|
425 |
switch (strtolower($type)) {
|
426 |
case 'string':
|
@@ -449,10 +460,10 @@ class AAM_Core_Policy_Condition
|
|
449 |
break;
|
450 |
|
451 |
default:
|
|
|
452 |
break;
|
453 |
}
|
454 |
|
455 |
return $value;
|
456 |
}
|
457 |
-
|
458 |
}
|
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 core policy condition evaluator
|
12 |
*
|
13 |
+
* @since 6.1.0 Improved type casting functionality
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
class AAM_Core_Policy_Condition
|
20 |
{
|
383 |
*
|
384 |
* @return mixed Prepared part of the condition or false on failure
|
385 |
*
|
386 |
+
* @since 6.1.0 Improved type casing functionality
|
387 |
+
* @since 6.0.0 Initial implementation of the method
|
388 |
+
*
|
389 |
* @access protected
|
390 |
+
* @version 6.1.0
|
391 |
*/
|
392 |
+
public function parseExpression($exp, $args)
|
393 |
{
|
394 |
if (is_scalar($exp)) {
|
395 |
if (preg_match_all('/(\$\{[^}]+\})/', $exp, $match)) {
|
398 |
|
399 |
$types = 'string|ip|int|boolean|bool|array|null';
|
400 |
|
401 |
+
// Note! It make no sense to have multiple type casting for one expression
|
402 |
+
// due to the fact that they all would have to be concatenated as a string
|
403 |
+
|
404 |
+
// If there is type casting, perform it too
|
405 |
if (preg_match('/^\(\*(' . $types . ')\)(.*)/i', $exp, $scale)) {
|
406 |
+
$exp = $this->_typecast($scale[2], $scale[1]);
|
407 |
}
|
408 |
} elseif (is_array($exp) || is_object($exp)) {
|
409 |
foreach ($exp as &$value) {
|
424 |
*
|
425 |
* @return mixed
|
426 |
*
|
427 |
+
* @version 6.1.0 Renamed the method from `castValue` to `_typecast`. Added new
|
428 |
+
* filter `aam_token_typecast_filter`
|
429 |
+
* @version 6.0.0 Initial implementation of the method
|
430 |
+
*
|
431 |
* @access protected
|
432 |
+
* @version 6.1.0
|
433 |
*/
|
434 |
+
private function _typecast($value, $type)
|
435 |
{
|
436 |
switch (strtolower($type)) {
|
437 |
case 'string':
|
460 |
break;
|
461 |
|
462 |
default:
|
463 |
+
$value = apply_filters('aam_token_typecast_filter', $value, $type);
|
464 |
break;
|
465 |
}
|
466 |
|
467 |
return $value;
|
468 |
}
|
|
|
469 |
}
|
application/Core/Policy/Factory.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* AAM core policy manager factory
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
final class AAM_Core_Policy_Factory
|
19 |
{
|
@@ -32,23 +33,32 @@ final class AAM_Core_Policy_Factory
|
|
32 |
* Get single instance of access manager
|
33 |
*
|
34 |
* @param AAM_Core_Subject $subject
|
|
|
35 |
*
|
36 |
* @return AAM_Core_Policy_Manager
|
37 |
*
|
|
|
|
|
|
|
38 |
* @access public
|
39 |
-
* @version 6.
|
40 |
*/
|
41 |
-
public static function get(AAM_Core_Subject $subject = null)
|
42 |
{
|
43 |
if (is_null($subject)) {
|
44 |
$subject = AAM::getUser();
|
45 |
}
|
46 |
|
47 |
-
$id
|
48 |
-
|
|
|
|
|
49 |
|
50 |
if (!isset(self::$_instances[$sid])) {
|
51 |
-
self::$_instances[$sid] = new AAM_Core_Policy_Manager(
|
|
|
|
|
|
|
52 |
// Parse all attached to the user policies
|
53 |
self::$_instances[$sid]->initialize();
|
54 |
}
|
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 core policy manager factory
|
12 |
*
|
13 |
+
* @since 6.1.0 Fixed bug with incorrectly managed internal cache
|
14 |
+
* @since 6.0.0 Initial implementation of the class
|
15 |
+
*
|
16 |
* @package AAM
|
17 |
+
* @version 6.1.0
|
18 |
*/
|
19 |
final class AAM_Core_Policy_Factory
|
20 |
{
|
33 |
* Get single instance of access manager
|
34 |
*
|
35 |
* @param AAM_Core_Subject $subject
|
36 |
+
* @param boolean $skipInheritance
|
37 |
*
|
38 |
* @return AAM_Core_Policy_Manager
|
39 |
*
|
40 |
+
* @since 6.1.0 Fixed bug with incorrectly managed internal caching
|
41 |
+
* @since 6.0.0 Initial implementation of the method
|
42 |
+
*
|
43 |
* @access public
|
44 |
+
* @version 6.1.0
|
45 |
*/
|
46 |
+
public static function get(AAM_Core_Subject $subject = null, $skipInheritance)
|
47 |
{
|
48 |
if (is_null($subject)) {
|
49 |
$subject = AAM::getUser();
|
50 |
}
|
51 |
|
52 |
+
$id = $subject->getId();
|
53 |
+
|
54 |
+
$sid = $subject::UID . (empty($id) ? '' : '_' . $id);
|
55 |
+
$sid .= ($skipInheritance ? '_direct' : '_complete');
|
56 |
|
57 |
if (!isset(self::$_instances[$sid])) {
|
58 |
+
self::$_instances[$sid] = new AAM_Core_Policy_Manager(
|
59 |
+
$subject, $skipInheritance
|
60 |
+
);
|
61 |
+
|
62 |
// Parse all attached to the user policies
|
63 |
self::$_instances[$sid]->initialize();
|
64 |
}
|
application/Core/Policy/Manager.php
CHANGED
@@ -10,11 +10,12 @@
|
|
10 |
/**
|
11 |
* AAM policy manager for a specific subject
|
12 |
*
|
|
|
13 |
* @since 6.0.4 Potential bug fix with improperly merged Param option:* values
|
14 |
* @since 6.0.0 Initial implementation of the class
|
15 |
*
|
16 |
* @package AAM
|
17 |
-
* @version 6.0
|
18 |
*/
|
19 |
class AAM_Core_Policy_Manager
|
20 |
{
|
@@ -55,14 +56,23 @@ class AAM_Core_Policy_Manager
|
|
55 |
/**
|
56 |
* Constructor
|
57 |
*
|
|
|
|
|
|
|
58 |
* @access protected
|
59 |
*
|
|
|
|
|
|
|
60 |
* @return void
|
61 |
-
* @version 6.
|
62 |
*/
|
63 |
-
public function __construct(AAM_Core_Subject $subject)
|
64 |
{
|
65 |
-
$this->object = $subject->getObject(
|
|
|
|
|
|
|
66 |
$this->subject = $subject;
|
67 |
}
|
68 |
|
@@ -382,8 +392,11 @@ class AAM_Core_Policy_Manager
|
|
382 |
*
|
383 |
* @return array
|
384 |
*
|
|
|
|
|
|
|
385 |
* @access protected
|
386 |
-
* @version 6.
|
387 |
*/
|
388 |
protected function updatePolicyTree(&$tree, $addition)
|
389 |
{
|
@@ -397,17 +410,31 @@ class AAM_Core_Policy_Manager
|
|
397 |
$actions = (isset($stm['Action']) ? (array) $stm['Action'] : array(''));
|
398 |
|
399 |
foreach ($resources as $res) {
|
|
|
|
|
400 |
// Allow to build resource name dynamically.
|
401 |
-
|
402 |
-
|
403 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
}
|
405 |
|
406 |
-
foreach
|
407 |
-
|
|
|
408 |
|
409 |
-
|
410 |
-
|
|
|
411 |
}
|
412 |
}
|
413 |
}
|
@@ -419,7 +446,7 @@ class AAM_Core_Policy_Manager
|
|
419 |
foreach ($addition['Param'] as $param) {
|
420 |
if (!empty($param['Key'])) {
|
421 |
// Allow to build param name dynamically.
|
422 |
-
// e.g. "${
|
423 |
if (preg_match_all('/(\$\{[^}]+\})/', $param['Key'], $match)) {
|
424 |
$id = AAM_Core_Policy_Token::evaluate($param['Key'], $match[1]);
|
425 |
} else {
|
10 |
/**
|
11 |
* AAM policy manager for a specific subject
|
12 |
*
|
13 |
+
* @since 6.1.0 Implemented `=>` operator. Improved inheritance mechanism
|
14 |
* @since 6.0.4 Potential bug fix with improperly merged Param option:* values
|
15 |
* @since 6.0.0 Initial implementation of the class
|
16 |
*
|
17 |
* @package AAM
|
18 |
+
* @version 6.1.0
|
19 |
*/
|
20 |
class AAM_Core_Policy_Manager
|
21 |
{
|
56 |
/**
|
57 |
* Constructor
|
58 |
*
|
59 |
+
* @param AAM_Core_Subject $subject
|
60 |
+
* @param boolean $skipInheritance
|
61 |
+
*
|
62 |
* @access protected
|
63 |
*
|
64 |
+
* @since 6.1.0 Added new `$skipInheritance` mandatory argument
|
65 |
+
* @since 6.0.0 Initial implementation of the method
|
66 |
+
*
|
67 |
* @return void
|
68 |
+
* @version 6.1.0
|
69 |
*/
|
70 |
+
public function __construct(AAM_Core_Subject $subject, $skipInheritance)
|
71 |
{
|
72 |
+
$this->object = $subject->getObject(
|
73 |
+
AAM_Core_Object_Policy::OBJECT_TYPE, null, $skipInheritance
|
74 |
+
);
|
75 |
+
|
76 |
$this->subject = $subject;
|
77 |
}
|
78 |
|
392 |
*
|
393 |
* @return array
|
394 |
*
|
395 |
+
* @since 6.1.0 Added support for the `=>` (map to) operator
|
396 |
+
* @since 6.0.0 Initial implementation of the method
|
397 |
+
*
|
398 |
* @access protected
|
399 |
+
* @version 6.1.0
|
400 |
*/
|
401 |
protected function updatePolicyTree(&$tree, $addition)
|
402 |
{
|
410 |
$actions = (isset($stm['Action']) ? (array) $stm['Action'] : array(''));
|
411 |
|
412 |
foreach ($resources as $res) {
|
413 |
+
$map = array(); // Reset map
|
414 |
+
|
415 |
// Allow to build resource name dynamically.
|
416 |
+
if (preg_match('/^(.*)[\s]+(map to|=>)[\s]+(.*)$/i', $res, $match)) {
|
417 |
+
// e.g. "Term:category:%s:posts => ${USER_META.regions}"
|
418 |
+
$values = (array) AAM_Core_Policy_Token::getTokenValue($match[3]);
|
419 |
+
|
420 |
+
// Create the map of resources and replace
|
421 |
+
foreach($values as $value) {
|
422 |
+
$map[] = sprintf($match[1], $value);
|
423 |
+
}
|
424 |
+
} elseif (preg_match_all('/(\$\{[^}]+\})/', $res, $match)) {
|
425 |
+
// e.g. "Term:category:${USER_META.region}:posts"
|
426 |
+
$map = array(AAM_Core_Policy_Token::evaluate($res, $match[1]));
|
427 |
+
} else {
|
428 |
+
$map = array($res);
|
429 |
}
|
430 |
|
431 |
+
foreach($map as $resource) {
|
432 |
+
foreach ($actions as $act) {
|
433 |
+
$id = strtolower($resource . (!empty($act) ? ":{$act}" : ''));
|
434 |
|
435 |
+
if (!isset($stmts[$id]) || empty($stmts[$id]['Enforce'])) {
|
436 |
+
$stmts[$id] = $stm;
|
437 |
+
}
|
438 |
}
|
439 |
}
|
440 |
}
|
446 |
foreach ($addition['Param'] as $param) {
|
447 |
if (!empty($param['Key'])) {
|
448 |
// Allow to build param name dynamically.
|
449 |
+
// e.g. "${USER_META.region}_posts"
|
450 |
if (preg_match_all('/(\$\{[^}]+\})/', $param['Key'], $match)) {
|
451 |
$id = AAM_Core_Policy_Token::evaluate($param['Key'], $match[1]);
|
452 |
} else {
|
application/Core/Policy/Token.php
CHANGED
@@ -12,8 +12,11 @@
|
|
12 |
/**
|
13 |
* AAM core policy token evaluator
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Core_Policy_Token
|
19 |
{
|
@@ -23,8 +26,11 @@ class AAM_Core_Policy_Token
|
|
23 |
*
|
24 |
* @var array
|
25 |
*
|
|
|
|
|
|
|
26 |
* @access protected
|
27 |
-
* @version 6.
|
28 |
*/
|
29 |
protected static $map = array(
|
30 |
'USER' => 'AAM_Core_Policy_Token::getUserValue',
|
@@ -40,7 +46,8 @@ class AAM_Core_Policy_Token
|
|
40 |
'ENV' => 'getenv',
|
41 |
'CONST' => 'AAM_Core_Policy_Token::getConstant',
|
42 |
'WP_OPTION' => 'AAM_Core_API::getOption',
|
43 |
-
'JWT' => 'AAM_Core_Policy_Token::getJwtClaim'
|
|
|
44 |
);
|
45 |
|
46 |
/**
|
@@ -52,17 +59,16 @@ class AAM_Core_Policy_Token
|
|
52 |
*
|
53 |
* @return string
|
54 |
*
|
|
|
|
|
|
|
55 |
* @access public
|
56 |
-
* @version 6.
|
57 |
*/
|
58 |
public static function evaluate($part, array $tokens, array $args = array())
|
59 |
{
|
60 |
foreach ($tokens as $token) {
|
61 |
-
$val
|
62 |
-
preg_replace('/^\$\{([^}]+)\}$/', '${1}', $token),
|
63 |
-
$args
|
64 |
-
);
|
65 |
-
|
66 |
$part = str_replace(
|
67 |
$token,
|
68 |
(is_scalar($val) || is_null($val) ? $val : json_encode($val)),
|
@@ -81,13 +87,12 @@ class AAM_Core_Policy_Token
|
|
81 |
*
|
82 |
* @return mixed
|
83 |
*
|
84 |
-
* @access
|
85 |
-
* @version 6.
|
86 |
*/
|
87 |
-
|
88 |
{
|
89 |
-
$
|
90 |
-
$parts = explode('.', $token);
|
91 |
|
92 |
if (isset(self::$map[$parts[0]])) {
|
93 |
if ($parts[0] === 'ARGS') {
|
@@ -97,6 +102,10 @@ class AAM_Core_Policy_Token
|
|
97 |
}
|
98 |
} elseif ($parts[0] === 'CALLBACK') {
|
99 |
$value = is_callable($parts[1]) ? call_user_func($parts[1], $args) : null;
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
|
102 |
return $value;
|
@@ -242,4 +251,19 @@ class AAM_Core_Policy_Token
|
|
242 |
return (defined($const) ? constant($const) : null);
|
243 |
}
|
244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
}
|
12 |
/**
|
13 |
* AAM core policy token evaluator
|
14 |
*
|
15 |
+
* @since 6.1.0 Added support for the new token `AAM_CONFIG`
|
16 |
+
* @since 6.0.0 Initial implementation of the class
|
17 |
+
*
|
18 |
* @package AAM
|
19 |
+
* @version 6.1.0
|
20 |
*/
|
21 |
class AAM_Core_Policy_Token
|
22 |
{
|
26 |
*
|
27 |
* @var array
|
28 |
*
|
29 |
+
* @since 6.1.0 Added `AAM_CONFIG` token
|
30 |
+
* @since 6.0.0 Initial implementation of the property
|
31 |
+
*
|
32 |
* @access protected
|
33 |
+
* @version 6.1.0
|
34 |
*/
|
35 |
protected static $map = array(
|
36 |
'USER' => 'AAM_Core_Policy_Token::getUserValue',
|
46 |
'ENV' => 'getenv',
|
47 |
'CONST' => 'AAM_Core_Policy_Token::getConstant',
|
48 |
'WP_OPTION' => 'AAM_Core_API::getOption',
|
49 |
+
'JWT' => 'AAM_Core_Policy_Token::getJwtClaim',
|
50 |
+
'AAM_CONFIG' => 'AAM_Core_Policy_Token::getConfig'
|
51 |
);
|
52 |
|
53 |
/**
|
59 |
*
|
60 |
* @return string
|
61 |
*
|
62 |
+
* @since 6.1.0 Changed `getValue` method to `getTokenValue`
|
63 |
+
* @since 6.0.0 Initial implementation of the method
|
64 |
+
*
|
65 |
* @access public
|
66 |
+
* @version 6.1.0
|
67 |
*/
|
68 |
public static function evaluate($part, array $tokens, array $args = array())
|
69 |
{
|
70 |
foreach ($tokens as $token) {
|
71 |
+
$val = self::getTokenValue($token, $args);
|
|
|
|
|
|
|
|
|
72 |
$part = str_replace(
|
73 |
$token,
|
74 |
(is_scalar($val) || is_null($val) ? $val : json_encode($val)),
|
87 |
*
|
88 |
* @return mixed
|
89 |
*
|
90 |
+
* @access public
|
91 |
+
* @version 6.1.0
|
92 |
*/
|
93 |
+
public static function getTokenValue($token, $args = array())
|
94 |
{
|
95 |
+
$parts = explode('.', preg_replace('/^\$\{([^}]+)\}$/', '${1}', $token), 2);
|
|
|
96 |
|
97 |
if (isset(self::$map[$parts[0]])) {
|
98 |
if ($parts[0] === 'ARGS') {
|
102 |
}
|
103 |
} elseif ($parts[0] === 'CALLBACK') {
|
104 |
$value = is_callable($parts[1]) ? call_user_func($parts[1], $args) : null;
|
105 |
+
} else {
|
106 |
+
$value = apply_filters(
|
107 |
+
'aam_get_policy_token_value_filter', $parts[0], $parts[1], $args
|
108 |
+
);
|
109 |
}
|
110 |
|
111 |
return $value;
|
251 |
return (defined($const) ? constant($const) : null);
|
252 |
}
|
253 |
|
254 |
+
/**
|
255 |
+
* Get AAM configuration
|
256 |
+
*
|
257 |
+
* @param string $config
|
258 |
+
*
|
259 |
+
* @return mixed
|
260 |
+
*
|
261 |
+
* @access protected
|
262 |
+
* @version 6.1.0
|
263 |
+
*/
|
264 |
+
protected static function getConfig($config)
|
265 |
+
{
|
266 |
+
return AAM::api()->getConfig($config);
|
267 |
+
}
|
268 |
+
|
269 |
}
|
application/Core/Subject.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 |
/**
|
@@ -28,8 +26,11 @@
|
|
28 |
* Subject principal is underlying WordPress core user or role. Not all Subjects have
|
29 |
* principals (e.g. Visitor or Default).
|
30 |
*
|
|
|
|
|
|
|
31 |
* @package AAM
|
32 |
-
* @version 6.
|
33 |
*/
|
34 |
abstract class AAM_Core_Subject
|
35 |
{
|
@@ -275,13 +276,19 @@ abstract class AAM_Core_Subject
|
|
275 |
*
|
276 |
* @return AAM_Core_Object
|
277 |
*
|
|
|
|
|
|
|
|
|
278 |
* @access public
|
279 |
-
* @version 6.
|
280 |
*/
|
281 |
public function getObject($type, $id = null, $skipInheritance = false)
|
282 |
{
|
|
|
|
|
283 |
// Check if there is an object with specified ID
|
284 |
-
if (!isset($this->_objects[$type . $id])) {
|
285 |
$class_name = 'AAM_Core_Object_' . ucfirst($type);
|
286 |
|
287 |
// If requested object is part of the core, instantiate it
|
@@ -304,10 +311,10 @@ abstract class AAM_Core_Subject
|
|
304 |
}
|
305 |
|
306 |
// Finally cache the object
|
307 |
-
$this->_objects[$type . $id] = $object;
|
308 |
}
|
309 |
} else {
|
310 |
-
$object = $this->_objects[$type . $id];
|
311 |
}
|
312 |
|
313 |
return $object;
|
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 |
/**
|
26 |
* Subject principal is underlying WordPress core user or role. Not all Subjects have
|
27 |
* principals (e.g. Visitor or Default).
|
28 |
*
|
29 |
+
* @since 6.1.0 Fixed bug with incorrectly managed internal cache
|
30 |
+
* @since 6.0.0 Initial implementation of the class
|
31 |
+
*
|
32 |
* @package AAM
|
33 |
+
* @version 6.1.0
|
34 |
*/
|
35 |
abstract class AAM_Core_Subject
|
36 |
{
|
276 |
*
|
277 |
* @return AAM_Core_Object
|
278 |
*
|
279 |
+
* @since 6.1.0 Fixed the bug where initialize object was not cached correctly
|
280 |
+
* due to $skipInheritance flag
|
281 |
+
* @since 6.0.0 Initial implementation of the method
|
282 |
+
*
|
283 |
* @access public
|
284 |
+
* @version 6.1.0
|
285 |
*/
|
286 |
public function getObject($type, $id = null, $skipInheritance = false)
|
287 |
{
|
288 |
+
$suffix = ($skipInheritance ? '_direct' : '_full');
|
289 |
+
|
290 |
// Check if there is an object with specified ID
|
291 |
+
if (!isset($this->_objects[$type . $id . $suffix])) {
|
292 |
$class_name = 'AAM_Core_Object_' . ucfirst($type);
|
293 |
|
294 |
// If requested object is part of the core, instantiate it
|
311 |
}
|
312 |
|
313 |
// Finally cache the object
|
314 |
+
$this->_objects[$type . $id . $suffix] = $object;
|
315 |
}
|
316 |
} else {
|
317 |
+
$object = $this->_objects[$type . $id . $suffix];
|
318 |
}
|
319 |
|
320 |
return $object;
|
application/Service/AccessPolicy.php
CHANGED
@@ -5,15 +5,16 @@
|
|
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 |
* Access Policy service
|
14 |
*
|
|
|
|
|
|
|
15 |
* @package AAM
|
16 |
-
* @version 6.
|
17 |
*/
|
18 |
class AAM_Service_AccessPolicy
|
19 |
{
|
@@ -222,13 +223,16 @@ class AAM_Service_AccessPolicy
|
|
222 |
*
|
223 |
* @return array
|
224 |
*
|
|
|
|
|
|
|
225 |
* @access public
|
226 |
* @see https://aamplugin.com/reference/policy#backendmenu
|
227 |
-
* @version 6.
|
228 |
*/
|
229 |
public function initializeMenu($option, AAM_Core_Object_Menu $object)
|
230 |
{
|
231 |
-
$manager =
|
232 |
$found = $manager->getResources(AAM_Core_Policy_Resource::MENU);
|
233 |
$parsed = array();
|
234 |
|
@@ -247,13 +251,16 @@ class AAM_Service_AccessPolicy
|
|
247 |
*
|
248 |
* @return array
|
249 |
*
|
|
|
|
|
|
|
250 |
* @access public
|
251 |
* @see https://aamplugin.com/reference/policy#toolbar
|
252 |
-
* @version 6.
|
253 |
*/
|
254 |
public function initializeToolbar($option, AAM_Core_Object_Toolbar $object)
|
255 |
{
|
256 |
-
$manager =
|
257 |
$found = $manager->getResources(AAM_Core_Policy_Resource::TOOLBAR);
|
258 |
$parsed = array();
|
259 |
|
@@ -272,13 +279,16 @@ class AAM_Service_AccessPolicy
|
|
272 |
*
|
273 |
* @return array
|
274 |
*
|
|
|
|
|
|
|
275 |
* @access public
|
276 |
* @see https://aamplugin.com/reference/policy#metabox
|
277 |
-
* @version 6.
|
278 |
*/
|
279 |
public function initializeMetabox($option, AAM_Core_Object_Metabox $object)
|
280 |
{
|
281 |
-
$manager =
|
282 |
$found = $manager->getResources(array(
|
283 |
AAM_Core_Policy_Resource::METABOX, AAM_Core_Policy_Resource::WIDGET
|
284 |
));
|
@@ -301,13 +311,16 @@ class AAM_Service_AccessPolicy
|
|
301 |
*
|
302 |
* @return boolean
|
303 |
*
|
|
|
|
|
|
|
304 |
* @access public
|
305 |
* @link https://aamplugin.com/reference/policy#capability
|
306 |
-
* @version 6.
|
307 |
*/
|
308 |
public function isCapabilityAllowed($allowed, $cap, $action)
|
309 |
{
|
310 |
-
$manager =
|
311 |
$result = $manager->isAllowed("Capability:{$cap}:AAM:{$action}");
|
312 |
|
313 |
return ($result === null ? $allowed : $result);
|
@@ -320,14 +333,17 @@ class AAM_Service_AccessPolicy
|
|
320 |
*
|
321 |
* @return void
|
322 |
*
|
|
|
|
|
|
|
323 |
* @access public
|
324 |
* @link https://aamplugin.com/reference/policy#capability
|
325 |
* @link https://aamplugin.com/reference/policy#role
|
326 |
-
* @version 6.
|
327 |
*/
|
328 |
public function initializeUser(AAM_Core_Subject_User $subject)
|
329 |
{
|
330 |
-
$manager =
|
331 |
$wp_user = $subject->getPrincipal();
|
332 |
|
333 |
// Update user's list of roles if policy states so
|
@@ -391,14 +407,16 @@ class AAM_Service_AccessPolicy
|
|
391 |
*
|
392 |
* @return array
|
393 |
*
|
|
|
|
|
|
|
394 |
* @access public
|
395 |
* @see https://aamplugin.com/reference/policy#post
|
396 |
-
* @version 6.
|
397 |
*/
|
398 |
public function initializePost($option, AAM_Core_Object_Post $object)
|
399 |
{
|
400 |
-
$manager =
|
401 |
-
|
402 |
$found = $manager->getResources(sprintf(
|
403 |
'%s:%s:(%d|%s)',
|
404 |
AAM_Core_Policy_Resource::POST,
|
@@ -564,12 +582,15 @@ class AAM_Service_AccessPolicy
|
|
564 |
*
|
565 |
* @return void
|
566 |
*
|
|
|
|
|
|
|
567 |
* @access public
|
568 |
-
* @version 6.
|
569 |
*/
|
570 |
public function initializeVisibility(AAM_Core_Object_Visibility $visibility)
|
571 |
{
|
572 |
-
$manager =
|
573 |
$found = $manager->getResources(AAM_Core_Policy_Resource::POST);
|
574 |
|
575 |
foreach($found as $resource => $stm) {
|
@@ -610,13 +631,16 @@ class AAM_Service_AccessPolicy
|
|
610 |
*
|
611 |
* @return array
|
612 |
|