-
Notifications
You must be signed in to change notification settings - Fork 22
/
addon.php
38 lines (29 loc) · 851 Bytes
/
addon.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
<?php
abstract class RevisionizeAddon {
abstract function name();
abstract function version();
abstract function init();
private static $loaded = array();
function __construct() {
add_filter('revisionize_registered_addons', array($this, 'register'));
if ($this->is_active()) {
$this->init();
}
}
function register($addons) {
$addons[$this->name()] = $this->version();
return $addons;
}
function is_active() {
return \Revisionize\is_addon_active($this->name());
}
static function addon_to_classname($addon, $prefix='Revisionize') {
return $prefix.implode('', array_map('ucfirst', explode('_', $addon)));
}
static function create($name) {
$class = RevisionizeAddon::addon_to_classname($name);
$obj = new $class;
RevisionizeAddon::$loaded[] = $obj;
return $obj;
}
}