Advanced Access Manager - Version 4.6.1

Version Description

  • Fixed bug with user capabilities
  • Fixed bug with post access settings not being checked even when they are
  • Added ability to manage hidden post types
  • Added ability to manage number of analyzed posts with get_post_limit config
Download this release

Release Info

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

Code changes from version 4.6 to 4.6.1

Application/Backend/Feature/Post.php CHANGED
@@ -74,9 +74,10 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
74
  $s = AAM_Core_Request::post('search.value');
75
  $length = AAM_Core_Request::post('length');
76
  $start = AAM_Core_Request::post('start');
 
77
 
78
  foreach (get_post_types(array(), 'objects') as $type) {
79
- if ($type->public
80
  && (empty($s) || stripos($type->labels->name, $s) !== false)) {
81
  $filtered[] = $type;
82
  }
@@ -157,20 +158,22 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
157
  $list = array_merge(
158
  $list,
159
  get_posts(array(
160
- 'post_type' => $type, 'category' => 0,
161
  'numberposts' => -1, 'post_status' => 'any'
162
  ))
163
  );
164
 
165
  foreach($list as $row) {
166
- if (!empty($s)) {
167
- if (isset($row->term_id) && stripos($row->name, $s) !== false) {
168
- $filtered[] = $row;
169
- } elseif (isset($row->ID) && stripos($row->post_title, $s) !== false) {
170
  $filtered[] = $row;
171
  }
172
- } else {
173
- $filtered[] = $row;
 
 
 
 
174
  }
175
  }
176
 
@@ -224,17 +227,17 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
224
  * @access public
225
  */
226
  public function getAccess() {
227
- $type = trim(AAM_Core_Request::post('type'));
228
- $id = AAM_Core_Request::post('id');
229
-
230
  $object = AAM_Backend_View::getSubject()->getObject($type, $id);
231
 
232
  //prepare the response object
233
- if ($object instanceof AAM_Core_Object) {
234
- $access = $object->getOption();
 
 
235
  $metadata = array('overwritten' => $object->isOverwritten());
236
- } else {
237
- $access = $metadata = array();
238
  }
239
 
240
  return json_encode(array('access' => $access, 'meta' => $metadata));
74
  $s = AAM_Core_Request::post('search.value');
75
  $length = AAM_Core_Request::post('length');
76
  $start = AAM_Core_Request::post('start');
77
+ $all = AAM_Core_Config::get('manage-hidden-post-types', false);
78
 
79
  foreach (get_post_types(array(), 'objects') as $type) {
80
+ if (($all || $type->public)
81
  && (empty($s) || stripos($type->labels->name, $s) !== false)) {
82
  $filtered[] = $type;
83
  }
158
  $list = array_merge(
159
  $list,
160
  get_posts(array(
161
+ 'post_type' => $type, 'category' => 0, 's' => $s,
162
  'numberposts' => -1, 'post_status' => 'any'
163
  ))
164
  );
165
 
166
  foreach($list as $row) {
167
+ if (isset($row->term_id)) { //this is term
168
+ if (empty($s) || stripos($row->name, $s) !== false) {
 
 
169
  $filtered[] = $row;
170
  }
171
+ } elseif (isset($row->ID)) { //this is post
172
+ if (empty($s) || stripos($row->post_title, $s) !== false) {
173
+ if (!empty($row->post_title)) {
174
+ $filtered[] = $row;
175
+ }
176
+ }
177
  }
178
  }
179
 
227
  * @access public
228
  */
229
  public function getAccess() {
230
+ $type = trim(AAM_Core_Request::post('type'));
231
+ $id = AAM_Core_Request::post('id');
232
+ $access = $metadata = array();
233
  $object = AAM_Backend_View::getSubject()->getObject($type, $id);
234
 
235
  //prepare the response object
236
+ if (is_a($object, 'AAM_Core_Object')) {
237
+ foreach($object->getOption() as $key => $value) {
238
+ $access[$key] = ($value ? 1 : 0); //TODO - to support legacy
239
+ }
240
  $metadata = array('overwritten' => $object->isOverwritten());
 
 
241
  }
242
 
243
  return json_encode(array('access' => $access, 'meta' => $metadata));
Application/Backend/View/UtilityOptionList.php CHANGED
@@ -33,6 +33,11 @@ return array(
33
  'descr' => __('For performance reasons, keep this option uncheck if do not use LIST or LIST TO OTHERS access options on Posts & Pages tab. When it is checked, AAM will filter list of posts that are hidden for a user on both frontend and backend.', AAM_KEY),
34
  'value' => AAM_Core_Config::get('check-post-visibility', true),
35
  ),
 
 
 
 
 
36
  'render-access-metabox' => array(
37
  'title' => __('Render Access Manager Metabox', AAM_KEY),
38
  'descr' => __('Render Access Manager metabox on all post and category edit pages. Access Manager metabox is the quick way to manage access to any post or category without leaving an edit page.', AAM_KEY),
33
  'descr' => __('For performance reasons, keep this option uncheck if do not use LIST or LIST TO OTHERS access options on Posts & Pages tab. When it is checked, AAM will filter list of posts that are hidden for a user on both frontend and backend.', AAM_KEY),
34
  'value' => AAM_Core_Config::get('check-post-visibility', true),
35
  ),
36
+ 'manage-hidden-post-types' => array(
37
+ 'title' => __('Manage Hidden Post Types', AAM_KEY),
38
+ 'descr' => __('By default AAM allows you to manage access only to public post types on Posts & Pages tab. By enabling this feature, you also will be able to manage access to hidden post types like revisions, navigation menus or any other custom post types that are not registered as public.', AAM_KEY),
39
+ 'value' => AAM_Core_Config::get('manage-hidden-post-types', false),
40
+ ),
41
  'render-access-metabox' => array(
42
  'title' => __('Render Access Manager Metabox', AAM_KEY),
43
  'descr' => __('Render Access Manager metabox on all post and category edit pages. Access Manager metabox is the quick way to manage access to any post or category without leaving an edit page.', AAM_KEY),
Application/Core/API.php CHANGED
@@ -318,7 +318,7 @@ final class AAM_Core_API {
318
  } else { //first initial build
319
  $posts = get_posts(array(
320
  'post_type' => $type,
321
- 'numberposts' => 500,
322
  'post_status' => 'any'
323
  ));
324
 
@@ -348,7 +348,7 @@ final class AAM_Core_API {
348
 
349
  $hidden = false;
350
 
351
- if ($counter <= 500) { //avoid server crash
352
  $user = get_current_user_id();
353
  $key = "{$type}__not_in_{$area}";
354
  $cache = AAM_Core_Cache::get($key, array());
318
  } else { //first initial build
319
  $posts = get_posts(array(
320
  'post_type' => $type,
321
+ 'numberposts' => AAM_Core_Config::get('get_post_limit', 500),
322
  'post_status' => 'any'
323
  ));
324
 
348
 
349
  $hidden = false;
350
 
351
+ if ($counter <= AAM_Core_Config::get('get_post_limit', 500)) { //avoid server crash
352
  $user = get_current_user_id();
353
  $key = "{$type}__not_in_{$area}";
354
  $cache = AAM_Core_Cache::get($key, array());
Application/Core/Subject/User.php CHANGED
@@ -82,9 +82,14 @@ class AAM_Core_Subject_User extends AAM_Core_Subject {
82
 
83
  //reset the user capabilities
84
  $subject->allcaps = $allcaps;
85
- $subject->caps = $caps;
 
 
 
 
 
86
  }
87
-
88
  return $subject;
89
  }
90
 
82
 
83
  //reset the user capabilities
84
  $subject->allcaps = $allcaps;
85
+ $subject->caps = $caps;
86
+
87
+ if (wp_get_current_user()->ID == $subject->ID) {
88
+ wp_get_current_user()->allcaps = $allcaps;
89
+ wp_get_current_user()->caps = $caps;
90
+ }
91
  }
92
+
93
  return $subject;
94
  }
95
 
Application/Frontend/Manager.php CHANGED
@@ -479,7 +479,7 @@ class AAM_Frontend_Manager {
479
  public function getNavigationMenu($pages) {
480
  if (is_array($pages)) {
481
  foreach ($pages as $i => $page) {
482
- if ($page->type == 'post_type') {
483
  $post = get_post($page->object_id);
484
  if (AAM_Core_API::isHiddenPost($post, $post->post_type)) {
485
  unset($pages[$i]);
479
  public function getNavigationMenu($pages) {
480
  if (is_array($pages)) {
481
  foreach ($pages as $i => $page) {
482
+ if (in_array($page->type, array('post_type', 'custom'))) {
483
  $post = get_post($page->object_id);
484
  if (AAM_Core_API::isHiddenPost($post, $post->post_type)) {
485
  unset($pages[$i]);
aam.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  Plugin Name: Advanced Access Manager
5
  Description: Manage website access for any user, role or visitors
6
- Version: 4.6
7
  Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
  Author URI: https://www.vasyltech.com
9
 
3
  /**
4
  Plugin Name: Advanced Access Manager
5
  Description: Manage website access for any user, role or visitors
6
+ Version: 4.6.1
7
  Author: Vasyl Martyniuk <vasyl@vasyltech.com>
8
  Author URI: https://www.vasyltech.com
9
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: vasyltech
3
  Tags: access, role, user, capability, page access, post access, security, login redirect, brute force attack, double authentication, membership, backend lockdown, wp-admin, 404, activity tracking
4
  Requires at least: 3.8
5
  Tested up to: 4.7.3
6
- Stable tag: 4.6
7
 
8
  Manage access to your website for any user, role or visitors for both frontend and backend.
9
 
@@ -110,6 +110,12 @@ Check our [help page](https://aamplugin.com/help) to find out more about AAM.
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
113
  = 4.6 =
114
  * Fixed internal bug with custom post type LIST control
115
  * Fixed PHP errors in Access Manager metabox
3
  Tags: access, role, user, capability, page access, post access, security, login redirect, brute force attack, double authentication, membership, backend lockdown, wp-admin, 404, activity tracking
4
  Requires at least: 3.8
5
  Tested up to: 4.7.3
6
+ Stable tag: 4.6.1
7
 
8
  Manage access to your website for any user, role or visitors for both frontend and backend.
9
 
110
 
111
  == Changelog ==
112
 
113
+ = 4.6.1 =
114
+ * Fixed bug with user capabilities
115
+ * Fixed bug with post access settings not being checked even when they are
116
+ * Added ability to manage hidden post types
117
+ * Added ability to manage number of analyzed posts with get_post_limit config
118
+
119
  = 4.6 =
120
  * Fixed internal bug with custom post type LIST control
121
  * Fixed PHP errors in Access Manager metabox