| 1 |
<?php |
| 2 |
/** |
| 3 |
* Abstract class to handle all the modules on the plugin. |
| 4 |
* |
| 5 |
* @package CookieYes\Lite\Includes |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace CookieYes\AccessibilityWidget\Lite\Includes; |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
/** |
| 15 |
* Class Module |
| 16 |
*/ |
| 17 |
abstract class Modules { |
| 18 |
|
| 19 |
/** |
| 20 |
* Module slug name |
| 21 |
* |
| 22 |
* @var string |
| 23 |
*/ |
| 24 |
protected $module_id = ''; |
| 25 |
|
| 26 |
/** |
| 27 |
* Slug of the main menu |
| 28 |
* |
| 29 |
* @var string |
| 30 |
*/ |
| 31 |
protected static $menu_slug = 'accessibility-widget'; |
| 32 |
|
| 33 |
/** |
| 34 |
* Default capability of menus |
| 35 |
* |
| 36 |
* @var string |
| 37 |
*/ |
| 38 |
protected static $capability = 'manage_options'; |
| 39 |
/** |
| 40 |
* All the module translation strings. |
| 41 |
* |
| 42 |
* @var [type] |
| 43 |
*/ |
| 44 |
public $translations = array(); |
| 45 |
|
| 46 |
/** |
| 47 |
* Module constructor. |
| 48 |
* |
| 49 |
* @param string $module_id Module identifier. |
| 50 |
*/ |
| 51 |
public function __construct( $module_id ) { |
| 52 |
$this->module_id = $module_id; |
| 53 |
if ( true === $this->is_active() ) { |
| 54 |
$this->init(); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Return true if the module is activated |
| 60 |
* |
| 61 |
* @return Boolean |
| 62 |
*/ |
| 63 |
public function is_active() { |
| 64 |
$module_id = $this->get_module_id(); |
| 65 |
return apply_filters( "cya11y_is_module_active_$module_id", true ); |
| 66 |
} |
| 67 |
/** |
| 68 |
* Return the module slug name |
| 69 |
* |
| 70 |
* @return string |
| 71 |
*/ |
| 72 |
public function get_module_id() { |
| 73 |
return $this->module_id; |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Initializes the module. Always executed even if the module is deactivated. |
| 78 |
* |
| 79 |
* Do not use __construct in subclasses, use init() instead |
| 80 |
*/ |
| 81 |
abstract public function init(); |
| 82 |
} |
| 83 |
|