AccessDeniedRedirect.php
1 year ago
AdminToolbar.php
1 year ago
ApiRoute.php
1 year ago
BackendMenu.php
1 year ago
Capability.php
1 year ago
Content.php
1 year ago
Identity.php
1 year ago
Jwt.php
1 year ago
LoginRedirect.php
1 year ago
LogoutRedirect.php
1 year ago
Metabox.php
1 year ago
NotFoundRedirect.php
1 year ago
Policy.php
1 year ago
Url.php
1 year ago
Welcome.php
1 year ago
Widget.php
1 year ago
Policy.php
94 lines
| 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 | * Access Policy UI manager |
| 12 | * |
| 13 | * @package AAM |
| 14 | * @version 7.0.0 |
| 15 | */ |
| 16 | class AAM_Backend_Feature_Main_Policy extends AAM_Backend_Feature_Abstract |
| 17 | { |
| 18 | |
| 19 | /** |
| 20 | * Default access capability to the feature |
| 21 | * |
| 22 | * @version 7.0.0 |
| 23 | */ |
| 24 | const ACCESS_CAPABILITY = 'aam_manage_policies'; |
| 25 | |
| 26 | /** |
| 27 | * HTML template to render |
| 28 | * |
| 29 | * @version 7.0.0 |
| 30 | */ |
| 31 | const TEMPLATE = 'service/policy.php'; |
| 32 | |
| 33 | /** |
| 34 | * Constructor |
| 35 | * |
| 36 | * @return void |
| 37 | * @access public |
| 38 | * |
| 39 | * @version 7.0.0 |
| 40 | */ |
| 41 | public function __construct() |
| 42 | { |
| 43 | add_filter('aam_iframe_content_filter', function($result, $type, $view) { |
| 44 | return $this->_render_principal_iframe($result, $type, $view); |
| 45 | }, 1, 3); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Render access policy principal metabox |
| 50 | * |
| 51 | * @param null|string $result |
| 52 | * @param string $type |
| 53 | * @param AAM_Backend_View $view |
| 54 | * |
| 55 | * @return string |
| 56 | * @access private |
| 57 | * |
| 58 | * @version 7.0.0 |
| 59 | */ |
| 60 | private function _render_principal_iframe($result, $type, $view) |
| 61 | { |
| 62 | if ($type === 'principal') { |
| 63 | $result = $view->loadTemplate( |
| 64 | dirname(__DIR__) . '/../tmpl/metabox/principal-iframe.php', |
| 65 | (object) array( |
| 66 | 'policyId' => filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT) |
| 67 | ) |
| 68 | ); |
| 69 | } |
| 70 | |
| 71 | return $result; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Register Access Policy UI feature |
| 76 | * |
| 77 | * @return void |
| 78 | * @access public |
| 79 | * |
| 80 | * @version 7.0.0 |
| 81 | */ |
| 82 | public static function register() |
| 83 | { |
| 84 | AAM_Backend_Feature::registerFeature((object) array( |
| 85 | 'uid' => 'policy', |
| 86 | 'position' => 2, |
| 87 | 'title' => __('Access Policies', 'advanced-access-manager'), |
| 88 | 'capability' => self::ACCESS_CAPABILITY, |
| 89 | 'type' => 'main', |
| 90 | 'view' => __CLASS__ |
| 91 | )); |
| 92 | } |
| 93 | |
| 94 | } |