Version Description
- Fixed bug with frontend page redirect
- Significantly improved AAM speed and caching
- Added 404 redirect to the Default Settings
Download this release
Release Info
Developer | vasyl_m |
Plugin | Advanced Access Manager |
Version | 4.4 |
Comparing to | |
See all releases |
Code changes from version 4.3.1 to 4.4
- Application/Backend/Feature/404Redirect.php +72 -0
- Application/Backend/Feature/Utility.php +10 -0
- Application/Backend/Filter.php +43 -9
- Application/Backend/Manager.php +22 -10
- Application/Backend/View.php +2 -1
- Application/Backend/View/UtilityOptionList.php +0 -10
- Application/Backend/phtml/404redirect.phtml +59 -0
- Application/Backend/phtml/index.phtml +1 -1
- Application/Backend/phtml/object/post.phtml +1 -1
- Application/Backend/phtml/utility.phtml +12 -1
- Application/Core/API.php +2 -2
- Application/Core/Cache.php +15 -9
- Application/Core/Subject/User.php +18 -10
- Application/Frontend/Manager.php +25 -8
- aam.php +1 -1
- media/js/aam-ui.js +87 -0
- readme.txt +10 -2
Application/Backend/Feature/404Redirect.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* ======================================================================
|
5 |
+
* LICENSE: This file is subject to the terms and conditions defined in *
|
6 |
+
* file 'license.txt', which is part of this source code package. *
|
7 |
+
* ======================================================================
|
8 |
+
*/
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Backend 404 redirect manager
|
12 |
+
*
|
13 |
+
* @package AAM
|
14 |
+
* @author Vasyl Martyniuk <vasyl@vasyltech.com>
|
15 |
+
*/
|
16 |
+
class AAM_Backend_Feature_404Redirect extends AAM_Backend_Feature_Abstract {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @inheritdoc
|
20 |
+
*/
|
21 |
+
public static function getAccessOption() {
|
22 |
+
return 'feature.404redirect.capability';
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @inheritdoc
|
27 |
+
*/
|
28 |
+
public static function getTemplate() {
|
29 |
+
return '404redirect.phtml';
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Save AAM utility options
|
34 |
+
*
|
35 |
+
* @return string
|
36 |
+
*
|
37 |
+
* @access public
|
38 |
+
*/
|
39 |
+
public function save() {
|
40 |
+
$param = AAM_Core_Request::post('param');
|
41 |
+
$value = stripslashes(AAM_Core_Request::post('value'));
|
42 |
+
|
43 |
+
AAM_Core_Config::set($param, $value);
|
44 |
+
|
45 |
+
return json_encode(array('status' => 'success'));
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Register 404 redirect feature
|
50 |
+
*
|
51 |
+
* @return void
|
52 |
+
*
|
53 |
+
* @access public
|
54 |
+
*/
|
55 |
+
public static function register() {
|
56 |
+
if (is_main_site()) {
|
57 |
+
$cap = AAM_Core_Config::get(self::getAccessOption(), 'administrator');
|
58 |
+
|
59 |
+
AAM_Backend_Feature::registerFeature((object) array(
|
60 |
+
'uid' => '404redirect',
|
61 |
+
'position' => 50,
|
62 |
+
'title' => __('404 Redirect', AAM_KEY),
|
63 |
+
'capability' => $cap,
|
64 |
+
'subjects' => array(
|
65 |
+
'AAM_Core_Subject_Default'
|
66 |
+
),
|
67 |
+
'view' => __CLASS__
|
68 |
+
));
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
Application/Backend/Feature/Utility.php
CHANGED
@@ -86,6 +86,16 @@ class AAM_Backend_Feature_Utility extends AAM_Backend_Feature_Abstract {
|
|
86 |
return json_encode(array('status' => 'success'));
|
87 |
}
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
/**
|
90 |
* Register Contact/Hire feature
|
91 |
*
|
86 |
return json_encode(array('status' => 'success'));
|
87 |
}
|
88 |
|
89 |
+
/**
|
90 |
+
*
|
91 |
+
* @return type
|
92 |
+
*/
|
93 |
+
public function clearCache() {
|
94 |
+
AAM_Core_Cache::clear();
|
95 |
+
|
96 |
+
return json_encode(array('status' => 'success'));
|
97 |
+
}
|
98 |
+
|
99 |
/**
|
100 |
* Register Contact/Hire feature
|
101 |
*
|
Application/Backend/Filter.php
CHANGED
@@ -60,11 +60,14 @@ class AAM_Backend_Filter {
|
|
60 |
//add post filter for LIST restriction
|
61 |
if (!AAM::isAAM()) {
|
62 |
add_filter('the_posts', array($this, 'thePosts'), 10, 2);
|
63 |
-
|
64 |
-
add_action('pre_get_posts', array($this, 'preparePostQuery'));
|
65 |
-
}
|
66 |
}
|
67 |
|
|
|
|
|
|
|
|
|
|
|
68 |
//some additional filter for user capabilities
|
69 |
add_filter('user_has_cap', array($this, 'checkUserCap'), 999, 4);
|
70 |
|
@@ -73,6 +76,33 @@ class AAM_Backend_Filter {
|
|
73 |
add_filter('contextual_help', array($this, 'helpOptions'), 10, 3);
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
/**
|
77 |
*
|
78 |
* @staticvar type $default
|
@@ -325,6 +355,11 @@ class AAM_Backend_Filter {
|
|
325 |
|
326 |
if (!$list && (!$others || $this->isAuthor($post))) {
|
327 |
$filtered[] = $post;
|
|
|
|
|
|
|
|
|
|
|
328 |
}
|
329 |
}
|
330 |
}
|
@@ -351,13 +386,13 @@ class AAM_Backend_Filter {
|
|
351 |
if (AAM_Core_Cache::has($postType . '__not_in_backend')) {
|
352 |
$filtered = AAM_Core_Cache::get($postType . '__not_in_backend');
|
353 |
} else {
|
354 |
-
foreach ($this->fetchPosts($postType) as $
|
355 |
-
$object = AAM::getUser()->getObject('post', $
|
356 |
$list = $object->has('backend.list');
|
357 |
$others = $object->has('backend.list_others');
|
358 |
|
359 |
if ($list || ($others && !$this->isAuthor($object->getPost()))) {
|
360 |
-
$filtered[] = $
|
361 |
}
|
362 |
}
|
363 |
AAM_Core_Cache::set(AAM::getUser(), $postType. '__not_in_backend', $filtered);
|
@@ -383,11 +418,10 @@ class AAM_Backend_Filter {
|
|
383 |
|
384 |
$posts = get_posts(array(
|
385 |
'post_type' => (is_string($postType) ? $postType : 'post'),
|
386 |
-
'numberposts' =>
|
387 |
-
'fields' => 'ids',
|
388 |
'post_status' => 'any'
|
389 |
));
|
390 |
-
|
391 |
$this->skip = false;
|
392 |
|
393 |
return $posts;
|
60 |
//add post filter for LIST restriction
|
61 |
if (!AAM::isAAM()) {
|
62 |
add_filter('the_posts', array($this, 'thePosts'), 10, 2);
|
63 |
+
add_action('pre_get_posts', array($this, 'preparePostQuery'));
|
|
|
|
|
64 |
}
|
65 |
|
66 |
+
add_action('pre_post_update', array($this, 'prePostUpdate'), 10, 2);
|
67 |
+
|
68 |
+
//user profile update action
|
69 |
+
add_action('profile_update', array($this, 'profileUpdate'), 10, 2);
|
70 |
+
|
71 |
//some additional filter for user capabilities
|
72 |
add_filter('user_has_cap', array($this, 'checkUserCap'), 999, 4);
|
73 |
|
76 |
add_filter('contextual_help', array($this, 'helpOptions'), 10, 3);
|
77 |
}
|
78 |
|
79 |
+
/**
|
80 |
+
*
|
81 |
+
* @param type $id
|
82 |
+
* @param type $old
|
83 |
+
*/
|
84 |
+
public function profileUpdate($id, $old) {
|
85 |
+
$user = get_user_by('ID', $id);
|
86 |
+
|
87 |
+
//role changed?
|
88 |
+
if (implode('', $user->roles) != implode('', $old->roles)) {
|
89 |
+
AAM_Core_Cache::clear($id);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
*
|
95 |
+
* @param type $id
|
96 |
+
* @param type $data
|
97 |
+
*/
|
98 |
+
public function prePostUpdate($id, $data) {
|
99 |
+
$post = get_post($id);
|
100 |
+
|
101 |
+
if ($post->post_author != $data['post_author']) {
|
102 |
+
AAM_Core_Cache::clear($id);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
/**
|
107 |
*
|
108 |
* @staticvar type $default
|
355 |
|
356 |
if (!$list && (!$others || $this->isAuthor($post))) {
|
357 |
$filtered[] = $post;
|
358 |
+
} else {
|
359 |
+
$notin = AAM_Core_Cache::get($post->post_type . '__not_in_backend');
|
360 |
+
AAM_Core_Cache::set(
|
361 |
+
AAM::getUser(), $post->post_type . '__not_in_backend', $notin
|
362 |
+
);
|
363 |
}
|
364 |
}
|
365 |
}
|
386 |
if (AAM_Core_Cache::has($postType . '__not_in_backend')) {
|
387 |
$filtered = AAM_Core_Cache::get($postType . '__not_in_backend');
|
388 |
} else {
|
389 |
+
foreach ($this->fetchPosts($postType) as $post) {
|
390 |
+
$object = AAM::getUser()->getObject('post', $post->ID);
|
391 |
$list = $object->has('backend.list');
|
392 |
$others = $object->has('backend.list_others');
|
393 |
|
394 |
if ($list || ($others && !$this->isAuthor($object->getPost()))) {
|
395 |
+
$filtered[] = $post->ID;
|
396 |
}
|
397 |
}
|
398 |
AAM_Core_Cache::set(AAM::getUser(), $postType. '__not_in_backend', $filtered);
|
418 |
|
419 |
$posts = get_posts(array(
|
420 |
'post_type' => (is_string($postType) ? $postType : 'post'),
|
421 |
+
'numberposts' => 500,
|
|
|
422 |
'post_status' => 'any'
|
423 |
));
|
424 |
+
|
425 |
$this->skip = false;
|
426 |
|
427 |
return $posts;
|
Application/Backend/Manager.php
CHANGED
@@ -66,16 +66,6 @@ class AAM_Backend_Manager {
|
|
66 |
//manager WordPress metaboxes
|
67 |
add_action("in_admin_header", array($this, 'initMetaboxes'), 999);
|
68 |
|
69 |
-
//user profile update action
|
70 |
-
add_action('profile_update', 'AAM_Core_Cache::clear');
|
71 |
-
|
72 |
-
//term & post CRUD hooks
|
73 |
-
if (AAM_Core_Config::get('cache-auto-clear', true)) {
|
74 |
-
add_action('delete_term', 'AAM_Core_Cache::clear');
|
75 |
-
add_action('edited_term', 'AAM_Core_Cache::clear');
|
76 |
-
add_action('save_post', 'AAM_Core_Cache::clear');
|
77 |
-
}
|
78 |
-
|
79 |
//extend post inline actions
|
80 |
add_filter('page_row_actions', array($this, 'postRowActions'), 10, 2);
|
81 |
add_filter('post_row_actions', array($this, 'postRowActions'), 10, 2);
|
@@ -83,6 +73,9 @@ class AAM_Backend_Manager {
|
|
83 |
//extend term inline actions
|
84 |
add_filter('tag_row_actions', array($this, 'tagRowActions'), 10, 2);
|
85 |
|
|
|
|
|
|
|
86 |
//check extension version
|
87 |
$this->checkExtensionList();
|
88 |
|
@@ -95,6 +88,25 @@ class AAM_Backend_Manager {
|
|
95 |
AAM_Backend_View_CodePinch::bootstrap();
|
96 |
}
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
/**
|
99 |
*
|
100 |
*/
|
66 |
//manager WordPress metaboxes
|
67 |
add_action("in_admin_header", array($this, 'initMetaboxes'), 999);
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
//extend post inline actions
|
70 |
add_filter('page_row_actions', array($this, 'postRowActions'), 10, 2);
|
71 |
add_filter('post_row_actions', array($this, 'postRowActions'), 10, 2);
|
73 |
//extend term inline actions
|
74 |
add_filter('tag_row_actions', array($this, 'tagRowActions'), 10, 2);
|
75 |
|
76 |
+
//footer thank you
|
77 |
+
add_filter('admin_footer_text', array($this, 'thankYou'), 999);
|
78 |
+
|
79 |
//check extension version
|
80 |
$this->checkExtensionList();
|
81 |
|
88 |
AAM_Backend_View_CodePinch::bootstrap();
|
89 |
}
|
90 |
|
91 |
+
/**
|
92 |
+
*
|
93 |
+
* @param type $text
|
94 |
+
* @return string
|
95 |
+
*/
|
96 |
+
public function thankYou($text) {
|
97 |
+
if (AAM::isAAM()) {
|
98 |
+
$text = '<span id="footer-thankyou">';
|
99 |
+
$text .= '<b>Please help us</b> and submit your review <a href="';
|
100 |
+
$text .= 'https://wordpress.org/support/plugin/advanced-access-manager/reviews/"';
|
101 |
+
$text .= 'target="_blank"><i class="icon-star"></i>';
|
102 |
+
$text .= '<i class="icon-star"></i><i class="icon-star"></i>';
|
103 |
+
$text .= '<i class="icon-star"></i><i class="icon-star"></i></a>';
|
104 |
+
$text .= '</span>';
|
105 |
+
}
|
106 |
+
|
107 |
+
return $text;
|
108 |
+
}
|
109 |
+
|
110 |
/**
|
111 |
*
|
112 |
*/
|
Application/Backend/View.php
CHANGED
@@ -62,6 +62,7 @@ class AAM_Backend_View {
|
|
62 |
AAM_Backend_Feature_Security::register();
|
63 |
AAM_Backend_Feature_Utility::register();
|
64 |
AAM_Backend_Feature_Contact::register();
|
|
|
65 |
|
66 |
//feature registration hook
|
67 |
do_action('aam-feature-registration');
|
@@ -94,7 +95,7 @@ class AAM_Backend_View {
|
|
94 |
global $post;
|
95 |
|
96 |
if (is_a($post, 'WP_Post')) {
|
97 |
-
$url = admin_url('admin.php?page=aam&oid=' . $post->ID . '#post');
|
98 |
|
99 |
ob_start();
|
100 |
require_once(dirname(__FILE__) . '/phtml/metabox.phtml');
|
62 |
AAM_Backend_Feature_Security::register();
|
63 |
AAM_Backend_Feature_Utility::register();
|
64 |
AAM_Backend_Feature_Contact::register();
|
65 |
+
AAM_Backend_Feature_404Redirect::register();
|
66 |
|
67 |
//feature registration hook
|
68 |
do_action('aam-feature-registration');
|
95 |
global $post;
|
96 |
|
97 |
if (is_a($post, 'WP_Post')) {
|
98 |
+
$url = admin_url('admin.php?page=aam&oid=' . $post->ID . '&otype=post#post');
|
99 |
|
100 |
ob_start();
|
101 |
require_once(dirname(__FILE__) . '/phtml/metabox.phtml');
|
Application/Backend/View/UtilityOptionList.php
CHANGED
@@ -27,15 +27,5 @@ return array(
|
|
27 |
'title' => __('Media Files Access Control', AAM_KEY),
|
28 |
'descr' => AAM_Backend_View_Helper::preparePhrase('Allow AAM to manage a physically access to all media files located in the [uploads] folder.', 'strong'),
|
29 |
'value' => AAM_Core_Config::get('media-access-control', false),
|
30 |
-
),
|
31 |
-
'cache-auto-clear' => array(
|
32 |
-
'title' => __('Clear cache automatically', AAM_KEY),
|
33 |
-
'descr' => __('Clear AAM cache automatically during post saving or when any category is updated or deleted', AAM_KEY),
|
34 |
-
'value' => AAM_Core_Config::get('cache-auto-clear', true),
|
35 |
-
),
|
36 |
-
'large-post-number' => array(
|
37 |
-
'title' => __('Enhance post filtering', AAM_KEY),
|
38 |
-
'descr' => AAM_Backend_View_Helper::preparePhrase('[Warning!] This may significantly reduce your website load with large amount of posts and categories until AAM caches results. Modify database query to exclude posts that have LIST or LIST TO OTHERS options checked.', 'b'),
|
39 |
-
'value' => AAM_Core_Config::get('large-post-number', false),
|
40 |
)
|
41 |
);
|
27 |
'title' => __('Media Files Access Control', AAM_KEY),
|
28 |
'descr' => AAM_Backend_View_Helper::preparePhrase('Allow AAM to manage a physically access to all media files located in the [uploads] folder.', 'strong'),
|
29 |
'value' => AAM_Core_Config::get('media-access-control', false),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
)
|
31 |
);
|
Application/Backend/phtml/404redirect.phtml
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if (defined('AAM_KEY')) { ?>
|
2 |
+
<div class="aam-feature" id="404redirect-content">
|
3 |
+
<div class="row">
|
4 |
+
<div class="col-xs-12">
|
5 |
+
<p class="aam-info">
|
6 |
+
<?php echo AAM_Backend_View_Helper::preparePhrase('Setup [default] 404 redirect for all none-existing pages.', 'strong'); ?>
|
7 |
+
</p>
|
8 |
+
</div>
|
9 |
+
</div>
|
10 |
+
|
11 |
+
<div class="row">
|
12 |
+
<div class="col-xs-12">
|
13 |
+
<?php $type = AAM_Core_Config::get('frontend.404redirect.type', 'default'); ?>
|
14 |
+
|
15 |
+
<div class="radio">
|
16 |
+
<input type="radio" name="frontend.404redirect.type" id="frontend-404redirect-default" value="default" data-action="none"<?php echo ($type == 'default' ? ' checked' : ''); ?> />
|
17 |
+
<label for="frontend-404redirect-default"><?php echo AAM_Backend_View_Helper::preparePhrase('Default WordPress 404 handler', 'small'); ?></label>
|
18 |
+
</div>
|
19 |
+
<div class="radio">
|
20 |
+
<input type="radio" name="frontend.404redirect.type" id="frontend-404redirect-page" data-action="#404redirect-page-action" value="page"<?php echo ($type == 'page' ? ' checked' : ''); ?> />
|
21 |
+
<label for="frontend-404redirect-page"><?php echo AAM_Backend_View_Helper::preparePhrase('Redirected to existing page [(select from the drop-down)]', 'small'); ?></label>
|
22 |
+
</div>
|
23 |
+
<div class="radio">
|
24 |
+
<input type="radio" name="frontend.404redirect.type" id="frontend-404redirect-url" data-action="#404redirect-url-action" value="url"<?php echo ($type == 'url' ? ' checked' : ''); ?> />
|
25 |
+
<label for="frontend-404redirect-url"><?php echo AAM_Backend_View_Helper::preparePhrase('Redirected to the URL [(enter valid URL starting from http or https)]', 'small'); ?></label>
|
26 |
+
</div>
|
27 |
+
<div class="radio">
|
28 |
+
<input type="radio" name="frontend.404redirect.type" id="frontend-404redirect-callback" data-action="#404redirect-callback-action" value="callback"<?php echo ($type == 'callback' ? ' checked' : ''); ?> />
|
29 |
+
<label for="frontend-404redirect-callback"><?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Trigger PHP callback function [(valid %sPHP callback%s is required)]', 'small'), '<a href="http://php.net/manual/en/language.types.callable.php" target="_blank">', '</a>'); ?></label>
|
30 |
+
</div>
|
31 |
+
|
32 |
+
<div class="form-group aam-404redirect-action" id="404redirect-page-action" style="display: <?php echo ($type == 'page' ? 'block' : 'none'); ?>;">
|
33 |
+
<label for="frontend-page"><?php echo __('Existing Page', AAM_KEY); ?></label>
|
34 |
+
<?php
|
35 |
+
wp_dropdown_pages(array(
|
36 |
+
'depth' => 99,
|
37 |
+
'selected' => AAM_Core_Config::get('frontend.404redirect.page'),
|
38 |
+
'echo' => 1,
|
39 |
+
'name' => 'frontend.404redirect.page',
|
40 |
+
'id' => 'frontend-page', // string
|
41 |
+
'class' => 'form-control', // string
|
42 |
+
'show_option_none' => __('-- Select Page --', AAM_KEY) // string
|
43 |
+
));
|
44 |
+
?>
|
45 |
+
</div>
|
46 |
+
|
47 |
+
<div class="form-group aam-404redirect-action" id="404redirect-url-action" style="display: <?php echo ($type == 'url' ? 'block' : 'none'); ?>;">
|
48 |
+
<label for="frontend-url"><?php echo __('The URL', AAM_KEY); ?></label>
|
49 |
+
<input type="text" class="form-control" name="frontend.404redirect.url" placeholder="http://" value="<?php echo AAM_Core_Config::get('frontend.404redirect.url'); ?>" />
|
50 |
+
</div>
|
51 |
+
|
52 |
+
<div class="form-group aam-404redirect-action" id="404redirect-callback-action" style="display: <?php echo ($type == 'callback' ? 'block' : 'none'); ?>;">
|
53 |
+
<label for="frontend-url"><?php echo __('PHP Callback Function', AAM_KEY); ?></label>
|
54 |
+
<input type="text" class="form-control" placeholder="Enter valid callback" name="frontend.404redirect.callback" value="<?php echo AAM_Core_Config::get('frontend.404redirect.callback'); ?>" />
|
55 |
+
</div>
|
56 |
+
</div>
|
57 |
+
</div>
|
58 |
+
</div>
|
59 |
+
<?php }
|
Application/Backend/phtml/index.phtml
CHANGED
@@ -225,7 +225,7 @@
|
|
225 |
</a>
|
226 |
<a href="https://wordpress.org/support/plugin/advanced-access-manager/reviews/" title="Rate Me" target="_blank">
|
227 |
<i class="icon-star"></i>
|
228 |
-
<span>
|
229 |
</a>
|
230 |
<a target="_blank" href="https://twitter.com/aamplugin">
|
231 |
<i class="icon-twitter"></i>
|
225 |
</a>
|
226 |
<a href="https://wordpress.org/support/plugin/advanced-access-manager/reviews/" title="Rate Me" target="_blank">
|
227 |
<i class="icon-star"></i>
|
228 |
+
<span>Reviews</span>
|
229 |
</a>
|
230 |
<a target="_blank" href="https://twitter.com/aamplugin">
|
231 |
<i class="icon-twitter"></i>
|
Application/Backend/phtml/object/post.phtml
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
<?php } ?>
|
12 |
|
13 |
<?php if (defined('AAM_PLUS_PACKAGE') || AAM_Backend_View::getSubject()->getUID() != 'default') { ?>
|
14 |
-
<?php $current = $this->getCurrentObject()
|
15 |
|
16 |
<div class="aam-post-breadcrumb">
|
17 |
<a href="#" data-level="root"><i class="icon-home"></i> <?php echo __('Root', AAM_KEY); ?></a>
|
11 |
<?php } ?>
|
12 |
|
13 |
<?php if (defined('AAM_PLUS_PACKAGE') || AAM_Backend_View::getSubject()->getUID() != 'default') { ?>
|
14 |
+
<?php $current = $this->getCurrentObject();?>
|
15 |
|
16 |
<div class="aam-post-breadcrumb">
|
17 |
<a href="#" data-level="root"><i class="icon-home"></i> <?php echo __('Root', AAM_KEY); ?></a>
|
Application/Backend/phtml/utility.phtml
CHANGED
@@ -21,6 +21,17 @@
|
|
21 |
<?php do_action('aam-post-utilities-setting'); ?>
|
22 |
|
23 |
<tr><td colspan="2"></td></tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
<tr>
|
25 |
<td>
|
26 |
<span class='aam-setting-title'><?php echo __('Clear All Settings', AAM_KEY); ?></span>
|
@@ -29,7 +40,7 @@
|
|
29 |
</p>
|
30 |
</td>
|
31 |
<td>
|
32 |
-
<a href="#clear-settings-modal" data-toggle="modal" class="btn btn-danger btn-block">
|
33 |
</td>
|
34 |
</tr>
|
35 |
</tbody>
|
21 |
<?php do_action('aam-post-utilities-setting'); ?>
|
22 |
|
23 |
<tr><td colspan="2"></td></tr>
|
24 |
+
<tr>
|
25 |
+
<td>
|
26 |
+
<span class='aam-setting-title'><?php echo __('Clear Cache', AAM_KEY); ?></span>
|
27 |
+
<p class="aam-setting-description">
|
28 |
+
<?php echo __('Clear all AAM cache.', AAM_KEY); ?>
|
29 |
+
</p>
|
30 |
+
</td>
|
31 |
+
<td>
|
32 |
+
<a href="#" class="btn btn-warning btn-block" id="clear-cache">Clear</a>
|
33 |
+
</td>
|
34 |
+
</tr>
|
35 |
<tr>
|
36 |
<td>
|
37 |
<span class='aam-setting-title'><?php echo __('Clear All Settings', AAM_KEY); ?></span>
|
40 |
</p>
|
41 |
</td>
|
42 |
<td>
|
43 |
+
<a href="#clear-settings-modal" data-toggle="modal" class="btn btn-danger btn-block">Clear</a>
|
44 |
</td>
|
45 |
</tr>
|
46 |
</tbody>
|
Application/Core/API.php
CHANGED
@@ -238,9 +238,9 @@ final class AAM_Core_API {
|
|
238 |
*/
|
239 |
public static function redirect($rule, $args = null) {
|
240 |
if (filter_var($rule, FILTER_VALIDATE_URL)) {
|
241 |
-
wp_redirect($rule);
|
242 |
} elseif (preg_match('/^[\d]+$/', $rule)) {
|
243 |
-
wp_safe_redirect(
|
244 |
} elseif (is_callable($rule)) {
|
245 |
call_user_func($rule, $args);
|
246 |
} elseif (!empty($args['callback']) && is_callable($args['callback'])) {
|
238 |
*/
|
239 |
public static function redirect($rule, $args = null) {
|
240 |
if (filter_var($rule, FILTER_VALIDATE_URL)) {
|
241 |
+
wp_redirect($rule, 301);
|
242 |
} elseif (preg_match('/^[\d]+$/', $rule)) {
|
243 |
+
wp_safe_redirect(get_page_link($rule), 301);
|
244 |
} elseif (is_callable($rule)) {
|
245 |
call_user_func($rule, $args);
|
246 |
} elseif (!empty($args['callback']) && is_callable($args['callback'])) {
|
Application/Core/Cache.php
CHANGED
@@ -47,8 +47,8 @@ class AAM_Core_Cache {
|
|
47 |
*
|
48 |
* @access public
|
49 |
*/
|
50 |
-
public static function get($option) {
|
51 |
-
return (isset(self::$cache[$option]) ? self::$cache[$option] :
|
52 |
}
|
53 |
|
54 |
/**
|
@@ -86,15 +86,21 @@ class AAM_Core_Cache {
|
|
86 |
* @access public
|
87 |
* @global WPDB $wpdb
|
88 |
*/
|
89 |
-
public static function clear() {
|
90 |
global $wpdb;
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
self::$cache = false;
|
100 |
|
47 |
*
|
48 |
* @access public
|
49 |
*/
|
50 |
+
public static function get($option, $default = null) {
|
51 |
+
return (isset(self::$cache[$option]) ? self::$cache[$option] : $default);
|
52 |
}
|
53 |
|
54 |
/**
|
86 |
* @access public
|
87 |
* @global WPDB $wpdb
|
88 |
*/
|
89 |
+
public static function clear($user = null) {
|
90 |
global $wpdb;
|
91 |
|
92 |
+
if (is_null($user)) {
|
93 |
+
//clear visitor cache
|
94 |
+
$oquery = "DELETE FROM {$wpdb->options} WHERE `option_name` = %s";
|
95 |
+
$wpdb->query($wpdb->prepare($oquery, 'aam_visitor_cache' ));
|
96 |
+
|
97 |
+
$mquery = "DELETE FROM {$wpdb->usermeta} WHERE `meta_key` = %s";
|
98 |
+
$wpdb->query($wpdb->prepare($mquery, $wpdb->prefix . 'aam_cache' ));
|
99 |
+
} else {
|
100 |
+
$query = "DELETE FROM {$wpdb->usermeta} WHERE (`user_id` = %d) AND ";
|
101 |
+
$query .= "`meta_key` = %s";
|
102 |
+
$wpdb->query($wpdb->prepare($query, $user, $wpdb->prefix . 'aam_cache'));
|
103 |
+
}
|
104 |
|
105 |
self::$cache = false;
|
106 |
|
Application/Core/Subject/User.php
CHANGED
@@ -29,6 +29,12 @@ class AAM_Core_Subject_User extends AAM_Core_Subject {
|
|
29 |
*/
|
30 |
const AAM_CAPKEY = 'aam_capability';
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
/**
|
33 |
* Block User
|
34 |
*
|
@@ -214,19 +220,21 @@ class AAM_Core_Subject_User extends AAM_Core_Subject {
|
|
214 |
* @inheritdoc
|
215 |
*/
|
216 |
public function getParent() {
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
|
|
221 |
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
|
|
227 |
}
|
228 |
|
229 |
-
return $
|
230 |
}
|
231 |
|
232 |
/**
|
29 |
*/
|
30 |
const AAM_CAPKEY = 'aam_capability';
|
31 |
|
32 |
+
/**
|
33 |
+
*
|
34 |
+
* @var type
|
35 |
+
*/
|
36 |
+
protected $parent = null;
|
37 |
+
|
38 |
/**
|
39 |
* Block User
|
40 |
*
|
220 |
* @inheritdoc
|
221 |
*/
|
222 |
public function getParent() {
|
223 |
+
if (is_null($this->parent)) {
|
224 |
+
//try to get this option from the User's Role
|
225 |
+
$roles = $this->getSubject()->roles;
|
226 |
+
//first user role is counted only. AAM does not support multi-roles
|
227 |
+
$parent = array_shift($roles);
|
228 |
|
229 |
+
//in case of multisite & current user does not belong to the site
|
230 |
+
if ($parent) {
|
231 |
+
$this->parent = new AAM_Core_Subject_Role($parent);
|
232 |
+
} else {
|
233 |
+
$this->parent = null;
|
234 |
+
}
|
235 |
}
|
236 |
|
237 |
+
return $this->parent;
|
238 |
}
|
239 |
|
240 |
/**
|
Application/Frontend/Manager.php
CHANGED
@@ -55,9 +55,7 @@ class AAM_Frontend_Manager {
|
|
55 |
add_filter('wp_authenticate_user', array($this, 'authenticate'), 1, 2);
|
56 |
//add post filter for LIST restriction
|
57 |
add_filter('the_posts', array($this, 'thePosts'), 999, 2);
|
58 |
-
|
59 |
-
add_action('pre_get_posts', array($this, 'preparePostQuery'));
|
60 |
-
}
|
61 |
|
62 |
//password protected filter
|
63 |
add_filter('post_password_required', array($this, 'isProtected'), 10, 2);
|
@@ -270,9 +268,25 @@ class AAM_Frontend_Manager {
|
|
270 |
* @global WP_Post $post
|
271 |
*/
|
272 |
public function wp() {
|
273 |
-
|
274 |
-
|
275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
}
|
277 |
}
|
278 |
|
@@ -391,6 +405,10 @@ class AAM_Frontend_Manager {
|
|
391 |
|
392 |
if ($list || ($others && !$this->isAuthor($post))) {
|
393 |
unset($posts[$i]);
|
|
|
|
|
|
|
|
|
394 |
}
|
395 |
}
|
396 |
}
|
@@ -522,8 +540,7 @@ class AAM_Frontend_Manager {
|
|
522 |
|
523 |
$posts = get_posts(array(
|
524 |
'post_type' => $this->getQueryType($query),
|
525 |
-
'numberposts' =>
|
526 |
-
'fields' => 'ids'
|
527 |
));
|
528 |
|
529 |
$this->skip = false;
|
55 |
add_filter('wp_authenticate_user', array($this, 'authenticate'), 1, 2);
|
56 |
//add post filter for LIST restriction
|
57 |
add_filter('the_posts', array($this, 'thePosts'), 999, 2);
|
58 |
+
add_action('pre_get_posts', array($this, 'preparePostQuery'));
|
|
|
|
|
59 |
|
60 |
//password protected filter
|
61 |
add_filter('post_password_required', array($this, 'isProtected'), 10, 2);
|
268 |
* @global WP_Post $post
|
269 |
*/
|
270 |
public function wp() {
|
271 |
+
global $wp_query;
|
272 |
+
|
273 |
+
if ($wp_query->is_404) {
|
274 |
+
$type = AAM_Core_Config::get('frontend.404redirect.type', 'default');
|
275 |
+
do_action('aam-rejected-action', 'frontend', array(
|
276 |
+
'hook' => 'aam_404',
|
277 |
+
'uri' => AAM_Core_Request::server('REQUEST_URI')
|
278 |
+
));
|
279 |
+
|
280 |
+
if ($type != 'default') {
|
281 |
+
AAM_Core_API::redirect(
|
282 |
+
AAM_Core_Config::get("frontend.404redirect.{$type}")
|
283 |
+
);
|
284 |
+
}
|
285 |
+
} else {
|
286 |
+
$post = $this->getCurrentPost();
|
287 |
+
if (is_a($post, 'WP_Post')) {
|
288 |
+
$this->checkPostReadAccess($post);
|
289 |
+
}
|
290 |
}
|
291 |
}
|
292 |
|
405 |
|
406 |
if ($list || ($others && !$this->isAuthor($post))) {
|
407 |
unset($posts[$i]);
|
408 |
+
$notin = AAM_Core_Cache::get($post->post_type . '__not_in_frontend');
|
409 |
+
AAM_Core_Cache::set(
|
410 |
+
AAM::getUser(), $post->post_type . '__not_in_frontend', $notin
|
411 |
+
);
|
412 |
}
|
413 |
}
|
414 |
}
|
540 |
|
541 |
$posts = get_posts(array(
|
542 |
'post_type' => $this->getQueryType($query),
|
543 |
+
'numberposts' => 500
|
|
|
544 |
));
|
545 |
|
546 |
$this->skip = false;
|
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.
|
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.4
|
7 |
Author: Vasyl Martyniuk <vasyl@vasyltech.com>
|
8 |
Author URI: https://www.vasyltech.com
|
9 |
|
media/js/aam-ui.js
CHANGED
@@ -2007,6 +2007,72 @@
|
|
2007 |
|
2008 |
})(jQuery);
|
2009 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010 |
/**
|
2011 |
* Extensions Interface
|
2012 |
*
|
@@ -2220,6 +2286,27 @@
|
|
2220 |
}
|
2221 |
});
|
2222 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2223 |
}
|
2224 |
|
2225 |
aam.addHook('init', initialize);
|
2007 |
|
2008 |
})(jQuery);
|
2009 |
|
2010 |
+
/**
|
2011 |
+
* 404 Redirect Interface
|
2012 |
+
*
|
2013 |
+
* @param {jQuery} $
|
2014 |
+
*
|
2015 |
+
* @returns {void}
|
2016 |
+
*/
|
2017 |
+
(function ($) {
|
2018 |
+
|
2019 |
+
/**
|
2020 |
+
*
|
2021 |
+
* @param {type} param
|
2022 |
+
* @param {type} value
|
2023 |
+
* @returns {undefined}
|
2024 |
+
*/
|
2025 |
+
function save(param, value) {
|
2026 |
+
$.ajax(aamLocal.ajaxurl, {
|
2027 |
+
type: 'POST',
|
2028 |
+
dataType: 'json',
|
2029 |
+
data: {
|
2030 |
+
action: 'aam',
|
2031 |
+
sub_action: '404Redirect.save',
|
2032 |
+
_ajax_nonce: aamLocal.nonce,
|
2033 |
+
subject: aam.getSubject().type,
|
2034 |
+
subjectId: aam.getSubject().id,
|
2035 |
+
param: param,
|
2036 |
+
value: value
|
2037 |
+
},
|
2038 |
+
error: function () {
|
2039 |
+
aam.notification('danger', aam.__('Application error'));
|
2040 |
+
}
|
2041 |
+
});
|
2042 |
+
}
|
2043 |
+
|
2044 |
+
/**
|
2045 |
+
*
|
2046 |
+
* @returns {undefined}
|
2047 |
+
*/
|
2048 |
+
function initialize() {
|
2049 |
+
var container = '#404redirect-content';
|
2050 |
+
|
2051 |
+
$('input[type="radio"]', container).each(function () {
|
2052 |
+
$(this).bind('click', function () {
|
2053 |
+
//hide group
|
2054 |
+
$('.aam-404redirect-action').hide();
|
2055 |
+
|
2056 |
+
//show the specific one
|
2057 |
+
$($(this).data('action')).show();
|
2058 |
+
|
2059 |
+
//save redirect type
|
2060 |
+
save($(this).attr('name'), $(this).val());
|
2061 |
+
});
|
2062 |
+
});
|
2063 |
+
|
2064 |
+
$('input[type="text"],select,textarea', container).each(function () {
|
2065 |
+
$(this).bind('change', function () {
|
2066 |
+
//save redirect type
|
2067 |
+
save($(this).attr('name'), $(this).val());
|
2068 |
+
});
|
2069 |
+
});
|
2070 |
+
}
|
2071 |
+
|
2072 |
+
aam.addHook('init', initialize);
|
2073 |
+
|
2074 |
+
})(jQuery);
|
2075 |
+
|
2076 |
/**
|
2077 |
* Extensions Interface
|
2078 |
*
|
2286 |
}
|
2287 |
});
|
2288 |
});
|
2289 |
+
|
2290 |
+
$('#clear-cache').bind('click', function () {
|
2291 |
+
$.ajax(aamLocal.ajaxurl, {
|
2292 |
+
type: 'POST',
|
2293 |
+
dataType: 'json',
|
2294 |
+
async: false,
|
2295 |
+
data: {
|
2296 |
+
action: 'aam',
|
2297 |
+
sub_action: 'Utility.clearCache',
|
2298 |
+
_ajax_nonce: aamLocal.nonce
|
2299 |
+
},
|
2300 |
+
success: function (response) {
|
2301 |
+
if (response.status === 'success') {
|
2302 |
+
location.reload();
|
2303 |
+
}
|
2304 |
+
},
|
2305 |
+
error: function () {
|
2306 |
+
aam.notification('danger', aam.__('Application Error'));
|
2307 |
+
}
|
2308 |
+
});
|
2309 |
+
});
|
2310 |
}
|
2311 |
|
2312 |
aam.addHook('init', initialize);
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Advanced Access Manager ===
|
2 |
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
|
4 |
Requires at least: 3.8
|
5 |
Tested up to: 4.7.3
|
6 |
-
Stable tag: 4.
|
7 |
|
8 |
Manage your website access and security for any user, role or visitors.
|
9 |
|
@@ -33,6 +33,9 @@ to learn more about this feature.
|
|
33 |
Track any user or visitor activities on your website with AAM User Activity extension. For more information about this
|
34 |
feature refer to the [How to track any WordPress user activity](https://aamplugin.com/help/how-to-track-any-wordpress-user-activity)
|
35 |
|
|
|
|
|
|
|
36 |
= Manage Backend Menu =
|
37 |
Manage access to the backend menu for any user or group or users (roles).
|
38 |
|
@@ -104,6 +107,11 @@ Check our [help page](https://aamplugin.com/help) to find out more about AAM.
|
|
104 |
|
105 |
== Changelog ==
|
106 |
|
|
|
|
|
|
|
|
|
|
|
107 |
= 4.3.1 =
|
108 |
* Minor bug fixes
|
109 |
|
1 |
=== Advanced Access Manager ===
|
2 |
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.4
|
7 |
|
8 |
Manage your website access and security for any user, role or visitors.
|
9 |
|
33 |
Track any user or visitor activities on your website with AAM User Activity extension. For more information about this
|
34 |
feature refer to the [How to track any WordPress user activity](https://aamplugin.com/help/how-to-track-any-wordpress-user-activity)
|
35 |
|
36 |
+
= 404 Redirect =
|
37 |
+
Redirect all users and visitors to specific page, URL or custom callback function when page does not exist.
|
38 |
+
|
39 |
= Manage Backend Menu =
|
40 |
Manage access to the backend menu for any user or group or users (roles).
|
41 |
|
107 |
|
108 |
== Changelog ==
|
109 |
|
110 |
+
= 4.4 =
|
111 |
+
* Fixed bug with frontend page redirect
|
112 |
+
* Significantly improved AAM speed and caching
|
113 |
+
* Added 404 redirect to the Default Settings
|
114 |
+
|
115 |
= 4.3.1 =
|
116 |
* Minor bug fixes
|
117 |
|