@@ -15,125 +15,125 @@ |
||
15 | 15 | class Response implements ResponseInterface, ReservedInstanceInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var array $notice |
|
20 | - */ |
|
21 | - protected $notice = []; |
|
22 | - |
|
23 | - /** |
|
24 | - * rendered output to be returned to WP |
|
25 | - * |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - protected $output = []; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var bool |
|
32 | - */ |
|
33 | - protected $request_terminated = false; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var bool $deactivate_plugin |
|
37 | - */ |
|
38 | - protected $deactivate_plugin = false; |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * EE_Response constructor. |
|
43 | - */ |
|
44 | - public function __construct() |
|
45 | - { |
|
46 | - $this->terminateRequest(false); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * @param $key |
|
52 | - * @param $value |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function setNotice($key, $value) |
|
56 | - { |
|
57 | - $this->notice[ $key ] = $value; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * @param $key |
|
63 | - * @return mixed |
|
64 | - */ |
|
65 | - public function getNotice($key) |
|
66 | - { |
|
67 | - return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - public function getNotices() |
|
75 | - { |
|
76 | - return $this->notice; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @param string $string |
|
82 | - * @param bool $append |
|
83 | - */ |
|
84 | - public function addOutput($string, $append = true) |
|
85 | - { |
|
86 | - if ($append) { |
|
87 | - $this->output[] = $string; |
|
88 | - return; |
|
89 | - } |
|
90 | - array_unshift($this->output, $string); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * @param bool $as_string |
|
96 | - * @param string $separator |
|
97 | - * @return array|string |
|
98 | - */ |
|
99 | - public function getOutput($as_string = true, $separator = PHP_EOL) |
|
100 | - { |
|
101 | - return $as_string ? implode($separator, $this->output) : $this->output ; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return boolean |
|
107 | - */ |
|
108 | - public function requestTerminated() |
|
109 | - { |
|
110 | - return $this->request_terminated; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @param boolean $request_terminated |
|
116 | - */ |
|
117 | - public function terminateRequest($request_terminated = true) |
|
118 | - { |
|
119 | - $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * @return boolean |
|
125 | - */ |
|
126 | - public function pluginDeactivated() |
|
127 | - { |
|
128 | - return $this->deactivate_plugin; |
|
129 | - } |
|
130 | - |
|
131 | - |
|
132 | - /** |
|
133 | - * sets $deactivate_plugin to true |
|
134 | - */ |
|
135 | - public function deactivatePlugin() |
|
136 | - { |
|
137 | - $this->deactivate_plugin = true; |
|
138 | - } |
|
18 | + /** |
|
19 | + * @var array $notice |
|
20 | + */ |
|
21 | + protected $notice = []; |
|
22 | + |
|
23 | + /** |
|
24 | + * rendered output to be returned to WP |
|
25 | + * |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + protected $output = []; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var bool |
|
32 | + */ |
|
33 | + protected $request_terminated = false; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var bool $deactivate_plugin |
|
37 | + */ |
|
38 | + protected $deactivate_plugin = false; |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * EE_Response constructor. |
|
43 | + */ |
|
44 | + public function __construct() |
|
45 | + { |
|
46 | + $this->terminateRequest(false); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * @param $key |
|
52 | + * @param $value |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function setNotice($key, $value) |
|
56 | + { |
|
57 | + $this->notice[ $key ] = $value; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * @param $key |
|
63 | + * @return mixed |
|
64 | + */ |
|
65 | + public function getNotice($key) |
|
66 | + { |
|
67 | + return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + public function getNotices() |
|
75 | + { |
|
76 | + return $this->notice; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @param string $string |
|
82 | + * @param bool $append |
|
83 | + */ |
|
84 | + public function addOutput($string, $append = true) |
|
85 | + { |
|
86 | + if ($append) { |
|
87 | + $this->output[] = $string; |
|
88 | + return; |
|
89 | + } |
|
90 | + array_unshift($this->output, $string); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * @param bool $as_string |
|
96 | + * @param string $separator |
|
97 | + * @return array|string |
|
98 | + */ |
|
99 | + public function getOutput($as_string = true, $separator = PHP_EOL) |
|
100 | + { |
|
101 | + return $as_string ? implode($separator, $this->output) : $this->output ; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return boolean |
|
107 | + */ |
|
108 | + public function requestTerminated() |
|
109 | + { |
|
110 | + return $this->request_terminated; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @param boolean $request_terminated |
|
116 | + */ |
|
117 | + public function terminateRequest($request_terminated = true) |
|
118 | + { |
|
119 | + $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * @return boolean |
|
125 | + */ |
|
126 | + public function pluginDeactivated() |
|
127 | + { |
|
128 | + return $this->deactivate_plugin; |
|
129 | + } |
|
130 | + |
|
131 | + |
|
132 | + /** |
|
133 | + * sets $deactivate_plugin to true |
|
134 | + */ |
|
135 | + public function deactivatePlugin() |
|
136 | + { |
|
137 | + $this->deactivate_plugin = true; |
|
138 | + } |
|
139 | 139 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function setNotice($key, $value) |
56 | 56 | { |
57 | - $this->notice[ $key ] = $value; |
|
57 | + $this->notice[$key] = $value; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function getNotice($key) |
66 | 66 | { |
67 | - return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
67 | + return isset($this->notice[$key]) ? $this->notice[$key] : null; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function getOutput($as_string = true, $separator = PHP_EOL) |
100 | 100 | { |
101 | - return $as_string ? implode($separator, $this->output) : $this->output ; |
|
101 | + return $as_string ? implode($separator, $this->output) : $this->output; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -27,1349 +27,1349 @@ |
||
27 | 27 | final class EE_System implements ResettableInterface |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
32 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
33 | - */ |
|
34 | - const req_type_normal = 0; |
|
35 | - |
|
36 | - /** |
|
37 | - * Indicates this is a brand new installation of EE so we should install |
|
38 | - * tables and default data etc |
|
39 | - */ |
|
40 | - const req_type_new_activation = 1; |
|
41 | - |
|
42 | - /** |
|
43 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
44 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
45 | - * and that default data is setup too |
|
46 | - */ |
|
47 | - const req_type_reactivation = 2; |
|
48 | - |
|
49 | - /** |
|
50 | - * indicates that EE has been upgraded since its previous request. |
|
51 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
52 | - */ |
|
53 | - const req_type_upgrade = 3; |
|
54 | - |
|
55 | - /** |
|
56 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
57 | - */ |
|
58 | - const req_type_downgrade = 4; |
|
59 | - |
|
60 | - /** |
|
61 | - * @deprecated since version 4.6.0.dev.006 |
|
62 | - * Now whenever a new_activation is detected the request type is still just |
|
63 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
64 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
65 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
66 | - * (Specifically, when the migration manager indicates migrations are finished |
|
67 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
68 | - */ |
|
69 | - const req_type_activation_but_not_installed = 5; |
|
70 | - |
|
71 | - /** |
|
72 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
73 | - */ |
|
74 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
75 | - |
|
76 | - /** |
|
77 | - * @var EE_System $_instance |
|
78 | - */ |
|
79 | - private static $_instance; |
|
80 | - |
|
81 | - /** |
|
82 | - * @var EE_Registry $registry |
|
83 | - */ |
|
84 | - private $registry; |
|
85 | - |
|
86 | - /** |
|
87 | - * @var LoaderInterface $loader |
|
88 | - */ |
|
89 | - private $loader; |
|
90 | - |
|
91 | - /** |
|
92 | - * @var EE_Capabilities $capabilities |
|
93 | - */ |
|
94 | - private $capabilities; |
|
95 | - |
|
96 | - /** |
|
97 | - * @var RequestInterface $request |
|
98 | - */ |
|
99 | - private $request; |
|
100 | - |
|
101 | - /** |
|
102 | - * @var EE_Maintenance_Mode $maintenance_mode |
|
103 | - */ |
|
104 | - private $maintenance_mode; |
|
105 | - |
|
106 | - /** |
|
107 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
108 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
109 | - * |
|
110 | - * @var int $_req_type |
|
111 | - */ |
|
112 | - private $_req_type; |
|
113 | - |
|
114 | - /** |
|
115 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
116 | - * |
|
117 | - * @var boolean $_major_version_change |
|
118 | - */ |
|
119 | - private $_major_version_change = false; |
|
120 | - |
|
121 | - /** |
|
122 | - * A Context DTO dedicated solely to identifying the current request type. |
|
123 | - * |
|
124 | - * @var RequestTypeContextCheckerInterface $request_type |
|
125 | - */ |
|
126 | - private $request_type; |
|
127 | - |
|
128 | - /** |
|
129 | - * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes |
|
130 | - */ |
|
131 | - private $register_custom_post_types; |
|
132 | - |
|
133 | - /** |
|
134 | - * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies |
|
135 | - */ |
|
136 | - private $register_custom_taxonomies; |
|
137 | - |
|
138 | - /** |
|
139 | - * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms |
|
140 | - */ |
|
141 | - private $register_custom_taxonomy_terms; |
|
142 | - |
|
143 | - /** |
|
144 | - * @singleton method used to instantiate class object |
|
145 | - * @param EE_Registry|null $registry |
|
146 | - * @param LoaderInterface|null $loader |
|
147 | - * @param RequestInterface|null $request |
|
148 | - * @param EE_Maintenance_Mode|null $maintenance_mode |
|
149 | - * @return EE_System |
|
150 | - */ |
|
151 | - public static function instance( |
|
152 | - EE_Registry $registry = null, |
|
153 | - LoaderInterface $loader = null, |
|
154 | - RequestInterface $request = null, |
|
155 | - EE_Maintenance_Mode $maintenance_mode = null |
|
156 | - ) { |
|
157 | - // check if class object is instantiated |
|
158 | - if (! self::$_instance instanceof EE_System) { |
|
159 | - self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
|
160 | - } |
|
161 | - return self::$_instance; |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * resets the instance and returns it |
|
167 | - * |
|
168 | - * @return EE_System |
|
169 | - */ |
|
170 | - public static function reset() |
|
171 | - { |
|
172 | - self::$_instance->_req_type = null; |
|
173 | - // make sure none of the old hooks are left hanging around |
|
174 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
175 | - // we need to reset the migration manager in order for it to detect DMSs properly |
|
176 | - EE_Data_Migration_Manager::reset(); |
|
177 | - self::instance()->detect_activations_or_upgrades(); |
|
178 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
179 | - return self::instance(); |
|
180 | - } |
|
181 | - |
|
182 | - |
|
183 | - /** |
|
184 | - * sets hooks for running rest of system |
|
185 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
186 | - * starting EE Addons from any other point may lead to problems |
|
187 | - * |
|
188 | - * @param EE_Registry $registry |
|
189 | - * @param LoaderInterface $loader |
|
190 | - * @param RequestInterface $request |
|
191 | - * @param EE_Maintenance_Mode $maintenance_mode |
|
192 | - */ |
|
193 | - private function __construct( |
|
194 | - EE_Registry $registry, |
|
195 | - LoaderInterface $loader, |
|
196 | - RequestInterface $request, |
|
197 | - EE_Maintenance_Mode $maintenance_mode |
|
198 | - ) { |
|
199 | - $this->registry = $registry; |
|
200 | - $this->loader = $loader; |
|
201 | - $this->request = $request; |
|
202 | - $this->maintenance_mode = $maintenance_mode; |
|
203 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
204 | - add_action( |
|
205 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
206 | - array($this, 'loadCapabilities'), |
|
207 | - 5 |
|
208 | - ); |
|
209 | - add_action( |
|
210 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
211 | - array($this, 'loadCommandBus'), |
|
212 | - 7 |
|
213 | - ); |
|
214 | - add_action( |
|
215 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
216 | - array($this, 'loadPluginApi'), |
|
217 | - 9 |
|
218 | - ); |
|
219 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
220 | - add_action( |
|
221 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
222 | - array($this, 'load_espresso_addons') |
|
223 | - ); |
|
224 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
225 | - // because the newly-activated addon didn't get a chance to run at all |
|
226 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
227 | - // detect whether install or upgrade |
|
228 | - add_action( |
|
229 | - 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
230 | - array($this, 'detect_activations_or_upgrades'), |
|
231 | - 3 |
|
232 | - ); |
|
233 | - // load EE_Config, EE_Textdomain, etc |
|
234 | - add_action( |
|
235 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
236 | - array($this, 'load_core_configuration'), |
|
237 | - 5 |
|
238 | - ); |
|
239 | - // load specifications for matching routes to current request |
|
240 | - add_action( |
|
241 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
242 | - array($this, 'loadRouteMatchSpecifications') |
|
243 | - ); |
|
244 | - // load specifications for custom post types |
|
245 | - add_action( |
|
246 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
247 | - array($this, 'loadCustomPostTypes') |
|
248 | - ); |
|
249 | - // load EE_Config, EE_Textdomain, etc |
|
250 | - add_action( |
|
251 | - 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
252 | - array($this, 'register_shortcodes_modules_and_widgets'), |
|
253 | - 7 |
|
254 | - ); |
|
255 | - // you wanna get going? I wanna get going... let's get going! |
|
256 | - add_action( |
|
257 | - 'AHEE__EE_Bootstrap__brew_espresso', |
|
258 | - array($this, 'brew_espresso'), |
|
259 | - 9 |
|
260 | - ); |
|
261 | - // other housekeeping |
|
262 | - // exclude EE critical pages from wp_list_pages |
|
263 | - add_filter( |
|
264 | - 'wp_list_pages_excludes', |
|
265 | - array($this, 'remove_pages_from_wp_list_pages'), |
|
266 | - 10 |
|
267 | - ); |
|
268 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
269 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
270 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * load and setup EE_Capabilities |
|
276 | - * |
|
277 | - * @return void |
|
278 | - * @throws EE_Error |
|
279 | - */ |
|
280 | - public function loadCapabilities() |
|
281 | - { |
|
282 | - $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
|
283 | - add_action( |
|
284 | - 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
285 | - function () { |
|
286 | - LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
287 | - } |
|
288 | - ); |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - /** |
|
293 | - * create and cache the CommandBus, and also add middleware |
|
294 | - * The CapChecker middleware requires the use of EE_Capabilities |
|
295 | - * which is why we need to load the CommandBus after Caps are set up |
|
296 | - * |
|
297 | - * @return void |
|
298 | - * @throws EE_Error |
|
299 | - */ |
|
300 | - public function loadCommandBus() |
|
301 | - { |
|
302 | - $this->loader->getShared( |
|
303 | - 'CommandBusInterface', |
|
304 | - array( |
|
305 | - null, |
|
306 | - apply_filters( |
|
307 | - 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
308 | - array( |
|
309 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
310 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
311 | - ) |
|
312 | - ), |
|
313 | - ) |
|
314 | - ); |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * @return void |
|
320 | - * @throws EE_Error |
|
321 | - */ |
|
322 | - public function loadPluginApi() |
|
323 | - { |
|
324 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
325 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
326 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * @param string $addon_name |
|
332 | - * @param string $version_constant |
|
333 | - * @param string $min_version_required |
|
334 | - * @param string $load_callback |
|
335 | - * @param string $plugin_file_constant |
|
336 | - * @return void |
|
337 | - */ |
|
338 | - private function deactivateIncompatibleAddon( |
|
339 | - $addon_name, |
|
340 | - $version_constant, |
|
341 | - $min_version_required, |
|
342 | - $load_callback, |
|
343 | - $plugin_file_constant |
|
344 | - ) { |
|
345 | - if (! defined($version_constant)) { |
|
346 | - return; |
|
347 | - } |
|
348 | - $addon_version = constant($version_constant); |
|
349 | - if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
|
350 | - remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
|
351 | - if (! function_exists('deactivate_plugins')) { |
|
352 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
353 | - } |
|
354 | - deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
|
355 | - $this->request->unSetRequestParams(['activate', 'activate-multi'], true); |
|
356 | - EE_Error::add_error( |
|
357 | - sprintf( |
|
358 | - esc_html__( |
|
359 | - 'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.', |
|
360 | - 'event_espresso' |
|
361 | - ), |
|
362 | - $addon_name, |
|
363 | - $min_version_required |
|
364 | - ), |
|
365 | - __FILE__, |
|
366 | - __FUNCTION__ . "({$addon_name})", |
|
367 | - __LINE__ |
|
368 | - ); |
|
369 | - EE_Error::get_notices(false, true); |
|
370 | - } |
|
371 | - } |
|
372 | - |
|
373 | - |
|
374 | - /** |
|
375 | - * load_espresso_addons |
|
376 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
377 | - * this is hooked into both: |
|
378 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
379 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
380 | - * and the WP 'activate_plugin' hook point |
|
381 | - * |
|
382 | - * @access public |
|
383 | - * @return void |
|
384 | - */ |
|
385 | - public function load_espresso_addons() |
|
386 | - { |
|
387 | - $this->deactivateIncompatibleAddon( |
|
388 | - 'Wait Lists', |
|
389 | - 'EE_WAIT_LISTS_VERSION', |
|
390 | - '1.0.0.beta.074', |
|
391 | - 'load_espresso_wait_lists', |
|
392 | - 'EE_WAIT_LISTS_PLUGIN_FILE' |
|
393 | - ); |
|
394 | - $this->deactivateIncompatibleAddon( |
|
395 | - 'Automated Upcoming Event Notifications', |
|
396 | - 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION', |
|
397 | - '1.0.0.beta.091', |
|
398 | - 'load_espresso_automated_upcoming_event_notification', |
|
399 | - 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE' |
|
400 | - ); |
|
401 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
402 | - // if the WP API basic auth plugin isn't already loaded, load it now. |
|
403 | - // We want it for mobile apps. Just include the entire plugin |
|
404 | - // also, don't load the basic auth when a plugin is getting activated, because |
|
405 | - // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
406 | - // and causes a fatal error |
|
407 | - if ( |
|
408 | - ($this->request->isWordPressApi() || $this->request->isApi()) |
|
409 | - && $this->request->getRequestParam('activate') !== 'true' |
|
410 | - && ! function_exists('json_basic_auth_handler') |
|
411 | - && ! function_exists('json_basic_auth_error') |
|
412 | - && ! in_array( |
|
413 | - $this->request->getRequestParam('action'), |
|
414 | - array('activate', 'activate-selected'), |
|
415 | - true |
|
416 | - ) |
|
417 | - ) { |
|
418 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
419 | - } |
|
420 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
421 | - } |
|
422 | - |
|
423 | - |
|
424 | - /** |
|
425 | - * detect_activations_or_upgrades |
|
426 | - * Checks for activation or upgrade of core first; |
|
427 | - * then also checks if any registered addons have been activated or upgraded |
|
428 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
429 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
430 | - * |
|
431 | - * @access public |
|
432 | - * @return void |
|
433 | - */ |
|
434 | - public function detect_activations_or_upgrades() |
|
435 | - { |
|
436 | - // first off: let's make sure to handle core |
|
437 | - $this->detect_if_activation_or_upgrade(); |
|
438 | - foreach ($this->registry->addons as $addon) { |
|
439 | - if ($addon instanceof EE_Addon) { |
|
440 | - // detect teh request type for that addon |
|
441 | - $addon->detect_req_type(); |
|
442 | - } |
|
443 | - } |
|
444 | - } |
|
445 | - |
|
446 | - |
|
447 | - /** |
|
448 | - * detect_if_activation_or_upgrade |
|
449 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
450 | - * and either setting up the DB or setting up maintenance mode etc. |
|
451 | - * |
|
452 | - * @access public |
|
453 | - * @return void |
|
454 | - */ |
|
455 | - public function detect_if_activation_or_upgrade() |
|
456 | - { |
|
457 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
458 | - // check if db has been updated, or if its a brand-new installation |
|
459 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
460 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
461 | - // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
462 | - switch ($request_type) { |
|
463 | - case EE_System::req_type_new_activation: |
|
464 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
465 | - $this->_handle_core_version_change($espresso_db_update); |
|
466 | - break; |
|
467 | - case EE_System::req_type_reactivation: |
|
468 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
469 | - $this->_handle_core_version_change($espresso_db_update); |
|
470 | - break; |
|
471 | - case EE_System::req_type_upgrade: |
|
472 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
473 | - // migrations may be required now that we've upgraded |
|
474 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
475 | - $this->_handle_core_version_change($espresso_db_update); |
|
476 | - break; |
|
477 | - case EE_System::req_type_downgrade: |
|
478 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
479 | - // its possible migrations are no longer required |
|
480 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
481 | - $this->_handle_core_version_change($espresso_db_update); |
|
482 | - break; |
|
483 | - case EE_System::req_type_normal: |
|
484 | - default: |
|
485 | - break; |
|
486 | - } |
|
487 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
488 | - } |
|
489 | - |
|
490 | - |
|
491 | - /** |
|
492 | - * Updates the list of installed versions and sets hooks for |
|
493 | - * initializing the database later during the request |
|
494 | - * |
|
495 | - * @param array $espresso_db_update |
|
496 | - */ |
|
497 | - private function _handle_core_version_change($espresso_db_update) |
|
498 | - { |
|
499 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
500 | - // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
501 | - add_action( |
|
502 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
503 | - array($this, 'initialize_db_if_no_migrations_required') |
|
504 | - ); |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - /** |
|
509 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
510 | - * information about what versions of EE have been installed and activated, |
|
511 | - * NOT necessarily the state of the database |
|
512 | - * |
|
513 | - * @param mixed $espresso_db_update the value of the WordPress option. |
|
514 | - * If not supplied, fetches it from the options table |
|
515 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
516 | - */ |
|
517 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
518 | - { |
|
519 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
520 | - if (! $espresso_db_update) { |
|
521 | - $espresso_db_update = get_option('espresso_db_update'); |
|
522 | - } |
|
523 | - // check that option is an array |
|
524 | - if (! is_array($espresso_db_update)) { |
|
525 | - // if option is FALSE, then it never existed |
|
526 | - if ($espresso_db_update === false) { |
|
527 | - // make $espresso_db_update an array and save option with autoload OFF |
|
528 | - $espresso_db_update = array(); |
|
529 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
530 | - } else { |
|
531 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
532 | - $espresso_db_update = array($espresso_db_update => array()); |
|
533 | - update_option('espresso_db_update', $espresso_db_update); |
|
534 | - } |
|
535 | - } else { |
|
536 | - $corrected_db_update = array(); |
|
537 | - // if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
538 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
539 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
540 | - // the key is an int, and the value IS NOT an array |
|
541 | - // so it must be numerically-indexed, where values are versions installed... |
|
542 | - // fix it! |
|
543 | - $version_string = $should_be_array; |
|
544 | - $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
545 | - } else { |
|
546 | - // ok it checks out |
|
547 | - $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
548 | - } |
|
549 | - } |
|
550 | - $espresso_db_update = $corrected_db_update; |
|
551 | - update_option('espresso_db_update', $espresso_db_update); |
|
552 | - } |
|
553 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
554 | - return $espresso_db_update; |
|
555 | - } |
|
556 | - |
|
557 | - |
|
558 | - /** |
|
559 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
560 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
561 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
562 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
563 | - * so that it will be done when migrations are finished |
|
564 | - * |
|
565 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
566 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
567 | - * This is a resource-intensive job |
|
568 | - * so we prefer to only do it when necessary |
|
569 | - * @return void |
|
570 | - * @throws EE_Error |
|
571 | - */ |
|
572 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
573 | - { |
|
574 | - $request_type = $this->detect_req_type(); |
|
575 | - // only initialize system if we're not in maintenance mode. |
|
576 | - if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
577 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
578 | - $rewrite_rules = $this->loader->getShared( |
|
579 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
580 | - ); |
|
581 | - $rewrite_rules->flush(); |
|
582 | - if ($verify_schema) { |
|
583 | - EEH_Activation::initialize_db_and_folders(); |
|
584 | - } |
|
585 | - EEH_Activation::initialize_db_content(); |
|
586 | - EEH_Activation::system_initialization(); |
|
587 | - if ($initialize_addons_too) { |
|
588 | - $this->initialize_addons(); |
|
589 | - } |
|
590 | - } else { |
|
591 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
592 | - } |
|
593 | - if ( |
|
594 | - $request_type === EE_System::req_type_new_activation |
|
595 | - || $request_type === EE_System::req_type_reactivation |
|
596 | - || ( |
|
597 | - $request_type === EE_System::req_type_upgrade |
|
598 | - && $this->is_major_version_change() |
|
599 | - ) |
|
600 | - ) { |
|
601 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
602 | - } |
|
603 | - } |
|
604 | - |
|
605 | - |
|
606 | - /** |
|
607 | - * Initializes the db for all registered addons |
|
608 | - * |
|
609 | - * @throws EE_Error |
|
610 | - */ |
|
611 | - public function initialize_addons() |
|
612 | - { |
|
613 | - // foreach registered addon, make sure its db is up-to-date too |
|
614 | - foreach ($this->registry->addons as $addon) { |
|
615 | - if ($addon instanceof EE_Addon) { |
|
616 | - $addon->initialize_db_if_no_migrations_required(); |
|
617 | - } |
|
618 | - } |
|
619 | - } |
|
620 | - |
|
621 | - |
|
622 | - /** |
|
623 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
624 | - * |
|
625 | - * @param array $version_history |
|
626 | - * @param string $current_version_to_add version to be added to the version history |
|
627 | - * @return boolean success as to whether or not this option was changed |
|
628 | - */ |
|
629 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
630 | - { |
|
631 | - if (! $version_history) { |
|
632 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
633 | - } |
|
634 | - if ($current_version_to_add === null) { |
|
635 | - $current_version_to_add = espresso_version(); |
|
636 | - } |
|
637 | - $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
638 | - // re-save |
|
639 | - return update_option('espresso_db_update', $version_history); |
|
640 | - } |
|
641 | - |
|
642 | - |
|
643 | - /** |
|
644 | - * Detects if the current version indicated in the has existed in the list of |
|
645 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
646 | - * |
|
647 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
648 | - * If not supplied, fetches it from the options table. |
|
649 | - * Also, caches its result so later parts of the code can also know whether |
|
650 | - * there's been an update or not. This way we can add the current version to |
|
651 | - * espresso_db_update, but still know if this is a new install or not |
|
652 | - * @return int one of the constants on EE_System::req_type_ |
|
653 | - */ |
|
654 | - public function detect_req_type($espresso_db_update = null) |
|
655 | - { |
|
656 | - if ($this->_req_type === null) { |
|
657 | - $espresso_db_update = ! empty($espresso_db_update) |
|
658 | - ? $espresso_db_update |
|
659 | - : $this->fix_espresso_db_upgrade_option(); |
|
660 | - $this->_req_type = EE_System::detect_req_type_given_activation_history( |
|
661 | - $espresso_db_update, |
|
662 | - 'ee_espresso_activation', |
|
663 | - espresso_version() |
|
664 | - ); |
|
665 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
666 | - $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal); |
|
667 | - } |
|
668 | - return $this->_req_type; |
|
669 | - } |
|
670 | - |
|
671 | - |
|
672 | - /** |
|
673 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
674 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
675 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
676 | - * |
|
677 | - * @param $activation_history |
|
678 | - * @return bool |
|
679 | - */ |
|
680 | - private function _detect_major_version_change($activation_history) |
|
681 | - { |
|
682 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
683 | - $previous_version_parts = explode('.', $previous_version); |
|
684 | - $current_version_parts = explode('.', espresso_version()); |
|
685 | - return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
686 | - && ($previous_version_parts[0] !== $current_version_parts[0] |
|
687 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
688 | - ); |
|
689 | - } |
|
690 | - |
|
691 | - |
|
692 | - /** |
|
693 | - * Returns true if either the major or minor version of EE changed during this request. |
|
694 | - * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
695 | - * |
|
696 | - * @return bool |
|
697 | - */ |
|
698 | - public function is_major_version_change() |
|
699 | - { |
|
700 | - return $this->_major_version_change; |
|
701 | - } |
|
702 | - |
|
703 | - |
|
704 | - /** |
|
705 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
706 | - * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
|
707 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
708 | - * just activated to (for core that will always be espresso_version()) |
|
709 | - * |
|
710 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
711 | - * ee plugin. for core that's 'espresso_db_update' |
|
712 | - * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
|
713 | - * indicate that this plugin was just activated |
|
714 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
715 | - * espresso_version()) |
|
716 | - * @return int one of the constants on EE_System::req_type_* |
|
717 | - */ |
|
718 | - public static function detect_req_type_given_activation_history( |
|
719 | - $activation_history_for_addon, |
|
720 | - $activation_indicator_option_name, |
|
721 | - $version_to_upgrade_to |
|
722 | - ) { |
|
723 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
724 | - if ($activation_history_for_addon) { |
|
725 | - // it exists, so this isn't a completely new install |
|
726 | - // check if this version already in that list of previously installed versions |
|
727 | - if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
728 | - // it a version we haven't seen before |
|
729 | - if ($version_is_higher === 1) { |
|
730 | - $req_type = EE_System::req_type_upgrade; |
|
731 | - } else { |
|
732 | - $req_type = EE_System::req_type_downgrade; |
|
733 | - } |
|
734 | - delete_option($activation_indicator_option_name); |
|
735 | - } else { |
|
736 | - // its not an update. maybe a reactivation? |
|
737 | - if (get_option($activation_indicator_option_name, false)) { |
|
738 | - if ($version_is_higher === -1) { |
|
739 | - $req_type = EE_System::req_type_downgrade; |
|
740 | - } elseif ($version_is_higher === 0) { |
|
741 | - // we've seen this version before, but it's an activation. must be a reactivation |
|
742 | - $req_type = EE_System::req_type_reactivation; |
|
743 | - } else {// $version_is_higher === 1 |
|
744 | - $req_type = EE_System::req_type_upgrade; |
|
745 | - } |
|
746 | - delete_option($activation_indicator_option_name); |
|
747 | - } else { |
|
748 | - // we've seen this version before and the activation indicate doesn't show it was just activated |
|
749 | - if ($version_is_higher === -1) { |
|
750 | - $req_type = EE_System::req_type_downgrade; |
|
751 | - } elseif ($version_is_higher === 0) { |
|
752 | - // we've seen this version before and it's not an activation. its normal request |
|
753 | - $req_type = EE_System::req_type_normal; |
|
754 | - } else {// $version_is_higher === 1 |
|
755 | - $req_type = EE_System::req_type_upgrade; |
|
756 | - } |
|
757 | - } |
|
758 | - } |
|
759 | - } else { |
|
760 | - // brand new install |
|
761 | - $req_type = EE_System::req_type_new_activation; |
|
762 | - delete_option($activation_indicator_option_name); |
|
763 | - } |
|
764 | - return $req_type; |
|
765 | - } |
|
766 | - |
|
767 | - |
|
768 | - /** |
|
769 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
770 | - * the $activation_history_for_addon |
|
771 | - * |
|
772 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
773 | - * sometimes containing 'unknown-date' |
|
774 | - * @param string $version_to_upgrade_to (current version) |
|
775 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
776 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
777 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
778 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
779 | - */ |
|
780 | - private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
781 | - { |
|
782 | - // find the most recently-activated version |
|
783 | - $most_recently_active_version = |
|
784 | - EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
785 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
786 | - } |
|
787 | - |
|
788 | - |
|
789 | - /** |
|
790 | - * Gets the most recently active version listed in the activation history, |
|
791 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
792 | - * |
|
793 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
794 | - * sometimes containing 'unknown-date' |
|
795 | - * @return string |
|
796 | - */ |
|
797 | - private static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
798 | - { |
|
799 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
800 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
801 | - if (is_array($activation_history)) { |
|
802 | - foreach ($activation_history as $version => $times_activated) { |
|
803 | - // check there is a record of when this version was activated. Otherwise, |
|
804 | - // mark it as unknown |
|
805 | - if (! $times_activated) { |
|
806 | - $times_activated = array('unknown-date'); |
|
807 | - } |
|
808 | - if (is_string($times_activated)) { |
|
809 | - $times_activated = array($times_activated); |
|
810 | - } |
|
811 | - foreach ($times_activated as $an_activation) { |
|
812 | - if ( |
|
813 | - $an_activation !== 'unknown-date' |
|
814 | - && $an_activation |
|
815 | - > $most_recently_active_version_activation |
|
816 | - ) { |
|
817 | - $most_recently_active_version = $version; |
|
818 | - $most_recently_active_version_activation = $an_activation === 'unknown-date' |
|
819 | - ? '1970-01-01 00:00:00' |
|
820 | - : $an_activation; |
|
821 | - } |
|
822 | - } |
|
823 | - } |
|
824 | - } |
|
825 | - return $most_recently_active_version; |
|
826 | - } |
|
827 | - |
|
828 | - |
|
829 | - /** |
|
830 | - * This redirects to the about EE page after activation |
|
831 | - * |
|
832 | - * @return void |
|
833 | - */ |
|
834 | - public function redirect_to_about_ee() |
|
835 | - { |
|
836 | - $notices = EE_Error::get_notices(false); |
|
837 | - // if current user is an admin and it's not an ajax or rest request |
|
838 | - if ( |
|
839 | - ! isset($notices['errors']) |
|
840 | - && $this->request->isAdmin() |
|
841 | - && apply_filters( |
|
842 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
843 | - $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
844 | - ) |
|
845 | - ) { |
|
846 | - $query_params = array('page' => 'espresso_about'); |
|
847 | - if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) { |
|
848 | - $query_params['new_activation'] = true; |
|
849 | - } |
|
850 | - if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) { |
|
851 | - $query_params['reactivation'] = true; |
|
852 | - } |
|
853 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
854 | - wp_safe_redirect($url); |
|
855 | - exit(); |
|
856 | - } |
|
857 | - } |
|
858 | - |
|
859 | - |
|
860 | - /** |
|
861 | - * load_core_configuration |
|
862 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
863 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
864 | - * |
|
865 | - * @return void |
|
866 | - * @throws ReflectionException |
|
867 | - * @throws Exception |
|
868 | - */ |
|
869 | - public function load_core_configuration() |
|
870 | - { |
|
871 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
872 | - $this->loader->getShared('EE_Load_Textdomain'); |
|
873 | - // load textdomain |
|
874 | - EE_Load_Textdomain::load_textdomain(); |
|
875 | - // load caf stuff a chance to play during the activation process too. |
|
876 | - $this->_maybe_brew_regular(); |
|
877 | - // load and setup EE_Config and EE_Network_Config |
|
878 | - $config = $this->loader->getShared('EE_Config'); |
|
879 | - $this->loader->getShared('EE_Network_Config'); |
|
880 | - // setup autoloaders |
|
881 | - // enable logging? |
|
882 | - if ($config->admin->use_remote_logging) { |
|
883 | - $this->loader->getShared('EE_Log'); |
|
884 | - } |
|
885 | - // check for activation errors |
|
886 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
887 | - if ($activation_errors) { |
|
888 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
889 | - update_option('ee_plugin_activation_errors', false); |
|
890 | - } |
|
891 | - // get model names |
|
892 | - $this->_parse_model_names(); |
|
893 | - // configure custom post type definitions |
|
894 | - $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions'); |
|
895 | - $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'); |
|
896 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
897 | - } |
|
898 | - |
|
899 | - |
|
900 | - /** |
|
901 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
902 | - * |
|
903 | - * @return void |
|
904 | - * @throws ReflectionException |
|
905 | - */ |
|
906 | - private function _parse_model_names() |
|
907 | - { |
|
908 | - // get all the files in the EE_MODELS folder that end in .model.php |
|
909 | - $models = glob(EE_MODELS . '*.model.php'); |
|
910 | - $model_names = array(); |
|
911 | - $non_abstract_db_models = array(); |
|
912 | - foreach ($models as $model) { |
|
913 | - // get model classname |
|
914 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
915 | - $short_name = str_replace('EEM_', '', $classname); |
|
916 | - $reflectionClass = new ReflectionClass($classname); |
|
917 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
918 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
919 | - } |
|
920 | - $model_names[ $short_name ] = $classname; |
|
921 | - } |
|
922 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
923 | - $this->registry->non_abstract_db_models = apply_filters( |
|
924 | - 'FHEE__EE_System__parse_implemented_model_names', |
|
925 | - $non_abstract_db_models |
|
926 | - ); |
|
927 | - } |
|
928 | - |
|
929 | - |
|
930 | - /** |
|
931 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
932 | - * that need to be setup before our EE_System launches. |
|
933 | - * |
|
934 | - * @return void |
|
935 | - * @throws DomainException |
|
936 | - * @throws InvalidArgumentException |
|
937 | - * @throws InvalidDataTypeException |
|
938 | - * @throws InvalidInterfaceException |
|
939 | - * @throws InvalidClassException |
|
940 | - * @throws InvalidFilePathException |
|
941 | - */ |
|
942 | - private function _maybe_brew_regular() |
|
943 | - { |
|
944 | - /** @var Domain $domain */ |
|
945 | - $domain = DomainFactory::getShared( |
|
946 | - new FullyQualifiedName( |
|
947 | - 'EventEspresso\core\domain\Domain' |
|
948 | - ), |
|
949 | - array( |
|
950 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
951 | - Version::fromString(espresso_version()), |
|
952 | - ) |
|
953 | - ); |
|
954 | - if ($domain->isCaffeinated()) { |
|
955 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
956 | - } |
|
957 | - } |
|
958 | - |
|
959 | - |
|
960 | - /** |
|
961 | - * @since 4.9.71.p |
|
962 | - * @throws Exception |
|
963 | - */ |
|
964 | - public function loadRouteMatchSpecifications() |
|
965 | - { |
|
966 | - try { |
|
967 | - $this->loader->getShared( |
|
968 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' |
|
969 | - ); |
|
970 | - } catch (Exception $exception) { |
|
971 | - new ExceptionStackTraceDisplay($exception); |
|
972 | - } |
|
973 | - do_action('AHEE__EE_System__loadRouteMatchSpecifications'); |
|
974 | - } |
|
975 | - |
|
976 | - |
|
977 | - /** |
|
978 | - * loading CPT related classes earlier so that their definitions are available |
|
979 | - * but not performing any actual registration with WP core until load_CPTs_and_session() is called |
|
980 | - * |
|
981 | - * @since 4.10.21.p |
|
982 | - */ |
|
983 | - public function loadCustomPostTypes() |
|
984 | - { |
|
985 | - $this->register_custom_taxonomies = $this->loader->getShared( |
|
986 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' |
|
987 | - ); |
|
988 | - $this->register_custom_post_types = $this->loader->getShared( |
|
989 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' |
|
990 | - ); |
|
991 | - $this->register_custom_taxonomy_terms = $this->loader->getShared( |
|
992 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms' |
|
993 | - ); |
|
994 | - // integrate WP_Query with the EE models |
|
995 | - $this->loader->getShared('EE_CPT_Strategy'); |
|
996 | - // load legacy EE_Request_Handler in case add-ons still need it |
|
997 | - $this->loader->getShared('EE_Request_Handler'); |
|
998 | - } |
|
999 | - |
|
1000 | - |
|
1001 | - /** |
|
1002 | - * register_shortcodes_modules_and_widgets |
|
1003 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
1004 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
1005 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
1006 | - * |
|
1007 | - * @access public |
|
1008 | - * @return void |
|
1009 | - * @throws Exception |
|
1010 | - */ |
|
1011 | - public function register_shortcodes_modules_and_widgets() |
|
1012 | - { |
|
1013 | - if ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isAjax()) { |
|
1014 | - // load, register, and add shortcodes the new way |
|
1015 | - $this->loader->getShared('EventEspresso\core\services\shortcodes\ShortcodesManager'); |
|
1016 | - } |
|
1017 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
1018 | - // check for addons using old hook point |
|
1019 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
1020 | - $this->_incompatible_addon_error(); |
|
1021 | - } |
|
1022 | - } |
|
1023 | - |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * _incompatible_addon_error |
|
1027 | - * |
|
1028 | - * @access public |
|
1029 | - * @return void |
|
1030 | - */ |
|
1031 | - private function _incompatible_addon_error() |
|
1032 | - { |
|
1033 | - // get array of classes hooking into here |
|
1034 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
1035 | - 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
1036 | - ); |
|
1037 | - if (! empty($class_names)) { |
|
1038 | - $msg = esc_html__( |
|
1039 | - 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
1040 | - 'event_espresso' |
|
1041 | - ); |
|
1042 | - $msg .= '<ul>'; |
|
1043 | - foreach ($class_names as $class_name) { |
|
1044 | - $msg .= '<li><b>Event Espresso - ' |
|
1045 | - . str_replace( |
|
1046 | - array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
|
1047 | - '', |
|
1048 | - $class_name |
|
1049 | - ) . '</b></li>'; |
|
1050 | - } |
|
1051 | - $msg .= '</ul>'; |
|
1052 | - $msg .= esc_html__( |
|
1053 | - 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
1054 | - 'event_espresso' |
|
1055 | - ); |
|
1056 | - // save list of incompatible addons to wp-options for later use |
|
1057 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
1058 | - if (is_admin()) { |
|
1059 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1060 | - } |
|
1061 | - } |
|
1062 | - } |
|
1063 | - |
|
1064 | - |
|
1065 | - /** |
|
1066 | - * brew_espresso |
|
1067 | - * begins the process of setting hooks for initializing EE in the correct order |
|
1068 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
1069 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
1070 | - * |
|
1071 | - * @return void |
|
1072 | - */ |
|
1073 | - public function brew_espresso() |
|
1074 | - { |
|
1075 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
1076 | - // load some final core systems |
|
1077 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
1078 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
1079 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
1080 | - add_action('init', array($this, 'load_controllers'), 7); |
|
1081 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
1082 | - add_action('init', array($this, 'initialize'), 10); |
|
1083 | - add_action('init', array($this, 'initialize_last'), 100); |
|
1084 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
1085 | - // pew pew pew |
|
1086 | - $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService'); |
|
1087 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
1088 | - } |
|
1089 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
1090 | - } |
|
1091 | - |
|
1092 | - |
|
1093 | - /** |
|
1094 | - * set_hooks_for_core |
|
1095 | - * |
|
1096 | - * @access public |
|
1097 | - * @return void |
|
1098 | - * @throws EE_Error |
|
1099 | - */ |
|
1100 | - public function set_hooks_for_core() |
|
1101 | - { |
|
1102 | - $this->_deactivate_incompatible_addons(); |
|
1103 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
1104 | - $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan'); |
|
1105 | - // caps need to be initialized on every request so that capability maps are set. |
|
1106 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
1107 | - $this->registry->CAP->init_caps(); |
|
1108 | - } |
|
1109 | - |
|
1110 | - |
|
1111 | - /** |
|
1112 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
1113 | - * deactivates any addons considered incompatible with the current version of EE |
|
1114 | - */ |
|
1115 | - private function _deactivate_incompatible_addons() |
|
1116 | - { |
|
1117 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
1118 | - if (! empty($incompatible_addons)) { |
|
1119 | - $active_plugins = get_option('active_plugins', array()); |
|
1120 | - foreach ($active_plugins as $active_plugin) { |
|
1121 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
1122 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
1123 | - $this->request->unSetRequestParams(['activate'], true); |
|
1124 | - espresso_deactivate_plugin($active_plugin); |
|
1125 | - } |
|
1126 | - } |
|
1127 | - } |
|
1128 | - } |
|
1129 | - } |
|
1130 | - |
|
1131 | - |
|
1132 | - /** |
|
1133 | - * perform_activations_upgrades_and_migrations |
|
1134 | - * |
|
1135 | - * @access public |
|
1136 | - * @return void |
|
1137 | - */ |
|
1138 | - public function perform_activations_upgrades_and_migrations() |
|
1139 | - { |
|
1140 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
1141 | - } |
|
1142 | - |
|
1143 | - |
|
1144 | - /** |
|
1145 | - * @return void |
|
1146 | - * @throws DomainException |
|
1147 | - */ |
|
1148 | - public function load_CPTs_and_session() |
|
1149 | - { |
|
1150 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
1151 | - $this->register_custom_taxonomies->registerCustomTaxonomies(); |
|
1152 | - $this->register_custom_post_types->registerCustomPostTypes(); |
|
1153 | - $this->register_custom_taxonomy_terms->registerCustomTaxonomyTerms(); |
|
1154 | - // load legacy Custom Post Types and Taxonomies |
|
1155 | - $this->loader->getShared('EE_Register_CPTs'); |
|
1156 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
1157 | - } |
|
1158 | - |
|
1159 | - |
|
1160 | - /** |
|
1161 | - * load_controllers |
|
1162 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
1163 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
1164 | - * time |
|
1165 | - * |
|
1166 | - * @access public |
|
1167 | - * @return void |
|
1168 | - */ |
|
1169 | - public function load_controllers() |
|
1170 | - { |
|
1171 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
1172 | - // let's get it started |
|
1173 | - if ( |
|
1174 | - ! $this->maintenance_mode->level() |
|
1175 | - && ($this->request->isFrontend() || $this->request->isFrontAjax()) |
|
1176 | - ) { |
|
1177 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
1178 | - $this->loader->getShared('EE_Front_Controller'); |
|
1179 | - } elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) { |
|
1180 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
1181 | - $this->loader->getShared('EE_Admin'); |
|
1182 | - } elseif ($this->request->isWordPressHeartbeat()) { |
|
1183 | - $this->loader->getShared('EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'); |
|
1184 | - } |
|
1185 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
1186 | - } |
|
1187 | - |
|
1188 | - |
|
1189 | - /** |
|
1190 | - * core_loaded_and_ready |
|
1191 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
1192 | - * |
|
1193 | - * @access public |
|
1194 | - * @return void |
|
1195 | - * @throws Exception |
|
1196 | - */ |
|
1197 | - public function core_loaded_and_ready() |
|
1198 | - { |
|
1199 | - if ( |
|
1200 | - $this->request->isAdmin() |
|
1201 | - || $this->request->isFrontend() |
|
1202 | - || $this->request->isIframe() |
|
1203 | - || $this->request->isWordPressApi() |
|
1204 | - ) { |
|
1205 | - try { |
|
1206 | - $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
1207 | - $this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager'); |
|
1208 | - if ($this->canLoadBlocks()) { |
|
1209 | - $this->loader->getShared( |
|
1210 | - 'EventEspresso\core\services\editor\BlockRegistrationManager' |
|
1211 | - ); |
|
1212 | - } |
|
1213 | - } catch (Exception $exception) { |
|
1214 | - new ExceptionStackTraceDisplay($exception); |
|
1215 | - } |
|
1216 | - } |
|
1217 | - if ( |
|
1218 | - $this->request->isAdmin() |
|
1219 | - || $this->request->isEeAjax() |
|
1220 | - || $this->request->isFrontend() |
|
1221 | - ) { |
|
1222 | - $this->loader->getShared('EE_Session'); |
|
1223 | - } |
|
1224 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
1225 | - // always load template tags, because it's faster than checking if it's a front-end request, and many page |
|
1226 | - // builders require these even on the front-end |
|
1227 | - require_once EE_PUBLIC . 'template_tags.php'; |
|
1228 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
1229 | - } |
|
1230 | - |
|
1231 | - |
|
1232 | - /** |
|
1233 | - * initialize |
|
1234 | - * this is the best place to begin initializing client code |
|
1235 | - * |
|
1236 | - * @access public |
|
1237 | - * @return void |
|
1238 | - */ |
|
1239 | - public function initialize() |
|
1240 | - { |
|
1241 | - do_action('AHEE__EE_System__initialize'); |
|
1242 | - add_filter( |
|
1243 | - 'safe_style_css', |
|
1244 | - function ($styles) { |
|
1245 | - $styles[] = 'display'; |
|
1246 | - $styles[] = 'visibility'; |
|
1247 | - return $styles; |
|
1248 | - } |
|
1249 | - ); |
|
1250 | - } |
|
1251 | - |
|
1252 | - |
|
1253 | - /** |
|
1254 | - * initialize_last |
|
1255 | - * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
1256 | - * initialize has done so |
|
1257 | - * |
|
1258 | - * @access public |
|
1259 | - * @return void |
|
1260 | - */ |
|
1261 | - public function initialize_last() |
|
1262 | - { |
|
1263 | - do_action('AHEE__EE_System__initialize_last'); |
|
1264 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
1265 | - $rewrite_rules = $this->loader->getShared( |
|
1266 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
1267 | - ); |
|
1268 | - $rewrite_rules->flushRewriteRules(); |
|
1269 | - add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
1270 | - if ( |
|
1271 | - ($this->request->isAjax() || $this->request->isAdmin()) |
|
1272 | - && $this->maintenance_mode->models_can_query() |
|
1273 | - ) { |
|
1274 | - $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager'); |
|
1275 | - $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager'); |
|
1276 | - } |
|
1277 | - } |
|
1278 | - |
|
1279 | - |
|
1280 | - /** |
|
1281 | - * @return void |
|
1282 | - * @throws EE_Error |
|
1283 | - */ |
|
1284 | - public function addEspressoToolbar() |
|
1285 | - { |
|
1286 | - $this->loader->getShared( |
|
1287 | - 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
1288 | - array($this->registry->CAP) |
|
1289 | - ); |
|
1290 | - } |
|
1291 | - |
|
1292 | - |
|
1293 | - /** |
|
1294 | - * do_not_cache |
|
1295 | - * sets no cache headers and defines no cache constants for WP plugins |
|
1296 | - * |
|
1297 | - * @access public |
|
1298 | - * @return void |
|
1299 | - */ |
|
1300 | - public static function do_not_cache() |
|
1301 | - { |
|
1302 | - // set no cache constants |
|
1303 | - if (! defined('DONOTCACHEPAGE')) { |
|
1304 | - define('DONOTCACHEPAGE', true); |
|
1305 | - } |
|
1306 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
1307 | - define('DONOTCACHCEOBJECT', true); |
|
1308 | - } |
|
1309 | - if (! defined('DONOTCACHEDB')) { |
|
1310 | - define('DONOTCACHEDB', true); |
|
1311 | - } |
|
1312 | - // add no cache headers |
|
1313 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1314 | - // plus a little extra for nginx and Google Chrome |
|
1315 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1316 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1317 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1318 | - } |
|
1319 | - |
|
1320 | - |
|
1321 | - /** |
|
1322 | - * extra_nocache_headers |
|
1323 | - * |
|
1324 | - * @access public |
|
1325 | - * @param $headers |
|
1326 | - * @return array |
|
1327 | - */ |
|
1328 | - public static function extra_nocache_headers($headers) |
|
1329 | - { |
|
1330 | - // for NGINX |
|
1331 | - $headers['X-Accel-Expires'] = 0; |
|
1332 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1333 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1334 | - return $headers; |
|
1335 | - } |
|
1336 | - |
|
1337 | - |
|
1338 | - /** |
|
1339 | - * nocache_headers |
|
1340 | - * |
|
1341 | - * @access public |
|
1342 | - * @return void |
|
1343 | - */ |
|
1344 | - public static function nocache_headers() |
|
1345 | - { |
|
1346 | - nocache_headers(); |
|
1347 | - } |
|
1348 | - |
|
1349 | - |
|
1350 | - /** |
|
1351 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1352 | - * never returned with the function. |
|
1353 | - * |
|
1354 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
1355 | - * @return array |
|
1356 | - */ |
|
1357 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
1358 | - { |
|
1359 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1360 | - } |
|
1361 | - |
|
1362 | - |
|
1363 | - /** |
|
1364 | - * Return whether blocks can be registered/loaded or not. |
|
1365 | - * @return bool |
|
1366 | - */ |
|
1367 | - private function canLoadBlocks() |
|
1368 | - { |
|
1369 | - return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
|
1370 | - && function_exists('register_block_type') |
|
1371 | - // don't load blocks if in the Divi page builder editor context |
|
1372 | - // @see https://github.com/eventespresso/event-espresso-core/issues/814 |
|
1373 | - && ! $this->request->getRequestParam('et_fb', false); |
|
1374 | - } |
|
30 | + /** |
|
31 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
32 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
33 | + */ |
|
34 | + const req_type_normal = 0; |
|
35 | + |
|
36 | + /** |
|
37 | + * Indicates this is a brand new installation of EE so we should install |
|
38 | + * tables and default data etc |
|
39 | + */ |
|
40 | + const req_type_new_activation = 1; |
|
41 | + |
|
42 | + /** |
|
43 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
44 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
45 | + * and that default data is setup too |
|
46 | + */ |
|
47 | + const req_type_reactivation = 2; |
|
48 | + |
|
49 | + /** |
|
50 | + * indicates that EE has been upgraded since its previous request. |
|
51 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
52 | + */ |
|
53 | + const req_type_upgrade = 3; |
|
54 | + |
|
55 | + /** |
|
56 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
57 | + */ |
|
58 | + const req_type_downgrade = 4; |
|
59 | + |
|
60 | + /** |
|
61 | + * @deprecated since version 4.6.0.dev.006 |
|
62 | + * Now whenever a new_activation is detected the request type is still just |
|
63 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
64 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
65 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
66 | + * (Specifically, when the migration manager indicates migrations are finished |
|
67 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
68 | + */ |
|
69 | + const req_type_activation_but_not_installed = 5; |
|
70 | + |
|
71 | + /** |
|
72 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
73 | + */ |
|
74 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
75 | + |
|
76 | + /** |
|
77 | + * @var EE_System $_instance |
|
78 | + */ |
|
79 | + private static $_instance; |
|
80 | + |
|
81 | + /** |
|
82 | + * @var EE_Registry $registry |
|
83 | + */ |
|
84 | + private $registry; |
|
85 | + |
|
86 | + /** |
|
87 | + * @var LoaderInterface $loader |
|
88 | + */ |
|
89 | + private $loader; |
|
90 | + |
|
91 | + /** |
|
92 | + * @var EE_Capabilities $capabilities |
|
93 | + */ |
|
94 | + private $capabilities; |
|
95 | + |
|
96 | + /** |
|
97 | + * @var RequestInterface $request |
|
98 | + */ |
|
99 | + private $request; |
|
100 | + |
|
101 | + /** |
|
102 | + * @var EE_Maintenance_Mode $maintenance_mode |
|
103 | + */ |
|
104 | + private $maintenance_mode; |
|
105 | + |
|
106 | + /** |
|
107 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
108 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
109 | + * |
|
110 | + * @var int $_req_type |
|
111 | + */ |
|
112 | + private $_req_type; |
|
113 | + |
|
114 | + /** |
|
115 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
116 | + * |
|
117 | + * @var boolean $_major_version_change |
|
118 | + */ |
|
119 | + private $_major_version_change = false; |
|
120 | + |
|
121 | + /** |
|
122 | + * A Context DTO dedicated solely to identifying the current request type. |
|
123 | + * |
|
124 | + * @var RequestTypeContextCheckerInterface $request_type |
|
125 | + */ |
|
126 | + private $request_type; |
|
127 | + |
|
128 | + /** |
|
129 | + * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes |
|
130 | + */ |
|
131 | + private $register_custom_post_types; |
|
132 | + |
|
133 | + /** |
|
134 | + * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies |
|
135 | + */ |
|
136 | + private $register_custom_taxonomies; |
|
137 | + |
|
138 | + /** |
|
139 | + * @param EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms |
|
140 | + */ |
|
141 | + private $register_custom_taxonomy_terms; |
|
142 | + |
|
143 | + /** |
|
144 | + * @singleton method used to instantiate class object |
|
145 | + * @param EE_Registry|null $registry |
|
146 | + * @param LoaderInterface|null $loader |
|
147 | + * @param RequestInterface|null $request |
|
148 | + * @param EE_Maintenance_Mode|null $maintenance_mode |
|
149 | + * @return EE_System |
|
150 | + */ |
|
151 | + public static function instance( |
|
152 | + EE_Registry $registry = null, |
|
153 | + LoaderInterface $loader = null, |
|
154 | + RequestInterface $request = null, |
|
155 | + EE_Maintenance_Mode $maintenance_mode = null |
|
156 | + ) { |
|
157 | + // check if class object is instantiated |
|
158 | + if (! self::$_instance instanceof EE_System) { |
|
159 | + self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
|
160 | + } |
|
161 | + return self::$_instance; |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * resets the instance and returns it |
|
167 | + * |
|
168 | + * @return EE_System |
|
169 | + */ |
|
170 | + public static function reset() |
|
171 | + { |
|
172 | + self::$_instance->_req_type = null; |
|
173 | + // make sure none of the old hooks are left hanging around |
|
174 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
175 | + // we need to reset the migration manager in order for it to detect DMSs properly |
|
176 | + EE_Data_Migration_Manager::reset(); |
|
177 | + self::instance()->detect_activations_or_upgrades(); |
|
178 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
179 | + return self::instance(); |
|
180 | + } |
|
181 | + |
|
182 | + |
|
183 | + /** |
|
184 | + * sets hooks for running rest of system |
|
185 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
186 | + * starting EE Addons from any other point may lead to problems |
|
187 | + * |
|
188 | + * @param EE_Registry $registry |
|
189 | + * @param LoaderInterface $loader |
|
190 | + * @param RequestInterface $request |
|
191 | + * @param EE_Maintenance_Mode $maintenance_mode |
|
192 | + */ |
|
193 | + private function __construct( |
|
194 | + EE_Registry $registry, |
|
195 | + LoaderInterface $loader, |
|
196 | + RequestInterface $request, |
|
197 | + EE_Maintenance_Mode $maintenance_mode |
|
198 | + ) { |
|
199 | + $this->registry = $registry; |
|
200 | + $this->loader = $loader; |
|
201 | + $this->request = $request; |
|
202 | + $this->maintenance_mode = $maintenance_mode; |
|
203 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
204 | + add_action( |
|
205 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
206 | + array($this, 'loadCapabilities'), |
|
207 | + 5 |
|
208 | + ); |
|
209 | + add_action( |
|
210 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
211 | + array($this, 'loadCommandBus'), |
|
212 | + 7 |
|
213 | + ); |
|
214 | + add_action( |
|
215 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
216 | + array($this, 'loadPluginApi'), |
|
217 | + 9 |
|
218 | + ); |
|
219 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
220 | + add_action( |
|
221 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
222 | + array($this, 'load_espresso_addons') |
|
223 | + ); |
|
224 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
225 | + // because the newly-activated addon didn't get a chance to run at all |
|
226 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
227 | + // detect whether install or upgrade |
|
228 | + add_action( |
|
229 | + 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
230 | + array($this, 'detect_activations_or_upgrades'), |
|
231 | + 3 |
|
232 | + ); |
|
233 | + // load EE_Config, EE_Textdomain, etc |
|
234 | + add_action( |
|
235 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
236 | + array($this, 'load_core_configuration'), |
|
237 | + 5 |
|
238 | + ); |
|
239 | + // load specifications for matching routes to current request |
|
240 | + add_action( |
|
241 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
242 | + array($this, 'loadRouteMatchSpecifications') |
|
243 | + ); |
|
244 | + // load specifications for custom post types |
|
245 | + add_action( |
|
246 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
247 | + array($this, 'loadCustomPostTypes') |
|
248 | + ); |
|
249 | + // load EE_Config, EE_Textdomain, etc |
|
250 | + add_action( |
|
251 | + 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
252 | + array($this, 'register_shortcodes_modules_and_widgets'), |
|
253 | + 7 |
|
254 | + ); |
|
255 | + // you wanna get going? I wanna get going... let's get going! |
|
256 | + add_action( |
|
257 | + 'AHEE__EE_Bootstrap__brew_espresso', |
|
258 | + array($this, 'brew_espresso'), |
|
259 | + 9 |
|
260 | + ); |
|
261 | + // other housekeeping |
|
262 | + // exclude EE critical pages from wp_list_pages |
|
263 | + add_filter( |
|
264 | + 'wp_list_pages_excludes', |
|
265 | + array($this, 'remove_pages_from_wp_list_pages'), |
|
266 | + 10 |
|
267 | + ); |
|
268 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
269 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
270 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * load and setup EE_Capabilities |
|
276 | + * |
|
277 | + * @return void |
|
278 | + * @throws EE_Error |
|
279 | + */ |
|
280 | + public function loadCapabilities() |
|
281 | + { |
|
282 | + $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
|
283 | + add_action( |
|
284 | + 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
285 | + function () { |
|
286 | + LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
287 | + } |
|
288 | + ); |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + /** |
|
293 | + * create and cache the CommandBus, and also add middleware |
|
294 | + * The CapChecker middleware requires the use of EE_Capabilities |
|
295 | + * which is why we need to load the CommandBus after Caps are set up |
|
296 | + * |
|
297 | + * @return void |
|
298 | + * @throws EE_Error |
|
299 | + */ |
|
300 | + public function loadCommandBus() |
|
301 | + { |
|
302 | + $this->loader->getShared( |
|
303 | + 'CommandBusInterface', |
|
304 | + array( |
|
305 | + null, |
|
306 | + apply_filters( |
|
307 | + 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
308 | + array( |
|
309 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
310 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
311 | + ) |
|
312 | + ), |
|
313 | + ) |
|
314 | + ); |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * @return void |
|
320 | + * @throws EE_Error |
|
321 | + */ |
|
322 | + public function loadPluginApi() |
|
323 | + { |
|
324 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
325 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
326 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * @param string $addon_name |
|
332 | + * @param string $version_constant |
|
333 | + * @param string $min_version_required |
|
334 | + * @param string $load_callback |
|
335 | + * @param string $plugin_file_constant |
|
336 | + * @return void |
|
337 | + */ |
|
338 | + private function deactivateIncompatibleAddon( |
|
339 | + $addon_name, |
|
340 | + $version_constant, |
|
341 | + $min_version_required, |
|
342 | + $load_callback, |
|
343 | + $plugin_file_constant |
|
344 | + ) { |
|
345 | + if (! defined($version_constant)) { |
|
346 | + return; |
|
347 | + } |
|
348 | + $addon_version = constant($version_constant); |
|
349 | + if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
|
350 | + remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
|
351 | + if (! function_exists('deactivate_plugins')) { |
|
352 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
353 | + } |
|
354 | + deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
|
355 | + $this->request->unSetRequestParams(['activate', 'activate-multi'], true); |
|
356 | + EE_Error::add_error( |
|
357 | + sprintf( |
|
358 | + esc_html__( |
|
359 | + 'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.', |
|
360 | + 'event_espresso' |
|
361 | + ), |
|
362 | + $addon_name, |
|
363 | + $min_version_required |
|
364 | + ), |
|
365 | + __FILE__, |
|
366 | + __FUNCTION__ . "({$addon_name})", |
|
367 | + __LINE__ |
|
368 | + ); |
|
369 | + EE_Error::get_notices(false, true); |
|
370 | + } |
|
371 | + } |
|
372 | + |
|
373 | + |
|
374 | + /** |
|
375 | + * load_espresso_addons |
|
376 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
377 | + * this is hooked into both: |
|
378 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
379 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
380 | + * and the WP 'activate_plugin' hook point |
|
381 | + * |
|
382 | + * @access public |
|
383 | + * @return void |
|
384 | + */ |
|
385 | + public function load_espresso_addons() |
|
386 | + { |
|
387 | + $this->deactivateIncompatibleAddon( |
|
388 | + 'Wait Lists', |
|
389 | + 'EE_WAIT_LISTS_VERSION', |
|
390 | + '1.0.0.beta.074', |
|
391 | + 'load_espresso_wait_lists', |
|
392 | + 'EE_WAIT_LISTS_PLUGIN_FILE' |
|
393 | + ); |
|
394 | + $this->deactivateIncompatibleAddon( |
|
395 | + 'Automated Upcoming Event Notifications', |
|
396 | + 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION', |
|
397 | + '1.0.0.beta.091', |
|
398 | + 'load_espresso_automated_upcoming_event_notification', |
|
399 | + 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE' |
|
400 | + ); |
|
401 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
402 | + // if the WP API basic auth plugin isn't already loaded, load it now. |
|
403 | + // We want it for mobile apps. Just include the entire plugin |
|
404 | + // also, don't load the basic auth when a plugin is getting activated, because |
|
405 | + // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
406 | + // and causes a fatal error |
|
407 | + if ( |
|
408 | + ($this->request->isWordPressApi() || $this->request->isApi()) |
|
409 | + && $this->request->getRequestParam('activate') !== 'true' |
|
410 | + && ! function_exists('json_basic_auth_handler') |
|
411 | + && ! function_exists('json_basic_auth_error') |
|
412 | + && ! in_array( |
|
413 | + $this->request->getRequestParam('action'), |
|
414 | + array('activate', 'activate-selected'), |
|
415 | + true |
|
416 | + ) |
|
417 | + ) { |
|
418 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
419 | + } |
|
420 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
421 | + } |
|
422 | + |
|
423 | + |
|
424 | + /** |
|
425 | + * detect_activations_or_upgrades |
|
426 | + * Checks for activation or upgrade of core first; |
|
427 | + * then also checks if any registered addons have been activated or upgraded |
|
428 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
429 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
430 | + * |
|
431 | + * @access public |
|
432 | + * @return void |
|
433 | + */ |
|
434 | + public function detect_activations_or_upgrades() |
|
435 | + { |
|
436 | + // first off: let's make sure to handle core |
|
437 | + $this->detect_if_activation_or_upgrade(); |
|
438 | + foreach ($this->registry->addons as $addon) { |
|
439 | + if ($addon instanceof EE_Addon) { |
|
440 | + // detect teh request type for that addon |
|
441 | + $addon->detect_req_type(); |
|
442 | + } |
|
443 | + } |
|
444 | + } |
|
445 | + |
|
446 | + |
|
447 | + /** |
|
448 | + * detect_if_activation_or_upgrade |
|
449 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
450 | + * and either setting up the DB or setting up maintenance mode etc. |
|
451 | + * |
|
452 | + * @access public |
|
453 | + * @return void |
|
454 | + */ |
|
455 | + public function detect_if_activation_or_upgrade() |
|
456 | + { |
|
457 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
458 | + // check if db has been updated, or if its a brand-new installation |
|
459 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
460 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
461 | + // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
462 | + switch ($request_type) { |
|
463 | + case EE_System::req_type_new_activation: |
|
464 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
465 | + $this->_handle_core_version_change($espresso_db_update); |
|
466 | + break; |
|
467 | + case EE_System::req_type_reactivation: |
|
468 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
469 | + $this->_handle_core_version_change($espresso_db_update); |
|
470 | + break; |
|
471 | + case EE_System::req_type_upgrade: |
|
472 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
473 | + // migrations may be required now that we've upgraded |
|
474 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
475 | + $this->_handle_core_version_change($espresso_db_update); |
|
476 | + break; |
|
477 | + case EE_System::req_type_downgrade: |
|
478 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
479 | + // its possible migrations are no longer required |
|
480 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
481 | + $this->_handle_core_version_change($espresso_db_update); |
|
482 | + break; |
|
483 | + case EE_System::req_type_normal: |
|
484 | + default: |
|
485 | + break; |
|
486 | + } |
|
487 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
488 | + } |
|
489 | + |
|
490 | + |
|
491 | + /** |
|
492 | + * Updates the list of installed versions and sets hooks for |
|
493 | + * initializing the database later during the request |
|
494 | + * |
|
495 | + * @param array $espresso_db_update |
|
496 | + */ |
|
497 | + private function _handle_core_version_change($espresso_db_update) |
|
498 | + { |
|
499 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
500 | + // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
501 | + add_action( |
|
502 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
503 | + array($this, 'initialize_db_if_no_migrations_required') |
|
504 | + ); |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + /** |
|
509 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
510 | + * information about what versions of EE have been installed and activated, |
|
511 | + * NOT necessarily the state of the database |
|
512 | + * |
|
513 | + * @param mixed $espresso_db_update the value of the WordPress option. |
|
514 | + * If not supplied, fetches it from the options table |
|
515 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
516 | + */ |
|
517 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
518 | + { |
|
519 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
520 | + if (! $espresso_db_update) { |
|
521 | + $espresso_db_update = get_option('espresso_db_update'); |
|
522 | + } |
|
523 | + // check that option is an array |
|
524 | + if (! is_array($espresso_db_update)) { |
|
525 | + // if option is FALSE, then it never existed |
|
526 | + if ($espresso_db_update === false) { |
|
527 | + // make $espresso_db_update an array and save option with autoload OFF |
|
528 | + $espresso_db_update = array(); |
|
529 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
530 | + } else { |
|
531 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
532 | + $espresso_db_update = array($espresso_db_update => array()); |
|
533 | + update_option('espresso_db_update', $espresso_db_update); |
|
534 | + } |
|
535 | + } else { |
|
536 | + $corrected_db_update = array(); |
|
537 | + // if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
538 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
539 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
540 | + // the key is an int, and the value IS NOT an array |
|
541 | + // so it must be numerically-indexed, where values are versions installed... |
|
542 | + // fix it! |
|
543 | + $version_string = $should_be_array; |
|
544 | + $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
545 | + } else { |
|
546 | + // ok it checks out |
|
547 | + $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
548 | + } |
|
549 | + } |
|
550 | + $espresso_db_update = $corrected_db_update; |
|
551 | + update_option('espresso_db_update', $espresso_db_update); |
|
552 | + } |
|
553 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
554 | + return $espresso_db_update; |
|
555 | + } |
|
556 | + |
|
557 | + |
|
558 | + /** |
|
559 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
560 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
561 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
562 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
563 | + * so that it will be done when migrations are finished |
|
564 | + * |
|
565 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
566 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
567 | + * This is a resource-intensive job |
|
568 | + * so we prefer to only do it when necessary |
|
569 | + * @return void |
|
570 | + * @throws EE_Error |
|
571 | + */ |
|
572 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
573 | + { |
|
574 | + $request_type = $this->detect_req_type(); |
|
575 | + // only initialize system if we're not in maintenance mode. |
|
576 | + if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
577 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
578 | + $rewrite_rules = $this->loader->getShared( |
|
579 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
580 | + ); |
|
581 | + $rewrite_rules->flush(); |
|
582 | + if ($verify_schema) { |
|
583 | + EEH_Activation::initialize_db_and_folders(); |
|
584 | + } |
|
585 | + EEH_Activation::initialize_db_content(); |
|
586 | + EEH_Activation::system_initialization(); |
|
587 | + if ($initialize_addons_too) { |
|
588 | + $this->initialize_addons(); |
|
589 | + } |
|
590 | + } else { |
|
591 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
592 | + } |
|
593 | + if ( |
|
594 | + $request_type === EE_System::req_type_new_activation |
|
595 | + || $request_type === EE_System::req_type_reactivation |
|
596 | + || ( |
|
597 | + $request_type === EE_System::req_type_upgrade |
|
598 | + && $this->is_major_version_change() |
|
599 | + ) |
|
600 | + ) { |
|
601 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
602 | + } |
|
603 | + } |
|
604 | + |
|
605 | + |
|
606 | + /** |
|
607 | + * Initializes the db for all registered addons |
|
608 | + * |
|
609 | + * @throws EE_Error |
|
610 | + */ |
|
611 | + public function initialize_addons() |
|
612 | + { |
|
613 | + // foreach registered addon, make sure its db is up-to-date too |
|
614 | + foreach ($this->registry->addons as $addon) { |
|
615 | + if ($addon instanceof EE_Addon) { |
|
616 | + $addon->initialize_db_if_no_migrations_required(); |
|
617 | + } |
|
618 | + } |
|
619 | + } |
|
620 | + |
|
621 | + |
|
622 | + /** |
|
623 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
624 | + * |
|
625 | + * @param array $version_history |
|
626 | + * @param string $current_version_to_add version to be added to the version history |
|
627 | + * @return boolean success as to whether or not this option was changed |
|
628 | + */ |
|
629 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
630 | + { |
|
631 | + if (! $version_history) { |
|
632 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
633 | + } |
|
634 | + if ($current_version_to_add === null) { |
|
635 | + $current_version_to_add = espresso_version(); |
|
636 | + } |
|
637 | + $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
638 | + // re-save |
|
639 | + return update_option('espresso_db_update', $version_history); |
|
640 | + } |
|
641 | + |
|
642 | + |
|
643 | + /** |
|
644 | + * Detects if the current version indicated in the has existed in the list of |
|
645 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
646 | + * |
|
647 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
648 | + * If not supplied, fetches it from the options table. |
|
649 | + * Also, caches its result so later parts of the code can also know whether |
|
650 | + * there's been an update or not. This way we can add the current version to |
|
651 | + * espresso_db_update, but still know if this is a new install or not |
|
652 | + * @return int one of the constants on EE_System::req_type_ |
|
653 | + */ |
|
654 | + public function detect_req_type($espresso_db_update = null) |
|
655 | + { |
|
656 | + if ($this->_req_type === null) { |
|
657 | + $espresso_db_update = ! empty($espresso_db_update) |
|
658 | + ? $espresso_db_update |
|
659 | + : $this->fix_espresso_db_upgrade_option(); |
|
660 | + $this->_req_type = EE_System::detect_req_type_given_activation_history( |
|
661 | + $espresso_db_update, |
|
662 | + 'ee_espresso_activation', |
|
663 | + espresso_version() |
|
664 | + ); |
|
665 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
666 | + $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal); |
|
667 | + } |
|
668 | + return $this->_req_type; |
|
669 | + } |
|
670 | + |
|
671 | + |
|
672 | + /** |
|
673 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
674 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
675 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
676 | + * |
|
677 | + * @param $activation_history |
|
678 | + * @return bool |
|
679 | + */ |
|
680 | + private function _detect_major_version_change($activation_history) |
|
681 | + { |
|
682 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
683 | + $previous_version_parts = explode('.', $previous_version); |
|
684 | + $current_version_parts = explode('.', espresso_version()); |
|
685 | + return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
686 | + && ($previous_version_parts[0] !== $current_version_parts[0] |
|
687 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
688 | + ); |
|
689 | + } |
|
690 | + |
|
691 | + |
|
692 | + /** |
|
693 | + * Returns true if either the major or minor version of EE changed during this request. |
|
694 | + * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
695 | + * |
|
696 | + * @return bool |
|
697 | + */ |
|
698 | + public function is_major_version_change() |
|
699 | + { |
|
700 | + return $this->_major_version_change; |
|
701 | + } |
|
702 | + |
|
703 | + |
|
704 | + /** |
|
705 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
706 | + * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
|
707 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
708 | + * just activated to (for core that will always be espresso_version()) |
|
709 | + * |
|
710 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
711 | + * ee plugin. for core that's 'espresso_db_update' |
|
712 | + * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
|
713 | + * indicate that this plugin was just activated |
|
714 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
715 | + * espresso_version()) |
|
716 | + * @return int one of the constants on EE_System::req_type_* |
|
717 | + */ |
|
718 | + public static function detect_req_type_given_activation_history( |
|
719 | + $activation_history_for_addon, |
|
720 | + $activation_indicator_option_name, |
|
721 | + $version_to_upgrade_to |
|
722 | + ) { |
|
723 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
724 | + if ($activation_history_for_addon) { |
|
725 | + // it exists, so this isn't a completely new install |
|
726 | + // check if this version already in that list of previously installed versions |
|
727 | + if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
728 | + // it a version we haven't seen before |
|
729 | + if ($version_is_higher === 1) { |
|
730 | + $req_type = EE_System::req_type_upgrade; |
|
731 | + } else { |
|
732 | + $req_type = EE_System::req_type_downgrade; |
|
733 | + } |
|
734 | + delete_option($activation_indicator_option_name); |
|
735 | + } else { |
|
736 | + // its not an update. maybe a reactivation? |
|
737 | + if (get_option($activation_indicator_option_name, false)) { |
|
738 | + if ($version_is_higher === -1) { |
|
739 | + $req_type = EE_System::req_type_downgrade; |
|
740 | + } elseif ($version_is_higher === 0) { |
|
741 | + // we've seen this version before, but it's an activation. must be a reactivation |
|
742 | + $req_type = EE_System::req_type_reactivation; |
|
743 | + } else {// $version_is_higher === 1 |
|
744 | + $req_type = EE_System::req_type_upgrade; |
|
745 | + } |
|
746 | + delete_option($activation_indicator_option_name); |
|
747 | + } else { |
|
748 | + // we've seen this version before and the activation indicate doesn't show it was just activated |
|
749 | + if ($version_is_higher === -1) { |
|
750 | + $req_type = EE_System::req_type_downgrade; |
|
751 | + } elseif ($version_is_higher === 0) { |
|
752 | + // we've seen this version before and it's not an activation. its normal request |
|
753 | + $req_type = EE_System::req_type_normal; |
|
754 | + } else {// $version_is_higher === 1 |
|
755 | + $req_type = EE_System::req_type_upgrade; |
|
756 | + } |
|
757 | + } |
|
758 | + } |
|
759 | + } else { |
|
760 | + // brand new install |
|
761 | + $req_type = EE_System::req_type_new_activation; |
|
762 | + delete_option($activation_indicator_option_name); |
|
763 | + } |
|
764 | + return $req_type; |
|
765 | + } |
|
766 | + |
|
767 | + |
|
768 | + /** |
|
769 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
770 | + * the $activation_history_for_addon |
|
771 | + * |
|
772 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
773 | + * sometimes containing 'unknown-date' |
|
774 | + * @param string $version_to_upgrade_to (current version) |
|
775 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
776 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
777 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
778 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
779 | + */ |
|
780 | + private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
781 | + { |
|
782 | + // find the most recently-activated version |
|
783 | + $most_recently_active_version = |
|
784 | + EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
785 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
786 | + } |
|
787 | + |
|
788 | + |
|
789 | + /** |
|
790 | + * Gets the most recently active version listed in the activation history, |
|
791 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
792 | + * |
|
793 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
794 | + * sometimes containing 'unknown-date' |
|
795 | + * @return string |
|
796 | + */ |
|
797 | + private static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
798 | + { |
|
799 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
800 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
801 | + if (is_array($activation_history)) { |
|
802 | + foreach ($activation_history as $version => $times_activated) { |
|
803 | + // check there is a record of when this version was activated. Otherwise, |
|
804 | + // mark it as unknown |
|
805 | + if (! $times_activated) { |
|
806 | + $times_activated = array('unknown-date'); |
|
807 | + } |
|
808 | + if (is_string($times_activated)) { |
|
809 | + $times_activated = array($times_activated); |
|
810 | + } |
|
811 | + foreach ($times_activated as $an_activation) { |
|
812 | + if ( |
|
813 | + $an_activation !== 'unknown-date' |
|
814 | + && $an_activation |
|
815 | + > $most_recently_active_version_activation |
|
816 | + ) { |
|
817 | + $most_recently_active_version = $version; |
|
818 | + $most_recently_active_version_activation = $an_activation === 'unknown-date' |
|
819 | + ? '1970-01-01 00:00:00' |
|
820 | + : $an_activation; |
|
821 | + } |
|
822 | + } |
|
823 | + } |
|
824 | + } |
|
825 | + return $most_recently_active_version; |
|
826 | + } |
|
827 | + |
|
828 | + |
|
829 | + /** |
|
830 | + * This redirects to the about EE page after activation |
|
831 | + * |
|
832 | + * @return void |
|
833 | + */ |
|
834 | + public function redirect_to_about_ee() |
|
835 | + { |
|
836 | + $notices = EE_Error::get_notices(false); |
|
837 | + // if current user is an admin and it's not an ajax or rest request |
|
838 | + if ( |
|
839 | + ! isset($notices['errors']) |
|
840 | + && $this->request->isAdmin() |
|
841 | + && apply_filters( |
|
842 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
843 | + $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
844 | + ) |
|
845 | + ) { |
|
846 | + $query_params = array('page' => 'espresso_about'); |
|
847 | + if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) { |
|
848 | + $query_params['new_activation'] = true; |
|
849 | + } |
|
850 | + if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) { |
|
851 | + $query_params['reactivation'] = true; |
|
852 | + } |
|
853 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
854 | + wp_safe_redirect($url); |
|
855 | + exit(); |
|
856 | + } |
|
857 | + } |
|
858 | + |
|
859 | + |
|
860 | + /** |
|
861 | + * load_core_configuration |
|
862 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
863 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
864 | + * |
|
865 | + * @return void |
|
866 | + * @throws ReflectionException |
|
867 | + * @throws Exception |
|
868 | + */ |
|
869 | + public function load_core_configuration() |
|
870 | + { |
|
871 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
872 | + $this->loader->getShared('EE_Load_Textdomain'); |
|
873 | + // load textdomain |
|
874 | + EE_Load_Textdomain::load_textdomain(); |
|
875 | + // load caf stuff a chance to play during the activation process too. |
|
876 | + $this->_maybe_brew_regular(); |
|
877 | + // load and setup EE_Config and EE_Network_Config |
|
878 | + $config = $this->loader->getShared('EE_Config'); |
|
879 | + $this->loader->getShared('EE_Network_Config'); |
|
880 | + // setup autoloaders |
|
881 | + // enable logging? |
|
882 | + if ($config->admin->use_remote_logging) { |
|
883 | + $this->loader->getShared('EE_Log'); |
|
884 | + } |
|
885 | + // check for activation errors |
|
886 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
887 | + if ($activation_errors) { |
|
888 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
889 | + update_option('ee_plugin_activation_errors', false); |
|
890 | + } |
|
891 | + // get model names |
|
892 | + $this->_parse_model_names(); |
|
893 | + // configure custom post type definitions |
|
894 | + $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions'); |
|
895 | + $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'); |
|
896 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
897 | + } |
|
898 | + |
|
899 | + |
|
900 | + /** |
|
901 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
902 | + * |
|
903 | + * @return void |
|
904 | + * @throws ReflectionException |
|
905 | + */ |
|
906 | + private function _parse_model_names() |
|
907 | + { |
|
908 | + // get all the files in the EE_MODELS folder that end in .model.php |
|
909 | + $models = glob(EE_MODELS . '*.model.php'); |
|
910 | + $model_names = array(); |
|
911 | + $non_abstract_db_models = array(); |
|
912 | + foreach ($models as $model) { |
|
913 | + // get model classname |
|
914 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
915 | + $short_name = str_replace('EEM_', '', $classname); |
|
916 | + $reflectionClass = new ReflectionClass($classname); |
|
917 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
918 | + $non_abstract_db_models[ $short_name ] = $classname; |
|
919 | + } |
|
920 | + $model_names[ $short_name ] = $classname; |
|
921 | + } |
|
922 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
923 | + $this->registry->non_abstract_db_models = apply_filters( |
|
924 | + 'FHEE__EE_System__parse_implemented_model_names', |
|
925 | + $non_abstract_db_models |
|
926 | + ); |
|
927 | + } |
|
928 | + |
|
929 | + |
|
930 | + /** |
|
931 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
932 | + * that need to be setup before our EE_System launches. |
|
933 | + * |
|
934 | + * @return void |
|
935 | + * @throws DomainException |
|
936 | + * @throws InvalidArgumentException |
|
937 | + * @throws InvalidDataTypeException |
|
938 | + * @throws InvalidInterfaceException |
|
939 | + * @throws InvalidClassException |
|
940 | + * @throws InvalidFilePathException |
|
941 | + */ |
|
942 | + private function _maybe_brew_regular() |
|
943 | + { |
|
944 | + /** @var Domain $domain */ |
|
945 | + $domain = DomainFactory::getShared( |
|
946 | + new FullyQualifiedName( |
|
947 | + 'EventEspresso\core\domain\Domain' |
|
948 | + ), |
|
949 | + array( |
|
950 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
951 | + Version::fromString(espresso_version()), |
|
952 | + ) |
|
953 | + ); |
|
954 | + if ($domain->isCaffeinated()) { |
|
955 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
956 | + } |
|
957 | + } |
|
958 | + |
|
959 | + |
|
960 | + /** |
|
961 | + * @since 4.9.71.p |
|
962 | + * @throws Exception |
|
963 | + */ |
|
964 | + public function loadRouteMatchSpecifications() |
|
965 | + { |
|
966 | + try { |
|
967 | + $this->loader->getShared( |
|
968 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' |
|
969 | + ); |
|
970 | + } catch (Exception $exception) { |
|
971 | + new ExceptionStackTraceDisplay($exception); |
|
972 | + } |
|
973 | + do_action('AHEE__EE_System__loadRouteMatchSpecifications'); |
|
974 | + } |
|
975 | + |
|
976 | + |
|
977 | + /** |
|
978 | + * loading CPT related classes earlier so that their definitions are available |
|
979 | + * but not performing any actual registration with WP core until load_CPTs_and_session() is called |
|
980 | + * |
|
981 | + * @since 4.10.21.p |
|
982 | + */ |
|
983 | + public function loadCustomPostTypes() |
|
984 | + { |
|
985 | + $this->register_custom_taxonomies = $this->loader->getShared( |
|
986 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' |
|
987 | + ); |
|
988 | + $this->register_custom_post_types = $this->loader->getShared( |
|
989 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' |
|
990 | + ); |
|
991 | + $this->register_custom_taxonomy_terms = $this->loader->getShared( |
|
992 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms' |
|
993 | + ); |
|
994 | + // integrate WP_Query with the EE models |
|
995 | + $this->loader->getShared('EE_CPT_Strategy'); |
|
996 | + // load legacy EE_Request_Handler in case add-ons still need it |
|
997 | + $this->loader->getShared('EE_Request_Handler'); |
|
998 | + } |
|
999 | + |
|
1000 | + |
|
1001 | + /** |
|
1002 | + * register_shortcodes_modules_and_widgets |
|
1003 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
1004 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
1005 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
1006 | + * |
|
1007 | + * @access public |
|
1008 | + * @return void |
|
1009 | + * @throws Exception |
|
1010 | + */ |
|
1011 | + public function register_shortcodes_modules_and_widgets() |
|
1012 | + { |
|
1013 | + if ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isAjax()) { |
|
1014 | + // load, register, and add shortcodes the new way |
|
1015 | + $this->loader->getShared('EventEspresso\core\services\shortcodes\ShortcodesManager'); |
|
1016 | + } |
|
1017 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
1018 | + // check for addons using old hook point |
|
1019 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
1020 | + $this->_incompatible_addon_error(); |
|
1021 | + } |
|
1022 | + } |
|
1023 | + |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * _incompatible_addon_error |
|
1027 | + * |
|
1028 | + * @access public |
|
1029 | + * @return void |
|
1030 | + */ |
|
1031 | + private function _incompatible_addon_error() |
|
1032 | + { |
|
1033 | + // get array of classes hooking into here |
|
1034 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
1035 | + 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
1036 | + ); |
|
1037 | + if (! empty($class_names)) { |
|
1038 | + $msg = esc_html__( |
|
1039 | + 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
1040 | + 'event_espresso' |
|
1041 | + ); |
|
1042 | + $msg .= '<ul>'; |
|
1043 | + foreach ($class_names as $class_name) { |
|
1044 | + $msg .= '<li><b>Event Espresso - ' |
|
1045 | + . str_replace( |
|
1046 | + array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
|
1047 | + '', |
|
1048 | + $class_name |
|
1049 | + ) . '</b></li>'; |
|
1050 | + } |
|
1051 | + $msg .= '</ul>'; |
|
1052 | + $msg .= esc_html__( |
|
1053 | + 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
1054 | + 'event_espresso' |
|
1055 | + ); |
|
1056 | + // save list of incompatible addons to wp-options for later use |
|
1057 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
1058 | + if (is_admin()) { |
|
1059 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1060 | + } |
|
1061 | + } |
|
1062 | + } |
|
1063 | + |
|
1064 | + |
|
1065 | + /** |
|
1066 | + * brew_espresso |
|
1067 | + * begins the process of setting hooks for initializing EE in the correct order |
|
1068 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
1069 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
1070 | + * |
|
1071 | + * @return void |
|
1072 | + */ |
|
1073 | + public function brew_espresso() |
|
1074 | + { |
|
1075 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
1076 | + // load some final core systems |
|
1077 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
1078 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
1079 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
1080 | + add_action('init', array($this, 'load_controllers'), 7); |
|
1081 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
1082 | + add_action('init', array($this, 'initialize'), 10); |
|
1083 | + add_action('init', array($this, 'initialize_last'), 100); |
|
1084 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
1085 | + // pew pew pew |
|
1086 | + $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService'); |
|
1087 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
1088 | + } |
|
1089 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
1090 | + } |
|
1091 | + |
|
1092 | + |
|
1093 | + /** |
|
1094 | + * set_hooks_for_core |
|
1095 | + * |
|
1096 | + * @access public |
|
1097 | + * @return void |
|
1098 | + * @throws EE_Error |
|
1099 | + */ |
|
1100 | + public function set_hooks_for_core() |
|
1101 | + { |
|
1102 | + $this->_deactivate_incompatible_addons(); |
|
1103 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
1104 | + $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan'); |
|
1105 | + // caps need to be initialized on every request so that capability maps are set. |
|
1106 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
1107 | + $this->registry->CAP->init_caps(); |
|
1108 | + } |
|
1109 | + |
|
1110 | + |
|
1111 | + /** |
|
1112 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
1113 | + * deactivates any addons considered incompatible with the current version of EE |
|
1114 | + */ |
|
1115 | + private function _deactivate_incompatible_addons() |
|
1116 | + { |
|
1117 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
1118 | + if (! empty($incompatible_addons)) { |
|
1119 | + $active_plugins = get_option('active_plugins', array()); |
|
1120 | + foreach ($active_plugins as $active_plugin) { |
|
1121 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
1122 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
1123 | + $this->request->unSetRequestParams(['activate'], true); |
|
1124 | + espresso_deactivate_plugin($active_plugin); |
|
1125 | + } |
|
1126 | + } |
|
1127 | + } |
|
1128 | + } |
|
1129 | + } |
|
1130 | + |
|
1131 | + |
|
1132 | + /** |
|
1133 | + * perform_activations_upgrades_and_migrations |
|
1134 | + * |
|
1135 | + * @access public |
|
1136 | + * @return void |
|
1137 | + */ |
|
1138 | + public function perform_activations_upgrades_and_migrations() |
|
1139 | + { |
|
1140 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
1141 | + } |
|
1142 | + |
|
1143 | + |
|
1144 | + /** |
|
1145 | + * @return void |
|
1146 | + * @throws DomainException |
|
1147 | + */ |
|
1148 | + public function load_CPTs_and_session() |
|
1149 | + { |
|
1150 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
1151 | + $this->register_custom_taxonomies->registerCustomTaxonomies(); |
|
1152 | + $this->register_custom_post_types->registerCustomPostTypes(); |
|
1153 | + $this->register_custom_taxonomy_terms->registerCustomTaxonomyTerms(); |
|
1154 | + // load legacy Custom Post Types and Taxonomies |
|
1155 | + $this->loader->getShared('EE_Register_CPTs'); |
|
1156 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
1157 | + } |
|
1158 | + |
|
1159 | + |
|
1160 | + /** |
|
1161 | + * load_controllers |
|
1162 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
1163 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
1164 | + * time |
|
1165 | + * |
|
1166 | + * @access public |
|
1167 | + * @return void |
|
1168 | + */ |
|
1169 | + public function load_controllers() |
|
1170 | + { |
|
1171 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
1172 | + // let's get it started |
|
1173 | + if ( |
|
1174 | + ! $this->maintenance_mode->level() |
|
1175 | + && ($this->request->isFrontend() || $this->request->isFrontAjax()) |
|
1176 | + ) { |
|
1177 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
1178 | + $this->loader->getShared('EE_Front_Controller'); |
|
1179 | + } elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) { |
|
1180 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
1181 | + $this->loader->getShared('EE_Admin'); |
|
1182 | + } elseif ($this->request->isWordPressHeartbeat()) { |
|
1183 | + $this->loader->getShared('EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'); |
|
1184 | + } |
|
1185 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
1186 | + } |
|
1187 | + |
|
1188 | + |
|
1189 | + /** |
|
1190 | + * core_loaded_and_ready |
|
1191 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
1192 | + * |
|
1193 | + * @access public |
|
1194 | + * @return void |
|
1195 | + * @throws Exception |
|
1196 | + */ |
|
1197 | + public function core_loaded_and_ready() |
|
1198 | + { |
|
1199 | + if ( |
|
1200 | + $this->request->isAdmin() |
|
1201 | + || $this->request->isFrontend() |
|
1202 | + || $this->request->isIframe() |
|
1203 | + || $this->request->isWordPressApi() |
|
1204 | + ) { |
|
1205 | + try { |
|
1206 | + $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
1207 | + $this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager'); |
|
1208 | + if ($this->canLoadBlocks()) { |
|
1209 | + $this->loader->getShared( |
|
1210 | + 'EventEspresso\core\services\editor\BlockRegistrationManager' |
|
1211 | + ); |
|
1212 | + } |
|
1213 | + } catch (Exception $exception) { |
|
1214 | + new ExceptionStackTraceDisplay($exception); |
|
1215 | + } |
|
1216 | + } |
|
1217 | + if ( |
|
1218 | + $this->request->isAdmin() |
|
1219 | + || $this->request->isEeAjax() |
|
1220 | + || $this->request->isFrontend() |
|
1221 | + ) { |
|
1222 | + $this->loader->getShared('EE_Session'); |
|
1223 | + } |
|
1224 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
1225 | + // always load template tags, because it's faster than checking if it's a front-end request, and many page |
|
1226 | + // builders require these even on the front-end |
|
1227 | + require_once EE_PUBLIC . 'template_tags.php'; |
|
1228 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
1229 | + } |
|
1230 | + |
|
1231 | + |
|
1232 | + /** |
|
1233 | + * initialize |
|
1234 | + * this is the best place to begin initializing client code |
|
1235 | + * |
|
1236 | + * @access public |
|
1237 | + * @return void |
|
1238 | + */ |
|
1239 | + public function initialize() |
|
1240 | + { |
|
1241 | + do_action('AHEE__EE_System__initialize'); |
|
1242 | + add_filter( |
|
1243 | + 'safe_style_css', |
|
1244 | + function ($styles) { |
|
1245 | + $styles[] = 'display'; |
|
1246 | + $styles[] = 'visibility'; |
|
1247 | + return $styles; |
|
1248 | + } |
|
1249 | + ); |
|
1250 | + } |
|
1251 | + |
|
1252 | + |
|
1253 | + /** |
|
1254 | + * initialize_last |
|
1255 | + * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
1256 | + * initialize has done so |
|
1257 | + * |
|
1258 | + * @access public |
|
1259 | + * @return void |
|
1260 | + */ |
|
1261 | + public function initialize_last() |
|
1262 | + { |
|
1263 | + do_action('AHEE__EE_System__initialize_last'); |
|
1264 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
1265 | + $rewrite_rules = $this->loader->getShared( |
|
1266 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
1267 | + ); |
|
1268 | + $rewrite_rules->flushRewriteRules(); |
|
1269 | + add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
1270 | + if ( |
|
1271 | + ($this->request->isAjax() || $this->request->isAdmin()) |
|
1272 | + && $this->maintenance_mode->models_can_query() |
|
1273 | + ) { |
|
1274 | + $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager'); |
|
1275 | + $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager'); |
|
1276 | + } |
|
1277 | + } |
|
1278 | + |
|
1279 | + |
|
1280 | + /** |
|
1281 | + * @return void |
|
1282 | + * @throws EE_Error |
|
1283 | + */ |
|
1284 | + public function addEspressoToolbar() |
|
1285 | + { |
|
1286 | + $this->loader->getShared( |
|
1287 | + 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
1288 | + array($this->registry->CAP) |
|
1289 | + ); |
|
1290 | + } |
|
1291 | + |
|
1292 | + |
|
1293 | + /** |
|
1294 | + * do_not_cache |
|
1295 | + * sets no cache headers and defines no cache constants for WP plugins |
|
1296 | + * |
|
1297 | + * @access public |
|
1298 | + * @return void |
|
1299 | + */ |
|
1300 | + public static function do_not_cache() |
|
1301 | + { |
|
1302 | + // set no cache constants |
|
1303 | + if (! defined('DONOTCACHEPAGE')) { |
|
1304 | + define('DONOTCACHEPAGE', true); |
|
1305 | + } |
|
1306 | + if (! defined('DONOTCACHCEOBJECT')) { |
|
1307 | + define('DONOTCACHCEOBJECT', true); |
|
1308 | + } |
|
1309 | + if (! defined('DONOTCACHEDB')) { |
|
1310 | + define('DONOTCACHEDB', true); |
|
1311 | + } |
|
1312 | + // add no cache headers |
|
1313 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
1314 | + // plus a little extra for nginx and Google Chrome |
|
1315 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
1316 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
1317 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
1318 | + } |
|
1319 | + |
|
1320 | + |
|
1321 | + /** |
|
1322 | + * extra_nocache_headers |
|
1323 | + * |
|
1324 | + * @access public |
|
1325 | + * @param $headers |
|
1326 | + * @return array |
|
1327 | + */ |
|
1328 | + public static function extra_nocache_headers($headers) |
|
1329 | + { |
|
1330 | + // for NGINX |
|
1331 | + $headers['X-Accel-Expires'] = 0; |
|
1332 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
1333 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
1334 | + return $headers; |
|
1335 | + } |
|
1336 | + |
|
1337 | + |
|
1338 | + /** |
|
1339 | + * nocache_headers |
|
1340 | + * |
|
1341 | + * @access public |
|
1342 | + * @return void |
|
1343 | + */ |
|
1344 | + public static function nocache_headers() |
|
1345 | + { |
|
1346 | + nocache_headers(); |
|
1347 | + } |
|
1348 | + |
|
1349 | + |
|
1350 | + /** |
|
1351 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
1352 | + * never returned with the function. |
|
1353 | + * |
|
1354 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
1355 | + * @return array |
|
1356 | + */ |
|
1357 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
1358 | + { |
|
1359 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
1360 | + } |
|
1361 | + |
|
1362 | + |
|
1363 | + /** |
|
1364 | + * Return whether blocks can be registered/loaded or not. |
|
1365 | + * @return bool |
|
1366 | + */ |
|
1367 | + private function canLoadBlocks() |
|
1368 | + { |
|
1369 | + return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
|
1370 | + && function_exists('register_block_type') |
|
1371 | + // don't load blocks if in the Divi page builder editor context |
|
1372 | + // @see https://github.com/eventespresso/event-espresso-core/issues/814 |
|
1373 | + && ! $this->request->getRequestParam('et_fb', false); |
|
1374 | + } |
|
1375 | 1375 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | EE_Maintenance_Mode $maintenance_mode = null |
156 | 156 | ) { |
157 | 157 | // check if class object is instantiated |
158 | - if (! self::$_instance instanceof EE_System) { |
|
158 | + if ( ! self::$_instance instanceof EE_System) { |
|
159 | 159 | self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
160 | 160 | } |
161 | 161 | return self::$_instance; |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
283 | 283 | add_action( |
284 | 284 | 'AHEE__EE_Capabilities__init_caps__before_initialization', |
285 | - function () { |
|
285 | + function() { |
|
286 | 286 | LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
287 | 287 | } |
288 | 288 | ); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | { |
324 | 324 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
325 | 325 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
326 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
326 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | |
@@ -342,14 +342,14 @@ discard block |
||
342 | 342 | $load_callback, |
343 | 343 | $plugin_file_constant |
344 | 344 | ) { |
345 | - if (! defined($version_constant)) { |
|
345 | + if ( ! defined($version_constant)) { |
|
346 | 346 | return; |
347 | 347 | } |
348 | 348 | $addon_version = constant($version_constant); |
349 | 349 | if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
350 | 350 | remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
351 | - if (! function_exists('deactivate_plugins')) { |
|
352 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
351 | + if ( ! function_exists('deactivate_plugins')) { |
|
352 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
353 | 353 | } |
354 | 354 | deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
355 | 355 | $this->request->unSetRequestParams(['activate', 'activate-multi'], true); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | $min_version_required |
364 | 364 | ), |
365 | 365 | __FILE__, |
366 | - __FUNCTION__ . "({$addon_name})", |
|
366 | + __FUNCTION__."({$addon_name})", |
|
367 | 367 | __LINE__ |
368 | 368 | ); |
369 | 369 | EE_Error::get_notices(false, true); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | true |
416 | 416 | ) |
417 | 417 | ) { |
418 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
418 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth/basic-auth.php'; |
|
419 | 419 | } |
420 | 420 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
421 | 421 | } |
@@ -517,11 +517,11 @@ discard block |
||
517 | 517 | private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
518 | 518 | { |
519 | 519 | do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
520 | - if (! $espresso_db_update) { |
|
520 | + if ( ! $espresso_db_update) { |
|
521 | 521 | $espresso_db_update = get_option('espresso_db_update'); |
522 | 522 | } |
523 | 523 | // check that option is an array |
524 | - if (! is_array($espresso_db_update)) { |
|
524 | + if ( ! is_array($espresso_db_update)) { |
|
525 | 525 | // if option is FALSE, then it never existed |
526 | 526 | if ($espresso_db_update === false) { |
527 | 527 | // make $espresso_db_update an array and save option with autoload OFF |
@@ -541,10 +541,10 @@ discard block |
||
541 | 541 | // so it must be numerically-indexed, where values are versions installed... |
542 | 542 | // fix it! |
543 | 543 | $version_string = $should_be_array; |
544 | - $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
544 | + $corrected_db_update[$version_string] = array('unknown-date'); |
|
545 | 545 | } else { |
546 | 546 | // ok it checks out |
547 | - $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
547 | + $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
548 | 548 | } |
549 | 549 | } |
550 | 550 | $espresso_db_update = $corrected_db_update; |
@@ -628,13 +628,13 @@ discard block |
||
628 | 628 | */ |
629 | 629 | public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
630 | 630 | { |
631 | - if (! $version_history) { |
|
631 | + if ( ! $version_history) { |
|
632 | 632 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
633 | 633 | } |
634 | 634 | if ($current_version_to_add === null) { |
635 | 635 | $current_version_to_add = espresso_version(); |
636 | 636 | } |
637 | - $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
637 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
638 | 638 | // re-save |
639 | 639 | return update_option('espresso_db_update', $version_history); |
640 | 640 | } |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | if ($activation_history_for_addon) { |
725 | 725 | // it exists, so this isn't a completely new install |
726 | 726 | // check if this version already in that list of previously installed versions |
727 | - if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
727 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
728 | 728 | // it a version we haven't seen before |
729 | 729 | if ($version_is_higher === 1) { |
730 | 730 | $req_type = EE_System::req_type_upgrade; |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | foreach ($activation_history as $version => $times_activated) { |
803 | 803 | // check there is a record of when this version was activated. Otherwise, |
804 | 804 | // mark it as unknown |
805 | - if (! $times_activated) { |
|
805 | + if ( ! $times_activated) { |
|
806 | 806 | $times_activated = array('unknown-date'); |
807 | 807 | } |
808 | 808 | if (is_string($times_activated)) { |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | private function _parse_model_names() |
907 | 907 | { |
908 | 908 | // get all the files in the EE_MODELS folder that end in .model.php |
909 | - $models = glob(EE_MODELS . '*.model.php'); |
|
909 | + $models = glob(EE_MODELS.'*.model.php'); |
|
910 | 910 | $model_names = array(); |
911 | 911 | $non_abstract_db_models = array(); |
912 | 912 | foreach ($models as $model) { |
@@ -915,9 +915,9 @@ discard block |
||
915 | 915 | $short_name = str_replace('EEM_', '', $classname); |
916 | 916 | $reflectionClass = new ReflectionClass($classname); |
917 | 917 | if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
918 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
918 | + $non_abstract_db_models[$short_name] = $classname; |
|
919 | 919 | } |
920 | - $model_names[ $short_name ] = $classname; |
|
920 | + $model_names[$short_name] = $classname; |
|
921 | 921 | } |
922 | 922 | $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
923 | 923 | $this->registry->non_abstract_db_models = apply_filters( |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | ) |
953 | 953 | ); |
954 | 954 | if ($domain->isCaffeinated()) { |
955 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
955 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
956 | 956 | } |
957 | 957 | } |
958 | 958 | |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
1035 | 1035 | 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
1036 | 1036 | ); |
1037 | - if (! empty($class_names)) { |
|
1037 | + if ( ! empty($class_names)) { |
|
1038 | 1038 | $msg = esc_html__( |
1039 | 1039 | 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
1040 | 1040 | 'event_espresso' |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
1047 | 1047 | '', |
1048 | 1048 | $class_name |
1049 | - ) . '</b></li>'; |
|
1049 | + ).'</b></li>'; |
|
1050 | 1050 | } |
1051 | 1051 | $msg .= '</ul>'; |
1052 | 1052 | $msg .= esc_html__( |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | private function _deactivate_incompatible_addons() |
1116 | 1116 | { |
1117 | 1117 | $incompatible_addons = get_option('ee_incompatible_addons', array()); |
1118 | - if (! empty($incompatible_addons)) { |
|
1118 | + if ( ! empty($incompatible_addons)) { |
|
1119 | 1119 | $active_plugins = get_option('active_plugins', array()); |
1120 | 1120 | foreach ($active_plugins as $active_plugin) { |
1121 | 1121 | foreach ($incompatible_addons as $incompatible_addon) { |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | do_action('AHEE__EE_System__core_loaded_and_ready'); |
1225 | 1225 | // always load template tags, because it's faster than checking if it's a front-end request, and many page |
1226 | 1226 | // builders require these even on the front-end |
1227 | - require_once EE_PUBLIC . 'template_tags.php'; |
|
1227 | + require_once EE_PUBLIC.'template_tags.php'; |
|
1228 | 1228 | do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
1229 | 1229 | } |
1230 | 1230 | |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | do_action('AHEE__EE_System__initialize'); |
1242 | 1242 | add_filter( |
1243 | 1243 | 'safe_style_css', |
1244 | - function ($styles) { |
|
1244 | + function($styles) { |
|
1245 | 1245 | $styles[] = 'display'; |
1246 | 1246 | $styles[] = 'visibility'; |
1247 | 1247 | return $styles; |
@@ -1300,13 +1300,13 @@ discard block |
||
1300 | 1300 | public static function do_not_cache() |
1301 | 1301 | { |
1302 | 1302 | // set no cache constants |
1303 | - if (! defined('DONOTCACHEPAGE')) { |
|
1303 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
1304 | 1304 | define('DONOTCACHEPAGE', true); |
1305 | 1305 | } |
1306 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
1306 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
1307 | 1307 | define('DONOTCACHCEOBJECT', true); |
1308 | 1308 | } |
1309 | - if (! defined('DONOTCACHEDB')) { |
|
1309 | + if ( ! defined('DONOTCACHEDB')) { |
|
1310 | 1310 | define('DONOTCACHEDB', true); |
1311 | 1311 | } |
1312 | 1312 | // add no cache headers |