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