-
Notifications
You must be signed in to change notification settings - Fork 0
/
abstract-sub-feature.php
100 lines (69 loc) · 1.77 KB
/
abstract-sub-feature.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* Abstract Class Sub_Feature
*
* Structure and required functionality for each sub_feature.
* Every sub_feature should inherit this class.
*/
abstract class Axio_Core_Sub_Feature {
/* ===================================================================
01. Things to implement
=================================================================== */
// var: key - string
private $key;
// var: name - string
private $name;
// var: description - string, not used in version 1
private $description;
// var: is the sub_feature active or inactive (disabled) - boolean
private $is_active;
// function: setup feature
abstract public function setup();
// function: run feature
abstract public function run();
/* ===================================================================
02. Things to inherit
=================================================================== */
/**
* Construct
*/
public function __construct() {
$this->setup();
if ($this->is_active()) {
$this->run();
}
}
/**
* Check if feature is active
*
* @return bool
*/
public function is_active() {
$default = $this->is_active;
// legacy filters (aucor_core)
$value = apply_filters(str_replace('axio_core', 'aucor_core', $this->key), $default);
// new filters (axio_core)
$value = apply_filters($this->key, $value);
return $value;
}
/**
* Set function
*/
public function set($key, $value) {
if (property_exists($this, $key)) {
$this->$key = $value;
}
}
/**
* Get functions
*/
public function get_key() {
return $this->key;
}
public function get_name() {
return $this->name;
}
public function get_description() {
return $this->description;
}
}