Advanced Access Manager - Version 5.0

Version Description

  • Added ACCESS COUNTER option to Posts & Pages
  • Added premium MONETIZE option to Posts & Pages
  • Added ability to turn off "Secure Login" feature
  • Added ability to toggle extension status (active/inactive)
  • Added ability for AAM to filter out Admin Top Bar based on restricted admin menus
  • Deprecated AAM Role Filter extension and merged it to the AAM core
  • Deprecated AAM Payment extension and merged it with AAM E-Commerce extension
  • Deprecated ConfigPress options that manage access to AAM UI. All is based on capabilities from now.
  • Split UI to three areas: Access, Settings and Extensions
  • Fixed over 25+ reported bugs and discovered during internal refactoring
  • Removed deprecated "Security" feature. Replaced with Secure Login Widget
  • Removed deprecated "Teaser" feature. Replaced with Teaser Message per post base
Download this release

Release Info

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

Code changes from version 4.9.5.2 to 5.0

Files changed (87) hide show
  1. Application/Backend/Authorization.php +296 -0
  2. Application/Backend/Feature.php +26 -7
  3. Application/Backend/Feature/Abstract.php +4 -20
  4. Application/Backend/Feature/Contact.php +0 -63
  5. Application/Backend/Feature/{Extension.php → Extension/Manager.php} +39 -52
  6. Application/Backend/Feature/{404Redirect.php → Main/404Redirect.php} +8 -19
  7. Application/Backend/Feature/{Capability.php → Main/Capability.php} +24 -33
  8. Application/Backend/Feature/{LoginRedirect.php → Main/LoginRedirect.php} +12 -24
  9. Application/Backend/Feature/{LogoutRedirect.php → Main/LogoutRedirect.php} +12 -24
  10. Application/Backend/Feature/{Menu.php → Main/Menu.php} +25 -41
  11. Application/Backend/Feature/{Metabox.php → Main/Metabox.php} +34 -30
  12. Application/Backend/Feature/{Post.php → Main/Post.php} +111 -35
  13. Application/Backend/Feature/{Redirect.php → Main/Redirect.php} +16 -26
  14. Application/Backend/Feature/Security.php +0 -62
  15. Application/Backend/Feature/Settings/Content.php +69 -0
  16. Application/Backend/Feature/Settings/Core.php +84 -0
  17. Application/Backend/Feature/Settings/Manager.php +34 -0
  18. Application/Backend/Feature/Settings/Tools.php +109 -0
  19. Application/Backend/Feature/{Role.php → Subject/Role.php} +11 -11
  20. Application/Backend/Feature/{User.php → Subject/User.php} +12 -8
  21. Application/Backend/Feature/Teaser.php +0 -98
  22. Application/Backend/Feature/Utility.php +0 -178
  23. Application/Backend/Filter.php +240 -320
  24. Application/Backend/Manager.php +124 -108
  25. Application/Backend/Subject.php +172 -0
  26. Application/Backend/View.php +32 -93
  27. Application/Backend/View/CodePinch.php +0 -151
  28. Application/Backend/View/Helper.php +0 -13
  29. Application/Backend/View/Localization.php +62 -44
  30. Application/Backend/View/PostOptionList.php +99 -78
  31. Application/Backend/View/SecurityOptionList.php +0 -26
  32. Application/Backend/View/UtilityOptionList.php +0 -59
  33. Application/Backend/phtml/contact.phtml +0 -18
  34. Application/Backend/phtml/{extension.phtml → extensions.phtml} +26 -29
  35. Application/Backend/phtml/frame.phtml +23 -28
  36. Application/Backend/phtml/index.phtml +46 -27
  37. Application/Backend/phtml/main-panel.phtml +7 -6
  38. Application/Backend/phtml/{404redirect.phtml → main/404redirect.phtml} +16 -10
  39. Application/Backend/phtml/{object → main}/capability.phtml +4 -4
  40. Application/Backend/phtml/{object → main}/login-redirect.phtml +12 -12
  41. Application/Backend/phtml/{object → main}/logout-redirect.phtml +11 -11
  42. Application/Backend/phtml/{object → main}/menu.phtml +15 -8
  43. Application/Backend/phtml/{object → main}/metabox.phtml +16 -5
  44. Application/Backend/phtml/{object → main}/post.phtml +15 -12
  45. Application/Backend/phtml/{object → main}/redirect.phtml +2 -2
  46. Application/Backend/phtml/object/teaser.phtml +0 -41
  47. Application/Backend/phtml/partial/post-advanced-settings.phtml +60 -15
  48. Application/Backend/phtml/partial/teaser.phtml +0 -5
  49. Application/Backend/phtml/security.phtml +0 -7
  50. Application/Backend/phtml/settings/content.phtml +21 -0
  51. Application/Backend/phtml/settings/core.phtml +21 -0
  52. Application/Backend/phtml/settings/tools.phtml +74 -0
  53. Application/Backend/phtml/utility.phtml +0 -148
  54. Application/Core/API.php +55 -19
  55. Application/Core/Cache.php +6 -5
  56. Application/Core/Compatibility.php +1 -0
  57. Application/Core/Console.php +32 -17
  58. Application/Core/Object/LoginRedirect.php +1 -1
  59. Application/Core/Object/LogoutRedirect.php +1 -1
  60. Application/Core/Object/Menu.php +2 -2
  61. Application/Core/Object/Redirect.php +1 -1
  62. Application/Core/Object/Teaser.php +0 -124
  63. Application/Core/Server.php +5 -14
  64. Application/Core/Subject.php +16 -0
  65. Application/Core/Subject/Default.php +8 -0
  66. Application/Core/Subject/Role.php +16 -0
  67. Application/Core/Subject/User.php +40 -1
  68. Application/Core/Subject/Visitor.php +8 -0
  69. Application/Extension/List.php +84 -76
  70. Application/Extension/Repository.php +103 -40
  71. Application/Frontend/Authorization.php +193 -0
  72. Application/Frontend/Filter.php +348 -0
  73. Application/Frontend/Manager.php +36 -432
  74. Lang/advanced-access-manager-en_US.mo +0 -0
  75. Lang/advanced-access-manager-en_US.po +620 -626
  76. Lang/advanced-access-manager.pot +620 -626
  77. aam.php +11 -29
  78. autoloader.php +12 -4
  79. media/css/aam.css +40 -47
  80. media/font/fontello.eot +0 -0
  81. media/font/fontello.svg +8 -0
  82. media/font/fontello.ttf +0 -0
  83. media/font/fontello.woff +0 -0
  84. media/font/fontello.woff2 +0 -0
  85. media/js/aam.js +308 -320
  86. media/js/vendor.js +5 -1
  87. readme.txt +40 -69
Application/Backend/Authorization.php ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 authorization
12
+ *
13
+ * @package AAM
14
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
+ */
16
+ class AAM_Backend_Authorization {
17
+
18
+ /**
19
+ * Instance of itself
20
+ *
21
+ * @var AAM_Backend_Authorization
22
+ *
23
+ * @access private
24
+ */
25
+ private static $_instance = null;
26
+
27
+ /**
28
+ * Constructor
29
+ *
30
+ * @return void
31
+ *
32
+ * @access protected
33
+ */
34
+ protected function __construct() {
35
+ //control admin area
36
+ add_action('admin_init', array($this, 'checkScreenAccess'));
37
+
38
+ //additional filter for user capabilities
39
+ add_filter('user_has_cap', array($this, 'isUserCapable'), 999, 3);
40
+
41
+ //post access
42
+ add_action('admin_action_edit', array($this, 'checkEditAccess'));
43
+ }
44
+
45
+ /**
46
+ * Check screen access
47
+ *
48
+ * @return void
49
+ *
50
+ * @access public
51
+ * @global string $plugin_page
52
+ */
53
+ public function checkScreenAccess() {
54
+ global $plugin_page;
55
+
56
+ //compile menu
57
+ $menu = $plugin_page;
58
+
59
+ if (empty($menu)){
60
+ $menu = basename(AAM_Core_Request::server('SCRIPT_NAME'));
61
+ $taxonomy = AAM_Core_Request::get('taxonomy');
62
+ $postType = AAM_Core_Request::get('post_type');
63
+ $page = AAM_Core_Request::get('page');
64
+
65
+ if (!empty($taxonomy)) {
66
+ $menu .= '?taxonomy=' . $taxonomy;
67
+ } elseif (!empty($postType)) {
68
+ $menu .= '?post_type=' . $postType;
69
+ } elseif (!empty($page)) {
70
+ $menu .= '?page=' . $page;
71
+ }
72
+ }
73
+
74
+ if (AAM::getUser()->getObject('menu')->has($menu, true)) {
75
+ AAM_Core_API::reject(
76
+ 'backend', array('hook' => 'access_backend_menu', 'id' => $menu)
77
+ );
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Check user capability
83
+ *
84
+ * This is a hack function that add additional layout on top of WordPress
85
+ * core functionality. Based on the capability passed in the $args array as
86
+ * "0" element, it performs additional check on user's capability to manage
87
+ * post.
88
+ *
89
+ * @param array $allCaps
90
+ * @param array $metaCaps
91
+ * @param array $args
92
+ *
93
+ * @return array
94
+ *
95
+ * @access public
96
+ */
97
+ public function isUserCapable($allCaps, $metaCaps, $args) {
98
+ global $post;
99
+
100
+ //check if current user is allowed to edit or delete user
101
+ if (in_array($args[0], array('edit_user', 'delete_user'))) {
102
+ $allCaps = $this->isAllowedToManagerUser($args[0], $allCaps, $metaCaps);
103
+ } elseif (isset($args[2]) && is_scalar($args[2])) { //make sure it is post ID
104
+ $allCaps = $this->isAllowedToManagerPost(
105
+ $args[0], $args[2], $allCaps, $metaCaps
106
+ );
107
+ } elseif (is_a($post, 'WP_Post')) {
108
+ if (in_array($args[0], array('publish_posts', 'publish_pages'))) {
109
+ $object = AAM::getUser()->getObject('post', $post->ID);
110
+
111
+ if (!$this->isAllowed('backend.publish', $object)) {
112
+ $allCaps = $this->restrictCapabilities($allCaps, $metaCaps);
113
+ }
114
+ }
115
+ }
116
+
117
+ return $allCaps;
118
+ }
119
+
120
+ /**
121
+ * Control Edit Post
122
+ *
123
+ * Make sure that current user does not have access to edit Post
124
+ *
125
+ * @return void
126
+ *
127
+ * @access public
128
+ */
129
+ public function checkEditAccess() {
130
+ $post = $this->getCurrentPost();
131
+
132
+ if (is_a($post, 'WP_Post')) {
133
+ $object = AAM::getUser()->getObject('post', $post->ID, $post);
134
+
135
+ if (!$this->isAllowed('backend.edit', $object)) {
136
+ AAM_Core_API::reject(
137
+ 'backend',
138
+ array(
139
+ 'hook' => 'post_edit',
140
+ 'action' => 'backend.edit',
141
+ 'post' => $post
142
+ )
143
+ );
144
+ }
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Get Post ID
150
+ *
151
+ * Replication of the same mechanism that is in wp-admin/post.php
152
+ *
153
+ * @return WP_Post|null
154
+ *
155
+ * @access public
156
+ */
157
+ protected function getCurrentPost() {
158
+ $post = null;
159
+
160
+ if (get_post()) {
161
+ $post = get_post();
162
+ } elseif ($post_id = AAM_Core_Request::get('post')) {
163
+ $post = get_post($post_id);
164
+ } elseif ($post_id = AAM_Core_Request::get('post_ID')) {
165
+ $post = get_post($post_id);
166
+ }
167
+
168
+ return $post;
169
+ }
170
+
171
+ /**
172
+ * Check if current user is allowed to manager specified user
173
+ *
174
+ * @param int $id
175
+ * @param array $allcaps
176
+ * @param array $metacaps
177
+ *
178
+ * @return array
179
+ *
180
+ * @access protected
181
+ */
182
+ protected function isAllowedToManagerUser($id, $allcaps, $metacaps) {
183
+ $user = new WP_User($id);
184
+
185
+ //current user max level
186
+ $cuserLevel = AAM_Core_API::maxLevel(AAM::getUser()->allcaps);
187
+ //userLevel
188
+ $userLevel = AAM_Core_API::maxLevel($user->allcaps);
189
+
190
+ if ($cuserLevel < $userLevel) {
191
+ $allcaps = $this->restrictCapabilities($allcaps, $metacaps);
192
+ }
193
+
194
+ return $allcaps;
195
+ }
196
+
197
+ /**
198
+ * Check if current user is allowed to manage post
199
+ *
200
+ * @param string $cap
201
+ * @param int $id
202
+ * @param array $allcaps
203
+ * @param array $metacaps
204
+ *
205
+ * @return array
206
+ *
207
+ * @access protected
208
+ */
209
+ protected function isAllowedToManagerPost($cap, $id, $allcaps, $metacaps) {
210
+ if ($cap == 'edit_post') {
211
+ $object = AAM::getUser()->getObject('post', $id);
212
+ $draft = $object->post_status == 'auto-draft';
213
+
214
+ if (!$draft && !$this->isAllowed('backend.edit', $object)) {
215
+ $allcaps = $this->restrictCapabilities($allcaps, $metacaps);
216
+ }
217
+ } elseif ($cap == 'delete_post') {
218
+ $object = AAM::getUser()->getObject('post', $id);
219
+ if (!$this->isAllowed('backend.delete', $object)) {
220
+ $allcaps = $this->restrictCapabilities($allcaps, $metacaps);
221
+ }
222
+ }
223
+
224
+ return $allcaps;
225
+ }
226
+
227
+ /**
228
+ * Check if action is allowed
229
+ *
230
+ * This method will take in consideration also *_others action
231
+ *
232
+ * @param string $action
233
+ * @param AAM_Core_Object_Post $object
234
+ *
235
+ * @return boolean
236
+ *
237
+ * @access protected
238
+ */
239
+ protected function isAllowed($action, $object) {
240
+ $edit = $object->has($action);
241
+ $others = $object->has("{$action}_others");
242
+ $author = ($object->post_author == get_current_user_id());
243
+
244
+ return ($edit || ($others && !$author)) ? false : true;
245
+ }
246
+
247
+ /**
248
+ * Restrict user capabilities
249
+ *
250
+ * Iterate through the list of meta capabilities and disable them in the
251
+ * list of all user capabilities. Keep in mind that this disable caps only
252
+ * for one time call.
253
+ *
254
+ * @param array $allCaps
255
+ * @param array $metaCaps
256
+ *
257
+ * @return array
258
+ *
259
+ * @access protected
260
+ */
261
+ protected function restrictCapabilities($allCaps, $metaCaps) {
262
+ foreach($metaCaps as $cap) {
263
+ $allCaps[$cap] = false;
264
+ }
265
+
266
+ return $allCaps;
267
+ }
268
+
269
+ /**
270
+ * Alias for the bootstrap
271
+ *
272
+ * @return AAM_Backend_Authorization
273
+ *
274
+ * @access public
275
+ * @static
276
+ */
277
+ public static function getInstance() {
278
+ return self::bootstrap();
279
+ }
280
+
281
+ /**
282
+ * Bootstrap authorization layer
283
+ *
284
+ * @return AAM_Backend_Authorization
285
+ *
286
+ * @access public
287
+ */
288
+ public static function bootstrap() {
289
+ if (is_null(self::$_instance)) {
290
+ self::$_instance = new self;
291
+ }
292
+
293
+ return self::$_instance;
294
+ }
295
+
296
+ }
Application/Backend/Feature.php CHANGED
@@ -7,6 +7,14 @@
7
  * ======================================================================
8
  */
9
 
 
 
 
 
 
 
 
 
10
  class AAM_Backend_Feature {
11
 
12
  /**
@@ -33,7 +41,7 @@ class AAM_Backend_Feature {
33
  $response = false;
34
 
35
  if (empty($feature->capability)){
36
- $cap = AAM_Backend_View::getAAMCapability();
37
  } else {
38
  $cap = $feature->capability;
39
  }
@@ -53,9 +61,16 @@ class AAM_Backend_Feature {
53
  }
54
 
55
  /**
 
 
 
 
 
 
56
  *
57
- * @param type $options
58
- * @return type
 
59
  */
60
  protected static function isVisible($options) {
61
  $count = 0;
@@ -89,18 +104,22 @@ class AAM_Backend_Feature {
89
  * Retrieve list of features
90
  *
91
  * Retrieve sorted list of featured based on current subject
 
 
92
  *
93
  * @return array
94
  *
95
  * @access public
96
  * @static
97
  */
98
- public static function retriveList() {
99
  $response = array();
100
 
101
- $subject = AAM_Backend_View::getSubject();
102
  foreach (self::$_features as $feature) {
103
- if (in_array(get_class($subject), $feature->subjects)) {
 
 
104
  $response[] = self::initView($feature);
105
  }
106
  }
@@ -110,7 +129,7 @@ class AAM_Backend_Feature {
110
  }
111
 
112
  /**
113
- * Order list of features or subjectes
114
  *
115
  * Reorganize the list based on "position" attribute
116
  *
7
  * ======================================================================
8
  */
9
 
10
+ /**
11
+ * AAM Backend Feature
12
+ *
13
+ * This class is used to hold the list of all registered UI features with few neat
14
+ * methods to manipulate it.
15
+ *
16
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
17
+ */
18
  class AAM_Backend_Feature {
19
 
20
  /**
41
  $response = false;
42
 
43
  if (empty($feature->capability)){
44
+ $cap = 'aam_manager';
45
  } else {
46
  $cap = $feature->capability;
47
  }
61
  }
62
 
63
  /**
64
+ * Check if feature is visible
65
+ *
66
+ * There is a way to show/hide feature based on the option. For example some
67
+ * features should be visible only when Backend Access options is enabled.
68
+ *
69
+ * @param string $options
70
  *
71
+ * @return boolean
72
+ *
73
+ * @access protected
74
  */
75
  protected static function isVisible($options) {
76
  $count = 0;
104
  * Retrieve list of features
105
  *
106
  * Retrieve sorted list of featured based on current subject
107
+ *
108
+ * @param string $type
109
  *
110
  * @return array
111
  *
112
  * @access public
113
  * @static
114
  */
115
+ public static function retriveList($type) {
116
  $response = array();
117
 
118
+ $subject = AAM_Backend_Subject::getInstance()->getUID();
119
  foreach (self::$_features as $feature) {
120
+ $ftype = (!empty($feature->type) ? $feature->type : 'main'); //TODO - legacy Nov 2018
121
+ if ($ftype == $type
122
+ && (empty($feature->subjects) || in_array($subject, $feature->subjects))) {
123
  $response[] = self::initView($feature);
124
  }
125
  }
129
  }
130
 
131
  /**
132
+ * Order list of features
133
  *
134
  * Reorganize the list based on "position" attribute
135
  *
Application/Backend/Feature/Abstract.php CHANGED
@@ -24,12 +24,10 @@ abstract class AAM_Backend_Feature_Abstract {
24
  * @throws Exception
25
  */
26
  public function __construct() {
27
- if (is_admin()) {
28
- $capability = AAM_Backend_View::getAAMCapability();
29
-
30
- if (!AAM::getUser()->hasCapability($capability)) {
31
- wp_die(__('Access Denied', AAM_KEY));
32
- }
33
  }
34
  }
35
 
@@ -49,20 +47,6 @@ abstract class AAM_Backend_Feature_Abstract {
49
  return $content;
50
  }
51
 
52
- /**
53
- * Get access option
54
- *
55
- * This function exists only to support implementation for PHP 5.2 cause later
56
- * static binding has been introduced only in PHP 5.3.0
57
- *
58
- * @return string
59
- *
60
- * @access public
61
- */
62
- public static function getAccessOption() {
63
- return '';
64
- }
65
-
66
  /**
67
  * Get template filename
68
  *
24
  * @throws Exception
25
  */
26
  public function __construct() {
27
+ if (!AAM::getUser()->hasCapability('aam_manager')) {
28
+ AAM_Core_API::reject(
29
+ 'backend', array('hook' => 'aam_manager')
30
+ );
 
 
31
  }
32
  }
33
 
47
  return $content;
48
  }
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  /**
51
  * Get template filename
52
  *
Application/Backend/Feature/Contact.php DELETED
@@ -1,63 +0,0 @@
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 contact/hire manager
12
- *
13
- * @package AAM
14
- * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
- */
16
- class AAM_Backend_Feature_Contact extends AAM_Backend_Feature_Abstract {
17
-
18
- /**
19
- * @inheritdoc
20
- */
21
- public static function getAccessOption() {
22
- return 'feature.contact.capability';
23
- }
24
-
25
- /**
26
- * @inheritdoc
27
- */
28
- public static function getTemplate() {
29
- return 'contact.phtml';
30
- }
31
-
32
- /**
33
- * Register Contact/Hire feature
34
- *
35
- * @return void
36
- *
37
- * @access public
38
- */
39
- public static function register() {
40
- if (AAM_Core_API::capabilityExists('aam_view_contact')) {
41
- $cap = 'aam_view_contact';
42
- } else {
43
- $cap = AAM_Core_Config::get(
44
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
45
- );
46
- }
47
-
48
- AAM_Backend_Feature::registerFeature((object) array(
49
- 'uid' => 'contact',
50
- 'position' => 9999,
51
- 'title' => __('Contact Us', AAM_KEY),
52
- 'capability' => $cap,
53
- 'subjects' => array(
54
- 'AAM_Core_Subject_Role',
55
- 'AAM_Core_Subject_User',
56
- 'AAM_Core_Subject_Visitor',
57
- 'AAM_Core_Subject_Default'
58
- ),
59
- 'view' => __CLASS__
60
- ));
61
- }
62
-
63
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Backend/Feature/{Extension.php → Extension/Manager.php} RENAMED
@@ -13,22 +13,21 @@
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
- class AAM_Backend_Feature_Extension extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
- * @inheritdoc
 
20
  */
21
- public static function getAccessOption() {
22
- return 'feature.extension.capability';
23
- }
24
 
25
  /**
26
- * @inheritdoc
27
  */
28
- public static function getTemplate() {
29
- return 'extension.phtml';
30
  }
31
-
32
  /**
33
  * Undocumented function
34
  *
@@ -112,6 +111,32 @@ class AAM_Backend_Feature_Extension extends AAM_Backend_Feature_Abstract {
112
  return $response;
113
  }
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  /**
116
  *
117
  * @param type $type
@@ -166,53 +191,15 @@ class AAM_Backend_Feature_Extension extends AAM_Backend_Feature_Abstract {
166
  }
167
 
168
  /**
169
- * Register Extension feature
170
- *
171
- * @return void
172
  *
173
- * @access public
174
  */
175
- public static function register() {
176
- if (is_main_site()) {
177
- if (AAM_Core_API::capabilityExists('aam_manage_extensions')) {
178
- $cap = 'aam_manage_extensions';
179
- } else {
180
- $cap = AAM_Core_Config::get(
181
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
182
- );
183
- }
184
- $updated = self::hasUpdates();
185
-
186
- AAM_Backend_Feature::registerFeature((object) array(
187
- 'uid' => 'extension',
188
- 'position' => 999,
189
- 'title' => __('Extensions', AAM_KEY),
190
- 'capability' => $cap,
191
- 'class' => 'highlight',
192
- 'notification' => ($updated ? $updated : 'NEW'),
193
- 'subjects' => array(
194
- 'AAM_Core_Subject_Role',
195
- 'AAM_Core_Subject_User',
196
- 'AAM_Core_Subject_Visitor',
197
- 'AAM_Core_Subject_Default',
198
- ),
199
- 'view' => __CLASS__
200
- ));
201
- }
202
- }
203
-
204
- /**
205
- *
206
- * @return type
207
- */
208
- protected static function hasUpdates() {
209
- $updates = 0;
210
-
211
- foreach(AAM_Extension_Repository::getInstance()->getList() as $item) {
212
- $updates += ($item['status'] == AAM_Extension_Repository::STATUS_UPDATE);
213
  }
214
 
215
- return $updates;
216
  }
217
 
218
  }
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Extension_Manager extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
+ *
20
+ * @var type
21
  */
22
+ protected static $instance = null;
 
 
23
 
24
  /**
25
+ *
26
  */
27
+ public function render() {
28
+ require_once(dirname(__FILE__) . '/../../phtml/extensions.phtml');
29
  }
30
+
31
  /**
32
  * Undocumented function
33
  *
111
  return $response;
112
  }
113
 
114
+ /**
115
+ *
116
+ * @return type
117
+ */
118
+ public function deactivate() {
119
+ AAM_Extension_Repository::getInstance()->updateStatus(
120
+ AAM_Core_Request::post('extension'),
121
+ AAM_Extension_Repository::STATUS_INACTIVE
122
+ );
123
+
124
+ return json_encode(array('status' => 'success'));
125
+ }
126
+
127
+ /**
128
+ *
129
+ * @return type
130
+ */
131
+ public function activate() {
132
+ AAM_Extension_Repository::getInstance()->updateStatus(
133
+ AAM_Core_Request::post('extension'),
134
+ AAM_Extension_Repository::STATUS_INSTALLED
135
+ );
136
+
137
+ return json_encode(array('status' => 'success'));
138
+ }
139
+
140
  /**
141
  *
142
  * @param type $type
191
  }
192
 
193
  /**
 
 
 
194
  *
195
+ * @return AAM_Backend_Feature_Extension_Manager
196
  */
197
+ public static function getInstance() {
198
+ if (is_null(self::$instance)) {
199
+ self::$instance = new self;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  }
201
 
202
+ return self::$instance;
203
  }
204
 
205
  }
Application/Backend/Feature/{404Redirect.php → Main/404Redirect.php} RENAMED
@@ -13,20 +13,13 @@
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
  /**
@@ -54,21 +47,17 @@ class AAM_Backend_Feature_404Redirect extends AAM_Backend_Feature_Abstract {
54
  */
55
  public static function register() {
56
  if (is_main_site()) {
57
- if (AAM_Core_API::capabilityExists('aam_manage_404_redirect')) {
58
- $cap = 'aam_manage_404_redirect';
59
- } else {
60
- $cap = AAM_Core_Config::get(
61
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
62
- );
63
- }
64
-
65
  AAM_Backend_Feature::registerFeature((object) array(
66
  'uid' => '404redirect',
67
  'position' => 50,
68
  'title' => __('404 Redirect', AAM_KEY),
69
- 'capability' => $cap,
 
70
  'subjects' => array(
71
- 'AAM_Core_Subject_Default'
 
 
 
72
  ),
73
  'view' => __CLASS__
74
  ));
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Main_404Redirect extends AAM_Backend_Feature_Abstract {
 
 
 
 
 
 
 
17
 
18
  /**
19
  * @inheritdoc
20
  */
21
  public static function getTemplate() {
22
+ return 'main/404redirect.phtml';
23
  }
24
 
25
  /**
47
  */
48
  public static function register() {
49
  if (is_main_site()) {
 
 
 
 
 
 
 
 
50
  AAM_Backend_Feature::registerFeature((object) array(
51
  'uid' => '404redirect',
52
  'position' => 50,
53
  'title' => __('404 Redirect', AAM_KEY),
54
+ 'capability' => 'aam_manage_404_redirect',
55
+ 'type' => 'main',
56
  'subjects' => array(
57
+ AAM_Core_Subject_Default::UID,
58
+ AAM_Core_Subject_Role::UID,
59
+ AAM_Core_Subject_User::UID,
60
+ AAM_Core_Subject_Visitor::UID
61
  ),
62
  'view' => __CLASS__
63
  ));
Application/Backend/Feature/{Capability.php → Main/Capability.php} RENAMED
@@ -13,7 +13,7 @@
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
- class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  * Capability groups
@@ -21,8 +21,9 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
21
  * @var array
22
  *
23
  * @access private
 
24
  */
25
- private $_groups = array(
26
  'system' => array(
27
  'level_0', 'level_1', 'level_2', 'level_3', 'level_4', 'level_5',
28
  'level_6', 'level_7', 'level_8', 'level_9', 'level_10'
@@ -50,10 +51,11 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
50
  'aam_manage_admin_menu', 'aam_manage_metaboxes', 'aam_manage_capabilities',
51
  'aam_manage_posts', 'aam_manage_access_denied_redirect', 'aam_create_roles',
52
  'aam_manage_login_redirect', 'aam_manage_logout_redirect', 'aam_manager',
53
- 'aam_manage_content_teaser', 'aam_manage_security', 'aam_manage_utilities',
54
- 'aam_manage_extensions', 'aam_view_contact', 'aam_manage_404_redirect',
55
  'aam_manage_default', 'aam_manage_visitors', 'aam_list_roles',
56
- 'aam_edit_roles', 'aam_delete_roles', 'aam_toggle_users', 'aam_switch_users'
 
57
  )
58
  );
59
 
@@ -112,9 +114,9 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
112
  public function delete() {
113
  $capability = AAM_Core_Request::post('capability');
114
  $roles = AAM_Core_API::getRoles();
115
- $subject = AAM_Backend_View::getSubject();
116
 
117
- if (is_a($subject, 'AAM_Core_Subject_Role')) {
118
  foreach($roles->role_objects as $role) {
119
  $role->remove_cap($capability);
120
  }
@@ -129,18 +131,11 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
129
  return json_encode($response);
130
  }
131
 
132
- /**
133
- * @inheritdoc
134
- */
135
- public static function getAccessOption() {
136
- return 'feature.capability.capability';
137
- }
138
-
139
  /**
140
  * @inheritdoc
141
  */
142
  public static function getTemplate() {
143
- return 'object/capability.phtml';
144
  }
145
 
146
  /**
@@ -149,14 +144,14 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
149
  * @return type
150
  */
151
  protected function prepareActionList($cap) {
152
- $subject = AAM_Backend_View::getSubject();
153
  $actions = array();
154
 
155
  $actions[] = ($subject->hasCapability($cap) ? 'checked' : 'unchecked');
156
 
157
  //allow to delete or update capability only for roles!
158
  if (AAM_Core_Config::get('manage-capability', false)
159
- && is_a($subject, 'AAM_Core_Subject_Role')) {
160
  $actions[] = 'edit';
161
  $actions[] = 'delete';
162
  }
@@ -241,7 +236,7 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
241
  if ($capability) {
242
  //add the capability to administrator's role as default behavior
243
  AAM_Core_API::getRoles()->add_cap('administrator', $capability);
244
- AAM_Backend_View::getSubject()->addCapability($capability);
245
  $response = array('status' => 'success');
246
  } else {
247
  $response = array('status' => 'failure');
@@ -260,13 +255,13 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
260
  * @access protected
261
  */
262
  protected function getGroup($capability) {
263
- if (in_array($capability, $this->_groups['system'])) {
264
  $response = __('System', AAM_KEY);
265
- } elseif (in_array($capability, $this->_groups['post'])) {
266
  $response = __('Posts & Pages', AAM_KEY);
267
- } elseif (in_array($capability, $this->_groups['backend'])) {
268
  $response = __('Backend', AAM_KEY);
269
- } elseif (in_array($capability, $this->_groups['aam'])) {
270
  $response = __('AAM Interface', AAM_KEY);
271
  } else {
272
  $response = __('Miscellaneous', AAM_KEY);
@@ -285,7 +280,7 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
285
  * @access protected
286
  */
287
  protected function isOverwritten() {
288
- $object = AAM_Backend_View::getSubject()->getObject('capability');
289
 
290
  return $object->isOverwritten();
291
  }
@@ -298,20 +293,16 @@ class AAM_Backend_Feature_Capability extends AAM_Backend_Feature_Abstract {
298
  * @access public
299
  */
300
  public static function register() {
301
- if (AAM_Core_API::capabilityExists('aam_manage_capabilities')) {
302
- $cap = 'aam_manage_capabilities';
303
- } else {
304
- $cap = AAM_Core_Config::get(
305
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
306
- );
307
- }
308
-
309
  AAM_Backend_Feature::registerFeature((object) array(
310
  'uid' => 'capability',
311
  'position' => 15,
312
  'title' => __('Capabilities', AAM_KEY),
313
- 'capability' => $cap,
314
- 'subjects' => array('AAM_Core_Subject_Role', 'AAM_Core_Subject_User'),
 
 
 
 
315
  'view' => __CLASS__
316
  ));
317
  }
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Main_Capability extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  * Capability groups
21
  * @var array
22
  *
23
  * @access private
24
+ * @todo Move this to the Object_Capability
25
  */
26
+ public static $groups = array(
27
  'system' => array(
28
  'level_0', 'level_1', 'level_2', 'level_3', 'level_4', 'level_5',
29
  'level_6', 'level_7', 'level_8', 'level_9', 'level_10'
51
  'aam_manage_admin_menu', 'aam_manage_metaboxes', 'aam_manage_capabilities',
52
  'aam_manage_posts', 'aam_manage_access_denied_redirect', 'aam_create_roles',
53
  'aam_manage_login_redirect', 'aam_manage_logout_redirect', 'aam_manager',
54
+ 'aam_manage_settings', 'aam_manage_extensions', 'aam_show_notifications',
55
+ 'aam_manage_404_redirect', 'aam_manage_ip_check',
56
  'aam_manage_default', 'aam_manage_visitors', 'aam_list_roles',
57
+ 'aam_edit_roles', 'aam_delete_roles', 'aam_toggle_users', 'aam_switch_users',
58
+ 'aam_manage_configpress'
59
  )
60
  );
61
 
114
  public function delete() {
115
  $capability = AAM_Core_Request::post('capability');
116
  $roles = AAM_Core_API::getRoles();
117
+ $subject = AAM_Backend_Subject::getInstance();
118
 
119
+ if ($subject->getUID() == AAM_Core_Subject_Role::UID) {
120
  foreach($roles->role_objects as $role) {
121
  $role->remove_cap($capability);
122
  }
131
  return json_encode($response);
132
  }
133
 
 
 
 
 
 
 
 
134
  /**
135
  * @inheritdoc
136
  */
137
  public static function getTemplate() {
138
+ return 'main/capability.phtml';
139
  }
140
 
141
  /**
144
  * @return type
145
  */
146
  protected function prepareActionList($cap) {
147
+ $subject = AAM_Backend_Subject::getInstance();
148
  $actions = array();
149
 
150
  $actions[] = ($subject->hasCapability($cap) ? 'checked' : 'unchecked');
151
 
152
  //allow to delete or update capability only for roles!
153
  if (AAM_Core_Config::get('manage-capability', false)
154
+ && ($subject->getUID() == AAM_Core_Subject_Role::UID)) {
155
  $actions[] = 'edit';
156
  $actions[] = 'delete';
157
  }
236
  if ($capability) {
237
  //add the capability to administrator's role as default behavior
238
  AAM_Core_API::getRoles()->add_cap('administrator', $capability);
239
+ AAM_Backend_Subject::getInstance()->addCapability($capability);
240
  $response = array('status' => 'success');
241
  } else {
242
  $response = array('status' => 'failure');
255
  * @access protected
256
  */
257
  protected function getGroup($capability) {
258
+ if (in_array($capability, self::$groups['system'])) {
259
  $response = __('System', AAM_KEY);
260
+ } elseif (in_array($capability, self::$groups['post'])) {
261
  $response = __('Posts & Pages', AAM_KEY);
262
+ } elseif (in_array($capability, self::$groups['backend'])) {
263
  $response = __('Backend', AAM_KEY);
264
+ } elseif (in_array($capability, self::$groups['aam'])) {
265
  $response = __('AAM Interface', AAM_KEY);
266
  } else {
267
  $response = __('Miscellaneous', AAM_KEY);
280
  * @access protected
281
  */
282
  protected function isOverwritten() {
283
+ $object = AAM_Backend_Subject::getInstance()->getObject('capability');
284
 
285
  return $object->isOverwritten();
286
  }
293
  * @access public
294
  */
295
  public static function register() {
 
 
 
 
 
 
 
 
296
  AAM_Backend_Feature::registerFeature((object) array(
297
  'uid' => 'capability',
298
  'position' => 15,
299
  'title' => __('Capabilities', AAM_KEY),
300
+ 'capability' => 'aam_manage_capabilities',
301
+ 'type' => 'main',
302
+ 'subjects' => array(
303
+ AAM_Core_Subject_Role::UID,
304
+ AAM_Core_Subject_User::UID
305
+ ),
306
  'view' => __CLASS__
307
  ));
308
  }
Application/Backend/Feature/{LoginRedirect.php → Main/LoginRedirect.php} RENAMED
@@ -13,14 +13,16 @@
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
- class AAM_Backend_Feature_LoginRedirect extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  *
20
  * @return type
21
  */
22
  public function isDefault() {
23
- return (AAM_Backend_View::getSubject()->getUID() == 'default');
 
 
24
  }
25
 
26
  /**
@@ -33,7 +35,7 @@ class AAM_Backend_Feature_LoginRedirect extends AAM_Backend_Feature_Abstract {
33
  * @access protected
34
  */
35
  protected function isOverwritten() {
36
- $object = AAM_Backend_View::getSubject()->getObject('loginRedirect');
37
 
38
  return $object->isOverwritten();
39
  }
@@ -44,24 +46,17 @@ class AAM_Backend_Feature_LoginRedirect extends AAM_Backend_Feature_Abstract {
44
  * @return type
45
  */
46
  public function getOption($option, $default = null) {
47
- $object = AAM_Backend_View::getSubject()->getObject('loginRedirect');
48
  $value = $object->get($option);
49
 
50
  return (!is_null($value) ? $value : $default);
51
  }
52
 
53
- /**
54
- * @inheritdoc
55
- */
56
- public static function getAccessOption() {
57
- return 'feature.login-redirect.capability';
58
- }
59
-
60
  /**
61
  * @inheritdoc
62
  */
63
  public static function getTemplate() {
64
- return 'object/login-redirect.phtml';
65
  }
66
 
67
  /**
@@ -72,23 +67,16 @@ class AAM_Backend_Feature_LoginRedirect extends AAM_Backend_Feature_Abstract {
72
  * @access public
73
  */
74
  public static function register() {
75
- if (AAM_Core_API::capabilityExists('aam_manage_login_redirect')) {
76
- $cap = 'aam_manage_login_redirect';
77
- } else {
78
- $cap = AAM_Core_Config::get(
79
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
80
- );
81
- }
82
-
83
  AAM_Backend_Feature::registerFeature((object) array(
84
  'uid' => 'login_redirect',
85
  'position' => 40,
86
  'title' => __('Login Redirect', AAM_KEY),
87
- 'capability' => $cap,
 
88
  'subjects' => array(
89
- 'AAM_Core_Subject_Role',
90
- 'AAM_Core_Subject_User',
91
- 'AAM_Core_Subject_Default'
92
  ),
93
  'view' => __CLASS__
94
  ));
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Main_LoginRedirect extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  *
20
  * @return type
21
  */
22
  public function isDefault() {
23
+ $subject = AAM_Backend_Subject::getInstance()->getUID();
24
+
25
+ return ($subject == AAM_Core_Subject_Default::UID);
26
  }
27
 
28
  /**
35
  * @access protected
36
  */
37
  protected function isOverwritten() {
38
+ $object = AAM_Backend_Subject::getInstance()->getObject('loginRedirect');
39
 
40
  return $object->isOverwritten();
41
  }
46
  * @return type
47
  */
48
  public function getOption($option, $default = null) {
49
+ $object = AAM_Backend_Subject::getInstance()->getObject('loginRedirect');
50
  $value = $object->get($option);
51
 
52
  return (!is_null($value) ? $value : $default);
53
  }
54
 
 
 
 
 
 
 
 
55
  /**
56
  * @inheritdoc
57
  */
58
  public static function getTemplate() {
59
+ return 'main/login-redirect.phtml';
60
  }
61
 
62
  /**
67
  * @access public
68
  */
69
  public static function register() {
 
 
 
 
 
 
 
 
70
  AAM_Backend_Feature::registerFeature((object) array(
71
  'uid' => 'login_redirect',
72
  'position' => 40,
73
  'title' => __('Login Redirect', AAM_KEY),
74
+ 'capability' => 'aam_manage_login_redirect',
75
+ 'type' => 'main',
76
  'subjects' => array(
77
+ AAM_Core_Subject_Role::UID,
78
+ AAM_Core_Subject_User::UID,
79
+ AAM_Core_Subject_Default::UID
80
  ),
81
  'view' => __CLASS__
82
  ));
Application/Backend/Feature/{LogoutRedirect.php → Main/LogoutRedirect.php} RENAMED
@@ -13,14 +13,16 @@
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
- class AAM_Backend_Feature_LogoutRedirect extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  *
20
  * @return type
21
  */
22
  public function isDefault() {
23
- return (AAM_Backend_View::getSubject()->getUID() == 'default');
 
 
24
  }
25
 
26
  /**
@@ -33,7 +35,7 @@ class AAM_Backend_Feature_LogoutRedirect extends AAM_Backend_Feature_Abstract {
33
  * @access protected
34
  */
35
  protected function isOverwritten() {
36
- $object = AAM_Backend_View::getSubject()->getObject('logoutRedirect');
37
 
38
  return $object->isOverwritten();
39
  }
@@ -44,24 +46,17 @@ class AAM_Backend_Feature_LogoutRedirect extends AAM_Backend_Feature_Abstract {
44
  * @return type
45
  */
46
  public function getOption($option, $default = null) {
47
- $object = AAM_Backend_View::getSubject()->getObject('logoutRedirect');
48
  $value = $object->get($option);
49
 
50
  return (!is_null($value) ? $value : $default);
51
  }
52
 
53
- /**
54
- * @inheritdoc
55
- */
56
- public static function getAccessOption() {
57
- return 'feature.logout-redirect.capability';
58
- }
59
-
60
  /**
61
  * @inheritdoc
62
  */
63
  public static function getTemplate() {
64
- return 'object/logout-redirect.phtml';
65
  }
66
 
67
  /**
@@ -72,23 +67,16 @@ class AAM_Backend_Feature_LogoutRedirect extends AAM_Backend_Feature_Abstract {
72
  * @access public
73
  */
74
  public static function register() {
75
- if (AAM_Core_API::capabilityExists('aam_manage_logout_redirect')) {
76
- $cap = 'aam_manage_logout_redirect';
77
- } else {
78
- $cap = AAM_Core_Config::get(
79
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
80
- );
81
- }
82
-
83
  AAM_Backend_Feature::registerFeature((object) array(
84
  'uid' => 'logout_redirect',
85
  'position' => 41,
86
  'title' => __('Logout Redirect', AAM_KEY),
87
- 'capability' => $cap,
 
88
  'subjects' => array(
89
- 'AAM_Core_Subject_Role',
90
- 'AAM_Core_Subject_User',
91
- 'AAM_Core_Subject_Default'
92
  ),
93
  'view' => __CLASS__
94
  ));
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Main_LogoutRedirect extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  *
20
  * @return type
21
  */
22
  public function isDefault() {
23
+ $subject = AAM_Backend_Subject::getInstance();
24
+
25
+ return ($subject->getUID() == 'default');
26
  }
27
 
28
  /**
35
  * @access protected
36
  */
37
  protected function isOverwritten() {
38
+ $object = AAM_Backend_Subject::getInstance()->getObject('logoutRedirect');
39
 
40
  return $object->isOverwritten();
41
  }
46
  * @return type
47
  */
48
  public function getOption($option, $default = null) {
49
+ $object = AAM_Backend_Subject::getInstance()->getObject('logoutRedirect');
50
  $value = $object->get($option);
51
 
52
  return (!is_null($value) ? $value : $default);
53
  }
54
 
 
 
 
 
 
 
 
55
  /**
56
  * @inheritdoc
57
  */
58
  public static function getTemplate() {
59
+ return 'main/logout-redirect.phtml';
60
  }
61
 
62
  /**
67
  * @access public
68
  */
69
  public static function register() {
 
 
 
 
 
 
 
 
70
  AAM_Backend_Feature::registerFeature((object) array(
71
  'uid' => 'logout_redirect',
72
  'position' => 41,
73
  'title' => __('Logout Redirect', AAM_KEY),
74
+ 'capability' => 'aam_manage_logout_redirect',
75
+ 'type' => 'main',
76
  'subjects' => array(
77
+ AAM_Core_Subject_Role::UID,
78
+ AAM_Core_Subject_User::UID,
79
+ AAM_Core_Subject_Default::UID
80
  ),
81
  'view' => __CLASS__
82
  ));
Application/Backend/Feature/{Menu.php → Main/Menu.php} RENAMED
@@ -13,7 +13,7 @@
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
- class AAM_Backend_Feature_Menu extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  * Undocumented function
@@ -24,7 +24,7 @@ class AAM_Backend_Feature_Menu extends AAM_Backend_Feature_Abstract {
24
  $items = AAM_Core_Request::post('items', array());
25
  $status = AAM_Core_Request::post('status');
26
 
27
- $object = AAM_Backend_View::getSubject()->getObject('menu');
28
 
29
  foreach($items as $item) {
30
  $object->save($item, $status);
@@ -57,7 +57,7 @@ class AAM_Backend_Feature_Menu extends AAM_Backend_Feature_Abstract {
57
 
58
  $submenu = $this->getSubmenu($item[2]);
59
 
60
- $allowed = AAM_Backend_View::getSubject()->hasCapability($item[1]);
61
 
62
  if ($allowed || count($submenu) > 0) {
63
  $response[] = array(
@@ -88,18 +88,11 @@ class AAM_Backend_Feature_Menu extends AAM_Backend_Feature_Abstract {
88
  return $menu;
89
  }
90
 
91
- /**
92
- * @inheritdoc
93
- */
94
- public static function getAccessOption() {
95
- return 'feature.admin_menu.capability';
96
- }
97
-
98
  /**
99
  * @inheritdoc
100
  */
101
  public static function getTemplate() {
102
- return 'object/menu.phtml';
103
  }
104
 
105
  /**
@@ -116,8 +109,8 @@ class AAM_Backend_Feature_Menu extends AAM_Backend_Feature_Abstract {
116
  global $submenu;
117
 
118
  $response = array();
119
- $subject = AAM_Backend_View::getSubject();
120
- $isDefault = is_a($subject, 'AAM_Core_Subject_Default');
121
 
122
  if (isset($submenu[$menu])) {
123
  foreach ($submenu[$menu] as $item) {
@@ -153,26 +146,24 @@ class AAM_Backend_Feature_Menu extends AAM_Backend_Feature_Abstract {
153
  }
154
 
155
  /**
156
- * Check if the entire menu branch is restricted
157
- *
158
- * @param array $menu
159
  *
 
 
160
  * @return boolean
161
- *
162
- * @access protected
163
  */
164
- protected function hasRestrictedAll($menu) {
165
- $object = AAM_Backend_View::getSubject()->getObject('menu');
166
- $response = $object->has($menu['id']);
167
-
168
- foreach ($menu['submenu'] as $submenu) {
169
- if ($object->has($submenu['id']) === false) {
170
- $response = false;
171
- break;
 
172
  }
173
  }
174
-
175
- return $response;
176
  }
177
 
178
  /**
@@ -185,7 +176,7 @@ class AAM_Backend_Feature_Menu extends AAM_Backend_Feature_Abstract {
185
  * @access protected
186
  */
187
  protected function isOverwritten() {
188
- $object = AAM_Backend_View::getSubject()->getObject('menu');
189
 
190
  return $object->isOverwritten();
191
  }
@@ -198,23 +189,16 @@ class AAM_Backend_Feature_Menu extends AAM_Backend_Feature_Abstract {
198
  * @access public
199
  */
200
  public static function register() {
201
- if (AAM_Core_API::capabilityExists('aam_manage_admin_menu')) {
202
- $cap = 'aam_manage_admin_menu';
203
- } else {
204
- $cap = AAM_Core_Config::get(
205
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
206
- );
207
- }
208
-
209
  AAM_Backend_Feature::registerFeature((object) array(
210
  'uid' => 'admin_menu',
211
  'position' => 5,
212
  'title' => __('Backend Menu', AAM_KEY),
213
- 'capability' => $cap,
 
214
  'subjects' => array(
215
- 'AAM_Core_Subject_Role',
216
- 'AAM_Core_Subject_User',
217
- 'AAM_Core_Subject_Default'
218
  ),
219
  'option' => 'backend-access-control',
220
  'view' => __CLASS__
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Main_Menu extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  * Undocumented function
24
  $items = AAM_Core_Request::post('items', array());
25
  $status = AAM_Core_Request::post('status');
26
 
27
+ $object = AAM_Backend_Subject::getInstance()->getObject('menu');
28
 
29
  foreach($items as $item) {
30
  $object->save($item, $status);
57
 
58
  $submenu = $this->getSubmenu($item[2]);
59
 
60
+ $allowed = AAM_Backend_Subject::getInstance()->hasCapability($item[1]);
61
 
62
  if ($allowed || count($submenu) > 0) {
63
  $response[] = array(
88
  return $menu;
89
  }
90
 
 
 
 
 
 
 
 
91
  /**
92
  * @inheritdoc
93
  */
94
  public static function getTemplate() {
95
+ return 'main/menu.phtml';
96
  }
97
 
98
  /**
109
  global $submenu;
110
 
111
  $response = array();
112
+ $subject = AAM_Backend_Subject::getInstance();
113
+ $isDefault = ($subject->getUID() == AAM_Core_Subject_Default::UID);
114
 
115
  if (isset($submenu[$menu])) {
116
  foreach ($submenu[$menu] as $item) {
146
  }
147
 
148
  /**
 
 
 
149
  *
150
+ * @param type $object
151
+ * @param type $subs
152
  * @return boolean
 
 
153
  */
154
+ protected function hasSubmenuChecked($object, $subs) {
155
+ $has = false;
156
+
157
+ if (!empty($subs)) {
158
+ foreach($subs as $submenu) {
159
+ if ($object->has($submenu['id'])) {
160
+ $has = true;
161
+ break;
162
+ }
163
  }
164
  }
165
+
166
+ return $has;
167
  }
168
 
169
  /**
176
  * @access protected
177
  */
178
  protected function isOverwritten() {
179
+ $object = AAM_Backend_Subject::getInstance()->getObject('menu');
180
 
181
  return $object->isOverwritten();
182
  }
189
  * @access public
190
  */
191
  public static function register() {
 
 
 
 
 
 
 
 
192
  AAM_Backend_Feature::registerFeature((object) array(
193
  'uid' => 'admin_menu',
194
  'position' => 5,
195
  'title' => __('Backend Menu', AAM_KEY),
196
+ 'capability' => 'aam_manage_admin_menu',
197
+ 'type' => 'main',
198
  'subjects' => array(
199
+ AAM_Core_Subject_Role::UID,
200
+ AAM_Core_Subject_User::UID,
201
+ AAM_Core_Subject_Default::UID
202
  ),
203
  'option' => 'backend-access-control',
204
  'view' => __CLASS__
Application/Backend/Feature/{Metabox.php → Main/Metabox.php} RENAMED
@@ -13,20 +13,13 @@
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
- class AAM_Backend_Feature_Metabox extends AAM_Backend_Feature_Abstract {
17
 
18
- /**
19
- * @inheritdoc
20
- */
21
- public static function getAccessOption() {
22
- return 'feature.metabox.capability';
23
- }
24
-
25
  /**
26
  * @inheritdoc
27
  */
28
  public static function getTemplate() {
29
- return 'object/metabox.phtml';
30
  }
31
 
32
  /**
@@ -53,9 +46,9 @@ class AAM_Backend_Feature_Metabox extends AAM_Backend_Feature_Abstract {
53
  admin_url('post-new.php?post_type=' . $type)
54
  );
55
  }
56
-
57
  //grab metaboxes
58
- AAM_Core_API::cURL($url);
59
  }
60
 
61
  return json_encode(array('status' => 'success'));
@@ -68,12 +61,30 @@ class AAM_Backend_Feature_Metabox extends AAM_Backend_Feature_Abstract {
68
  */
69
  public function initURL() {
70
  //grab metaboxes
71
- AAM_Core_API::cURL(
72
- add_query_arg('init', 'metabox', AAM_Core_Request::post('url'))
73
- );
74
 
75
  return json_encode(array('status' => 'success'));
76
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  /**
79
  * Initialize metabox list
@@ -177,10 +188,10 @@ class AAM_Backend_Feature_Metabox extends AAM_Backend_Feature_Abstract {
177
  global $wp_post_types;
178
 
179
  $cache = AAM_Core_API::getOption('aam_metabox_cache', array());
180
- $subject = AAM_Backend_View::getSubject();
181
 
182
  //if visitor, return only frontend widgets
183
- if ($subject instanceof AAM_Core_Subject_Visitor) {
184
  if (!empty($cache['widgets'])) {
185
  $response = array('widgets' => $cache['widgets']);
186
  } else {
@@ -206,7 +217,7 @@ class AAM_Backend_Feature_Metabox extends AAM_Backend_Feature_Abstract {
206
  * @return type
207
  */
208
  protected function isOverwritten() {
209
- $object = AAM_Backend_View::getSubject()->getObject('metabox');
210
 
211
  return $object->isOverwritten();
212
  }
@@ -219,24 +230,17 @@ class AAM_Backend_Feature_Metabox extends AAM_Backend_Feature_Abstract {
219
  * @access public
220
  */
221
  public static function register() {
222
- if (AAM_Core_API::capabilityExists('aam_manage_metaboxes')) {
223
- $cap = 'aam_manage_metaboxes';
224
- } else {
225
- $cap = AAM_Core_Config::get(
226
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
227
- );
228
- }
229
-
230
  AAM_Backend_Feature::registerFeature((object) array(
231
  'uid' => 'metabox',
232
  'position' => 10,
233
  'title' => __('Metaboxes & Widgets', AAM_KEY),
234
- 'capability' => $cap,
 
235
  'subjects' => array(
236
- 'AAM_Core_Subject_Role',
237
- 'AAM_Core_Subject_User',
238
- 'AAM_Core_Subject_Visitor',
239
- 'AAM_Core_Subject_Default'
240
  ),
241
  'option' => 'backend-access-control',
242
  'view' => __CLASS__
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Main_Metabox extends AAM_Backend_Feature_Abstract {
17
 
 
 
 
 
 
 
 
18
  /**
19
  * @inheritdoc
20
  */
21
  public static function getTemplate() {
22
+ return 'main/metabox.phtml';
23
  }
24
 
25
  /**
46
  admin_url('post-new.php?post_type=' . $type)
47
  );
48
  }
49
+
50
  //grab metaboxes
51
+ AAM_Core_API::cURL($this->addHttpPasswd($url));
52
  }
53
 
54
  return json_encode(array('status' => 'success'));
61
  */
62
  public function initURL() {
63
  //grab metaboxes
64
+ $url = $this->addHttpPasswd(AAM_Core_Request::post('url'));
65
+ AAM_Core_API::cURL(add_query_arg('init', 'metabox', $url));
 
66
 
67
  return json_encode(array('status' => 'success'));
68
  }
69
+
70
+ /**
71
+ *
72
+ * @param type $url
73
+ * @return type
74
+ */
75
+ protected function addHttpPasswd($url) {
76
+ $htpasswd = AAM_Core_Config::get('htpasswd');
77
+
78
+ if (!empty($htpasswd['user']) && !empty($htpasswd['pass'])) {
79
+ $url = preg_replace(
80
+ '/^(http[s]?:\/\/)/',
81
+ "$1{$htpasswd['user']}:{$htpasswd['pass']}@",
82
+ $url
83
+ );
84
+ }
85
+
86
+ return $url;
87
+ }
88
 
89
  /**
90
  * Initialize metabox list
188
  global $wp_post_types;
189
 
190
  $cache = AAM_Core_API::getOption('aam_metabox_cache', array());
191
+ $subject = AAM_Backend_Subject::getInstance();
192
 
193
  //if visitor, return only frontend widgets
194
+ if ($subject->getUID() == AAM_Core_Subject_Visitor::UID) {
195
  if (!empty($cache['widgets'])) {
196
  $response = array('widgets' => $cache['widgets']);
197
  } else {
217
  * @return type
218
  */
219
  protected function isOverwritten() {
220
+ $object = AAM_Backend_Subject::getInstance()->getObject('metabox');
221
 
222
  return $object->isOverwritten();
223
  }
230
  * @access public
231
  */
232
  public static function register() {
 
 
 
 
 
 
 
 
233
  AAM_Backend_Feature::registerFeature((object) array(
234
  'uid' => 'metabox',
235
  'position' => 10,
236
  'title' => __('Metaboxes & Widgets', AAM_KEY),
237
+ 'capability' => 'aam_manage_metaboxes',
238
+ 'type' => 'main',
239
  'subjects' => array(
240
+ AAM_Core_Subject_Role::UID,
241
+ AAM_Core_Subject_User::UID,
242
+ AAM_Core_Subject_Visitor::UID,
243
+ AAM_Core_Subject_Default::UID
244
  ),
245
  'option' => 'backend-access-control',
246
  'view' => __CLASS__
Application/Backend/Feature/{Post.php → Main/Post.php} RENAMED
@@ -13,7 +13,7 @@
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
- class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  * Get list for the table
@@ -111,12 +111,17 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
111
 
112
  foreach($list->records as $record) {
113
  if (isset($record->ID)) { //this is post
 
114
  $response['data'][] = array(
115
  $record->ID,
116
- get_edit_post_link($record->ID, 'link'),
117
  'post',
118
- (!empty($record->post_title) ? $record->post_title : 'Reference To: ' . $record->post_name),
119
- apply_filters('aam-post-row-actions-filter', 'manage,edit', $record),
 
 
 
 
120
  //get_post_permalink($record)
121
  );
122
  } else { //term
@@ -317,6 +322,30 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
317
 
318
  return json_encode($response);
319
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
 
321
  /**
322
  * Get Post or Term access
@@ -329,7 +358,7 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
329
  $type = trim(AAM_Core_Request::post('type'));
330
  $id = AAM_Core_Request::post('id');
331
  $access = $metadata = array();
332
- $object = AAM_Backend_View::getSubject()->getObject($type, $id);
333
 
334
  //prepare the response object
335
  if (is_a($object, 'AAM_Core_Object')) {
@@ -343,7 +372,49 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
343
  $metadata = array('overwritten' => $object->isOverwritten());
344
  }
345
 
346
- return json_encode(array('access' => $access, 'meta' => $metadata));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  }
348
 
349
  /**
@@ -354,7 +425,7 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
354
  * @access public
355
  */
356
  public function save() {
357
- $subject = AAM_Backend_View::getSubject();
358
 
359
  $object = trim(AAM_Core_Request::post('object'));
360
  $id = AAM_Core_Request::post('objectId', null);
@@ -372,8 +443,9 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
372
  $result = $subject->save($param, $value, $object, $id);
373
 
374
  return json_encode(array(
375
- 'status' => ($result ? 'success' : 'failure'),
376
- 'value' => $value
 
377
  ));
378
  }
379
 
@@ -388,7 +460,7 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
388
  $type = trim(AAM_Core_Request::post('type'));
389
  $id = AAM_Core_Request::post('id', 0);
390
 
391
- $object = AAM_Backend_View::getSubject()->getObject($type, $id);
392
  if ($object instanceof AAM_Core_Object) {
393
  $result = $object->reset();
394
  //clear cache
@@ -400,18 +472,11 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
400
  return json_encode(array('status' => ($result ? 'success' : 'failure')));
401
  }
402
 
403
- /**
404
- * @inheritdoc
405
- */
406
- public static function getAccessOption() {
407
- return 'feature.post.capability';
408
- }
409
-
410
  /**
411
  * @inheritdoc
412
  */
413
  public static function getTemplate() {
414
- return 'object/post.phtml';
415
  }
416
 
417
  /**
@@ -421,13 +486,31 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
421
  * @return type
422
  */
423
  public static function getAccessOptionList($area) {
424
- static $list = null;
 
 
 
 
425
 
426
- if (is_null($list)) {
427
- $list = require_once dirname(__FILE__) . '/../View/PostOptionList.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  }
429
 
430
- return apply_filters('aam-post-access-options-filter', $list[$area], $area);
431
  }
432
 
433
  /**
@@ -460,24 +543,17 @@ class AAM_Backend_Feature_Post extends AAM_Backend_Feature_Abstract {
460
  * @access public
461
  */
462
  public static function register() {
463
- if (AAM_Core_API::capabilityExists('aam_manage_posts')) {
464
- $cap = 'aam_manage_posts';
465
- } else {
466
- $cap = AAM_Core_Config::get(
467
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
468
- );
469
- }
470
-
471
  AAM_Backend_Feature::registerFeature((object) array(
472
  'uid' => 'post',
473
  'position' => 20,
474
  'title' => __('Posts & Pages', AAM_KEY),
475
- 'capability' => $cap,
 
476
  'subjects' => array(
477
- 'AAM_Core_Subject_Role',
478
- 'AAM_Core_Subject_User',
479
- 'AAM_Core_Subject_Visitor',
480
- 'AAM_Core_Subject_Default'
481
  ),
482
  'option' => 'backend-access-control,frontend-access-control',
483
  'view' => __CLASS__
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Main_Post extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  * Get list for the table
111
 
112
  foreach($list->records as $record) {
113
  if (isset($record->ID)) { //this is post
114
+ $link = get_edit_post_link($record->ID, 'link');
115
  $response['data'][] = array(
116
  $record->ID,
117
+ $link,
118
  'post',
119
+ get_the_title($record),
120
+ apply_filters(
121
+ 'aam-post-row-actions-filter',
122
+ 'manage' . ($link ? ',edit' : ''),
123
+ $record
124
+ ),
125
  //get_post_permalink($record)
126
  );
127
  } else { //term
322
 
323
  return json_encode($response);
324
  }
325
+
326
+ /**
327
+ *
328
+ * @return type
329
+ */
330
+ public function autocomplete() {
331
+ $res = array();
332
+ $list = get_posts(array(
333
+ 'post_type' => AAM_Core_Request::post('type'),
334
+ 'category' => 0,
335
+ 's' => AAM_Core_Request::post('s'),
336
+ 'numberposts' => 10,
337
+ 'post_status' => 'any',
338
+ 'fields' => 'all'
339
+ ));
340
+
341
+ if (count($list)) {
342
+ foreach($list as $post) {
343
+ $res[] = "{$post->ID}|{$post->post_title}";
344
+ }
345
+ }
346
+
347
+ return json_encode($res);
348
+ }
349
 
350
  /**
351
  * Get Post or Term access
358
  $type = trim(AAM_Core_Request::post('type'));
359
  $id = AAM_Core_Request::post('id');
360
  $access = $metadata = array();
361
+ $object = AAM_Backend_Subject::getInstance()->getObject($type, $id);
362
 
363
  //prepare the response object
364
  if (is_a($object, 'AAM_Core_Object')) {
372
  $metadata = array('overwritten' => $object->isOverwritten());
373
  }
374
 
375
+ return json_encode(array(
376
+ 'access' => $access,
377
+ 'meta' => $metadata,
378
+ 'preview' => $this->preparePreviewValues($access)
379
+ ));
380
+ }
381
+
382
+ /**
383
+ *
384
+ * @param type $options
385
+ * @return type
386
+ */
387
+ protected function preparePreviewValues($options) {
388
+ $previews = array();
389
+
390
+ foreach($options as $option => $value) {
391
+ $previews[$option] = $this->getPreviewValue($option, $value);
392
+ }
393
+
394
+ return $previews;
395
+ }
396
+
397
+ /**
398
+ *
399
+ * @param type $option
400
+ * @param type $val
401
+ * @return type
402
+ */
403
+ protected function getPreviewValue($option, $val) {
404
+ switch($option) {
405
+ case 'frontend.teaser':
406
+ $str = strip_tags($val);
407
+ $preview = (strlen($str) > 25 ? substr($str, 0, 22) . '...' : $str);
408
+ break;
409
+
410
+ default:
411
+ $preview = apply_filters(
412
+ 'aam-post-option-preview-filter', $val, $option
413
+ );
414
+ break;
415
+ }
416
+
417
+ return $preview;
418
  }
419
 
420
  /**
425
  * @access public
426
  */
427
  public function save() {
428
+ $subject = AAM_Backend_Subject::getInstance();
429
 
430
  $object = trim(AAM_Core_Request::post('object'));
431
  $id = AAM_Core_Request::post('objectId', null);
443
  $result = $subject->save($param, $value, $object, $id);
444
 
445
  return json_encode(array(
446
+ 'status' => ($result ? 'success' : 'failure'),
447
+ 'value' => $value,
448
+ 'preview' => $this->getPreviewValue($param, $value)
449
  ));
450
  }
451
 
460
  $type = trim(AAM_Core_Request::post('type'));
461
  $id = AAM_Core_Request::post('id', 0);
462
 
463
+ $object = AAM_Backend_Subject::getInstance()->getObject($type, $id);
464
  if ($object instanceof AAM_Core_Object) {
465
  $result = $object->reset();
466
  //clear cache
472
  return json_encode(array('status' => ($result ? 'success' : 'failure')));
473
  }
474
 
 
 
 
 
 
 
 
475
  /**
476
  * @inheritdoc
477
  */
478
  public static function getTemplate() {
479
+ return 'main/post.phtml';
480
  }
481
 
482
  /**
486
  * @return type
487
  */
488
  public static function getAccessOptionList($area) {
489
+ static $cache = null;
490
+
491
+ if (is_null($cache)) {
492
+ $cache = AAM_Backend_View_PostOptionList::get();
493
+ }
494
 
495
+ $subject = AAM_Backend_Subject::getInstance()->getUID();
496
+ $list = apply_filters(
497
+ 'aam-post-access-options-filter', $cache[$area], $area
498
+ );
499
+
500
+ $filtered = array();
501
+ foreach($list as $option => $data) {
502
+ $add = empty($data['exclude']) || !in_array($subject, $data['exclude']);
503
+
504
+ if ($add) {
505
+ $add = empty($data['config']) || AAM_Core_Config::get($data['config'], true);
506
+ }
507
+
508
+ if ($add) {
509
+ $filtered[$option] = $data;
510
+ }
511
  }
512
 
513
+ return $filtered;
514
  }
515
 
516
  /**
543
  * @access public
544
  */
545
  public static function register() {
 
 
 
 
 
 
 
 
546
  AAM_Backend_Feature::registerFeature((object) array(
547
  'uid' => 'post',
548
  'position' => 20,
549
  'title' => __('Posts & Pages', AAM_KEY),
550
+ 'capability' => 'aam_manage_posts',
551
+ 'type' => 'main',
552
  'subjects' => array(
553
+ AAM_Core_Subject_Role::UID,
554
+ AAM_Core_Subject_User::UID,
555
+ AAM_Core_Subject_Visitor::UID,
556
+ AAM_Core_Subject_Default::UID
557
  ),
558
  'option' => 'backend-access-control,frontend-access-control',
559
  'view' => __CLASS__
Application/Backend/Feature/{Redirect.php → Main/Redirect.php} RENAMED
@@ -13,14 +13,16 @@
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
- class AAM_Backend_Feature_Redirect extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  *
20
  * @return type
21
  */
22
  public function isDefault() {
23
- return AAM_Backend_View::getSubject()->getUID() == 'default';
 
 
24
  }
25
 
26
  /**
@@ -28,7 +30,9 @@ class AAM_Backend_Feature_Redirect extends AAM_Backend_Feature_Abstract {
28
  * @return type
29
  */
30
  public function isVisitor() {
31
- return AAM_Backend_View::getSubject()->getUID() == 'visitor';
 
 
32
  }
33
 
34
  /**
@@ -41,7 +45,7 @@ class AAM_Backend_Feature_Redirect extends AAM_Backend_Feature_Abstract {
41
  * @access protected
42
  */
43
  protected function isOverwritten() {
44
- $object = AAM_Backend_View::getSubject()->getObject('redirect');
45
 
46
  return $object->isOverwritten();
47
  }
@@ -52,24 +56,17 @@ class AAM_Backend_Feature_Redirect extends AAM_Backend_Feature_Abstract {
52
  * @return type
53
  */
54
  public function getOption($option, $default = null) {
55
- $object = AAM_Backend_View::getSubject()->getObject('redirect');
56
  $value = $object->get($option);
57
 
58
  return (!is_null($value) ? $value : $default);
59
  }
60
 
61
- /**
62
- * @inheritdoc
63
- */
64
- public static function getAccessOption() {
65
- return 'feature.redirect.capability';
66
- }
67
-
68
  /**
69
  * @inheritdoc
70
  */
71
  public static function getTemplate() {
72
- return 'object/redirect.phtml';
73
  }
74
 
75
  /**
@@ -80,24 +77,17 @@ class AAM_Backend_Feature_Redirect extends AAM_Backend_Feature_Abstract {
80
  * @access public
81
  */
82
  public static function register() {
83
- if (AAM_Core_API::capabilityExists('aam_manage_access_denied_redirect')) {
84
- $cap = 'aam_manage_access_denied_redirect';
85
- } else {
86
- $cap = AAM_Core_Config::get(
87
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
88
- );
89
- }
90
-
91
  AAM_Backend_Feature::registerFeature((object) array(
92
  'uid' => 'redirect',
93
  'position' => 30,
94
  'title' => __('Access Denied Redirect', AAM_KEY),
95
- 'capability' => $cap,
 
96
  'subjects' => array(
97
- 'AAM_Core_Subject_Role',
98
- 'AAM_Core_Subject_User',
99
- 'AAM_Core_Subject_Visitor',
100
- 'AAM_Core_Subject_Default'
101
  ),
102
  'option' => 'backend-access-control,frontend-access-control',
103
  'view' => __CLASS__
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Main_Redirect extends AAM_Backend_Feature_Abstract {
17
 
18
  /**
19
  *
20
  * @return type
21
  */
22
  public function isDefault() {
23
+ $subject = AAM_Backend_Subject::getInstance();
24
+
25
+ return $subject->getUID() == AAM_Core_Subject_Default::UID;
26
  }
27
 
28
  /**
30
  * @return type
31
  */
32
  public function isVisitor() {
33
+ $subject = AAM_Backend_Subject::getInstance();
34
+
35
+ return $subject->getUID() == AAM_Core_Subject_Visitor::UID;
36
  }
37
 
38
  /**
45
  * @access protected
46
  */
47
  protected function isOverwritten() {
48
+ $object = AAM_Backend_Subject::getInstance()->getObject('redirect');
49
 
50
  return $object->isOverwritten();
51
  }
56
  * @return type
57
  */
58
  public function getOption($option, $default = null) {
59
+ $object = AAM_Backend_Subject::getInstance()->getObject('redirect');
60
  $value = $object->get($option);
61
 
62
  return (!is_null($value) ? $value : $default);
63
  }
64
 
 
 
 
 
 
 
 
65
  /**
66
  * @inheritdoc
67
  */
68
  public static function getTemplate() {
69
+ return 'main/redirect.phtml';
70
  }
71
 
72
  /**
77
  * @access public
78
  */
79
  public static function register() {
 
 
 
 
 
 
 
 
80
  AAM_Backend_Feature::registerFeature((object) array(
81
  'uid' => 'redirect',
82
  'position' => 30,
83
  'title' => __('Access Denied Redirect', AAM_KEY),
84
+ 'capability' => 'aam_manage_access_denied_redirect',
85
+ 'type' => 'main',
86
  'subjects' => array(
87
+ AAM_Core_Subject_Role::UID,
88
+ AAM_Core_Subject_User::UID,
89
+ AAM_Core_Subject_Visitor::UID,
90
+ AAM_Core_Subject_Default::UID
91
  ),
92
  'option' => 'backend-access-control,frontend-access-control',
93
  'view' => __CLASS__
Application/Backend/Feature/Security.php DELETED
@@ -1,62 +0,0 @@
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 security manager
12
- *
13
- * @package AAM
14
- * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
- */
16
- class AAM_Backend_Feature_Security extends AAM_Backend_Feature_Abstract {
17
-
18
- /**
19
- * @inheritdoc
20
- */
21
- public static function getAccessOption() {
22
- return 'feature.security.capability';
23
- }
24
-
25
- /**
26
- * @inheritdoc
27
- */
28
- public static function getTemplate() {
29
- return 'security.phtml';
30
- }
31
-
32
- /**
33
- * Register Contact/Hire feature
34
- *
35
- * @return void
36
- *
37
- * @access public
38
- */
39
- public static function register() {
40
- if (is_main_site()) {
41
- if (AAM_Core_API::capabilityExists('aam_manage_security')) {
42
- $cap = 'aam_manage_security';
43
- } else {
44
- $cap = AAM_Core_Config::get(
45
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
46
- );
47
- }
48
-
49
- AAM_Backend_Feature::registerFeature((object) array(
50
- 'uid' => 'security',
51
- 'position' => 90,
52
- 'title' => __('Security', AAM_KEY),
53
- 'capability' => $cap,
54
- 'subjects' => array(
55
- 'AAM_Core_Subject_Role'
56
- ),
57
- 'view' => __CLASS__
58
- ));
59
- }
60
- }
61
-
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Backend/Feature/Settings/Content.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 content settings
12
+ *
13
+ * @package AAM
14
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
+ */
16
+ class AAM_Backend_Feature_Settings_Content extends AAM_Backend_Feature_Abstract {
17
+
18
+ /**
19
+ * @inheritdoc
20
+ */
21
+ public static function getTemplate() {
22
+ return 'settings/content.phtml';
23
+ }
24
+
25
+ /**
26
+ *
27
+ * @return type
28
+ */
29
+ protected function getList() {
30
+ $settings = array(
31
+ 'media-access-control' => array(
32
+ 'title' => __('Media Files Access Control', AAM_KEY),
33
+ 'descr' => sprintf(AAM_Backend_View_Helper::preparePhrase('Allow AAM to manage a physically access to all media files located in the defined by the system [uploads] folder. [Note!] This feature requires additional steps as described in %sthis article%s.', 'strong', 'strong'), '<a href="https://aamplugin.com/help/how-to-manage-wordpress-media-access" target="_blank">', '</a>'),
34
+ 'value' => AAM_Core_Config::get('media-access-control', false)
35
+ ),
36
+ 'check-post-visibility' => array(
37
+ 'title' => __('Check Post Visibility', AAM_KEY),
38
+ '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),
39
+ 'value' => AAM_Core_Config::get('check-post-visibility', true)
40
+ ),
41
+ 'manage-hidden-post-types' => array(
42
+ 'title' => __('Manage Hidden Post Types', AAM_KEY),
43
+ '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),
44
+ 'value' => AAM_Core_Config::get('manage-hidden-post-types', false)
45
+ )
46
+ );
47
+
48
+ return apply_filters('aam-settings-filter', $settings, 'post');
49
+ }
50
+
51
+ /**
52
+ * Register Contact/Hire feature
53
+ *
54
+ * @return void
55
+ *
56
+ * @access public
57
+ */
58
+ public static function register() {
59
+ AAM_Backend_Feature::registerFeature((object) array(
60
+ 'uid' => 'settings-content',
61
+ 'position' => 5,
62
+ 'title' => __('Content Settings', AAM_KEY),
63
+ 'capability' => 'aam_manage_settings',
64
+ 'type' => 'settings',
65
+ 'view' => __CLASS__
66
+ ));
67
+ }
68
+
69
+ }
Application/Backend/Feature/Settings/Core.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 core settings
12
+ *
13
+ * @package AAM
14
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
+ */
16
+ class AAM_Backend_Feature_Settings_Core extends AAM_Backend_Feature_Abstract {
17
+
18
+ /**
19
+ * @inheritdoc
20
+ */
21
+ public static function getTemplate() {
22
+ return 'settings/core.phtml';
23
+ }
24
+
25
+ /**
26
+ *
27
+ * @return type
28
+ */
29
+ protected function getList() {
30
+ $settings = array(
31
+ 'manage-capability' => array(
32
+ 'title' => __('Edit/Delete Capabilities', AAM_KEY),
33
+ 'descr' => AAM_Backend_View_Helper::preparePhrase('Allow to edit or delete any existing capability on the Capabilities tab. [Warning!] For experienced users only. Changing or deleting capability may result in loosing access to some features or the entire website.', 'b'),
34
+ 'value' => AAM_Core_Config::get('manage-capability', false)
35
+ ),
36
+ 'backend-access-control' => array(
37
+ 'title' => __('Backend Access Control', AAM_KEY),
38
+ 'descr' => __('Allow AAM to manage access to the backend. Keep this option disabled if there is no needs to restrict backend features for other users. This option may reduce your website backend performance.', AAM_KEY),
39
+ 'value' => AAM_Core_Config::get('backend-access-control', true)
40
+ ),
41
+ 'frontend-access-control' => array(
42
+ 'title' => __('Frontend Access Control', AAM_KEY),
43
+ 'descr' => __('Allow AAM to manage access to frontend resources. If there is no need to manage access to the website frontend then keep this option unchecked as it may increase your webiste performance.', AAM_KEY),
44
+ 'value' => AAM_Core_Config::get('frontend-access-control', true)
45
+ ),
46
+ 'render-access-metabox' => array(
47
+ 'title' => __('Render Access Manager Metabox', AAM_KEY),
48
+ '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),
49
+ 'value' => AAM_Core_Config::get('render-access-metabox', true),
50
+ ),
51
+ 'show-access-link' => array(
52
+ 'title' => __('Render Access Link', AAM_KEY),
53
+ 'descr' => __('Render Access shortcut link under any post, page, custom post type, category, custom taxonomy title or user name.', AAM_KEY),
54
+ 'value' => AAM_Core_Config::get('show-access-link', true),
55
+ ),
56
+ 'secure-login' => array(
57
+ 'title' => __('Secure Login', AAM_KEY),
58
+ 'descr' => __('AAM comes with its own user login handler. With this feature you can add AJAX login widget to your frontend page that significantly enhance your website security.', AAM_KEY),
59
+ 'value' => AAM_Core_Config::get('secure-login', true)
60
+ )
61
+ );
62
+
63
+ return apply_filters('aam-settings-filter', $settings, 'core');
64
+ }
65
+
66
+ /**
67
+ * Register Contact/Hire feature
68
+ *
69
+ * @return void
70
+ *
71
+ * @access public
72
+ */
73
+ public static function register() {
74
+ AAM_Backend_Feature::registerFeature((object) array(
75
+ 'uid' => 'settings-core',
76
+ 'position' => 1,
77
+ 'title' => __('Core Settings', AAM_KEY),
78
+ 'capability' => 'aam_manage_settings',
79
+ 'type' => 'settings',
80
+ 'view' => __CLASS__
81
+ ));
82
+ }
83
+
84
+ }
Application/Backend/Feature/Settings/Manager.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Utility manager
12
+ *
13
+ * @package AAM
14
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
+ */
16
+ class AAM_Backend_Feature_Settings_Manager extends AAM_Backend_Feature_Abstract {
17
+
18
+ /**
19
+ * Save AAM utility options
20
+ *
21
+ * @return string
22
+ *
23
+ * @access public
24
+ */
25
+ public function save() {
26
+ $param = AAM_Core_Request::post('param');
27
+ $value = stripslashes(AAM_Core_Request::post('value'));
28
+
29
+ AAM_Core_Config::set($param, $value);
30
+
31
+ return json_encode(array('status' => 'success'));
32
+ }
33
+
34
+ }
Application/Backend/Feature/Settings/Tools.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 tools settings
12
+ *
13
+ * @package AAM
14
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
+ */
16
+ class AAM_Backend_Feature_Settings_Tools extends AAM_Backend_Feature_Abstract {
17
+
18
+ /**
19
+ * @inheritdoc
20
+ */
21
+ public static function getTemplate() {
22
+ return 'settings/tools.phtml';
23
+ }
24
+
25
+ /**
26
+ *
27
+ * @return type
28
+ */
29
+ public function export() {
30
+ $exporter = new AAM_Core_Exporter(AAM_Core_Config::get(
31
+ 'export', array('system' => 'roles,utilities,configpress')
32
+ ));
33
+
34
+ return json_encode(array(
35
+ 'status' => 'success',
36
+ 'content' => base64_encode(json_encode($exporter->run()))
37
+ ));
38
+ }
39
+
40
+ /**
41
+ *
42
+ * @return type
43
+ */
44
+ public function import() {
45
+ $importer = new AAM_Core_Importer(filter_input(INPUT_POST, 'json'));
46
+
47
+ return json_encode(array('status' => $importer->run()));
48
+ }
49
+
50
+ /**
51
+ * Clear all AAM settings
52
+ *
53
+ * @global wpdb $wpdb
54
+ *
55
+ * @return string
56
+ *
57
+ * @access public
58
+ */
59
+ public function clear() {
60
+ global $wpdb;
61
+
62
+ //clear wp_options
63
+ $oquery = "DELETE FROM {$wpdb->options} WHERE (`option_name` LIKE %s) AND ";
64
+ $oquery .= "(`option_name` NOT IN ('aam-extensions', 'aam-uid'))";
65
+ $wpdb->query($wpdb->prepare($oquery, 'aam%'));
66
+
67
+ //clear wp_postmeta
68
+ $pquery = "DELETE FROM {$wpdb->postmeta} WHERE `meta_key` LIKE %s";
69
+ $wpdb->query($wpdb->prepare($pquery, 'aam-post-access-%'));
70
+
71
+ //clear wp_usermeta
72
+ $uquery = "DELETE FROM {$wpdb->usermeta} WHERE `meta_key` LIKE %s";
73
+ $wpdb->query($wpdb->prepare($uquery, 'aam%'));
74
+
75
+ $mquery = "DELETE FROM {$wpdb->usermeta} WHERE `meta_key` LIKE %s";
76
+ $wpdb->query($wpdb->prepare($mquery, $wpdb->prefix . 'aam%'));
77
+
78
+ return json_encode(array('status' => 'success'));
79
+ }
80
+
81
+ /**
82
+ *
83
+ * @return type
84
+ */
85
+ public function clearCache() {
86
+ AAM_Core_Cache::clear();
87
+
88
+ return json_encode(array('status' => 'success'));
89
+ }
90
+
91
+ /**
92
+ * Register Contact/Hire feature
93
+ *
94
+ * @return void
95
+ *
96
+ * @access public
97
+ */
98
+ public static function register() {
99
+ AAM_Backend_Feature::registerFeature((object) array(
100
+ 'uid' => 'settings-tools',
101
+ 'position' => 10,
102
+ 'title' => __('Tools', AAM_KEY),
103
+ 'capability' => 'aam_manage_settings',
104
+ 'type' => 'settings',
105
+ 'view' => __CLASS__
106
+ ));
107
+ }
108
+
109
+ }
Application/Backend/Feature/{Role.php → Subject/Role.php} RENAMED
@@ -13,7 +13,7 @@
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
- class AAM_Backend_Feature_Role {
17
 
18
  /**
19
  * Get role list
@@ -25,7 +25,7 @@ class AAM_Backend_Feature_Role {
25
  * @access public
26
  */
27
  public function getTable() {
28
- if (AAM_Backend_View::userCan('aam_list_roles')) {
29
  //retrieve list of users
30
  $count = count_users();
31
  $stats = $count['avail_roles'];
@@ -75,13 +75,13 @@ class AAM_Backend_Feature_Role {
75
  protected function prepareRowActions($count) {
76
  $actions = array('manage');
77
 
78
- if (AAM_Backend_View::userCan('aam_edit_roles')) {
79
  $actions[] = 'edit';
80
  }
81
- if (AAM_Backend_View::userCan('aam_create_roles')) {
82
  $actions[] = 'clone';
83
  }
84
- if (AAM_Backend_View::userCan('aam_delete_roles') && !$count) {
85
  $actions[] = 'delete';
86
  }
87
 
@@ -134,7 +134,7 @@ class AAM_Backend_Feature_Role {
134
  public function add() {
135
  $response = array('status' => 'failure');
136
 
137
- if (AAM_Backend_View::userCan('aam_create_roles')) {
138
  $name = sanitize_text_field(filter_input(INPUT_POST, 'name'));
139
  $expire = filter_input(INPUT_POST, 'expire');
140
  $roles = AAM_Core_API::getRoles();
@@ -213,8 +213,8 @@ class AAM_Backend_Feature_Role {
213
  * @access public
214
  */
215
  public function edit() {
216
- if (AAM_Backend_View::userCan('aam_edit_roles')) {
217
- $role = AAM_Backend_View::getSubject();
218
  $role->update(trim(filter_input(INPUT_POST, 'name')));
219
 
220
  $expire = filter_input(INPUT_POST, 'expire');
@@ -227,7 +227,7 @@ class AAM_Backend_Feature_Role {
227
  AAM_Core_API::deleteOption('aam-role-' . $role->getId() .'-expiration');
228
  }
229
 
230
- do_action('aam-post-update-role-action', $role);
231
 
232
  $response = array('status' => 'success');
233
  } else {
@@ -247,8 +247,8 @@ class AAM_Backend_Feature_Role {
247
  public function delete() {
248
  $status = 'failure';
249
 
250
- if (AAM_Backend_View::userCan('aam_delete_roles')) {
251
- if (AAM_Backend_View::getSubject()->delete()) {
252
  $status = 'success';
253
  }
254
  }
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Subject_Role {
17
 
18
  /**
19
  * Get role list
25
  * @access public
26
  */
27
  public function getTable() {
28
+ if (current_user_can('aam_list_roles')) {
29
  //retrieve list of users
30
  $count = count_users();
31
  $stats = $count['avail_roles'];
75
  protected function prepareRowActions($count) {
76
  $actions = array('manage');
77
 
78
+ if (current_user_can('aam_edit_roles')) {
79
  $actions[] = 'edit';
80
  }
81
+ if (current_user_can('aam_create_roles')) {
82
  $actions[] = 'clone';
83
  }
84
+ if (current_user_can('aam_delete_roles') && !$count) {
85
  $actions[] = 'delete';
86
  }
87
 
134
  public function add() {
135
  $response = array('status' => 'failure');
136
 
137
+ if (current_user_can('aam_create_roles')) {
138
  $name = sanitize_text_field(filter_input(INPUT_POST, 'name'));
139
  $expire = filter_input(INPUT_POST, 'expire');
140
  $roles = AAM_Core_API::getRoles();
213
  * @access public
214
  */
215
  public function edit() {
216
+ if (current_user_can('aam_edit_roles')) {
217
+ $role = AAM_Backend_Subject::getInstance();
218
  $role->update(trim(filter_input(INPUT_POST, 'name')));
219
 
220
  $expire = filter_input(INPUT_POST, 'expire');
227
  AAM_Core_API::deleteOption('aam-role-' . $role->getId() .'-expiration');
228
  }
229
 
230
+ do_action('aam-post-update-role-action', $role->get());
231
 
232
  $response = array('status' => 'success');
233
  } else {
247
  public function delete() {
248
  $status = 'failure';
249
 
250
+ if (current_user_can('aam_delete_roles')) {
251
+ if (AAM_Backend_Subject::getInstance()->delete()) {
252
  $status = 'success';
253
  }
254
  }
Application/Backend/Feature/{User.php → Subject/User.php} RENAMED
@@ -13,7 +13,7 @@
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
- class AAM_Backend_Feature_User {
17
 
18
  /**
19
  * Retrieve list of users
@@ -25,7 +25,7 @@ class AAM_Backend_Feature_User {
25
  * @access public
26
  */
27
  public function getTable() {
28
- if (AAM_Backend_View::userCan('list_users')) {
29
  //get total number of users
30
  $total = count_users();
31
  $result = $this->query();
@@ -100,13 +100,17 @@ class AAM_Backend_Feature_User {
100
  if ($allowed || ($user->ID == get_current_user_id())) {
101
  $actions = array('manage');
102
 
103
- if (AAM_Backend_View::userCan('aam_toggle_users')) {
104
- $actions[] = ($user->user_status ? 'unlock' : 'lock');
 
 
105
  }
106
- if (AAM_Backend_View::userCan('edit_users')) {
 
107
  $actions[] = 'edit';
108
  }
109
- if (AAM_Backend_View::userCan('aam_switch_users')) {
 
110
  $actions[] = 'switch';
111
  }
112
  } else {
@@ -154,8 +158,8 @@ class AAM_Backend_Feature_User {
154
  public function block() {
155
  $result = false;
156
 
157
- if (AAM_Backend_View::userCan('aam_toggle_users')) {
158
- $subject = AAM_Backend_View::getSubject();
159
 
160
  //user is not allowed to lock himself
161
  if ($subject->getId() != get_current_user_id()) {
13
  * @package AAM
14
  * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
  */
16
+ class AAM_Backend_Feature_Subject_User {
17
 
18
  /**
19
  * Retrieve list of users
25
  * @access public
26
  */
27
  public function getTable() {
28
+ if (current_user_can('list_users')) {
29
  //get total number of users
30
  $total = count_users();
31
  $result = $this->query();
100
  if ($allowed || ($user->ID == get_current_user_id())) {
101
  $actions = array('manage');
102
 
103
+ if (AAM_Core_Config::get('secure-login', true)) {
104
+ if (current_user_can('aam_toggle_users')) {
105
+ $actions[] = ($user->user_status ? 'unlock' : 'lock');
106
+ }
107
  }
108
+
109
+ if (current_user_can('edit_users')) {
110
  $actions[] = 'edit';
111
  }
112
+
113
+ if (current_user_can('aam_switch_users')) {
114
  $actions[] = 'switch';
115
  }
116
  } else {
158
  public function block() {
159
  $result = false;
160
 
161
+ if (current_user_can('aam_toggle_users')) {
162
+ $subject = AAM_Backend_Subject::getInstance();
163
 
164
  //user is not allowed to lock himself
165
  if ($subject->getId() != get_current_user_id()) {
Application/Backend/Feature/Teaser.php DELETED
@@ -1,98 +0,0 @@
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
- * Content teaser manager
12
- *
13
- * @package AAM
14
- * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
- */
16
- class AAM_Backend_Feature_Teaser extends AAM_Backend_Feature_Abstract {
17
-
18
- /**
19
- *
20
- * @return type
21
- */
22
- public function isDefault() {
23
- return (AAM_Backend_View::getSubject()->getUID() == 'default');
24
- }
25
-
26
- /**
27
- * Check inheritance status
28
- *
29
- * Check if teaser settings are overwritten
30
- *
31
- * @return boolean
32
- *
33
- * @access protected
34
- */
35
- protected function isOverwritten() {
36
- $object = AAM_Backend_View::getSubject()->getObject('teaser');
37
-
38
- return $object->isOverwritten();
39
- }
40
-
41
- /**
42
- *
43
- * @param type $option
44
- * @return type
45
- */
46
- public function getOption($option, $default = null) {
47
- $object = AAM_Backend_View::getSubject()->getObject('teaser');
48
- $value = $object->get($option);
49
-
50
- return (!is_null($value) ? $value : $default);
51
- }
52
-
53
- /**
54
- * @inheritdoc
55
- */
56
- public static function getAccessOption() {
57
- return 'feature.teaser.capability';
58
- }
59
-
60
- /**
61
- * @inheritdoc
62
- */
63
- public static function getTemplate() {
64
- return 'object/teaser.phtml';
65
- }
66
-
67
- /**
68
- * Register Contact/Hire feature
69
- *
70
- * @return void
71
- *
72
- * @access public
73
- */
74
- public static function register() {
75
- if (AAM_Core_API::capabilityExists('aam_manage_content_teaser')) {
76
- $cap = 'aam_manage_content_teaser';
77
- } else {
78
- $cap = AAM_Core_Config::get(
79
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
80
- );
81
- }
82
-
83
- AAM_Backend_Feature::registerFeature((object) array(
84
- 'uid' => 'teaser',
85
- 'position' => 45,
86
- 'title' => __('Content Teaser', AAM_KEY),
87
- 'capability' => $cap,
88
- 'subjects' => array(
89
- 'AAM_Core_Subject_Role',
90
- 'AAM_Core_Subject_User',
91
- 'AAM_Core_Subject_Visitor',
92
- 'AAM_Core_Subject_Default'
93
- ),
94
- 'view' => __CLASS__
95
- ));
96
- }
97
-
98
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Backend/Feature/Utility.php DELETED
@@ -1,178 +0,0 @@
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 Utility manager
12
- *
13
- * @package AAM
14
- * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
- */
16
- class AAM_Backend_Feature_Utility extends AAM_Backend_Feature_Abstract {
17
-
18
- /**
19
- * @inheritdoc
20
- */
21
- public static function getAccessOption() {
22
- return 'feature.utility.capability';
23
- }
24
-
25
- /**
26
- * @inheritdoc
27
- */
28
- public static function getTemplate() {
29
- return 'utility.phtml';
30
- }
31
-
32
- /**
33
- *
34
- * @return type
35
- */
36
- public function getUtilityOptionList($category = 'miscellaneous') {
37
- static $options = null;
38
-
39
- if (is_null($options)) {
40
- $filename = dirname(__FILE__) . '/../View/UtilityOptionList.php';
41
- $options = apply_filters(
42
- 'aam-utility-option-list-filter', include $filename
43
- );
44
- }
45
-
46
- $filtered = array();
47
-
48
- foreach($options as $id => $option) {
49
- if (isset($option['category'])) {
50
- $cat = $option['category'];
51
- } else {
52
- $cat = 'miscellaneous';
53
- }
54
-
55
- if ($cat == $category) {
56
- $filtered[$id] = $option;
57
- }
58
- }
59
-
60
- return $filtered;
61
- }
62
-
63
- /**
64
- * Save AAM utility options
65
- *
66
- * @return string
67
- *
68
- * @access public
69
- */
70
- public function save() {
71
- $param = AAM_Core_Request::post('param');
72
- $value = stripslashes(AAM_Core_Request::post('value'));
73
-
74
- AAM_Core_Config::set($param, $value);
75
-
76
- return json_encode(array('status' => 'success'));
77
- }
78
-
79
- /**
80
- *
81
- * @return type
82
- */
83
- public function export() {
84
- $exporter = new AAM_Core_Exporter(AAM_Core_Config::get(
85
- 'export', array('system' => 'roles,utilities,configpress')
86
- ));
87
-
88
- return json_encode(array(
89
- 'status' => 'success',
90
- 'content' => base64_encode(json_encode($exporter->run()))
91
- ));
92
- }
93
-
94
- /**
95
- *
96
- * @return type
97
- */
98
- public function import() {
99
- $importer = new AAM_Core_Importer(filter_input(INPUT_POST, 'json'));
100
-
101
- return json_encode(array('status' => $importer->run()));
102
- }
103
-
104
- /**
105
- * Clear all AAM settings
106
- *
107
- * @global wpdb $wpdb
108
- *
109
- * @return string
110
- *
111
- * @access public
112
- */
113
- public function clear() {
114
- global $wpdb;
115
-
116
- //clear wp_options
117
- $oquery = "DELETE FROM {$wpdb->options} WHERE (`option_name` LIKE %s) AND ";
118
- $oquery .= "(`option_name` NOT IN ('aam-extensions', 'aam-uid'))";
119
- $wpdb->query($wpdb->prepare($oquery, 'aam%' ));
120
-
121
- //clear wp_postmeta
122
- $pquery = "DELETE FROM {$wpdb->postmeta} WHERE `meta_key` LIKE %s";
123
- $wpdb->query($wpdb->prepare($pquery, 'aam%' ));
124
-
125
- //clear wp_usermeta
126
- $uquery = "DELETE FROM {$wpdb->usermeta} WHERE `meta_key` LIKE %s";
127
- $wpdb->query($wpdb->prepare($uquery, 'aam%' ));
128
-
129
- $mquery = "DELETE FROM {$wpdb->usermeta} WHERE `meta_key` LIKE %s";
130
- $wpdb->query($wpdb->prepare($mquery, $wpdb->prefix . 'aam%' ));
131
-
132
- return json_encode(array('status' => 'success'));
133
- }
134
-
135
- /**
136
- *
137
- * @return type
138
- */
139
- public function clearCache() {
140
- AAM_Core_Cache::clear();
141
-
142
- return json_encode(array('status' => 'success'));
143
- }
144
-
145
- /**
146
- * Register Contact/Hire feature
147
- *
148
- * @return void
149
- *
150
- * @access public
151
- */
152
- public static function register() {
153
- if (is_main_site()) {
154
- if (AAM_Core_API::capabilityExists('aam_manage_utilities')) {
155
- $cap = 'aam_manage_utilities';
156
- } else {
157
- $cap = AAM_Core_Config::get(
158
- self::getAccessOption(), AAM_Backend_View::getAAMCapability()
159
- );
160
- }
161
-
162
- AAM_Backend_Feature::registerFeature((object) array(
163
- 'uid' => 'utilities',
164
- 'position' => 100,
165
- 'title' => __('Utilities', AAM_KEY),
166
- 'capability' => $cap,
167
- 'subjects' => array(
168
- 'AAM_Core_Subject_Role',
169
- 'AAM_Core_Subject_User',
170
- 'AAM_Core_Subject_Visitor',
171
- 'AAM_Core_Subject_Default'
172
- ),
173
- 'view' => __CLASS__
174
- ));
175
- }
176
- }
177
-
178
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Backend/Filter.php CHANGED
@@ -44,22 +44,23 @@ class AAM_Backend_Filter {
44
  add_action("in_admin_header", array($this, 'metaboxes'), 999);
45
 
46
  //control admin area
47
- add_action('admin_init', array($this, 'adminInit'));
48
  add_action('admin_notices', array($this, 'adminNotices'), -1);
49
  add_action('network_admin_notices', array($this, 'adminNotices'), -1);
50
  add_action('user_admin_notices', array($this, 'adminNotices'), -1);
51
 
 
 
 
52
  //post restrictions
53
  add_filter('page_row_actions', array($this, 'postRowActions'), 10, 2);
54
  add_filter('post_row_actions', array($this, 'postRowActions'), 10, 2);
55
- add_action('admin_action_edit', array($this, 'adminActionEdit'));
56
 
57
  //default category filder
58
- add_filter('pre_option_default_category', array($this, 'defaultCategory'));
59
 
60
  //add post filter for LIST restriction
61
  if (!AAM::isAAM() && AAM_Core_Config::get('check-post-visibility', true)) {
62
- add_filter('found_posts', array($this, 'foundPosts'), 999, 2);
63
  add_filter('posts_fields_request', array($this, 'fieldsRequest'), 999, 2);
64
  add_action('pre_get_posts', array($this, 'preparePostQuery'), 999);
65
  }
@@ -69,126 +70,12 @@ class AAM_Backend_Filter {
69
  //user profile update action
70
  add_action('profile_update', array($this, 'profileUpdate'), 10, 2);
71
 
72
- //some additional filter for user capabilities
73
- add_filter('user_has_cap', array($this, 'checkUserCap'), 999, 4);
 
 
74
 
75
- //screen options & contextual help hooks
76
- add_filter('screen_options_show_screen', array($this, 'screenOptions'));
77
- add_filter('contextual_help', array($this, 'helpOptions'), 10, 3);
78
- }
79
-
80
- /**
81
- *
82
- * @global type $wp_filter
83
- */
84
- public function adminNotices() {
85
- if (AAM_Core_API::capabilityExists('show_admin_notices')) {
86
- if (!AAM::getUser()->hasCapability('show_admin_notices')) {
87
- remove_all_actions('admin_notices');
88
- remove_all_actions('network_admin_notices');
89
- remove_all_actions('user_admin_notices');
90
- }
91
- }
92
- }
93
-
94
- /**
95
- *
96
- * @param type $id
97
- * @param type $old
98
- */
99
- public function profileUpdate($id, $old) {
100
- $user = get_user_by('ID', $id);
101
-
102
- //role changed?
103
- if (implode('', $user->roles) != implode('', $old->roles)) {
104
- AAM_Core_Cache::clear($id);
105
-
106
- //check if role has expiration data set
107
- $role = (is_array($user->roles) ? $user->roles[0] : '');
108
- $expire = AAM_Core_API::getOption("aam-role-{$role}-expiration", '');
109
-
110
- if ($expire) {
111
- update_user_option($id, "aam-original-roles", $old->roles);
112
- update_user_option($id, "aam-role-expires", strtotime($expire));
113
- }
114
- }
115
- }
116
-
117
- /**
118
- *
119
- * @param type $id
120
- * @param type $data
121
- */
122
- public function prePostUpdate($id, $data) {
123
- $post = get_post($id);
124
-
125
- if ($post->post_author != $data['post_author']) {
126
- AAM_Core_Cache::clear($id);
127
- }
128
- }
129
-
130
- /**
131
- *
132
- * @staticvar type $default
133
- * @param type $category
134
- * @return type
135
- */
136
- public function defaultCategory($category) {
137
- static $default = null;
138
-
139
- if (is_null($default)) {
140
- //check if user category is defined
141
- $id = get_current_user_id();
142
- $default = AAM_Core_Config::get('default.category.user.' . $id , null);
143
- $roles = AAM::getUser()->roles;
144
-
145
- if (is_null($default) && count($roles)) {
146
- $default = AAM_Core_Config::get(
147
- 'default.category.role.' . array_shift($roles), false
148
- );
149
- }
150
- }
151
-
152
- return ($default ? $default : $category);
153
- }
154
-
155
- /**
156
- * Control Admin Area access
157
- *
158
- * @return void
159
- *
160
- * @access public
161
- * @since 3.3
162
- */
163
- public function adminInit() {
164
- global $plugin_page;
165
-
166
- //compile menu
167
- if (empty($plugin_page)){
168
- $menu = basename(AAM_Core_Request::server('SCRIPT_NAME'));
169
- $taxonomy = AAM_Core_Request::get('taxonomy');
170
- $postType = AAM_Core_Request::get('post_type');
171
- $page = AAM_Core_Request::get('page');
172
-
173
- if (!empty($taxonomy)) {
174
- $menu .= '?taxonomy=' . $taxonomy;
175
- } elseif (!empty($postType)) {
176
- $menu .= '?post_type=' . $postType;
177
- } elseif (!empty($page)) {
178
- $menu .= '?page=' . $page;
179
- }
180
- } else {
181
- $menu = $plugin_page;
182
- }
183
-
184
- $object = AAM::getUser()->getObject('menu');
185
-
186
- if ($object->has($menu)) {
187
- AAM_Core_API::reject(
188
- 'backend',
189
- array('hook' => 'access_backend_menu', 'id' => $menu)
190
- );
191
- }
192
  }
193
 
194
  /**
@@ -206,7 +93,7 @@ class AAM_Backend_Filter {
206
 
207
  return $parent_file;
208
  }
209
-
210
  /**
211
  * Handle metabox initialization process
212
  *
@@ -231,6 +118,77 @@ class AAM_Backend_Filter {
231
  }
232
  }
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  /**
235
  * Post Quick Menu Actions Filtering
236
  *
@@ -244,11 +202,8 @@ class AAM_Backend_Filter {
244
  public function postRowActions($actions, $post) {
245
  $object = AAM::getUser()->getObject('post', $post->ID, $post);
246
 
247
- $edit = $object->has('backend.edit');
248
- $others = $object->has('backend.edit_others');
249
-
250
  //filter edit menu
251
- if ($edit || ($others && !$this->isAuthor($post))) {
252
  if (isset($actions['edit'])) {
253
  unset($actions['edit']);
254
  }
@@ -257,24 +212,14 @@ class AAM_Backend_Filter {
257
  }
258
  }
259
 
260
- $delete = $object->has('backend.delete');
261
- $others = $object->has('backend.delete_others');
262
-
263
  //filter delete menu
264
- if ($delete || ($others && !$this->isAuthor($post))) {
265
- if (isset($actions['trash'])) {
266
- unset($actions['trash']);
267
- }
268
- if (isset($actions['delete'])) {
269
- unset($actions['delete']);
270
- }
271
  }
272
 
273
- $publish = $object->has('backend.publish');
274
- $others = $object->has('backend.publish_others');
275
-
276
  //filter edit menu
277
- if ($publish || ($others && !$this->isAuthor($post))) {
278
  if (isset($actions['inline hide-if-no-js'])) {
279
  unset($actions['inline hide-if-no-js']);
280
  }
@@ -282,94 +227,58 @@ class AAM_Backend_Filter {
282
 
283
  return $actions;
284
  }
285
-
286
  /**
287
- * Control Edit Post
288
- *
289
- * Make sure that current user does not have access to edit Post
290
- *
291
- * @return void
292
- *
293
- * @access public
 
 
 
294
  */
295
- public function adminActionEdit() {
296
- $post = $this->getPost();
 
 
297
 
298
- if (is_a($post, 'WP_Post')) {
299
- $object = AAM::getUser()->getObject('post', $post->ID, $post);
300
- $edit = $object->has('backend.edit');
301
- $others = $object->has('backend.edit_others');
302
-
303
- if ($edit || ($others && !$this->isAuthor($post))) {
304
- AAM_Core_API::reject(
305
- 'backend',
306
- array(
307
- 'hook' => 'post_edit',
308
- 'action' => 'backend.edit',
309
- 'post' => $post
310
- )
311
- );
312
- }
313
- }
314
- }
315
-
316
- /**
317
- * Get Post ID
318
- *
319
- * Replication of the same mechanism that is in wp-admin/post.php
320
- *
321
- * @return WP_Post|null
322
- *
323
- * @access public
324
- */
325
- public function getPost() {
326
- $post = null;
327
-
328
- if (get_post()) {
329
- $post = get_post();
330
- } elseif ($post_id = AAM_Core_Request::get('post')) {
331
- $post = get_post($post_id);
332
- } elseif ($post_id = AAM_Core_Request::get('post_ID')) {
333
- $post = get_post($post_id);
334
- }
335
-
336
- return $post;
337
  }
338
 
339
  /**
 
340
  *
341
- * @global type $wpdb
342
- * @param type $fields
343
- * @param type $query
344
- * @return type
 
 
345
  */
346
- public function fieldsRequest($fields, $query) {
347
- global $wpdb;
348
-
349
- $qfields = (isset($query->query['fields']) ? $query->query['fields'] : '');
350
 
351
- if ($qfields == 'id=>parent') {
352
- $author = "{$wpdb->posts}.post_author";
353
- if (strpos($fields, $author) === false) {
354
- $fields .= ", $author";
355
- }
356
 
357
- $status = "{$wpdb->posts}.post_status";
358
- if (strpos($fields, $status) === false) {
359
- $fields .= ", $status";
 
360
  }
361
-
362
- $type = "{$wpdb->posts}.post_type";
363
- if (strpos($fields, $type) === false) {
364
- $fields .= ", $type";
365
- }
366
  }
367
 
368
- return $fields;
369
  }
370
-
371
  /**
372
- * Filter posts from the list
373
  *
374
  * @param int $counter
375
  * @param WP_Query $query
@@ -378,7 +287,7 @@ class AAM_Backend_Filter {
378
  *
379
  * @access public
380
  */
381
- public function foundPosts($counter, $query) {
382
  $filtered = array();
383
 
384
  foreach ($query->posts as $post) {
@@ -403,6 +312,42 @@ class AAM_Backend_Filter {
403
  return $counter;
404
  }
405
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  /**
407
  * Prepare pre post query
408
  *
@@ -428,152 +373,127 @@ class AAM_Backend_Filter {
428
  }
429
  }
430
  }
431
-
432
  /**
433
- * Check user capability
434
  *
435
- * This is a hack function that add additional layout on top of WordPress
436
- * core functionality. Based on the capability passed in the $args array as
437
- * "0" element, it performs additional check on user's capability to manage
438
- * post.
439
  *
440
- * @param array $allCaps
441
- * @param array $metaCaps
442
- * @param array $args
443
  *
444
- * @return array
445
  *
446
  * @access public
447
  */
448
- public function checkUserCap($allCaps, $metaCaps, $args) {
449
- global $post;
450
 
451
- //make sure that $args[2] is actually post ID
452
- if (isset($args[2]) && is_scalar($args[2])) {
453
- switch($args[0]) {
454
- case 'edit_post':
455
- $object = AAM::getUser()->getObject('post', $args[2]);
456
- if ($object->getPost()->post_status != 'auto-draft') {
457
- $edit = $object->has('backend.edit');
458
- $others = $object->has('backend.edit_others');
459
- if ($edit || ($others && !$this->isAuthor($object->getPost()))) {
460
- $allCaps = $this->restrictPostActions($allCaps, $metaCaps);
461
- }
462
- }
463
- break;
464
-
465
- case 'delete_post' :
466
- $object = AAM::getUser()->getObject('post', $args[2]);
467
- $delete = $object->has('backend.delete');
468
- $others = $object->has('backend.delete_others');
469
- if ($delete || ($others && !$this->isAuthor($object->getPost()))) {
470
- $allCaps = $this->restrictPostActions($allCaps, $metaCaps);
471
- }
472
- break;
473
-
474
- default:
475
- $allCaps = apply_filters(
476
- 'aam-check-user-cap-filter',
477
- $allCaps,
478
- $metaCaps,
479
- $args,
480
- $this
481
- );
482
- break;
483
- }
484
- } elseif (is_a($post, 'WP_Post')) {
485
- switch ($args[0]) {
486
- case 'publish_posts':
487
- case 'publish_pages':
488
- $object = AAM::getUser()->getObject('post', $post->ID);
489
- $publish = $object->has('backend.publish');
490
- $others = $object->has('backend.publish_others');
491
- if ($publish || ($others && !$this->isAuthor($post))) {
492
- $allCaps = $this->restrictPostActions($allCaps, $metaCaps);
493
- }
494
- break;
495
-
496
- default:
497
- $allCaps = apply_filters(
498
- 'aam-check-user-cap-filter',
499
- $allCaps,
500
- $metaCaps,
501
- $args,
502
- $this
503
- );
504
- break;
505
- }
506
  }
507
-
508
- return $allCaps;
509
  }
510
 
511
  /**
 
 
 
 
 
 
 
 
512
  *
513
- * @param type $flag
514
- * @return type
515
  */
516
- public function screenOptions($flag) {
517
- if (AAM_Core_API::capabilityExists('show_screen_options')) {
518
- $flag = AAM::getUser()->hasCapability('show_screen_options');
519
- }
520
 
521
- return $flag;
 
 
 
 
 
 
 
 
 
 
 
 
522
  }
523
 
524
  /**
 
 
 
525
  *
526
- * @param array $help
527
- * @param type $id
528
- * @param type $screen
529
  * @return array
530
  */
531
- public function helpOptions($help, $id, $screen) {
532
- if (AAM_Core_API::capabilityExists('show_help_tabs')) {
533
- if (!AAM::getUser()->hasCapability('show_help_tabs')) {
534
- $screen->remove_help_tabs();
535
- $help = array();
 
 
 
536
  }
537
  }
538
 
539
- return $help;
540
  }
541
 
542
  /**
543
- * Restrict user capabilities
544
  *
545
- * Iterate through the list of meta capabilities and disable them in the
546
- * list of all user capabilities. Keep in mind that this disable caps only
547
- * for one time call.
548
  *
549
- * @param array $allCaps
550
- * @param array $metaCaps
551
  *
552
- * @return array
553
  *
554
- * @access protected
555
  */
556
- protected function restrictPostActions($allCaps, $metaCaps) {
557
- foreach($metaCaps as $cap) {
558
- $allCaps[$cap] = false;
 
 
 
 
 
 
 
559
  }
560
 
561
- return $allCaps;
562
  }
563
 
564
  /**
565
- * Check if user is post author
566
  *
567
- * @param WP_Post $post
568
  *
569
- * @return boolean
570
  *
571
- * @access protected
572
  */
573
- protected function isAuthor($post) {
574
- return ($post->post_author == get_current_user_id());
 
 
 
 
 
 
 
 
 
 
575
  }
576
-
577
  /**
578
  * Register backend filters and actions
579
  *
44
  add_action("in_admin_header", array($this, 'metaboxes'), 999);
45
 
46
  //control admin area
 
47
  add_action('admin_notices', array($this, 'adminNotices'), -1);
48
  add_action('network_admin_notices', array($this, 'adminNotices'), -1);
49
  add_action('user_admin_notices', array($this, 'adminNotices'), -1);
50
 
51
+ //admin bar
52
+ add_action('wp_before_admin_bar_render', array($this, 'filterAdminBar'), 999);
53
+
54
  //post restrictions
55
  add_filter('page_row_actions', array($this, 'postRowActions'), 10, 2);
56
  add_filter('post_row_actions', array($this, 'postRowActions'), 10, 2);
 
57
 
58
  //default category filder
59
+ add_filter('pre_option_default_category', array($this, 'filterDefaultCategory'));
60
 
61
  //add post filter for LIST restriction
62
  if (!AAM::isAAM() && AAM_Core_Config::get('check-post-visibility', true)) {
63
+ add_filter('found_posts', array($this, 'filterPostCount'), 999, 2);
64
  add_filter('posts_fields_request', array($this, 'fieldsRequest'), 999, 2);
65
  add_action('pre_get_posts', array($this, 'preparePostQuery'), 999);
66
  }
70
  //user profile update action
71
  add_action('profile_update', array($this, 'profileUpdate'), 10, 2);
72
 
73
+ //user/role filters
74
+ add_filter('editable_roles', array($this, 'filterRoles'));
75
+ add_action('pre_get_users', array($this, 'filterUserQuery'), 999);
76
+ add_filter('views_users', array($this, 'filterViews'));
77
 
78
+ AAM_Backend_Authorization::bootstrap(); //bootstrap backend authorization
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
  /**
93
 
94
  return $parent_file;
95
  }
96
+
97
  /**
98
  * Handle metabox initialization process
99
  *
118
  }
119
  }
120
 
121
+ /**
122
+ * Manage notifications visibility
123
+ *
124
+ * @return void
125
+ *
126
+ * @access public
127
+ */
128
+ public function adminNotices() {
129
+ if (AAM_Core_API::capabilityExists('show_admin_notices')) {
130
+ if (!AAM::getUser()->hasCapability('show_admin_notices')) {
131
+ remove_all_actions('admin_notices');
132
+ remove_all_actions('network_admin_notices');
133
+ remove_all_actions('user_admin_notices');
134
+ }
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Filter top admin bar
140
+ *
141
+ * The filter will be performed based on the Backend Menu access settings
142
+ *
143
+ * @return void
144
+ *
145
+ * @access public
146
+ * @global WP_Admin_Bar $wp_admin_bar
147
+ */
148
+ public function filterAdminBar() {
149
+ global $wp_admin_bar;
150
+
151
+ $menu = AAM::getUser()->getObject('menu');
152
+ foreach($wp_admin_bar->get_nodes() as $id => $node) {
153
+ if (!empty($node->href)) {
154
+ $suffix = str_replace(admin_url(), '', $node->href);
155
+ if ($menu->has($suffix, true)) {
156
+ if (empty($node->parent) && $this->hasChildren($id)) { //root level
157
+ $node->href = '#';
158
+ $wp_admin_bar->add_node($node);
159
+ } else {
160
+ $wp_admin_bar->remove_menu($id);
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Check if specified top bar item has children
169
+ *
170
+ * @param string $id
171
+ *
172
+ * @return boolean
173
+ *
174
+ * @access protected
175
+ * @global WP_Admin_Bar $wp_admin_bar
176
+ */
177
+ protected function hasChildren($id) {
178
+ global $wp_admin_bar;
179
+
180
+ $has = false;
181
+
182
+ foreach($wp_admin_bar->get_nodes() as $node) {
183
+ if ($node->parent == $id) {
184
+ $has = true;
185
+ break;
186
+ }
187
+ }
188
+
189
+ return $has;
190
+ }
191
+
192
  /**
193
  * Post Quick Menu Actions Filtering
194
  *
202
  public function postRowActions($actions, $post) {
203
  $object = AAM::getUser()->getObject('post', $post->ID, $post);
204
 
 
 
 
205
  //filter edit menu
206
+ if (!$this->isAllowed('backend.edit', $object)) {
207
  if (isset($actions['edit'])) {
208
  unset($actions['edit']);
209
  }
212
  }
213
  }
214
 
 
 
 
215
  //filter delete menu
216
+ if (!$this->isAllowed('backend.delete', $object)) {
217
+ if (isset($actions['trash'])) { unset($actions['trash']); }
218
+ if (isset($actions['delete'])) { unset($actions['delete']); }
 
 
 
 
219
  }
220
 
 
 
 
221
  //filter edit menu
222
+ if (!$this->isAllowed('backend.publish', $object)) {
223
  if (isset($actions['inline hide-if-no-js'])) {
224
  unset($actions['inline hide-if-no-js']);
225
  }
227
 
228
  return $actions;
229
  }
230
+
231
  /**
232
+ * Check if action is allowed
233
+ *
234
+ * This method will take in consideration also *_others action
235
+ *
236
+ * @param string $action
237
+ * @param AAM_Core_Object_Post $object
238
+ *
239
+ * @return boolean
240
+ *
241
+ * @access protected
242
  */
243
+ protected function isAllowed($action, $object) {
244
+ $edit = $object->has($action);
245
+ $others = $object->has("{$action}_others");
246
+ $author = ($object->post_author == get_current_user_id());
247
 
248
+ return ($edit || ($others && !$author)) ? false : true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
250
 
251
  /**
252
+ * Override default category if defined
253
  *
254
+ * @param type $category
255
+ *
256
+ * @return int
257
+ *
258
+ * @access public
259
+ * @staticvar type $default
260
  */
261
+ public function filterDefaultCategory($category) {
262
+ static $default = null;
 
 
263
 
264
+ if (is_null($default)) {
265
+ //check if user category is defined
266
+ $id = get_current_user_id();
267
+ $default = AAM_Core_Config::get('default.category.user.' . $id , null);
268
+ $roles = AAM::getUser()->roles;
269
 
270
+ if (is_null($default) && count($roles)) {
271
+ $default = AAM_Core_Config::get(
272
+ 'default.category.role.' . array_shift($roles), false
273
+ );
274
  }
 
 
 
 
 
275
  }
276
 
277
+ return ($default ? $default : $category);
278
  }
279
+
280
  /**
281
+ * Filter post count for pagination
282
  *
283
  * @param int $counter
284
  * @param WP_Query $query
287
  *
288
  * @access public
289
  */
290
+ public function filterPostCount($counter, $query) {
291
  $filtered = array();
292
 
293
  foreach ($query->posts as $post) {
312
  return $counter;
313
  }
314
 
315
+ /**
316
+ * Filter pages fields
317
+ *
318
+ * @param string $fields
319
+ * @param WP_Query $query
320
+ *
321
+ * @return string
322
+ *
323
+ * @access public
324
+ * @global WPDB $wpdb
325
+ */
326
+ public function fieldsRequest($fields, $query) {
327
+ global $wpdb;
328
+
329
+ $qfields = (isset($query->query['fields']) ? $query->query['fields'] : '');
330
+
331
+ if ($qfields == 'id=>parent') {
332
+ $author = "{$wpdb->posts}.post_author";
333
+ if (strpos($fields, $author) === false) {
334
+ $fields .= ", $author";
335
+ }
336
+
337
+ $status = "{$wpdb->posts}.post_status";
338
+ if (strpos($fields, $status) === false) {
339
+ $fields .= ", $status";
340
+ }
341
+
342
+ $type = "{$wpdb->posts}.post_type";
343
+ if (strpos($fields, $type) === false) {
344
+ $fields .= ", $type";
345
+ }
346
+ }
347
+
348
+ return $fields;
349
+ }
350
+
351
  /**
352
  * Prepare pre post query
353
  *
373
  }
374
  }
375
  }
376
+
377
  /**
378
+ * Post update hook
379
  *
380
+ * Clear cache if post owner changed
 
 
 
381
  *
382
+ * @param int $id
383
+ * @param array $data
 
384
  *
385
+ * @return void
386
  *
387
  * @access public
388
  */
389
+ public function prePostUpdate($id, $data) {
390
+ $post = get_post($id);
391
 
392
+ if ($post->post_author != $data['post_author']) {
393
+ AAM_Core_Cache::clear($id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
  }
 
 
395
  }
396
 
397
  /**
398
+ * Profile updated hook
399
+ *
400
+ * Adjust expiration time and user cache if profile updated
401
+ *
402
+ * @param int $id
403
+ * @param WP_User $old
404
+ *
405
+ * @return void
406
  *
407
+ * @access public
 
408
  */
409
+ public function profileUpdate($id, $old) {
410
+ $user = get_user_by('ID', $id);
 
 
411
 
412
+ //role changed?
413
+ if (implode('', $user->roles) != implode('', $old->roles)) {
414
+ AAM_Core_Cache::clear($id);
415
+
416
+ //check if role has expiration data set
417
+ $role = (is_array($user->roles) ? $user->roles[0] : '');
418
+ $expire = AAM_Core_API::getOption("aam-role-{$role}-expiration", '');
419
+
420
+ if ($expire) {
421
+ update_user_option($id, "aam-original-roles", $old->roles);
422
+ update_user_option($id, "aam-role-expires", strtotime($expire));
423
+ }
424
+ }
425
  }
426
 
427
  /**
428
+ * Filter roles
429
+ *
430
+ * @param array $roles
431
  *
 
 
 
432
  * @return array
433
  */
434
+ public function filterRoles($roles) {
435
+ $userLevel = AAM_Core_API::maxLevel(AAM::getUser()->allcaps);
436
+
437
+ //filter roles
438
+ foreach($roles as $id => $role) {
439
+ $roleLevel = AAM_Core_API::maxLevel($role['capabilities']);
440
+ if ($userLevel < $roleLevel) {
441
+ unset($roles[$id]);
442
  }
443
  }
444
 
445
+ return $roles;
446
  }
447
 
448
  /**
449
+ * Filter user query
450
  *
451
+ * Exclude all users that have higher user level
 
 
452
  *
453
+ * @param object $query
 
454
  *
455
+ * @access public
456
  *
457
+ * @return void
458
  */
459
+ public function filterUserQuery($query) {
460
+ //current user max level
461
+ $max = AAM_Core_API::maxLevel(AAM::getUser()->allcaps);
462
+ $exclude = array();
463
+ $roles = AAM_Core_API::getRoles();
464
+
465
+ foreach($roles->role_objects as $id => $role) {
466
+ if (AAM_Core_API::maxLevel($role->capabilities) > $max) {
467
+ $exclude[] = $id;
468
+ }
469
  }
470
 
471
+ $query->query_vars['role__not_in'] = $exclude;
472
  }
473
 
474
  /**
475
+ * Filter user list view options
476
  *
477
+ * @param array $views
478
  *
479
+ * @return array
480
  *
481
+ * @access public
482
  */
483
+ public function filterViews($views) {
484
+ $max = AAM_Core_API::maxLevel(AAM::getUser()->allcaps);
485
+ $roles = AAM_Core_API::getRoles();
486
+
487
+ foreach($roles->role_objects as $id => $role) {
488
+ if (isset($views[$id])
489
+ && AAM_Core_API::maxLevel($role->capabilities) > $max) {
490
+ unset($views[$id]);
491
+ }
492
+ }
493
+
494
+ return $views;
495
  }
496
+
497
  /**
498
  * Register backend filters and actions
499
  *
Application/Backend/Manager.php CHANGED
@@ -41,13 +41,23 @@ class AAM_Backend_Manager {
41
  //print required JS & CSS
42
  add_action('admin_print_scripts', array($this, 'printJavascript'));
43
  add_action('admin_print_styles', array($this, 'printStylesheet'));
 
 
 
 
 
 
 
 
 
 
44
 
45
  //manager Admin Menu
46
  if (is_multisite() && is_network_admin()) {
47
  //register AAM in the network admin panel
48
- add_action('network_admin_menu', array($this, 'adminMenu'), 999);
49
  } else {
50
- add_action('admin_menu', array($this, 'adminMenu'), 999);
51
  add_action('all_admin_notices', array($this, 'notification'));
52
  }
53
 
@@ -89,16 +99,86 @@ class AAM_Backend_Manager {
89
  add_action('admin_init', array($this, 'adminInit'));
90
 
91
  //register login widget
92
- add_action('widgets_init', array($this, 'registerLoginWidget'));
93
- add_action('wp_ajax_nopriv_aamlogin', array($this, 'handleLogin'));
 
 
94
 
95
  //register backend hooks and filters
96
  if (AAM_Core_Config::get('backend-access-control', true)) {
97
  AAM_Backend_Filter::register();
98
  }
99
 
100
- //register CodePinch affiliate
101
- AAM_Backend_View_CodePinch::bootstrap();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
103
 
104
  /**
@@ -116,18 +196,10 @@ class AAM_Backend_Manager {
116
  *
117
  */
118
  public function adminInit() {
119
- $user = AAM::getUser();
120
-
121
- if (AAM_Core_API::capabilityExists('aam_manage_posts')) {
122
- $cap = 'aam_manage_posts';
123
- } else {
124
- $cap = AAM_Core_Config::get(
125
- AAM_Backend_Feature_Post::getAccessOption(),
126
- AAM_Backend_View::getAAMCapability()
127
- );
128
- }
129
 
130
- if (AAM_Core_Request::get('aamframe') && $user->hasCapability($cap)) {
131
  echo AAM_Backend_View::getInstance()->renderAccessFrame();
132
  exit;
133
  }
@@ -233,19 +305,10 @@ class AAM_Backend_Manager {
233
  *
234
  */
235
  public function metabox() {
236
- if (AAM_Core_API::capabilityExists('aam_manage_posts')) {
237
- $cap = 'aam_manage_posts';
238
- } else {
239
- $cap = AAM_Core_Config::get(
240
- AAM_Backend_Feature_Post::getAccessOption(),
241
- AAM_Backend_View::getAAMCapability()
242
- );
243
- }
244
-
245
  $frontend = AAM_Core_Config::get('frontend-access-control', true);
246
  $backend = AAM_Core_Config::get('backend-access-control', true);
247
 
248
- if (($frontend || $backend) && AAM::getUser()->hasCapability($cap)) {
249
  add_meta_box(
250
  'aam-acceess-manager',
251
  __('Access Manager', AAM_KEY) . ' <small style="color:#999999;">by AAM plugin</small>',
@@ -275,19 +338,10 @@ class AAM_Backend_Manager {
275
  */
276
  public function renderTermMetabox($term) {
277
  if (is_a($term, 'WP_Term') && is_taxonomy_hierarchical($term->taxonomy)) {
278
- if (AAM_Core_API::capabilityExists('aam_manage_posts')) {
279
- $cap = 'aam_manage_posts';
280
- } else {
281
- $option = AAM_Backend_Feature_Post::getAccessOption();
282
- $cap = AAM_Core_Config::get(
283
- $option, AAM_Backend_View::getAAMCapability()
284
- );
285
- }
286
-
287
  $frontend = AAM_Core_Config::get('frontend-access-control', true);
288
  $backend = AAM_Core_Config::get('backend-access-control', true);
289
 
290
- if (($frontend || $backend) && AAM::getUser()->hasCapability($cap)) {
291
  echo AAM_Backend_View::getInstance()->renderTermMetabox($term);
292
  }
293
  }
@@ -313,7 +367,7 @@ class AAM_Backend_Manager {
313
  $screen = '';
314
  }
315
 
316
- $model = new AAM_Backend_Feature_Metabox;
317
  $model->initialize($screen);
318
  }
319
  }
@@ -340,7 +394,7 @@ class AAM_Backend_Manager {
340
  * @return string
341
  */
342
  public function postRowActions($actions, $post) {
343
- if (AAM::getUser()->hasCapability(AAM_Backend_View::getAAMCapability())) {
344
  $url = admin_url('admin.php?page=aam&oid=' . $post->ID . '&otype=post#post');
345
 
346
  $actions['aam'] = '<a href="' . $url . '" target="_blank">';
@@ -357,7 +411,7 @@ class AAM_Backend_Manager {
357
  * @return string
358
  */
359
  public function tagRowActions($actions, $term) {
360
- if (AAM::getUser()->hasCapability(AAM_Backend_View::getAAMCapability())) {
361
  $oid = $term->term_id . '|' . $term->taxonomy;
362
  $url = admin_url('admin.php?page=aam&oid=' . $oid . '&otype=term#post');
363
 
@@ -381,7 +435,7 @@ class AAM_Backend_Manager {
381
  * @access public
382
  */
383
  public function userActions($actions, $user) {
384
- if (current_user_can(AAM_Backend_View::getAAMCapability(), $user->ID)) {
385
  $url = admin_url('admin.php?page=aam&user=' . $user->ID);
386
 
387
  $actions['aam'] = '<a href="' . $url . '" target="_blank">';
@@ -390,6 +444,20 @@ class AAM_Backend_Manager {
390
 
391
  return $actions;
392
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
393
 
394
  /**
395
  * Print javascript libraries
@@ -418,7 +486,7 @@ class AAM_Backend_Manager {
418
  * @access protected
419
  */
420
  protected function printLocalization($localKey) {
421
- $subject = $this->getCurrentSubject();
422
 
423
  $locals = array(
424
  'nonce' => wp_create_nonce('aam_ajax'),
@@ -430,16 +498,16 @@ class AAM_Backend_Manager {
430
  ),
431
  'level' => AAM_Core_API::maxLevel(wp_get_current_user()->allcaps),
432
  'subject' => array(
433
- 'type' => $subject->type,
434
- 'id' => $subject->id,
435
- 'name' => $subject->name,
436
- 'level' => $subject->level,
437
  'blog' => get_current_blog_id()
438
  ),
439
- 'translation' => require (dirname(__FILE__) . '/View/Localization.php'),
440
  'caps' => array(
441
- 'create_roles' => AAM_Backend_View::userCan('aam_create_roles'),
442
- 'create_users' => AAM_Backend_View::userCan('create_users')
443
  )
444
  );
445
 
@@ -450,60 +518,6 @@ class AAM_Backend_Manager {
450
  wp_localize_script($localKey, 'aamLocal', $locals);
451
  }
452
 
453
- /**
454
- * Get current subject
455
- *
456
- * @return stdClass
457
- *
458
- * @access protected
459
- */
460
- protected function getCurrentSubject() {
461
- $userId = AAM_Core_Request::get('user');
462
- if ($userId && AAM_Backend_View::userCan('list_users')) {
463
- $u = get_user_by('id', $userId);
464
- $subject = array(
465
- 'type' => 'user',
466
- 'id' => $userId,
467
- 'name' => ($u->display_name ? $u->display_name : $u->user_nicename),
468
- 'level' => AAM_Core_API::maxLevel($u->allcaps)
469
- );
470
- } elseif (AAM_Backend_View::userCan('aam_list_roles')) {
471
- $roles = array_keys(get_editable_roles());
472
- $id = array_shift($roles);
473
- $role = AAM_Core_API::getRoles()->get_role($id);
474
-
475
- $subject = array(
476
- 'type' => 'role',
477
- 'id' => $id,
478
- 'name' => $role->name,
479
- 'level' => AAM_Core_API::maxLevel($role->capabilities)
480
- );
481
- } elseif (AAM_Backend_View::userCan('aam_manage_visitors')) {
482
- $subject = array(
483
- 'type' => 'visitor',
484
- 'id' => null,
485
- 'name' => __('Anonymous', AAM_KEY),
486
- 'level' => 0
487
- );
488
- } elseif (AAM_Backend_View::userCan('aam_manage_default')) {
489
- $subject = array(
490
- 'type' => 'default',
491
- 'id' => null,
492
- 'name' => __('All Users, Roles and Visitor', AAM_KEY),
493
- 'level' => 0
494
- );
495
- } else {
496
- $subject = array(
497
- 'type' => null,
498
- 'id' => null,
499
- 'name' => null,
500
- 'level' => 0
501
- );
502
- }
503
-
504
- return (object) $subject;
505
- }
506
-
507
  /**
508
  * Print necessary styles
509
  *
@@ -527,7 +541,7 @@ class AAM_Backend_Manager {
527
  * @access public
528
  */
529
  public function adminMenu() {
530
- if (AAM_Core_Console::hasIssues()) {
531
  $counter = '&nbsp;<span class="update-plugins">'
532
  . '<span class="plugin-count">' . AAM_Core_Console::count()
533
  . '</span></span>';
@@ -539,7 +553,7 @@ class AAM_Backend_Manager {
539
  add_menu_page(
540
  'AAM',
541
  'AAM' . $counter,
542
- AAM_Backend_View::getAAMCapability(),
543
  'aam',
544
  array($this, 'renderPage'),
545
  AAM_MEDIA . '/active-menu.svg'
@@ -570,8 +584,10 @@ class AAM_Backend_Manager {
570
  public function renderContent() {
571
  check_ajax_referer('aam_ajax');
572
 
573
- if (AAM::getUser()->hasCapability(AAM_Backend_View::getAAMCapability())) {
574
- echo AAM_Backend_View::getInstance()->renderContent();
 
 
575
  } else {
576
  echo __('Access Denied', AAM_KEY);
577
  }
@@ -593,7 +609,7 @@ class AAM_Backend_Manager {
593
  while (@ob_end_clean()){}
594
 
595
  //process ajax request
596
- if (AAM::getUser()->hasCapability(AAM_Backend_View::getAAMCapability())) {
597
  echo AAM_Backend_View::getInstance()->processAjax();
598
  } else {
599
  echo __('Access Denied', AAM_KEY);
41
  //print required JS & CSS
42
  add_action('admin_print_scripts', array($this, 'printJavascript'));
43
  add_action('admin_print_styles', array($this, 'printStylesheet'));
44
+
45
+ //map AAM UI specific capabilities
46
+ add_filter('map_meta_cap', array($this, 'mapMetaCap'), 10, 4);
47
+
48
+ //post title decorator
49
+ add_filter('the_title', array($this, 'theTitle'), 10, 2);
50
+
51
+ //screen options & contextual help hooks
52
+ add_filter('screen_options_show_screen', array($this, 'screenOptions'));
53
+ add_filter('contextual_help', array($this, 'helpOptions'), 10, 3);
54
 
55
  //manager Admin Menu
56
  if (is_multisite() && is_network_admin()) {
57
  //register AAM in the network admin panel
58
+ add_action('network_admin_menu', array($this, 'adminMenu'));
59
  } else {
60
+ add_action('admin_menu', array($this, 'adminMenu'));
61
  add_action('all_admin_notices', array($this, 'notification'));
62
  }
63
 
99
  add_action('admin_init', array($this, 'adminInit'));
100
 
101
  //register login widget
102
+ if (AAM_Core_Config::get('secure-login', true)) {
103
+ add_action('widgets_init', array($this, 'registerLoginWidget'));
104
+ add_action('wp_ajax_nopriv_aamlogin', array($this, 'handleLogin'));
105
+ }
106
 
107
  //register backend hooks and filters
108
  if (AAM_Core_Config::get('backend-access-control', true)) {
109
  AAM_Backend_Filter::register();
110
  }
111
 
112
+ AAM_Extension_Repository::getInstance()->hasUpdates();
113
+ }
114
+
115
+ /**
116
+ *
117
+ * @param type $caps
118
+ * @param type $cap
119
+ * @return type
120
+ */
121
+ public function mapMetaCap($caps, $cap) {
122
+ if (in_array($cap, AAM_Backend_Feature_Main_Capability::$groups['aam'])) {
123
+ if (!AAM_Core_API::capabilityExists($cap)) {
124
+ $caps = array(AAM_Core_Config::get('page.capability', 'administrator'));
125
+ }
126
+ }
127
+
128
+ return $caps;
129
+ }
130
+
131
+ /**
132
+ *
133
+ * @param type $title
134
+ * @param type $id
135
+ * @return type
136
+ */
137
+ public function theTitle($title, $id) {
138
+ if (empty($title)) {
139
+ $title = '[No Title]: ID ' . $id;
140
+ }
141
+
142
+ return $title;
143
+ }
144
+
145
+ /**
146
+ *
147
+ * @param type $flag
148
+ * @return type
149
+ */
150
+ public function screenOptions($flag) {
151
+ if (AAM_Core_API::capabilityExists('show_screen_options')) {
152
+ $flag = AAM::getUser()->hasCapability('show_screen_options');
153
+ }
154
+
155
+ if (AAM::isAAM()) {
156
+ $flag = false;
157
+ }
158
+
159
+ return $flag;
160
+ }
161
+
162
+ /**
163
+ *
164
+ * @param array $help
165
+ * @param type $id
166
+ * @param type $screen
167
+ * @return array
168
+ */
169
+ public function helpOptions($help, $id, $screen) {
170
+ if (AAM_Core_API::capabilityExists('show_help_tabs')) {
171
+ if (!AAM::getUser()->hasCapability('show_help_tabs')) {
172
+ $screen->remove_help_tabs();
173
+ $help = array();
174
+ }
175
+ }
176
+
177
+ if (AAM::isAAM()) {
178
+ $screen->remove_help_tabs();
179
+ }
180
+
181
+ return $help;
182
  }
183
 
184
  /**
196
  *
197
  */
198
  public function adminInit() {
199
+ $user = AAM::getUser();
200
+ $frame = AAM_Core_Request::get('aamframe');
 
 
 
 
 
 
 
 
201
 
202
+ if ($frame && $user->hasCapability('aam_manage_posts')) {
203
  echo AAM_Backend_View::getInstance()->renderAccessFrame();
204
  exit;
205
  }
305
  *
306
  */
307
  public function metabox() {
 
 
 
 
 
 
 
 
 
308
  $frontend = AAM_Core_Config::get('frontend-access-control', true);
309
  $backend = AAM_Core_Config::get('backend-access-control', true);
310
 
311
+ if (($frontend || $backend) && AAM::getUser()->hasCapability('aam_manage_posts')) {
312
  add_meta_box(
313
  'aam-acceess-manager',
314
  __('Access Manager', AAM_KEY) . ' <small style="color:#999999;">by AAM plugin</small>',
338
  */
339
  public function renderTermMetabox($term) {
340
  if (is_a($term, 'WP_Term') && is_taxonomy_hierarchical($term->taxonomy)) {
 
 
 
 
 
 
 
 
 
341
  $frontend = AAM_Core_Config::get('frontend-access-control', true);
342
  $backend = AAM_Core_Config::get('backend-access-control', true);
343
 
344
+ if (($frontend || $backend) && AAM::getUser()->hasCapability('aam_manage_posts')) {
345
  echo AAM_Backend_View::getInstance()->renderTermMetabox($term);
346
  }
347
  }
367
  $screen = '';
368
  }
369
 
370
+ $model = new AAM_Backend_Feature_Main_Metabox;
371
  $model->initialize($screen);
372
  }
373
  }
394
  * @return string
395
  */
396
  public function postRowActions($actions, $post) {
397
+ if ($this->renderExternalUIFeature('aam_manage_posts')) {
398
  $url = admin_url('admin.php?page=aam&oid=' . $post->ID . '&otype=post#post');
399
 
400
  $actions['aam'] = '<a href="' . $url . '" target="_blank">';
411
  * @return string
412
  */
413
  public function tagRowActions($actions, $term) {
414
+ if ($this->renderExternalUIFeature('aam_manage_posts')) {
415
  $oid = $term->term_id . '|' . $term->taxonomy;
416
  $url = admin_url('admin.php?page=aam&oid=' . $oid . '&otype=term#post');
417
 
435
  * @access public
436
  */
437
  public function userActions($actions, $user) {
438
+ if ($this->renderExternalUIFeature('list_users')) {
439
  $url = admin_url('admin.php?page=aam&user=' . $user->ID);
440
 
441
  $actions['aam'] = '<a href="' . $url . '" target="_blank">';
444
 
445
  return $actions;
446
  }
447
+
448
+ /**
449
+ *
450
+ * @param type $cap
451
+ * @return type
452
+ */
453
+ protected function renderExternalUIFeature($cap) {
454
+ $frontend = AAM_Core_Config::get('frontend-access-control', true);
455
+ $backend = AAM_Core_Config::get('backend-access-control', true);
456
+ $aamManager = AAM::getUser()->hasCapability('aam_manager');
457
+ $featureManager = AAM::getUser()->hasCapability($cap);
458
+
459
+ return ($frontend || $backend) && $aamManager && $featureManager;
460
+ }
461
 
462
  /**
463
  * Print javascript libraries
486
  * @access protected
487
  */
488
  protected function printLocalization($localKey) {
489
+ $subject = AAM_Backend_Subject::getInstance();
490
 
491
  $locals = array(
492
  'nonce' => wp_create_nonce('aam_ajax'),
498
  ),
499
  'level' => AAM_Core_API::maxLevel(wp_get_current_user()->allcaps),
500
  'subject' => array(
501
+ 'type' => $subject->getUID(),
502
+ 'id' => $subject->getId(),
503
+ 'name' => $subject->getName(),
504
+ 'level' => $subject->getMaxLevel(),
505
  'blog' => get_current_blog_id()
506
  ),
507
+ 'translation' => AAM_Backend_View_Localization::get(),
508
  'caps' => array(
509
+ 'create_roles' => current_user_can('aam_create_roles'),
510
+ 'create_users' => current_user_can('create_users')
511
  )
512
  );
513
 
518
  wp_localize_script($localKey, 'aamLocal', $locals);
519
  }
520
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
  /**
522
  * Print necessary styles
523
  *
541
  * @access public
542
  */
543
  public function adminMenu() {
544
+ if (AAM_Core_Console::count()) {
545
  $counter = '&nbsp;<span class="update-plugins">'
546
  . '<span class="plugin-count">' . AAM_Core_Console::count()
547
  . '</span></span>';
553
  add_menu_page(
554
  'AAM',
555
  'AAM' . $counter,
556
+ 'aam_manager',
557
  'aam',
558
  array($this, 'renderPage'),
559
  AAM_MEDIA . '/active-menu.svg'
584
  public function renderContent() {
585
  check_ajax_referer('aam_ajax');
586
 
587
+ if (AAM::getUser()->hasCapability('aam_manager')) {
588
+ echo AAM_Backend_View::getInstance()->renderContent(
589
+ AAM_Core_Request::post('uiType', 'main')
590
+ );
591
  } else {
592
  echo __('Access Denied', AAM_KEY);
593
  }
609
  while (@ob_end_clean()){}
610
 
611
  //process ajax request
612
+ if (AAM::getUser()->hasCapability('aam_manager')) {
613
  echo AAM_Backend_View::getInstance()->processAjax();
614
  } else {
615
  echo __('Access Denied', AAM_KEY);
Application/Backend/Subject.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 subject
12
+ *
13
+ * Currently managed subject. Based on the HTTP request critiria, define what subject
14
+ * is currently managed with AAM UI.
15
+ *
16
+ * @package AAM
17
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
18
+ */
19
+ class AAM_Backend_Subject {
20
+
21
+ /**
22
+ * Single instance of itself
23
+ *
24
+ * @var AAM_Backend_Subject
25
+ *
26
+ * @access protected
27
+ * @static
28
+ */
29
+ protected static $instance = null;
30
+
31
+ /**
32
+ * Subject information
33
+ *
34
+ * @var AAM_Core_Subject
35
+ *
36
+ * @access protected
37
+ */
38
+ protected $subject = null;
39
+
40
+ /**
41
+ * Constructor
42
+ *
43
+ * @return void
44
+ *
45
+ * @access protected
46
+ */
47
+ protected function __construct() {
48
+ $subject = AAM_Core_Request::request('subject');
49
+
50
+ if ($subject) {
51
+ $this->initRequestedSubject(
52
+ $subject, AAM_Core_Request::request('subjectId')
53
+ );
54
+ } else {
55
+ $this->initDefaultSubject();
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Initialize requested subject
61
+ *
62
+ * @param string $type
63
+ * @param string $id
64
+ *
65
+ * @return void
66
+ *
67
+ * @access protected
68
+ */
69
+ protected function initRequestedSubject($type, $id) {
70
+ $classname = 'AAM_Core_Subject_' . ucfirst($type);
71
+
72
+ if (class_exists($classname)) {
73
+ $this->setSubject(new $classname(stripslashes($id)));
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Initialize default subject
79
+ *
80
+ * Based on user permissions, pick the first available subject that current user
81
+ * can manage with AAM UI
82
+ *
83
+ * @return void
84
+ *
85
+ * @access protected
86
+ */
87
+ protected function initDefaultSubject() {
88
+ $user = intval(AAM_Core_Request::get('user'));
89
+
90
+ if ($user && current_user_can('list_users')) {
91
+ $this->initRequestedSubject(AAM_Core_Subject_User::UID, $user);
92
+ } elseif (current_user_can('aam_list_roles')) {
93
+ $roles = array_keys(get_editable_roles());
94
+ $this->initRequestedSubject(AAM_Core_Subject_Role::UID, array_shift($roles));
95
+ } elseif (current_user_can('aam_manage_visitors')) {
96
+ $this->initRequestedSubject(AAM_Core_Subject_Visitor::UID, null);
97
+ } elseif (current_user_can('aam_manage_default')) {
98
+ $this->initRequestedSubject(AAM_Core_Subject_Default::UID, null);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Set subject
104
+ *
105
+ * @param AAM_Core_Subject $subject
106
+ *
107
+ * @access protected
108
+ */
109
+ protected function setSubject(AAM_Core_Subject $subject) {
110
+ $this->subject = $subject;
111
+ }
112
+
113
+ /**
114
+ * Get subject property
115
+ *
116
+ * @return mixed
117
+ *
118
+ * @access public
119
+ */
120
+ public function __get($name) {
121
+ return (!empty($this->subject->$name) ? $this->subject->$name : null);
122
+ }
123
+
124
+ /**
125
+ * Call subject's method
126
+ *
127
+ * @param string $name
128
+ * @param array $args
129
+ *
130
+ * @return mized
131
+ *
132
+ * @access public
133
+ */
134
+ public function __call($name, $args) {
135
+ //make sure that method is callable
136
+ if (method_exists($this->subject, $name)) {
137
+ $response = call_user_func_array(array($this->subject, $name), $args);
138
+ } else {
139
+ $response = null;
140
+ }
141
+
142
+ return $response;
143
+ }
144
+
145
+ /**
146
+ * Get AAM subject
147
+ *
148
+ * @return AAM_Core_Subject
149
+ *
150
+ * @access public
151
+ */
152
+ public function get() {
153
+ return $this->subject;
154
+ }
155
+
156
+ /**
157
+ * Get single instance of the subject
158
+ *
159
+ * @return AAM_Backend_Subject
160
+ *
161
+ * @access public
162
+ * @static
163
+ */
164
+ public static function getInstance() {
165
+ if (is_null(self::$instance)) {
166
+ self::$instance = new self;
167
+ }
168
+
169
+ return self::$instance;
170
+ }
171
+
172
+ }
Application/Backend/View.php CHANGED
@@ -24,15 +24,6 @@ class AAM_Backend_View {
24
  */
25
  private static $_instance = null;
26
 
27
- /**
28
- * Current Subject
29
- *
30
- * @var AAM_Core_Subject
31
- *
32
- * @access private
33
- */
34
- private static $_subject = null;
35
-
36
  /**
37
  * Construct the view object
38
  *
@@ -41,34 +32,22 @@ class AAM_Backend_View {
41
  * @access protected
42
  */
43
  protected function __construct() {
44
- if (AAM_Core_Request::request('subject')) {
45
- $classname = 'AAM_Core_Subject_' . ucfirst(
46
- AAM_Core_Request::request('subject')
47
- );
48
- if (class_exists($classname)) {
49
- $this->setSubject(new $classname(
50
- stripslashes(AAM_Core_Request::request('subjectId'))
51
- ));
52
- }
53
- }
54
-
55
  //register default features
56
- AAM_Backend_Feature_Menu::register();
57
- AAM_Backend_Feature_Metabox::register();
58
- AAM_Backend_Feature_Capability::register();
59
- AAM_Backend_Feature_Post::register();
60
- AAM_Backend_Feature_Redirect::register();
61
- AAM_Backend_Feature_Teaser::register();
62
- AAM_Backend_Feature_LoginRedirect::register();
63
- AAM_Backend_Feature_LogoutRedirect::register();
64
- AAM_Backend_Feature_Extension::register();
65
- AAM_Backend_Feature_Security::register();
66
- AAM_Backend_Feature_Utility::register();
67
- AAM_Backend_Feature_Contact::register();
68
- AAM_Backend_Feature_404Redirect::register();
69
 
70
  //feature registration hook
71
- do_action('aam-feature-registration');
72
  }
73
 
74
  /**
@@ -158,20 +137,29 @@ class AAM_Backend_View {
158
  }
159
 
160
  return apply_filters(
161
- 'aam-ajax-filter', $response, $this->getSubject(), $action
 
 
 
162
  );
163
  }
164
 
165
  /**
166
  * Render the Main Control Area
167
  *
 
 
168
  * @return void
169
  *
170
  * @access public
171
  */
172
- public function renderContent() {
173
  ob_start();
174
- require_once(dirname(__FILE__) . '/phtml/main-panel.phtml');
 
 
 
 
175
  $content = ob_get_contents();
176
  ob_end_clean();
177
 
@@ -208,7 +196,9 @@ class AAM_Backend_View {
208
  $param = AAM_Core_Request::post('param');
209
  $value = AAM_Core_Request::post('value');
210
 
211
- $result = $this->getSubject()->save($param, $value, $object, $objectId);
 
 
212
 
213
  return json_encode(array('status' => ($result ? 'success' : 'failure')));
214
  }
@@ -218,7 +208,9 @@ class AAM_Backend_View {
218
  * @return type
219
  */
220
  public function reset() {
221
- return $this->getSubject()->resetObject(AAM_Core_Request::post('object'));
 
 
222
  }
223
 
224
  /**
@@ -231,7 +223,7 @@ class AAM_Backend_View {
231
  'reason' => 'You are not allowed to switch to this user'
232
  );
233
 
234
- if (self::userCan('aam_switch_users')) {
235
  $user = new WP_User(AAM_Core_Request::post('user'));
236
  $max = AAM_Core_API::maxLevel(wp_get_current_user()->allcaps);
237
 
@@ -251,59 +243,6 @@ class AAM_Backend_View {
251
  return json_encode($response);
252
  }
253
 
254
- /**
255
- *
256
- * @param type $capability
257
- * @return type
258
- */
259
- public static function userCan($capability) {
260
- if (AAM_Core_API::capabilityExists($capability)) {
261
- $can = AAM::getUser()->hasCapability($capability);
262
- } else {
263
- $can = AAM::getUser()->hasCapability(self::getAAMCapability());
264
- }
265
-
266
- return ($can ? 1 : 0);
267
- }
268
-
269
- /**
270
- *
271
- * @return type
272
- */
273
- public static function getAAMCapability() {
274
- if (AAM_Core_API::capabilityExists('aam_manager')) {
275
- $cap = 'aam_manager';
276
- } else {
277
- $cap = AAM_Core_Config::get('page.capability', 'administrator');
278
- }
279
-
280
- return $cap;
281
- }
282
-
283
- /**
284
- * Get Subject
285
- *
286
- * @return AAM_Core_Subject
287
- *
288
- * @access public
289
- */
290
- public static function getSubject() {
291
- return self::$_subject;
292
- }
293
-
294
- /**
295
- * Set Subject
296
- *
297
- * @param AAM_Core_Subject $subject
298
- *
299
- * @return void
300
- *
301
- * @access public
302
- */
303
- protected function setSubject(AAM_Core_Subject $subject) {
304
- self::$_subject = $subject;
305
- }
306
-
307
  /**
308
  * Get instance of itself
309
  *
24
  */
25
  private static $_instance = null;
26
 
 
 
 
 
 
 
 
 
 
27
  /**
28
  * Construct the view object
29
  *
32
  * @access protected
33
  */
34
  protected function __construct() {
 
 
 
 
 
 
 
 
 
 
 
35
  //register default features
36
+ AAM_Backend_Feature_Main_Menu::register();
37
+ AAM_Backend_Feature_Main_Metabox::register();
38
+ AAM_Backend_Feature_Main_Capability::register();
39
+ AAM_Backend_Feature_Main_Post::register();
40
+ AAM_Backend_Feature_Main_Redirect::register();
41
+ AAM_Backend_Feature_Main_LoginRedirect::register();
42
+ AAM_Backend_Feature_Main_LogoutRedirect::register();
43
+ AAM_Backend_Feature_Main_404Redirect::register();
44
+
45
+ AAM_Backend_Feature_Settings_Core::register();
46
+ AAM_Backend_Feature_Settings_Content::register();
47
+ AAM_Backend_Feature_Settings_Tools::register();
 
48
 
49
  //feature registration hook
50
+ do_action('aam-feature-registration-action');
51
  }
52
 
53
  /**
137
  }
138
 
139
  return apply_filters(
140
+ 'aam-ajax-filter',
141
+ $response,
142
+ AAM_Backend_Subject::getInstance()->get(),
143
+ $action
144
  );
145
  }
146
 
147
  /**
148
  * Render the Main Control Area
149
  *
150
+ * @param string $type
151
+ *
152
  * @return void
153
  *
154
  * @access public
155
  */
156
+ public function renderContent($type = 'main') {
157
  ob_start();
158
+ if ($type == 'extensions') {
159
+ AAM_Backend_Feature_Extension_Manager::getInstance()->render();
160
+ } else {
161
+ require_once(dirname(__FILE__) . '/phtml/main-panel.phtml');
162
+ }
163
  $content = ob_get_contents();
164
  ob_end_clean();
165
 
196
  $param = AAM_Core_Request::post('param');
197
  $value = AAM_Core_Request::post('value');
198
 
199
+ $result = AAM_Backend_Subject::getInstance()->save(
200
+ $param, $value, $object, $objectId
201
+ );
202
 
203
  return json_encode(array('status' => ($result ? 'success' : 'failure')));
204
  }
208
  * @return type
209
  */
210
  public function reset() {
211
+ return AAM_Backend_Subject::getInstance()->resetObject(
212
+ AAM_Core_Request::post('object')
213
+ );
214
  }
215
 
216
  /**
223
  'reason' => 'You are not allowed to switch to this user'
224
  );
225
 
226
+ if (current_user_can('aam_switch_users')) {
227
  $user = new WP_User(AAM_Core_Request::post('user'));
228
  $max = AAM_Core_API::maxLevel(wp_get_current_user()->allcaps);
229
 
243
  return json_encode($response);
244
  }
245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  /**
247
  * Get instance of itself
248
  *
Application/Backend/View/CodePinch.php DELETED
@@ -1,151 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Copyright (C) <2016> CodePinch LLC <support@codepinch.com>
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
18
- */
19
-
20
- /**
21
- * CodePinch affiliate main class
22
- *
23
- * @author Vasyl Martyniuk <vasyl@vasyltech.com>
24
- */
25
- class AAM_Backend_View_CodePinch {
26
-
27
- /**
28
- * Single instance of itself
29
- *
30
- * @var AAM_Backend_View_CodePinch
31
- *
32
- * @access private
33
- */
34
- private static $_instance = null;
35
-
36
- /**
37
- * Affiliate construct
38
- *
39
- * @return void
40
- *
41
- * @access protected
42
- */
43
- protected function __construct() {
44
- if (is_admin()) {
45
- //store Affiliate code when plugin information pop-up is opened
46
- add_action(
47
- 'install_plugins_pre_search',
48
- array($this, 'saveAffiliate')
49
- );
50
- }
51
- }
52
-
53
- /**
54
- * Save affiliate code
55
- *
56
- * Store affiliate code to the database when plugin's information pop-up is
57
- * open.
58
- *
59
- * @return void
60
- *
61
- * @access public
62
- */
63
- public function saveAffiliate() {
64
- $affiliate = filter_input(INPUT_GET, 'affiliate');
65
-
66
- if ($affiliate) {
67
- update_option('codepinch-affiliate', $affiliate);
68
- }
69
- }
70
-
71
- /**
72
- * Bootstrap the SKD
73
- *
74
- * The best way to initialize the CodePinch affiliate SDK is in the init
75
- * action so it can register the menu for CodePinch installation process.
76
- *
77
- * @return void
78
- *
79
- * @access public
80
- * @static
81
- */
82
- public static function bootstrap() {
83
- self::$_instance = new self;
84
- }
85
-
86
- /**
87
- * Get URL
88
- *
89
- * Prepare and return CodePinch installation URL based on the passed
90
- * affiliate code
91
- *
92
- * @param string $affiliate
93
- *
94
- * @return string
95
- *
96
- * @access public
97
- */
98
- public static function getUrl($affiliate = null) {
99
- $link = 'plugin-install.php?tab=plugin-information&';
100
- $link .= 's=codepinch&affiliate=' . $affiliate . '&';
101
- $link .= 'tab=search&type=term';
102
-
103
- return self_admin_url($link);
104
- }
105
-
106
- /**
107
- * Check plugin's status
108
- *
109
- * Check if CodePinch is already installed
110
- *
111
- * @return boolean
112
- *
113
- * @access public
114
- * @static
115
- */
116
- public static function isInstalled() {
117
- return self::find();
118
- }
119
-
120
- /**
121
- * Get plugin's status
122
- *
123
- * @return string
124
- *
125
- * @access protected
126
- * @static
127
- */
128
- protected static function find() {
129
- static $status = null;
130
-
131
- if (is_null($status)) {
132
- $status = false;
133
-
134
- if (file_exists(ABSPATH . 'wp-admin/includes/plugin.php')) {
135
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
- }
137
-
138
- if (function_exists('get_plugin_data')) {
139
- foreach(get_plugins() as $plugin) {
140
- if ($plugin['Name'] == 'CodePinch') {
141
- $status = true;
142
- break;
143
- }
144
- }
145
- }
146
- }
147
-
148
- return $status;
149
- }
150
-
151
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Backend/View/Helper.php CHANGED
@@ -50,17 +50,4 @@ class AAM_Backend_View_Helper {
50
  $value = '/\\' . ($index % 2 ? ']' : '[') . '/';
51
  }
52
 
53
- /**
54
- * Conver string to readable
55
- *
56
- * @param string $text
57
- *
58
- * @return string
59
- *
60
- * @access public
61
- */
62
- public static function getHumanText($text) {
63
- return implode(' ', array_map('ucfirst', explode('_', $text)));
64
- }
65
-
66
  }
50
  $value = '/\\' . ($index % 2 ? ']' : '[') . '/';
51
  }
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
Application/Backend/View/Localization.php CHANGED
@@ -7,47 +7,65 @@
7
  * ======================================================================
8
  */
9
 
10
- return array(
11
- 'Search Capability' => __('Search Capability', AAM_KEY),
12
- '_TOTAL_ capability(s)' => __('_TOTAL_ capability(s)', AAM_KEY),
13
- 'Saving...' => __('Saving...', AAM_KEY),
14
- 'Failed to add new capability' => __('Failed to add new capability', AAM_KEY),
15
- 'Application error' => __('Application error', AAM_KEY),
16
- 'Add Capability' => __('Add Capability', AAM_KEY),
17
- 'Show Menu' => __('Show Menu', AAM_KEY),
18
- 'Restrict Menu' => __('Restrict Menu', AAM_KEY),
19
- 'Failed to retrieve mataboxes' => __('Failed to retrieve mataboxes', AAM_KEY),
20
- 'Search' => __('Search', AAM_KEY),
21
- '_TOTAL_ object(s)' => __('_TOTAL_ object(s)', AAM_KEY),
22
- 'Failed' => __('Failed', AAM_KEY),
23
- 'Loading...' => __('Loading...', AAM_KEY),
24
- 'No Role' => __('No Role', AAM_KEY),
25
- 'Search Role' => __('Search Role', AAM_KEY),
26
- '_TOTAL_ role(s)' => __('_TOTAL_ role(s)', AAM_KEY),
27
- 'Create' => __('Create', AAM_KEY),
28
- 'Users' => __('Users', AAM_KEY),
29
- 'Failed to add new role' => __('Failed to add new role', AAM_KEY),
30
- 'Add Role' => __('Add Role', AAM_KEY),
31
- 'Failed to update role' => __('Failed to update role', AAM_KEY),
32
- 'Update' => __('Update', AAM_KEY),
33
- 'Deleting...' => __('Deleting...', AAM_KEY),
34
- 'Failed to delete role' => __('Failed to delete role', AAM_KEY),
35
- 'Delete Role' => __('Delete Role', AAM_KEY),
36
- 'Failed to block user' => __('Failed to block user', AAM_KEY),
37
- 'Search User' => __('Search User', AAM_KEY),
38
- '_TOTAL_ user(s)' => __('_TOTAL_ user(s)', AAM_KEY),
39
- 'Role' => __('Role', AAM_KEY),
40
- 'Anonymous' => __('Anonymous', AAM_KEY),
41
- 'Current user' => __('Current user', AAM_KEY),
42
- 'Current role' => __('Current role', AAM_KEY),
43
- 'Manage Access' => __('Manage Access', AAM_KEY),
44
- 'Edit' => __('Edit', AAM_KEY),
45
- 'Manage Role' => __('Manage Role', AAM_KEY),
46
- 'Edit Role' => __('Edit Role', AAM_KEY),
47
- 'Delete Role' => __('Delete Role', AAM_KEY),
48
- 'Manage User' => __('Manage User', AAM_KEY),
49
- 'Edit User' => __('Edit User', AAM_KEY),
50
- 'Lock User' => __('Lock User', AAM_KEY),
51
- 'Unlock User' => __('Unlock User', AAM_KEY),
52
- 'Failed to grand capability - WordPress policy' => __('Failed to grand capability - WordPress policy', AAM_KEY),
53
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  * ======================================================================
8
  */
9
 
10
+ /**
11
+ * Localization
12
+ *
13
+ */
14
+ class AAM_Backend_View_Localization {
15
+
16
+ /**
17
+ * Get localization array
18
+ *
19
+ * @return array
20
+ *
21
+ * @access public
22
+ * @static
23
+ */
24
+ public static function get() {
25
+ return array(
26
+ 'Search Capability' => __('Search Capability', AAM_KEY),
27
+ '_TOTAL_ capability(s)' => __('_TOTAL_ capability(s)', AAM_KEY),
28
+ 'Saving...' => __('Saving...', AAM_KEY),
29
+ 'Failed to add new capability' => __('Failed to add new capability', AAM_KEY),
30
+ 'Application error' => __('Application error', AAM_KEY),
31
+ 'Add Capability' => __('Add Capability', AAM_KEY),
32
+ 'Show Menu' => __('Show Menu', AAM_KEY),
33
+ 'Restrict Menu' => __('Restrict Menu', AAM_KEY),
34
+ 'Failed to retrieve mataboxes' => __('Failed to retrieve mataboxes', AAM_KEY),
35
+ 'Search' => __('Search', AAM_KEY),
36
+ '_TOTAL_ object(s)' => __('_TOTAL_ object(s)', AAM_KEY),
37
+ 'Failed' => __('Failed', AAM_KEY),
38
+ 'Loading...' => __('Loading...', AAM_KEY),
39
+ 'No Role' => __('No Role', AAM_KEY),
40
+ 'Search Role' => __('Search Role', AAM_KEY),
41
+ '_TOTAL_ role(s)' => __('_TOTAL_ role(s)', AAM_KEY),
42
+ 'Create' => __('Create', AAM_KEY),
43
+ 'Users' => __('Users', AAM_KEY),
44
+ 'Failed to add new role' => __('Failed to add new role', AAM_KEY),
45
+ 'Add Role' => __('Add Role', AAM_KEY),
46
+ 'Failed to update role' => __('Failed to update role', AAM_KEY),
47
+ 'Update' => __('Update', AAM_KEY),
48
+ 'Deleting...' => __('Deleting...', AAM_KEY),
49
+ 'Failed to delete role' => __('Failed to delete role', AAM_KEY),
50
+ 'Delete Role' => __('Delete Role', AAM_KEY),
51
+ 'Failed to block user' => __('Failed to block user', AAM_KEY),
52
+ 'Search User' => __('Search User', AAM_KEY),
53
+ '_TOTAL_ user(s)' => __('_TOTAL_ user(s)', AAM_KEY),
54
+ 'Role' => __('Role', AAM_KEY),
55
+ 'Anonymous' => __('Anonymous', AAM_KEY),
56
+ 'Current user' => __('Current user', AAM_KEY),
57
+ 'Current role' => __('Current role', AAM_KEY),
58
+ 'Manage Access' => __('Manage Access', AAM_KEY),
59
+ 'Edit' => __('Edit', AAM_KEY),
60
+ 'Manage Role' => __('Manage Role', AAM_KEY),
61
+ 'Edit Role' => __('Edit Role', AAM_KEY),
62
+ 'Delete Role' => __('Delete Role', AAM_KEY),
63
+ 'Manage User' => __('Manage User', AAM_KEY),
64
+ 'Edit User' => __('Edit User', AAM_KEY),
65
+ 'Lock User' => __('Lock User', AAM_KEY),
66
+ 'Unlock User' => __('Unlock User', AAM_KEY),
67
+ 'Failed to grand capability - WordPress policy' => __('Failed to grand capability - WordPress policy', AAM_KEY),
68
+ );
69
+ }
70
+
71
+ }
Application/Backend/View/PostOptionList.php CHANGED
@@ -7,81 +7,102 @@
7
  * ======================================================================
8
  */
9
 
10
- return array(
11
- 'frontend' => array(
12
- 'list' => array(
13
- 'title' => __('List', AAM_KEY),
14
- 'descr' => __('Hide %s however access with a direct URL will be still allowed. When there are more than 500 posts, this option may not be applied immediately because, for performance reasons, AAM checks limited number of posts per request.', AAM_KEY) . sprintf(__(' %sSee in action.%s', AAM_KEY), "<a href='https://youtu.be/2jiu_CL6JJg' target='_blank'>", '</a>')
15
- ),
16
- 'list_others' => array(
17
- 'title' => __('List To Others', AAM_KEY),
18
- 'descr' => __('Hide %s for all except author (whoever created %s or was assigned on the Author metabox). Access with a direct URL will be still allowed. When there are more than 500 posts, this option may not be applied immediately because, for performance reasons, AAM checks limited number of posts per request.', AAM_KEY)
19
- ),
20
- 'read' => array(
21
- 'title' => __('Read', AAM_KEY),
22
- 'descr' => __('Restrict access to read %s. Any attempts to read, view or open %s will result in redirecting user based on the Access Denied Redirect rule.', AAM_KEY) . sprintf(__(' %sSee in action.%s', AAM_KEY), "<a href='https://youtu.be/1742nVeGvgs' target='_blank'>", '</a>')
23
- ),
24
- 'read_others' => array(
25
- 'title' => __('Read By Others', AAM_KEY),
26
- 'descr' => __('Restrict access to read %s for all except author (whoever created %s or was assigned on the Author metabox). Any attempts to read, view or open %s will result in redirecting user based on the Access Denied Redirect rule.', AAM_KEY)
27
- ),
28
- 'limit' => array(
29
- 'title' => __('Limit', AAM_KEY),
30
- 'sub' => '<small>' . sprintf(__('Teaser message: %s', AAM_KEY), '<b data-preview="frontend.teaser" id="post-teaser"></b>' ) . ' <a href="#" class="change-teaser" data-ref="frontend.teaser" data-preview-id="post-teaser">' . __('change', AAM_KEY) . '</a></small>',
31
- 'descr' => __('When checked, show defined teaser message instead of the %s content.', AAM_KEY)
32
- ),
33
- 'comment' => array(
34
- 'title' => __('Comment', AAM_KEY),
35
- 'descr' => __('Restrict access to comment on %s when commenting feature is enabled.', AAM_KEY)
36
- ),
37
- 'redirect' => array(
38
- 'title' => __('Redirect', AAM_KEY),
39
- 'sub' => '<small>' . sprintf(__('Redirect to: %s', AAM_KEY), '<b data-preview="frontend.location" id="post-location"></b>' ) . ' <a href="#" class="change-location" data-ref="frontend.location" data-preview-id="post-location">' . __('change', AAM_KEY) . '</a></small>',
40
- 'descr' => __('Redirect user to defined location when user tries to read the %s. Define either valid full URL or public page ID within the website. The REDIRECT option will be ignored if READ option checked and user will be redirected based on the Access Denied Redirect rule.', AAM_KEY)
41
- ),
42
- 'protected' => array(
43
- 'title' => __('Password Protected', AAM_KEY),
44
- 'sub' => '<small>' . sprintf(__('Password: %s', AAM_KEY), '<b data-preview="frontend.password" id="post-password"></b>' ) . ' <a href="#" class="change-password" data-ref="frontend.password" data-preview-id="post-password">' . __('change', AAM_KEY) . '</a></small>',
45
- 'descr' => __('Add the password protection for the %s. Available with WordPress 4.7.0 or higher.', AAM_KEY)
46
- ),
47
- 'expire' => array(
48
- 'title' => __('Access Expiration', AAM_KEY),
49
- 'sub' => '<small>' . sprintf(__('Expires: %s', AAM_KEY), '<b data-preview="frontend.expire_datetime" id="post-expire"></b>' ) . ' <a href="#" class="change-expiration" data-ref="frontend.expire_datetime" data-preview-id="post-expire">' . __('change', AAM_KEY) . '</a></small>',
50
- 'descr' => __('Define when access is expired for %s.', AAM_KEY) . sprintf(__('After the expiration date, the access to READ will be denied unless this behavior is overwritten in ConfigPress. For more information %scheck this article%s or ', AAM_KEY), "<a href='https://aamplugin.com/help/how-to-set-expiration-date-for-any-wordpress-content' target='_blank'>", '</a>') . sprintf(__(' %ssee in action.%s', AAM_KEY), "<a href='https://youtu.be/IgtgVoWs35w' target='_blank'>", '</a>')
51
- ),
52
- ),
53
- 'backend' => array(
54
- 'list' => array(
55
- 'title' => __('List', AAM_KEY),
56
- 'descr' => __('Hide %s however access with a direct URL is still allowed. When there are more than 500 posts, this option may not be applied immediately because, for performance reasons, AAM checks limited number of posts per request.', AAM_KEY)
57
- ),
58
- 'list_others' => array(
59
- 'title' => __('List To Others', AAM_KEY),
60
- 'descr' => __('Hide %s for all except author (whoever created %s or was assigned on the Author metabox). Access with a direct URL is still allowed. When there are more than 500 posts, this option may not be applied immediately because, for performance reasons, AAM checks limited number of posts per request.', AAM_KEY)
61
- ),
62
- 'edit' => array(
63
- 'title' => __('Edit', AAM_KEY),
64
- 'descr' => __('Restrict access to edit %s. Any attempts to edit %s will result in redirecting user based on the Access Denied Redirect rule.', AAM_KEY)
65
- ),
66
- 'edit_others' => array(
67
- 'title' => __('Edit By Others', AAM_KEY),
68
- 'descr' => __('Restrict access to edit %s for all except author (whoever created %s or was assigned on the Author metabox). Any attempts to edit %s will result in redirecting user based on the Access Denied Redirect rule.', AAM_KEY)
69
- ),
70
- 'delete' => array(
71
- 'title' => __('Delete', AAM_KEY),
72
- 'descr' => __('Restrict access to trash or permanently delete %s.', AAM_KEY)
73
- ),
74
- 'delete_others' => array(
75
- 'title' => __('Delete By Others', AAM_KEY),
76
- 'descr' => __('Restrict access to trash or permanently delete %s for all except author (whoever created %s or was assigned on the Author metabox).', AAM_KEY)
77
- ),
78
- 'publish' => array(
79
- 'title' => __('Publish', AAM_KEY),
80
- 'descr' => __('Restrict access to publish %s. User will be allowed only submit for review. Quick Edit inline action is also removed from the list page.', AAM_KEY)
81
- ),
82
- 'publish_others' => array(
83
- 'title' => __('Publish By Others', AAM_KEY),
84
- 'descr' => __('Restrict access to publish %s for all except author (whoever created %s or was assigned on the Author metabox). User will be allowed only submit for review. Quick Edit inline action is also removed from the list page.', AAM_KEY)
85
- )
86
- )
87
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  * ======================================================================
8
  */
9
 
10
+ /**
11
+ * Post option list
12
+ */
13
+ class AAM_Backend_View_PostOptionList {
14
+
15
+ /**
16
+ * Get post option list
17
+ *
18
+ * @return array
19
+ *
20
+ * @access public
21
+ */
22
+ public static function get() {
23
+ return array(
24
+ 'frontend' => array(
25
+ 'list' => array(
26
+ 'title' => __('List', AAM_KEY),
27
+ 'descr' => __('Hide %s however access with a direct URL will be still allowed. When there are more than 500 posts, this option may not be applied immediately because, for performance reasons, AAM checks limited number of posts per request.', AAM_KEY) . sprintf(__(' %sSee in action.%s', AAM_KEY), "<a href='https://youtu.be/2jiu_CL6JJg' target='_blank'>", '</a>'),
28
+ 'config' => 'check-post-visibility'
29
+ ),
30
+ 'read' => array(
31
+ 'title' => __('Read', AAM_KEY),
32
+ 'descr' => __('Restrict access to read the %s. Any attempts to read, view or open the %s will be denied and redirected based on the Access Denied Redirect rule.', AAM_KEY) . sprintf(__(' %sSee in action.%s', AAM_KEY), "<a href='https://youtu.be/1742nVeGvgs' target='_blank'>", '</a>')
33
+ ),
34
+ 'limit' => array(
35
+ 'title' => __('Limit', AAM_KEY),
36
+ 'sub' => __('Teaser message', AAM_KEY),
37
+ 'option' => 'frontend.teaser',
38
+ 'preview' => 'frontend-teaser-preview',
39
+ 'descr' => __('When checked, show defined teaser message instead of the %s content.', AAM_KEY)
40
+ ),
41
+ 'access_counter' => array(
42
+ 'title' => __('Read Counter', AAM_KEY),
43
+ 'sub' => __('Threshold', AAM_KEY),
44
+ 'option' => 'frontend.access_counter_limit',
45
+ 'preview' => 'frontend-access_counter_limit-preview',
46
+ 'exclude' => array(AAM_Core_Subject_Visitor::UID),
47
+ 'descr' => __('Define how many times the %s can be opened to read, view or download. After number of time exceeds the defined threshold, the access will be denied to the %s and redirected based on the Access Denied Redirect rule.', AAM_KEY)
48
+ ),
49
+ 'comment' => array(
50
+ 'title' => __('Comment', AAM_KEY),
51
+ 'descr' => __('Restrict access to comment on %s when commenting feature is enabled.', AAM_KEY)
52
+ ),
53
+ 'redirect' => array(
54
+ 'title' => __('Redirect', AAM_KEY),
55
+ 'sub' => __('Redirect Rule', AAM_KEY),
56
+ 'option' => 'frontend.location',
57
+ 'preview' => 'frontend-location-preview',
58
+ 'descr' => sprintf(__('Redirect user based on the defined redirect rule when user tries to read the %s. The REDIRECT option will be ignored if READ option checked. For more information about this option please refer to the %sHelp Section%s.', AAM_KEY), '%s', '<a href="https://aamplugin.com/help#post-redirect" target="_blank">', '</a>')
59
+ ),
60
+ 'protected' => array(
61
+ 'title' => __('Password Protected', AAM_KEY),
62
+ 'sub' => __('Password', AAM_KEY),
63
+ 'option' => 'frontend.password',
64
+ 'preview' => 'frontend-option-preview',
65
+ 'descr' => __('Password protect the %s. Available with WordPress 4.7.0 or higher.', AAM_KEY)
66
+ ),
67
+ 'expire' => array(
68
+ 'title' => __('Access Expiration', AAM_KEY),
69
+ 'sub' => __('Expires:', AAM_KEY),
70
+ 'option' => 'frontend.expire_datetime',
71
+ 'preview' => 'frontend-expire_datetime-preview',
72
+ 'descr' => __('Define when access expires for %s.', AAM_KEY) . sprintf(__('After expiration, the access to %s will be denied and user will be redirected based on the Access Denied Redirect rule. For more information %scheck this article%s or ', AAM_KEY), '%s', "<a href='https://aamplugin.com/help/how-to-set-expiration-date-for-any-wordpress-content' target='_blank'>", '</a>') . sprintf(__(' %ssee in action.%s', AAM_KEY), "<a href='https://youtu.be/IgtgVoWs35w' target='_blank'>", '</a>')
73
+ ),
74
+ 'monetize' => array(
75
+ 'title' => __('Monetized Access', AAM_KEY),
76
+ 'sub' => __('E-Product', AAM_KEY),
77
+ 'option' => 'frontend.eproduct',
78
+ 'preview' => 'frontend-eproduct-preview',
79
+ 'exclude' => array(AAM_Core_Subject_Visitor::UID),
80
+ 'descr' => sprintf(AAM_Backend_View_Helper::preparePhrase('[Premium feature!] Start selling access to the %s. Access will be granted to read, view or download %s only if selected E-Product had been purchased. For more information %scheck this article%s.', 'b'), '%s', '%s', "<a href='https://aamplugin.com/help/how-to-monetize-access-to-the-wordpress-content' target='_blank'>", '</a>')
81
+ ),
82
+ ),
83
+ 'backend' => array(
84
+ 'list' => array(
85
+ 'title' => __('List', AAM_KEY),
86
+ 'exclude' => array(AAM_Core_Subject_Visitor::UID),
87
+ 'descr' => __('Hide %s however access with a direct URL is still allowed. When there are more than 500 posts, this option may not be applied immediately because, for performance reasons, AAM checks limited number of posts per request.', AAM_KEY),
88
+ 'config' => 'check-post-visibility'
89
+ ),
90
+ 'edit' => array(
91
+ 'title' => __('Edit', AAM_KEY),
92
+ 'exclude' => array(AAM_Core_Subject_Visitor::UID),
93
+ 'descr' => __('Restrict access to edit the %s. Any attempts to edit %s will result in redirecting user based on the Access Denied Redirect rule.', AAM_KEY)
94
+ ),
95
+ 'delete' => array(
96
+ 'title' => __('Delete', AAM_KEY),
97
+ 'exclude' => array(AAM_Core_Subject_Visitor::UID),
98
+ 'descr' => __('Restrict access to trash or permanently delete %s.', AAM_KEY)
99
+ ),
100
+ 'publish' => array(
101
+ 'title' => __('Publish', AAM_KEY),
102
+ 'exclude' => array(AAM_Core_Subject_Visitor::UID),
103
+ 'descr' => __('Restrict access to publish the %s. User will be allowed only submit the %s for review.', AAM_KEY)
104
+ )
105
+ )
106
+ );
107
+ }
108
+ }
Application/Backend/View/SecurityOptionList.php DELETED
@@ -1,26 +0,0 @@
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
- return array(
11
- 'login-timeout' => array(
12
- 'title' => __('Login Timeout', AAM_KEY),
13
- 'descr' => sprintf(__('Delay the login process for %s second to significantly reduce the chance for brute force or dictionary attack.', AAM_KEY), AAM_Core_Config::get('security.login.timeout', 1)),
14
- 'value' => AAM_Core_Config::get('login-timeout', false)
15
- ),
16
- 'login-ip-track' => array(
17
- 'title' => __('Track IP Address', AAM_KEY),
18
- 'descr' => __('Track the IP address for the last successful user login and trigger double authentication via email when the same username/password combination is used to login from a different IP address.', AAM_KEY),
19
- 'value' => AAM_Core_Config::get('login-ip-track', false),
20
- ),
21
- 'brute-force-lockout' => array(
22
- 'title' => __('Brute Force Lockout', AAM_KEY),
23
- 'descr' => sprintf(__('Automatically reject login attempts if number of unsuccessful login attempts is more than %s over the period of %s.', AAM_KEY), AAM_Core_Config::get('security.login.attempts', 20), AAM_Core_Config::get('security.login.period', '2 minutes')),
24
- 'value' => AAM_Core_Config::get('brute-force-lockout', false),
25
- )
26
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Backend/View/UtilityOptionList.php DELETED
@@ -1,59 +0,0 @@
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
- return array(
11
- 'manage-capability' => array(
12
- 'title' => __('Edit/Delete Capabilities', AAM_KEY),
13
- 'descr' => AAM_Backend_View_Helper::preparePhrase('Allow to edit or delete any capability on the Capabilities tab. [Note!] For experienced users only. Changing or deleting capability may result in loosing access to some features or the entire website.', 'b'),
14
- 'value' => AAM_Core_Config::get('manage-capability', false),
15
- 'category' => 'core'
16
- ),
17
- 'backend-access-control' => array(
18
- 'title' => __('Backend Access Control', AAM_KEY),
19
- 'descr' => __('Allow AAM to manage access to backend resources. If there is no need to manage access to the website backend then keep this option unchecked as it may increase your webiste performance.', AAM_KEY),
20
- 'value' => AAM_Core_Config::get('backend-access-control', true),
21
- 'category' => 'core'
22
- ),
23
- 'frontend-access-control' => array(
24
- 'title' => __('Frontend Access Control', AAM_KEY),
25
- 'descr' => __('Allow AAM to manage access to frontend resources. If there is no need to manage access to the website frontend then keep this option unchecked as it may increase your webiste performance.', AAM_KEY),
26
- 'value' => AAM_Core_Config::get('frontend-access-control', true),
27
- 'category' => 'core'
28
- ),
29
- 'media-access-control' => array(
30
- 'title' => __('Media Files Access Control', AAM_KEY),
31
- 'descr' => sprintf(AAM_Backend_View_Helper::preparePhrase('Allow AAM to manage a physically access to all media files located in the defined by the system [uploads] folder. [Note!] This feature requires additional steps as described in %sthis article%s.', 'strong', 'strong'), '<a href="https://aamplugin.com/help/how-to-manage-wordpress-media-access" target="_blank">', '</a>'),
32
- 'value' => AAM_Core_Config::get('media-access-control', false),
33
- 'category' => 'post'
34
- ),
35
- 'check-post-visibility' => array(
36
- 'title' => __('Check Post Visibility', AAM_KEY),
37
- '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),
38
- 'value' => AAM_Core_Config::get('check-post-visibility', true),
39
- 'category' => 'post'
40
- ),
41
- 'manage-hidden-post-types' => array(
42
- 'title' => __('Manage Hidden Post Types', AAM_KEY),
43
- '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),
44
- 'value' => AAM_Core_Config::get('manage-hidden-post-types', false),
45
- 'category' => 'post'
46
- ),
47
- 'render-access-metabox' => array(
48
- 'title' => __('Render Access Manager Metabox', AAM_KEY),
49
- '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),
50
- 'value' => AAM_Core_Config::get('render-access-metabox', true),
51
- 'category' => 'core'
52
- ),
53
- 'show-access-link' => array(
54
- 'title' => __('Show Access Link', AAM_KEY),
55
- 'descr' => __('Show Access shortcut link under any post, page, custom post type, category, custom taxonomy title or user name.', AAM_KEY),
56
- 'value' => AAM_Core_Config::get('show-access-link', true),
57
- 'category' => 'core'
58
- ),
59
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Backend/phtml/contact.phtml DELETED
@@ -1,18 +0,0 @@
1
- <?php if (defined('AAM_KEY')) { ?>
2
- <div class="aam-feature" id="contact-content">
3
- <div class="row">
4
- <div class="col-xs-12">
5
- <p class="aam-info">
6
- <?php echo __('Contact us if you have any questions or concerns but follow few simple rules:'); ?>
7
- </p>
8
- <ol class="text-larger">
9
- <li>Keep your message short. As longer message as more times we will take to response;</li>
10
- <li>Use English, Polish, Russian or Ukrainian language. Otherwise we may ignore your message;</li>
11
- <li>In case of a problem with the plugin, include screenshots, videos or step-by-step description on how to reproduce the issue;</li>
12
- <li>Email us at <a href="mailto:support@aamplugin.com" class="aam-highlight">support@aamplugin.com</a>, add us to Google Hangout or submit contact form on <a href="https://aamplugin.com/help" target="_blank">aamplugin.com</a> website to speed-up the response. Any other channels of communication we will be ignored.</li>
13
- <li>Be patient. It might take up to 3 business days for us to response.</li>
14
- </ol>
15
- </div>
16
- </div>
17
- </div>
18
- <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Backend/phtml/{extension.phtml → extensions.phtml} RENAMED
@@ -1,9 +1,9 @@
1
  <?php if (defined('AAM_KEY')) { ?>
2
- <div class="aam-feature" id="extension-content">
3
  <div class="row">
4
  <div class="col-xs-12">
5
  <p class="aam-info">
6
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('By purchasing any extension below you obtain the license to use it [for one life site] unless you purchased %sdevelopment package%s. The license can be used for unlimited number of test or development sites where URL is either [localhost] or starts with [dev.], [staging.], [test.] or [demo.] [before it is activated on the life site]. Contact us immediately if you have troubles installing extension. [Money back guaranteed] within 10 day from the time of purchase.', 'b', 'i', 'i', 'i', 'i', 'i', 'b', 'b'), '<a href="https://aamplugin.com/development-package" target="_blank">', '</a>'); ?><br/>
7
  </p>
8
  </div>
9
  </div>
@@ -36,31 +36,26 @@
36
  <table class="table table-striped table-bordered">
37
  <tbody>
38
  <?php foreach ($commercial as $i => $product) { ?>
39
- <?php if ($i == 2) { ?>
40
- <tr class="aam-highligh-row">
41
- <td colspan="2">Do not know which extension to choose? <b>Please do not hesitate to <a href="mailto:support@aamplugin.com">send us a message to support@aamplugin.com</a></b>. We speak English, Russian, Ukrainian and Polish. Any other language is acceptable, however we might have some lost in translation.</td>
42
- </tr>
43
- <?php } ?>
44
- <tr>
45
- <td>
46
- <span class='aam-setting-title'><?php echo $product['title'], (!empty($product['new']) ? ' <span class="badge">NEW</span> ' : ''), (!empty($product['version']) ? ' <small class="text-muted">v' . $product['version'] . '</small>' : ''); ?></span>
47
- <?php if (!empty($product['license']) && $this->canShowLicense()) { ?><small class="aam-license-key"><b>License:</b> <?php echo $product['license'] . (!empty($product['expire']) ? " (updates expire at {$product['expire']})" : ''); ?></small><?php } ?>
48
- <p class="aam-extension-description">
49
- <?php echo $product['description']; ?>
50
- </p>
51
- </td>
52
- <td>
53
- <?php if ($product['status'] == AAM_Extension_Repository::STATUS_INSTALLED) { ?>
54
- <span class="aam-extension-installed"><i class="icon-check"></i> <?php echo __('Installed', AAM_KEY); ?></span>
55
- <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_UPDATE) { ?>
56
- <a href="#" class="btn btn-sm btn-warning btn-block aam-update-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-arrows-cw"></i> <?php echo __('Update', AAM_KEY); ?></a>
57
- <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_INACTIVE) { ?>
58
- <span class="aam-extension-inactive"><i class="icon-stop"></i> <?php echo __('Inactive', AAM_KEY); ?></span>
59
- <?php } else { ?>
60
- <a href="<?php echo $product['storeURL']; ?>" target="_blank" class="btn btn-sm btn-primary btn-block"><i class="icon-link"></i> <?php echo __('Read More', AAM_KEY); ?></a>
61
- <?php } ?>
62
- </td>
63
- </tr>
64
  <?php } ?>
65
  </tbody>
66
  </table>
@@ -70,7 +65,7 @@
70
  <tbody>
71
  <?php foreach ($free as $product) { ?>
72
  <tr>
73
- <td>
74
  <span class='aam-setting-title'><?php echo $product['title'], (!empty($product['version']) ? ' <small class="text-muted">v' . $product['version'] . '</small>' : ''), ' - ' . ('<span class="text-success">' . __('Free', AAM_KEY) . '</span>'); ?></span>
75
  <p class="aam-extension-description">
76
  <?php echo $product['description']; ?>
@@ -78,9 +73,11 @@
78
  </td>
79
  <td>
80
  <?php if ($product['status'] == AAM_Extension_Repository::STATUS_INSTALLED) { ?>
81
- <span class="aam-extension-installed"><i class="icon-check"></i> <?php echo __('Installed', AAM_KEY); ?></span>
82
  <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_UPDATE) { ?>
83
  <a href="#" class="btn btn-sm btn-warning btn-block aam-update-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-arrows-cw"></i> <?php echo __('Update', AAM_KEY); ?></a>
 
 
84
  <?php } else { ?>
85
  <a href="#" class="btn btn-sm btn-success btn-block aam-download-extension" data-license="<?php echo $product['license']; ?>"><i class="icon-download-cloud"></i> <?php echo __('Download', AAM_KEY); ?></a>
86
  <?php } ?>
1
  <?php if (defined('AAM_KEY')) { ?>
2
+ <div id="extension-content" class="extension-container">
3
  <div class="row">
4
  <div class="col-xs-12">
5
  <p class="aam-info">
6
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('By purchasing any of the extensions below, you obtain the license that allows you to install and use our software for life and for one physical WordPress installation only. However you will be able to download new updates for one year from the time of purchase unless you purchased the [Extended version]. Exceptions are websites where URL is either [localhost] or starts with [dev.], [staging.], [test.] or [demo.] They are considered as development websites and you can use the purchased license unlimited number of times before it is activated on a production website. [Money back guaranteed] within 10 day from the time of purchase.', 'i', 'i', 'i', 'i', 'i', 'i', 'b'), '<a href="https://aamplugin.com/development-package" target="_blank">', '</a>'); ?><br/>
7
  </p>
8
  </div>
9
  </div>
36
  <table class="table table-striped table-bordered">
37
  <tbody>
38
  <?php foreach ($commercial as $i => $product) { ?>
39
+ <tr>
40
+ <td width="80%">
41
+ <span class='aam-setting-title'><?php echo $product['title'], (!empty($product['new']) ? ' <span class="badge">NEW</span> ' : ''), (!empty($product['version']) ? ' <small class="text-muted">v' . $product['version'] . '</small>' : ''); ?></span>
42
+ <?php if (!empty($product['license']) && $this->canShowLicense()) { ?><small class="aam-license-key"><b>License:</b> <?php echo $product['license'] . (!empty($product['expire']) ? " (updates expire on {$product['expire']})" : ''); ?></small><?php } ?>
43
+ <p class="aam-extension-description">
44
+ <?php echo $product['description']; ?>
45
+ </p>
46
+ </td>
47
+ <td>
48
+ <?php if ($product['status'] == AAM_Extension_Repository::STATUS_INSTALLED) { ?>
49
+ <a href="#" class="btn btn-sm btn-danger btn-block aam-deactivate-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-attention-circled"></i> <?php echo __('Deactivate', AAM_KEY); ?></a>
50
+ <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_UPDATE) { ?>
51
+ <a href="#" class="btn btn-sm btn-warning btn-block aam-update-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-arrows-cw"></i> <?php echo __('Update', AAM_KEY); ?></a>
52
+ <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_INACTIVE) { ?>
53
+ <a href="#" class="btn btn-sm btn-success btn-block aam-activate-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-check"></i> <?php echo __('Activate', AAM_KEY); ?></a>
54
+ <?php } else { ?>
55
+ <a href="<?php echo $product['url']; ?>" target="_blank" class="btn btn-sm btn-primary btn-block"><i class="icon-link"></i> <?php echo __('Read More', AAM_KEY); ?></a>
56
+ <?php } ?>
57
+ </td>
58
+ </tr>
 
 
 
 
 
59
  <?php } ?>
60
  </tbody>
61
  </table>
65
  <tbody>
66
  <?php foreach ($free as $product) { ?>
67
  <tr>
68
+ <td width="80%">
69
  <span class='aam-setting-title'><?php echo $product['title'], (!empty($product['version']) ? ' <small class="text-muted">v' . $product['version'] . '</small>' : ''), ' - ' . ('<span class="text-success">' . __('Free', AAM_KEY) . '</span>'); ?></span>
70
  <p class="aam-extension-description">
71
  <?php echo $product['description']; ?>
73
  </td>
74
  <td>
75
  <?php if ($product['status'] == AAM_Extension_Repository::STATUS_INSTALLED) { ?>
76
+ <a href="#" class="btn btn-sm btn-danger btn-block aam-deactivate-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-attention-circled"></i> <?php echo __('Deactivate', AAM_KEY); ?></a>
77
  <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_UPDATE) { ?>
78
  <a href="#" class="btn btn-sm btn-warning btn-block aam-update-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-arrows-cw"></i> <?php echo __('Update', AAM_KEY); ?></a>
79
+ <?php } elseif ($product['status'] == AAM_Extension_Repository::STATUS_INACTIVE) { ?>
80
+ <a href="#" class="btn btn-sm btn-success btn-block aam-activate-extension" data-product="<?php echo $product['id']; ?>"><i class="icon-check"></i> <?php echo __('Activate', AAM_KEY); ?></a>
81
  <?php } else { ?>
82
  <a href="#" class="btn btn-sm btn-success btn-block aam-download-extension" data-license="<?php echo $product['license']; ?>"><i class="icon-download-cloud"></i> <?php echo __('Download', AAM_KEY); ?></a>
83
  <?php } ?>
Application/Backend/phtml/frame.phtml CHANGED
@@ -13,7 +13,7 @@
13
 
14
  <?php do_action( 'admin_print_scripts' ); ?>
15
 
16
- <?php $object = AAM_Backend_Feature_Post::getCurrentObject(); ?>
17
  </head>
18
 
19
  <body id="aam-container">
@@ -22,21 +22,21 @@
22
  <div class="panel panel-default" style="border-radius:0;">
23
  <div class="panel-body">
24
  <ul class="nav nav-tabs" role="tablist">
25
- <?php if (AAM_Backend_View::userCan('aam_list_roles')) { ?>
26
  <li role="presentation" class="active"><a href="#roles" aria-controls="roles" role="tab" data-toggle="tab"><i class="icon-users" data-toggle="tooltip" data-placement="top" title="Roles"></i></a></li>
27
  <?php } ?>
28
- <?php if (AAM_Backend_View::userCan('list_users')) { ?>
29
  <li role="presentation"><a href="#users" aria-controls="users" role="tab" data-toggle="tab"><i class="icon-user" data-toggle="tooltip" data-placement="top" title="Users"></i></a></li>
30
  <?php } ?>
31
- <?php if (AAM_Backend_View::userCan('aam_manage_visitors')) { ?>
32
  <li role="presentation"><a href="#visitor" aria-controls="visitor" role="tab" data-toggle="tab"><i class="icon-user-secret" data-toggle="tooltip" data-placement="top" title="Visitor"></i></a></li>
33
  <?php } ?>
34
- <?php if (AAM_Backend_View::userCan('aam_manage_default')) { ?>
35
  <li role="presentation"><a href="#default" aria-controls="default" role="tab" data-toggle="tab" class="text-danger"><i class="icon-asterisk" data-toggle="tooltip" data-placement="top" title="Default"></i></a></li>
36
  <?php } ?>
37
  </ul>
38
  <div class="tab-content">
39
- <?php if (AAM_Backend_View::userCan('aam_list_roles')) { ?>
40
  <div role="tabpanel" class="tab-pane active" id="roles">
41
  <table id="role-list" class="table table-striped table-bordered">
42
  <thead>
@@ -52,7 +52,7 @@
52
  </table>
53
  </div>
54
  <?php } ?>
55
- <?php if (AAM_Backend_View::userCan('list_users')) { ?>
56
  <div role="tabpanel" class="tab-pane" id="users">
57
  <table id="user-list" class="table table-striped table-bordered">
58
  <thead>
@@ -68,7 +68,7 @@
68
  </table>
69
  </div>
70
  <?php } ?>
71
- <?php if (AAM_Backend_View::userCan('aam_manage_visitors')) { ?>
72
  <div role="tabpanel" class="tab-pane" id="visitor">
73
  <div class="visitor-message">
74
  <span class="aam-bordered"><?php echo sprintf(__('Manage access to %s for visitors (any user that is not authenticated)', AAM_KEY), '<b>' . ($object->type == 'post' ? $object->post->post_title : $object->term->name) . '</b>'); ?>.</span>
@@ -76,7 +76,7 @@
76
  </div>
77
  </div>
78
  <?php } ?>
79
- <?php if (AAM_Backend_View::userCan('aam_manage_default')) { ?>
80
  <div role="tabpanel" class="tab-pane" id="default">
81
  <div class="visitor-message">
82
  <span class="aam-bordered"><?php echo sprintf(__('Manage default access to %s for all users, roles and visitor. This includes Administrator role and yourself', AAM_KEY), '<b>' . ($object->type == 'post' ? $object->post->post_title : $object->term->name) . '</b>'); ?>.</span>
@@ -102,7 +102,7 @@
102
  </div>
103
 
104
  <?php if ($object->id) { ?>
105
- <input type="hidden" id="load-post-object" value="<?php echo ($object->type == 'post' ? $object->post->ID : $object->term->term_id); ?>" />
106
  <input type="hidden" id="load-post-object-type" value="<?php echo $object->type; ?>" />
107
  <input type="hidden" id="load-post-object-title" value="<?php echo ($object->type == 'post' ? $object->post->post_title : $object->term->name); ?>" />
108
  <?php } ?>
@@ -111,22 +111,23 @@
111
  <?php if ($object->type == 'post') { ?>
112
  <table class="table table-striped table-bordered">
113
  <tbody>
114
- <?php if (AAM_Core_Config::get('frontend-access-control', true)) { ?>
 
 
 
115
  <tr>
116
  <td colspan="2" class="aam-table-group">
117
  <i class="icon-doc-text-inv"></i> <strong><?php echo __('Frontend', AAM_KEY); ?></strong>
118
  </td>
119
  </tr>
120
 
121
- <?php foreach (AAM_Backend_Feature_Post::getAccessOptionList('frontend') as $option => $data) { ?>
122
  <tr>
123
  <td width="90%">
124
  <strong class="aam-block aam-highlight text-uppercase"><?php echo $data['title']; ?></strong>
125
- <?php
126
- if (!empty($data['sub'])) {
127
- echo $data['sub'];
128
- }
129
- ?>
130
  <p class="aam-hint" data-dynamic-post-label="<?php echo $data['descr']; ?>">---</p>
131
  </td>
132
  <td>
@@ -136,26 +137,22 @@
136
  </td>
137
  </tr>
138
  <?php } ?>
139
-
140
- <?php do_action('aam-post-access-option-action', 'post', 'frontend'); ?>
141
  <?php } ?>
142
 
143
- <?php if (AAM_Core_Config::get('backend-access-control', true)) { ?>
144
  <tr class="aam-backend-post-access">
145
  <td colspan="2" class="aam-table-group">
146
  <i class="icon-doc-text-inv"></i> <strong><?php echo __('Backend', AAM_KEY); ?></strong>
147
  </td>
148
  </tr>
149
 
150
- <?php foreach (AAM_Backend_Feature_Post::getAccessOptionList('backend') as $option => $data) { ?>
151
  <tr class="aam-backend-post-access">
152
  <td width="90%">
153
  <strong class="aam-block aam-highlight text-uppercase"><?php echo $data['title']; ?></strong>
154
- <?php
155
- if (!empty($data['sub'])) {
156
- echo $data['sub'];
157
- }
158
- ?>
159
  <p class="aam-hint" data-dynamic-post-label="<?php echo $data['descr']; ?>">---</p>
160
  </td>
161
  <td>
@@ -165,8 +162,6 @@
165
  </td>
166
  </tr>
167
  <?php } ?>
168
-
169
- <?php do_action('aam-post-access-option-action', 'post', 'backend'); ?>
170
  <?php } ?>
171
  </tbody>
172
  </table>
13
 
14
  <?php do_action( 'admin_print_scripts' ); ?>
15
 
16
+ <?php $object = AAM_Backend_Feature_Main_Post::getCurrentObject(); ?>
17
  </head>
18
 
19
  <body id="aam-container">
22
  <div class="panel panel-default" style="border-radius:0;">
23
  <div class="panel-body">
24
  <ul class="nav nav-tabs" role="tablist">
25
+ <?php if (current_user_can('aam_list_roles')) { ?>
26
  <li role="presentation" class="active"><a href="#roles" aria-controls="roles" role="tab" data-toggle="tab"><i class="icon-users" data-toggle="tooltip" data-placement="top" title="Roles"></i></a></li>
27
  <?php } ?>
28
+ <?php if (current_user_can('list_users')) { ?>
29
  <li role="presentation"><a href="#users" aria-controls="users" role="tab" data-toggle="tab"><i class="icon-user" data-toggle="tooltip" data-placement="top" title="Users"></i></a></li>
30
  <?php } ?>
31
+ <?php if (current_user_can('aam_manage_visitors')) { ?>
32
  <li role="presentation"><a href="#visitor" aria-controls="visitor" role="tab" data-toggle="tab"><i class="icon-user-secret" data-toggle="tooltip" data-placement="top" title="Visitor"></i></a></li>
33
  <?php } ?>
34
+ <?php if (current_user_can('aam_manage_default')) { ?>
35
  <li role="presentation"><a href="#default" aria-controls="default" role="tab" data-toggle="tab" class="text-danger"><i class="icon-asterisk" data-toggle="tooltip" data-placement="top" title="Default"></i></a></li>
36
  <?php } ?>
37
  </ul>
38
  <div class="tab-content">
39
+ <?php if (current_user_can('aam_list_roles')) { ?>
40
  <div role="tabpanel" class="tab-pane active" id="roles">
41
  <table id="role-list" class="table table-striped table-bordered">
42
  <thead>
52
  </table>
53
  </div>
54
  <?php } ?>
55
+ <?php if (current_user_can('list_users')) { ?>
56
  <div role="tabpanel" class="tab-pane" id="users">
57
  <table id="user-list" class="table table-striped table-bordered">
58
  <thead>
68
  </table>
69
  </div>
70
  <?php } ?>
71
+ <?php if (current_user_can('aam_manage_visitors')) { ?>
72
  <div role="tabpanel" class="tab-pane" id="visitor">
73
  <div class="visitor-message">
74
  <span class="aam-bordered"><?php echo sprintf(__('Manage access to %s for visitors (any user that is not authenticated)', AAM_KEY), '<b>' . ($object->type == 'post' ? $object->post->post_title : $object->term->name) . '</b>'); ?>.</span>
76
  </div>
77
  </div>
78
  <?php } ?>
79
+ <?php if (current_user_can('aam_manage_default')) { ?>
80
  <div role="tabpanel" class="tab-pane" id="default">
81
  <div class="visitor-message">
82
  <span class="aam-bordered"><?php echo sprintf(__('Manage default access to %s for all users, roles and visitor. This includes Administrator role and yourself', AAM_KEY), '<b>' . ($object->type == 'post' ? $object->post->post_title : $object->term->name) . '</b>'); ?>.</span>
102
  </div>
103
 
104
  <?php if ($object->id) { ?>
105
+ <input type="hidden" id="load-post-object" value="<?php echo ($object->type == 'post' ? $object->post->ID : $object->term->term_id . '|' . $object->term->taxonomy); ?>" />
106
  <input type="hidden" id="load-post-object-type" value="<?php echo $object->type; ?>" />
107
  <input type="hidden" id="load-post-object-title" value="<?php echo ($object->type == 'post' ? $object->post->post_title : $object->term->name); ?>" />
108
  <?php } ?>
111
  <?php if ($object->type == 'post') { ?>
112
  <table class="table table-striped table-bordered">
113
  <tbody>
114
+ <?php $frontend = AAM_Backend_Feature_Main_Post::getAccessOptionList('frontend'); ?>
115
+ <?php $backend = AAM_Backend_Feature_Main_Post::getAccessOptionList('backend'); ?>
116
+
117
+ <?php if (count($frontend) && AAM_Core_Config::get('frontend-access-control', true)) { ?>
118
  <tr>
119
  <td colspan="2" class="aam-table-group">
120
  <i class="icon-doc-text-inv"></i> <strong><?php echo __('Frontend', AAM_KEY); ?></strong>
121
  </td>
122
  </tr>
123
 
124
+ <?php foreach ($frontend as $option => $data) { ?>
125
  <tr>
126
  <td width="90%">
127
  <strong class="aam-block aam-highlight text-uppercase"><?php echo $data['title']; ?></strong>
128
+ <?php if (!empty($data['sub'])) { ?>
129
+ <small><?php echo $data['sub']; ?>: <b id="<?php echo $data['preview']; ?>" data-ref="<?php echo $data['option']; ?>" class="option-preview">...</b> <a href="#modal-<?php echo str_replace('.', '-', $data['option']); ?>" data-toggle="modal" class="advanced-post-option" data-ref="<?php echo $data['option']; ?>" data-preview="#<?php echo $data['preview']; ?>"><?php echo __('change', AAM_KEY); ?></a></small>
130
+ <?php } ?>
 
 
131
  <p class="aam-hint" data-dynamic-post-label="<?php echo $data['descr']; ?>">---</p>
132
  </td>
133
  <td>
137
  </td>
138
  </tr>
139
  <?php } ?>
 
 
140
  <?php } ?>
141
 
142
+ <?php if (count($backend) && AAM_Core_Config::get('backend-access-control', true)) { ?>
143
  <tr class="aam-backend-post-access">
144
  <td colspan="2" class="aam-table-group">
145
  <i class="icon-doc-text-inv"></i> <strong><?php echo __('Backend', AAM_KEY); ?></strong>
146
  </td>
147
  </tr>
148
 
149
+ <?php foreach ($backend as $option => $data) { ?>
150
  <tr class="aam-backend-post-access">
151
  <td width="90%">
152
  <strong class="aam-block aam-highlight text-uppercase"><?php echo $data['title']; ?></strong>
153
+ <?php if (!empty($data['sub'])) { ?>
154
+ <small><?php echo $data['sub']; ?>: <b id="<?php echo $data['preview']; ?>" data-ref="<?php echo $data['option']; ?>" class="option-preview">...</b> <a href="#modal-<?php echo str_replace('.', '-', $data['option']); ?>" data-toggle="modal" class="advanced-post-option" data-ref="<?php echo $data['option']; ?>" data-preview="#<?php echo $data['preview']; ?>"><?php echo __('change', AAM_KEY); ?></a></small>
155
+ <?php } ?>
 
 
156
  <p class="aam-hint" data-dynamic-post-label="<?php echo $data['descr']; ?>">---</p>
157
  </td>
158
  <td>
162
  </td>
163
  </tr>
164
  <?php } ?>
 
 
165
  <?php } ?>
166
  </tbody>
167
  </table>
Application/Backend/phtml/index.phtml CHANGED
@@ -1,6 +1,6 @@
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="wrap" id="aam-container">
3
- <div class="row">
4
  <div class="col-xs-12 col-md-8">
5
  <div class="aam-current-subject"></div>
6
  </div>
@@ -11,7 +11,7 @@
11
  <div class="metabox-holder">
12
  <div class="postbox">
13
  <h3 class="hndle">
14
- <span><?php echo __('Access Control Panel', AAM_KEY); ?></span>
15
  <span class="aam-help-menu" data-target="#access-manager-inside"><i class="icon-help-circled"></i></span>
16
  </h3>
17
  <div class="inside" id="access-manager-inside">
@@ -24,7 +24,6 @@
24
  <p class="text-larger"><span class="aam-highlight"><?php echo __('Please Note!', AAM_KEY); ?></span> <?php echo AAM_Backend_View_Helper::preparePhrase('Power comes with responsibility. Make sure you have enough knowledge in WordPress Roles & Capabilities because AAM is very closely intergrated with WordPress core. It is also very important [to have backup of your database before you start working with AAM] (there is no need to backup your files, AAM does not modify any physical files on your server and never did).', 'b'); ?></p>
25
  <p class="text-larger"><?php echo __('AAM was thoroughly tested on the fresh installation of WordPress and in the latest versions of Chrome, Safari, IE and Firefox. If you have any issues, the most typical case is the conflict with other plugins or themes.', AAM_KEY); ?></p>
26
  <p class="text-larger"><?php echo sprintf(__('Check our %sHelp%s section to find some useful articles about AAM functionality or %scontact us%s directly.', AAM_KEY), '<a href="https://aamplugin.com/help" target="_blank">', '</a>', '<a href="mailto:support@aamplugin.com">', '</a>'); ?></p>
27
- <p class="text-larger"><?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('[Still do not know where to start?] Check our %s[Get Started]%s section.', 'b', 'b'), '<a href="https://aamplugin.com/get-started" target="_blank">', '</a>'); ?></p>
28
  </div>
29
  </div>
30
  </div>
@@ -32,9 +31,9 @@
32
  </div>
33
  </div>
34
 
35
- <div class="col-xs-12 col-md-4">
36
- <?php if (AAM_Core_Console::hasIssues()) { ?>
37
- <div class="metabox-holder">
38
  <div class="postbox">
39
  <h3 class="hndle text-danger">
40
  <i class='icon-attention-circled'></i> <span><?php echo __('Notifications', AAM_KEY); ?></span>
@@ -42,7 +41,7 @@
42
  <div class="inside">
43
  <div class="aam-postbox-inside">
44
  <ul class="aam-error-list">
45
- <?php foreach (AAM_Core_Console::getWarnings() as $message) { ?>
46
  <li><?php echo $message; ?></li>
47
  <?php } ?>
48
  </ul>
@@ -52,29 +51,48 @@
52
  </div>
53
  <?php } ?>
54
 
55
- <div class="metabox-holder">
56
  <div class="postbox">
57
  <div class="inside">
58
  <div class="aam-social">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  <a href="https://aamplugin.com/help" title="Help" target="_blank">
60
  <i class="icon-help-circled"></i>
61
  <span>Help</span>
62
  </a>
63
- <a target="_blank" href="mailto:support@aamplugin.com">
64
- <i class="icon-mail-alt"></i>
65
- <span>Email Us</span>
66
- </a>
67
- <a href="https://wordpress.org/support/plugin/advanced-access-manager/reviews/" title="Rate Me" target="_blank">
68
- <i class="icon-star"></i>
69
- <span>Reviews</span>
70
- </a>
 
 
 
71
  </div>
72
  </div>
73
  </div>
74
  </div>
75
 
76
  <?php if (is_network_admin() && !defined('AAM_MULTISITE')) { ?>
77
- <div class="metabox-holder">
78
  <div class="postbox">
79
  <h3 class="hndle text-warning">
80
  <i class='icon-attention-circled'></i> <span><?php echo __('AAM Multisite', AAM_KEY); ?></span>
@@ -89,30 +107,30 @@
89
 
90
  <?php do_action('aam-sidebar-ui-action', 'top'); ?>
91
 
92
- <div class="metabox-holder">
93
  <div class="postbox">
94
  <h3 class="hndle">
95
- <span><?php echo __('Users/Roles Panel', AAM_KEY); ?></span>
96
  <span class="aam-help-menu" data-target="#user-role-manager-inside"><i class="icon-help-circled"></i></span>
97
  </h3>
98
  <div class="inside" id="user-role-manager-inside">
99
  <div class="aam-postbox-inside">
100
  <ul class="nav nav-tabs" role="tablist">
101
- <?php if (AAM_Backend_View::userCan('aam_list_roles')) { ?>
102
  <li role="presentation" class="active text-center"><a href="#roles" aria-controls="roles" role="tab" data-toggle="tab"><i class="icon-users"></i><br/><?php echo __('Roles', AAM_KEY); ?></a></li>
103
  <?php } ?>
104
- <?php if (AAM_Backend_View::userCan('list_users')) { ?>
105
  <li role="presentation" class="text-center"><a href="#users" aria-controls="users" role="tab" data-toggle="tab"><i class="icon-user"></i><br/><?php echo __('Users', AAM_KEY); ?></a></li>
106
  <?php } ?>
107
- <?php if (AAM_Backend_View::userCan('aam_manage_visitors')) { ?>
108
  <li role="presentation" class="text-center"><a href="#visitor" aria-controls="visitor" role="tab" data-toggle="tab"><i class="icon-user-secret"></i><br/><?php echo __('Visitor', AAM_KEY); ?></a></li>
109
  <?php } ?>
110
- <?php if (AAM_Backend_View::userCan('aam_manage_default')) { ?>
111
  <li role="presentation" class="text-center"><a href="#default" aria-controls="default" role="tab" data-toggle="tab" class="text-danger"><i class="icon-asterisk"></i><br/><?php echo __('Default', AAM_KEY); ?></a></li>
112
  <?php } ?>
113
  </ul>
114
  <div class="tab-content">
115
- <?php if (AAM_Backend_View::userCan('aam_list_roles')) { ?>
116
  <div role="tabpanel" class="tab-pane active" id="roles">
117
  <table id="role-list" class="table table-striped table-bordered">
118
  <thead>
@@ -144,6 +162,7 @@
144
  <label><?php echo __('Role Expiration', AAM_KEY); ?> <a href="https://aamplugin.com/help/how-to-manage-wordpress-roles" target="_blank" data-toggle="tooltip" title="For how long user can have this role. Click to learn more."><i class="icon-help-circled"></i></a></label>
145
  <input type="text" class="form-control" name="expire" placeholder="<?php echo __('Enter Expiration Rule', AAM_KEY); ?>" />
146
  </div>
 
147
  <?php echo apply_filters('aam-add-role-ui-filter', AAM_Backend_View::getInstance()->loadPartial('role-inheritance.phtml')); ?>
148
  </div>
149
  <div class="modal-footer">
@@ -199,7 +218,7 @@
199
  </div>
200
  </div>
201
  <?php } ?>
202
- <?php if (AAM_Backend_View::userCan('list_users')) { ?>
203
  <div role="tabpanel" class="tab-pane" id="users">
204
  <table id="user-list" class="table table-striped table-bordered">
205
  <thead>
@@ -215,7 +234,7 @@
215
  </table>
216
  </div>
217
  <?php } ?>
218
- <?php if (AAM_Backend_View::userCan('aam_manage_visitors')) { ?>
219
  <div role="tabpanel" class="tab-pane" id="visitor">
220
  <div class="visitor-message">
221
  <span class="aam-bordered"><?php echo __('Manage access to your website for visitors (any user that is not authenticated)', AAM_KEY); ?>.</span>
@@ -223,7 +242,7 @@
223
  </div>
224
  </div>
225
  <?php } ?>
226
- <?php if (AAM_Backend_View::userCan('aam_manage_default')) { ?>
227
  <div role="tabpanel" class="tab-pane" id="default">
228
  <div class="visitor-message">
229
  <span class="aam-bordered"><?php echo __('Manage default access to your website resources for all users, roles and visitor. This includes Administrator role and your user', AAM_KEY); ?>.</span>
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="wrap" id="aam-container">
3
+ <div class="row" id="aam-subject-banner">
4
  <div class="col-xs-12 col-md-8">
5
  <div class="aam-current-subject"></div>
6
  </div>
11
  <div class="metabox-holder">
12
  <div class="postbox">
13
  <h3 class="hndle">
14
+ <span><?php echo __('Main Panel', AAM_KEY); ?></span>
15
  <span class="aam-help-menu" data-target="#access-manager-inside"><i class="icon-help-circled"></i></span>
16
  </h3>
17
  <div class="inside" id="access-manager-inside">
24
  <p class="text-larger"><span class="aam-highlight"><?php echo __('Please Note!', AAM_KEY); ?></span> <?php echo AAM_Backend_View_Helper::preparePhrase('Power comes with responsibility. Make sure you have enough knowledge in WordPress Roles & Capabilities because AAM is very closely intergrated with WordPress core. It is also very important [to have backup of your database before you start working with AAM] (there is no need to backup your files, AAM does not modify any physical files on your server and never did).', 'b'); ?></p>
25
  <p class="text-larger"><?php echo __('AAM was thoroughly tested on the fresh installation of WordPress and in the latest versions of Chrome, Safari, IE and Firefox. If you have any issues, the most typical case is the conflict with other plugins or themes.', AAM_KEY); ?></p>
26
  <p class="text-larger"><?php echo sprintf(__('Check our %sHelp%s section to find some useful articles about AAM functionality or %scontact us%s directly.', AAM_KEY), '<a href="https://aamplugin.com/help" target="_blank">', '</a>', '<a href="mailto:support@aamplugin.com">', '</a>'); ?></p>
 
27
  </div>
28
  </div>
29
  </div>
31
  </div>
32
  </div>
33
 
34
+ <div class="col-xs-12 col-md-4 aam-sidebar">
35
+ <?php if (AAM_Core_Console::count() && current_user_can('aam_show_notifications')) { ?>
36
+ <div class="metabox-holder shared-metabox">
37
  <div class="postbox">
38
  <h3 class="hndle text-danger">
39
  <i class='icon-attention-circled'></i> <span><?php echo __('Notifications', AAM_KEY); ?></span>
41
  <div class="inside">
42
  <div class="aam-postbox-inside">
43
  <ul class="aam-error-list">
44
+ <?php foreach (AAM_Core_Console::getAll() as $message) { ?>
45
  <li><?php echo $message; ?></li>
46
  <?php } ?>
47
  </ul>
51
  </div>
52
  <?php } ?>
53
 
54
+ <div class="metabox-holder shared-metabox">
55
  <div class="postbox">
56
  <div class="inside">
57
  <div class="aam-social">
58
+ <a href="#" title="Access" data-type="main" class="aam-area text-danger">
59
+ <i class="icon-cog-alt"></i>
60
+ <span>Access</span>
61
+ </a>
62
+ <?php if (current_user_can('aam_manage_settings')) { ?>
63
+ <a href="#" title="Settings" data-type="settings" class="aam-area">
64
+ <i class="icon-wrench"></i>
65
+ <span>Settings</span>
66
+ </a>
67
+ <?php } ?>
68
+ <?php if (current_user_can('aam_manage_extensions')) { ?>
69
+ <a href="#" title="Extensions" data-type="extensions" class="aam-area">
70
+ <i class="icon-cubes"></i>
71
+ <span>Extensions</span>
72
+ </a>
73
+ <?php } ?>
74
  <a href="https://aamplugin.com/help" title="Help" target="_blank">
75
  <i class="icon-help-circled"></i>
76
  <span>Help</span>
77
  </a>
78
+ </div>
79
+ </div>
80
+ </div>
81
+ </div>
82
+
83
+ <div class="metabox-holder extensions-metabox" style="display:none;">
84
+ <div class="postbox">
85
+ <div class="inside">
86
+ <div class="aam-postbox-inside text-center">
87
+ <p class="alert alert-info text-larger"><?php echo AAM_Backend_View_Helper::preparePhrase('The [Development Package] allows you to get all premium extensions for [unlimited number of websites].', 'i', 'b'); ?></p>
88
+ <a href="https://aamplugin.com/development-package" target="_blank" class="btn btn-sm btn-primary btn-block"><i class="icon-link"></i> <?php echo __('Read More', AAM_KEY); ?></a>
89
  </div>
90
  </div>
91
  </div>
92
  </div>
93
 
94
  <?php if (is_network_admin() && !defined('AAM_MULTISITE')) { ?>
95
+ <div class="metabox-holder main-metabox">
96
  <div class="postbox">
97
  <h3 class="hndle text-warning">
98
  <i class='icon-attention-circled'></i> <span><?php echo __('AAM Multisite', AAM_KEY); ?></span>
107
 
108
  <?php do_action('aam-sidebar-ui-action', 'top'); ?>
109
 
110
+ <div class="metabox-holder main-metabox">
111
  <div class="postbox">
112
  <h3 class="hndle">
113
+ <span><?php echo __('Users/Roles Manager', AAM_KEY); ?></span>
114
  <span class="aam-help-menu" data-target="#user-role-manager-inside"><i class="icon-help-circled"></i></span>
115
  </h3>
116
  <div class="inside" id="user-role-manager-inside">
117
  <div class="aam-postbox-inside">
118
  <ul class="nav nav-tabs" role="tablist">
119
+ <?php if (current_user_can('aam_list_roles')) { ?>
120
  <li role="presentation" class="active text-center"><a href="#roles" aria-controls="roles" role="tab" data-toggle="tab"><i class="icon-users"></i><br/><?php echo __('Roles', AAM_KEY); ?></a></li>
121
  <?php } ?>
122
+ <?php if (current_user_can('list_users')) { ?>
123
  <li role="presentation" class="text-center"><a href="#users" aria-controls="users" role="tab" data-toggle="tab"><i class="icon-user"></i><br/><?php echo __('Users', AAM_KEY); ?></a></li>
124
  <?php } ?>
125
+ <?php if (current_user_can('aam_manage_visitors')) { ?>
126
  <li role="presentation" class="text-center"><a href="#visitor" aria-controls="visitor" role="tab" data-toggle="tab"><i class="icon-user-secret"></i><br/><?php echo __('Visitor', AAM_KEY); ?></a></li>
127
  <?php } ?>
128
+ <?php if (current_user_can('aam_manage_default')) { ?>
129
  <li role="presentation" class="text-center"><a href="#default" aria-controls="default" role="tab" data-toggle="tab" class="text-danger"><i class="icon-asterisk"></i><br/><?php echo __('Default', AAM_KEY); ?></a></li>
130
  <?php } ?>
131
  </ul>
132
  <div class="tab-content">
133
+ <?php if (current_user_can('aam_list_roles')) { ?>
134
  <div role="tabpanel" class="tab-pane active" id="roles">
135
  <table id="role-list" class="table table-striped table-bordered">
136
  <thead>
162
  <label><?php echo __('Role Expiration', AAM_KEY); ?> <a href="https://aamplugin.com/help/how-to-manage-wordpress-roles" target="_blank" data-toggle="tooltip" title="For how long user can have this role. Click to learn more."><i class="icon-help-circled"></i></a></label>
163
  <input type="text" class="form-control" name="expire" placeholder="<?php echo __('Enter Expiration Rule', AAM_KEY); ?>" />
164
  </div>
165
+ <?php do_action('aam-add-role-ui-action'); ?>
166
  <?php echo apply_filters('aam-add-role-ui-filter', AAM_Backend_View::getInstance()->loadPartial('role-inheritance.phtml')); ?>
167
  </div>
168
  <div class="modal-footer">
218
  </div>
219
  </div>
220
  <?php } ?>
221
+ <?php if (current_user_can('list_users')) { ?>
222
  <div role="tabpanel" class="tab-pane" id="users">
223
  <table id="user-list" class="table table-striped table-bordered">
224
  <thead>
234
  </table>
235
  </div>
236
  <?php } ?>
237
+ <?php if (current_user_can('aam_manage_visitors')) { ?>
238
  <div role="tabpanel" class="tab-pane" id="visitor">
239
  <div class="visitor-message">
240
  <span class="aam-bordered"><?php echo __('Manage access to your website for visitors (any user that is not authenticated)', AAM_KEY); ?>.</span>
242
  </div>
243
  </div>
244
  <?php } ?>
245
+ <?php if (current_user_can('aam_manage_default')) { ?>
246
  <div role="tabpanel" class="tab-pane" id="default">
247
  <div class="visitor-message">
248
  <span class="aam-bordered"><?php echo __('Manage default access to your website resources for all users, roles and visitor. This includes Administrator role and your user', AAM_KEY); ?>.</span>
Application/Backend/phtml/main-panel.phtml CHANGED
@@ -1,10 +1,11 @@
1
  <?php if (defined('AAM_KEY')) { ?>
 
2
  <div class="row">
3
- <?php if (count(AAM_Backend_Feature::retriveList())) { ?>
4
  <div class="col-xs-12 col-md-4">
5
  <ul class="list-group" id="feature-list">
6
  <?php
7
- foreach (AAM_Backend_Feature::retriveList() as $i => $feature) {
8
  echo '<li class="list-group-item' . (isset($feature->class) ? ' ' . $feature->class : '') . '" data-feature="' . $feature->uid . '">';
9
  echo $feature->title;
10
  echo (empty($feature->notification) ? '' : ' <span class="badge">' . $feature->notification . '</span>');
@@ -15,10 +16,10 @@
15
  </div>
16
  <div class="col-xs-12 col-md-8">
17
  <?php
18
- foreach (AAM_Backend_Feature::retriveList() as $feature) {
19
- echo $feature->view->getContent();
20
- }
21
- do_action('aam-content-action');
22
  ?>
23
  </div>
24
  <?php } else { ?>
1
  <?php if (defined('AAM_KEY')) { ?>
2
+ <?php $features = AAM_Backend_Feature::retriveList($type); ?>
3
  <div class="row">
4
+ <?php if (count($features)) { ?>
5
  <div class="col-xs-12 col-md-4">
6
  <ul class="list-group" id="feature-list">
7
  <?php
8
+ foreach ($features as $i => $feature) {
9
  echo '<li class="list-group-item' . (isset($feature->class) ? ' ' . $feature->class : '') . '" data-feature="' . $feature->uid . '">';
10
  echo $feature->title;
11
  echo (empty($feature->notification) ? '' : ' <span class="badge">' . $feature->notification . '</span>');
16
  </div>
17
  <div class="col-xs-12 col-md-8">
18
  <?php
19
+ foreach ($features as $feature) {
20
+ echo $feature->view->getContent();
21
+ }
22
+ do_action('aam-content-action');
23
  ?>
24
  </div>
25
  <?php } else { ?>
Application/Backend/phtml/{404redirect.phtml → main/404redirect.phtml} RENAMED
@@ -1,5 +1,6 @@
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">
@@ -7,9 +8,11 @@
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">
@@ -32,16 +35,16 @@
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'); ?>;">
@@ -53,6 +56,9 @@
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>
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="aam-feature" id="404redirect-content">
3
+ <?php if (AAM_Backend_Subject::getInstance()->getUID() == AAM_Core_Subject_Default::UID) { ?>
4
  <div class="row">
5
  <div class="col-xs-12">
6
  <p class="aam-info">
8
  </p>
9
  </div>
10
  </div>
11
+ <?php } ?>
12
 
13
  <div class="row">
14
  <div class="col-xs-12">
15
+ <?php if (AAM_Backend_Subject::getInstance()->getUID() == AAM_Core_Subject_Default::UID) { ?>
16
  <?php $type = AAM_Core_Config::get('frontend.404redirect.type', 'default'); ?>
17
 
18
  <div class="radio">
35
  <div class="form-group aam-404redirect-action" id="404redirect-page-action" style="display: <?php echo ($type == 'page' ? 'block' : 'none'); ?>;">
36
  <label for="frontend-page"><?php echo __('Existing Page', AAM_KEY); ?></label>
37
  <?php
38
+ wp_dropdown_pages(array(
39
+ 'depth' => 99,
40
+ 'selected' => AAM_Core_Config::get('frontend.404redirect.page'),
41
+ 'echo' => 1,
42
+ 'name' => 'frontend.404redirect.page',
43
+ 'id' => '404-redirect-page', // string
44
+ 'class' => 'form-control', // string
45
+ 'show_option_none' => __('-- Select Page --', AAM_KEY) // string
46
+ ));
47
+ ?>
48
  </div>
49
 
50
  <div class="form-group aam-404redirect-action" id="404redirect-url-action" style="display: <?php echo ($type == 'url' ? 'block' : 'none'); ?>;">
56
  <label for="frontend-url"><?php echo __('PHP Callback Function', AAM_KEY); ?></label>
57
  <input type="text" class="form-control" placeholder="Enter valid callback" name="frontend.404redirect.callback" value="<?php echo AAM_Core_Config::get('frontend.404redirect.callback'); ?>" />
58
  </div>
59
+ <?php } else { ?>
60
+ <p class="alert alert-info text-center"><?php echo AAM_Backend_View_Helper::preparePhrase('You cannot setup 404 redirect for specific user, role or visitors. Switch to [Manage Default Access] and define default 404 redirect for everybody.', 'strong'); ?></p>
61
+ <?php } ?>
62
  </div>
63
  </div>
64
  </div>
Application/Backend/phtml/{object → main}/capability.phtml RENAMED
@@ -1,11 +1,11 @@
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="aam-feature" id="capability-content">
3
- <?php $subject = AAM_Backend_View::getSubject(); ?>
4
 
5
  <div class="row">
6
  <div class="col-xs-12">
7
- <p class="aam-info">
8
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Manage list of capabilities for current %s. For more information about concept of capabilities check %sWhat is a WordPress capability%s article.', 'b'), AAM_Backend_View::getSubject()->getUID(), '<a href="https://aamplugin.com/help/what-is-a-wordpress-capability" target="_blank">', '</a>'); ?>
9
  </p>
10
  </div>
11
  </div>
@@ -98,7 +98,7 @@
98
  <h4 class="modal-title"><?php echo __('Delete Capability', AAM_KEY); ?></h4>
99
  </div>
100
  <div class="modal-body">
101
- <p class="text-center aam-confirm-message" data-message="<?php echo __('Are you sure that you want to delete %s capability for all roles?', AAM_KEY); ?>"></p>
102
  </div>
103
  <div class="modal-footer">
104
  <button type="button" class="btn btn-danger" id="delete-capability-btn"><?php echo __('Delete', AAM_KEY); ?></button>
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="aam-feature" id="capability-content">
3
+ <?php $subject = AAM_Backend_Subject::getInstance(); ?>
4
 
5
  <div class="row">
6
  <div class="col-xs-12">
7
+ <p class="aam-notification">
8
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('[Be careful!] Manage capabilities for [%s]. For more information about the concept of capabilities check %sWhat is a WordPress capability%s article.', 'b', 'b'), AAM_Backend_Subject::getInstance()->getName(), '<a href="https://aamplugin.com/help/what-is-a-wordpress-capability" target="_blank">', '</a>'); ?>
9
  </p>
10
  </div>
11
  </div>
98
  <h4 class="modal-title"><?php echo __('Delete Capability', AAM_KEY); ?></h4>
99
  </div>
100
  <div class="modal-body">
101
+ <p class="text-center aam-confirm-message alert alert-danger" data-message="<?php echo __('Are you sure that you want to delete %s capability for all roles?', AAM_KEY); ?>"></p>
102
  </div>
103
  <div class="modal-footer">
104
  <button type="button" class="btn btn-danger" id="delete-capability-btn"><?php echo __('Delete', AAM_KEY); ?></button>
Application/Backend/phtml/{object → main}/login-redirect.phtml RENAMED
@@ -4,11 +4,11 @@
4
  <div class="col-xs-12">
5
  <?php if ($this->isDefault()) { ?>
6
  <p class="aam-info">
7
- <?php echo AAM_Backend_View_Helper::preparePhrase('Define the [default] login redirect for all users, roles when the authentication completed successfully. [Please note!] The login redirect works only with the default WordPress login page.', 'strong', 'strong'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize login redirect for this %s when the authentication completed successfully. [Please note!] The login redirect works only with the default WordPress login page.', 'strong'), AAM_Backend_View::getSubject()->getUID()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-login-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
@@ -42,16 +42,16 @@
42
  <div class="form-group login-redirect-action" id="page-login-redirect-action" style="display: <?php echo ($type == 'page' ? 'block' : 'none'); ?>;">
43
  <label><?php echo __('Existing Page', AAM_KEY); ?></label>
44
  <?php
45
- wp_dropdown_pages(array(
46
- 'depth' => 99,
47
- 'selected' => $this->getOption('login.redirect.page'),
48
- 'echo' => 1,
49
- 'name' => 'login.redirect.page',
50
- 'id' => 'page-redirect', // string
51
- 'class' => 'form-control', // string
52
- 'show_option_none' => __('-- Select Page --', AAM_KEY) // string
53
- ));
54
- ?>
55
  </div>
56
 
57
  <div class="form-group login-redirect-action" id="url-login-redirect-action" style="display: <?php echo ($type == 'url' ? 'block' : 'none'); ?>;">
4
  <div class="col-xs-12">
5
  <?php if ($this->isDefault()) { ?>
6
  <p class="aam-info">
7
+ <?php echo AAM_Backend_View_Helper::preparePhrase('Define the [default] login redirect for all users and roles when authentication is completed successfully.', 'strong'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize login redirect for [%s] when the authentication is completed successfully.', 'strong'), AAM_Backend_Subject::getInstance()->getName()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-login-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
42
  <div class="form-group login-redirect-action" id="page-login-redirect-action" style="display: <?php echo ($type == 'page' ? 'block' : 'none'); ?>;">
43
  <label><?php echo __('Existing Page', AAM_KEY); ?></label>
44
  <?php
45
+ wp_dropdown_pages(array(
46
+ 'depth' => 99,
47
+ 'selected' => $this->getOption('login.redirect.page'),
48
+ 'echo' => 1,
49
+ 'name' => 'login.redirect.page',
50
+ 'id' => 'login-redirect-page', // string
51
+ 'class' => 'form-control', // string
52
+ 'show_option_none' => __('-- Select Page --', AAM_KEY) // string
53
+ ));
54
+ ?>
55
  </div>
56
 
57
  <div class="form-group login-redirect-action" id="url-login-redirect-action" style="display: <?php echo ($type == 'url' ? 'block' : 'none'); ?>;">
Application/Backend/phtml/{object → main}/logout-redirect.phtml RENAMED
@@ -8,7 +8,7 @@
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize logout redirect for this %s.'), AAM_Backend_View::getSubject()->getUID()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-logout-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
@@ -42,16 +42,16 @@
42
  <div class="form-group logout-redirect-action" id="page-logout-redirect-action" style="display: <?php echo ($type == 'page' ? 'block' : 'none'); ?>;">
43
  <label><?php echo __('Existing Page', AAM_KEY); ?></label>
44
  <?php
45
- wp_dropdown_pages(array(
46
- 'depth' => 99,
47
- 'selected' => $this->getOption('logout.redirect.page'),
48
- 'echo' => 1,
49
- 'name' => 'logout.redirect.page',
50
- 'id' => 'page-redirect', // string
51
- 'class' => 'form-control', // string
52
- 'show_option_none' => __('-- Select Page --', AAM_KEY) // string
53
- ));
54
- ?>
55
  </div>
56
 
57
  <div class="form-group logout-redirect-action" id="url-logout-redirect-action" style="display: <?php echo ($type == 'url' ? 'block' : 'none'); ?>;">
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize logout redirect for [%s].', 'strong'), AAM_Backend_Subject::getInstance()->getName()); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-logout-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
42
  <div class="form-group logout-redirect-action" id="page-logout-redirect-action" style="display: <?php echo ($type == 'page' ? 'block' : 'none'); ?>;">
43
  <label><?php echo __('Existing Page', AAM_KEY); ?></label>
44
  <?php
45
+ wp_dropdown_pages(array(
46
+ 'depth' => 99,
47
+ 'selected' => $this->getOption('logout.redirect.page'),
48
+ 'echo' => 1,
49
+ 'name' => 'logout.redirect.page',
50
+ 'id' => 'logout-redirect-page', // string
51
+ 'class' => 'form-control', // string
52
+ 'show_option_none' => __('-- Select Page --', AAM_KEY) // string
53
+ ));
54
+ ?>
55
  </div>
56
 
57
  <div class="form-group logout-redirect-action" id="url-logout-redirect-action" style="display: <?php echo ($type == 'url' ? 'block' : 'none'); ?>;">
Application/Backend/phtml/{object → main}/menu.phtml RENAMED
@@ -3,7 +3,7 @@
3
  <div class="row">
4
  <div class="col-xs-12">
5
  <p class="aam-info">
6
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Protect your backend area. The list of menus and submenus is based on list of capabilities that current %s has. For more information about this feature, please check %sHow to manage WordPress backend menu%s.', 'b'), AAM_Backend_View::getSubject()->getUID(), '<a href="https://aamplugin.com/help/how-to-manage-wordpress-backend-menu" target="_blank">', '</a>'); ?>
7
  </p>
8
  </div>
9
  </div>
@@ -19,7 +19,7 @@
19
  <div class="panel-group" id="admin-menu" role="tablist" aria-multiselectable="true">
20
  <?php
21
  $first = false;
22
- $object = AAM_Backend_View::getSubject()->getObject('menu');
23
  foreach ($this->getMenu() as $i => $menu) {
24
  ?>
25
  <div class="panel panel-default">
@@ -28,14 +28,18 @@
28
  <a role="button" data-toggle="collapse" data-parent="#admin-menu" href="#menu-<?php echo $i; ?>" aria-controls="menu-<?php echo $i; ?>" <?php if (!$first) { echo 'aria-expanded="true"'; } ?>>
29
  <?php echo $menu['name']; ?> <small class="aam-menu-capability"><?php echo $menu['capability']; ?></small>
30
  </a>
31
- <?php echo ($object->has($menu['id']) ? '<i class="aam-panel-title-icon icon-eye-off text-danger"></i>' : ''); ?>
 
 
 
 
32
  </h4>
33
  </div>
34
 
35
  <div id="menu-<?php echo $i; ?>" class="panel-collapse collapse<?php if (!$first) { echo ' in'; $first = true; } ?>" role="tabpanel" aria-labelledby="menu-<?php echo $i; ?>-heading">
36
  <div class="panel-body">
37
  <?php if (!empty($menu['submenu'])) { ?>
38
- <div class="row aam-bordered">
39
  <?php echo ($object->has($menu['id']) ? '<div class="aam-lock"></div>' : ''); ?>
40
  <?php foreach ($menu['submenu'] as $j => $submenu) { ?>
41
  <?php if ($submenu['id'] == 'index.php') { ?>
@@ -47,11 +51,13 @@
47
  <div class="col-xs-12 col-md-6 aam-submenu-item">
48
  <label for="menu-item-<?php echo $i . $j; ?>"><?php echo $submenu['name']; ?> <small class="aam-menu-capability"><?php echo $submenu['capability']; ?></small></label>
49
  <input type="checkbox" class="aam-checkbox-danger" id="menu-item-<?php echo $i . $j; ?>" data-menu-id="<?php echo $submenu['id']; ?>"<?php echo ($object->has($submenu['id']) ? ' checked="checked"' : ''); ?> />
50
- <label for="menu-item-<?php echo $i . $j; ?>"></label>
51
  </div>
52
  <?php } ?>
53
  <?php } ?>
54
  </div>
 
 
55
  <?php } ?>
56
 
57
  <div class="row<?php echo (!empty($menu['submenu']) ? ' aam-margin-top-xs' : ''); ?>">
@@ -81,9 +87,10 @@
81
  <h4 class="modal-title"><?php echo __('Dashboard Lockdown', AAM_KEY); ?></h4>
82
  </div>
83
  <div class="modal-body">
84
- <p class="text-center alert alert-warning"><strong><?php echo __('You cannot restrict access to Dashboard home page.', AAM_KEY); ?></strong></p>
85
-
86
- <p class="aam-outer-top-xs text-center"><?php echo sprintf(__('Dashboard home page is the default page every user is redirected after login. If you need to lockdown user from the entire website dashboard, %splease check this article%s.', AAM_KEY), '<a href="https://aamplugin.com/help/how-to-lockdown-wordpress-backend" target="_blank">', '</a>'); ?></p>
 
87
  </div>
88
  <div class="modal-footer">
89
  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('OK', AAM_KEY); ?></button>
3
  <div class="row">
4
  <div class="col-xs-12">
5
  <p class="aam-info">
6
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Protect your backend area. The list of menus and submenus is based on capabilities [%s] has. For more information please check %sHow to manage WordPress backend menu%s.', 'b', 'b'), AAM_Backend_Subject::getInstance()->getName(), '<a href="https://aamplugin.com/help/how-to-manage-wordpress-backend-menu" target="_blank">', '</a>'); ?>
7
  </p>
8
  </div>
9
  </div>
19
  <div class="panel-group" id="admin-menu" role="tablist" aria-multiselectable="true">
20
  <?php
21
  $first = false;
22
+ $object = AAM_Backend_Subject::getInstance()->getObject('menu');
23
  foreach ($this->getMenu() as $i => $menu) {
24
  ?>
25
  <div class="panel panel-default">
28
  <a role="button" data-toggle="collapse" data-parent="#admin-menu" href="#menu-<?php echo $i; ?>" aria-controls="menu-<?php echo $i; ?>" <?php if (!$first) { echo 'aria-expanded="true"'; } ?>>
29
  <?php echo $menu['name']; ?> <small class="aam-menu-capability"><?php echo $menu['capability']; ?></small>
30
  </a>
31
+ <?php if ($object->has($menu['id'])) { ?>
32
+ <i class="aam-panel-title-icon icon-eye-off text-danger"></i>
33
+ <?php } elseif ($this->hasSubmenuChecked($object, $menu['submenu'])) { ?>
34
+ <i class="aam-panel-title-icon icon-attention-circled text-warning"></i>
35
+ <?php } ?>
36
  </h4>
37
  </div>
38
 
39
  <div id="menu-<?php echo $i; ?>" class="panel-collapse collapse<?php if (!$first) { echo ' in'; $first = true; } ?>" role="tabpanel" aria-labelledby="menu-<?php echo $i; ?>-heading">
40
  <div class="panel-body">
41
  <?php if (!empty($menu['submenu'])) { ?>
42
+ <div class="row">
43
  <?php echo ($object->has($menu['id']) ? '<div class="aam-lock"></div>' : ''); ?>
44
  <?php foreach ($menu['submenu'] as $j => $submenu) { ?>
45
  <?php if ($submenu['id'] == 'index.php') { ?>
51
  <div class="col-xs-12 col-md-6 aam-submenu-item">
52
  <label for="menu-item-<?php echo $i . $j; ?>"><?php echo $submenu['name']; ?> <small class="aam-menu-capability"><?php echo $submenu['capability']; ?></small></label>
53
  <input type="checkbox" class="aam-checkbox-danger" id="menu-item-<?php echo $i . $j; ?>" data-menu-id="<?php echo $submenu['id']; ?>"<?php echo ($object->has($submenu['id']) ? ' checked="checked"' : ''); ?> />
54
+ <label for="menu-item-<?php echo $i . $j; ?>" data-toggle="tooltip" title="<?php echo ($object->has($submenu['id']) ? __('Uncheck to allow', AAM_KEY) : __('Check to restrict', AAM_KEY)); ?>"></label>
55
  </div>
56
  <?php } ?>
57
  <?php } ?>
58
  </div>
59
+
60
+ <hr class="aam-divider" />
61
  <?php } ?>
62
 
63
  <div class="row<?php echo (!empty($menu['submenu']) ? ' aam-margin-top-xs' : ''); ?>">
87
  <h4 class="modal-title"><?php echo __('Dashboard Lockdown', AAM_KEY); ?></h4>
88
  </div>
89
  <div class="modal-body">
90
+ <p class="text-center alert alert-warning text-larger">
91
+ <strong><?php echo __('You cannot restrict access to Dashboard home page.', AAM_KEY); ?></strong><br/>
92
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('The [Home] is the default page every user is redirected after login. To restrict access to the entire backend, please check %sHow to lockdown WordPress backend%s article.', 'b'), '<a href="https://aamplugin.com/help/how-to-lockdown-wordpress-backend" target="_blank">', '</a>'); ?>
93
+ </p>
94
  </div>
95
  <div class="modal-footer">
96
  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('OK', AAM_KEY); ?></button>
Application/Backend/phtml/{object → main}/metabox.phtml RENAMED
@@ -1,5 +1,13 @@
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="aam-feature" id="metabox-content">
 
 
 
 
 
 
 
 
3
  <div class="aam-feature-top-actions text-right">
4
  <a href="#" class="btn btn-xs btn-primary" id="refresh-metabox-list"><i class="icon-arrows-cw"></i> <?php echo __('Refresh', AAM_KEY); ?></a>
5
  <a href="#init-url-modal" class="btn btn-xs btn-primary" data-toggle="modal"><i class="icon-link"></i> <?php echo __('Init URL', AAM_KEY); ?></a>
@@ -18,7 +26,7 @@
18
  global $wp_post_types;
19
 
20
  $first = false;
21
- $object = AAM_Backend_View::getSubject()->getObject('metabox');
22
  $metaboxList = $this->getMetaboxList();
23
  ?>
24
 
@@ -49,12 +57,12 @@
49
  </div>
50
  <div id="group-<?php echo $screen; ?>" class="panel-collapse collapse<?php if (!$first) { echo ' in'; $first = true; } ?>" role="tabpanel" aria-labelledby="group-<?php echo $screen; ?>-heading">
51
  <div class="panel-body">
52
- <div class="row aam-bordered">
53
  <?php foreach ($metaboxes as $metabox) { ?>
54
  <div class="col-xs-12 col-md-6 aam-submenu-item">
55
  <label for="metabox-<?php echo $screen; ?>-<?php echo $metabox['id']; ?>"><?php echo $metabox['title']; ?></label>
56
  <input type="checkbox" class="aam-checkbox-danger" id="metabox-<?php echo $screen; ?>-<?php echo $metabox['id']; ?>" data-metabox="<?php echo $screen; ?>|<?php echo $metabox['id']; ?>"<?php echo ($object->has($screen, $metabox['id']) ? ' checked="checked"' : ''); ?> />
57
- <label for="metabox-<?php echo $screen; ?>-<?php echo $metabox['id']; ?>"></label>
58
  </div>
59
  <?php } ?>
60
  </div>
@@ -66,7 +74,10 @@
66
  <?php } else { ?>
67
  <div class="row">
68
  <div class="col-xs-12 text-center">
69
- <p class="aam-notification-message"><?php echo __('The list is not initialized. Click Refresh button above.'); ?></p>
 
 
 
70
  </div>
71
  </div>
72
  <?php } ?>
@@ -80,7 +91,7 @@
80
  </div>
81
  <div class="modal-body">
82
  <p class="aam-info">
83
- <?php echo __('Some metaboxes are "conditional" and appear on the Edit Screen when certain conditions are met. For example metabox "Comments" appears only for existing page and not for new page. If you do not see a desired metabox, try to copy & paste a full URL to a backend page where that metabox appears.'); ?>
84
  </p>
85
  <div class="form-group">
86
  <label><?php echo __('Backend page URL', AAM_KEY); ?></label>
1
  <?php if (defined('AAM_KEY')) { ?>
2
  <div class="aam-feature" id="metabox-content">
3
+ <div class="row">
4
+ <div class="col-xs-12">
5
+ <p class="aam-info">
6
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Hide unnecessary or restricted metaboxes and widgets for [%s]. For more information please check %sHow to hide WordPress metaboxes and widgets%s.', 'b', 'b'), AAM_Backend_Subject::getInstance()->getName(), '<a href="https://aamplugin.com/help/how-to-hide-wordpress-metaboxes-and-widgets" target="_blank">', '</a>'); ?>
7
+ </p>
8
+ </div>
9
+ </div>
10
+
11
  <div class="aam-feature-top-actions text-right">
12
  <a href="#" class="btn btn-xs btn-primary" id="refresh-metabox-list"><i class="icon-arrows-cw"></i> <?php echo __('Refresh', AAM_KEY); ?></a>
13
  <a href="#init-url-modal" class="btn btn-xs btn-primary" data-toggle="modal"><i class="icon-link"></i> <?php echo __('Init URL', AAM_KEY); ?></a>
26
  global $wp_post_types;
27
 
28
  $first = false;
29
+ $object = AAM_Backend_Subject::getInstance()->getObject('metabox');
30
  $metaboxList = $this->getMetaboxList();
31
  ?>
32
 
57
  </div>
58
  <div id="group-<?php echo $screen; ?>" class="panel-collapse collapse<?php if (!$first) { echo ' in'; $first = true; } ?>" role="tabpanel" aria-labelledby="group-<?php echo $screen; ?>-heading">
59
  <div class="panel-body">
60
+ <div class="row">
61
  <?php foreach ($metaboxes as $metabox) { ?>
62
  <div class="col-xs-12 col-md-6 aam-submenu-item">
63
  <label for="metabox-<?php echo $screen; ?>-<?php echo $metabox['id']; ?>"><?php echo $metabox['title']; ?></label>
64
  <input type="checkbox" class="aam-checkbox-danger" id="metabox-<?php echo $screen; ?>-<?php echo $metabox['id']; ?>" data-metabox="<?php echo $screen; ?>|<?php echo $metabox['id']; ?>"<?php echo ($object->has($screen, $metabox['id']) ? ' checked="checked"' : ''); ?> />
65
+ <label for="metabox-<?php echo $screen; ?>-<?php echo $metabox['id']; ?>" data-toggle="tooltip" title="<?php echo ($object->has($screen, $metabox['id']) ? __('Uncheck to show', AAM_KEY) : __('Check to hide', AAM_KEY)); ?>"></label>
66
  </div>
67
  <?php } ?>
68
  </div>
74
  <?php } else { ?>
75
  <div class="row">
76
  <div class="col-xs-12 text-center">
77
+ <p class="alert alert-info text-larger">
78
+ <?php echo __('The list is not initialized. Click Refresh button above.'); ?><br/>
79
+ <small><?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('If your website requires HTTP authentication, please refer to [%sthis article%s] for additional information.', 'b'), '<a href="https://aamplugin.com/help/how-to-hide-wordpress-metaboxes-and-widgets" target="_blank">', '</a>'); ?></small>
80
+ </p>
81
  </div>
82
  </div>
83
  <?php } ?>
91
  </div>
92
  <div class="modal-body">
93
  <p class="aam-info">
94
+ <?php echo __('Some metaboxes are "conditional" and appear on the Edit screen when certain conditions are met. For example metabox "Comments" appears only for existing page and not for new page. If you do not see a desired metabox, try to copy & paste the full URL to the backend page where that metabox appears.'); ?>
95
  </p>
96
  <div class="form-group">
97
  <label><?php echo __('Backend page URL', AAM_KEY); ?></label>
Application/Backend/phtml/{object → main}/post.phtml RENAMED
@@ -12,13 +12,13 @@
12
  <div class="row">
13
  <div class="col-xs-12">
14
  <p class="aam-info">
15
- <?php echo sprintf(__('Manage access to posts, pages and custom post types. For more information about this functionality check %sWhat is a WordPress post%s article.'), '<a href="https://aamplugin.com/help/what-is-a-wordpress-post" target="_blank">', '</a>'); ?>
16
  </p>
17
  </div>
18
  </div>
19
  <?php } ?>
20
 
21
- <?php if (defined('AAM_PLUS_PACKAGE') || AAM_Backend_View::getSubject()->getUID() != 'default') { ?>
22
  <?php $current = $this->getCurrentObject();?>
23
 
24
  <div class="aam-post-breadcrumb">
@@ -71,18 +71,23 @@
71
  <a href="#" class="btn btn-xs btn-primary post-back btn-right">&Lt; <?php echo __('Go Back', AAM_KEY); ?></a>
72
  <table class="table table-striped table-bordered">
73
  <tbody>
74
- <?php if (AAM_Core_Config::get('frontend-access-control', true)) { ?>
 
 
 
75
  <tr>
76
  <td colspan="2" class="aam-table-group">
77
  <i class="icon-doc-text-inv"></i> <strong><?php echo __('Frontend', AAM_KEY); ?></strong>
78
  </td>
79
  </tr>
80
 
81
- <?php foreach($this->getAccessOptionList('frontend') as $option => $data) { ?>
82
  <tr>
83
  <td width="90%">
84
  <strong class="aam-block aam-highlight text-uppercase"><?php echo $data['title']; ?></strong>
85
- <?php if (!empty($data['sub'])) { echo $data['sub']; } ?>
 
 
86
  <p class="aam-hint" data-dynamic-post-label="<?php echo $data['descr']; ?>"></p>
87
  </td>
88
  <td>
@@ -92,22 +97,22 @@
92
  </td>
93
  </tr>
94
  <?php } ?>
95
-
96
- <?php do_action('aam-post-access-option-action', 'post', 'frontend'); ?>
97
  <?php } ?>
98
 
99
- <?php if (AAM_Core_Config::get('backend-access-control', true)) { ?>
100
  <tr class="aam-backend-post-access">
101
  <td colspan="2" class="aam-table-group">
102
  <i class="icon-doc-text-inv"></i> <strong><?php echo __('Backend', AAM_KEY); ?></strong>
103
  </td>
104
  </tr>
105
 
106
- <?php foreach($this->getAccessOptionList('backend') as $option => $data) { ?>
107
  <tr class="aam-backend-post-access">
108
  <td width="90%">
109
  <strong class="aam-block aam-highlight text-uppercase"><?php echo $data['title']; ?></strong>
110
- <?php if (!empty($data['sub'])) { echo $data['sub']; } ?>
 
 
111
  <p class="aam-hint" data-dynamic-post-label="<?php echo $data['descr']; ?>"></p>
112
  </td>
113
  <td>
@@ -117,8 +122,6 @@
117
  </td>
118
  </tr>
119
  <?php } ?>
120
-
121
- <?php do_action('aam-post-access-option-action', 'post', 'backend'); ?>
122
  <?php } ?>
123
  </tbody>
124
  </table>
12
  <div class="row">
13
  <div class="col-xs-12">
14
  <p class="aam-info">
15
+ <?php echo sprintf(__('Manage access to posts, pages and custom post types. For more information about this functionality check %sHow to manage access to the WordPress content%s article.'), '<a href="https://aamplugin.com/help/how-to-manage-access-to-the-wordpress-content" target="_blank">', '</a>'); ?>
16
  </p>
17
  </div>
18
  </div>
19
  <?php } ?>
20
 
21
+ <?php if (defined('AAM_PLUS_PACKAGE') || AAM_Backend_Subject::getInstance()->getUID() != AAM_Core_Subject_Default::UID) { ?>
22
  <?php $current = $this->getCurrentObject();?>
23
 
24
  <div class="aam-post-breadcrumb">
71
  <a href="#" class="btn btn-xs btn-primary post-back btn-right">&Lt; <?php echo __('Go Back', AAM_KEY); ?></a>
72
  <table class="table table-striped table-bordered">
73
  <tbody>
74
+ <?php $frontend = $this->getAccessOptionList('frontend'); ?>
75
+ <?php $backend = $this->getAccessOptionList('backend'); ?>
76
+
77
+ <?php if (count($frontend) && AAM_Core_Config::get('frontend-access-control', true)) { ?>
78
  <tr>
79
  <td colspan="2" class="aam-table-group">
80
  <i class="icon-doc-text-inv"></i> <strong><?php echo __('Frontend', AAM_KEY); ?></strong>
81
  </td>
82
  </tr>
83
 
84
+ <?php foreach($frontend as $option => $data) { ?>
85
  <tr>
86
  <td width="90%">
87
  <strong class="aam-block aam-highlight text-uppercase"><?php echo $data['title']; ?></strong>
88
+ <?php if (!empty($data['sub'])) { ?>
89
+ <small><?php echo $data['sub']; ?>: <b id="<?php echo $data['preview']; ?>" data-ref="<?php echo $data['option']; ?>" class="option-preview">...</b> <a href="#modal-<?php echo str_replace('.', '-', $data['option']); ?>" data-toggle="modal" class="advanced-post-option" data-ref="<?php echo $data['option']; ?>" data-preview="#<?php echo $data['preview']; ?>"><?php echo __('change', AAM_KEY); ?></a></small>
90
+ <?php } ?>
91
  <p class="aam-hint" data-dynamic-post-label="<?php echo $data['descr']; ?>"></p>
92
  </td>
93
  <td>
97
  </td>
98
  </tr>
99
  <?php } ?>
 
 
100
  <?php } ?>
101
 
102
+ <?php if (count($backend) && AAM_Core_Config::get('backend-access-control', true)) { ?>
103
  <tr class="aam-backend-post-access">
104
  <td colspan="2" class="aam-table-group">
105
  <i class="icon-doc-text-inv"></i> <strong><?php echo __('Backend', AAM_KEY); ?></strong>
106
  </td>
107
  </tr>
108
 
109
+ <?php foreach($backend as $option => $data) { ?>
110
  <tr class="aam-backend-post-access">
111
  <td width="90%">
112
  <strong class="aam-block aam-highlight text-uppercase"><?php echo $data['title']; ?></strong>
113
+ <?php if (!empty($data['sub'])) { ?>
114
+ <small><?php echo $data['sub']; ?>: <b id="<?php echo $data['preview']; ?>" data-ref="<?php echo $data['option']; ?>" class="option-preview">...</b> <a href="#modal-<?php echo str_replace('.', '-', $data['option']); ?>" data-toggle="modal" class="advanced-post-option" data-ref="<?php echo $data['option']; ?>" data-preview="#<?php echo $data['preview']; ?>"><?php echo __('change', AAM_KEY); ?></a></small>
115
+ <?php } ?>
116
  <p class="aam-hint" data-dynamic-post-label="<?php echo $data['descr']; ?>"></p>
117
  </td>
118
  <td>
122
  </td>
123
  </tr>
124
  <?php } ?>
 
 
125
  <?php } ?>
126
  </tbody>
127
  </table>
Application/Backend/phtml/{object → main}/redirect.phtml RENAMED
@@ -8,7 +8,7 @@
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize redirect for this %s when access is denied to restricted resources like posts, categories, menus, etc. For more information about this feature, please check %sHow to redirect WordPress user when access is denied%s.'), AAM_Backend_View::getSubject()->getUID(), '<a href="https://aamplugin.com/help/how-to-redirect-wordpress-user-when-access-is-denied" target="_blank">', '</a>'); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
@@ -23,7 +23,7 @@
23
  <div>
24
  <ul class="nav nav-tabs" role="tablist">
25
  <?php if (AAM_Core_Config::get('frontend-access-control', true)) { ?> <li role="presentation" class="active"><a href="#frontend-redirect" aria-controls="frontend-redirect" role="tab" data-toggle="tab"><i class="icon-home"></i> <?php echo __('Frontend Redirect', AAM_KEY); ?></a></li><?php } ?>
26
- <?php if (AAM_Core_Config::get('backend-access-control', true)) { ?><li role="presentation"><a href="#backend-redirect" aria-controls="backend-redirect" role="tab" data-toggle="tab"><i class="icon-circle"></i> <?php echo __('Backend Redirect', AAM_KEY); ?></a></li><?php } ?>
27
  </ul>
28
 
29
  <?php $frontendType = $this->getOption('frontend.redirect.type', 'default'); ?>
8
  </p>
9
  <?php } else { ?>
10
  <p class="aam-info">
11
+ <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize redirect for %s when access is denied to restricted resources like posts, categories, menus, etc. For more information about this feature, please check %sHow to redirect WordPress user when access is denied%s.'), AAM_Backend_Subject::getInstance()->getName(), '<a href="https://aamplugin.com/help/how-to-redirect-wordpress-user-when-access-is-denied" target="_blank">', '</a>'); ?>
12
  </p>
13
  <?php } ?>
14
  <div class="aam-overwrite" id="aam-redirect-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
23
  <div>
24
  <ul class="nav nav-tabs" role="tablist">
25
  <?php if (AAM_Core_Config::get('frontend-access-control', true)) { ?> <li role="presentation" class="active"><a href="#frontend-redirect" aria-controls="frontend-redirect" role="tab" data-toggle="tab"><i class="icon-home"></i> <?php echo __('Frontend Redirect', AAM_KEY); ?></a></li><?php } ?>
26
+ <?php if (AAM_Core_Config::get('backend-access-control', true) && !$this->isVisitor()) { ?><li role="presentation"><a href="#backend-redirect" aria-controls="backend-redirect" role="tab" data-toggle="tab"><i class="icon-circle"></i> <?php echo __('Backend Redirect', AAM_KEY); ?></a></li><?php } ?>
27
  </ul>
28
 
29
  <?php $frontendType = $this->getOption('frontend.redirect.type', 'default'); ?>
Application/Backend/phtml/object/teaser.phtml DELETED
@@ -1,41 +0,0 @@
1
- <?php if (defined('AAM_KEY')) { ?>
2
- <div class="aam-feature" id="teaser-content">
3
- <div class="row">
4
- <div class="col-xs-12">
5
- <p class="aam-notification">
6
- <?php echo AAM_Backend_View_Helper::preparePhrase('[Warning!] The Content Teaser tab is deprecated and has been moved to the [Posts & Pages tab]. Now you can define teaser message for an individual post, category or all posts for any user, role or visitors. Please adjust your AAM settings because Content Teaser tab will be removed in AAM 5.0. For any feedback of questions, do not hesistate to contact us directly.', 'strong', 'strong'); ?>
7
- </p>
8
- <?php if ($this->isDefault()) { ?>
9
- <p class="aam-info">
10
- <?php echo AAM_Backend_View_Helper::preparePhrase('Define the [default] teaser message for all users, roles and visitors when access is limited to any post on your website.', 'strong'); ?>
11
- </p>
12
- <?php } else { ?>
13
- <p class="aam-info">
14
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Customize the teaser message for this %s when access is limited to any post, page or custom post type on your website.'), AAM_Backend_View::getSubject()->getUID()); ?>
15
- </p>
16
- <?php } ?>
17
- <div class="aam-overwrite" id="aam-teaser-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
18
- <span><i class="icon-check"></i> Settings are customized</span>
19
- <span><a href="#" id="teaser-reset" class="btn btn-xs btn-primary">Reset To Default</a></span>
20
- </div>
21
- </div>
22
- </div>
23
-
24
- <div class="row">
25
- <div class="col-xs-12">
26
- <div>
27
- <div class="form-group">
28
- <label><?php echo __('Teaser Message', AAM_KEY); ?></label>
29
- <textarea class="form-control" name="frontend.teaser.message" rows="3" placeholder="<?php echo __('Enter teaser message...', AAM_KEY); ?>"><?php echo stripslashes($this->getOption('frontend.teaser.message')); ?></textarea>
30
- </div>
31
- <div class="checkbox">
32
- <label>
33
- <input type="checkbox" name="frontend.teaser.excerpt" value="1" <?php echo intval($this->getOption('frontend.teaser.excerpt')) ? 'checked' : ''; ?> />
34
- <?php echo __('Add excerpt before teaser message', AAM_KEY); ?>
35
- </label>
36
- </div>
37
- </div>
38
- </div>
39
- </div>
40
- </div>
41
- <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Backend/phtml/partial/post-advanced-settings.phtml CHANGED
@@ -1,5 +1,26 @@
1
  <?php if (defined('AAM_KEY')) { ?>
2
- <div class="modal fade" id="password-modal" tabindex="-1" role="dialog">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  <div class="modal-dialog modal-sm" role="document">
4
  <div class="modal-content">
5
  <div class="modal-header">
@@ -9,39 +30,40 @@
9
  <div class="modal-body">
10
  <div class="form-group">
11
  <label><?php echo __('Password', AAM_KEY); ?></label>
12
- <input type="text" class="form-control" id="password-value" placeholder="<?php echo __('Enter Password', AAM_KEY); ?>" />
13
  </div>
14
  </div>
15
  <div class="modal-footer">
16
- <button type="button" class="btn btn-success extended-post-access-btn" id="change-password-btn"><?php echo __('Set', AAM_KEY); ?></button>
17
  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
18
  </div>
19
  </div>
20
  </div>
21
  </div>
22
 
23
- <div class="modal fade" id="location-modal" tabindex="-1" role="dialog">
24
  <div class="modal-dialog" role="document">
25
  <div class="modal-content">
26
  <div class="modal-header">
27
  <button type="button" class="close" data-dismiss="modal" aria-label="<?php echo __('Close', AAM_KEY); ?>"><span aria-hidden="true">&times;</span></button>
28
- <h4 class="modal-title"><?php echo __('Set Redirect', AAM_KEY); ?></h4>
29
  </div>
30
  <div class="modal-body">
31
- <div class="form-group">
32
- <label><?php echo __('Valid URL, Page ID or PHP callback function', AAM_KEY); ?></label>
33
- <input type="text" class="form-control" id="location-value" placeholder="<?php echo __('Enter Redirect', AAM_KEY); ?>" />
 
34
  </div>
35
  </div>
36
  <div class="modal-footer">
37
- <button type="button" class="btn btn-success extended-post-access-btn" id="change-location-btn"><?php echo __('Set', AAM_KEY); ?></button>
38
  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
39
  </div>
40
  </div>
41
  </div>
42
  </div>
43
 
44
- <div class="modal fade" id="expiration-modal" tabindex="-1" role="dialog">
45
  <div class="modal-dialog" role="document">
46
  <div class="modal-content">
47
  <div class="modal-header">
@@ -57,18 +79,18 @@
57
  </p>
58
  <div class="form-group">
59
  <label><?php echo __('Enter expiration critiria', AAM_KEY); ?></label>
60
- <input type="text" class="form-control" id="expiration-value" placeholder="<?php echo __('Enter critiria', AAM_KEY); ?>" />
61
  </div>
62
  </div>
63
  <div class="modal-footer">
64
- <button type="button" class="btn btn-success extended-post-access-btn" id="change-expiration-btn"><?php echo __('Set', AAM_KEY); ?></button>
65
  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
66
  </div>
67
  </div>
68
  </div>
69
  </div>
70
 
71
- <div class="modal fade" id="teaser-modal" tabindex="-1" role="dialog">
72
  <div class="modal-dialog" role="document">
73
  <div class="modal-content">
74
  <div class="modal-header">
@@ -78,11 +100,34 @@
78
  <div class="modal-body">
79
  <div class="form-group">
80
  <label><?php echo __('Simple text or valid HTML', AAM_KEY); ?></label>
81
- <textarea class="form-control" id="teaser-value" placeholder="<?php echo __('Enter your teaser', AAM_KEY); ?>" rows="5"></textarea>
82
  </div>
83
  </div>
84
  <div class="modal-footer">
85
- <button type="button" class="btn btn-success extended-post-access-btn" id="change-teaser-btn"><?php echo __('Save', AAM_KEY); ?></button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
87
  </div>
88
  </div>
1
  <?php if (defined('AAM_KEY')) { ?>
2
+ <div class="modal fade" id="modal-frontend-access_counter_limit" tabindex="-1" role="dialog">
3
+ <div class="modal-dialog modal-sm" role="document">
4
+ <div class="modal-content">
5
+ <div class="modal-header">
6
+ <button type="button" class="close" data-dismiss="modal" aria-label="<?php echo __('Close', AAM_KEY); ?>"><span aria-hidden="true">&times;</span></button>
7
+ <h4 class="modal-title"><?php echo __('Define Threshold', AAM_KEY); ?></h4>
8
+ </div>
9
+ <div class="modal-body">
10
+ <div class="form-group">
11
+ <label><?php echo __('Threshold', AAM_KEY); ?></label>
12
+ <input type="text" class="form-control" placeholder="<?php echo __('Enter digital number', AAM_KEY); ?>" id="aam-read-counter" />
13
+ </div>
14
+ </div>
15
+ <div class="modal-footer">
16
+ <button type="button" class="btn btn-success extended-post-access-btn" data-modal="#modal-frontend-access_counter_limit" data-field="#aam-read-counter"><?php echo __('Update', AAM_KEY); ?></button>
17
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </div>
22
+
23
+ <div class="modal fade" id="modal-frontend-password" tabindex="-1" role="dialog">
24
  <div class="modal-dialog modal-sm" role="document">
25
  <div class="modal-content">
26
  <div class="modal-header">
30
  <div class="modal-body">
31
  <div class="form-group">
32
  <label><?php echo __('Password', AAM_KEY); ?></label>
33
+ <input type="text" class="form-control" placeholder="<?php echo __('Enter Password', AAM_KEY); ?>" id="aam-access-password" />
34
  </div>
35
  </div>
36
  <div class="modal-footer">
37
+ <button type="button" class="btn btn-success extended-post-access-btn" data-modal="#modal-frontend-password" data-field="#aam-access-password"><?php echo __('Update', AAM_KEY); ?></button>
38
  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
39
  </div>
40
  </div>
41
  </div>
42
  </div>
43
 
44
+ <div class="modal fade" id="modal-frontend-location" tabindex="-1" role="dialog">
45
  <div class="modal-dialog" role="document">
46
  <div class="modal-content">
47
  <div class="modal-header">
48
  <button type="button" class="close" data-dismiss="modal" aria-label="<?php echo __('Close', AAM_KEY); ?>"><span aria-hidden="true">&times;</span></button>
49
+ <h4 class="modal-title"><?php echo __('Define Redirect Rule', AAM_KEY); ?></h4>
50
  </div>
51
  <div class="modal-body">
52
+ <p class="aam-info"><?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('To learn more about REDIRECT option, please refer to our [%sHelp Section%s].', 'b'), '<a href="https://aamplugin.com/help#post-redirect" target="_blank">', '</a>'); ?></p>
53
+ <div class="form-group aam-outer-top-xs">
54
+ <label><?php echo __('Enter Redirect Rule', AAM_KEY); ?></label>
55
+ <input type="text" class="form-control" placeholder="<?php echo __('Enter rule', AAM_KEY); ?>" id="aam-access-redirect" />
56
  </div>
57
  </div>
58
  <div class="modal-footer">
59
+ <button type="button" class="btn btn-success extended-post-access-btn" data-modal="#modal-frontend-location" data-field="#aam-access-redirect"><?php echo __('Update', AAM_KEY); ?></button>
60
  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
61
  </div>
62
  </div>
63
  </div>
64
  </div>
65
 
66
+ <div class="modal fade" id="modal-frontend-expire_datetime" tabindex="-1" role="dialog">
67
  <div class="modal-dialog" role="document">
68
  <div class="modal-content">
69
  <div class="modal-header">
79
  </p>
80
  <div class="form-group">
81
  <label><?php echo __('Enter expiration critiria', AAM_KEY); ?></label>
82
+ <input type="text" class="form-control" placeholder="<?php echo __('Enter critiria', AAM_KEY); ?>" id="aam-expire-datetime" />
83
  </div>
84
  </div>
85
  <div class="modal-footer">
86
+ <button type="button" class="btn btn-success extended-post-access-btn" data-modal="#modal-frontend-expire_datetime" data-field="#aam-expire-datetime"><?php echo __('Update', AAM_KEY); ?></button>
87
  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
88
  </div>
89
  </div>
90
  </div>
91
  </div>
92
 
93
+ <div class="modal fade" id="modal-frontend-teaser" tabindex="-1" role="dialog">
94
  <div class="modal-dialog" role="document">
95
  <div class="modal-content">
96
  <div class="modal-header">
100
  <div class="modal-body">
101
  <div class="form-group">
102
  <label><?php echo __('Simple text or valid HTML', AAM_KEY); ?></label>
103
+ <textarea class="form-control" placeholder="<?php echo __('Enter your teaser', AAM_KEY); ?>" rows="5" id="aam-teaser-message"></textarea>
104
  </div>
105
  </div>
106
  <div class="modal-footer">
107
+ <button type="button" class="btn btn-success extended-post-access-btn" data-modal="#modal-frontend-teaser" data-field="#aam-teaser-message"><?php echo __('Save', AAM_KEY); ?></button>
108
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
109
+ </div>
110
+ </div>
111
+ </div>
112
+ </div>
113
+
114
+ <div class="modal fade" id="modal-frontend-eproduct" tabindex="-1" role="dialog">
115
+ <div class="modal-dialog" role="document">
116
+ <div class="modal-content">
117
+ <div class="modal-header">
118
+ <button type="button" class="close" data-dismiss="modal" aria-label="<?php echo __('Close', AAM_KEY); ?>"><span aria-hidden="true">&times;</span></button>
119
+ <h4 class="modal-title"><?php echo __('E-Commerce Setup', AAM_KEY); ?></h4>
120
+ </div>
121
+ <div class="modal-body">
122
+ <?php
123
+ echo apply_filters(
124
+ 'aam-frontend-eproduct-setup',
125
+ '<p class="alert alert-warning text-center">' . AAM_Backend_View_Helper::preparePhrase('Monetization is the premium feature that is available with [Payment] extension.', 'b') . '</p>'
126
+ );
127
+ ?>
128
+ </div>
129
+ <div class="modal-footer">
130
+ <button type="button" class="btn btn-success extended-post-access-btn" data-modal="#modal-frontend-eproduct" data-field="#aam-selected-eproduct"><?php echo __('Update', AAM_KEY); ?></button>
131
  <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Close', AAM_KEY); ?></button>
132
  </div>
133
  </div>
Application/Backend/phtml/partial/teaser.phtml DELETED
@@ -1,5 +0,0 @@
1
- <?php if (defined('AAM_KEY')) { ?>
2
- <p class="aam-info">
3
- <?php echo AAM_Backend_View_Helper::preparePhrase('Setup [default] teaser message for all users, roles and visitors when access is limited to read posts or pages.', 'strong'); ?>
4
- </p>
5
- <?php }
 
 
 
 
 
Application/Backend/phtml/security.phtml DELETED
@@ -1,7 +0,0 @@
1
- <?php if (defined('AAM_KEY')) { ?>
2
- <div class="aam-feature" id="security-content">
3
- <p class="aam-notification">
4
- <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('[Warning!] The Security feature has been deprecated and will be removed in AAM 5.0. This feature has been replaced with AAM Secure Login Widget and Shortcode. For more information please check %sHow does AAM Secure Login works%s article. For any feedback of questions, do not hesistate to contact us directly.', 'strong'), '<a href="https://aamplugin.com/help/how-does-aam-secure-login-works" target="_blank">', '</a>'); ?>
5
- </p>
6
- </div>
7
- <?php }
 
 
 
 
 
 
 
Application/Backend/phtml/settings/content.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (defined('AAM_KEY')) { ?>
2
+ <div class="aam-feature settings" id="settings-content-content">
3
+ <table class="table table-striped table-bordered">
4
+ <tbody>
5
+ <?php foreach($this->getList() as $id => $option) { ?>
6
+ <tr>
7
+ <td>
8
+ <span class='aam-setting-title'><?php echo $option['title']; ?></span>
9
+ <p class="aam-setting-description">
10
+ <?php echo $option['descr']; ?>
11
+ </p>
12
+ </td>
13
+ <td class="text-center">
14
+ <input data-toggle="toggle" name="<?php echo $id; ?>" id="utility-<?php echo $id; ?>" <?php echo ($option['value'] ? 'checked' : ''); ?> type="checkbox" data-on="Enabled" data-off="Disabled" data-size="small" />
15
+ </td>
16
+ </tr>
17
+ <?php } ?>
18
+ </tbody>
19
+ </table>
20
+ </div>
21
+ <?php }
Application/Backend/phtml/settings/core.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (defined('AAM_KEY')) { ?>
2
+ <div class="aam-feature settings" id="settings-core-content">
3
+ <table class="table table-striped table-bordered">
4
+ <tbody>
5
+ <?php foreach($this->getList() as $id => $option) { ?>
6
+ <tr>
7
+ <td>
8
+ <span class='aam-setting-title'><?php echo $option['title']; ?></span>
9
+ <p class="aam-setting-description">
10
+ <?php echo $option['descr']; ?>
11
+ </p>
12
+ </td>
13
+ <td class="text-center">
14
+ <input data-toggle="toggle" name="<?php echo $id; ?>" id="utility-<?php echo $id; ?>" <?php echo ($option['value'] ? 'checked' : ''); ?> type="checkbox" data-on="Enabled" data-off="Disabled" data-size="small" />
15
+ </td>
16
+ </tr>
17
+ <?php } ?>
18
+ </tbody>
19
+ </table>
20
+ </div>
21
+ <?php }
Application/Backend/phtml/settings/tools.phtml ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (defined('AAM_KEY')) { ?>
2
+ <div class="aam-feature settings" id="settings-tools-content">
3
+ <div role="tabpanel" class="tab-pane" id="utility-tools">
4
+ <table class="table table-striped table-bordered">
5
+ <tbody>
6
+ <tr>
7
+ <td>
8
+ <span class='aam-setting-title'><?php echo __('Export AAM Settings', AAM_KEY); ?></span>
9
+ <p class="aam-setting-description">
10
+ <?php echo sprintf(__('Export selected AAM settings to the file. For more information about this feature check %sHow to export and import AAM settings%s article.', AAM_KEY), '<a href="https://aamplugin.com/help/how-to-export-and-import-aam-settings" target="_blank">', '</a>'); ?>
11
+ </p>
12
+ </td>
13
+ <td>
14
+ <a href="#" class="btn btn-success btn-block" id="export-aam">Export</a>
15
+ </td>
16
+ </tr>
17
+ <tr>
18
+ <td>
19
+ <span class='aam-setting-title'><?php echo __('Import AAM Settings', AAM_KEY); ?></span>
20
+ <p class="aam-setting-description">
21
+ <?php echo __('Import AAM settings from the file.', AAM_KEY); ?>
22
+ </p>
23
+ </td>
24
+ <td>
25
+ <div class="hidden"><input type="file" id="aam-import-file" /></div>
26
+ <a href="#" class="btn btn-warning btn-block" id="import-aam">Import</a>
27
+ </td>
28
+ </tr>
29
+ <tr>
30
+ <td>
31
+ <span class='aam-setting-title'><?php echo __('Clear Cache', AAM_KEY); ?></span>
32
+ <p class="aam-setting-description">
33
+ <?php echo __('Clear all AAM cache.', AAM_KEY); ?>
34
+ </p>
35
+ </td>
36
+ <td>
37
+ <a href="#" class="btn btn-primary btn-block" id="clear-cache">Clear</a>
38
+ </td>
39
+ </tr>
40
+ <tr>
41
+ <td>
42
+ <span class='aam-setting-title'><?php echo __('Clear All Settings', AAM_KEY); ?></span>
43
+ <p class="aam-setting-description">
44
+ <?php echo __('Remove all the settings related to AAM from the database.', AAM_KEY); ?>
45
+ </p>
46
+ </td>
47
+ <td>
48
+ <a href="#clear-settings-modal" data-toggle="modal" class="btn btn-danger btn-block">Clear</a>
49
+ </td>
50
+ </tr>
51
+ </tbody>
52
+ </table>
53
+ </div>
54
+
55
+ <div class="modal fade" id="clear-settings-modal" tabindex="-1" role="dialog">
56
+ <div class="modal-dialog modal-sm" role="document">
57
+ <div class="modal-content">
58
+ <div class="modal-header">
59
+ <button type="button" class="close" data-dismiss="modal" aria-label="<?php echo __('Close', AAM_KEY); ?>"><span aria-hidden="true">&times;</span></button>
60
+ <h4 class="modal-title"><?php echo __('Clear all settings', AAM_KEY); ?></h4>
61
+ </div>
62
+ <div class="modal-body">
63
+ <p class="text-center alert alert-danger text-larger"><?php echo __('All AAM settings will be removed.', AAM_KEY); ?></p>
64
+ </div>
65
+ <div class="modal-footer">
66
+ <button type="button" class="btn btn-danger" id="clear-settings"><?php echo __('Clear', AAM_KEY); ?></button>
67
+ <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Cancel', AAM_KEY); ?></button>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ <?php
74
+ }
Application/Backend/phtml/utility.phtml DELETED
@@ -1,148 +0,0 @@
1
- <?php if (defined('AAM_KEY')) { ?>
2
- <div class="aam-feature" id="utilities-content">
3
- <ul class="nav nav-tabs" role="tablist">
4
- <li role="presentation" class="active"><a href="#utility-core" aria-controls="utility-core" role="tab" data-toggle="tab"><?php echo __('AAM Core', AAM_KEY); ?></a></li>
5
- <li role="presentation"><a href="#utility-post" aria-controls="utility-post" role="tab" data-toggle="tab"><?php echo __('Posts Access', AAM_KEY); ?></a></li>
6
- <li role="presentation"><a href="#utility-tools" aria-controls="utility-tools" role="tab" data-toggle="tab"><?php echo __('Tools', AAM_KEY); ?></a></li>
7
- <li role="presentation"><a href="#utility-miscellaneous" aria-controls="utility-miscellaneous" role="tab" data-toggle="tab"><?php echo __('Miscellaneous', AAM_KEY); ?></a></li>
8
- </ul>
9
-
10
- <div class="tab-content">
11
- <div role="tabpanel" class="tab-pane active" id="utility-core">
12
- <table class="table table-striped table-bordered">
13
- <tbody>
14
- <?php foreach($this->getUtilityOptionList('core') as $id => $option) { ?>
15
- <tr>
16
- <td>
17
- <span class='aam-setting-title'><?php echo $option['title']; ?></span>
18
- <p class="aam-setting-description">
19
- <?php echo $option['descr']; ?>
20
- </p>
21
- </td>
22
- <td class="text-center">
23
- <input data-toggle="toggle" name="<?php echo $id; ?>" id="utility-<?php echo $id; ?>" <?php echo ($option['value'] ? 'checked' : ''); ?> type="checkbox" data-on="Enabled" data-off="Disabled" data-size="small" />
24
- </td>
25
- </tr>
26
- <?php } ?>
27
- </tbody>
28
- </table>
29
- </div>
30
- <div role="tabpanel" class="tab-pane" id="utility-post">
31
- <table class="table table-striped table-bordered">
32
- <tbody>
33
- <?php foreach($this->getUtilityOptionList('post') as $id => $option) { ?>
34
- <tr>
35
- <td>
36
- <span class='aam-setting-title'><?php echo $option['title']; ?></span>
37
- <p class="aam-setting-description">
38
- <?php echo $option['descr']; ?>
39
- </p>
40
- </td>
41
- <td class="text-center">
42
- <input data-toggle="toggle" name="<?php echo $id; ?>" id="utility-<?php echo $id; ?>" <?php echo ($option['value'] ? 'checked' : ''); ?> type="checkbox" data-on="Enabled" data-off="Disabled" data-size="small" />
43
- </td>
44
- </tr>
45
- <?php } ?>
46
- </tbody>
47
- </table>
48
- </div>
49
- <div role="tabpanel" class="tab-pane" id="utility-tools">
50
- <table class="table table-striped table-bordered">
51
- <tbody>
52
- <tr>
53
- <td>
54
- <span class='aam-setting-title'><?php echo __('Export AAM Settings', AAM_KEY); ?></span>
55
- <p class="aam-setting-description">
56
- <?php echo sprintf(__('Export selected AAM settings to the file. For more information about this feature check %sHow to export and import AAM settings%s article.', AAM_KEY), '<a href="https://aamplugin.com/help/how-to-export-and-import-aam-settings" target="_blank">', '</a>'); ?>
57
- </p>
58
- </td>
59
- <td>
60
- <a href="#" class="btn btn-success btn-block" id="export-aam">Export</a>
61
- </td>
62
- </tr>
63
- <tr>
64
- <td>
65
- <span class='aam-setting-title'><?php echo __('Import AAM Settings', AAM_KEY); ?></span>
66
- <p class="aam-setting-description">
67
- <?php echo __('Import AAM settings from the file.', AAM_KEY); ?>
68
- </p>
69
- </td>
70
- <td>
71
- <div class="hidden"><input type="file" id="aam-import-file" /></div>
72
- <a href="#" class="btn btn-warning btn-block" id="import-aam">Import</a>
73
- </td>
74
- </tr>
75
- <tr>
76
- <td>
77
- <span class='aam-setting-title'><?php echo __('Clear Cache', AAM_KEY); ?></span>
78
- <p class="aam-setting-description">
79
- <?php echo __('Clear all AAM cache.', AAM_KEY); ?>
80
- </p>
81
- </td>
82
- <td>
83
- <a href="#" class="btn btn-primary btn-block" id="clear-cache">Clear</a>
84
- </td>
85
- </tr>
86
- <tr>
87
- <td>
88
- <span class='aam-setting-title'><?php echo __('Clear All Settings', AAM_KEY); ?></span>
89
- <p class="aam-setting-description">
90
- <?php echo __('Remove all the settings related to AAM from the database.', AAM_KEY); ?>
91
- </p>
92
- </td>
93
- <td>
94
- <a href="#clear-settings-modal" data-toggle="modal" class="btn btn-danger btn-block">Clear</a>
95
- </td>
96
- </tr>
97
- </tbody>
98
- </table>
99
- </div>
100
- <div role="tabpanel" class="tab-pane" id="utility-miscellaneous">
101
- <table class="table table-striped table-bordered">
102
- <tbody>
103
- <?php $misc = $this->getUtilityOptionList('miscellaneous'); ?>
104
- <?php if (count($misc)) { ?>
105
- <?php foreach($this->getUtilityOptionList('miscellaneous') as $id => $option) { ?>
106
- <tr>
107
- <td>
108
- <span class='aam-setting-title'><?php echo $option['title']; ?></span>
109
- <p class="aam-setting-description">
110
- <?php echo $option['descr']; ?>
111
- </p>
112
- </td>
113
- <td class="text-center">
114
- <input data-toggle="toggle" name="<?php echo $id; ?>" id="utility-<?php echo $id; ?>" <?php echo ($option['value'] ? 'checked' : ''); ?> type="checkbox" data-on="Enabled" data-off="Disabled" data-size="small" />
115
- </td>
116
- </tr>
117
- <?php } ?>
118
- <?php } else { ?>
119
- <tr>
120
- <td colspan="2" class="text-center"><?php echo __('No miscellaneous options found.', AAM_KEY); ?></td>
121
- </tr>
122
- <?php } ?>
123
-
124
- <?php do_action('aam-post-utilities-setting'); ?>
125
- </tbody>
126
- </table>
127
- </div>
128
- </div>
129
-
130
- <div class="modal fade" id="clear-settings-modal" tabindex="-1" role="dialog">
131
- <div class="modal-dialog modal-sm" role="document">
132
- <div class="modal-content">
133
- <div class="modal-header">
134
- <button type="button" class="close" data-dismiss="modal" aria-label="<?php echo __('Close', AAM_KEY); ?>"><span aria-hidden="true">&times;</span></button>
135
- <h4 class="modal-title"><?php echo __('Clear all settings', AAM_KEY); ?></h4>
136
- </div>
137
- <div class="modal-body">
138
- <p class="text-center alert alert-danger text-larger"><?php echo __('All AAM settings will be removed.', AAM_KEY); ?></p>
139
- </div>
140
- <div class="modal-footer">
141
- <button type="button" class="btn btn-danger" id="clear-settings"><?php echo __('Clear', AAM_KEY); ?></button>
142
- <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('Cancel', AAM_KEY); ?></button>
143
- </div>
144
- </div>
145
- </div>
146
- </div>
147
- </div>
148
- <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Core/API.php CHANGED
@@ -231,25 +231,29 @@ final class AAM_Core_API {
231
  * @access public
232
  */
233
  public static function reject($area = 'frontend', $args = array()) {
234
- $object = AAM::getUser()->getObject('redirect');
235
- $type = $object->get("{$area}.redirect.type");
236
-
237
- if (!empty($type) && ($type == 'login')) {
238
- $redirect = add_query_arg(
239
- array('aam-redirect' => 'login'),
240
- wp_login_url(AAM_Core_Request::server('REQUEST_URI'))
241
- );
242
- } elseif (!empty($type) && ($type != 'default')) {
243
- $redirect = $object->get("{$area}.redirect.{$type}");
244
- } else { //ConfigPress setup
245
- $redirect = AAM_Core_Config::get(
246
- "{$area}.access.deny.redirect", __('Access Denied', AAM_KEY)
247
- );
 
 
 
 
 
 
 
 
248
  }
249
-
250
- do_action('aam-rejected-action', $area, $args);
251
-
252
- self::redirect($redirect, $args);
253
  }
254
 
255
  /**
@@ -263,7 +267,8 @@ final class AAM_Core_API {
263
  * @access public
264
  */
265
  public static function redirect($rule, $args = null) {
266
- if (filter_var($rule, FILTER_VALIDATE_URL)) {
 
267
  wp_redirect($rule, 307);
268
  } elseif (preg_match('/^[\d]+$/', $rule)) {
269
  wp_safe_redirect(get_page_link($rule), 307);
@@ -423,4 +428,35 @@ final class AAM_Core_API {
423
  return $type;
424
  }
425
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
  }
231
  * @access public
232
  */
233
  public static function reject($area = 'frontend', $args = array()) {
234
+ if (AAM_Core_Request::server('REQUEST_METHOD') != 'POST') {
235
+ $object = AAM::getUser()->getObject('redirect');
236
+ $type = $object->get("{$area}.redirect.type");
237
+
238
+ if (!empty($type) && ($type == 'login')) {
239
+ $redirect = add_query_arg(
240
+ array('aam-redirect' => 'login'),
241
+ wp_login_url(AAM_Core_Request::server('REQUEST_URI'))
242
+ );
243
+ } elseif (!empty($type) && ($type != 'default')) {
244
+ $redirect = $object->get("{$area}.redirect.{$type}");
245
+ } else { //ConfigPress setup
246
+ $redirect = AAM_Core_Config::get(
247
+ "{$area}.access.deny.redirect", __('Access Denied', AAM_KEY)
248
+ );
249
+ }
250
+
251
+ do_action('aam-rejected-action', $area, $args);
252
+
253
+ self::redirect($redirect, $args);
254
+ } else {
255
+ wp_die(-1);
256
  }
 
 
 
 
257
  }
258
 
259
  /**
267
  * @access public
268
  */
269
  public static function redirect($rule, $args = null) {
270
+ $path = parse_url($rule);
271
+ if ($path && !empty($path['host'])) {
272
  wp_redirect($rule, 307);
273
  } elseif (preg_match('/^[\d]+$/', $rule)) {
274
  wp_safe_redirect(get_page_link($rule), 307);
428
  return $type;
429
  }
430
 
431
+ /**
432
+ * Get current post
433
+ *
434
+ * @global type $wp_query
435
+ *
436
+ * @return WP_Post|null
437
+ */
438
+ public static function getCurrentPost() {
439
+ global $wp_query, $post;
440
+
441
+ $res = null;
442
+
443
+ if (!empty($wp_query->queried_object)) {
444
+ $res = $wp_query->queried_object;
445
+ } elseif (!empty($wp_query->post)) {
446
+ $res = $wp_query->post;
447
+ } elseif (!empty($wp_query->query['name']) && !empty($wp_query->posts)) {
448
+ //Important! Cover the scenario of NOT LIST but ALLOW READ
449
+ foreach($wp_query->posts as $post) {
450
+ if ($post->post_name == $wp_query->query['name']) {
451
+ $res = $post;
452
+ break;
453
+ }
454
+ }
455
+ }
456
+
457
+ $user = AAM::getUser();
458
+
459
+ return (is_a($res, 'WP_Post') ? $user->getObject('post', $res->ID) : null);
460
+ }
461
+
462
  }
Application/Core/Cache.php CHANGED
@@ -18,7 +18,7 @@ class AAM_Core_Cache {
18
  /**
19
  * DB Cache option
20
  */
21
- const CACHE_OPTION = 'cache';
22
 
23
  /**
24
  * Core config
@@ -94,12 +94,13 @@ class AAM_Core_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;
@@ -119,7 +120,7 @@ class AAM_Core_Cache {
119
  */
120
  public static function save() {
121
  if (self::$updated) {
122
- AAM::getUser()->updateOption(self::$cache, self::CACHE_OPTION);
123
  }
124
  }
125
 
@@ -134,7 +135,7 @@ class AAM_Core_Cache {
134
  */
135
  public static function bootstrap() {
136
  if (!AAM::isAAM()) {
137
- $cache = AAM::getUser()->readOption(self::CACHE_OPTION);
138
  self::$cache = (is_array($cache) ? $cache : array());
139
 
140
  add_action('shutdown', 'AAM_Core_Cache::save');
18
  /**
19
  * DB Cache option
20
  */
21
+ const CACHE_OPTION = 'aam-cache';
22
 
23
  /**
24
  * Core config
94
  $oquery = "DELETE FROM {$wpdb->options} WHERE `option_name` = %s";
95
  $wpdb->query($wpdb->prepare($oquery, 'aam_visitor_cache' ));
96
 
97
+ //clear all users cache
98
  $mquery = "DELETE FROM {$wpdb->usermeta} WHERE `meta_key` = %s";
99
+ $wpdb->query($wpdb->prepare($mquery, self::CACHE_OPTION));
100
  } else {
101
  $query = "DELETE FROM {$wpdb->usermeta} WHERE (`user_id` = %d) AND ";
102
  $query .= "`meta_key` = %s";
103
+ $wpdb->query($wpdb->prepare($query, $user, self::CACHE_OPTION));
104
  }
105
 
106
  self::$cache = false;
120
  */
121
  public static function save() {
122
  if (self::$updated) {
123
+ update_user_meta(AAM::getUser()->ID, self::CACHE_OPTION, self::$cache);
124
  }
125
  }
126
 
135
  */
136
  public static function bootstrap() {
137
  if (!AAM::isAAM()) {
138
+ $cache = get_user_meta(AAM::getUser(), self::CACHE_OPTION, true);
139
  self::$cache = (is_array($cache) ? $cache : array());
140
 
141
  add_action('shutdown', 'AAM_Core_Cache::save');
Application/Core/Compatibility.php CHANGED
@@ -22,6 +22,7 @@ class AAM_Core_Compatibility {
22
  public static function initExtensions() {
23
  //block deprecated extensions from loading
24
  define('AAM_UTILITIES', '99');
 
25
  define('AAM_POST_FILTER', '99');
26
  define('AAM_REDIRECT', '99');
27
  define('AAM_CONTENT_TEASER', '99');
22
  public static function initExtensions() {
23
  //block deprecated extensions from loading
24
  define('AAM_UTILITIES', '99');
25
+ define('AAM_ROLE_FILTER', '99');
26
  define('AAM_POST_FILTER', '99');
27
  define('AAM_REDIRECT', '99');
28
  define('AAM_CONTENT_TEASER', '99');
Application/Core/Console.php CHANGED
@@ -26,12 +26,13 @@ class AAM_Core_Console {
26
  * @access private
27
  * @static
28
  */
29
- private static $_warnings = array();
30
 
31
  /**
32
  * Add new warning
33
  *
34
  * @param string $message
 
35
  *
36
  * @return void
37
  *
@@ -39,19 +40,20 @@ class AAM_Core_Console {
39
  * @static
40
  */
41
  public static function add($message) {
42
- self::$_warnings[] = $message;
43
- }
44
-
45
- /**
46
- * Check if there is any warning during execution
47
- *
48
- * @return boolean
49
- *
50
- * @access public
51
- * @static
52
- */
53
- public static function hasIssues() {
54
- return (count(self::$_warnings) ? true : false);
 
55
  }
56
 
57
  /**
@@ -62,8 +64,8 @@ class AAM_Core_Console {
62
  * @access public
63
  * @static
64
  */
65
- public static function getWarnings() {
66
- return self::$_warnings;
67
  }
68
 
69
  /**
@@ -71,7 +73,20 @@ class AAM_Core_Console {
71
  * @return type
72
  */
73
  public static function count() {
74
- return count(self::$_warnings);
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
 
77
  }
26
  * @access private
27
  * @static
28
  */
29
+ private static $_messages = array();
30
 
31
  /**
32
  * Add new warning
33
  *
34
  * @param string $message
35
+ * @param stirng $args...
36
  *
37
  * @return void
38
  *
40
  * @static
41
  */
42
  public static function add($message) {
43
+ //prepare search patterns
44
+ $num = func_num_args();
45
+ $search = ($num > 1 ? array_fill(0, ($num - 1) * 2, null) : array());
46
+
47
+ array_walk($search, 'AAM_Core_Console::walk');
48
+
49
+ $replace = array();
50
+ foreach (array_slice(func_get_args(), 1) as $key) {
51
+ array_push($replace, "<{$key}>", "</{$key}>");
52
+ }
53
+
54
+ self::$_messages[] = preg_replace(
55
+ $search, $replace, __($message, AAM_KEY), 1
56
+ );
57
  }
58
 
59
  /**
64
  * @access public
65
  * @static
66
  */
67
+ public static function getAll() {
68
+ return self::$_messages;
69
  }
70
 
71
  /**
73
  * @return type
74
  */
75
  public static function count() {
76
+ return count(self::$_messages);
77
+ }
78
+
79
+ /**
80
+ * Replace place holders with markup
81
+ *
82
+ * @param string $value
83
+ * @param int $index
84
+ *
85
+ * @access protected
86
+ * @static
87
+ */
88
+ protected static function walk(&$value, $index) {
89
+ $value = '/\\' . ($index % 2 ? ']' : '[') . '/';
90
  }
91
 
92
  }
Application/Core/Object/LoginRedirect.php CHANGED
@@ -43,7 +43,7 @@ class AAM_Core_Object_LoginRedirect extends AAM_Core_Object {
43
  if (empty($option)) {
44
  //inherit from parent subject
45
  $option = $this->getSubject()->inheritFromParent('loginredirect');
46
- } elseif (method_exists($this, 'setOverwritten')) { //TODO - Support legacy
47
  $this->setOverwritten(true);
48
  }
49
 
43
  if (empty($option)) {
44
  //inherit from parent subject
45
  $option = $this->getSubject()->inheritFromParent('loginredirect');
46
+ } else {
47
  $this->setOverwritten(true);
48
  }
49
 
Application/Core/Object/LogoutRedirect.php CHANGED
@@ -43,7 +43,7 @@ class AAM_Core_Object_LogoutRedirect extends AAM_Core_Object {
43
  if (empty($option)) {
44
  //inherit from parent subject
45
  $option = $this->getSubject()->inheritFromParent('logoutredirect');
46
- } elseif (method_exists($this, 'setOverwritten')) { //TODO - Support legacy
47
  $this->setOverwritten(true);
48
  }
49
 
43
  if (empty($option)) {
44
  //inherit from parent subject
45
  $option = $this->getSubject()->inheritFromParent('logoutredirect');
46
+ } else {
47
  $this->setOverwritten(true);
48
  }
49
 
Application/Core/Object/Menu.php CHANGED
@@ -142,12 +142,12 @@ class AAM_Core_Object_Menu extends AAM_Core_Object {
142
  *
143
  * @access public
144
  */
145
- public function has($menu) {
146
  //decode URL in case of any special characters like &amp;
147
  $decoded = htmlspecialchars_decode($menu);
148
  $options = $this->getOption();
149
 
150
- return !empty($options[$decoded]);
151
  }
152
 
153
  /**
142
  *
143
  * @access public
144
  */
145
+ public function has($menu, $both = false) {
146
  //decode URL in case of any special characters like &amp;
147
  $decoded = htmlspecialchars_decode($menu);
148
  $options = $this->getOption();
149
 
150
+ return !empty($options[$decoded]) || ($both && !empty($options['menu-' . $decoded]));
151
  }
152
 
153
  /**
Application/Core/Object/Redirect.php CHANGED
@@ -49,7 +49,7 @@ class AAM_Core_Object_Redirect extends AAM_Core_Object {
49
  $this->readByArea('frontend', $option);
50
  $this->readByArea('backend', $option);
51
  }
52
- } elseif (method_exists($this, 'setOverwritten')) { //TODO - Support legacy
53
  $this->setOverwritten(true);
54
  }
55
 
49
  $this->readByArea('frontend', $option);
50
  $this->readByArea('backend', $option);
51
  }
52
+ } else {
53
  $this->setOverwritten(true);
54
  }
55
 
Application/Core/Object/Teaser.php DELETED
@@ -1,124 +0,0 @@
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
- * Teaser object
12
- *
13
- * @package AAM
14
- * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
- */
16
- class AAM_Core_Object_Teaser extends AAM_Core_Object {
17
-
18
- /**
19
- * Constructor
20
- *
21
- * @param AAM_Core_Subject $subject
22
- *
23
- * @return void
24
- *
25
- * @access public
26
- */
27
- public function __construct(AAM_Core_Subject $subject) {
28
- parent::__construct($subject);
29
-
30
- $this->read();
31
- }
32
-
33
- /**
34
- *
35
- * @return void
36
- *
37
- * @access public
38
- */
39
- public function read() {
40
- $option = $this->getSubject()->readOption('teaser');
41
-
42
- //inherit from default Administrator role
43
- if (empty($option)) {
44
- //inherit from parent subject
45
- $option = $this->getSubject()->inheritFromParent('teaser');
46
- if (empty($option)) {
47
- $option = array();
48
- $this->readByArea('frontend', $option);
49
- }
50
- } elseif (method_exists($this, 'setOverwritten')) { //TODO - Support legacy
51
- $this->setOverwritten(true);
52
- }
53
-
54
- $this->setOption($option);
55
- }
56
-
57
- /**
58
- *
59
- * @param type $area
60
- * @param type $option
61
- */
62
- protected function readByArea($area, &$option) {
63
- $message = AAM_Core_Config::get("{$area}.teaser.message");
64
- $excerpt = AAM_Core_Config::get("{$area}.teaser.excerpt");
65
- if ($message || $excerpt) {
66
- $option["{$area}.teaser.message"] = $message;
67
- $option["{$area}.teaser.excerpt"] = $excerpt;
68
- }
69
- }
70
-
71
- /**
72
- * Save options
73
- *
74
- * @param string $property
75
- * @param boolean $value
76
- *
77
- * @return boolean
78
- *
79
- * @access public
80
- */
81
- public function save($property, $value) {
82
- $option = $this->getOption();
83
- $option[$property] = $value;
84
-
85
- return $this->getSubject()->updateOption($option, 'teaser');
86
- }
87
-
88
- /**
89
- *
90
- * @return type
91
- */
92
- public function reset() {
93
- return $this->getSubject()->deleteOption('teaser');
94
- }
95
-
96
- /**
97
- *
98
- * @param string $param
99
- *
100
- * @return boolean
101
- *
102
- * @access public
103
- */
104
- public function has($param) {
105
- $option = $this->getOption();
106
-
107
- return isset($option[$param]);
108
- }
109
-
110
- /**
111
- *
112
- * @param string $param
113
- *
114
- * @return boolean
115
- *
116
- * @access public
117
- */
118
- public function get($param) {
119
- $option = $this->getOption();
120
-
121
- return !empty($option[$param]) ? $option[$param] : null;
122
- }
123
-
124
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Application/Core/Server.php CHANGED
@@ -22,11 +22,6 @@ final class AAM_Core_Server {
22
  */
23
  const SERVER_URL = 'https://aamplugin.com/api/v1';
24
 
25
- /**
26
- * Fallback endpoint
27
- */
28
- const FALLBACK_URL = 'http://rest.vasyltech.com/v1';
29
-
30
  /**
31
  * Fetch the extension list
32
  *
@@ -68,7 +63,7 @@ final class AAM_Core_Server {
68
  $response = self::send('/check', $params);
69
  $result = array();
70
 
71
- if (!is_wp_error($response)) {
72
  //WP Error Fix bug report
73
  if ($response->error !== true && !empty($response->products)) {
74
  $result = $response->products;
@@ -121,17 +116,13 @@ final class AAM_Core_Server {
121
  *
122
  * @access protected
123
  */
124
- protected static function send($request, $params, $timeout = 20) {
125
  $response = self::parseResponse(
126
- AAM_Core_API::cURL(self::SERVER_URL . $request, false, $params, $timeout)
 
 
127
  );
128
 
129
- if (empty($response) || is_wp_error($response)) {
130
- $response = self::parseResponse(
131
- AAM_Core_API::cURL(self::FALLBACK_URL . $request, false, $params, $timeout)
132
- );
133
- }
134
-
135
  return $response;
136
  }
137
 
22
  */
23
  const SERVER_URL = 'https://aamplugin.com/api/v1';
24
 
 
 
 
 
 
25
  /**
26
  * Fetch the extension list
27
  *
63
  $response = self::send('/check', $params);
64
  $result = array();
65
 
66
+ if (!is_wp_error($response) && is_object($response)) {
67
  //WP Error Fix bug report
68
  if ($response->error !== true && !empty($response->products)) {
69
  $result = $response->products;
116
  *
117
  * @access protected
118
  */
119
+ protected static function send($request, $params, $timeout = 10) {
120
  $response = self::parseResponse(
121
+ AAM_Core_API::cURL(
122
+ self::SERVER_URL . $request, false, $params, $timeout
123
+ )
124
  );
125
 
 
 
 
 
 
 
126
  return $response;
127
  }
128
 
Application/Core/Subject.php CHANGED
@@ -142,6 +142,22 @@ abstract class AAM_Core_Subject {
142
  public function getId() {
143
  return $this->_id;
144
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
  /**
147
  * Get Subject
142
  public function getId() {
143
  return $this->_id;
144
  }
145
+
146
+ /**
147
+ *
148
+ * @return type
149
+ */
150
+ public function getName() {
151
+ return null;
152
+ }
153
+
154
+ /**
155
+ *
156
+ * @return int
157
+ */
158
+ public function getMaxLevel() {
159
+ return 0;
160
+ }
161
 
162
  /**
163
  * Get Subject
Application/Core/Subject/Default.php CHANGED
@@ -70,6 +70,14 @@ class AAM_Core_Subject_Default extends AAM_Core_Subject {
70
  return self::UID;
71
  }
72
 
 
 
 
 
 
 
 
 
73
  /**
74
  *
75
  * @return type
70
  return self::UID;
71
  }
72
 
73
+ /**
74
+ *
75
+ * @return type
76
+ */
77
+ public function getName() {
78
+ return __('All Users, Roles and Visitor', AAM_KEY);
79
+ }
80
+
81
  /**
82
  *
83
  * @return type
Application/Core/Subject/Role.php CHANGED
@@ -186,4 +186,20 @@ class AAM_Core_Subject_Role extends AAM_Core_Subject {
186
  );
187
  }
188
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  }
186
  );
187
  }
188
 
189
+ /**
190
+ *
191
+ * @return type
192
+ */
193
+ public function getName() {
194
+ return $this->name;
195
+ }
196
+
197
+ /**
198
+ *
199
+ * @return type
200
+ */
201
+ public function getMaxLevel() {
202
+ return AAM_Core_API::maxLevel($this->capabilities);
203
+ }
204
+
205
  }
Application/Core/Subject/User.php CHANGED
@@ -35,6 +35,27 @@ class AAM_Core_Subject_User extends AAM_Core_Subject {
35
  */
36
  protected $parent = null;
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  /**
39
  * Block User
40
  *
@@ -196,7 +217,7 @@ class AAM_Core_Subject_User extends AAM_Core_Subject {
196
  $result = $this->deleteOption($object);
197
  }
198
 
199
- return result;
200
  }
201
 
202
  /**
@@ -293,5 +314,23 @@ class AAM_Core_Subject_User extends AAM_Core_Subject {
293
  public function getUID() {
294
  return self::UID;
295
  }
 
 
 
 
 
 
 
 
 
 
296
 
 
 
 
 
 
 
 
 
297
  }
35
  */
36
  protected $parent = null;
37
 
38
+ /**
39
+ *
40
+ * @param type $id
41
+ */
42
+ public function __construct($id) {
43
+ parent::__construct($id);
44
+
45
+ if (get_current_user_id() == $id) {
46
+ //check if user is locked
47
+ if ($this->user_status == 1) {
48
+ wp_logout();
49
+ }
50
+
51
+ //check if user's role expired
52
+ $expire = get_user_option('aam-role-expires');
53
+ if ($expire && ($expire <= time())) {
54
+ $this->restoreRoles();
55
+ }
56
+ }
57
+ }
58
+
59
  /**
60
  * Block User
61
  *
217
  $result = $this->deleteOption($object);
218
  }
219
 
220
+ return $result;
221
  }
222
 
223
  /**
314
  public function getUID() {
315
  return self::UID;
316
  }
317
+
318
+ /**
319
+ *
320
+ * @return type
321
+ */
322
+ public function getName() {
323
+ $display = $this->display_name;
324
+
325
+ return ($display ? $display : $this->user_nicename);
326
+ }
327
 
328
+ /**
329
+ *
330
+ * @return type
331
+ */
332
+ public function getMaxLevel() {
333
+ return AAM_Core_API::maxLevel($this->allcaps);
334
+ }
335
+
336
  }
Application/Core/Subject/Visitor.php CHANGED
@@ -71,4 +71,12 @@ class AAM_Core_Subject_Visitor extends AAM_Core_Subject {
71
  return AAM_Core_Subject_Default::getInstance();
72
  }
73
 
 
 
 
 
 
 
 
 
74
  }
71
  return AAM_Core_Subject_Default::getInstance();
72
  }
73
 
74
+ /**
75
+ *
76
+ * @return type
77
+ */
78
+ public function getName() {
79
+ return __('Anonymous', AAM_KEY);
80
+ }
81
+
82
  }
Application/Extension/List.php CHANGED
@@ -7,79 +7,87 @@
7
  * ======================================================================
8
  */
9
 
10
- return array(
11
- 'AAM_COMPLETE_PACKAGE' => array(
12
- 'title' => 'AAM Complete Package',
13
- 'id' => 'AAM_COMPLETE_PACKAGE',
14
- 'type' => 'commercial',
15
- 'description' => 'Get list of all available premium extensions in one package. Any additional premium extensions in the future will be available for free. Get complete package today and instantly save over 50%.',
16
- 'storeURL' => 'https://aamplugin.com/complete-package',
17
- 'version' => (defined('AAM_COMPLETE_PACKAGE') ? constant('AAM_COMPLETE_PACKAGE') : null)
18
- ),
19
- 'AAM_PLUS_PACKAGE' => array(
20
- 'title' => 'AAM Plus Package',
21
- 'id' => 'AAM_PLUS_PACKAGE',
22
- 'type' => 'commercial',
23
- 'description' => 'Our best selling extension that allows you to manage access to unlimited number of posts, pages, custom post types, categories, custom hierarchical taxonomies or define the default access to all.',
24
- 'storeURL' => 'https://aamplugin.com/extension/plus-package',
25
- 'version' => (defined('AAM_PLUS_PACKAGE') ? constant('AAM_PLUS_PACKAGE') : null)
26
- ),
27
- 'AAM_IP_CHECK' => array(
28
- 'title' => 'AAM IP Check',
29
- 'id' => 'AAM_IP_CHECK',
30
- 'type' => 'commercial',
31
- 'new' => true,
32
- 'description' => 'Manage access to your website based on a visitor geo-location, refered host or IP address.',
33
- 'storeURL' => 'https://aamplugin.com/extension/ip-check',
34
- 'version' => (defined('AAM_IP_CHECK') ? constant('AAM_IP_CHECK') : null)
35
- ),
36
- 'AAM_ROLE_HIERARCHY' => array(
37
- 'title' => 'AAM Role Hierarchy',
38
- 'id' => 'AAM_ROLE_HIERARCHY',
39
- 'type' => 'commercial',
40
- 'description' => 'Create complex role hierarchy and automatically inherit access settings from parent roles.',
41
- 'storeURL' => 'https://aamplugin.com/extension/role-hierarchy',
42
- 'version' => (defined('AAM_ROLE_HIERARCHY') ? constant('AAM_ROLE_HIERARCHY') : null)
43
- ),
44
- 'AAM_ROLE_FILTER' => array(
45
- 'title' => 'AAM Role Filter',
46
- 'id' => 'AAM_ROLE_FILTER',
47
- 'type' => 'commercial',
48
- 'description' => 'Based on user levels, restrict access to manage list of roles and users that have higher user level.',
49
- 'storeURL' => 'https://aamplugin.com/extension/role-filter',
50
- 'version' => (defined('AAM_ROLE_FILTER') ? constant('AAM_ROLE_FILTER') : null)
51
- ),
52
- 'AAM_PAYMENT' => array(
53
- 'title' => 'AAM Payment',
54
- 'id' => 'AAM_PAYMENT',
55
- 'type' => 'commercial',
56
- 'new' => true,
57
- 'description' => 'Start selling access to your posts, categories or user levels.',
58
- 'storeURL' => 'https://aamplugin.com/extension/payment',
59
- 'version' => (defined('AAM_PAYMENT') ? constant('AAM_PAYMENT') : null)
60
- ),
61
- 'AAM_MULTISITE' => array(
62
- 'title' => 'AAM Multisite',
63
- 'id' => 'AAM_MULTISITE',
64
- 'type' => 'GNU',
65
- 'license' => 'AAMMULTISITE',
66
- 'description' => 'Convenient way to navigate between different sites in the Network Admin Panel.',
67
- 'version' => (defined('AAM_MULTISITE') ? constant('AAM_MULTISITE') : null)
68
- ),
69
- 'AAM_CONFIGPRESS' => array(
70
- 'title' => 'AAM ConfigPress',
71
- 'id' => 'AAM_CONFIGPRESS',
72
- 'type' => 'GNU',
73
- 'license' => 'AAMCONFIGPRESS',
74
- 'description' => 'Extension to manage AAM core functionality with advanced configuration settings.',
75
- 'version' => (defined('AAM_CONFIGPRESS') ? constant('AAM_CONFIGPRESS') : null)
76
- ),
77
- 'AAM_USER_ACTIVITY' => array(
78
- 'title' => 'AAM User Activities',
79
- 'id' => 'AAM_USER_ACTIVITY',
80
- 'type' => 'GNU',
81
- 'license' => 'AAMUSERACTIVITY',
82
- 'description' => 'Track any kind of user or visitor activity on your website. <a href="https://aamplugin.com/help/how-to-track-any-wordpress-user-activity" target="_blank">Read more.</a>',
83
- 'version' => (defined('AAM_USER_ACTIVITY') ? constant('AAM_USER_ACTIVITY') : null)
84
- ),
85
- );
 
 
 
 
 
 
 
 
7
  * ======================================================================
8
  */
9
 
10
+ class AAM_Extension_List {
11
+
12
+ /**
13
+ *
14
+ * @return type
15
+ */
16
+ public static function get() {
17
+ return array(
18
+ 'AAM_COMPLETE_PACKAGE' => array(
19
+ 'title' => 'Complete Package',
20
+ 'id' => 'AAM_COMPLETE_PACKAGE',
21
+ 'type' => 'commercial',
22
+ 'description' => 'Get the complete list of all available premium extensions in one package. Any new premium extensions in the future will be available with updates for no additional cost.',
23
+ 'url' => 'https://aamplugin.com/complete-package',
24
+ 'version' => (defined('AAM_COMPLETE_PACKAGE') ? constant('AAM_COMPLETE_PACKAGE') : null)
25
+ ),
26
+ 'AAM_PLUS_PACKAGE' => array(
27
+ 'title' => 'Plus Package',
28
+ 'id' => 'AAM_PLUS_PACKAGE',
29
+ 'type' => 'commercial',
30
+ 'description' => 'The best selling extension that has the most advanced content management features for WordPress CMS. Manage accsss to any post, page, custom post type, category, custom hierarchical taxonomy or define the default access to all.',
31
+ 'url' => 'https://aamplugin.com/extension/plus-package',
32
+ 'version' => (defined('AAM_PLUS_PACKAGE') ? constant('AAM_PLUS_PACKAGE') : null)
33
+ ),
34
+ 'AAM_IP_CHECK' => array(
35
+ 'title' => 'IP Check',
36
+ 'id' => 'AAM_IP_CHECK',
37
+ 'type' => 'commercial',
38
+ 'description' => 'This extension was designed to manage access to your entire website based on visitor\'s geo-location, refered host or IP address.',
39
+ 'url' => 'https://aamplugin.com/extension/ip-check',
40
+ 'version' => (defined('AAM_IP_CHECK') ? constant('AAM_IP_CHECK') : null)
41
+ ),
42
+ 'AAM_ROLE_HIERARCHY' => array(
43
+ 'title' => 'Role Hierarchy',
44
+ 'id' => 'AAM_ROLE_HIERARCHY',
45
+ 'type' => 'commercial',
46
+ 'description' => 'This extension alters default WordPress linear role system and give you the ability to create complex role hierarchy tree where all access settings are automatically inherited from parent roles.',
47
+ 'url' => 'https://aamplugin.com/extension/role-hierarchy',
48
+ 'version' => (defined('AAM_ROLE_HIERARCHY') ? constant('AAM_ROLE_HIERARCHY') : null)
49
+ ),
50
+ 'AAM_ECOMMERCE' => array(
51
+ 'title' => 'E-Commerce',
52
+ 'id' => 'AAM_ECOMMERCE',
53
+ 'type' => 'commercial',
54
+ 'new' => true,
55
+ 'description' => 'Start selling access to your website content. This extension gives ability to define the list of E-Commerce products that you can bind with any content on your website. The properly configured AAM Payment widget allows any authenticated user to purchase access with credit/debig card or PayPal. Braintree and Stripe gateways are used to handle actual purchase.',
56
+ 'url' => 'https://aamplugin.com/extension/ecommerce',
57
+ 'version' => (defined('AAM_ECOMMERCE') ? constant('AAM_ECOMMERCE') : null)
58
+ ),
59
+ 'AAM_PAYMENT' => array(
60
+ 'title' => 'Payment',
61
+ 'id' => 'AAM_PAYMENT',
62
+ 'type' => 'commercial',
63
+ 'description' => AAM_Backend_View_Helper::preparePhrase('[Deprecated!]. The extension is deprecated and replaces with more sophisticated E-Commerce extension. If you already purchased it, please contact us to upgrade your license for no additional cost.', 'b'),
64
+ 'url' => 'https://aamplugin.com/extension/ecommerce',
65
+ 'version' => (defined('AAM_PAYMENT') ? constant('AAM_PAYMENT') : null)
66
+ ),
67
+ 'AAM_MULTISITE' => array(
68
+ 'title' => 'Multisite',
69
+ 'id' => 'AAM_MULTISITE',
70
+ 'type' => 'GNU',
71
+ 'license' => 'AAMMULTISITE',
72
+ 'description' => 'Convenient way to navigate between different sites in the Network Admin Panel.',
73
+ 'version' => (defined('AAM_MULTISITE') ? constant('AAM_MULTISITE') : null)
74
+ ),
75
+ 'AAM_CONFIGPRESS' => array(
76
+ 'title' => 'ConfigPress',
77
+ 'id' => 'AAM_CONFIGPRESS',
78
+ 'type' => 'GNU',
79
+ 'license' => 'AAMCONFIGPRESS',
80
+ 'description' => 'Extension to manage AAM core functionality with advanced configuration settings.',
81
+ 'version' => (defined('AAM_CONFIGPRESS') ? constant('AAM_CONFIGPRESS') : null)
82
+ ),
83
+ 'AAM_USER_ACTIVITY' => array(
84
+ 'title' => 'User Activities',
85
+ 'id' => 'AAM_USER_ACTIVITY',
86
+ 'type' => 'GNU',
87
+ 'license' => 'AAMUSERACTIVITY',
88
+ 'description' => 'Track any kind of user or visitor activity on your website. <a href="https://aamplugin.com/help/how-to-track-any-wordpress-user-activity" target="_blank">Read more.</a>',
89
+ 'version' => (defined('AAM_USER_ACTIVITY') ? constant('AAM_USER_ACTIVITY') : null)
90
+ ),
91
+ );
92
+ }
93
+ }
Application/Extension/Repository.php CHANGED
@@ -72,24 +72,6 @@ class AAM_Extension_Repository {
72
  */
73
  protected function __construct() {}
74
 
75
- /**
76
- * Get single instance of itself
77
- *
78
- * @param AAM $parent
79
- *
80
- * @return AAM_Extension_Repository
81
- *
82
- * @access public
83
- * @static
84
- */
85
- public static function getInstance() {
86
- if (is_null(self::$_instance)) {
87
- self::$_instance = new self;
88
- }
89
-
90
- return self::$_instance;
91
- }
92
-
93
  /**
94
  * Load active extensions
95
  *
@@ -127,9 +109,30 @@ class AAM_Extension_Repository {
127
  * @access protected
128
  */
129
  protected function bootstrapExtension($path) {
 
 
 
 
 
 
 
 
130
  $bootstrap = "{$path}/bootstrap.php";
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
- if (file_exists($bootstrap)) { //bootstrap the extension
133
  require($bootstrap);
134
  }
135
  }
@@ -183,6 +186,22 @@ class AAM_Extension_Repository {
183
  return $result;
184
  }
185
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  /**
187
  * Get extension version
188
  *
@@ -205,18 +224,14 @@ class AAM_Extension_Repository {
205
  */
206
  public function getList() {
207
  if (empty($this->list)) {
208
- $list = require dirname(__FILE__) . '/List.php';
209
  $index = AAM_Core_Compatibility::getLicenseList();
210
  $check = AAM_Core_API::getOption('aam-check', array(), 'site');
211
 
212
  foreach ($list as $id => &$item) {
213
  //get premium license from the stored license index
214
  if (empty($item['license'])) {
215
- // TODO - Fix bug with EXTENDED license
216
- if (!empty($index[$id . '_EXTENDED']['license'])) {
217
- $item['license'] = $index[$id . '_EXTENDED']['license'];
218
- $item['expire'] = (isset($index[$id . '_EXTENDED']['expire']) ? date('Y-m-d', strtotime($index[$id . '_EXTENDED']['expire'])) : null);
219
- } elseif (!empty($index[$id]['license'])) {
220
  $item['license'] = $index[$id]['license'];
221
  $item['expire'] = (isset($index[$id]['expire']) ? date('Y-m-d', strtotime($index[$id]['expire'])) : null);
222
  } else {
@@ -225,7 +240,7 @@ class AAM_Extension_Repository {
225
  }
226
 
227
  //update extension status
228
- $item['status'] = $this->checkStatus($item, $check);
229
  }
230
 
231
  $this->list = $list;
@@ -240,23 +255,32 @@ class AAM_Extension_Repository {
240
  * @param type $index
241
  * @return type
242
  */
243
- protected function checkStatus($item, $index) {
244
- $id = $item['id'];
245
- $status = AAM_Extension_Repository::STATUS_INSTALLED;
246
-
247
- if ($item['type'] == 'commercial') {
248
- $valid = !empty($item['license']);
249
- } else {
250
- $valid = true;
251
- }
252
 
253
- if (defined($id)) { //extension is installed
254
- if ($valid && isset($index->$id)
255
- && version_compare(constant($id), $index->$id->version) == -1) {
 
 
 
 
 
 
 
 
 
 
256
  $status = AAM_Extension_Repository::STATUS_UPDATE;
 
 
 
 
 
 
257
  }
258
  } else {
259
- $status = AAM_Extension_Repository::STATUS_DOWNLOAD;
260
  }
261
 
262
  return $status;
@@ -296,7 +320,46 @@ class AAM_Extension_Repository {
296
  * @access public
297
  */
298
  public function getBasedir() {
299
- return AAM_Core_Config::get('extention.directory', AAM_EXTENSION_BASE);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
  }
301
 
302
  }
72
  */
73
  protected function __construct() {}
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  /**
76
  * Load active extensions
77
  *
109
  * @access protected
110
  */
111
  protected function bootstrapExtension($path) {
112
+ static $cache = null;
113
+
114
+ if (is_null($cache)) {
115
+ $cache = AAM_Core_Compatibility::getLicenseList();
116
+ }
117
+
118
+ $load = true;
119
+ $config = "{$path}/config.php";
120
  $bootstrap = "{$path}/bootstrap.php";
121
+
122
+ if (file_exists($config)) {
123
+ $conf = require $config;
124
+ $load = empty($cache[$conf['id']]['status']) || ($cache[$conf['id']]['status'] != self::STATUS_INACTIVE);
125
+ } else { // TODO - Remove May 2018
126
+ AAM_Core_Console::add(AAM_Backend_View_Helper::preparePhrase(
127
+ sprintf(
128
+ __('The [%s] file is missing. Update all your extensions to the latest version.', AAM_KEY),
129
+ str_replace(AAM_EXTENSION_BASE . '/', '', $config)
130
+ ),
131
+ 'b'
132
+ ));
133
+ }
134
 
135
+ if ($load && file_exists($bootstrap)) { //bootstrap the extension
136
  require($bootstrap);
137
  }
138
  }
186
  return $result;
187
  }
188
 
189
+ /**
190
+ * Update extension status
191
+ *
192
+ * @param string $id
193
+ * @param string $status
194
+ */
195
+ public function updateStatus($id, $status) {
196
+ //retrieve the installed list of extensions
197
+ $list = AAM_Core_Compatibility::getLicenseList();
198
+
199
+ $list[$id]['status'] = $status;
200
+
201
+ //update the extension list
202
+ AAM_Core_API::updateOption('aam-extensions', $list);
203
+ }
204
+
205
  /**
206
  * Get extension version
207
  *
224
  */
225
  public function getList() {
226
  if (empty($this->list)) {
227
+ $list = AAM_Extension_List::get();
228
  $index = AAM_Core_Compatibility::getLicenseList();
229
  $check = AAM_Core_API::getOption('aam-check', array(), 'site');
230
 
231
  foreach ($list as $id => &$item) {
232
  //get premium license from the stored license index
233
  if (empty($item['license'])) {
234
+ if (!empty($index[$id]['license'])) {
 
 
 
 
235
  $item['license'] = $index[$id]['license'];
236
  $item['expire'] = (isset($index[$id]['expire']) ? date('Y-m-d', strtotime($index[$id]['expire'])) : null);
237
  } else {
240
  }
241
 
242
  //update extension status
243
+ $item['status'] = $this->checkStatus($item, $check, $index);
244
  }
245
 
246
  $this->list = $list;
255
  * @param type $index
256
  * @return type
257
  */
258
+ protected function checkStatus($item, $retrieved, $stored) {
259
+ $id = $item['id'];
 
 
 
 
 
 
 
260
 
261
+ if (!defined($id)) {
262
+ $status = AAM_Extension_Repository::STATUS_DOWNLOAD;
263
+ } elseif (empty($stored[$id]['status'])) {
264
+ $status = AAM_Extension_Repository::STATUS_INSTALLED;
265
+
266
+ if ($item['type'] == 'commercial') {
267
+ $valid = !empty($item['license']);
268
+ } else {
269
+ $valid = true;
270
+ }
271
+
272
+ if ($valid && isset($retrieved->$id)
273
+ && version_compare(constant($id), $retrieved->$id->version) == -1) {
274
  $status = AAM_Extension_Repository::STATUS_UPDATE;
275
+ AAM_Core_Console::add(
276
+ AAM_Backend_View_Helper::preparePhrase(sprintf(
277
+ 'The [%s] extension has new update available for download;',
278
+ $item['title']
279
+ ), 'b')
280
+ );
281
  }
282
  } else {
283
+ $status = $stored[$id]['status'];
284
  }
285
 
286
  return $status;
320
  * @access public
321
  */
322
  public function getBasedir() {
323
+ $dirname = AAM_Core_Config::get('extention.directory', AAM_EXTENSION_BASE);
324
+
325
+ if (file_exists($dirname) === false) {
326
+ @mkdir($dirname, fileperms( ABSPATH ) & 0777 | 0755);
327
+ }
328
+
329
+ return $dirname;
330
+ }
331
+
332
+ /**
333
+ * Check if there are any updates
334
+ *
335
+ * @return type
336
+ */
337
+ public function hasUpdates() {
338
+ $updates = 0;
339
+
340
+ foreach($this->getList() as $item) {
341
+ $updates += ($item['status'] == self::STATUS_UPDATE);
342
+ }
343
+
344
+ return $updates ? true : false;
345
+ }
346
+
347
+ /**
348
+ * Get single instance of itself
349
+ *
350
+ * @param AAM $parent
351
+ *
352
+ * @return AAM_Extension_Repository
353
+ *
354
+ * @access public
355
+ * @static
356
+ */
357
+ public static function getInstance() {
358
+ if (is_null(self::$_instance)) {
359
+ self::$_instance = new self;
360
+ }
361
+
362
+ return self::$_instance;
363
  }
364
 
365
  }
Application/Frontend/Authorization.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * AAM frontend authorization
12
+ *
13
+ * @package AAM
14
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
+ */
16
+ class AAM_Frontend_Authorization {
17
+
18
+ /**
19
+ * Instance of itself
20
+ *
21
+ * @var AAM_Frontend_Authorization
22
+ *
23
+ * @access private
24
+ */
25
+ private static $_instance = null;
26
+
27
+ /**
28
+ * Check post access
29
+ *
30
+ * Based on the provided post object, check if current user has access to it.
31
+ * This method run multiple checks at-once
32
+ *
33
+ * @param AAM_Core_Object_Post $post
34
+ *
35
+ * @return void
36
+ *
37
+ * @access public
38
+ */
39
+ public function post(AAM_Core_Object_Post $post) {
40
+ // pre post access hook
41
+ do_action('aam-pre-post-authorization-action', $post);
42
+
43
+ // Step #1. Check if access expired to the post
44
+ $this->checkExpiration($post);
45
+
46
+ // Step #2. Check if user has access to read the post
47
+ $this->checkReadAccess($post);
48
+
49
+ // Step #3. Check if counter exceeded max allowed views
50
+ $this->checkCounter($post);
51
+
52
+ // Step #4. Check if redirect is defined for the post
53
+ $this->checkRedirect($post);
54
+
55
+ // post post access hook
56
+ do_action('aam-post-post-authorization-action', $post);
57
+ }
58
+
59
+ /**
60
+ * Check ACCESS_EXPIRATION option
61
+ *
62
+ * If access is expired, override the access settings based on the
63
+ * post.access.expired ConfigPress settings (default frontend.read)
64
+ *
65
+ * @param AAM_Core_Object_Post $post
66
+ *
67
+ * @return void
68
+ *
69
+ * @access protected
70
+ */
71
+ protected function checkExpiration($post) {
72
+ $expire = $post->has('frontend.expire');
73
+
74
+ if ($expire) {
75
+ $date = strtotime($post->get('frontend.expire_datetime'));
76
+ if ($date <= time()) {
77
+ $actions = AAM_Core_Config::get(
78
+ 'post.access.expired', 'frontend.read'
79
+ );
80
+
81
+ foreach(array_map('trim', explode(',', $actions)) as $action) {
82
+ $post->set($action, 1);
83
+ }
84
+ }
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Check READ & READ_OTHERS options
90
+ *
91
+ * @param AAM_Core_Object_Post $post
92
+ *
93
+ * @return void
94
+ *
95
+ * @access protected
96
+ */
97
+ protected function checkReadAccess(AAM_Core_Object_Post $post) {
98
+ $read = $post->has('frontend.read');
99
+ $others = $post->has('frontend.read_others');
100
+
101
+ if ($read || ($others && ($post->post_author != get_current_user_id()))) {
102
+ $this->deny('post_read', 'frontend.read', $post->getPost());
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Check ACCESS_COUNTER option
108
+ *
109
+ * @param AAM_Core_Object_Post $post
110
+ *
111
+ * @return void
112
+ *
113
+ * @access protected
114
+ */
115
+ protected function checkCounter(AAM_Core_Object_Post $post) {
116
+ $user = get_current_user_id();
117
+
118
+ //check counter only for authenticated users and if ACCESS COUNTER is set
119
+ if ($user && $post->has('frontend.access_counter')) {
120
+ $counter = intval(get_user_meta(
121
+ $user, 'aam-post-' . $post->ID . '-access-counter', true
122
+ ));
123
+
124
+ if ($counter >= $post->get('frontend.access_counter_limit')) {
125
+ $this->deny('post_read', 'frontend.access_counter', $post->getPost());
126
+ } else {
127
+ update_user_meta(
128
+ $user, 'aam-post-' . $post->ID . '-access-counter', ++$counter
129
+ );
130
+ }
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Check REDIRECT option
136
+ *
137
+ * @param AAM_Core_Object_Post $post
138
+ *
139
+ * @return void
140
+ *
141
+ * @access protected
142
+ */
143
+ protected function checkRedirect(AAM_Core_Object_Post $post) {
144
+ if ($post->has('frontend.redirect')) {
145
+ AAM_Core_API::redirect($post->get('frontend.location'));
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Deny access
151
+ *
152
+ * @param string $hook
153
+ * @param string $action
154
+ * @param WP_Post $post
155
+ *
156
+ * @return void
157
+ *
158
+ * @access protected
159
+ */
160
+ protected function deny($hook, $action, $post) {
161
+ AAM_Core_API::reject('frontend', array(
162
+ 'hook' => $hook, 'action' => $action, 'post' => $post
163
+ ));
164
+ }
165
+
166
+ /**
167
+ * Alias for the bootstrap
168
+ *
169
+ * @return AAM_Frontend_Authorization
170
+ *
171
+ * @access public
172
+ * @static
173
+ */
174
+ public static function getInstance() {
175
+ return self::bootstrap();
176
+ }
177
+
178
+ /**
179
+ * Bootstrap authorization layer
180
+ *
181
+ * @return void
182
+ *
183
+ * @access public
184
+ */
185
+ public static function bootstrap() {
186
+ if (is_null(self::$_instance)) {
187
+ self::$_instance = new self;
188
+ }
189
+
190
+ return self::$_instance;
191
+ }
192
+
193
+ }
Application/Frontend/Filter.php ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * AAM frontend filter
12
+ *
13
+ * @package AAM
14
+ * @author Vasyl Martyniuk <vasyl@vasyltech.com>
15
+ */
16
+ class AAM_Frontend_Filter {
17
+
18
+ /**
19
+ * Instance of itself
20
+ *
21
+ * @var AAM_Frontend_Filter
22
+ *
23
+ * @access private
24
+ */
25
+ private static $_instance = null;
26
+
27
+ /**
28
+ * Constructor
29
+ *
30
+ * @return void
31
+ *
32
+ * @access protected
33
+ */
34
+ protected function __construct() {
35
+ //bootstrap authorization layer
36
+ AAM_Frontend_Authorization::bootstrap();
37
+
38
+ //manage access to frontend posts & pages
39
+ add_action('wp', array($this, 'wp'), 999);
40
+ add_action('404_template', array($this, 'themeRedirect'), 999);
41
+
42
+ //important to keep this option optional for optimization reasons
43
+ if (AAM_Core_Config::get('check-post-visibility', true)) {
44
+ //filter navigation pages & taxonomies
45
+ add_filter('get_pages', array($this, 'filterPostList'), 999);
46
+ add_filter('wp_get_nav_menu_items', array($this, 'getNavigationMenu'), 999);
47
+
48
+ //add post filter for LIST restriction
49
+ add_filter('the_posts', array($this, 'filterPostList'), 999);
50
+ add_action('pre_get_posts', array($this, 'preparePostQuery'), 999);
51
+ }
52
+
53
+ //password protected filter
54
+ add_filter('post_password_required', array($this, 'isPassProtected'), 10, 2);
55
+ //manage password check expiration
56
+ add_filter('post_password_expires', array($this, 'checkPassExpiration'));
57
+
58
+ //widget filters
59
+ add_filter('sidebars_widgets', array($this, 'filterWidgets'), 999);
60
+
61
+ //get control over commenting stuff
62
+ add_filter('comments_open', array($this, 'commentOpen'), 10, 2);
63
+
64
+ //filter post content
65
+ add_filter('the_content', array($this, 'filterPostContent'), 999);
66
+ }
67
+
68
+ /**
69
+ * Main frontend access control hook
70
+ *
71
+ * @return void
72
+ *
73
+ * @access public
74
+ * @global WP_Post $post
75
+ */
76
+ public function wp() {
77
+ global $wp_query;
78
+
79
+ if ($wp_query->is_404) { // Handle 404 redirect
80
+ $type = AAM_Core_Config::get('frontend.404redirect.type', 'default');
81
+ do_action('aam-rejected-action', 'frontend', array(
82
+ 'hook' => 'aam_404',
83
+ 'uri' => AAM_Core_Request::server('REQUEST_URI')
84
+ ));
85
+
86
+ if ($type != 'default') {
87
+ AAM_Core_API::redirect(
88
+ AAM_Core_Config::get("frontend.404redirect.{$type}")
89
+ );
90
+ }
91
+ } elseif ($wp_query->is_single || $wp_query->is_page
92
+ || $wp_query->is_posts_page || $wp_query->is_home) {
93
+ $post = AAM_Core_API::getCurrentPost();
94
+
95
+ if ($post) {
96
+ AAM_Frontend_Authorization::getInstance()->post($post);
97
+ }
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Theme redirect
103
+ *
104
+ * Super important function that cover the 404 redirect that triggered by theme
105
+ * when page is not found. This covers the scenario when page is restricted from
106
+ * listing and read.
107
+ *
108
+ * @global type $wp_query
109
+ *
110
+ * @param type $template
111
+ *
112
+ * @return string
113
+ *
114
+ * @access public
115
+ */
116
+ public function themeRedirect($template) {
117
+ $post = AAM_Core_API::getCurrentPost();
118
+
119
+ if ($post) {
120
+ AAM_Frontend_Authorization::getInstance()->post($post);
121
+ }
122
+
123
+ return $template;
124
+ }
125
+
126
+ /**
127
+ * Filter posts from the list
128
+ *
129
+ * @param array $posts
130
+ *
131
+ * @return array
132
+ *
133
+ * @access public
134
+ */
135
+ public function filterPostList($posts) {
136
+ $current = AAM_Core_API::getCurrentPost();
137
+
138
+ if (is_array($posts) && !$this->isMainWP()) {
139
+ foreach ($posts as $i => $post) {
140
+ if ($current && ($current->ID == $post->ID)) { continue; }
141
+
142
+ if (AAM_Core_API::isHiddenPost($post, $post->post_type)) {
143
+ unset($posts[$i]);
144
+ }
145
+ }
146
+
147
+ $posts = array_values($posts);
148
+ }
149
+
150
+ return $posts;
151
+ }
152
+
153
+ /**
154
+ * Filter Navigation menu
155
+ *
156
+ * @param array $pages
157
+ *
158
+ * @return array
159
+ *
160
+ * @access public
161
+ */
162
+ public function getNavigationMenu($pages) {
163
+ if (is_array($pages)) {
164
+ foreach ($pages as $i => $page) {
165
+ if (in_array($page->type, array('post_type', 'custom'))) {
166
+ $post = get_post($page->object_id);
167
+ if (AAM_Core_API::isHiddenPost($post, $post->post_type)) {
168
+ unset($pages[$i]);
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ return $pages;
175
+ }
176
+
177
+ /**
178
+ * Build pre-post query request
179
+ *
180
+ * This is used to solve the problem or pagination
181
+ *
182
+ * @param stdClass $query
183
+ *
184
+ * @return void
185
+ *
186
+ * @access public
187
+ */
188
+ public function preparePostQuery($query) {
189
+ static $skip = false;
190
+
191
+ if (($skip === false) && $this->isMainWP()) { // avoid loop
192
+ $skip = true;
193
+ $filtered = AAM_Core_API::getFilteredPostList($query);
194
+ $skip = false;
195
+
196
+ if (isset($query->query_vars['post__not_in'])
197
+ && is_array($query->query_vars['post__not_in'])) {
198
+ $query->query_vars['post__not_in'] = array_merge(
199
+ $query->query_vars['post__not_in'], $filtered
200
+ );
201
+ } else {
202
+ $query->query_vars['post__not_in'] = $filtered;
203
+ }
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Check if post is password protected
209
+ *
210
+ * @param boolean $res
211
+ * @param WP_Post $post
212
+ *
213
+ * @return boolean
214
+ *
215
+ * @access public
216
+ */
217
+ public function isPassProtected($res, $post) {
218
+ if (is_a($post, 'WP_Post')) {
219
+ $object = AAM::getUser()->getObject('post', $post->ID);
220
+
221
+ if ($object->has('frontend.protected')) {
222
+ require_once( ABSPATH . 'wp-includes/class-phpass.php' );
223
+ $hasher = new PasswordHash( 8, true );
224
+ $pass = $object->get('frontend.password');
225
+ $hash = wp_unslash(
226
+ AAM_Core_Request::cookie('wp-postpass_' . COOKIEHASH)
227
+ );
228
+
229
+ $res = empty($hash) ? true : !$hasher->CheckPassword($pass, $hash);
230
+ }
231
+ }
232
+
233
+ return $res;
234
+ }
235
+
236
+ /**
237
+ * Get password expiration TTL
238
+ *
239
+ * @param int $expire
240
+ *
241
+ * @return int
242
+ *
243
+ * @access public
244
+ */
245
+ public function checkPassExpiration($expire) {
246
+ $overwrite = AAM_Core_Config::get('post.password.expires', null);
247
+
248
+ if ($overwrite !== null) {
249
+ $expire = ($overwrite ? time() + strtotime($overwrite) : 0);
250
+ }
251
+
252
+ return $expire;
253
+ }
254
+
255
+ /**
256
+ * Filter frontend widgets
257
+ *
258
+ * @param array $widgets
259
+ *
260
+ * @return array
261
+ *
262
+ * @access public
263
+ */
264
+ public function filterWidgets($widgets) {
265
+ return AAM::getUser()->getObject('metabox')->filterFrontend($widgets);
266
+ }
267
+
268
+ /**
269
+ * Control frontend commenting feature
270
+ *
271
+ * @param boolean $open
272
+ * @param int $post_id
273
+ *
274
+ * @return boolean
275
+ *
276
+ * @access public
277
+ */
278
+ public function commentOpen($open, $post_id) {
279
+ $object = AAM::getUser()->getObject('post', $post_id);
280
+
281
+ return ($object->has('frontend.comment') ? false : $open);
282
+ }
283
+
284
+ /**
285
+ * Filter post content
286
+ *
287
+ * @param string $content
288
+ *
289
+ * @return string
290
+ *
291
+ * @access public
292
+ * @global WP_Post $post
293
+ */
294
+ public function filterPostContent($content) {
295
+ $post = AAM_Core_API::getCurrentPost();
296
+
297
+ if ($post && $post->has('frontend.limit')) {
298
+ if ($post->has('frontend.teaser')) {
299
+ $message = $post->get('frontend.teaser');
300
+ } else {
301
+ $message = __('[No teaser message provided]', AAM_KEY);
302
+ }
303
+
304
+ $content = do_shortcode(stripslashes($message));
305
+ }
306
+
307
+ return $content;
308
+ }
309
+
310
+ /**
311
+ * Check if request comes from wp()
312
+ *
313
+ * Super important method is used to solve the problem with hidden posts
314
+ *
315
+ * @return boolean
316
+ *
317
+ * @access protected
318
+ */
319
+ protected function isMainWP() {
320
+ $result = false;
321
+
322
+ foreach(debug_backtrace() as $level) {
323
+ $class = (isset($level['class']) ? $level['class'] : null);
324
+ $func = (isset($level['function']) ? $level['function'] : null);
325
+
326
+ if ($class == 'WP' && $func == 'main') {
327
+ $result = true;
328
+ break;
329
+ }
330
+ }
331
+
332
+ return $result;
333
+ }
334
+
335
+ /**
336
+ * Register backend filters and actions
337
+ *
338
+ * @return void
339
+ *
340
+ * @access public
341
+ */
342
+ public static function register() {
343
+ if (is_null(self::$_instance)) {
344
+ self::$_instance = new self;
345
+ }
346
+ }
347
+
348
+ }
Application/Frontend/Manager.php CHANGED
@@ -24,11 +24,6 @@ class AAM_Frontend_Manager {
24
  */
25
  private static $_instance = null;
26
 
27
- /**
28
- * pre_get_posts flag
29
- */
30
- protected $skip = false;
31
-
32
  /**
33
  * Construct the manager
34
  *
@@ -38,359 +33,36 @@ class AAM_Frontend_Manager {
38
  */
39
  public function __construct() {
40
  if (AAM_Core_Config::get('frontend-access-control', true)) {
41
- //control WordPress frontend
42
- add_action('wp', array($this, 'wp'), 999);
43
- add_action('404_template', array($this, 'themeRedirect'), 999);
44
-
45
- //support login widget
46
- add_action('wp_enqueue_scripts', array($this, 'printJavascript'));
47
-
48
- if (AAM_Core_Config::get('check-post-visibility', true)) {
49
- //filter navigation pages & taxonomies
50
- add_filter('get_pages', array($this, 'thePosts'), 999);
51
- add_filter('wp_get_nav_menu_items', array($this, 'getNavigationMenu'), 999);
52
-
53
- //add post filter for LIST restriction
54
- add_filter('the_posts', array($this, 'thePosts'), 999, 2);
55
- add_action('pre_get_posts', array($this, 'preparePostQuery'), 999);
56
- }
57
-
58
- //widget filters
59
- add_filter('sidebars_widgets', array($this, 'widgetFilter'), 999);
60
- //get control over commenting stuff
61
- add_filter('comments_open', array($this, 'commentOpen'), 10, 2);
62
-
63
- //password protected filter
64
- add_filter('post_password_required', array($this, 'isProtected'), 10, 2);
65
-
66
- //filter post content
67
- add_filter('the_content', array($this, 'theContent'), 999);
68
-
69
- //manage AAM shortcode
70
- add_shortcode('aam', array($this, 'processShortcode'));
71
-
72
- //core AAM filter
73
- add_filter('aam-object-filter', array($this, 'getObject'), 10, 4);
74
-
75
- //manage password check expiration
76
- add_filter('post_password_expires', array($this, 'postPasswordExpires'));
77
-
78
- //admin bar
79
- $this->checkAdminBar();
80
  }
81
 
82
- //register login widget
83
- add_action('widgets_init', array($this, 'registerLoginWidget'));
84
-
85
- if (AAM_Core_Request::get('action') == 'aam-auth') {
86
- $this->doubleAuthentication();
87
- }
88
- }
89
-
90
- /**
91
- *
92
- * @param type $expire
93
- * @return type
94
- */
95
- public function postPasswordExpires($expire) {
96
- $overwrite = AAM_Core_Config::get('post.password.expires', null);
97
 
98
- if ($overwrite !== null) {
99
- $expire = ($overwrite ? time() + strtotime($overwrite) : 0);
100
- }
101
 
102
- return $expire;
103
- }
104
-
105
- /**
106
- *
107
- */
108
- public function registerLoginWidget() {
109
- register_widget('AAM_Backend_Widget_Login');
110
- }
111
-
112
- /**
113
- * Print javascript libraries
114
- *
115
- * @return void
116
- *
117
- * @access public
118
- */
119
- public function printJavascript() {
120
- wp_enqueue_script('aam-login', AAM_MEDIA . '/js/aam-login.js');
121
-
122
- //add plugin localization
123
- $locals = array(
124
- 'nonce' => wp_create_nonce('aam_ajax'),
125
- 'ajaxurl' => admin_url('admin-ajax.php')
126
- );
127
-
128
- wp_localize_script('aam-login', 'aamLocal', $locals);
129
- }
130
-
131
- /**
132
- *
133
- * @param type $object
134
- * @param type $type
135
- * @param type $id
136
- * @param type $subject
137
- * @return type
138
- */
139
- public function getObject($object, $type, $id, $subject) {
140
- if (is_a($object, 'AAM_Core_Object_Post')) {
141
- $expire = $object->has('frontend.expire');
142
- $date = strtotime($object->get('frontend.expire_datetime'));
143
-
144
- if ($expire && ($date <= time())) {
145
- $actions = AAM_Core_Config::get('post.access.expire.action', 'read');
146
-
147
- $object->set('frontend.expire', 0);
148
-
149
- foreach(array_map('trim', explode(',', $actions)) as $action) {
150
- $object->set('frontend.' . $action, 1);
151
- }
152
- }
153
- }
154
-
155
- return $object;
156
- }
157
-
158
- /**
159
- *
160
- * @param type $response
161
- * @param WP_Post $post
162
- * @return type
163
- */
164
- public function isProtected($response, $post) {
165
- if (is_a($post, 'WP_Post')) {
166
- $object = AAM::getUser()->getObject('post', $post->ID);
167
-
168
- if ($object->has('frontend.protected')) {
169
- require_once( ABSPATH . 'wp-includes/class-phpass.php' );
170
- $hasher = new PasswordHash( 8, true );
171
- $hash = wp_unslash(AAM_Core_Request::cookie('wp-postpass_' . COOKIEHASH));
172
-
173
- if (empty($hash)) {
174
- $response = true;
175
- } else {
176
- $response = !$hasher->CheckPassword(
177
- $object->get('frontend.password'), $hash
178
- );
179
- }
180
- }
181
- }
182
-
183
- return $response;
184
- }
185
-
186
- /**
187
- * Main frontend access control hook
188
- *
189
- * @return void
190
- *
191
- * @access public
192
- * @global WP_Post $post
193
- */
194
- public function wp() {
195
- global $wp_query;
196
-
197
- if ($wp_query->is_404) {
198
- $type = AAM_Core_Config::get('frontend.404redirect.type', 'default');
199
- do_action('aam-rejected-action', 'frontend', array(
200
- 'hook' => 'aam_404',
201
- 'uri' => AAM_Core_Request::server('REQUEST_URI')
202
- ));
203
-
204
- if ($type != 'default') {
205
- AAM_Core_API::redirect(
206
- AAM_Core_Config::get("frontend.404redirect.{$type}")
207
- );
208
- }
209
- } elseif ($wp_query->is_single || $wp_query->is_page
210
- || $wp_query->is_posts_page || $wp_query->is_home) {
211
- $post = $this->getCurrentPost();
212
-
213
- if (is_a($post, 'WP_Post')) {
214
- $this->checkPostReadAccess($post);
215
- }
216
  }
217
  }
218
 
219
  /**
220
- * Theme redirect
221
  *
222
- * Super important function that cover the 404 redirect that triggered by theme
223
- * when page is not found. This covers the scenario when page is restricted from
224
- * listing and read.
225
- *
226
- * @global type $wp_query
227
- *
228
- * @param type $template
229
  *
230
  * @return string
231
  *
232
  * @access public
233
  */
234
- public function themeRedirect($template) {
235
- global $wp_query;
236
-
237
- $object = (isset($wp_query->queried_object) ? $wp_query->queried_object : 0);
238
- if ($object && is_a($object, 'WP_Post')) {
239
- $this->checkPostReadAccess($object);
240
- }
241
-
242
- return $template;
243
- }
244
-
245
- /**
246
- *
247
- * @global type $wp_query
248
- * @return type
249
- */
250
- protected function getCurrentPost() {
251
- global $wp_query, $post;
252
-
253
- $current = null;
254
-
255
- if (!empty($wp_query->queried_object)) {
256
- $current = $wp_query->queried_object;
257
- } elseif (!empty($wp_query->post)) {
258
- $current = $wp_query->post;
259
- } elseif (!empty($wp_query->query['name']) && !empty($wp_query->posts)) {
260
- //Important! Cover the scenario of NOT LIST but ALLOW READ
261
- foreach($wp_query->posts as $post) {
262
- if ($post->post_name == $wp_query->query['name']) {
263
- $current = $post;
264
- break;
265
- }
266
- }
267
- }
268
-
269
- return (is_a($current, 'WP_Post') ? $current : null);
270
- }
271
-
272
- /**
273
- * Check post read access
274
- *
275
- * @param WP_Post $post
276
- *
277
- * @return void
278
- *
279
- * @access protected
280
- */
281
- protected function checkPostReadAccess($post) {
282
- $object = AAM::getUser()->getObject('post', $post->ID);
283
- $read = $object->has('frontend.read');
284
- $others = $object->has('frontend.read_others');
285
-
286
- $restrict = apply_filters(
287
- 'aam-check-post-read-access-filer',
288
- ($read || ($others && !$this->isAuthor($post))),
289
- $object
290
- );
291
-
292
- if ($restrict) {
293
- AAM_Core_API::reject(
294
- 'frontend',
295
- array(
296
- 'hook' => 'post_read',
297
- 'action' => 'frontend.read',
298
- 'post' => $post
299
- )
300
- );
301
- }
302
-
303
- //check post redirect
304
- if ($object->has('frontend.redirect')) {
305
- AAM_Core_API::redirect($object->get('frontend.location'));
306
- }
307
-
308
- //trigger any action
309
- do_action('aam-wp-action', $object);
310
- }
311
-
312
- /**
313
- * Filter posts from the list
314
- *
315
- * @param array $posts
316
- *
317
- * @return array
318
- *
319
- * @access public
320
- */
321
- public function thePosts($posts) {
322
- $current = $this->getCurrentPost();
323
-
324
- if (is_array($posts) && !$this->isMainWP()) {
325
- foreach ($posts as $i => $post) {
326
- if ($current && ($current->ID == $post->ID)) { continue; }
327
-
328
- if (AAM_Core_API::isHiddenPost($post, $post->post_type)) {
329
- unset($posts[$i]);
330
- }
331
- }
332
-
333
- $posts = array_values($posts);
334
- }
335
-
336
- return $posts;
337
- }
338
-
339
- /**
340
- * Filter Navigation menu
341
- *
342
- * @param array $pages
343
- *
344
- * @return array
345
- *
346
- * @access public
347
- */
348
- public function getNavigationMenu($pages) {
349
- if (is_array($pages)) {
350
- foreach ($pages as $i => $page) {
351
- if (in_array($page->type, array('post_type', 'custom'))) {
352
- $post = get_post($page->object_id);
353
- if (AAM_Core_API::isHiddenPost($post, $post->post_type)) {
354
- unset($pages[$i]);
355
- }
356
- }
357
- }
358
- }
359
-
360
- return $pages;
361
- }
362
-
363
- /**
364
- * Filter Frontend widgets
365
- *
366
- * @param array $widgets
367
- *
368
- * @return array
369
- *
370
- * @access public
371
- */
372
- public function widgetFilter($widgets) {
373
- return AAM::getUser()->getObject('metabox')->filterFrontend($widgets);
374
- }
375
-
376
- /**
377
- * Control Frontend commenting freature
378
- *
379
- * @param boolean $open
380
- * @param int $post_id
381
- *
382
- * @return boolean
383
- *
384
- * @access public
385
- */
386
- public function commentOpen($open, $post_id) {
387
- $object = AAM::getUser()->getObject('post', $post_id);
388
 
389
- if ($object->has('frontend.comment')) {
390
- $open = false;
391
- }
392
-
393
- return $open;
394
  }
395
 
396
  /**
@@ -409,107 +81,39 @@ class AAM_Frontend_Manager {
409
  }
410
  }
411
  }
412
-
413
  /**
 
 
 
414
  *
415
- * @param type $query
416
  */
417
- public function preparePostQuery($query) {
418
- if (($this->skip === false) && $this->isMainWP()) {
419
- $this->skip = true;
420
- $filtered = AAM_Core_API::getFilteredPostList($query);
421
- $this->skip = false;
422
-
423
- if (isset($query->query_vars['post__not_in'])
424
- && is_array($query->query_vars['post__not_in'])) {
425
- $query->query_vars['post__not_in'] = array_merge(
426
- $query->query_vars['post__not_in'], $filtered
427
- );
428
- } else {
429
- $query->query_vars['post__not_in'] = $filtered;
430
- }
431
- }
432
  }
433
-
434
  /**
435
- * Undocumented function
 
 
436
  *
437
- * @return boolean
438
  */
439
- protected function isMainWP() {
440
- $result = false;
441
-
442
- foreach(debug_backtrace() as $level) {
443
- $class = (isset($level['class']) ? $level['class'] : null);
444
- $func = (isset($level['function']) ? $level['function'] : null);
445
-
446
- if ($class == 'WP' && $func == 'main') {
447
- $result = true;
448
- break;
449
- }
450
- }
451
 
452
- return $result;
453
- }
 
 
 
454
 
455
- /**
456
- *
457
- * @global WP_Post $post
458
- * @param type $content
459
- *
460
- * @return string
461
- *
462
- * @access public
463
- */
464
- public function theContent($content) {
465
- global $post;
466
-
467
- if (is_a($post, 'WP_Post')) {
468
- $object = AAM::getUser()->getObject('post', $post->ID);
469
- if ($object->has('frontend.limit')) {
470
- if ($object->has('frontend.teaser')) {
471
- $message = $object->get('frontend.teaser');
472
- $excerpt = false;
473
- } else {
474
- $teaser = AAM::getUser()->getObject('teaser');
475
- $message = $teaser->get('frontend.teaser.message');
476
- $excerpt = $teaser->get('frontend.teaser.excerpt');
477
- }
478
-
479
- $html = (intval($excerpt) ? $post->post_excerpt : '');
480
- $html .= stripslashes($message);
481
- $content = do_shortcode($html);
482
- }
483
  }
484
-
485
- return $content;
486
  }
487
 
488
- /**
489
- *
490
- * @param type $args
491
- * @param type $content
492
- * @return type
493
- */
494
- public function processShortcode($args, $content) {
495
- $shortcode = new AAM_Shortcode_Factory($args, $content);
496
-
497
- return $shortcode->process();
498
- }
499
-
500
- /**
501
- * Check if user is post author
502
- *
503
- * @param WP_Post $post
504
- *
505
- * @return boolean
506
- *
507
- * @access protected
508
- */
509
- protected function isAuthor($post) {
510
- return ($post->post_author == get_current_user_id());
511
- }
512
-
513
  /**
514
  * Bootstrap the manager
515
  *
24
  */
25
  private static $_instance = null;
26
 
 
 
 
 
 
27
  /**
28
  * Construct the manager
29
  *
33
  */
34
  public function __construct() {
35
  if (AAM_Core_Config::get('frontend-access-control', true)) {
36
+ AAM_Frontend_Filter::register();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
 
39
+ //manage AAM shortcode
40
+ add_shortcode('aam', array($this, 'processShortcode'));
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
+ //admin bar
43
+ $this->checkAdminBar();
 
44
 
45
+ //register login widget
46
+ if (AAM_Core_Config::get('secure-login', true)) {
47
+ add_action('widgets_init', array($this, 'registerLoginWidget'));
48
+ add_action('wp_enqueue_scripts', array($this, 'printJavascript'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
  }
51
 
52
  /**
53
+ * Process AAM short-codes
54
  *
55
+ * @param array $args
56
+ * @param string $content
 
 
 
 
 
57
  *
58
  * @return string
59
  *
60
  * @access public
61
  */
62
+ public function processShortcode($args, $content) {
63
+ $shortcode = new AAM_Shortcode_Factory($args, $content);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
+ return $shortcode->process();
 
 
 
 
66
  }
67
 
68
  /**
81
  }
82
  }
83
  }
84
+
85
  /**
86
+ * Register login widget
87
+ *
88
+ * @return void
89
  *
90
+ * @access public
91
  */
92
+ public function registerLoginWidget() {
93
+ register_widget('AAM_Backend_Widget_Login');
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
+
96
  /**
97
+ * Print JS libraries
98
+ *
99
+ * @return void
100
  *
101
+ * @access public
102
  */
103
+ public function printJavascript() {
104
+ if (AAM_Core_Config::get('secure-login', true)) {
105
+ wp_enqueue_script('aam-login', AAM_MEDIA . '/js/aam-login.js');
 
 
 
 
 
 
 
 
 
106
 
107
+ //add plugin localization
108
+ $locals = array(
109
+ 'nonce' => wp_create_nonce('aam_ajax'),
110
+ 'ajaxurl' => admin_url('admin-ajax.php')
111
+ );
112
 
113
+ wp_localize_script('aam-login', 'aamLocal', $locals);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
 
 
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  /**
118
  * Bootstrap the manager
119
  *
Lang/advanced-access-manager-en_US.mo CHANGED
Binary file
Lang/advanced-access-manager-en_US.po CHANGED
@@ -1,13 +1,13 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: AAM\n"
4
- "POT-Creation-Date: 2017-05-30 19:56-0400\n"
5
  "PO-Revision-Date: \n"
6
  "Language-Team: WP AAM <vasyl@vasyltech.com>\n"
7
  "MIME-Version: 1.0\n"
8
  "Content-Type: text/plain; charset=UTF-8\n"
9
  "Content-Transfer-Encoding: 8bit\n"
10
- "X-Generator: Poedit 2.0.2\n"
11
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
12
  "X-Poedit-SourceCharset: UTF-8\n"
13
  "X-Poedit-KeywordsList: __\n"
@@ -16,323 +16,388 @@ msgstr ""
16
  "Language: en_US\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
- #: Application/Backend/Feature/404Redirect.php:68
20
- msgid "404 Redirect"
21
  msgstr ""
22
 
23
- #: Application/Backend/Feature/Abstract.php:31
24
- #: Application/Backend/Manager.php:539 Application/Backend/Manager.php:562
25
- #: Application/Core/API.php:246
26
- msgid "Access Denied"
27
  msgstr ""
28
 
29
- #: Application/Backend/Feature/Capability.php:96
30
  msgid "Capability already exists"
31
  msgstr ""
32
 
33
- #: Application/Backend/Feature/Capability.php:125
34
  msgid "Can not remove the capability"
35
  msgstr ""
36
 
37
- #: Application/Backend/Feature/Capability.php:235
38
- #: Application/Backend/Feature/Capability.php:276
39
  msgid "System"
40
  msgstr ""
41
 
42
- #: Application/Backend/Feature/Capability.php:236
43
- #: Application/Backend/Feature/Capability.php:278
44
- #: Application/Backend/Feature/Post.php:467
45
  msgid "Posts & Pages"
46
  msgstr ""
47
 
48
- #: Application/Backend/Feature/Capability.php:237
49
- #: Application/Backend/Feature/Capability.php:280
50
- #: Application/Backend/phtml/frame.phtml:143
51
- #: Application/Backend/phtml/object/post.phtml:96
52
  msgid "Backend"
53
  msgstr ""
54
 
55
- #: Application/Backend/Feature/Capability.php:238
56
- #: Application/Backend/Feature/Capability.php:282
57
  msgid "AAM Interface"
58
  msgstr ""
59
 
60
- #: Application/Backend/Feature/Capability.php:239
61
- #: Application/Backend/Feature/Capability.php:284
62
- #: Application/Backend/phtml/utility.phtml:7
63
  msgid "Miscellaneous"
64
  msgstr ""
65
 
66
- #: Application/Backend/Feature/Capability.php:324
67
  msgid "Capabilities"
68
  msgstr ""
69
 
70
- #: Application/Backend/Feature/Contact.php:51
71
- msgid "Contact Us"
72
  msgstr ""
73
 
74
- #: Application/Backend/Feature/Extension.php:96
75
- msgid "Enter license key to update extension."
76
  msgstr ""
77
 
78
- #: Application/Backend/Feature/Extension.php:164
79
- msgid "Extensions"
80
  msgstr ""
81
 
82
- #: Application/Backend/Feature/LoginRedirect.php:109
83
- msgid "Login Redirect"
84
  msgstr ""
85
 
86
- #: Application/Backend/Feature/LogoutRedirect.php:110
87
- msgid "Logout Redirect"
88
  msgstr ""
89
 
90
- #: Application/Backend/Feature/Menu.php:209
91
- msgid "Backend Menu"
92
  msgstr ""
93
 
94
- #: Application/Backend/Feature/Metabox.php:245
95
- msgid "Metaboxes & Widgets"
96
  msgstr ""
97
 
98
- #: Application/Backend/Feature/Redirect.php:117
99
- msgid "Access Denied Redirect"
 
 
 
100
  msgstr ""
101
 
102
- #: Application/Backend/Feature/Security.php:79
103
- msgid "Security"
104
  msgstr ""
105
 
106
- #: Application/Backend/Feature/Teaser.php:109
107
- msgid "Content Teaser"
 
 
 
 
108
  msgstr ""
109
 
110
- #: Application/Backend/Feature/Utility.php:140
111
- msgid "Utilities"
112
  msgstr ""
113
 
114
- #: Application/Backend/Manager.php:216
115
- msgid "Access Manager"
116
  msgstr ""
117
 
118
- #: Application/Backend/Manager.php:309 Application/Backend/Manager.php:327
119
- #: Application/Backend/Manager.php:350
120
- msgid "Access"
121
  msgstr ""
122
 
123
- #: Application/Backend/Manager.php:448
124
- #: Application/Backend/View/Localization.php:40 media/js/aam-interface.js:713
125
- msgid "Anonymous"
 
 
126
  msgstr ""
127
 
128
- #: Application/Backend/Manager.php:455 media/js/aam-interface.js:745
129
- msgid "All Users, Roles and Visitor"
130
  msgstr ""
131
 
132
- #: Application/Backend/View.php:229
133
- msgid "Invalid Email"
 
 
 
134
  msgstr ""
135
 
136
- #: Application/Backend/View/Localization.php:11 media/js/aam-interface.js:1075
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  msgid "Search Capability"
138
  msgstr ""
139
 
140
- #: Application/Backend/View/Localization.php:12 media/js/aam-interface.js:1076
141
  msgid "_TOTAL_ capability(s)"
142
  msgstr ""
143
 
144
- #: Application/Backend/View/Localization.php:13 media/js/aam-interface.js:286
145
- #: media/js/aam-interface.js:341 media/js/aam-interface.js:1179
146
- #: media/js/aam-interface.js:1225 media/js/aam-interface.js:1760
147
- #: media/js/aam-interface.js:1807 media/js/aam-interface.js:1853
148
  msgid "Saving..."
149
  msgstr ""
150
 
151
- #: Application/Backend/View/Localization.php:14 media/js/aam-interface.js:1187
152
  msgid "Failed to add new capability"
153
  msgstr ""
154
 
155
- #: Application/Backend/View/Localization.php:15 media/js/aam-interface.js:306
156
- #: media/js/aam-interface.js:353 media/js/aam-interface.js:390
157
- #: media/js/aam-interface.js:484 media/js/aam-interface.js:516
158
- #: media/js/aam-interface.js:890 media/js/aam-interface.js:927
159
- #: media/js/aam-interface.js:963 media/js/aam-interface.js:1192
160
- #: media/js/aam-interface.js:1238 media/js/aam-interface.js:1279
161
- #: media/js/aam-interface.js:1473 media/js/aam-interface.js:1523
162
- #: media/js/aam-interface.js:1915 media/js/aam-interface.js:2010
163
- #: media/js/aam-interface.js:2109 media/js/aam-interface.js:2203
164
- #: media/js/aam-interface.js:2284 media/js/aam-interface.js:2358
165
- #: media/js/aam.js:207
166
  msgid "Application error"
167
  msgstr ""
168
 
169
- #: Application/Backend/View/Localization.php:16 media/js/aam-interface.js:1195
170
  msgid "Add Capability"
171
  msgstr ""
172
 
173
- #: Application/Backend/View/Localization.php:17 media/js/aam-interface.js:795
174
- #: Application/Backend/phtml/object/menu.phtml:63
175
  msgid "Show Menu"
176
  msgstr ""
177
 
178
- #: Application/Backend/View/Localization.php:18 media/js/aam-interface.js:810
179
- #: Application/Backend/phtml/object/menu.phtml:67
180
  msgid "Restrict Menu"
181
  msgstr ""
182
 
183
- #: Application/Backend/View/Localization.php:19 media/js/aam-interface.js:922
184
  msgid "Failed to retrieve mataboxes"
185
  msgstr ""
186
 
187
- #: Application/Backend/View/Localization.php:20 media/js/aam-interface.js:1562
188
  msgid "Search"
189
  msgstr ""
190
 
191
- #: Application/Backend/View/Localization.php:21 media/js/aam-interface.js:1563
192
  msgid "_TOTAL_ object(s)"
193
  msgstr ""
194
 
195
- #: Application/Backend/View/Localization.php:22
196
  msgid "Failed"
197
  msgstr ""
198
 
199
- #: Application/Backend/View/Localization.php:23 media/js/aam-interface.js:44
200
  msgid "Loading..."
201
  msgstr ""
202
 
203
- #: Application/Backend/View/Localization.php:24 media/js/aam-interface.js:49
204
- #: Application/Backend/phtml/partial/role-inheritance.phtml:5
205
- msgid "Select Role"
206
  msgstr ""
207
 
208
- #: Application/Backend/View/Localization.php:25 media/js/aam-interface.js:90
209
  msgid "Search Role"
210
  msgstr ""
211
 
212
- #: Application/Backend/View/Localization.php:26 media/js/aam-interface.js:91
213
  msgid "_TOTAL_ role(s)"
214
  msgstr ""
215
 
216
- #: Application/Backend/View/Localization.php:27 media/js/aam-interface.js:99
217
- #: media/js/aam-interface.js:555 Application/Backend/phtml/index.phtml:122
218
- #: Application/Backend/phtml/object/capability.phtml:26
219
- #: Application/Backend/phtml/object/capability.phtml:66
220
  msgid "Create"
221
  msgstr ""
222
 
223
- #: Application/Backend/View/Localization.php:28 media/js/aam-interface.js:120
224
- #: Application/Backend/phtml/index.phtml:82
225
- #: Application/Backend/phtml/index.phtml:215
226
  msgid "Users"
227
  msgstr ""
228
 
229
- #: Application/Backend/View/Localization.php:29 media/js/aam-interface.js:301
230
  msgid "Failed to add new role"
231
  msgstr ""
232
 
233
- #: Application/Backend/View/Localization.php:30 media/js/aam-interface.js:309
234
  msgid "Add Role"
235
  msgstr ""
236
 
237
- #: Application/Backend/View/Localization.php:31 media/js/aam-interface.js:348
238
  msgid "Failed to update role"
239
  msgstr ""
240
 
241
- #: Application/Backend/View/Localization.php:32 media/js/aam-interface.js:357
242
- #: Application/Backend/phtml/extension.phtml:55
243
- #: Application/Backend/phtml/extension.phtml:82
244
- #: Application/Backend/phtml/index.phtml:144
245
- #: Application/Backend/phtml/object/capability.phtml:88
 
 
 
 
 
246
  msgid "Update"
247
  msgstr ""
248
 
249
- #: Application/Backend/View/Localization.php:33 media/js/aam-interface.js:380
250
- #: media/js/aam-interface.js:1266
251
  msgid "Deleting..."
252
  msgstr ""
253
 
254
- #: Application/Backend/View/Localization.php:34 media/js/aam-interface.js:386
255
  msgid "Failed to delete role"
256
  msgstr ""
257
 
258
- #: Application/Backend/View/Localization.php:35
259
- #: Application/Backend/View/Localization.php:47 media/js/aam-interface.js:211
260
- #: media/js/aam-interface.js:394 Application/Backend/phtml/index.phtml:156
261
  msgid "Delete Role"
262
  msgstr ""
263
 
264
- #: Application/Backend/View/Localization.php:36 media/js/aam-interface.js:480
265
  msgid "Failed to block user"
266
  msgstr ""
267
 
268
- #: Application/Backend/View/Localization.php:37 media/js/aam-interface.js:546
269
  msgid "Search User"
270
  msgstr ""
271
 
272
- #: Application/Backend/View/Localization.php:38 media/js/aam-interface.js:547
273
  msgid "_TOTAL_ user(s)"
274
  msgstr ""
275
 
276
- #: Application/Backend/View/Localization.php:39 media/js/aam-interface.js:573
277
  #: Application/Backend/phtml/frame.phtml:46
278
- #: Application/Backend/phtml/index.phtml:99
279
  msgid "Role"
280
  msgstr ""
281
 
282
- #: Application/Backend/View/Localization.php:41
 
 
 
 
 
283
  msgid "Current user"
284
  msgstr ""
285
 
286
- #: Application/Backend/View/Localization.php:42
287
  msgid "Current role"
288
  msgstr ""
289
 
290
- #: Application/Backend/View/Localization.php:43 media/js/aam-interface.js:1647
291
  msgid "Manage Access"
292
  msgstr ""
293
 
294
- #: Application/Backend/View/Localization.php:44
295
- #: Application/Backend/View/PostOptionList.php:62
296
- #: media/js/aam-interface.js:1659
297
  msgid "Edit"
298
  msgstr ""
299
 
300
- #: Application/Backend/View/Localization.php:45 media/js/aam-interface.js:157
301
  msgid "Manage Role"
302
  msgstr ""
303
 
304
- #: Application/Backend/View/Localization.php:46 media/js/aam-interface.js:174
305
- msgid "Edit Role Name"
306
  msgstr ""
307
 
308
- #: Application/Backend/View/Localization.php:48 media/js/aam-interface.js:605
309
  msgid "Manage User"
310
  msgstr ""
311
 
312
- #: Application/Backend/View/Localization.php:49 media/js/aam-interface.js:619
313
  msgid "Edit User"
314
  msgstr ""
315
 
316
- #: Application/Backend/View/Localization.php:50 media/js/aam-interface.js:475
317
- #: media/js/aam-interface.js:476 media/js/aam-interface.js:632
318
  msgid "Lock User"
319
  msgstr ""
320
 
321
- #: Application/Backend/View/Localization.php:51 media/js/aam-interface.js:469
322
- #: media/js/aam-interface.js:470 media/js/aam-interface.js:645
323
  msgid "Unlock User"
324
  msgstr ""
325
 
326
- #: Application/Backend/View/Localization.php:52 media/js/aam-interface.js:1040
327
  msgid "Failed to grand capability - WordPress policy"
328
  msgstr ""
329
 
330
- #: Application/Backend/View/PostOptionList.php:13
331
- #: Application/Backend/View/PostOptionList.php:54
332
  msgid "List"
333
  msgstr ""
334
 
335
- #: Application/Backend/View/PostOptionList.php:14
336
  #, php-format
337
  msgid ""
338
  "Hide %s however access with a direct URL will be still allowed. When there "
@@ -340,563 +405,413 @@ msgid ""
340
  "for performance reasons, AAM checks limited number of posts per request."
341
  msgstr ""
342
 
343
- #: Application/Backend/View/PostOptionList.php:14
344
- #: Application/Backend/View/PostOptionList.php:22
345
  #, php-format
346
  msgid " %sSee in action.%s"
347
  msgstr ""
348
 
349
- #: Application/Backend/View/PostOptionList.php:17
350
- #: Application/Backend/View/PostOptionList.php:58
351
- msgid "List To Others"
352
  msgstr ""
353
 
354
- #: Application/Backend/View/PostOptionList.php:18
355
  #, php-format
356
  msgid ""
357
- "Hide %s for all except author (whoever created %s or was assigned on the "
358
- "Author metabox). Access with a direct URL will be still allowed. When there "
359
- "are more than 500 posts, this option may not be applied immediately because, "
360
- "for performance reasons, AAM checks limited number of posts per request."
361
  msgstr ""
362
 
363
- #: Application/Backend/View/PostOptionList.php:21
364
- msgid "Read"
365
  msgstr ""
366
 
367
- #: Application/Backend/View/PostOptionList.php:22
368
- #, php-format
369
- msgid ""
370
- "Restrict access to read %s. Any attempts to read, view or open %s will "
371
- "result in redirecting user based on the Access Denied Redirect rule."
372
  msgstr ""
373
 
374
- #: Application/Backend/View/PostOptionList.php:25
375
- msgid "Read By Others"
 
376
  msgstr ""
377
 
378
- #: Application/Backend/View/PostOptionList.php:26
379
- #, php-format
380
- msgid ""
381
- "Restrict access to read %s for all except author (whoever created %s or was "
382
- "assigned on the Author metabox). Any attempts to read, view or open %s will "
383
- "result in redirecting user based on the Access Denied Redirect rule."
384
  msgstr ""
385
 
386
- #: Application/Backend/View/PostOptionList.php:29
387
- msgid "Limit"
 
388
  msgstr ""
389
 
390
- #: Application/Backend/View/PostOptionList.php:30
391
  #, php-format
392
  msgid ""
393
- "When checked, show defined on the Content Teaser tab teaser message instead "
394
- "of the %s content."
 
395
  msgstr ""
396
 
397
- #: Application/Backend/View/PostOptionList.php:33
398
  msgid "Comment"
399
  msgstr ""
400
 
401
- #: Application/Backend/View/PostOptionList.php:34
402
  #, php-format
403
  msgid "Restrict access to comment on %s when commenting feature is enabled."
404
  msgstr ""
405
 
406
- #: Application/Backend/View/PostOptionList.php:37
407
  msgid "Redirect"
408
  msgstr ""
409
 
410
- #: Application/Backend/View/PostOptionList.php:38
411
- #, php-format
412
- msgid "Redirect to: %s"
413
- msgstr ""
414
-
415
- #: Application/Backend/View/PostOptionList.php:38
416
- #: Application/Backend/View/PostOptionList.php:43
417
- #: Application/Backend/View/PostOptionList.php:48
418
- msgid "change"
419
  msgstr ""
420
 
421
- #: Application/Backend/View/PostOptionList.php:39
422
  #, php-format
423
  msgid ""
424
- "Redirect user to defined location when user tries to read the %s. Define "
425
- "either valid full URL or public page ID within the website."
 
426
  msgstr ""
427
 
428
- #: Application/Backend/View/PostOptionList.php:42
429
  msgid "Password Protected"
430
  msgstr ""
431
 
432
- #: Application/Backend/View/PostOptionList.php:43
433
- #, php-format
434
- msgid "Password: %s"
435
  msgstr ""
436
 
437
- #: Application/Backend/View/PostOptionList.php:44
438
  #, php-format
439
- msgid ""
440
- "Add the password protection for the %s. Available with WordPress 4.7.0 or "
441
- "higher."
442
  msgstr ""
443
 
444
- #: Application/Backend/View/PostOptionList.php:47
445
  msgid "Access Expiration"
446
  msgstr ""
447
 
448
- #: Application/Backend/View/PostOptionList.php:48
449
- #, php-format
450
- msgid "Expires: %s"
451
  msgstr ""
452
 
453
- #: Application/Backend/View/PostOptionList.php:49
454
  #, php-format
455
- msgid "Define when access is expired for %s."
456
  msgstr ""
457
 
458
- #: Application/Backend/View/PostOptionList.php:49
459
  #, php-format
460
  msgid ""
461
- "After the expiration date, the access to READ will be denied unless this "
462
- "behavior is overwritten in ConfigPress. For more information %scheck this "
463
- "article%s or "
464
  msgstr ""
465
 
466
- #: Application/Backend/View/PostOptionList.php:49
467
  #, php-format
468
  msgid " %ssee in action.%s"
469
  msgstr ""
470
 
471
- #: Application/Backend/View/PostOptionList.php:55
472
- #, php-format
473
- msgid ""
474
- "Hide %s however access with a direct URL is still allowed. When there are "
475
- "more than 500 posts, this option may not be applied immediately because, for "
476
- "performance reasons, AAM checks limited number of posts per request."
477
  msgstr ""
478
 
479
- #: Application/Backend/View/PostOptionList.php:59
480
- #, php-format
481
- msgid ""
482
- "Hide %s for all except author (whoever created %s or was assigned on the "
483
- "Author metabox). Access with a direct URL is still allowed. When there are "
484
- "more than 500 posts, this option may not be applied immediately because, for "
485
- "performance reasons, AAM checks limited number of posts per request."
486
  msgstr ""
487
 
488
- #: Application/Backend/View/PostOptionList.php:63
489
  #, php-format
490
  msgid ""
491
- "Restrict access to edit %s. Any attempts to edit %s will result in "
492
- "redirecting user based on the Access Denied Redirect rule."
493
- msgstr ""
494
-
495
- #: Application/Backend/View/PostOptionList.php:66
496
- msgid "Edit By Others"
497
  msgstr ""
498
 
499