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