Advanced Access Manager - Version 6.2.2

Version Description

  • Fixed Bug: Backend Dashboard index.php still could be restricted with Backend Menu service
  • Fixed Bug: Policy Generator - Fatal error with PHP lower than 7.0.0
  • Fixed Bug: Policy Validator - Improper dependency validation when if it is not installed
  • Fixed Bug: Default access settings not propagated to user that does not have any roles (multisite setup)
  • Fixed Bug: Reset settings where not synced across all subsites in multisite setup
  • Added New: Ability to define wildcard BackendMenu resource with Access Policy
  • Added New: Ability to define wildcard Metabox resource with Access Policy
  • Added New: Ability to define wildcard Widget resource with Access Policy
  • Added New: Ability to define wildcard Toolbar resource with Access Policy
Download this release

Release Info

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

Code changes from version 6.2.1 to 6.2.2

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.2.1
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.2.1');
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.2.2
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.2.2');
268
  define('AAM_BASEDIR', __DIR__);
269
 
270
  //load vendor
application/Backend/Feature/Main/Policy.php CHANGED
@@ -10,12 +10,14 @@
10
  /**
11
  * Access Policy UI manager
12
  *
 
 
13
  * @since 6.2.0 Added ability to generate Access Policy
14
  * @since 6.1.0 Fixed bug with "Attach to Default" button
15
  * @since 6.0.0 Initial implementation of the class
16
  *
17
  * @package AAM
18
- * @version 6.2.0
19
  */
20
  class AAM_Backend_Feature_Main_Policy
21
  extends AAM_Backend_Feature_Abstract implements AAM_Backend_Feature_ISubjectAware
@@ -255,11 +257,12 @@ extends AAM_Backend_Feature_Abstract implements AAM_Backend_Feature_ISubjectAwar
255
  *
256
  * @return string
257
  *
 
258
  * @since 6.2.0 Added "delete" action
259
  * @since 6.0.0 Initial implementation of the method
260
  *
261
  * @access protected
262
- * @version 6.2.0
263
  */
264
  protected function preparePolicyActionList($record)
265
  {
@@ -267,11 +270,13 @@ extends AAM_Backend_Feature_Abstract implements AAM_Backend_Feature_ISubjectAwar
267
 
268
  $policy = $subject->getObject(AAM_Core_Object_Policy::OBJECT_TYPE);
269
  $post = $subject->getObject(AAM_Core_Object_Post::OBJECT_TYPE, $record->ID);
 
 
270
 
271
  $actions = array(
272
- $policy->has($record->ID) ? "detach" : "attach",
273
- $post->isAllowedTo('edit') ? 'edit' : 'no-edit',
274
- $post->isAllowedTo('delete') ? 'delete' : 'no-delete'
275
  );
276
 
277
  return implode(',', $actions);
10
  /**
11
  * Access Policy UI manager
12
  *
13
+ * @since 6.2.2 Integration with multisite network where user is allowed to manage
14
+ * policies only on the main site if Multiste Sync Settings is enabled
15
  * @since 6.2.0 Added ability to generate Access Policy
16
  * @since 6.1.0 Fixed bug with "Attach to Default" button
17
  * @since 6.0.0 Initial implementation of the class
18
  *
19
  * @package AAM
20
+ * @version 6.2.2
21
  */
22
  class AAM_Backend_Feature_Main_Policy
23
  extends AAM_Backend_Feature_Abstract implements AAM_Backend_Feature_ISubjectAware
257
  *
258
  * @return string
259
  *
260
+ * @since 6.2.2 Changed the way list of actions is determined for a policy
261
  * @since 6.2.0 Added "delete" action
262
  * @since 6.0.0 Initial implementation of the method
263
  *
264
  * @access protected
265
+ * @version 6.2.2
266
  */
267
  protected function preparePolicyActionList($record)
268
  {
270
 
271
  $policy = $subject->getObject(AAM_Core_Object_Policy::OBJECT_TYPE);
272
  $post = $subject->getObject(AAM_Core_Object_Post::OBJECT_TYPE, $record->ID);
273
+ $managed = apply_filters('aam_is_managed_policy_filter', true, $record);
274
+ $prefix = ($managed ? '' : 'no-');
275
 
276
  $actions = array(
277
+ $policy->has($record->ID) ? "{$prefix}detach" : "{$prefix}attach",
278
+ $managed && $post->isAllowedTo('edit') ? 'edit' : 'no-edit',
279
+ $managed && $post->isAllowedTo('delete') ? 'delete' : 'no-delete'
280
  );
281
 
282
  return implode(',', $actions);
application/Backend/Manager.php CHANGED
@@ -10,12 +10,14 @@
10
  /**
11
  * Backend manager
12
  *
 
 
13
  * @since 6.2.0 Added new property to the JS localization `blog_id`
14
  * @since 6.1.0 Fixed bug with HTML compression
15
  * @since 6.0.0 Initial implementation of the class
16
  *
17
  * @package AAM
18
- * @version 6.2.0
19
  */
20
  class AAM_Backend_Manager
21
  {
@@ -125,11 +127,13 @@ class AAM_Backend_Manager
125
  *
126
  * @return void
127
  *
 
 
128
  * @since 6.2.0 Added `blog_id` to the localized array of properties
129
  * @since 6.0.0 Initial implementation of the method
130
  *
131
  * @access public
132
- * @version 6.2.0
133
  */
134
  public function printFooterJavascript()
135
  {
@@ -157,10 +161,10 @@ class AAM_Backend_Manager
157
  ),
158
  'translation' => AAM_Backend_View_Localization::get(),
159
  'caps' => array(
160
- 'create_roles' => current_user_can('aam_create_roles'),
161
- 'create_users' => current_user_can('create_users')
162
- ),
163
- 'blog_id' => get_current_blog_id()
164
  ));
165
 
166
  echo '<script type="text/javascript">';
10
  /**
11
  * Backend manager
12
  *
13
+ * @since 6.2.2 Added `manage_policies` and removed `blog_id` for the localized
14
+ * array of properties
15
  * @since 6.2.0 Added new property to the JS localization `blog_id`
16
  * @since 6.1.0 Fixed bug with HTML compression
17
  * @since 6.0.0 Initial implementation of the class
18
  *
19
  * @package AAM
20
+ * @version 6.2.2
21
  */
22
  class AAM_Backend_Manager
23
  {
127
  *
128
  * @return void
129
  *
130
+ * @since 6.2.2 Added `manage_policies` and removed `blog_id` for the localized
131
+ * array of properties
132
  * @since 6.2.0 Added `blog_id` to the localized array of properties
133
  * @since 6.0.0 Initial implementation of the method
134
  *
135
  * @access public
136
+ * @version 6.2.2
137
  */
138
  public function printFooterJavascript()
139
  {
161
  ),
162
  'translation' => AAM_Backend_View_Localization::get(),
163
  'caps' => array(
164
+ 'create_roles' => current_user_can('aam_create_roles'),
165
+ 'create_users' => current_user_can('create_users'),
166
+ 'manage_policies' => is_main_site() || !AAM_Core_Config::get(AAM_Service_Multisite::FEATURE_FLAG, true)
167
+ )
168
  ));
169
 
170
  echo '<script type="text/javascript">';
application/Backend/tmpl/metabox/policy-metabox.php CHANGED
@@ -1,10 +1,11 @@
1
  <?php
2
  /**
 
3
  * @since 6.2.0 Escaping backslashes to avoid issue with JSON validation
4
  * @since 6.1.1 Removing the backslashes before displaying the policy
5
  * @since 6.0.0 Initial implementation of the template
6
  *
7
- * @version 6.2.0
8
  */
9
  ?>
10
  <?php if (defined('AAM_KEY')) { ?>
@@ -23,7 +24,16 @@
23
  ?>
24
 
25
  <div class="aam-alert-danger<?php echo (empty($errors) ? ' hidden' : ''); ?>" id="policy-parsing-error">
26
- <?php echo implode('<br/>', $errors); ?>
 
 
 
 
 
 
 
 
 
27
  </div>
28
 
29
  <textarea id="aam-policy-editor" name="aam-policy" class="policy-editor" rows="10"><?php echo stripslashes($params->post->post_content); ?></textarea>
1
  <?php
2
  /**
3
+ * @since 6.2.2 Slightly changed the way errors are displayed
4
  * @since 6.2.0 Escaping backslashes to avoid issue with JSON validation
5
  * @since 6.1.1 Removing the backslashes before displaying the policy
6
  * @since 6.0.0 Initial implementation of the template
7
  *
8
+ * @version 6.2.2
9
  */
10
  ?>
11
  <?php if (defined('AAM_KEY')) { ?>
24
  ?>
25
 
26
  <div class="aam-alert-danger<?php echo (empty($errors) ? ' hidden' : ''); ?>" id="policy-parsing-error">
27
+ <?php
28
+ $list = array();
29
+ foreach($errors as $error) {
30
+ $list[] = '<li>- ' . $error . ';</li>';
31
+ }
32
+
33
+ if (!empty($list)) {
34
+ echo '<ul>' . implode('', $list) . '</ul>';
35
+ }
36
+ ?>
37
  </div>
38
 
39
  <textarea id="aam-policy-editor" name="aam-policy" class="policy-editor" rows="10"><?php echo stripslashes($params->post->post_content); ?></textarea>
application/Core/API.php CHANGED
@@ -5,19 +5,18 @@
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
14
  *
 
15
  * @since 6.0.5 Fixed bug with getOption method where incorrect type could be
16
  * returned
17
  * @since 6.0.0 Initial implementation of the class
18
  *
19
  * @package AAM
20
- * @version 6.0.5
21
  */
22
  final class AAM_Core_API
23
  {
@@ -265,18 +264,27 @@ final class AAM_Core_API
265
  *
266
  * @return void
267
  *
 
 
 
268
  * @access public
269
- * @version 6.0.0
270
  */
271
  public static function clearSettings()
272
  {
273
- self::deleteOption(AAM_Core_AccessSettings::DB_OPTION);
274
- self::deleteOption(AAM_Core_Config::DB_OPTION);
275
- self::deleteOption(AAM_Core_ConfigPress::DB_OPTION);
276
- self::deleteOption(AAM_Core_Migration::DB_FAILURE_OPTION);
 
 
 
 
 
 
277
 
278
  // Trigger the action to inform other services to clean-up the options
279
- do_action('aam_clear_settings_action');
280
  }
281
 
282
  /**
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
12
  *
13
+ * @since 6.2.2 Minor refactoring to the clearSettings method
14
  * @since 6.0.5 Fixed bug with getOption method where incorrect type could be
15
  * returned
16
  * @since 6.0.0 Initial implementation of the class
17
  *
18
  * @package AAM
19
+ * @version 6.2.2
20
  */
21
  final class AAM_Core_API
22
  {
264
  *
265
  * @return void
266
  *
267
+ * @since 6.2.2 Refactored the way we iterate over the deleting list of options
268
+ * @since 6.0.0 Initial implementation of the method
269
+ *
270
  * @access public
271
+ * @version 6.2.2
272
  */
273
  public static function clearSettings()
274
  {
275
+ $options = array(
276
+ AAM_Core_AccessSettings::DB_OPTION,
277
+ AAM_Core_Config::DB_OPTION,
278
+ AAM_Core_ConfigPress::DB_OPTION,
279
+ AAM_Core_Migration::DB_OPTION
280
+ );
281
+
282
+ foreach($options as $option) {
283
+ self::deleteOption($option);
284
+ }
285
 
286
  // Trigger the action to inform other services to clean-up the options
287
+ do_action('aam_clear_settings_action', $options);
288
  }
289
 
290
  /**
application/Core/Object/Menu.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
  * Menu object
14
  *
 
 
 
 
15
  * @package AAM
16
- * @version 6.0.0
17
  */
18
  class AAM_Core_Object_Menu extends AAM_Core_Object
19
  {
@@ -49,32 +51,41 @@ class AAM_Core_Object_Menu extends AAM_Core_Object
49
  *
50
  * @return boolean
51
  *
 
 
 
52
  * @access public
53
- * @version 6.0.0
54
  */
55
  public function isRestricted($menu)
56
  {
57
  // Decode URL in case of any special characters like &amp;
58
- $decoded = htmlspecialchars_decode($menu);
59
 
60
- $options = $this->getOption();
61
- $parent = $this->getParentMenu($decoded);
 
62
 
63
- // Step #1. Check if menu is directly restricted
64
- $direct = !empty($options[$decoded]);
65
 
66
- // Step #2. Check if whole branch is restricted
67
- $branch = !empty($options['menu-' . $decoded]);
68
 
69
- // Step #3. Check if dynamic submenu is restricted because of whole branch
70
- $indirect = ($parent && (!empty($options['menu-' . $parent])));
71
 
72
- return apply_filters(
73
- 'aam_admin_menu_is_restricted_filter',
74
- $direct || $branch || $indirect,
75
- $decoded,
76
- $this
77
- );
 
 
 
 
 
78
  }
79
 
80
  /**
@@ -84,11 +95,14 @@ class AAM_Core_Object_Menu extends AAM_Core_Object
84
  *
85
  * @return string|null
86
  *
87
- * @access protected
 
 
 
88
  * @global array $submenu
89
- * @version 6.0.0
90
  */
91
- protected function getParentMenu($search)
92
  {
93
  global $submenu;
94
 
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
  * Menu object
12
  *
13
+ * @since 6.2.2 Added new filter `aam_backend_menu_is_restricted_filter` so it can
14
+ * be integrated with access policy wildcard
15
+ * @since 6.0.0 Initial implementation of the method
16
+ *
17
  * @package AAM
18
+ * @version 6.2.2
19
  */
20
  class AAM_Core_Object_Menu extends AAM_Core_Object
21
  {
51
  *
52
  * @return boolean
53
  *
54
+ * @since 6.2.2 Added new filter `aam_backend_menu_is_restricted_filter`
55
+ * @since 6.0.0 Initial implementation of the method
56
+ *
57
  * @access public
58
+ * @version 6.2.2
59
  */
60
  public function isRestricted($menu)
61
  {
62
  // Decode URL in case of any special characters like &amp;
63
+ $s = htmlspecialchars_decode($menu);
64
 
65
+ if (!in_array($s, array('index.php', 'menu-index.php'))) {
66
+ $options = $this->getOption();
67
+ $parent = $this->getParentMenu($s);
68
 
69
+ // Step #1. Check if menu is directly restricted
70
+ $direct = !empty($options[$s]);
71
 
72
+ // Step #2. Check if whole branch is restricted
73
+ $branch = !empty($options['menu-' . $s]);
74
 
75
+ // Step #3. Check if dynamic submenu is restricted because of whole branch
76
+ $indirect = ($parent && (!empty($options['menu-' . $parent])));
77
 
78
+ $restricted = apply_filters(
79
+ 'aam_backend_menu_is_restricted_filter',
80
+ $direct || $branch || $indirect,
81
+ $s,
82
+ $this
83
+ );
84
+ } else {
85
+ $restricted = false;
86
+ }
87
+
88
+ return $restricted;
89
  }
90
 
91
  /**
95
  *
96
  * @return string|null
97
  *
98
+ * @since 6.2.2 Made the method public
99
+ * @since 6.0.0 Initial implementation of the method
100
+ *
101
+ * @access public
102
  * @global array $submenu
103
+ * @version 6.2.2
104
  */
105
+ public function getParentMenu($search)
106
  {
107
  global $submenu;
108
 
application/Core/Object/Metabox.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
  * Metabox object
14
  *
 
 
 
15
  * @package AAM
16
- * @version 6.0.0
17
  */
18
  class AAM_Core_Object_Metabox extends AAM_Core_Object
19
  {
@@ -50,14 +51,24 @@ class AAM_Core_Object_Metabox extends AAM_Core_Object
50
  *
51
  * @return boolean
52
  *
 
 
 
53
  * @access public
54
- * @version 6.0.0
55
  */
56
  public function isHidden($screen, $metaboxId)
57
  {
58
  $option = $this->getOption();
 
59
 
60
- return !empty($option[strtolower("{$screen}|{$metaboxId}")]);
 
 
 
 
 
 
61
  }
62
 
63
  }
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
  * Metabox object
12
  *
13
+ * @since 6.2.2 Added `aam_metabox_is_hidden_filter` filter
14
+ * @since 6.0.0 Initial implementation of the method
15
+ *
16
  * @package AAM
17
+ * @version 6.2.2
18
  */
19
  class AAM_Core_Object_Metabox extends AAM_Core_Object
20
  {
51
  *
52
  * @return boolean
53
  *
54
+ * @since 6.2.2 Added `aam_metabox_is_hidden_filter` filter
55
+ * @since 6.0.0 Initial implementation of the method
56
+ *
57
  * @access public
58
+ * @version 6.2.2
59
  */
60
  public function isHidden($screen, $metaboxId)
61
  {
62
  $option = $this->getOption();
63
+ $id = strtolower("{$screen}|{$metaboxId}");
64
 
65
+ return apply_filters(
66
+ 'aam_metabox_is_hidden_filter',
67
+ !empty($option[$id]),
68
+ $screen,
69
+ $metaboxId,
70
+ $this
71
+ );
72
  }
73
 
74
  }
application/Core/Object/Toolbar.php CHANGED
@@ -5,18 +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
  * 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
  {
@@ -58,8 +57,11 @@ class AAM_Core_Object_Toolbar extends AAM_Core_Object
58
  *
59
  * @return boolean
60
  *
 
 
 
61
  * @access public
62
- * @version 6.0.0
63
  */
64
  public function isHidden($item, $both = false)
65
  {
@@ -71,7 +73,9 @@ class AAM_Core_Object_Toolbar extends AAM_Core_Object
71
  // Step #2. Check if whole branch is restricted
72
  $branch = ($both && !empty($options['toolbar-' . $item]));
73
 
74
- return $direct || $branch;
 
 
75
  }
76
 
77
  }
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
  * Admin toolbar object
12
  *
13
+ * @since 6.2.2 Added support for the new `aam_toolbar_is_hidden_filter` filter
14
  * @since 6.1.0 Fixed bug with incorrectly halted inheritance mechanism
15
  * @since 6.0.0 Initial implementation of the class
16
  *
17
  * @package AAM
18
+ * @version 6.2.2
19
  */
20
  class AAM_Core_Object_Toolbar extends AAM_Core_Object
21
  {
57
  *
58
  * @return boolean
59
  *
60
+ * @since 6.2.2 Added `aam_toolbar_is_hidden_filter` filter
61
+ * @since 6.0.0 Initial implementation of the method
62
+ *
63
  * @access public
64
+ * @version 6.2.2
65
  */
66
  public function isHidden($item, $both = false)
67
  {
73
  // Step #2. Check if whole branch is restricted
74
  $branch = ($both && !empty($options['toolbar-' . $item]));
75
 
76
+ return apply_filters(
77
+ 'aam_toolbar_is_hidden_filter', $direct || $branch, $item, $this
78
+ );
79
  }
80
 
81
  }
application/Core/Policy/Generator.php CHANGED
@@ -10,8 +10,11 @@
10
  /**
11
  * AAM core policy generator
12
  *
 
 
 
13
  * @package AAM
14
- * @version 6.2.0
15
  */
16
  class AAM_Core_Policy_Generator
17
  {
@@ -301,8 +304,11 @@ class AAM_Core_Policy_Generator
301
  *
302
  * @return array
303
  *
 
 
 
304
  * @access private
305
- * @version 6.2.0
306
  */
307
  private function _convertToPostStatements($resource, $options)
308
  {
@@ -440,7 +446,11 @@ class AAM_Core_Policy_Generator
440
  }
441
 
442
  if ($action !== null) {
443
- $$effect[] = $resource . ':' . $action;
 
 
 
 
444
  }
445
  }
446
 
10
  /**
11
  * AAM core policy generator
12
  *
13
+ * @since 6.2.2 Fixed bug with incompatibility with PHP lower than 7.0.0
14
+ * @since 6.2.0 Initial implementation of the class
15
+ *
16
  * @package AAM
17
+ * @version 6.2.2
18
  */
19
  class AAM_Core_Policy_Generator
20
  {
304
  *
305
  * @return array
306
  *
307
+ * @since 6.2.2 Fixed bug that caused fatal error for PHP lower than 7.0.0
308
+ * @since 6.2.0 Initial implementation of the method
309
+ *
310
  * @access private
311
+ * @version 6.2.2
312
  */
313
  private function _convertToPostStatements($resource, $options)
314
  {
446
  }
447
 
448
  if ($action !== null) {
449
+ if ($effect === 'allowed') {
450
+ $allowed[] = $resource . ':' . $action;
451
+ } else {
452
+ $denied[] = $resource . ':' . $action;
453
+ }
454
  }
455
  }
456
 
application/Core/Policy/Validator.php CHANGED
@@ -12,12 +12,13 @@ use Composer\Semver\Semver;
12
  /**
13
  * AAM access policy validator
14
  *
 
15
  * @since 6.2.0 Allowing to define token in the dependencies array as well as
16
  * enhanced with additional attributes
17
  * @since 6.0.0 Initial implementation of the class
18
  *
19
  * @package AAM
20
- * @version 6.2.0
21
  */
22
  class AAM_Core_Policy_Validator
23
  {
@@ -152,11 +153,12 @@ class AAM_Core_Policy_Validator
152
  *
153
  * @return void
154
  *
 
155
  * @since 6.2.0 Enhanced dependency with more attributes
156
  * @since 6.0.0 Initial implementation of the method
157
  *
158
  * @access protected
159
- * @version 6.2.0
160
  */
161
  protected function isValidDependency()
162
  {
@@ -164,7 +166,8 @@ class AAM_Core_Policy_Validator
164
  foreach ($this->json['Dependency'] as $slug => $info) {
165
  try {
166
  $v = (is_array($info) ? $info['Version'] : $info);
167
- $valid = Semver::satisfies($this->getAppVersion($slug), $v);
 
168
 
169
  if ($valid === false) {
170
  throw new Exception('', self::INVALID_DEPENDENCY_VERSION);
@@ -189,7 +192,7 @@ class AAM_Core_Policy_Validator
189
  }
190
 
191
  if ($e->getCode() === self::INVALID_DEPENDENCY_VERSION) {
192
- $message = __('The {$app} does not satisfy minimum required version', AAM_KEY);
193
  } elseif ($e->getCode() === self::MISSING_DEPENDENCY) {
194
  $message = __('The {$app} is required', AAM_KEY);
195
  } else {
12
  /**
13
  * AAM access policy validator
14
  *
15
+ * @since 6.2.2 Bug fixing
16
  * @since 6.2.0 Allowing to define token in the dependencies array as well as
17
  * enhanced with additional attributes
18
  * @since 6.0.0 Initial implementation of the class
19
  *
20
  * @package AAM
21
+ * @version 6.2.2
22
  */
23
  class AAM_Core_Policy_Validator
24
  {
153
  *
154
  * @return void
155
  *
156
+ * @since 6.2.2 Fixed bug with validation when plugin is not installed
157
  * @since 6.2.0 Enhanced dependency with more attributes
158
  * @since 6.0.0 Initial implementation of the method
159
  *
160
  * @access protected
161
+ * @version 6.2.2
162
  */
163
  protected function isValidDependency()
164
  {
166
  foreach ($this->json['Dependency'] as $slug => $info) {
167
  try {
168
  $v = (is_array($info) ? $info['Version'] : $info);
169
+ $app_v = $this->getAppVersion($slug);
170
+ $valid = !empty($app_v) && Semver::satisfies($app_v, $v);
171
 
172
  if ($valid === false) {
173
  throw new Exception('', self::INVALID_DEPENDENCY_VERSION);
192
  }
193
 
194
  if ($e->getCode() === self::INVALID_DEPENDENCY_VERSION) {
195
+ $message = __('The {$app} is not active or does not satisfy minimum required version', AAM_KEY);
196
  } elseif ($e->getCode() === self::MISSING_DEPENDENCY) {
197
  $message = __('The {$app} is required', AAM_KEY);
198
  } else {
application/Core/Subject/User.php CHANGED
@@ -10,11 +10,12 @@
10
  /**
11
  * User subject
12
  *
 
13
  * @since 6.0.2 Enhanced stability of the code
14
  * @since 6.0.0 Initial implementation of the class
15
  *
16
  * @package AAM
17
- * @version 6.0.2
18
  */
19
  class AAM_Core_Subject_User extends AAM_Core_Subject
20
  {
@@ -165,7 +166,12 @@ class AAM_Core_Subject_User extends AAM_Core_Subject
165
 
166
  /**
167
  * @inheritDoc
168
- * @version 6.0.0
 
 
 
 
 
169
  */
170
  public function getParent()
171
  {
@@ -186,7 +192,7 @@ class AAM_Core_Subject_User extends AAM_Core_Subject
186
  $this->_parent->setSiblings($siblings);
187
  }
188
  } else {
189
- $this->_parent = false;
190
  }
191
  }
192
 
10
  /**
11
  * User subject
12
  *
13
+ * @since 6.2.2 Fixed bug with settings inheritance from the Default subject
14
  * @since 6.0.2 Enhanced stability of the code
15
  * @since 6.0.0 Initial implementation of the class
16
  *
17
  * @package AAM
18
+ * @version 6.2.2
19
  */
20
  class AAM_Core_Subject_User extends AAM_Core_Subject
21
  {
166
 
167
  /**
168
  * @inheritDoc
169
+ *
170
+ * @since 6.2.2 Fixed bug where user did not inherit settings from default if
171
+ * user has not roles
172
+ * @since 6.0.0 Initial implementation of the method
173
+ *
174
+ * @version 6.2.2
175
  */
176
  public function getParent()
177
  {
192
  $this->_parent->setSiblings($siblings);
193
  }
194
  } else {
195
+ $this->_parent = AAM::api()->getDefault();
196
  }
197
  }
198
 
application/Service/Multisite.php CHANGED
@@ -10,8 +10,11 @@
10
  /**
11
  * Multisite service
12
  *
 
 
 
13
  * @package AAM
14
- * @version 6.2.0
15
  */
16
  class AAM_Service_Multisite
17
  {
@@ -73,8 +76,11 @@ class AAM_Service_Multisite
73
  *
74
  * @return void
75
  *
 
 
 
76
  * @access protected
77
- * @version 6.2.0
78
  */
79
  protected function initializeHooks()
80
  {
@@ -99,6 +105,11 @@ class AAM_Service_Multisite
99
  $this->syncOption(AAM_Core_AccessSettings::DB_OPTION, $settings);
100
  });
101
 
 
 
 
 
 
102
  add_filter('wp_insert_post_data', function($data) {
103
  if (
104
  isset($data['post_type'])
@@ -124,6 +135,10 @@ class AAM_Service_Multisite
124
  wp_die('Access Denied', 'aam_access_denied');
125
  }
126
  }, 999);
 
 
 
 
127
  }
128
 
129
  /**
@@ -134,24 +149,18 @@ class AAM_Service_Multisite
134
  *
135
  * @return void
136
  *
 
 
 
137
  * @access protected
138
  * @global WPDB $wpdb
139
- * @version 6.2.0
140
  */
141
  protected function syncOption($option, $value)
142
  {
143
  global $wpdb;
144
 
145
- $sites = get_sites(array(
146
- 'number' => PHP_INT_MAX,
147
- 'offset' => 0,
148
- 'orderby' => 'id',
149
- 'site__not_in' => array_merge(
150
- $this->getExcludedBlogs(), array(get_current_blog_id())
151
- )
152
- ));
153
-
154
- foreach($sites as $site) {
155
  AAM_Core_API::updateOption(
156
  str_replace('%s', $wpdb->get_blog_prefix($site->blog_id), $option),
157
  $value,
@@ -160,6 +169,45 @@ class AAM_Service_Multisite
160
  }
161
  }
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  /**
164
  * Get the list of excluded blogs from sync process
165
  *
10
  /**
11
  * Multisite service
12
  *
13
+ * @since 6.2.2 Fixed the bug where reset settings was not synced across all sites
14
+ * @since 6.2.0 Initial implementation of the class
15
+ *
16
  * @package AAM
17
+ * @version 6.2.2
18
  */
19
  class AAM_Service_Multisite
20
  {
76
  *
77
  * @return void
78
  *
79
+ * @since 6.2.2 Hooks to the setting clearing and policy table list
80
+ * @since 6.2.0 Initial implementation of the method
81
+ *
82
  * @access protected
83
+ * @version 6.2.2
84
  */
85
  protected function initializeHooks()
86
  {
105
  $this->syncOption(AAM_Core_AccessSettings::DB_OPTION, $settings);
106
  });
107
 
108
+ // Sync settings resetting
109
+ add_action('aam_clear_settings_action', function($options) {
110
+ $this->resetOptions($options);
111
+ });
112
+
113
  add_filter('wp_insert_post_data', function($data) {
114
  if (
115
  isset($data['post_type'])
135
  wp_die('Access Denied', 'aam_access_denied');
136
  }
137
  }, 999);
138
+
139
+ add_filter('aam_is_managed_policy_filter', function() {
140
+ return is_main_site();
141
+ });
142
  }
143
 
144
  /**
149
  *
150
  * @return void
151
  *
152
+ * @since 6.2.2 Refactored how the list of sites is fetched
153
+ * @since 6.2.0 Initial implementation of the method
154
+ *
155
  * @access protected
156
  * @global WPDB $wpdb
157
+ * @version 6.2.2
158
  */
159
  protected function syncOption($option, $value)
160
  {
161
  global $wpdb;
162
 
163
+ foreach($this->getSitList() as $site) {
 
 
 
 
 
 
 
 
 
164
  AAM_Core_API::updateOption(
165
  str_replace('%s', $wpdb->get_blog_prefix($site->blog_id), $option),
166
  $value,
169
  }
170
  }
171
 
172
+ /**
173
+ * Reset settings across all sites
174
+ *
175
+ * @param array $options
176
+ *
177
+ * @return void
178
+ *
179
+ * @access protected
180
+ * @version 6.2.2
181
+ */
182
+ protected function resetOptions($options)
183
+ {
184
+ foreach($this->getSitList() as $site) {
185
+ foreach($options as $option) {
186
+ AAM_Core_API::deleteOption($option, $site->blog_id);
187
+ }
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Get list of sites
193
+ *
194
+ * @return array
195
+ *
196
+ * @access protected
197
+ * @version 6.2.2
198
+ */
199
+ protected function getSitList()
200
+ {
201
+ return get_sites(array(
202
+ 'number' => PHP_INT_MAX,
203
+ 'offset' => 0,
204
+ 'orderby' => 'id',
205
+ 'site__not_in' => array_merge(
206
+ $this->getExcludedBlogs(), array(get_current_blog_id())
207
+ )
208
+ ));
209
+ }
210
+
211
  /**
212
  * Get the list of excluded blogs from sync process
213
  *
media/js/aam.js CHANGED
@@ -1354,22 +1354,24 @@
1354
  { visible: false, targets: [0, 3, 4] }
1355
  ],
1356
  initComplete: function () {
1357
- var create = $('<a/>', {
1358
- 'href': '#',
1359
- 'class': 'btn btn-sm btn-primary'
1360
- }).html('<i class="icon-plus"></i> ' + getAAM().__('Create'))
1361
- .bind('click', function () {
1362
- window.open(getLocal().url.addPolicy, '_blank');
1363
- });
 
1364
 
1365
- var install = $('<a/>', {
1366
- 'href': '#modal-install-policy',
1367
- 'class': 'btn btn-sm btn-success aam-outer-left-xxs',
1368
- 'data-toggle': 'modal'
1369
- }).html('<i class="icon-download-cloud"></i> ' + getAAM().__('Install'));
1370
 
1371
- $('.dataTables_filter', '#policy-list_wrapper').append(install);
1372
- $('.dataTables_filter', '#policy-list_wrapper').append(create);
 
1373
  },
1374
  createdRow: function (row, data) {
1375
  var actions = data[2].split(',');
1354
  { visible: false, targets: [0, 3, 4] }
1355
  ],
1356
  initComplete: function () {
1357
+ if (getLocal().caps.manage_policies) {
1358
+ var create = $('<a/>', {
1359
+ 'href': '#',
1360
+ 'class': 'btn btn-sm btn-primary'
1361
+ }).html('<i class="icon-plus"></i> ' + getAAM().__('Create'))
1362
+ .bind('click', function () {
1363
+ window.open(getLocal().url.addPolicy, '_blank');
1364
+ });
1365
 
1366
+ var install = $('<a/>', {
1367
+ 'href': '#modal-install-policy',
1368
+ 'class': 'btn btn-sm btn-success aam-outer-left-xxs',
1369
+ 'data-toggle': 'modal'
1370
+ }).html('<i class="icon-download-cloud"></i> ' + getAAM().__('Install'));
1371
 
1372
+ $('.dataTables_filter', '#policy-list_wrapper').append(install);
1373
+ $('.dataTables_filter', '#policy-list_wrapper').append(create);
1374
+ }
1375
  },
1376
  createdRow: function (row, data) {
1377
  var actions = data[2].split(',');
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.2.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,6 +91,17 @@ We take security and privacy very seriously, that is why there are several non-n
91
 
92
  == Changelog ==
93
 
 
 
 
 
 
 
 
 
 
 
 
94
  = 6.2.1 =
95
  * Fixed Bug: Very minor UI issue with Access Policy Delete pop-up
96
  * Added New: Enhanced Access Policy with new [POLICY_META](https://aamplugin.com/reference/policy#policy_meta) token
4
  Requires at least: 4.7.0
5
  Requires PHP: 5.6.0
6
  Tested up to: 5.3.2
7
+ Stable tag: 6.2.2
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.2.2 =
95
+ * Fixed Bug: Backend Dashboard index.php still could be restricted with Backend Menu service
96
+ * Fixed Bug: Policy Generator - Fatal error with PHP lower than 7.0.0
97
+ * Fixed Bug: Policy Validator - Improper dependency validation when if it is not installed
98
+ * Fixed Bug: Default access settings not propagated to user that does not have any roles (multisite setup)
99
+ * Fixed Bug: Reset settings where not synced across all subsites in multisite setup
100
+ * Added New: Ability to define wildcard [BackendMenu](https://aamplugin.com/reference/policy#backendmenu) resource with Access Policy
101
+ * Added New: Ability to define wildcard [Metabox](https://aamplugin.com/reference/policy#metabox) resource with Access Policy
102
+ * Added New: Ability to define wildcard [Widget](https://aamplugin.com/reference/policy#widget) resource with Access Policy
103
+ * Added New: Ability to define wildcard [Toolbar](https://aamplugin.com/reference/policy#toolbar) resource with Access Policy
104
+
105
  = 6.2.1 =
106
  * Fixed Bug: Very minor UI issue with Access Policy Delete pop-up
107
  * Added New: Enhanced Access Policy with new [POLICY_META](https://aamplugin.com/reference/policy#policy_meta) token