Version Description
- Enhanced Admin Menu feature
- Extended AAM API. Preparing it for developers to use.
Download this release
Release Info
Developer | vasyl_m |
Plugin | Advanced Access Manager |
Version | 5.0.5 |
Comparing to | |
See all releases |
Code changes from version 5.0.4 to 5.0.5
- Application/Backend/Feature/Main/Capability.php +1 -2
- Application/Backend/Feature/Main/Menu.php +3 -1
- Application/Backend/Manager.php +1 -1
- Application/Core/Object.php +41 -1
- Application/Core/Object/Menu.php +65 -11
- Application/Core/Subject.php +34 -16
- Application/Core/Subject/Default.php +8 -0
- Application/Core/Subject/Role.php +8 -0
- Application/Core/Subject/User.php +8 -0
- Application/Core/Subject/Visitor.php +8 -0
- aam.php +1 -1
- readme.txt +5 -1
Application/Backend/Feature/Main/Capability.php
CHANGED
@@ -21,7 +21,6 @@ class AAM_Backend_Feature_Main_Capability extends AAM_Backend_Feature_Abstract {
|
|
21 |
* @var array
|
22 |
*
|
23 |
* @access private
|
24 |
-
* @todo Move this to the Object_Capability
|
25 |
*/
|
26 |
public static $groups = array(
|
27 |
'system' => array(
|
@@ -45,7 +44,7 @@ class AAM_Backend_Feature_Main_Capability extends AAM_Backend_Feature_Abstract {
|
|
45 |
'manage_options', 'manage_links', 'manage_categories', 'customize',
|
46 |
'unfiltered_html', 'unfiltered_upload', 'update_themes',
|
47 |
'update_core', 'upload_files', 'delete_plugins', 'remove_users',
|
48 |
-
'switch_themes', 'list_users', 'promote_users', 'create_users'
|
49 |
),
|
50 |
'aam' => array(
|
51 |
'aam_manage_admin_menu', 'aam_manage_metaboxes', 'aam_manage_capabilities',
|
21 |
* @var array
|
22 |
*
|
23 |
* @access private
|
|
|
24 |
*/
|
25 |
public static $groups = array(
|
26 |
'system' => array(
|
44 |
'manage_options', 'manage_links', 'manage_categories', 'customize',
|
45 |
'unfiltered_html', 'unfiltered_upload', 'update_themes',
|
46 |
'update_core', 'upload_files', 'delete_plugins', 'remove_users',
|
47 |
+
'switch_themes', 'list_users', 'promote_users', 'create_users', 'delete_site'
|
48 |
),
|
49 |
'aam' => array(
|
50 |
'aam_manage_admin_menu', 'aam_manage_metaboxes', 'aam_manage_capabilities',
|
Application/Backend/Feature/Main/Menu.php
CHANGED
@@ -27,8 +27,10 @@ class AAM_Backend_Feature_Main_Menu extends AAM_Backend_Feature_Abstract {
|
|
27 |
$object = AAM_Backend_Subject::getInstance()->getObject('menu');
|
28 |
|
29 |
foreach($items as $item) {
|
30 |
-
$object->
|
31 |
}
|
|
|
|
|
32 |
|
33 |
return json_encode(array('status' => 'success'));
|
34 |
}
|
27 |
$object = AAM_Backend_Subject::getInstance()->getObject('menu');
|
28 |
|
29 |
foreach($items as $item) {
|
30 |
+
$object->updateOptionItem($item, $status);
|
31 |
}
|
32 |
+
|
33 |
+
$object->save();
|
34 |
|
35 |
return json_encode(array('status' => 'success'));
|
36 |
}
|
Application/Backend/Manager.php
CHANGED
@@ -172,7 +172,7 @@ class AAM_Backend_Manager {
|
|
172 |
* @access public
|
173 |
*/
|
174 |
public function theTitle($title, $id = null) {
|
175 |
-
if (empty($title)) {
|
176 |
$title = '[No Title]: ID ' . ($id ? $id : '[No ID]');
|
177 |
}
|
178 |
|
172 |
* @access public
|
173 |
*/
|
174 |
public function theTitle($title, $id = null) {
|
175 |
+
if (empty($title) && AAM::isAAM()) { //apply filter only for AAM page
|
176 |
$title = '[No Title]: ID ' . ($id ? $id : '[No ID]');
|
177 |
}
|
178 |
|
Application/Core/Object.php
CHANGED
@@ -116,7 +116,25 @@ abstract class AAM_Core_Object {
|
|
116 |
public function getOption() {
|
117 |
return $this->_option;
|
118 |
}
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
/**
|
121 |
* Set Inherited flag
|
122 |
*
|
@@ -162,5 +180,27 @@ abstract class AAM_Core_Object {
|
|
162 |
public function isOverwritten () {
|
163 |
return $this->_overwritten;
|
164 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
}
|
116 |
public function getOption() {
|
117 |
return $this->_option;
|
118 |
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Update single option item
|
122 |
+
*
|
123 |
+
* @param string $item
|
124 |
+
* @param mixed $value
|
125 |
+
*
|
126 |
+
* @return boolean Always true
|
127 |
+
*
|
128 |
+
* @access public
|
129 |
+
*/
|
130 |
+
public function updateOptionItem($item, $value) {
|
131 |
+
$option = $this->getOption();
|
132 |
+
$option[$item] = $value;
|
133 |
+
$this->setOption($option);
|
134 |
+
|
135 |
+
return true;
|
136 |
+
}
|
137 |
+
|
138 |
/**
|
139 |
* Set Inherited flag
|
140 |
*
|
180 |
public function isOverwritten () {
|
181 |
return $this->_overwritten;
|
182 |
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Check if access is allowed
|
186 |
+
*
|
187 |
+
* @return bool
|
188 |
+
*
|
189 |
+
* @access public
|
190 |
+
*/
|
191 |
+
public function allowed() {
|
192 |
+
return !call_user_func_array(array($this, 'has'), func_get_args());
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Check if access is denied
|
197 |
+
*
|
198 |
+
* @return boolean
|
199 |
+
*
|
200 |
+
* @access public
|
201 |
+
*/
|
202 |
+
public function denied() {
|
203 |
+
return call_user_func_array(array($this, 'has'), func_get_args());
|
204 |
+
}
|
205 |
|
206 |
}
|
Application/Core/Object/Menu.php
CHANGED
@@ -57,7 +57,8 @@ class AAM_Core_Object_Menu extends AAM_Core_Object {
|
|
57 |
|
58 |
foreach ($menu as $id => $item) {
|
59 |
if (!empty($submenu[$item[2]])) {
|
60 |
-
|
|
|
61 |
} else {
|
62 |
$subs = array();
|
63 |
}
|
@@ -108,20 +109,22 @@ class AAM_Core_Object_Menu extends AAM_Core_Object {
|
|
108 |
* Filter submenu
|
109 |
*
|
110 |
* @param array &$parent
|
|
|
111 |
*
|
112 |
* @return void
|
113 |
*
|
114 |
* @access protected
|
|
|
115 |
* @global array $menu
|
116 |
* @global array $submenu
|
117 |
*/
|
118 |
-
protected function filterSubmenu(&$parent) {
|
119 |
global $submenu;
|
120 |
|
121 |
$filtered = array();
|
122 |
|
123 |
foreach ($submenu[$parent[2]] as $id => $item) {
|
124 |
-
if ($this->has($this->normalizeItem($item[2]))) {
|
125 |
unset($submenu[$parent[2]][$id]);
|
126 |
} else {
|
127 |
$filtered[] = $submenu[$parent[2]][$id];
|
@@ -135,6 +138,39 @@ class AAM_Core_Object_Menu extends AAM_Core_Object {
|
|
135 |
|
136 |
return $filtered;
|
137 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
/**
|
140 |
* Check is menu defined
|
@@ -151,23 +187,41 @@ class AAM_Core_Object_Menu extends AAM_Core_Object {
|
|
151 |
//decode URL in case of any special characters like &
|
152 |
$decoded = htmlspecialchars_decode($menu);
|
153 |
$options = $this->getOption();
|
|
|
|
|
|
|
|
|
154 |
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
|
158 |
/**
|
159 |
-
*
|
|
|
|
|
|
|
|
|
160 |
*/
|
161 |
-
public function save($
|
162 |
-
$
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
return $this->getSubject()->updateOption($
|
167 |
}
|
168 |
|
169 |
/**
|
|
|
|
|
|
|
170 |
*
|
|
|
171 |
*/
|
172 |
public function reset() {
|
173 |
return $this->getSubject()->deleteOption('menu');
|
57 |
|
58 |
foreach ($menu as $id => $item) {
|
59 |
if (!empty($submenu[$item[2]])) {
|
60 |
+
// Cover the scenario when there are some dynamic submenus
|
61 |
+
$subs = $this->filterSubmenu($item, ($this->has('menu-' . $item[2])));
|
62 |
} else {
|
63 |
$subs = array();
|
64 |
}
|
109 |
* Filter submenu
|
110 |
*
|
111 |
* @param array &$parent
|
112 |
+
* @param bool $deny_all
|
113 |
*
|
114 |
* @return void
|
115 |
*
|
116 |
* @access protected
|
117 |
+
*
|
118 |
* @global array $menu
|
119 |
* @global array $submenu
|
120 |
*/
|
121 |
+
protected function filterSubmenu(&$parent, $deny_all = false) {
|
122 |
global $submenu;
|
123 |
|
124 |
$filtered = array();
|
125 |
|
126 |
foreach ($submenu[$parent[2]] as $id => $item) {
|
127 |
+
if ($deny_all || $this->has($this->normalizeItem($item[2]))) {
|
128 |
unset($submenu[$parent[2]][$id]);
|
129 |
} else {
|
130 |
$filtered[] = $submenu[$parent[2]][$id];
|
138 |
|
139 |
return $filtered;
|
140 |
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Get parent menu
|
144 |
+
*
|
145 |
+
* @param string $search
|
146 |
+
*
|
147 |
+
* @return string|bool
|
148 |
+
*
|
149 |
+
* @access protected
|
150 |
+
* @global array $submenu
|
151 |
+
*/
|
152 |
+
protected function getParentMenu($search) {
|
153 |
+
global $submenu;
|
154 |
+
|
155 |
+
$result = null;
|
156 |
+
|
157 |
+
if (is_array($submenu)) {
|
158 |
+
foreach($submenu as $parent => $subs) {
|
159 |
+
foreach($subs as $sub) {
|
160 |
+
if ($sub[2] == $search) {
|
161 |
+
$result = $parent;
|
162 |
+
break;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
if ($result !== null) {
|
167 |
+
break;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
return $result;
|
173 |
+
}
|
174 |
|
175 |
/**
|
176 |
* Check is menu defined
|
187 |
//decode URL in case of any special characters like &
|
188 |
$decoded = htmlspecialchars_decode($menu);
|
189 |
$options = $this->getOption();
|
190 |
+
$parent = $this->getParentMenu($decoded);
|
191 |
+
|
192 |
+
// Step #1. Check if menu is directly restricted
|
193 |
+
$direct = !empty($options[$decoded]);
|
194 |
|
195 |
+
// Step #2. Check if whole branch is restricted
|
196 |
+
$branch = ($both && !empty($options['menu-' . $decoded]));
|
197 |
+
|
198 |
+
// Step #3. Check if dynamic submenu is restricted because of whole branch
|
199 |
+
$indirect = ($parent && !empty($options['menu-' . $parent]));
|
200 |
+
|
201 |
+
return $direct || $branch || $indirect;
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
+
* Save menu option
|
206 |
+
*
|
207 |
+
* @return bool
|
208 |
+
*
|
209 |
+
* @access public
|
210 |
*/
|
211 |
+
public function save($item = null, $value = null) {
|
212 |
+
if (!is_null($item)) { // keep it compatible with main Manager.save
|
213 |
+
$this->updateOptionItem($item, $value);
|
214 |
+
}
|
215 |
+
|
216 |
+
return $this->getSubject()->updateOption($this->getOption(), 'menu');
|
217 |
}
|
218 |
|
219 |
/**
|
220 |
+
* Reset default settings
|
221 |
+
*
|
222 |
+
* @return bool
|
223 |
*
|
224 |
+
* @access public
|
225 |
*/
|
226 |
public function reset() {
|
227 |
return $this->getSubject()->deleteOption('menu');
|
Application/Core/Subject.php
CHANGED
@@ -144,11 +144,14 @@ abstract class AAM_Core_Subject {
|
|
144 |
}
|
145 |
|
146 |
/**
|
|
|
147 |
*
|
148 |
-
* @return
|
|
|
|
|
149 |
*/
|
150 |
public function getName() {
|
151 |
-
return
|
152 |
}
|
153 |
|
154 |
/**
|
@@ -220,9 +223,13 @@ abstract class AAM_Core_Subject {
|
|
220 |
}
|
221 |
|
222 |
/**
|
223 |
-
*
|
224 |
-
*
|
225 |
-
* @
|
|
|
|
|
|
|
|
|
226 |
*/
|
227 |
public function hasCapability($capability) {
|
228 |
$subject = $this->getSubject();
|
@@ -231,32 +238,43 @@ abstract class AAM_Core_Subject {
|
|
231 |
}
|
232 |
|
233 |
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
*
|
235 |
-
* @
|
236 |
-
* @param type $value
|
237 |
-
* @param type $object
|
238 |
-
* @param type $objectId
|
239 |
-
* @return type
|
240 |
*/
|
241 |
public function save($param, $value, $object, $objectId = 0) {
|
242 |
return $this->getObject($object, $objectId)->save($param, $value);
|
243 |
}
|
244 |
|
245 |
/**
|
246 |
-
*
|
247 |
*
|
248 |
* @param string $object
|
249 |
-
*
|
|
|
|
|
|
|
250 |
*/
|
251 |
public function resetObject($object) {
|
252 |
return $this->deleteOption($object);
|
253 |
}
|
254 |
|
255 |
/**
|
256 |
-
*
|
257 |
-
*
|
258 |
-
* @param
|
259 |
-
* @
|
|
|
|
|
|
|
|
|
260 |
*/
|
261 |
public function deleteOption($object, $id = 0) {
|
262 |
return AAM_Core_API::deleteOption($this->getOptionName($object, $id));
|
144 |
}
|
145 |
|
146 |
/**
|
147 |
+
* Get subject name
|
148 |
*
|
149 |
+
* @return string
|
150 |
+
*
|
151 |
+
* @access public
|
152 |
*/
|
153 |
public function getName() {
|
154 |
+
return '';
|
155 |
}
|
156 |
|
157 |
/**
|
223 |
}
|
224 |
|
225 |
/**
|
226 |
+
* Check if subject has capability
|
227 |
+
*
|
228 |
+
* @param string $capability
|
229 |
+
*
|
230 |
+
* @return boolean
|
231 |
+
*
|
232 |
+
* @access public
|
233 |
*/
|
234 |
public function hasCapability($capability) {
|
235 |
$subject = $this->getSubject();
|
238 |
}
|
239 |
|
240 |
/**
|
241 |
+
* Save option
|
242 |
+
*
|
243 |
+
* @param string $param
|
244 |
+
* @param mixed $value
|
245 |
+
* @param string $object
|
246 |
+
* @param mixed $objectId
|
247 |
+
*
|
248 |
+
* @return boolean
|
249 |
*
|
250 |
+
* @access public
|
|
|
|
|
|
|
|
|
251 |
*/
|
252 |
public function save($param, $value, $object, $objectId = 0) {
|
253 |
return $this->getObject($object, $objectId)->save($param, $value);
|
254 |
}
|
255 |
|
256 |
/**
|
257 |
+
* Reset object
|
258 |
*
|
259 |
* @param string $object
|
260 |
+
*
|
261 |
+
* @return boolean
|
262 |
+
*
|
263 |
+
* @access public
|
264 |
*/
|
265 |
public function resetObject($object) {
|
266 |
return $this->deleteOption($object);
|
267 |
}
|
268 |
|
269 |
/**
|
270 |
+
* Delete option
|
271 |
+
*
|
272 |
+
* @param string $object
|
273 |
+
* @param mixed $id
|
274 |
+
*
|
275 |
+
* @return boolean
|
276 |
+
*
|
277 |
+
* @access public
|
278 |
*/
|
279 |
public function deleteOption($object, $id = 0) {
|
280 |
return AAM_Core_API::deleteOption($this->getOptionName($object, $id));
|
Application/Core/Subject/Default.php
CHANGED
@@ -78,6 +78,14 @@ class AAM_Core_Subject_Default extends AAM_Core_Subject {
|
|
78 |
return __('All Users, Roles and Visitor', AAM_KEY);
|
79 |
}
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
/**
|
82 |
*
|
83 |
* @return type
|
78 |
return __('All Users, Roles and Visitor', AAM_KEY);
|
79 |
}
|
80 |
|
81 |
+
/**
|
82 |
+
*
|
83 |
+
* @return boolean
|
84 |
+
*/
|
85 |
+
public function isDefault() {
|
86 |
+
return true;
|
87 |
+
}
|
88 |
+
|
89 |
/**
|
90 |
*
|
91 |
* @return type
|
Application/Core/Subject/Role.php
CHANGED
@@ -202,4 +202,12 @@ class AAM_Core_Subject_Role extends AAM_Core_Subject {
|
|
202 |
return AAM_Core_API::maxLevel($this->capabilities);
|
203 |
}
|
204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
}
|
202 |
return AAM_Core_API::maxLevel($this->capabilities);
|
203 |
}
|
204 |
|
205 |
+
/**
|
206 |
+
*
|
207 |
+
* @return boolean
|
208 |
+
*/
|
209 |
+
public function isRole() {
|
210 |
+
return true;
|
211 |
+
}
|
212 |
+
|
213 |
}
|
Application/Core/Subject/User.php
CHANGED
@@ -333,4 +333,12 @@ class AAM_Core_Subject_User extends AAM_Core_Subject {
|
|
333 |
return AAM_Core_API::maxLevel($this->allcaps);
|
334 |
}
|
335 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
336 |
}
|
333 |
return AAM_Core_API::maxLevel($this->allcaps);
|
334 |
}
|
335 |
|
336 |
+
/**
|
337 |
+
*
|
338 |
+
* @return boolean
|
339 |
+
*/
|
340 |
+
public function isUser() {
|
341 |
+
return true;
|
342 |
+
}
|
343 |
+
|
344 |
}
|
Application/Core/Subject/Visitor.php
CHANGED
@@ -79,4 +79,12 @@ class AAM_Core_Subject_Visitor extends AAM_Core_Subject {
|
|
79 |
return __('Anonymous', AAM_KEY);
|
80 |
}
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
79 |
return __('Anonymous', AAM_KEY);
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
*
|
84 |
+
* @return boolean
|
85 |
+
*/
|
86 |
+
public function isVisitor() {
|
87 |
+
return true;
|
88 |
+
}
|
89 |
+
|
90 |
}
|
aam.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
Plugin Name: Advanced Access Manager
|
5 |
Description: All you need to manage access to your WordPress website
|
6 |
-
Version: 5.0.
|
7 |
Author: Vasyl Martyniuk <vasyl@vasyltech.com>
|
8 |
Author URI: https://vasyltech.com
|
9 |
|
3 |
/**
|
4 |
Plugin Name: Advanced Access Manager
|
5 |
Description: All you need to manage access to your WordPress website
|
6 |
+
Version: 5.0.5
|
7 |
Author: Vasyl Martyniuk <vasyl@vasyltech.com>
|
8 |
Author URI: https://vasyltech.com
|
9 |
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: vasyltech
|
|
3 |
Tags: access, role, user, capability, page access, post access, comments, 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.9.1
|
6 |
-
Stable tag: 5.0.
|
7 |
|
8 |
The most powerful access management plugin for WordPress websites.
|
9 |
|
@@ -60,6 +60,10 @@ https://www.youtube.com/watch?v=yiOhjaacNJc
|
|
60 |
|
61 |
== Changelog ==
|
62 |
|
|
|
|
|
|
|
|
|
63 |
= 5.0.4 =
|
64 |
* Fixed bug with caching. Significantly improved speed.
|
65 |
* Fixed incompatibility issue with websites that have corrupted role list.
|
3 |
Tags: access, role, user, capability, page access, post access, comments, 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.9.1
|
6 |
+
Stable tag: 5.0.5
|
7 |
|
8 |
The most powerful access management plugin for WordPress websites.
|
9 |
|
60 |
|
61 |
== Changelog ==
|
62 |
|
63 |
+
= 5.0.5 =
|
64 |
+
* Enhanced Admin Menu feature
|
65 |
+
* Extended AAM API. Preparing it for developers to use.
|
66 |
+
|
67 |
= 5.0.4 =
|
68 |
* Fixed bug with caching. Significantly improved speed.
|
69 |
* Fixed incompatibility issue with websites that have corrupted role list.
|