-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathabstract-sub-feature.php
79 lines (64 loc) · 1.56 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
<?php
/**
* Abstract Class Sub_Feature
*
* Structure and required functionality for each sub_feature.
* Every sub_feature should inherit this class.
*/
abstract class Aucor_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() {
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;
}
}