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