-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathabstract-feature.php
86 lines (69 loc) · 1.73 KB
/
abstract-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
<?php
/**
* Abstract Class Feature
*
* Structure and required functionality for each feature.
* Every feature should inherit this class.
*/
abstract class Aucor_Core_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 feature active or inactive (disabled) - boolean
private $is_active;
// var: list of sub_features in the feature - array
private $sub_features;
// function: setup feature
abstract public function setup();
// function: init sub_features
abstract public function sub_features_init();
/* ===================================================================
02. Things to inherit
=================================================================== */
/**
* Construct
*/
public function __construct() {
$this->setup();
if ($this->is_active()) {
$this->sub_features_init();
}
}
/**
* Check if the feature is active
*
* @return bool
*/
public function is_active() {
return apply_filters($this->key, $this->is_active);
}
/**
* 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;
}
public function get_sub_features() {
return $this->sub_features;
}
}