Capability.php
| 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 | * Capability service |
| 12 | * |
| 13 | * @package AAM |
| 14 | * @version 6.0.0 |
| 15 | */ |
| 16 | class AAM_Service_Capability |
| 17 | { |
| 18 | use AAM_Core_Contract_ServiceTrait; |
| 19 | |
| 20 | /** |
| 21 | * AAM configuration setting that is associated with the feature |
| 22 | * |
| 23 | * @version 6.0.0 |
| 24 | */ |
| 25 | const FEATURE_FLAG = 'core.service.capability.enabled'; |
| 26 | |
| 27 | /** |
| 28 | * Constructor |
| 29 | * |
| 30 | * @return void |
| 31 | * |
| 32 | * @access protected |
| 33 | * @version 6.0.0 |
| 34 | */ |
| 35 | protected function __construct() |
| 36 | { |
| 37 | if (is_admin()) { |
| 38 | // Hook that initialize the AAM UI part of the service |
| 39 | if (AAM_Core_Config::get(self::FEATURE_FLAG, true)) { |
| 40 | add_action('aam_init_ui_action', function () { |
| 41 | AAM_Backend_Feature_Main_Capability::register(); |
| 42 | }); |
| 43 | } |
| 44 | |
| 45 | // Hook that returns the detailed information about the nature of the |
| 46 | // service. This is used to display information about service on the |
| 47 | // Settings->Services tab |
| 48 | add_filter('aam_service_list_filter', function($services) { |
| 49 | $services[] = array( |
| 50 | 'title' => __('Capabilities', AAM_KEY), |
| 51 | 'description' => __('Manage list of all the registered with WordPress core capabilities for any role or individual user. The service allows to create new or update and delete existing capabilities. Very powerful set of tools for more advanced user/role access management.', AAM_KEY), |
| 52 | 'setting' => self::FEATURE_FLAG |
| 53 | ); |
| 54 | |
| 55 | return $services; |
| 56 | }, 15); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | } |
| 61 | |
| 62 | if (defined('AAM_KEY')) { |
| 63 | AAM_Service_Capability::bootstrap(); |
| 64 | } |