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