1
|
|
|
<?php use EventEspresso\core\interfaces\ResettableInterface; |
2
|
|
|
|
3
|
|
|
if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
4
|
|
|
/** |
5
|
|
|
* Event Espresso |
6
|
|
|
* |
7
|
|
|
* Event Registration and Management Plugin for WordPress |
8
|
|
|
* |
9
|
|
|
* @ package Event Espresso |
10
|
|
|
* @ author Event Espresso |
11
|
|
|
* @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
12
|
|
|
* @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
13
|
|
|
* @ link http://www.eventespresso.com |
14
|
|
|
* @ version 4.0 |
15
|
|
|
* |
16
|
|
|
* ------------------------------------------------------------------------ |
17
|
|
|
* |
18
|
|
|
* EED_Module |
19
|
|
|
* |
20
|
|
|
* @package Event Espresso |
21
|
|
|
* @subpackage /core/ |
22
|
|
|
* @author Brent Christensen |
23
|
|
|
* |
24
|
|
|
* ------------------------------------------------------------------------ |
25
|
|
|
*/ |
26
|
|
|
abstract class EED_Module extends EE_Configurable implements ResettableInterface { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* instance of the EED_Module object |
30
|
|
|
* @access protected |
31
|
|
|
* @var EED_Module $_instance |
32
|
|
|
*/ |
33
|
|
|
protected static $_instance = NULL; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* rendered output to be returned to WP |
37
|
|
|
* @access protected |
38
|
|
|
* @var string $output |
39
|
|
|
*/ |
40
|
|
|
protected $output = ''; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* the current active espresso template theme |
44
|
|
|
* @access protected |
45
|
|
|
* @var string $theme |
46
|
|
|
*/ |
47
|
|
|
protected $theme = ''; |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @return mixed |
53
|
|
|
*/ |
54
|
|
|
public static function reset() { |
55
|
|
|
static::$_instance = null; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* set_hooks - for hooking into EE Core, other modules, etc |
62
|
|
|
* |
63
|
|
|
* @access public |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
|
|
public static function set_hooks() {} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
70
|
|
|
* |
71
|
|
|
* @access public |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
|
|
public static function set_hooks_admin() {} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* run - initial module setup |
80
|
|
|
* this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters |
81
|
|
|
* |
82
|
|
|
* @access public |
83
|
|
|
* @var WP $WP |
84
|
|
|
* @return void |
85
|
|
|
*/ |
86
|
|
|
public abstract function run( $WP ); |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* class constructor - can ONLY be instantiated by EE_Front_Controller |
92
|
|
|
* |
93
|
|
|
* @override default exception handling |
94
|
|
|
* @access public |
95
|
|
|
* @return \EED_Module |
|
|
|
|
96
|
|
|
*/ |
97
|
|
|
final public function __construct() { |
98
|
|
|
$this->theme = EE_Config::get_current_theme(); |
99
|
|
|
$module_name = $this->module_name(); |
100
|
|
|
EE_Registry::instance()->modules->{$module_name} = $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param $module_name |
107
|
|
|
* @return EED_Module |
108
|
|
|
*/ |
109
|
|
|
protected static function get_instance( $module_name = '' ) { |
110
|
|
|
$module_name = ! empty( $module_name ) ? $module_name : get_called_class(); |
111
|
|
|
if ( ! isset( EE_Registry::instance()->modules->{$module_name} ) || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module ) { |
112
|
|
|
EE_Registry::instance()->add_module( $module_name ); |
113
|
|
|
} |
114
|
|
|
return EE_Registry::instance()->get_module( $module_name ); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* module_name |
121
|
|
|
* |
122
|
|
|
* @access public |
123
|
|
|
* @return string |
124
|
|
|
*/ |
125
|
|
|
public function module_name() { |
126
|
|
|
return get_class( $this ); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
|
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return string |
133
|
|
|
*/ |
134
|
|
|
public function theme() { |
135
|
|
|
return $this->theme; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
|
140
|
|
|
} |
141
|
|
|
// End of file EED_Module.module.php |
142
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.