@@ -462,29 +462,29 @@ discard block |
||
462 | 462 | |
463 | 463 | |
464 | 464 | |
465 | - /** |
|
466 | - * Gets all payments which have not been approved |
|
467 | - * @return \EEI_Payment[] |
|
468 | - * @throws EE_Error if a model is misconfigured somehow |
|
469 | - */ |
|
465 | + /** |
|
466 | + * Gets all payments which have not been approved |
|
467 | + * @return \EEI_Payment[] |
|
468 | + * @throws EE_Error if a model is misconfigured somehow |
|
469 | + */ |
|
470 | 470 | public function pending_payments() |
471 | - { |
|
472 | - return $this->get_many_related( |
|
473 | - 'Payment', |
|
474 | - array( |
|
475 | - array( |
|
476 | - 'STS_ID' => EEM_Payment::status_id_pending |
|
477 | - ), |
|
478 | - 'order_by' => array( |
|
479 | - 'PAY_timestamp' => 'DESC' |
|
480 | - ) |
|
481 | - ) |
|
482 | - ); |
|
483 | - } |
|
484 | - |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
471 | + { |
|
472 | + return $this->get_many_related( |
|
473 | + 'Payment', |
|
474 | + array( |
|
475 | + array( |
|
476 | + 'STS_ID' => EEM_Payment::status_id_pending |
|
477 | + ), |
|
478 | + 'order_by' => array( |
|
479 | + 'PAY_timestamp' => 'DESC' |
|
480 | + ) |
|
481 | + ) |
|
482 | + ); |
|
483 | + } |
|
484 | + |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | 488 | * echoes $this->pretty_status() |
489 | 489 | * |
490 | 490 | * @param bool $show_icons |
@@ -645,20 +645,20 @@ discard block |
||
645 | 645 | * @throws \EE_Error |
646 | 646 | */ |
647 | 647 | public function primary_registration() { |
648 | - $registrations = (array) $this->get_many_related( |
|
649 | - 'Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT)) |
|
650 | - ); |
|
651 | - foreach ($registrations as $registration) { |
|
652 | - // valid registration that is NOT cancelled or declined ? |
|
653 | - if( |
|
654 | - $registration instanceof EE_Registration |
|
655 | - && ! in_array($registration->status_ID(), EEM_Registration::closed_reg_statuses(), true) |
|
656 | - ) { |
|
657 | - return $registration; |
|
658 | - } |
|
659 | - } |
|
660 | - // nothing valid found, so just return first thing from array of results |
|
661 | - return reset($registrations); |
|
648 | + $registrations = (array) $this->get_many_related( |
|
649 | + 'Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT)) |
|
650 | + ); |
|
651 | + foreach ($registrations as $registration) { |
|
652 | + // valid registration that is NOT cancelled or declined ? |
|
653 | + if( |
|
654 | + $registration instanceof EE_Registration |
|
655 | + && ! in_array($registration->status_ID(), EEM_Registration::closed_reg_statuses(), true) |
|
656 | + ) { |
|
657 | + return $registration; |
|
658 | + } |
|
659 | + } |
|
660 | + // nothing valid found, so just return first thing from array of results |
|
661 | + return reset($registrations); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * EE_Transaction class |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | * @return EE_Transaction |
35 | 35 | * @throws \EE_Error |
36 | 36 | */ |
37 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
38 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
37 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
38 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
39 | 39 | $txn = $has_object |
40 | 40 | ? $has_object |
41 | - : new self( $props_n_values, false, $timezone, $date_formats ); |
|
42 | - if ( ! $has_object ) { |
|
43 | - $txn->set_old_txn_status( $txn->status_ID() ); |
|
41 | + : new self($props_n_values, false, $timezone, $date_formats); |
|
42 | + if ( ! $has_object) { |
|
43 | + $txn->set_old_txn_status($txn->status_ID()); |
|
44 | 44 | } |
45 | 45 | return $txn; |
46 | 46 | } |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @return EE_Transaction |
55 | 55 | * @throws \EE_Error |
56 | 56 | */ |
57 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
58 | - $txn = new self( $props_n_values, TRUE, $timezone ); |
|
59 | - $txn->set_old_txn_status( $txn->status_ID() ); |
|
57 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
58 | + $txn = new self($props_n_values, TRUE, $timezone); |
|
59 | + $txn->set_old_txn_status($txn->status_ID()); |
|
60 | 60 | return $txn; |
61 | 61 | } |
62 | 62 | |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function lock() { |
75 | 75 | // attempt to set lock, but if that fails... |
76 | - if ( ! $this->add_extra_meta( 'lock', time(), true ) ) { |
|
76 | + if ( ! $this->add_extra_meta('lock', time(), true)) { |
|
77 | 77 | // then attempt to remove the lock in case it is expired |
78 | - if ( $this->_remove_expired_lock() ) { |
|
78 | + if ($this->_remove_expired_lock()) { |
|
79 | 79 | // if removal was successful, then try setting lock again |
80 | 80 | $this->lock(); |
81 | 81 | } else { |
82 | 82 | // but if the lock can not be removed, then throw an exception |
83 | 83 | throw new EE_Error( |
84 | 84 | sprintf( |
85 | - __( 'Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso' ), |
|
85 | + __('Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso'), |
|
86 | 86 | $this->ID() |
87 | 87 | ) |
88 | 88 | ); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @throws \EE_Error |
102 | 102 | */ |
103 | 103 | public function unlock() { |
104 | - return $this->delete_extra_meta( 'lock' ); |
|
104 | + return $this->delete_extra_meta('lock'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function is_locked() { |
124 | 124 | // if TXN is not locked, then return false immediately |
125 | - if ( ! $this->_get_lock() ) { |
|
125 | + if ( ! $this->_get_lock()) { |
|
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | // if not, then let's try and remove the lock in case it's expired... |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @throws \EE_Error |
144 | 144 | */ |
145 | 145 | protected function _get_lock() { |
146 | - return (int)$this->get_extra_meta( 'lock', true, 0 ); |
|
146 | + return (int) $this->get_extra_meta('lock', true, 0); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | protected function _remove_expired_lock() { |
160 | 160 | $locked = $this->_get_lock(); |
161 | - if ( $locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked ) { |
|
161 | + if ($locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked) { |
|
162 | 162 | return $this->unlock(); |
163 | 163 | } |
164 | 164 | return 0; |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param float $total total value of transaction |
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | - public function set_total( $total = 0.00 ) { |
|
177 | - $this->set( 'TXN_total', (float)$total ); |
|
176 | + public function set_total($total = 0.00) { |
|
177 | + $this->set('TXN_total', (float) $total); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param float $total_paid total amount paid to date (sum of all payments) |
187 | 187 | * @throws \EE_Error |
188 | 188 | */ |
189 | - public function set_paid( $total_paid = 0.00 ) { |
|
190 | - $this->set( 'TXN_paid', (float)$total_paid ); |
|
189 | + public function set_paid($total_paid = 0.00) { |
|
190 | + $this->set('TXN_paid', (float) $total_paid); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @param string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set |
200 | 200 | * @throws \EE_Error |
201 | 201 | */ |
202 | - public function set_status( $status = '' ) { |
|
203 | - $this->set( 'STS_ID', $status ); |
|
202 | + public function set_status($status = '') { |
|
203 | + $this->set('STS_ID', $status); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * @param string $hash_salt required for some payment gateways |
213 | 213 | * @throws \EE_Error |
214 | 214 | */ |
215 | - public function set_hash_salt( $hash_salt = '' ) { |
|
216 | - $this->set( 'TXN_hash_salt', $hash_salt ); |
|
215 | + public function set_hash_salt($hash_salt = '') { |
|
216 | + $this->set('TXN_hash_salt', $hash_salt); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | * @param array $txn_reg_steps |
225 | 225 | * @throws \EE_Error |
226 | 226 | */ |
227 | - public function set_reg_steps( array $txn_reg_steps ) { |
|
228 | - $this->set( 'TXN_reg_steps', $txn_reg_steps ); |
|
227 | + public function set_reg_steps(array $txn_reg_steps) { |
|
228 | + $this->set('TXN_reg_steps', $txn_reg_steps); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | |
@@ -237,8 +237,8 @@ discard block |
||
237 | 237 | * @throws \EE_Error |
238 | 238 | */ |
239 | 239 | public function reg_steps() { |
240 | - $TXN_reg_steps = $this->get( 'TXN_reg_steps' ); |
|
241 | - return is_array( $TXN_reg_steps ) ? (array)$TXN_reg_steps : array(); |
|
240 | + $TXN_reg_steps = $this->get('TXN_reg_steps'); |
|
241 | + return is_array($TXN_reg_steps) ? (array) $TXN_reg_steps : array(); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @throws \EE_Error |
249 | 249 | */ |
250 | 250 | public function pretty_total() { |
251 | - return $this->get_pretty( 'TXN_total' ); |
|
251 | + return $this->get_pretty('TXN_total'); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @throws \EE_Error |
261 | 261 | */ |
262 | 262 | public function pretty_paid() { |
263 | - return $this->get_pretty( 'TXN_paid' ); |
|
263 | + return $this->get_pretty('TXN_paid'); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @throws \EE_Error |
274 | 274 | */ |
275 | 275 | public function remaining() { |
276 | - return (float)( $this->total() - $this->paid() ); |
|
276 | + return (float) ($this->total() - $this->paid()); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @throws \EE_Error |
287 | 287 | */ |
288 | 288 | public function total() { |
289 | - return (float)$this->get( 'TXN_total' ); |
|
289 | + return (float) $this->get('TXN_total'); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @throws \EE_Error |
300 | 300 | */ |
301 | 301 | public function paid() { |
302 | - return (float)$this->get( 'TXN_paid' ); |
|
302 | + return (float) $this->get('TXN_paid'); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @throws \EE_Error |
312 | 312 | */ |
313 | 313 | public function get_cart_session() { |
314 | - $session_data = (array)$this->get( 'TXN_session_data' ); |
|
315 | - return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart |
|
316 | - ? $session_data[ 'cart' ] |
|
314 | + $session_data = (array) $this->get('TXN_session_data'); |
|
315 | + return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart |
|
316 | + ? $session_data['cart'] |
|
317 | 317 | : null; |
318 | 318 | } |
319 | 319 | |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | * @throws \EE_Error |
327 | 327 | */ |
328 | 328 | public function session_data() { |
329 | - $session_data = $this->get( 'TXN_session_data' ); |
|
330 | - if ( empty( $session_data ) ) { |
|
329 | + $session_data = $this->get('TXN_session_data'); |
|
330 | + if (empty($session_data)) { |
|
331 | 331 | $session_data = array( |
332 | 332 | 'id' => null, |
333 | 333 | 'user_id' => null, |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | * @param EE_Session|array $session_data |
351 | 351 | * @throws \EE_Error |
352 | 352 | */ |
353 | - public function set_txn_session_data( $session_data ) { |
|
354 | - if ( $session_data instanceof EE_Session ) { |
|
355 | - $this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE )); |
|
353 | + public function set_txn_session_data($session_data) { |
|
354 | + if ($session_data instanceof EE_Session) { |
|
355 | + $this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE)); |
|
356 | 356 | } else { |
357 | - $this->set( 'TXN_session_data', $session_data ); |
|
357 | + $this->set('TXN_session_data', $session_data); |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | * @throws \EE_Error |
368 | 368 | */ |
369 | 369 | public function hash_salt_() { |
370 | - return $this->get( 'TXN_hash_salt' ); |
|
370 | + return $this->get('TXN_hash_salt'); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | |
@@ -387,13 +387,13 @@ discard block |
||
387 | 387 | * @return string | int |
388 | 388 | * @throws \EE_Error |
389 | 389 | */ |
390 | - public function datetime( $format = FALSE, $gmt = FALSE ) { |
|
391 | - if ( $format ) { |
|
392 | - return $this->get_pretty( 'TXN_timestamp' ); |
|
393 | - } else if ( $gmt ) { |
|
394 | - return $this->get_raw( 'TXN_timestamp' ); |
|
390 | + public function datetime($format = FALSE, $gmt = FALSE) { |
|
391 | + if ($format) { |
|
392 | + return $this->get_pretty('TXN_timestamp'); |
|
393 | + } else if ($gmt) { |
|
394 | + return $this->get_raw('TXN_timestamp'); |
|
395 | 395 | } else { |
396 | - return $this->get( 'TXN_timestamp' ); |
|
396 | + return $this->get('TXN_timestamp'); |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | * @return EE_Registration[] |
408 | 408 | * @throws \EE_Error |
409 | 409 | */ |
410 | - public function registrations( $query_params = array(), $get_cached = FALSE ) { |
|
411 | - $query_params = ( empty( $query_params ) || ! is_array( $query_params ) ) |
|
410 | + public function registrations($query_params = array(), $get_cached = FALSE) { |
|
411 | + $query_params = (empty($query_params) || ! is_array($query_params)) |
|
412 | 412 | ? array( |
413 | 413 | 'order_by' => array( |
414 | 414 | 'Event.EVT_name' => 'ASC', |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | ) |
419 | 419 | : $query_params; |
420 | 420 | $query_params = $get_cached ? array() : $query_params; |
421 | - return $this->get_many_related( 'Registration', $query_params ); |
|
421 | + return $this->get_many_related('Registration', $query_params); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | * @throws \EE_Error |
432 | 432 | */ |
433 | 433 | public function attendees() { |
434 | - return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) ); |
|
434 | + return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID()))); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * @return EE_Payment[] |
444 | 444 | * @throws \EE_Error |
445 | 445 | */ |
446 | - public function payments( $query_params = array() ) { |
|
447 | - return $this->get_many_related( 'Payment', $query_params ); |
|
446 | + public function payments($query_params = array()) { |
|
447 | + return $this->get_many_related('Payment', $query_params); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -456,8 +456,8 @@ discard block |
||
456 | 456 | * @throws \EE_Error |
457 | 457 | */ |
458 | 458 | public function approved_payments() { |
459 | - EE_Registry::instance()->load_model( 'Payment' ); |
|
460 | - return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) ); |
|
459 | + EE_Registry::instance()->load_model('Payment'); |
|
460 | + return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC'))); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -491,8 +491,8 @@ discard block |
||
491 | 491 | * @return string |
492 | 492 | * @throws \EE_Error |
493 | 493 | */ |
494 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
495 | - echo $this->pretty_status( $show_icons ); |
|
494 | + public function e_pretty_status($show_icons = FALSE) { |
|
495 | + echo $this->pretty_status($show_icons); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | * @return string |
505 | 505 | * @throws \EE_Error |
506 | 506 | */ |
507 | - public function pretty_status( $show_icons = FALSE ) { |
|
508 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
507 | + public function pretty_status($show_icons = FALSE) { |
|
508 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
509 | 509 | $icon = ''; |
510 | - switch ( $this->status_ID() ) { |
|
510 | + switch ($this->status_ID()) { |
|
511 | 511 | case EEM_Transaction::complete_status_code: |
512 | 512 | $icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : ''; |
513 | 513 | break; |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | $icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : ''; |
525 | 525 | break; |
526 | 526 | } |
527 | - return $icon . $status[ $this->status_ID() ]; |
|
527 | + return $icon.$status[$this->status_ID()]; |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | * @throws \EE_Error |
537 | 537 | */ |
538 | 538 | public function status_ID() { |
539 | - return $this->get( 'STS_ID' ); |
|
539 | + return $this->get('STS_ID'); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | * @throws \EE_Error |
549 | 549 | */ |
550 | 550 | public function is_free() { |
551 | - return EEH_Money::compare_floats( $this->get( 'TXN_total' ), 0, '==' ); |
|
551 | + return EEH_Money::compare_floats($this->get('TXN_total'), 0, '=='); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | |
@@ -628,12 +628,12 @@ discard block |
||
628 | 628 | * @return string |
629 | 629 | * @throws \EE_Error |
630 | 630 | */ |
631 | - public function invoice_url( $type = 'html' ) { |
|
631 | + public function invoice_url($type = 'html') { |
|
632 | 632 | $REG = $this->primary_registration(); |
633 | - if ( ! $REG instanceof EE_Registration ) { |
|
633 | + if ( ! $REG instanceof EE_Registration) { |
|
634 | 634 | return ''; |
635 | 635 | } |
636 | - return $REG->invoice_url( $type ); |
|
636 | + return $REG->invoice_url($type); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | ); |
651 | 651 | foreach ($registrations as $registration) { |
652 | 652 | // valid registration that is NOT cancelled or declined ? |
653 | - if( |
|
653 | + if ( |
|
654 | 654 | $registration instanceof EE_Registration |
655 | 655 | && ! in_array($registration->status_ID(), EEM_Registration::closed_reg_statuses(), true) |
656 | 656 | ) { |
@@ -670,12 +670,12 @@ discard block |
||
670 | 670 | * @return string |
671 | 671 | * @throws \EE_Error |
672 | 672 | */ |
673 | - public function receipt_url( $type = 'html' ) { |
|
673 | + public function receipt_url($type = 'html') { |
|
674 | 674 | $REG = $this->primary_registration(); |
675 | - if ( ! $REG instanceof EE_Registration ) { |
|
675 | + if ( ! $REG instanceof EE_Registration) { |
|
676 | 676 | return ''; |
677 | 677 | } |
678 | - return $REG->receipt_url( $type ); |
|
678 | + return $REG->receipt_url($type); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * @throws \EE_Error |
701 | 701 | */ |
702 | 702 | public function gateway_response_on_transaction() { |
703 | - $payment = $this->get_first_related( 'Payment' ); |
|
703 | + $payment = $this->get_first_related('Payment'); |
|
704 | 704 | return $payment instanceof EE_Payment ? $payment->gateway_response() : ''; |
705 | 705 | } |
706 | 706 | |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | * @throws \EE_Error |
714 | 714 | */ |
715 | 715 | public function status_obj() { |
716 | - return $this->get_first_related( 'Status' ); |
|
716 | + return $this->get_first_related('Status'); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | * @return EE_Extra_Meta |
726 | 726 | * @throws \EE_Error |
727 | 727 | */ |
728 | - public function extra_meta( $query_params = array() ) { |
|
729 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
728 | + public function extra_meta($query_params = array()) { |
|
729 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | |
@@ -738,8 +738,8 @@ discard block |
||
738 | 738 | * @return EE_Base_Class the relation was added to |
739 | 739 | * @throws \EE_Error |
740 | 740 | */ |
741 | - public function add_registration( EE_Registration $registration ) { |
|
742 | - return $this->_add_relation_to( $registration, 'Registration' ); |
|
741 | + public function add_registration(EE_Registration $registration) { |
|
742 | + return $this->_add_relation_to($registration, 'Registration'); |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | |
@@ -752,8 +752,8 @@ discard block |
||
752 | 752 | * @return EE_Base_Class that was removed from being related |
753 | 753 | * @throws \EE_Error |
754 | 754 | */ |
755 | - public function remove_registration_with_id( $registration_or_id ) { |
|
756 | - return $this->_remove_relation_to( $registration_or_id, 'Registration' ); |
|
755 | + public function remove_registration_with_id($registration_or_id) { |
|
756 | + return $this->_remove_relation_to($registration_or_id, 'Registration'); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | * @throws \EE_Error |
766 | 766 | */ |
767 | 767 | public function items_purchased() { |
768 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) ); |
|
768 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item))); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | * @return EE_Base_Class the relation was added to |
778 | 778 | * @throws \EE_Error |
779 | 779 | */ |
780 | - public function add_line_item( EE_Line_Item $line_item ) { |
|
781 | - return $this->_add_relation_to( $line_item, 'Line_Item' ); |
|
780 | + public function add_line_item(EE_Line_Item $line_item) { |
|
781 | + return $this->_add_relation_to($line_item, 'Line_Item'); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | |
@@ -790,8 +790,8 @@ discard block |
||
790 | 790 | * @return EE_Line_Item[] |
791 | 791 | * @throws \EE_Error |
792 | 792 | */ |
793 | - public function line_items( $query_params = array() ) { |
|
794 | - return $this->get_many_related( 'Line_Item', $query_params ); |
|
793 | + public function line_items($query_params = array()) { |
|
794 | + return $this->get_many_related('Line_Item', $query_params); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | * @throws \EE_Error |
804 | 804 | */ |
805 | 805 | public function tax_items() { |
806 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) ); |
|
806 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | |
@@ -816,10 +816,10 @@ discard block |
||
816 | 816 | * @return \EE_Line_Item |
817 | 817 | * @throws \EE_Error |
818 | 818 | */ |
819 | - public function total_line_item( $create_if_not_found = true ) { |
|
820 | - $item = $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) ); |
|
821 | - if( ! $item && $create_if_not_found ){ |
|
822 | - $item = EEH_Line_Item::create_total_line_item( $this ); |
|
819 | + public function total_line_item($create_if_not_found = true) { |
|
820 | + $item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total))); |
|
821 | + if ( ! $item && $create_if_not_found) { |
|
822 | + $item = EEH_Line_Item::create_total_line_item($this); |
|
823 | 823 | } |
824 | 824 | return $item; |
825 | 825 | } |
@@ -835,10 +835,10 @@ discard block |
||
835 | 835 | */ |
836 | 836 | public function tax_total() { |
837 | 837 | $tax_line_item = $this->tax_total_line_item(); |
838 | - if ( $tax_line_item ) { |
|
839 | - return (float)$tax_line_item->total(); |
|
838 | + if ($tax_line_item) { |
|
839 | + return (float) $tax_line_item->total(); |
|
840 | 840 | } else { |
841 | - return (float)0; |
|
841 | + return (float) 0; |
|
842 | 842 | } |
843 | 843 | } |
844 | 844 | |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | * @throws \EE_Error |
852 | 852 | */ |
853 | 853 | public function tax_total_line_item() { |
854 | - return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() ); |
|
854 | + return EEH_Line_Item::get_taxes_subtotal($this->total_line_item()); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | |
@@ -862,20 +862,20 @@ discard block |
||
862 | 862 | * @return EE_Form_Section_Proper |
863 | 863 | * @throws \EE_Error |
864 | 864 | */ |
865 | - public function billing_info(){ |
|
865 | + public function billing_info() { |
|
866 | 866 | $payment_method = $this->payment_method(); |
867 | - if ( !$payment_method){ |
|
867 | + if ( ! $payment_method) { |
|
868 | 868 | EE_Error::add_error(__("Could not find billing info for transaction because no gateway has been used for it yet", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
869 | 869 | return false; |
870 | 870 | } |
871 | 871 | $primary_reg = $this->primary_registration(); |
872 | - if ( ! $primary_reg ) { |
|
873 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
872 | + if ( ! $primary_reg) { |
|
873 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
874 | 874 | return FALSE; |
875 | 875 | } |
876 | 876 | $attendee = $primary_reg->attendee(); |
877 | - if ( ! $attendee ) { |
|
878 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
877 | + if ( ! $attendee) { |
|
878 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
879 | 879 | return FALSE; |
880 | 880 | } |
881 | 881 | return $attendee->billing_info_for_payment_method($payment_method); |
@@ -916,15 +916,15 @@ discard block |
||
916 | 916 | * @return EE_Payment_Method |
917 | 917 | * @throws \EE_Error |
918 | 918 | */ |
919 | - public function payment_method(){ |
|
919 | + public function payment_method() { |
|
920 | 920 | $pm = $this->get_first_related('Payment_Method'); |
921 | - if( $pm instanceof EE_Payment_Method ){ |
|
921 | + if ($pm instanceof EE_Payment_Method) { |
|
922 | 922 | return $pm; |
923 | - }else{ |
|
923 | + } else { |
|
924 | 924 | $last_payment = $this->last_payment(); |
925 | - if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){ |
|
925 | + if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) { |
|
926 | 926 | return $last_payment->payment_method(); |
927 | - }else{ |
|
927 | + } else { |
|
928 | 928 | return NULL; |
929 | 929 | } |
930 | 930 | } |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | * @throws \EE_Error |
940 | 940 | */ |
941 | 941 | public function last_payment() { |
942 | - return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) ); |
|
942 | + return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc'))); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | * @return EE_Line_Item[] |
951 | 951 | * @throws \EE_Error |
952 | 952 | */ |
953 | - public function non_ticket_line_items(){ |
|
954 | - return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() ); |
|
953 | + public function non_ticket_line_items() { |
|
954 | + return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID()); |
|
955 | 955 | } |
956 | 956 | |
957 | 957 | |
@@ -999,7 +999,7 @@ discard block |
||
999 | 999 | public function update_based_on_payments() |
1000 | 1000 | { |
1001 | 1001 | EE_Error::doing_it_wrong( |
1002 | - __CLASS__ . '::' . __FUNCTION__, |
|
1002 | + __CLASS__.'::'.__FUNCTION__, |
|
1003 | 1003 | sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
1004 | 1004 | 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
1005 | 1005 | '4.6.0' |
@@ -1023,9 +1023,9 @@ discard block |
||
1023 | 1023 | /** |
1024 | 1024 | * @param string $old_txn_status |
1025 | 1025 | */ |
1026 | - public function set_old_txn_status( $old_txn_status ) { |
|
1026 | + public function set_old_txn_status($old_txn_status) { |
|
1027 | 1027 | // only set the first time |
1028 | - if ( $this->_old_txn_status === null ) { |
|
1028 | + if ($this->_old_txn_status === null) { |
|
1029 | 1029 | $this->_old_txn_status = $old_txn_status; |
1030 | 1030 | } |
1031 | 1031 | } |
@@ -1054,17 +1054,17 @@ discard block |
||
1054 | 1054 | * @param bool $check_all |
1055 | 1055 | * @return boolean | int |
1056 | 1056 | */ |
1057 | - private function _reg_steps_completed( $reg_step_slug = '', $check_all = true ) { |
|
1057 | + private function _reg_steps_completed($reg_step_slug = '', $check_all = true) { |
|
1058 | 1058 | $reg_steps = $this->reg_steps(); |
1059 | - if ( ! is_array( $reg_steps ) || empty( $reg_steps ) ) { |
|
1059 | + if ( ! is_array($reg_steps) || empty($reg_steps)) { |
|
1060 | 1060 | return false; |
1061 | 1061 | } |
1062 | 1062 | // loop thru reg steps array) |
1063 | - foreach ( $reg_steps as $slug => $reg_step_completed ) { |
|
1063 | + foreach ($reg_steps as $slug => $reg_step_completed) { |
|
1064 | 1064 | // if NOT checking ALL steps (only checking one step) |
1065 | - if ( ! $check_all ) { |
|
1065 | + if ( ! $check_all) { |
|
1066 | 1066 | // and this is the one |
1067 | - if ( $slug === $reg_step_slug ) { |
|
1067 | + if ($slug === $reg_step_slug) { |
|
1068 | 1068 | return $reg_step_completed; |
1069 | 1069 | } else { |
1070 | 1070 | // skip to next reg step in loop |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | } |
1073 | 1073 | } |
1074 | 1074 | // $check_all must be true, else we would never have gotten to this point |
1075 | - if ( $slug === $reg_step_slug ) { |
|
1075 | + if ($slug === $reg_step_slug) { |
|
1076 | 1076 | // if we reach this point, then we are testing either: |
1077 | 1077 | // all_reg_steps_completed_except() or |
1078 | 1078 | // all_reg_steps_completed_except_final_step(), |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | // ie: "is everything completed except the final step?" |
1082 | 1082 | // "that is correct... the final step is not completed, but all others are." |
1083 | 1083 | return $reg_step_completed !== true ? true : false; |
1084 | - } else if ( $reg_step_completed !== true ) { |
|
1084 | + } else if ($reg_step_completed !== true) { |
|
1085 | 1085 | // if any reg step is NOT completed, then ALL steps are not completed |
1086 | 1086 | return false; |
1087 | 1087 | } |
@@ -1115,8 +1115,8 @@ discard block |
||
1115 | 1115 | * @param string $exception |
1116 | 1116 | * @return boolean |
1117 | 1117 | */ |
1118 | - public function all_reg_steps_completed_except( $exception = '' ) { |
|
1119 | - return $this->_reg_steps_completed( $exception ); |
|
1118 | + public function all_reg_steps_completed_except($exception = '') { |
|
1119 | + return $this->_reg_steps_completed($exception); |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | * @return boolean |
1132 | 1132 | */ |
1133 | 1133 | public function all_reg_steps_completed_except_final_step() { |
1134 | - return $this->_reg_steps_completed( 'finalize_registration' ); |
|
1134 | + return $this->_reg_steps_completed('finalize_registration'); |
|
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | |
@@ -1146,8 +1146,8 @@ discard block |
||
1146 | 1146 | * @param string $reg_step_slug |
1147 | 1147 | * @return boolean | int |
1148 | 1148 | */ |
1149 | - public function reg_step_completed( $reg_step_slug ) { |
|
1150 | - return $this->_reg_steps_completed( $reg_step_slug, false ); |
|
1149 | + public function reg_step_completed($reg_step_slug) { |
|
1150 | + return $this->_reg_steps_completed($reg_step_slug, false); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | * @return boolean | int |
1163 | 1163 | */ |
1164 | 1164 | public function final_reg_step_completed() { |
1165 | - return $this->_reg_steps_completed( 'finalize_registration', false ); |
|
1165 | + return $this->_reg_steps_completed('finalize_registration', false); |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | |
@@ -1176,8 +1176,8 @@ discard block |
||
1176 | 1176 | * @return boolean |
1177 | 1177 | * @throws \EE_Error |
1178 | 1178 | */ |
1179 | - public function set_reg_step_initiated( $reg_step_slug ) { |
|
1180 | - return $this->_set_reg_step_completed_status( $reg_step_slug, time() ); |
|
1179 | + public function set_reg_step_initiated($reg_step_slug) { |
|
1180 | + return $this->_set_reg_step_completed_status($reg_step_slug, time()); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | |
@@ -1191,8 +1191,8 @@ discard block |
||
1191 | 1191 | * @return boolean |
1192 | 1192 | * @throws \EE_Error |
1193 | 1193 | */ |
1194 | - public function set_reg_step_completed( $reg_step_slug ) { |
|
1195 | - return $this->_set_reg_step_completed_status( $reg_step_slug, true ); |
|
1194 | + public function set_reg_step_completed($reg_step_slug) { |
|
1195 | + return $this->_set_reg_step_completed_status($reg_step_slug, true); |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | |
@@ -1206,8 +1206,8 @@ discard block |
||
1206 | 1206 | * @return boolean |
1207 | 1207 | * @throws \EE_Error |
1208 | 1208 | */ |
1209 | - public function set_reg_step_not_completed( $reg_step_slug ) { |
|
1210 | - return $this->_set_reg_step_completed_status( $reg_step_slug, false ); |
|
1209 | + public function set_reg_step_not_completed($reg_step_slug) { |
|
1210 | + return $this->_set_reg_step_completed_status($reg_step_slug, false); |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | |
@@ -1222,37 +1222,37 @@ discard block |
||
1222 | 1222 | * @return boolean |
1223 | 1223 | * @throws \EE_Error |
1224 | 1224 | */ |
1225 | - private function _set_reg_step_completed_status( $reg_step_slug, $status ) { |
|
1225 | + private function _set_reg_step_completed_status($reg_step_slug, $status) { |
|
1226 | 1226 | // validate status |
1227 | - $status = is_bool( $status ) || is_int( $status ) ? $status : false; |
|
1227 | + $status = is_bool($status) || is_int($status) ? $status : false; |
|
1228 | 1228 | // get reg steps array |
1229 | 1229 | $txn_reg_steps = $this->reg_steps(); |
1230 | 1230 | // if reg step does NOT exist |
1231 | - if ( ! isset( $txn_reg_steps[ $reg_step_slug ] ) ) { |
|
1231 | + if ( ! isset($txn_reg_steps[$reg_step_slug])) { |
|
1232 | 1232 | return false; |
1233 | 1233 | } |
1234 | 1234 | // if we're trying to complete a step that is already completed |
1235 | - if ( $txn_reg_steps[ $reg_step_slug ] === true ) { |
|
1235 | + if ($txn_reg_steps[$reg_step_slug] === true) { |
|
1236 | 1236 | return true; |
1237 | 1237 | } |
1238 | 1238 | // if we're trying to complete a step that hasn't even started |
1239 | - if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) { |
|
1239 | + if ($status === true && $txn_reg_steps[$reg_step_slug] === false) { |
|
1240 | 1240 | return false; |
1241 | 1241 | } |
1242 | 1242 | // if current status value matches the incoming value (no change) |
1243 | 1243 | // type casting as int means values should collapse to either 0, 1, or a timestamp like 1234567890 |
1244 | - if ( (int) $txn_reg_steps[ $reg_step_slug ] === (int) $status ) { |
|
1244 | + if ((int) $txn_reg_steps[$reg_step_slug] === (int) $status) { |
|
1245 | 1245 | // this will happen in cases where multiple AJAX requests occur during the same step |
1246 | 1246 | return true; |
1247 | 1247 | } |
1248 | 1248 | // if we're trying to set a start time, but it has already been set... |
1249 | - if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] ) ) { |
|
1249 | + if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) { |
|
1250 | 1250 | // skip the update below, but don't return FALSE so that errors won't be displayed |
1251 | 1251 | return true; |
1252 | 1252 | } |
1253 | 1253 | // update completed status |
1254 | - $txn_reg_steps[ $reg_step_slug ] = $status; |
|
1255 | - $this->set_reg_steps( $txn_reg_steps ); |
|
1254 | + $txn_reg_steps[$reg_step_slug] = $status; |
|
1255 | + $this->set_reg_steps($txn_reg_steps); |
|
1256 | 1256 | $this->save(); |
1257 | 1257 | return true; |
1258 | 1258 | } |
@@ -1268,11 +1268,11 @@ discard block |
||
1268 | 1268 | * @param string $reg_step_slug |
1269 | 1269 | * @return void |
1270 | 1270 | */ |
1271 | - public function remove_reg_step( $reg_step_slug ) { |
|
1271 | + public function remove_reg_step($reg_step_slug) { |
|
1272 | 1272 | // get reg steps array |
1273 | 1273 | $txn_reg_steps = $this->reg_steps(); |
1274 | - unset( $txn_reg_steps[ $reg_step_slug ] ); |
|
1275 | - $this->set_reg_steps( $txn_reg_steps ); |
|
1274 | + unset($txn_reg_steps[$reg_step_slug]); |
|
1275 | + $this->set_reg_steps($txn_reg_steps); |
|
1276 | 1276 | } |
1277 | 1277 | |
1278 | 1278 | |
@@ -1286,11 +1286,11 @@ discard block |
||
1286 | 1286 | * @param bool $save |
1287 | 1287 | * @return bool |
1288 | 1288 | */ |
1289 | - public function toggle_failed_transaction_status( $save = true ) { |
|
1289 | + public function toggle_failed_transaction_status($save = true) { |
|
1290 | 1290 | // if TXN status is still set as "failed"... |
1291 | - if ( $this->status_ID() === EEM_Transaction::failed_status_code ) { |
|
1292 | - $this->set_status( EEM_Transaction::abandoned_status_code ); |
|
1293 | - if ( $save ) { |
|
1291 | + if ($this->status_ID() === EEM_Transaction::failed_status_code) { |
|
1292 | + $this->set_status(EEM_Transaction::abandoned_status_code); |
|
1293 | + if ($save) { |
|
1294 | 1294 | $this->save(); |
1295 | 1295 | } |
1296 | 1296 | return true; |
@@ -1319,10 +1319,10 @@ discard block |
||
1319 | 1319 | $this->primary_registration() instanceof EE_Registration |
1320 | 1320 | && $this->primary_registration()->attendee() instanceof EE_Attendee |
1321 | 1321 | ) { |
1322 | - $this->set_status( EEM_Transaction::incomplete_status_code ); |
|
1322 | + $this->set_status(EEM_Transaction::incomplete_status_code); |
|
1323 | 1323 | } else { |
1324 | 1324 | // no contact record? yer abandoned! |
1325 | - $this->set_status( EEM_Transaction::abandoned_status_code ); |
|
1325 | + $this->set_status(EEM_Transaction::abandoned_status_code); |
|
1326 | 1326 | } |
1327 | 1327 | return true; |
1328 | 1328 | } |
@@ -1336,16 +1336,16 @@ discard block |
||
1336 | 1336 | * updates the TXN status based on the amount paid |
1337 | 1337 | */ |
1338 | 1338 | public function verify_abandoned_transaction_status() { |
1339 | - if ( $this->status_ID() !== EEM_Transaction::abandoned_status_code ) { |
|
1339 | + if ($this->status_ID() !== EEM_Transaction::abandoned_status_code) { |
|
1340 | 1340 | return; |
1341 | 1341 | } |
1342 | - $payments = $this->get_many_related( 'Payment' ); |
|
1343 | - if ( ! empty( $payments ) ) { |
|
1344 | - foreach ( $payments as $payment ) { |
|
1345 | - if ( $payment instanceof EE_Payment ) { |
|
1342 | + $payments = $this->get_many_related('Payment'); |
|
1343 | + if ( ! empty($payments)) { |
|
1344 | + foreach ($payments as $payment) { |
|
1345 | + if ($payment instanceof EE_Payment) { |
|
1346 | 1346 | // kk this TXN should NOT be abandoned |
1347 | 1347 | $this->update_status_based_on_total_paid(); |
1348 | - if ( is_admin() && ! ( defined('DOING_AJAX') && DOING_AJAX ) ) { |
|
1348 | + if (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
1349 | 1349 | EE_Error::add_attention( |
1350 | 1350 | sprintf( |
1351 | 1351 | esc_html__( |
@@ -1361,8 +1361,8 @@ discard block |
||
1361 | 1361 | $finalized = $this->final_reg_step_completed(); |
1362 | 1362 | // if the 'finalize_registration' step has been initiated (has a timestamp) |
1363 | 1363 | // but has not yet been fully completed (TRUE) |
1364 | - if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) { |
|
1365 | - $this->set_reg_step_completed( 'finalize_registration' ); |
|
1364 | + if (is_int($finalized) && $finalized !== false && $finalized !== true) { |
|
1365 | + $this->set_reg_step_completed('finalize_registration'); |
|
1366 | 1366 | $this->save(); |
1367 | 1367 | } |
1368 | 1368 | } |
@@ -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 | |
@@ -19,1043 +19,1043 @@ discard block |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * possibly truncated version of the EE core version string |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - protected static $_core_version = ''; |
|
22 | + /** |
|
23 | + * possibly truncated version of the EE core version string |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + protected static $_core_version = ''; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Holds values for registered addons |
|
31 | - * |
|
32 | - * @var array |
|
33 | - */ |
|
34 | - protected static $_settings = array(); |
|
29 | + /** |
|
30 | + * Holds values for registered addons |
|
31 | + * |
|
32 | + * @var array |
|
33 | + */ |
|
34 | + protected static $_settings = array(); |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var array $_incompatible_addons keys are addon SLUGS |
|
38 | - * (first argument passed to EE_Register_Addon::register()), keys are |
|
39 | - * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004). |
|
40 | - * Generally this should be used sparingly, as we don't want to muddle up |
|
41 | - * EE core with knowledge of ALL the addons out there. |
|
42 | - * If you want NO versions of an addon to run with a certain version of core, |
|
43 | - * it's usually best to define the addon's "min_core_version" as part of its call |
|
44 | - * to EE_Register_Addon::register(), rather than using this array with a super high value for its |
|
45 | - * minimum plugin version. |
|
46 | - * @access protected |
|
47 | - */ |
|
48 | - protected static $_incompatible_addons = array( |
|
49 | - 'Multi_Event_Registration' => '2.0.11.rc.002', |
|
50 | - 'Promotions' => '1.0.0.rc.084', |
|
51 | - ); |
|
36 | + /** |
|
37 | + * @var array $_incompatible_addons keys are addon SLUGS |
|
38 | + * (first argument passed to EE_Register_Addon::register()), keys are |
|
39 | + * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004). |
|
40 | + * Generally this should be used sparingly, as we don't want to muddle up |
|
41 | + * EE core with knowledge of ALL the addons out there. |
|
42 | + * If you want NO versions of an addon to run with a certain version of core, |
|
43 | + * it's usually best to define the addon's "min_core_version" as part of its call |
|
44 | + * to EE_Register_Addon::register(), rather than using this array with a super high value for its |
|
45 | + * minimum plugin version. |
|
46 | + * @access protected |
|
47 | + */ |
|
48 | + protected static $_incompatible_addons = array( |
|
49 | + 'Multi_Event_Registration' => '2.0.11.rc.002', |
|
50 | + 'Promotions' => '1.0.0.rc.084', |
|
51 | + ); |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * We should always be comparing core to a version like '4.3.0.rc.000', |
|
56 | - * not just '4.3.0'. |
|
57 | - * So if the addon developer doesn't provide that full version string, |
|
58 | - * fill in the blanks for them |
|
59 | - * |
|
60 | - * @param string $min_core_version |
|
61 | - * @return string always like '4.3.0.rc.000' |
|
62 | - */ |
|
63 | - protected static function _effective_version($min_core_version) |
|
64 | - { |
|
65 | - // versions: 4 . 3 . 1 . p . 123 |
|
66 | - // offsets: 0 . 1 . 2 . 3 . 4 |
|
67 | - $version_parts = explode('.', $min_core_version); |
|
68 | - //check they specified the micro version (after 2nd period) |
|
69 | - if (! isset($version_parts[2])) { |
|
70 | - $version_parts[2] = '0'; |
|
71 | - } |
|
72 | - //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
|
73 | - //soon we can assume that's 'rc', but this current version is 'alpha' |
|
74 | - if (! isset($version_parts[3])) { |
|
75 | - $version_parts[3] = 'dev'; |
|
76 | - } |
|
77 | - if (! isset($version_parts[4])) { |
|
78 | - $version_parts[4] = '000'; |
|
79 | - } |
|
80 | - return implode('.', $version_parts); |
|
81 | - } |
|
54 | + /** |
|
55 | + * We should always be comparing core to a version like '4.3.0.rc.000', |
|
56 | + * not just '4.3.0'. |
|
57 | + * So if the addon developer doesn't provide that full version string, |
|
58 | + * fill in the blanks for them |
|
59 | + * |
|
60 | + * @param string $min_core_version |
|
61 | + * @return string always like '4.3.0.rc.000' |
|
62 | + */ |
|
63 | + protected static function _effective_version($min_core_version) |
|
64 | + { |
|
65 | + // versions: 4 . 3 . 1 . p . 123 |
|
66 | + // offsets: 0 . 1 . 2 . 3 . 4 |
|
67 | + $version_parts = explode('.', $min_core_version); |
|
68 | + //check they specified the micro version (after 2nd period) |
|
69 | + if (! isset($version_parts[2])) { |
|
70 | + $version_parts[2] = '0'; |
|
71 | + } |
|
72 | + //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
|
73 | + //soon we can assume that's 'rc', but this current version is 'alpha' |
|
74 | + if (! isset($version_parts[3])) { |
|
75 | + $version_parts[3] = 'dev'; |
|
76 | + } |
|
77 | + if (! isset($version_parts[4])) { |
|
78 | + $version_parts[4] = '000'; |
|
79 | + } |
|
80 | + return implode('.', $version_parts); |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * Returns whether or not the min core version requirement of the addon is met |
|
86 | - * |
|
87 | - * @param string $min_core_version the minimum core version required by the addon |
|
88 | - * @param string $actual_core_version the actual core version, optional |
|
89 | - * @return boolean |
|
90 | - */ |
|
91 | - public static function _meets_min_core_version_requirement( |
|
92 | - $min_core_version, |
|
93 | - $actual_core_version = EVENT_ESPRESSO_VERSION |
|
94 | - ) { |
|
95 | - return version_compare( |
|
96 | - self::_effective_version($actual_core_version), |
|
97 | - self::_effective_version($min_core_version), |
|
98 | - '>=' |
|
99 | - ); |
|
100 | - } |
|
84 | + /** |
|
85 | + * Returns whether or not the min core version requirement of the addon is met |
|
86 | + * |
|
87 | + * @param string $min_core_version the minimum core version required by the addon |
|
88 | + * @param string $actual_core_version the actual core version, optional |
|
89 | + * @return boolean |
|
90 | + */ |
|
91 | + public static function _meets_min_core_version_requirement( |
|
92 | + $min_core_version, |
|
93 | + $actual_core_version = EVENT_ESPRESSO_VERSION |
|
94 | + ) { |
|
95 | + return version_compare( |
|
96 | + self::_effective_version($actual_core_version), |
|
97 | + self::_effective_version($min_core_version), |
|
98 | + '>=' |
|
99 | + ); |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * Method for registering new EE_Addons. |
|
105 | - * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE |
|
106 | - * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it |
|
107 | - * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon |
|
108 | - * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after |
|
109 | - * 'activate_plugin', it registers the addon still, but its components are not registered |
|
110 | - * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do |
|
111 | - * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns |
|
112 | - * (so that we can detect that the addon has activated on the subsequent request) |
|
113 | - * |
|
114 | - * @since 4.3.0 |
|
115 | - * @param string $addon_name the EE_Addon's name. Required. |
|
116 | - * @param array $setup_args { An |
|
117 | - * array of arguments provided for registering |
|
118 | - * the message type. |
|
119 | - * @type string $class_name the addon's main file name. |
|
120 | - * If left blank, generated from the addon |
|
121 | - * name, changes something like "calendar" to |
|
122 | - * "EE_Calendar" |
|
123 | - * @type string $min_core_version the minimum version of EE Core that the |
|
124 | - * addon will work with. eg "4.8.1.rc.084" |
|
125 | - * @type string $version the "software" version for the addon. eg |
|
126 | - * "1.0.0.p" for a first stable release, or "1.0.0.rc.043" for a version in progress |
|
127 | - * @type string $main_file_path the full server path to the main file |
|
128 | - * loaded |
|
129 | - * directly by WP |
|
130 | - * @type string $admin_path full server path to the folder where the |
|
131 | - * addon\'s admin files reside |
|
132 | - * @type string $admin_callback a method to be called when the EE Admin is |
|
133 | - * first invoked, can be used for hooking into any admin page |
|
134 | - * @type string $config_section the section name for this addon's |
|
135 | - * configuration settings section (defaults to "addons") |
|
136 | - * @type string $config_class the class name for this addon's |
|
137 | - * configuration settings object |
|
138 | - * @type string $config_name the class name for this addon's |
|
139 | - * configuration settings object |
|
140 | - * @type string $autoloader_paths an array of class names and the full server |
|
141 | - * paths to those files. Required. |
|
142 | - * @type string $autoloader_folders an array of "full server paths" for any |
|
143 | - * folders containing classes that might be invoked by the addon |
|
144 | - * @type string $dms_paths an array of full server paths to folders |
|
145 | - * that contain data migration scripts. Required. |
|
146 | - * @type string $module_paths an array of full server paths to any |
|
147 | - * EED_Modules used by the addon |
|
148 | - * @type string $shortcode_paths an array of full server paths to folders |
|
149 | - * that contain EES_Shortcodes |
|
150 | - * @type string $widget_paths an array of full server paths to folders |
|
151 | - * that contain WP_Widgets |
|
152 | - * @type string $pue_options |
|
153 | - * @type array $capabilities an array indexed by role name |
|
154 | - * (i.e administrator,author ) and the values |
|
155 | - * are an array of caps to add to the role. |
|
156 | - * 'administrator' => array( |
|
157 | - * 'read_addon', 'edit_addon', etc. |
|
158 | - * ). |
|
159 | - * @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object |
|
160 | - * for any addons that need to register any special meta mapped capabilities. Should be indexed where the |
|
161 | - * key is the EE_Meta_Capability_Map class name and the values are the arguments sent to the class. |
|
162 | - * @type array $model_paths array of folders containing DB models |
|
163 | - * @see EE_Register_Model |
|
164 | - * @type array $class_paths array of folders containing DB classes |
|
165 | - * @see EE_Register_Model |
|
166 | - * @type array $model_extension_paths array of folders containing DB model |
|
167 | - * extensions |
|
168 | - * @see EE_Register_Model_Extension |
|
169 | - * @type array $class_extension_paths array of folders containing DB class |
|
170 | - * extensions |
|
171 | - * @see EE_Register_Model_Extension |
|
172 | - * @type array message_types { |
|
173 | - * An array of message types with the key as |
|
174 | - * the message type name and the values as |
|
175 | - * below: |
|
176 | - * @type string $mtfilename The filename of the message type being |
|
177 | - * registered. This will be the main EE_{Messagetype_Name}_message_type class. |
|
178 | - * (eg. |
|
179 | - * EE_Declined_Registration_message_type.class.php) |
|
180 | - * Required. |
|
181 | - * @type array $autoloadpaths An array of paths to add to the messages |
|
182 | - * autoloader for the new message type. |
|
183 | - * Required. |
|
184 | - * @type array $messengers_to_activate_with An array of messengers that this message |
|
185 | - * type should activate with. Each value in |
|
186 | - * the |
|
187 | - * array |
|
188 | - * should match the name property of a |
|
189 | - * EE_messenger. Optional. |
|
190 | - * @type array $messengers_to_validate_with An array of messengers that this message |
|
191 | - * type should validate with. Each value in |
|
192 | - * the |
|
193 | - * array |
|
194 | - * should match the name property of an |
|
195 | - * EE_messenger. |
|
196 | - * Optional. |
|
197 | - * } |
|
198 | - * @type array $custom_post_types |
|
199 | - * @type array $custom_taxonomies |
|
200 | - * @type array $payment_method_paths each element is the folder containing the |
|
201 | - * EE_PMT_Base child class |
|
202 | - * (eg, |
|
203 | - * '/wp-content/plugins/my_plugin/Payomatic/' |
|
204 | - * which contains the files |
|
205 | - * EE_PMT_Payomatic.pm.php) |
|
206 | - * @type array $default_terms |
|
207 | - * @type array $namespace { |
|
208 | - * An array with two items for registering the |
|
209 | - * addon's namespace. (If, for some reason, |
|
210 | - * you |
|
211 | - * require additional namespaces, use |
|
212 | - * EventEspresso\core\Psr4Autoloader::addNamespace() |
|
213 | - * directly) |
|
214 | - * @see EventEspresso\core\Psr4Autoloader::addNamespace() |
|
215 | - * @type string $FQNS the namespace prefix |
|
216 | - * @type string $DIR a base directory for class files in the |
|
217 | - * namespace. |
|
218 | - * } |
|
219 | - * } |
|
220 | - * @throws EE_Error |
|
221 | - * @return void |
|
222 | - */ |
|
223 | - public static function register($addon_name = '', $setup_args = array()) |
|
224 | - { |
|
225 | - // required fields MUST be present, so let's make sure they are. |
|
226 | - \EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
227 | - // get class name for addon |
|
228 | - $class_name = \EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
|
229 | - //setup $_settings array from incoming values. |
|
230 | - $addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
231 | - // setup PUE |
|
232 | - \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
233 | - // does this addon work with this version of core or WordPress ? |
|
234 | - if (! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
235 | - return; |
|
236 | - } |
|
237 | - // register namespaces |
|
238 | - \EE_Register_Addon::_setup_namespaces($addon_settings); |
|
239 | - // check if this is an activation request |
|
240 | - if (\EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
241 | - // dont bother setting up the rest of the addon atm |
|
242 | - return; |
|
243 | - } |
|
244 | - // we need cars |
|
245 | - \EE_Register_Addon::_setup_autoloaders($addon_name); |
|
246 | - // register new models and extensions |
|
247 | - \EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
248 | - // setup DMS |
|
249 | - \EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
250 | - // if config_class is present let's register config. |
|
251 | - \EE_Register_Addon::_register_config($addon_name); |
|
252 | - // register admin pages |
|
253 | - \EE_Register_Addon::_register_admin_pages($addon_name); |
|
254 | - // add to list of modules to be registered |
|
255 | - \EE_Register_Addon::_register_modules($addon_name); |
|
256 | - // add to list of shortcodes to be registered |
|
257 | - \EE_Register_Addon::_register_shortcodes($addon_name); |
|
258 | - // add to list of widgets to be registered |
|
259 | - \EE_Register_Addon::_register_widgets($addon_name); |
|
260 | - // register capability related stuff. |
|
261 | - \EE_Register_Addon::_register_capabilities($addon_name); |
|
262 | - // any message type to register? |
|
263 | - \EE_Register_Addon::_register_message_types($addon_name); |
|
264 | - // any custom post type/ custom capabilities or default terms to register |
|
265 | - \EE_Register_Addon::_register_custom_post_types($addon_name); |
|
266 | - // and any payment methods |
|
267 | - \EE_Register_Addon::_register_payment_methods($addon_name); |
|
268 | - // load and instantiate main addon class |
|
269 | - $addon = \EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
270 | - $addon->after_registration(); |
|
271 | - } |
|
103 | + /** |
|
104 | + * Method for registering new EE_Addons. |
|
105 | + * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE |
|
106 | + * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it |
|
107 | + * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon |
|
108 | + * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after |
|
109 | + * 'activate_plugin', it registers the addon still, but its components are not registered |
|
110 | + * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do |
|
111 | + * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns |
|
112 | + * (so that we can detect that the addon has activated on the subsequent request) |
|
113 | + * |
|
114 | + * @since 4.3.0 |
|
115 | + * @param string $addon_name the EE_Addon's name. Required. |
|
116 | + * @param array $setup_args { An |
|
117 | + * array of arguments provided for registering |
|
118 | + * the message type. |
|
119 | + * @type string $class_name the addon's main file name. |
|
120 | + * If left blank, generated from the addon |
|
121 | + * name, changes something like "calendar" to |
|
122 | + * "EE_Calendar" |
|
123 | + * @type string $min_core_version the minimum version of EE Core that the |
|
124 | + * addon will work with. eg "4.8.1.rc.084" |
|
125 | + * @type string $version the "software" version for the addon. eg |
|
126 | + * "1.0.0.p" for a first stable release, or "1.0.0.rc.043" for a version in progress |
|
127 | + * @type string $main_file_path the full server path to the main file |
|
128 | + * loaded |
|
129 | + * directly by WP |
|
130 | + * @type string $admin_path full server path to the folder where the |
|
131 | + * addon\'s admin files reside |
|
132 | + * @type string $admin_callback a method to be called when the EE Admin is |
|
133 | + * first invoked, can be used for hooking into any admin page |
|
134 | + * @type string $config_section the section name for this addon's |
|
135 | + * configuration settings section (defaults to "addons") |
|
136 | + * @type string $config_class the class name for this addon's |
|
137 | + * configuration settings object |
|
138 | + * @type string $config_name the class name for this addon's |
|
139 | + * configuration settings object |
|
140 | + * @type string $autoloader_paths an array of class names and the full server |
|
141 | + * paths to those files. Required. |
|
142 | + * @type string $autoloader_folders an array of "full server paths" for any |
|
143 | + * folders containing classes that might be invoked by the addon |
|
144 | + * @type string $dms_paths an array of full server paths to folders |
|
145 | + * that contain data migration scripts. Required. |
|
146 | + * @type string $module_paths an array of full server paths to any |
|
147 | + * EED_Modules used by the addon |
|
148 | + * @type string $shortcode_paths an array of full server paths to folders |
|
149 | + * that contain EES_Shortcodes |
|
150 | + * @type string $widget_paths an array of full server paths to folders |
|
151 | + * that contain WP_Widgets |
|
152 | + * @type string $pue_options |
|
153 | + * @type array $capabilities an array indexed by role name |
|
154 | + * (i.e administrator,author ) and the values |
|
155 | + * are an array of caps to add to the role. |
|
156 | + * 'administrator' => array( |
|
157 | + * 'read_addon', 'edit_addon', etc. |
|
158 | + * ). |
|
159 | + * @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object |
|
160 | + * for any addons that need to register any special meta mapped capabilities. Should be indexed where the |
|
161 | + * key is the EE_Meta_Capability_Map class name and the values are the arguments sent to the class. |
|
162 | + * @type array $model_paths array of folders containing DB models |
|
163 | + * @see EE_Register_Model |
|
164 | + * @type array $class_paths array of folders containing DB classes |
|
165 | + * @see EE_Register_Model |
|
166 | + * @type array $model_extension_paths array of folders containing DB model |
|
167 | + * extensions |
|
168 | + * @see EE_Register_Model_Extension |
|
169 | + * @type array $class_extension_paths array of folders containing DB class |
|
170 | + * extensions |
|
171 | + * @see EE_Register_Model_Extension |
|
172 | + * @type array message_types { |
|
173 | + * An array of message types with the key as |
|
174 | + * the message type name and the values as |
|
175 | + * below: |
|
176 | + * @type string $mtfilename The filename of the message type being |
|
177 | + * registered. This will be the main EE_{Messagetype_Name}_message_type class. |
|
178 | + * (eg. |
|
179 | + * EE_Declined_Registration_message_type.class.php) |
|
180 | + * Required. |
|
181 | + * @type array $autoloadpaths An array of paths to add to the messages |
|
182 | + * autoloader for the new message type. |
|
183 | + * Required. |
|
184 | + * @type array $messengers_to_activate_with An array of messengers that this message |
|
185 | + * type should activate with. Each value in |
|
186 | + * the |
|
187 | + * array |
|
188 | + * should match the name property of a |
|
189 | + * EE_messenger. Optional. |
|
190 | + * @type array $messengers_to_validate_with An array of messengers that this message |
|
191 | + * type should validate with. Each value in |
|
192 | + * the |
|
193 | + * array |
|
194 | + * should match the name property of an |
|
195 | + * EE_messenger. |
|
196 | + * Optional. |
|
197 | + * } |
|
198 | + * @type array $custom_post_types |
|
199 | + * @type array $custom_taxonomies |
|
200 | + * @type array $payment_method_paths each element is the folder containing the |
|
201 | + * EE_PMT_Base child class |
|
202 | + * (eg, |
|
203 | + * '/wp-content/plugins/my_plugin/Payomatic/' |
|
204 | + * which contains the files |
|
205 | + * EE_PMT_Payomatic.pm.php) |
|
206 | + * @type array $default_terms |
|
207 | + * @type array $namespace { |
|
208 | + * An array with two items for registering the |
|
209 | + * addon's namespace. (If, for some reason, |
|
210 | + * you |
|
211 | + * require additional namespaces, use |
|
212 | + * EventEspresso\core\Psr4Autoloader::addNamespace() |
|
213 | + * directly) |
|
214 | + * @see EventEspresso\core\Psr4Autoloader::addNamespace() |
|
215 | + * @type string $FQNS the namespace prefix |
|
216 | + * @type string $DIR a base directory for class files in the |
|
217 | + * namespace. |
|
218 | + * } |
|
219 | + * } |
|
220 | + * @throws EE_Error |
|
221 | + * @return void |
|
222 | + */ |
|
223 | + public static function register($addon_name = '', $setup_args = array()) |
|
224 | + { |
|
225 | + // required fields MUST be present, so let's make sure they are. |
|
226 | + \EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
227 | + // get class name for addon |
|
228 | + $class_name = \EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
|
229 | + //setup $_settings array from incoming values. |
|
230 | + $addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
231 | + // setup PUE |
|
232 | + \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
233 | + // does this addon work with this version of core or WordPress ? |
|
234 | + if (! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
235 | + return; |
|
236 | + } |
|
237 | + // register namespaces |
|
238 | + \EE_Register_Addon::_setup_namespaces($addon_settings); |
|
239 | + // check if this is an activation request |
|
240 | + if (\EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
241 | + // dont bother setting up the rest of the addon atm |
|
242 | + return; |
|
243 | + } |
|
244 | + // we need cars |
|
245 | + \EE_Register_Addon::_setup_autoloaders($addon_name); |
|
246 | + // register new models and extensions |
|
247 | + \EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
248 | + // setup DMS |
|
249 | + \EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
250 | + // if config_class is present let's register config. |
|
251 | + \EE_Register_Addon::_register_config($addon_name); |
|
252 | + // register admin pages |
|
253 | + \EE_Register_Addon::_register_admin_pages($addon_name); |
|
254 | + // add to list of modules to be registered |
|
255 | + \EE_Register_Addon::_register_modules($addon_name); |
|
256 | + // add to list of shortcodes to be registered |
|
257 | + \EE_Register_Addon::_register_shortcodes($addon_name); |
|
258 | + // add to list of widgets to be registered |
|
259 | + \EE_Register_Addon::_register_widgets($addon_name); |
|
260 | + // register capability related stuff. |
|
261 | + \EE_Register_Addon::_register_capabilities($addon_name); |
|
262 | + // any message type to register? |
|
263 | + \EE_Register_Addon::_register_message_types($addon_name); |
|
264 | + // any custom post type/ custom capabilities or default terms to register |
|
265 | + \EE_Register_Addon::_register_custom_post_types($addon_name); |
|
266 | + // and any payment methods |
|
267 | + \EE_Register_Addon::_register_payment_methods($addon_name); |
|
268 | + // load and instantiate main addon class |
|
269 | + $addon = \EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
270 | + $addon->after_registration(); |
|
271 | + } |
|
272 | 272 | |
273 | 273 | |
274 | - /** |
|
275 | - * @param string $addon_name |
|
276 | - * @param array $setup_args |
|
277 | - * @return void |
|
278 | - * @throws \EE_Error |
|
279 | - */ |
|
280 | - private static function _verify_parameters($addon_name, array $setup_args) |
|
281 | - { |
|
282 | - // required fields MUST be present, so let's make sure they are. |
|
283 | - if (empty($addon_name) || ! is_array($setup_args)) { |
|
284 | - throw new EE_Error( |
|
285 | - __( |
|
286 | - 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
287 | - 'event_espresso' |
|
288 | - ) |
|
289 | - ); |
|
290 | - } |
|
291 | - if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
292 | - throw new EE_Error( |
|
293 | - sprintf( |
|
294 | - __( |
|
295 | - 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
296 | - 'event_espresso' |
|
297 | - ), |
|
298 | - implode(',', array_keys($setup_args)) |
|
299 | - ) |
|
300 | - ); |
|
301 | - } |
|
302 | - // check that addon has not already been registered with that name |
|
303 | - if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
304 | - throw new EE_Error( |
|
305 | - sprintf( |
|
306 | - __( |
|
307 | - 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
308 | - 'event_espresso' |
|
309 | - ), |
|
310 | - $addon_name |
|
311 | - ) |
|
312 | - ); |
|
313 | - } |
|
314 | - } |
|
274 | + /** |
|
275 | + * @param string $addon_name |
|
276 | + * @param array $setup_args |
|
277 | + * @return void |
|
278 | + * @throws \EE_Error |
|
279 | + */ |
|
280 | + private static function _verify_parameters($addon_name, array $setup_args) |
|
281 | + { |
|
282 | + // required fields MUST be present, so let's make sure they are. |
|
283 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
284 | + throw new EE_Error( |
|
285 | + __( |
|
286 | + 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
287 | + 'event_espresso' |
|
288 | + ) |
|
289 | + ); |
|
290 | + } |
|
291 | + if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
292 | + throw new EE_Error( |
|
293 | + sprintf( |
|
294 | + __( |
|
295 | + 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
296 | + 'event_espresso' |
|
297 | + ), |
|
298 | + implode(',', array_keys($setup_args)) |
|
299 | + ) |
|
300 | + ); |
|
301 | + } |
|
302 | + // check that addon has not already been registered with that name |
|
303 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
304 | + throw new EE_Error( |
|
305 | + sprintf( |
|
306 | + __( |
|
307 | + 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
308 | + 'event_espresso' |
|
309 | + ), |
|
310 | + $addon_name |
|
311 | + ) |
|
312 | + ); |
|
313 | + } |
|
314 | + } |
|
315 | 315 | |
316 | 316 | |
317 | - /** |
|
318 | - * @param string $addon_name |
|
319 | - * @param array $setup_args |
|
320 | - * @return string |
|
321 | - */ |
|
322 | - private static function _parse_class_name($addon_name, array $setup_args) |
|
323 | - { |
|
324 | - if (empty($setup_args['class_name'])) { |
|
325 | - // generate one by first separating name with spaces |
|
326 | - $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
327 | - //capitalize, then replace spaces with underscores |
|
328 | - $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
329 | - } else { |
|
330 | - $class_name = $setup_args['class_name']; |
|
331 | - } |
|
332 | - return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
333 | - } |
|
317 | + /** |
|
318 | + * @param string $addon_name |
|
319 | + * @param array $setup_args |
|
320 | + * @return string |
|
321 | + */ |
|
322 | + private static function _parse_class_name($addon_name, array $setup_args) |
|
323 | + { |
|
324 | + if (empty($setup_args['class_name'])) { |
|
325 | + // generate one by first separating name with spaces |
|
326 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
327 | + //capitalize, then replace spaces with underscores |
|
328 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
329 | + } else { |
|
330 | + $class_name = $setup_args['class_name']; |
|
331 | + } |
|
332 | + return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
333 | + } |
|
334 | 334 | |
335 | 335 | |
336 | - /** |
|
337 | - * @param string $class_name |
|
338 | - * @param array $setup_args |
|
339 | - * @return array |
|
340 | - */ |
|
341 | - private static function _get_addon_settings($class_name, array $setup_args) |
|
342 | - { |
|
343 | - //setup $_settings array from incoming values. |
|
344 | - $addon_settings = array( |
|
345 | - // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
346 | - 'class_name' => $class_name, |
|
347 | - // the addon slug for use in URLs, etc |
|
348 | - 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
349 | - ? (string)$setup_args['plugin_slug'] |
|
350 | - : '', |
|
351 | - // page slug to be used when generating the "Settings" link on the WP plugin page |
|
352 | - 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
353 | - ? (string)$setup_args['plugin_action_slug'] |
|
354 | - : '', |
|
355 | - // the "software" version for the addon |
|
356 | - 'version' => isset($setup_args['version']) |
|
357 | - ? (string)$setup_args['version'] |
|
358 | - : '', |
|
359 | - // the minimum version of EE Core that the addon will work with |
|
360 | - 'min_core_version' => isset($setup_args['min_core_version']) |
|
361 | - ? (string)$setup_args['min_core_version'] |
|
362 | - : '', |
|
363 | - // the minimum version of WordPress that the addon will work with |
|
364 | - 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
365 | - ? (string)$setup_args['min_wp_version'] |
|
366 | - : EE_MIN_WP_VER_REQUIRED, |
|
367 | - // full server path to main file (file loaded directly by WP) |
|
368 | - 'main_file_path' => isset($setup_args['main_file_path']) |
|
369 | - ? (string)$setup_args['main_file_path'] |
|
370 | - : '', |
|
371 | - // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
372 | - 'admin_path' => isset($setup_args['admin_path']) |
|
373 | - ? (string)$setup_args['admin_path'] : '', |
|
374 | - // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
375 | - 'admin_callback' => isset($setup_args['admin_callback']) |
|
376 | - ? (string)$setup_args['admin_callback'] |
|
377 | - : '', |
|
378 | - // the section name for this addon's configuration settings section (defaults to "addons") |
|
379 | - 'config_section' => isset($setup_args['config_section']) |
|
380 | - ? (string)$setup_args['config_section'] |
|
381 | - : 'addons', |
|
382 | - // the class name for this addon's configuration settings object |
|
383 | - 'config_class' => isset($setup_args['config_class']) |
|
384 | - ? (string)$setup_args['config_class'] : '', |
|
385 | - //the name given to the config for this addons' configuration settings object (optional) |
|
386 | - 'config_name' => isset($setup_args['config_name']) |
|
387 | - ? (string)$setup_args['config_name'] : '', |
|
388 | - // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
389 | - 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
390 | - ? (array)$setup_args['autoloader_paths'] |
|
391 | - : array(), |
|
392 | - // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
393 | - 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
394 | - ? (array)$setup_args['autoloader_folders'] |
|
395 | - : array(), |
|
396 | - // array of full server paths to any EE_DMS data migration scripts used by the addon |
|
397 | - 'dms_paths' => isset($setup_args['dms_paths']) |
|
398 | - ? (array)$setup_args['dms_paths'] |
|
399 | - : array(), |
|
400 | - // array of full server paths to any EED_Modules used by the addon |
|
401 | - 'module_paths' => isset($setup_args['module_paths']) |
|
402 | - ? (array)$setup_args['module_paths'] |
|
403 | - : array(), |
|
404 | - // array of full server paths to any EES_Shortcodes used by the addon |
|
405 | - 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
406 | - ? (array)$setup_args['shortcode_paths'] |
|
407 | - : array(), |
|
408 | - // array of full server paths to any WP_Widgets used by the addon |
|
409 | - 'widget_paths' => isset($setup_args['widget_paths']) |
|
410 | - ? (array)$setup_args['widget_paths'] |
|
411 | - : array(), |
|
412 | - // array of PUE options used by the addon |
|
413 | - 'pue_options' => isset($setup_args['pue_options']) |
|
414 | - ? (array)$setup_args['pue_options'] |
|
415 | - : array(), |
|
416 | - 'message_types' => isset($setup_args['message_types']) |
|
417 | - ? (array)$setup_args['message_types'] |
|
418 | - : array(), |
|
419 | - 'capabilities' => isset($setup_args['capabilities']) |
|
420 | - ? (array)$setup_args['capabilities'] |
|
421 | - : array(), |
|
422 | - 'capability_maps' => isset($setup_args['capability_maps']) |
|
423 | - ? (array)$setup_args['capability_maps'] |
|
424 | - : array(), |
|
425 | - 'model_paths' => isset($setup_args['model_paths']) |
|
426 | - ? (array)$setup_args['model_paths'] |
|
427 | - : array(), |
|
428 | - 'class_paths' => isset($setup_args['class_paths']) |
|
429 | - ? (array)$setup_args['class_paths'] |
|
430 | - : array(), |
|
431 | - 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
432 | - ? (array)$setup_args['model_extension_paths'] |
|
433 | - : array(), |
|
434 | - 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
435 | - ? (array)$setup_args['class_extension_paths'] |
|
436 | - : array(), |
|
437 | - 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
438 | - ? (array)$setup_args['custom_post_types'] |
|
439 | - : array(), |
|
440 | - 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
441 | - ? (array)$setup_args['custom_taxonomies'] |
|
442 | - : array(), |
|
443 | - 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
444 | - ? (array)$setup_args['payment_method_paths'] |
|
445 | - : array(), |
|
446 | - 'default_terms' => isset($setup_args['default_terms']) |
|
447 | - ? (array)$setup_args['default_terms'] |
|
448 | - : array(), |
|
449 | - // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
450 | - // that can be used for adding upgrading/marketing info |
|
451 | - 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
452 | - ? $setup_args['plugins_page_row'] |
|
453 | - : '', |
|
454 | - 'namespace' => isset( |
|
455 | - $setup_args['namespace'], |
|
456 | - $setup_args['namespace']['FQNS'], |
|
457 | - $setup_args['namespace']['DIR'] |
|
458 | - ) |
|
459 | - ? (array)$setup_args['namespace'] |
|
460 | - : array(), |
|
461 | - ); |
|
462 | - // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
463 | - // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
464 | - $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
465 | - && ! empty($addon_settings['admin_path']) |
|
466 | - ? $addon_settings['plugin_slug'] |
|
467 | - : $addon_settings['plugin_action_slug']; |
|
468 | - // full server path to main file (file loaded directly by WP) |
|
469 | - $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
470 | - return $addon_settings; |
|
471 | - } |
|
336 | + /** |
|
337 | + * @param string $class_name |
|
338 | + * @param array $setup_args |
|
339 | + * @return array |
|
340 | + */ |
|
341 | + private static function _get_addon_settings($class_name, array $setup_args) |
|
342 | + { |
|
343 | + //setup $_settings array from incoming values. |
|
344 | + $addon_settings = array( |
|
345 | + // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
346 | + 'class_name' => $class_name, |
|
347 | + // the addon slug for use in URLs, etc |
|
348 | + 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
349 | + ? (string)$setup_args['plugin_slug'] |
|
350 | + : '', |
|
351 | + // page slug to be used when generating the "Settings" link on the WP plugin page |
|
352 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
353 | + ? (string)$setup_args['plugin_action_slug'] |
|
354 | + : '', |
|
355 | + // the "software" version for the addon |
|
356 | + 'version' => isset($setup_args['version']) |
|
357 | + ? (string)$setup_args['version'] |
|
358 | + : '', |
|
359 | + // the minimum version of EE Core that the addon will work with |
|
360 | + 'min_core_version' => isset($setup_args['min_core_version']) |
|
361 | + ? (string)$setup_args['min_core_version'] |
|
362 | + : '', |
|
363 | + // the minimum version of WordPress that the addon will work with |
|
364 | + 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
365 | + ? (string)$setup_args['min_wp_version'] |
|
366 | + : EE_MIN_WP_VER_REQUIRED, |
|
367 | + // full server path to main file (file loaded directly by WP) |
|
368 | + 'main_file_path' => isset($setup_args['main_file_path']) |
|
369 | + ? (string)$setup_args['main_file_path'] |
|
370 | + : '', |
|
371 | + // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
372 | + 'admin_path' => isset($setup_args['admin_path']) |
|
373 | + ? (string)$setup_args['admin_path'] : '', |
|
374 | + // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
375 | + 'admin_callback' => isset($setup_args['admin_callback']) |
|
376 | + ? (string)$setup_args['admin_callback'] |
|
377 | + : '', |
|
378 | + // the section name for this addon's configuration settings section (defaults to "addons") |
|
379 | + 'config_section' => isset($setup_args['config_section']) |
|
380 | + ? (string)$setup_args['config_section'] |
|
381 | + : 'addons', |
|
382 | + // the class name for this addon's configuration settings object |
|
383 | + 'config_class' => isset($setup_args['config_class']) |
|
384 | + ? (string)$setup_args['config_class'] : '', |
|
385 | + //the name given to the config for this addons' configuration settings object (optional) |
|
386 | + 'config_name' => isset($setup_args['config_name']) |
|
387 | + ? (string)$setup_args['config_name'] : '', |
|
388 | + // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
389 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
390 | + ? (array)$setup_args['autoloader_paths'] |
|
391 | + : array(), |
|
392 | + // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
393 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
394 | + ? (array)$setup_args['autoloader_folders'] |
|
395 | + : array(), |
|
396 | + // array of full server paths to any EE_DMS data migration scripts used by the addon |
|
397 | + 'dms_paths' => isset($setup_args['dms_paths']) |
|
398 | + ? (array)$setup_args['dms_paths'] |
|
399 | + : array(), |
|
400 | + // array of full server paths to any EED_Modules used by the addon |
|
401 | + 'module_paths' => isset($setup_args['module_paths']) |
|
402 | + ? (array)$setup_args['module_paths'] |
|
403 | + : array(), |
|
404 | + // array of full server paths to any EES_Shortcodes used by the addon |
|
405 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
406 | + ? (array)$setup_args['shortcode_paths'] |
|
407 | + : array(), |
|
408 | + // array of full server paths to any WP_Widgets used by the addon |
|
409 | + 'widget_paths' => isset($setup_args['widget_paths']) |
|
410 | + ? (array)$setup_args['widget_paths'] |
|
411 | + : array(), |
|
412 | + // array of PUE options used by the addon |
|
413 | + 'pue_options' => isset($setup_args['pue_options']) |
|
414 | + ? (array)$setup_args['pue_options'] |
|
415 | + : array(), |
|
416 | + 'message_types' => isset($setup_args['message_types']) |
|
417 | + ? (array)$setup_args['message_types'] |
|
418 | + : array(), |
|
419 | + 'capabilities' => isset($setup_args['capabilities']) |
|
420 | + ? (array)$setup_args['capabilities'] |
|
421 | + : array(), |
|
422 | + 'capability_maps' => isset($setup_args['capability_maps']) |
|
423 | + ? (array)$setup_args['capability_maps'] |
|
424 | + : array(), |
|
425 | + 'model_paths' => isset($setup_args['model_paths']) |
|
426 | + ? (array)$setup_args['model_paths'] |
|
427 | + : array(), |
|
428 | + 'class_paths' => isset($setup_args['class_paths']) |
|
429 | + ? (array)$setup_args['class_paths'] |
|
430 | + : array(), |
|
431 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
432 | + ? (array)$setup_args['model_extension_paths'] |
|
433 | + : array(), |
|
434 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
435 | + ? (array)$setup_args['class_extension_paths'] |
|
436 | + : array(), |
|
437 | + 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
438 | + ? (array)$setup_args['custom_post_types'] |
|
439 | + : array(), |
|
440 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
441 | + ? (array)$setup_args['custom_taxonomies'] |
|
442 | + : array(), |
|
443 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
444 | + ? (array)$setup_args['payment_method_paths'] |
|
445 | + : array(), |
|
446 | + 'default_terms' => isset($setup_args['default_terms']) |
|
447 | + ? (array)$setup_args['default_terms'] |
|
448 | + : array(), |
|
449 | + // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
450 | + // that can be used for adding upgrading/marketing info |
|
451 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
452 | + ? $setup_args['plugins_page_row'] |
|
453 | + : '', |
|
454 | + 'namespace' => isset( |
|
455 | + $setup_args['namespace'], |
|
456 | + $setup_args['namespace']['FQNS'], |
|
457 | + $setup_args['namespace']['DIR'] |
|
458 | + ) |
|
459 | + ? (array)$setup_args['namespace'] |
|
460 | + : array(), |
|
461 | + ); |
|
462 | + // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
463 | + // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
464 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
465 | + && ! empty($addon_settings['admin_path']) |
|
466 | + ? $addon_settings['plugin_slug'] |
|
467 | + : $addon_settings['plugin_action_slug']; |
|
468 | + // full server path to main file (file loaded directly by WP) |
|
469 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
470 | + return $addon_settings; |
|
471 | + } |
|
472 | 472 | |
473 | 473 | |
474 | - /** |
|
475 | - * @param string $addon_name |
|
476 | - * @param array $addon_settings |
|
477 | - * @return boolean |
|
478 | - */ |
|
479 | - private static function _addon_is_compatible($addon_name, array $addon_settings) |
|
480 | - { |
|
481 | - global $wp_version; |
|
482 | - $incompatibility_message = ''; |
|
483 | - //check whether this addon version is compatible with EE core |
|
484 | - if ( |
|
485 | - isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
486 | - && ! self::_meets_min_core_version_requirement( |
|
487 | - EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
488 | - $addon_settings['version'] |
|
489 | - ) |
|
490 | - ) { |
|
491 | - $incompatibility_message = sprintf( |
|
492 | - __( |
|
493 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.' |
|
494 | - ), |
|
495 | - $addon_name, |
|
496 | - '<br />', |
|
497 | - EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
498 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
499 | - '</span><br />' |
|
500 | - ); |
|
501 | - } else if ( |
|
502 | - ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
503 | - ) { |
|
504 | - $incompatibility_message = sprintf( |
|
505 | - __( |
|
506 | - '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
507 | - 'event_espresso' |
|
508 | - ), |
|
509 | - $addon_name, |
|
510 | - self::_effective_version($addon_settings['min_core_version']), |
|
511 | - self::_effective_version(espresso_version()), |
|
512 | - '<br />', |
|
513 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
514 | - '</span><br />' |
|
515 | - ); |
|
516 | - } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
517 | - $incompatibility_message = sprintf( |
|
518 | - __( |
|
519 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
520 | - 'event_espresso' |
|
521 | - ), |
|
522 | - $addon_name, |
|
523 | - $addon_settings['min_wp_version'], |
|
524 | - '<br />', |
|
525 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
526 | - '</span><br />' |
|
527 | - ); |
|
528 | - } |
|
529 | - if (! empty($incompatibility_message)) { |
|
530 | - // remove 'activate' from the REQUEST |
|
531 | - // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
532 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
533 | - if (current_user_can('activate_plugins')) { |
|
534 | - // show an error message indicating the plugin didn't activate properly |
|
535 | - EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
536 | - } |
|
537 | - // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
538 | - return false; |
|
539 | - } |
|
540 | - // addon IS compatible |
|
541 | - return true; |
|
542 | - } |
|
474 | + /** |
|
475 | + * @param string $addon_name |
|
476 | + * @param array $addon_settings |
|
477 | + * @return boolean |
|
478 | + */ |
|
479 | + private static function _addon_is_compatible($addon_name, array $addon_settings) |
|
480 | + { |
|
481 | + global $wp_version; |
|
482 | + $incompatibility_message = ''; |
|
483 | + //check whether this addon version is compatible with EE core |
|
484 | + if ( |
|
485 | + isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
486 | + && ! self::_meets_min_core_version_requirement( |
|
487 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
488 | + $addon_settings['version'] |
|
489 | + ) |
|
490 | + ) { |
|
491 | + $incompatibility_message = sprintf( |
|
492 | + __( |
|
493 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.' |
|
494 | + ), |
|
495 | + $addon_name, |
|
496 | + '<br />', |
|
497 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
498 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
499 | + '</span><br />' |
|
500 | + ); |
|
501 | + } else if ( |
|
502 | + ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
503 | + ) { |
|
504 | + $incompatibility_message = sprintf( |
|
505 | + __( |
|
506 | + '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
507 | + 'event_espresso' |
|
508 | + ), |
|
509 | + $addon_name, |
|
510 | + self::_effective_version($addon_settings['min_core_version']), |
|
511 | + self::_effective_version(espresso_version()), |
|
512 | + '<br />', |
|
513 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
514 | + '</span><br />' |
|
515 | + ); |
|
516 | + } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
517 | + $incompatibility_message = sprintf( |
|
518 | + __( |
|
519 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
520 | + 'event_espresso' |
|
521 | + ), |
|
522 | + $addon_name, |
|
523 | + $addon_settings['min_wp_version'], |
|
524 | + '<br />', |
|
525 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
526 | + '</span><br />' |
|
527 | + ); |
|
528 | + } |
|
529 | + if (! empty($incompatibility_message)) { |
|
530 | + // remove 'activate' from the REQUEST |
|
531 | + // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
532 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
533 | + if (current_user_can('activate_plugins')) { |
|
534 | + // show an error message indicating the plugin didn't activate properly |
|
535 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
536 | + } |
|
537 | + // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
538 | + return false; |
|
539 | + } |
|
540 | + // addon IS compatible |
|
541 | + return true; |
|
542 | + } |
|
543 | 543 | |
544 | 544 | |
545 | - /** |
|
546 | - * if plugin update engine is being used for auto-updates, |
|
547 | - * then let's set that up now before going any further so that ALL addons can be updated |
|
548 | - * (not needed if PUE is not being used) |
|
549 | - * |
|
550 | - * @param string $addon_name |
|
551 | - * @param string $class_name |
|
552 | - * @param array $setup_args |
|
553 | - * @return void |
|
554 | - */ |
|
555 | - private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
|
556 | - { |
|
557 | - if (! empty($setup_args['pue_options'])) { |
|
558 | - self::$_settings[$addon_name]['pue_options'] = array( |
|
559 | - 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
560 | - ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
561 | - : 'espresso_' . strtolower($class_name), |
|
562 | - 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
563 | - ? (string)$setup_args['pue_options']['plugin_basename'] |
|
564 | - : plugin_basename($setup_args['main_file_path']), |
|
565 | - 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
566 | - ? (string)$setup_args['pue_options']['checkPeriod'] |
|
567 | - : '24', |
|
568 | - 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
569 | - ? (string)$setup_args['pue_options']['use_wp_update'] |
|
570 | - : false, |
|
571 | - ); |
|
572 | - add_action( |
|
573 | - 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
574 | - array('EE_Register_Addon', 'load_pue_update') |
|
575 | - ); |
|
576 | - } |
|
577 | - } |
|
545 | + /** |
|
546 | + * if plugin update engine is being used for auto-updates, |
|
547 | + * then let's set that up now before going any further so that ALL addons can be updated |
|
548 | + * (not needed if PUE is not being used) |
|
549 | + * |
|
550 | + * @param string $addon_name |
|
551 | + * @param string $class_name |
|
552 | + * @param array $setup_args |
|
553 | + * @return void |
|
554 | + */ |
|
555 | + private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
|
556 | + { |
|
557 | + if (! empty($setup_args['pue_options'])) { |
|
558 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
559 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
560 | + ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
561 | + : 'espresso_' . strtolower($class_name), |
|
562 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
563 | + ? (string)$setup_args['pue_options']['plugin_basename'] |
|
564 | + : plugin_basename($setup_args['main_file_path']), |
|
565 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
566 | + ? (string)$setup_args['pue_options']['checkPeriod'] |
|
567 | + : '24', |
|
568 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
569 | + ? (string)$setup_args['pue_options']['use_wp_update'] |
|
570 | + : false, |
|
571 | + ); |
|
572 | + add_action( |
|
573 | + 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
574 | + array('EE_Register_Addon', 'load_pue_update') |
|
575 | + ); |
|
576 | + } |
|
577 | + } |
|
578 | 578 | |
579 | 579 | |
580 | - /** |
|
581 | - * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
582 | - * |
|
583 | - * @param array $addon_settings |
|
584 | - * @return void |
|
585 | - */ |
|
586 | - private static function _setup_namespaces(array $addon_settings) |
|
587 | - { |
|
588 | - // |
|
589 | - if ( |
|
590 | - isset( |
|
591 | - $addon_settings['namespace'], |
|
592 | - $addon_settings['namespace']['FQNS'], |
|
593 | - $addon_settings['namespace']['DIR'] |
|
594 | - ) |
|
595 | - ) { |
|
596 | - EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
597 | - $addon_settings['namespace']['FQNS'], |
|
598 | - $addon_settings['namespace']['DIR'] |
|
599 | - ); |
|
600 | - } |
|
601 | - } |
|
580 | + /** |
|
581 | + * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
582 | + * |
|
583 | + * @param array $addon_settings |
|
584 | + * @return void |
|
585 | + */ |
|
586 | + private static function _setup_namespaces(array $addon_settings) |
|
587 | + { |
|
588 | + // |
|
589 | + if ( |
|
590 | + isset( |
|
591 | + $addon_settings['namespace'], |
|
592 | + $addon_settings['namespace']['FQNS'], |
|
593 | + $addon_settings['namespace']['DIR'] |
|
594 | + ) |
|
595 | + ) { |
|
596 | + EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
597 | + $addon_settings['namespace']['FQNS'], |
|
598 | + $addon_settings['namespace']['DIR'] |
|
599 | + ); |
|
600 | + } |
|
601 | + } |
|
602 | 602 | |
603 | 603 | |
604 | - /** |
|
605 | - * @param string $addon_name |
|
606 | - * @param array $addon_settings |
|
607 | - * @return bool |
|
608 | - */ |
|
609 | - private static function _addon_activation($addon_name, array $addon_settings) |
|
610 | - { |
|
611 | - // this is an activation request |
|
612 | - if (did_action('activate_plugin')) { |
|
613 | - //to find if THIS is the addon that was activated, |
|
614 | - //just check if we have already registered it or not |
|
615 | - //(as the newly-activated addon wasn't around the first time addons were registered) |
|
616 | - if (! isset(self::$_settings[$addon_name])) { |
|
617 | - self::$_settings[$addon_name] = $addon_settings; |
|
618 | - $addon = self::_load_and_init_addon_class($addon_name); |
|
619 | - $addon->set_activation_indicator_option(); |
|
620 | - // dont bother setting up the rest of the addon. |
|
621 | - // we know it was just activated and the request will end soon |
|
622 | - } |
|
623 | - return true; |
|
624 | - } else { |
|
625 | - // make sure this was called in the right place! |
|
626 | - if ( |
|
627 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
628 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
629 | - ) { |
|
630 | - EE_Error::doing_it_wrong( |
|
631 | - __METHOD__, |
|
632 | - sprintf( |
|
633 | - __( |
|
634 | - 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
635 | - 'event_espresso' |
|
636 | - ), |
|
637 | - $addon_name |
|
638 | - ), |
|
639 | - '4.3.0' |
|
640 | - ); |
|
641 | - } |
|
642 | - // make sure addon settings are set correctly without overwriting anything existing |
|
643 | - if (isset(self::$_settings[$addon_name])) { |
|
644 | - self::$_settings[$addon_name] += $addon_settings; |
|
645 | - } else { |
|
646 | - self::$_settings[$addon_name] = $addon_settings; |
|
647 | - } |
|
648 | - } |
|
649 | - return false; |
|
650 | - } |
|
604 | + /** |
|
605 | + * @param string $addon_name |
|
606 | + * @param array $addon_settings |
|
607 | + * @return bool |
|
608 | + */ |
|
609 | + private static function _addon_activation($addon_name, array $addon_settings) |
|
610 | + { |
|
611 | + // this is an activation request |
|
612 | + if (did_action('activate_plugin')) { |
|
613 | + //to find if THIS is the addon that was activated, |
|
614 | + //just check if we have already registered it or not |
|
615 | + //(as the newly-activated addon wasn't around the first time addons were registered) |
|
616 | + if (! isset(self::$_settings[$addon_name])) { |
|
617 | + self::$_settings[$addon_name] = $addon_settings; |
|
618 | + $addon = self::_load_and_init_addon_class($addon_name); |
|
619 | + $addon->set_activation_indicator_option(); |
|
620 | + // dont bother setting up the rest of the addon. |
|
621 | + // we know it was just activated and the request will end soon |
|
622 | + } |
|
623 | + return true; |
|
624 | + } else { |
|
625 | + // make sure this was called in the right place! |
|
626 | + if ( |
|
627 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
628 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
629 | + ) { |
|
630 | + EE_Error::doing_it_wrong( |
|
631 | + __METHOD__, |
|
632 | + sprintf( |
|
633 | + __( |
|
634 | + 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
635 | + 'event_espresso' |
|
636 | + ), |
|
637 | + $addon_name |
|
638 | + ), |
|
639 | + '4.3.0' |
|
640 | + ); |
|
641 | + } |
|
642 | + // make sure addon settings are set correctly without overwriting anything existing |
|
643 | + if (isset(self::$_settings[$addon_name])) { |
|
644 | + self::$_settings[$addon_name] += $addon_settings; |
|
645 | + } else { |
|
646 | + self::$_settings[$addon_name] = $addon_settings; |
|
647 | + } |
|
648 | + } |
|
649 | + return false; |
|
650 | + } |
|
651 | 651 | |
652 | 652 | |
653 | - /** |
|
654 | - * @param string $addon_name |
|
655 | - * @return void |
|
656 | - * @throws \EE_Error |
|
657 | - */ |
|
658 | - private static function _setup_autoloaders($addon_name) |
|
659 | - { |
|
660 | - if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
661 | - // setup autoloader for single file |
|
662 | - EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
663 | - } |
|
664 | - // setup autoloaders for folders |
|
665 | - if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
666 | - foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
667 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
668 | - } |
|
669 | - } |
|
670 | - } |
|
653 | + /** |
|
654 | + * @param string $addon_name |
|
655 | + * @return void |
|
656 | + * @throws \EE_Error |
|
657 | + */ |
|
658 | + private static function _setup_autoloaders($addon_name) |
|
659 | + { |
|
660 | + if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
661 | + // setup autoloader for single file |
|
662 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
663 | + } |
|
664 | + // setup autoloaders for folders |
|
665 | + if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
666 | + foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
667 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
668 | + } |
|
669 | + } |
|
670 | + } |
|
671 | 671 | |
672 | 672 | |
673 | - /** |
|
674 | - * register new models and extensions |
|
675 | - * |
|
676 | - * @param string $addon_name |
|
677 | - * @return void |
|
678 | - * @throws \EE_Error |
|
679 | - */ |
|
680 | - private static function _register_models_and_extensions($addon_name) |
|
681 | - { |
|
682 | - // register new models |
|
683 | - if ( |
|
684 | - ! empty(self::$_settings[$addon_name]['model_paths']) |
|
685 | - || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
686 | - ) { |
|
687 | - EE_Register_Model::register( |
|
688 | - $addon_name, |
|
689 | - array( |
|
690 | - 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
691 | - 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
692 | - ) |
|
693 | - ); |
|
694 | - } |
|
695 | - // register model extensions |
|
696 | - if ( |
|
697 | - ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
698 | - || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
699 | - ) { |
|
700 | - EE_Register_Model_Extensions::register( |
|
701 | - $addon_name, |
|
702 | - array( |
|
703 | - 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
704 | - 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
705 | - ) |
|
706 | - ); |
|
707 | - } |
|
708 | - } |
|
673 | + /** |
|
674 | + * register new models and extensions |
|
675 | + * |
|
676 | + * @param string $addon_name |
|
677 | + * @return void |
|
678 | + * @throws \EE_Error |
|
679 | + */ |
|
680 | + private static function _register_models_and_extensions($addon_name) |
|
681 | + { |
|
682 | + // register new models |
|
683 | + if ( |
|
684 | + ! empty(self::$_settings[$addon_name]['model_paths']) |
|
685 | + || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
686 | + ) { |
|
687 | + EE_Register_Model::register( |
|
688 | + $addon_name, |
|
689 | + array( |
|
690 | + 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
691 | + 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
692 | + ) |
|
693 | + ); |
|
694 | + } |
|
695 | + // register model extensions |
|
696 | + if ( |
|
697 | + ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
698 | + || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
699 | + ) { |
|
700 | + EE_Register_Model_Extensions::register( |
|
701 | + $addon_name, |
|
702 | + array( |
|
703 | + 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
704 | + 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
705 | + ) |
|
706 | + ); |
|
707 | + } |
|
708 | + } |
|
709 | 709 | |
710 | 710 | |
711 | - /** |
|
712 | - * @param string $addon_name |
|
713 | - * @return void |
|
714 | - * @throws \EE_Error |
|
715 | - */ |
|
716 | - private static function _register_data_migration_scripts($addon_name) |
|
717 | - { |
|
718 | - // setup DMS |
|
719 | - if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
720 | - EE_Register_Data_Migration_Scripts::register( |
|
721 | - $addon_name, |
|
722 | - array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
723 | - ); |
|
724 | - } |
|
725 | - } |
|
711 | + /** |
|
712 | + * @param string $addon_name |
|
713 | + * @return void |
|
714 | + * @throws \EE_Error |
|
715 | + */ |
|
716 | + private static function _register_data_migration_scripts($addon_name) |
|
717 | + { |
|
718 | + // setup DMS |
|
719 | + if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
720 | + EE_Register_Data_Migration_Scripts::register( |
|
721 | + $addon_name, |
|
722 | + array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
723 | + ); |
|
724 | + } |
|
725 | + } |
|
726 | 726 | |
727 | 727 | |
728 | - /** |
|
729 | - * @param string $addon_name |
|
730 | - * @return void |
|
731 | - * @throws \EE_Error |
|
732 | - */ |
|
733 | - private static function _register_config($addon_name) |
|
734 | - { |
|
735 | - // if config_class is present let's register config. |
|
736 | - if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
737 | - EE_Register_Config::register( |
|
738 | - self::$_settings[$addon_name]['config_class'], |
|
739 | - array( |
|
740 | - 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
741 | - 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
742 | - ) |
|
743 | - ); |
|
744 | - } |
|
745 | - } |
|
728 | + /** |
|
729 | + * @param string $addon_name |
|
730 | + * @return void |
|
731 | + * @throws \EE_Error |
|
732 | + */ |
|
733 | + private static function _register_config($addon_name) |
|
734 | + { |
|
735 | + // if config_class is present let's register config. |
|
736 | + if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
737 | + EE_Register_Config::register( |
|
738 | + self::$_settings[$addon_name]['config_class'], |
|
739 | + array( |
|
740 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
741 | + 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
742 | + ) |
|
743 | + ); |
|
744 | + } |
|
745 | + } |
|
746 | 746 | |
747 | 747 | |
748 | - /** |
|
749 | - * @param string $addon_name |
|
750 | - * @return void |
|
751 | - * @throws \EE_Error |
|
752 | - */ |
|
753 | - private static function _register_admin_pages($addon_name) |
|
754 | - { |
|
755 | - if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
756 | - EE_Register_Admin_Page::register( |
|
757 | - $addon_name, |
|
758 | - array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
759 | - ); |
|
760 | - } |
|
761 | - } |
|
748 | + /** |
|
749 | + * @param string $addon_name |
|
750 | + * @return void |
|
751 | + * @throws \EE_Error |
|
752 | + */ |
|
753 | + private static function _register_admin_pages($addon_name) |
|
754 | + { |
|
755 | + if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
756 | + EE_Register_Admin_Page::register( |
|
757 | + $addon_name, |
|
758 | + array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
759 | + ); |
|
760 | + } |
|
761 | + } |
|
762 | 762 | |
763 | 763 | |
764 | - /** |
|
765 | - * @param string $addon_name |
|
766 | - * @return void |
|
767 | - * @throws \EE_Error |
|
768 | - */ |
|
769 | - private static function _register_modules($addon_name) |
|
770 | - { |
|
771 | - if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
772 | - EE_Register_Module::register( |
|
773 | - $addon_name, |
|
774 | - array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
775 | - ); |
|
776 | - } |
|
777 | - } |
|
764 | + /** |
|
765 | + * @param string $addon_name |
|
766 | + * @return void |
|
767 | + * @throws \EE_Error |
|
768 | + */ |
|
769 | + private static function _register_modules($addon_name) |
|
770 | + { |
|
771 | + if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
772 | + EE_Register_Module::register( |
|
773 | + $addon_name, |
|
774 | + array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
775 | + ); |
|
776 | + } |
|
777 | + } |
|
778 | 778 | |
779 | 779 | |
780 | - /** |
|
781 | - * @param string $addon_name |
|
782 | - * @return void |
|
783 | - * @throws \EE_Error |
|
784 | - */ |
|
785 | - private static function _register_shortcodes($addon_name) |
|
786 | - { |
|
787 | - if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
788 | - EE_Register_Shortcode::register( |
|
789 | - $addon_name, |
|
790 | - array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']) |
|
791 | - ); |
|
792 | - } |
|
793 | - } |
|
780 | + /** |
|
781 | + * @param string $addon_name |
|
782 | + * @return void |
|
783 | + * @throws \EE_Error |
|
784 | + */ |
|
785 | + private static function _register_shortcodes($addon_name) |
|
786 | + { |
|
787 | + if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
788 | + EE_Register_Shortcode::register( |
|
789 | + $addon_name, |
|
790 | + array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']) |
|
791 | + ); |
|
792 | + } |
|
793 | + } |
|
794 | 794 | |
795 | 795 | |
796 | - /** |
|
797 | - * @param string $addon_name |
|
798 | - * @return void |
|
799 | - * @throws \EE_Error |
|
800 | - */ |
|
801 | - private static function _register_widgets($addon_name) |
|
802 | - { |
|
803 | - if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
804 | - EE_Register_Widget::register( |
|
805 | - $addon_name, |
|
806 | - array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
807 | - ); |
|
808 | - } |
|
809 | - } |
|
796 | + /** |
|
797 | + * @param string $addon_name |
|
798 | + * @return void |
|
799 | + * @throws \EE_Error |
|
800 | + */ |
|
801 | + private static function _register_widgets($addon_name) |
|
802 | + { |
|
803 | + if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
804 | + EE_Register_Widget::register( |
|
805 | + $addon_name, |
|
806 | + array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
807 | + ); |
|
808 | + } |
|
809 | + } |
|
810 | 810 | |
811 | 811 | |
812 | - /** |
|
813 | - * @param string $addon_name |
|
814 | - * @return void |
|
815 | - * @throws \EE_Error |
|
816 | - */ |
|
817 | - private static function _register_capabilities($addon_name) |
|
818 | - { |
|
819 | - if (! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
820 | - EE_Register_Capabilities::register( |
|
821 | - $addon_name, |
|
822 | - array( |
|
823 | - 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
824 | - 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
825 | - ) |
|
826 | - ); |
|
827 | - } |
|
828 | - } |
|
812 | + /** |
|
813 | + * @param string $addon_name |
|
814 | + * @return void |
|
815 | + * @throws \EE_Error |
|
816 | + */ |
|
817 | + private static function _register_capabilities($addon_name) |
|
818 | + { |
|
819 | + if (! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
820 | + EE_Register_Capabilities::register( |
|
821 | + $addon_name, |
|
822 | + array( |
|
823 | + 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
824 | + 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
825 | + ) |
|
826 | + ); |
|
827 | + } |
|
828 | + } |
|
829 | 829 | |
830 | 830 | |
831 | - /** |
|
832 | - * @param string $addon_name |
|
833 | - * @return void |
|
834 | - * @throws \EE_Error |
|
835 | - */ |
|
836 | - private static function _register_message_types($addon_name) |
|
837 | - { |
|
838 | - if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
839 | - add_action( |
|
840 | - 'EE_Brewing_Regular___messages_caf', |
|
841 | - array('EE_Register_Addon', 'register_message_types') |
|
842 | - ); |
|
843 | - } |
|
844 | - } |
|
831 | + /** |
|
832 | + * @param string $addon_name |
|
833 | + * @return void |
|
834 | + * @throws \EE_Error |
|
835 | + */ |
|
836 | + private static function _register_message_types($addon_name) |
|
837 | + { |
|
838 | + if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
839 | + add_action( |
|
840 | + 'EE_Brewing_Regular___messages_caf', |
|
841 | + array('EE_Register_Addon', 'register_message_types') |
|
842 | + ); |
|
843 | + } |
|
844 | + } |
|
845 | 845 | |
846 | 846 | |
847 | - /** |
|
848 | - * @param string $addon_name |
|
849 | - * @return void |
|
850 | - * @throws \EE_Error |
|
851 | - */ |
|
852 | - private static function _register_custom_post_types($addon_name) |
|
853 | - { |
|
854 | - if ( |
|
855 | - ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
856 | - || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
857 | - ) { |
|
858 | - EE_Register_CPT::register( |
|
859 | - $addon_name, |
|
860 | - array( |
|
861 | - 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
862 | - 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
863 | - 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
864 | - ) |
|
865 | - ); |
|
866 | - } |
|
867 | - } |
|
847 | + /** |
|
848 | + * @param string $addon_name |
|
849 | + * @return void |
|
850 | + * @throws \EE_Error |
|
851 | + */ |
|
852 | + private static function _register_custom_post_types($addon_name) |
|
853 | + { |
|
854 | + if ( |
|
855 | + ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
856 | + || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
857 | + ) { |
|
858 | + EE_Register_CPT::register( |
|
859 | + $addon_name, |
|
860 | + array( |
|
861 | + 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
862 | + 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
863 | + 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
864 | + ) |
|
865 | + ); |
|
866 | + } |
|
867 | + } |
|
868 | 868 | |
869 | 869 | |
870 | - /** |
|
871 | - * @param string $addon_name |
|
872 | - * @return void |
|
873 | - * @throws \EE_Error |
|
874 | - */ |
|
875 | - private static function _register_payment_methods($addon_name) |
|
876 | - { |
|
877 | - if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
878 | - EE_Register_Payment_Method::register( |
|
879 | - $addon_name, |
|
880 | - array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
881 | - ); |
|
882 | - } |
|
883 | - } |
|
870 | + /** |
|
871 | + * @param string $addon_name |
|
872 | + * @return void |
|
873 | + * @throws \EE_Error |
|
874 | + */ |
|
875 | + private static function _register_payment_methods($addon_name) |
|
876 | + { |
|
877 | + if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
878 | + EE_Register_Payment_Method::register( |
|
879 | + $addon_name, |
|
880 | + array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
881 | + ); |
|
882 | + } |
|
883 | + } |
|
884 | 884 | |
885 | 885 | |
886 | - /** |
|
887 | - * Loads and instantiates the EE_Addon class and adds it onto the registry |
|
888 | - * |
|
889 | - * @param string $addon_name |
|
890 | - * @return EE_Addon |
|
891 | - */ |
|
892 | - private static function _load_and_init_addon_class($addon_name) |
|
893 | - { |
|
894 | - $addon = EE_Registry::instance()->load_addon( |
|
895 | - dirname(self::$_settings[$addon_name]['main_file_path']), |
|
896 | - self::$_settings[$addon_name]['class_name'] |
|
897 | - ); |
|
898 | - $addon->set_name($addon_name); |
|
899 | - $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
900 | - $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
901 | - $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
902 | - $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
903 | - $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
904 | - $addon->set_version(self::$_settings[$addon_name]['version']); |
|
905 | - $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
906 | - $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
907 | - $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
908 | - $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
909 | - //unfortunately this can't be hooked in upon construction, because we don't have |
|
910 | - //the plugin mainfile's path upon construction. |
|
911 | - register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
912 | - // call any additional admin_callback functions during load_admin_controller hook |
|
913 | - if (! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
914 | - add_action( |
|
915 | - 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
916 | - array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
917 | - ); |
|
918 | - } |
|
919 | - return $addon; |
|
920 | - } |
|
886 | + /** |
|
887 | + * Loads and instantiates the EE_Addon class and adds it onto the registry |
|
888 | + * |
|
889 | + * @param string $addon_name |
|
890 | + * @return EE_Addon |
|
891 | + */ |
|
892 | + private static function _load_and_init_addon_class($addon_name) |
|
893 | + { |
|
894 | + $addon = EE_Registry::instance()->load_addon( |
|
895 | + dirname(self::$_settings[$addon_name]['main_file_path']), |
|
896 | + self::$_settings[$addon_name]['class_name'] |
|
897 | + ); |
|
898 | + $addon->set_name($addon_name); |
|
899 | + $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
900 | + $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
901 | + $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
902 | + $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
903 | + $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
904 | + $addon->set_version(self::$_settings[$addon_name]['version']); |
|
905 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
906 | + $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
907 | + $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
908 | + $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
909 | + //unfortunately this can't be hooked in upon construction, because we don't have |
|
910 | + //the plugin mainfile's path upon construction. |
|
911 | + register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
912 | + // call any additional admin_callback functions during load_admin_controller hook |
|
913 | + if (! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
914 | + add_action( |
|
915 | + 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
916 | + array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
917 | + ); |
|
918 | + } |
|
919 | + return $addon; |
|
920 | + } |
|
921 | 921 | |
922 | 922 | |
923 | - /** |
|
924 | - * load_pue_update - Update notifications |
|
925 | - * |
|
926 | - * @return void |
|
927 | - */ |
|
928 | - public static function load_pue_update() |
|
929 | - { |
|
930 | - // load PUE client |
|
931 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
932 | - // cycle thru settings |
|
933 | - foreach (self::$_settings as $settings) { |
|
934 | - if (! empty($settings['pue_options'])) { |
|
935 | - // initiate the class and start the plugin update engine! |
|
936 | - new PluginUpdateEngineChecker( |
|
937 | - // host file URL |
|
938 | - 'https://eventespresso.com', |
|
939 | - // plugin slug(s) |
|
940 | - array( |
|
941 | - 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
942 | - 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
943 | - ), |
|
944 | - // options |
|
945 | - array( |
|
946 | - 'apikey' => EE_Registry::instance()->NET_CFG->core->site_license_key, |
|
947 | - 'lang_domain' => 'event_espresso', |
|
948 | - 'checkPeriod' => $settings['pue_options']['checkPeriod'], |
|
949 | - 'option_key' => 'site_license_key', |
|
950 | - 'options_page_slug' => 'event_espresso', |
|
951 | - 'plugin_basename' => $settings['pue_options']['plugin_basename'], |
|
952 | - // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP |
|
953 | - 'use_wp_update' => $settings['pue_options']['use_wp_update'], |
|
954 | - ) |
|
955 | - ); |
|
956 | - } |
|
957 | - } |
|
958 | - } |
|
923 | + /** |
|
924 | + * load_pue_update - Update notifications |
|
925 | + * |
|
926 | + * @return void |
|
927 | + */ |
|
928 | + public static function load_pue_update() |
|
929 | + { |
|
930 | + // load PUE client |
|
931 | + require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
932 | + // cycle thru settings |
|
933 | + foreach (self::$_settings as $settings) { |
|
934 | + if (! empty($settings['pue_options'])) { |
|
935 | + // initiate the class and start the plugin update engine! |
|
936 | + new PluginUpdateEngineChecker( |
|
937 | + // host file URL |
|
938 | + 'https://eventespresso.com', |
|
939 | + // plugin slug(s) |
|
940 | + array( |
|
941 | + 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
942 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
943 | + ), |
|
944 | + // options |
|
945 | + array( |
|
946 | + 'apikey' => EE_Registry::instance()->NET_CFG->core->site_license_key, |
|
947 | + 'lang_domain' => 'event_espresso', |
|
948 | + 'checkPeriod' => $settings['pue_options']['checkPeriod'], |
|
949 | + 'option_key' => 'site_license_key', |
|
950 | + 'options_page_slug' => 'event_espresso', |
|
951 | + 'plugin_basename' => $settings['pue_options']['plugin_basename'], |
|
952 | + // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP |
|
953 | + 'use_wp_update' => $settings['pue_options']['use_wp_update'], |
|
954 | + ) |
|
955 | + ); |
|
956 | + } |
|
957 | + } |
|
958 | + } |
|
959 | 959 | |
960 | 960 | |
961 | - /** |
|
962 | - * Callback for EE_Brewing_Regular__messages_caf hook used to register message types. |
|
963 | - * |
|
964 | - * @since 4.4.0 |
|
965 | - * @return void |
|
966 | - * @throws \EE_Error |
|
967 | - */ |
|
968 | - public static function register_message_types() |
|
969 | - { |
|
970 | - foreach (self::$_settings as $addon_name => $settings) { |
|
971 | - if (! empty($settings['message_types'])) { |
|
972 | - foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) { |
|
973 | - EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
974 | - } |
|
975 | - } |
|
976 | - } |
|
977 | - } |
|
961 | + /** |
|
962 | + * Callback for EE_Brewing_Regular__messages_caf hook used to register message types. |
|
963 | + * |
|
964 | + * @since 4.4.0 |
|
965 | + * @return void |
|
966 | + * @throws \EE_Error |
|
967 | + */ |
|
968 | + public static function register_message_types() |
|
969 | + { |
|
970 | + foreach (self::$_settings as $addon_name => $settings) { |
|
971 | + if (! empty($settings['message_types'])) { |
|
972 | + foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) { |
|
973 | + EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
974 | + } |
|
975 | + } |
|
976 | + } |
|
977 | + } |
|
978 | 978 | |
979 | 979 | |
980 | - /** |
|
981 | - * This deregisters an addon that was previously registered with a specific addon_name. |
|
982 | - * |
|
983 | - * @since 4.3.0 |
|
984 | - * @param string $addon_name the name for the addon that was previously registered |
|
985 | - * @throws EE_Error |
|
986 | - * @return void |
|
987 | - */ |
|
988 | - public static function deregister($addon_name = null) |
|
989 | - { |
|
990 | - if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) { |
|
991 | - do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
|
992 | - $class_name = self::$_settings[$addon_name]['class_name']; |
|
993 | - if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
994 | - // setup DMS |
|
995 | - EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
996 | - } |
|
997 | - if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
998 | - // register admin page |
|
999 | - EE_Register_Admin_Page::deregister($addon_name); |
|
1000 | - } |
|
1001 | - if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
1002 | - // add to list of modules to be registered |
|
1003 | - EE_Register_Module::deregister($addon_name); |
|
1004 | - } |
|
1005 | - if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
1006 | - // add to list of shortcodes to be registered |
|
1007 | - EE_Register_Shortcode::deregister($addon_name); |
|
1008 | - } |
|
1009 | - if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
1010 | - // if config_class present let's register config. |
|
1011 | - EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
1012 | - } |
|
1013 | - if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
1014 | - // add to list of widgets to be registered |
|
1015 | - EE_Register_Widget::deregister($addon_name); |
|
1016 | - } |
|
1017 | - if (! empty(self::$_settings[$addon_name]['model_paths']) |
|
1018 | - || |
|
1019 | - ! empty(self::$_settings[$addon_name]['class_paths']) |
|
1020 | - ) { |
|
1021 | - // add to list of shortcodes to be registered |
|
1022 | - EE_Register_Model::deregister($addon_name); |
|
1023 | - } |
|
1024 | - if (! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
1025 | - || |
|
1026 | - ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
1027 | - ) { |
|
1028 | - // add to list of shortcodes to be registered |
|
1029 | - EE_Register_Model_Extensions::deregister($addon_name); |
|
1030 | - } |
|
1031 | - if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
1032 | - foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
1033 | - EE_Register_Message_Type::deregister($message_type); |
|
1034 | - } |
|
1035 | - } |
|
1036 | - //deregister capabilities for addon |
|
1037 | - if ( |
|
1038 | - ! empty(self::$_settings[$addon_name]['capabilities']) |
|
1039 | - || ! empty(self::$_settings[$addon_name]['capability_maps']) |
|
1040 | - ) { |
|
1041 | - EE_Register_Capabilities::deregister($addon_name); |
|
1042 | - } |
|
1043 | - //deregister custom_post_types for addon |
|
1044 | - if (! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
1045 | - EE_Register_CPT::deregister($addon_name); |
|
1046 | - } |
|
1047 | - remove_action( |
|
1048 | - 'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), |
|
1049 | - array(EE_Registry::instance()->addons->{$class_name}, 'deactivation') |
|
1050 | - ); |
|
1051 | - remove_action( |
|
1052 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
1053 | - array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required') |
|
1054 | - ); |
|
1055 | - unset(EE_Registry::instance()->addons->{$class_name}, self::$_settings[$addon_name]); |
|
1056 | - do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
|
1057 | - } |
|
1058 | - } |
|
980 | + /** |
|
981 | + * This deregisters an addon that was previously registered with a specific addon_name. |
|
982 | + * |
|
983 | + * @since 4.3.0 |
|
984 | + * @param string $addon_name the name for the addon that was previously registered |
|
985 | + * @throws EE_Error |
|
986 | + * @return void |
|
987 | + */ |
|
988 | + public static function deregister($addon_name = null) |
|
989 | + { |
|
990 | + if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) { |
|
991 | + do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
|
992 | + $class_name = self::$_settings[$addon_name]['class_name']; |
|
993 | + if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
994 | + // setup DMS |
|
995 | + EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
996 | + } |
|
997 | + if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
998 | + // register admin page |
|
999 | + EE_Register_Admin_Page::deregister($addon_name); |
|
1000 | + } |
|
1001 | + if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
1002 | + // add to list of modules to be registered |
|
1003 | + EE_Register_Module::deregister($addon_name); |
|
1004 | + } |
|
1005 | + if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
1006 | + // add to list of shortcodes to be registered |
|
1007 | + EE_Register_Shortcode::deregister($addon_name); |
|
1008 | + } |
|
1009 | + if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
1010 | + // if config_class present let's register config. |
|
1011 | + EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
1012 | + } |
|
1013 | + if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
1014 | + // add to list of widgets to be registered |
|
1015 | + EE_Register_Widget::deregister($addon_name); |
|
1016 | + } |
|
1017 | + if (! empty(self::$_settings[$addon_name]['model_paths']) |
|
1018 | + || |
|
1019 | + ! empty(self::$_settings[$addon_name]['class_paths']) |
|
1020 | + ) { |
|
1021 | + // add to list of shortcodes to be registered |
|
1022 | + EE_Register_Model::deregister($addon_name); |
|
1023 | + } |
|
1024 | + if (! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
1025 | + || |
|
1026 | + ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
1027 | + ) { |
|
1028 | + // add to list of shortcodes to be registered |
|
1029 | + EE_Register_Model_Extensions::deregister($addon_name); |
|
1030 | + } |
|
1031 | + if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
1032 | + foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
1033 | + EE_Register_Message_Type::deregister($message_type); |
|
1034 | + } |
|
1035 | + } |
|
1036 | + //deregister capabilities for addon |
|
1037 | + if ( |
|
1038 | + ! empty(self::$_settings[$addon_name]['capabilities']) |
|
1039 | + || ! empty(self::$_settings[$addon_name]['capability_maps']) |
|
1040 | + ) { |
|
1041 | + EE_Register_Capabilities::deregister($addon_name); |
|
1042 | + } |
|
1043 | + //deregister custom_post_types for addon |
|
1044 | + if (! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
1045 | + EE_Register_CPT::deregister($addon_name); |
|
1046 | + } |
|
1047 | + remove_action( |
|
1048 | + 'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), |
|
1049 | + array(EE_Registry::instance()->addons->{$class_name}, 'deactivation') |
|
1050 | + ); |
|
1051 | + remove_action( |
|
1052 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
1053 | + array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required') |
|
1054 | + ); |
|
1055 | + unset(EE_Registry::instance()->addons->{$class_name}, self::$_settings[$addon_name]); |
|
1056 | + do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
|
1057 | + } |
|
1058 | + } |
|
1059 | 1059 | |
1060 | 1060 | |
1061 | 1061 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | // offsets: 0 . 1 . 2 . 3 . 4 |
67 | 67 | $version_parts = explode('.', $min_core_version); |
68 | 68 | //check they specified the micro version (after 2nd period) |
69 | - if (! isset($version_parts[2])) { |
|
69 | + if ( ! isset($version_parts[2])) { |
|
70 | 70 | $version_parts[2] = '0'; |
71 | 71 | } |
72 | 72 | //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
73 | 73 | //soon we can assume that's 'rc', but this current version is 'alpha' |
74 | - if (! isset($version_parts[3])) { |
|
74 | + if ( ! isset($version_parts[3])) { |
|
75 | 75 | $version_parts[3] = 'dev'; |
76 | 76 | } |
77 | - if (! isset($version_parts[4])) { |
|
77 | + if ( ! isset($version_parts[4])) { |
|
78 | 78 | $version_parts[4] = '000'; |
79 | 79 | } |
80 | 80 | return implode('.', $version_parts); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | // setup PUE |
232 | 232 | \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
233 | 233 | // does this addon work with this version of core or WordPress ? |
234 | - if (! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
234 | + if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
235 | 235 | return; |
236 | 236 | } |
237 | 237 | // register namespaces |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | ) |
289 | 289 | ); |
290 | 290 | } |
291 | - if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
291 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
292 | 292 | throw new EE_Error( |
293 | 293 | sprintf( |
294 | 294 | __( |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | } else { |
330 | 330 | $class_name = $setup_args['class_name']; |
331 | 331 | } |
332 | - return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name; |
|
332 | + return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_'.$class_name; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -346,105 +346,105 @@ discard block |
||
346 | 346 | 'class_name' => $class_name, |
347 | 347 | // the addon slug for use in URLs, etc |
348 | 348 | 'plugin_slug' => isset($setup_args['plugin_slug']) |
349 | - ? (string)$setup_args['plugin_slug'] |
|
349 | + ? (string) $setup_args['plugin_slug'] |
|
350 | 350 | : '', |
351 | 351 | // page slug to be used when generating the "Settings" link on the WP plugin page |
352 | 352 | 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
353 | - ? (string)$setup_args['plugin_action_slug'] |
|
353 | + ? (string) $setup_args['plugin_action_slug'] |
|
354 | 354 | : '', |
355 | 355 | // the "software" version for the addon |
356 | 356 | 'version' => isset($setup_args['version']) |
357 | - ? (string)$setup_args['version'] |
|
357 | + ? (string) $setup_args['version'] |
|
358 | 358 | : '', |
359 | 359 | // the minimum version of EE Core that the addon will work with |
360 | 360 | 'min_core_version' => isset($setup_args['min_core_version']) |
361 | - ? (string)$setup_args['min_core_version'] |
|
361 | + ? (string) $setup_args['min_core_version'] |
|
362 | 362 | : '', |
363 | 363 | // the minimum version of WordPress that the addon will work with |
364 | 364 | 'min_wp_version' => isset($setup_args['min_wp_version']) |
365 | - ? (string)$setup_args['min_wp_version'] |
|
365 | + ? (string) $setup_args['min_wp_version'] |
|
366 | 366 | : EE_MIN_WP_VER_REQUIRED, |
367 | 367 | // full server path to main file (file loaded directly by WP) |
368 | 368 | 'main_file_path' => isset($setup_args['main_file_path']) |
369 | - ? (string)$setup_args['main_file_path'] |
|
369 | + ? (string) $setup_args['main_file_path'] |
|
370 | 370 | : '', |
371 | 371 | // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
372 | 372 | 'admin_path' => isset($setup_args['admin_path']) |
373 | - ? (string)$setup_args['admin_path'] : '', |
|
373 | + ? (string) $setup_args['admin_path'] : '', |
|
374 | 374 | // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
375 | 375 | 'admin_callback' => isset($setup_args['admin_callback']) |
376 | - ? (string)$setup_args['admin_callback'] |
|
376 | + ? (string) $setup_args['admin_callback'] |
|
377 | 377 | : '', |
378 | 378 | // the section name for this addon's configuration settings section (defaults to "addons") |
379 | 379 | 'config_section' => isset($setup_args['config_section']) |
380 | - ? (string)$setup_args['config_section'] |
|
380 | + ? (string) $setup_args['config_section'] |
|
381 | 381 | : 'addons', |
382 | 382 | // the class name for this addon's configuration settings object |
383 | 383 | 'config_class' => isset($setup_args['config_class']) |
384 | - ? (string)$setup_args['config_class'] : '', |
|
384 | + ? (string) $setup_args['config_class'] : '', |
|
385 | 385 | //the name given to the config for this addons' configuration settings object (optional) |
386 | 386 | 'config_name' => isset($setup_args['config_name']) |
387 | - ? (string)$setup_args['config_name'] : '', |
|
387 | + ? (string) $setup_args['config_name'] : '', |
|
388 | 388 | // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
389 | 389 | 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
390 | - ? (array)$setup_args['autoloader_paths'] |
|
390 | + ? (array) $setup_args['autoloader_paths'] |
|
391 | 391 | : array(), |
392 | 392 | // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
393 | 393 | 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
394 | - ? (array)$setup_args['autoloader_folders'] |
|
394 | + ? (array) $setup_args['autoloader_folders'] |
|
395 | 395 | : array(), |
396 | 396 | // array of full server paths to any EE_DMS data migration scripts used by the addon |
397 | 397 | 'dms_paths' => isset($setup_args['dms_paths']) |
398 | - ? (array)$setup_args['dms_paths'] |
|
398 | + ? (array) $setup_args['dms_paths'] |
|
399 | 399 | : array(), |
400 | 400 | // array of full server paths to any EED_Modules used by the addon |
401 | 401 | 'module_paths' => isset($setup_args['module_paths']) |
402 | - ? (array)$setup_args['module_paths'] |
|
402 | + ? (array) $setup_args['module_paths'] |
|
403 | 403 | : array(), |
404 | 404 | // array of full server paths to any EES_Shortcodes used by the addon |
405 | 405 | 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
406 | - ? (array)$setup_args['shortcode_paths'] |
|
406 | + ? (array) $setup_args['shortcode_paths'] |
|
407 | 407 | : array(), |
408 | 408 | // array of full server paths to any WP_Widgets used by the addon |
409 | 409 | 'widget_paths' => isset($setup_args['widget_paths']) |
410 | - ? (array)$setup_args['widget_paths'] |
|
410 | + ? (array) $setup_args['widget_paths'] |
|
411 | 411 | : array(), |
412 | 412 | // array of PUE options used by the addon |
413 | 413 | 'pue_options' => isset($setup_args['pue_options']) |
414 | - ? (array)$setup_args['pue_options'] |
|
414 | + ? (array) $setup_args['pue_options'] |
|
415 | 415 | : array(), |
416 | 416 | 'message_types' => isset($setup_args['message_types']) |
417 | - ? (array)$setup_args['message_types'] |
|
417 | + ? (array) $setup_args['message_types'] |
|
418 | 418 | : array(), |
419 | 419 | 'capabilities' => isset($setup_args['capabilities']) |
420 | - ? (array)$setup_args['capabilities'] |
|
420 | + ? (array) $setup_args['capabilities'] |
|
421 | 421 | : array(), |
422 | 422 | 'capability_maps' => isset($setup_args['capability_maps']) |
423 | - ? (array)$setup_args['capability_maps'] |
|
423 | + ? (array) $setup_args['capability_maps'] |
|
424 | 424 | : array(), |
425 | 425 | 'model_paths' => isset($setup_args['model_paths']) |
426 | - ? (array)$setup_args['model_paths'] |
|
426 | + ? (array) $setup_args['model_paths'] |
|
427 | 427 | : array(), |
428 | 428 | 'class_paths' => isset($setup_args['class_paths']) |
429 | - ? (array)$setup_args['class_paths'] |
|
429 | + ? (array) $setup_args['class_paths'] |
|
430 | 430 | : array(), |
431 | 431 | 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
432 | - ? (array)$setup_args['model_extension_paths'] |
|
432 | + ? (array) $setup_args['model_extension_paths'] |
|
433 | 433 | : array(), |
434 | 434 | 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
435 | - ? (array)$setup_args['class_extension_paths'] |
|
435 | + ? (array) $setup_args['class_extension_paths'] |
|
436 | 436 | : array(), |
437 | 437 | 'custom_post_types' => isset($setup_args['custom_post_types']) |
438 | - ? (array)$setup_args['custom_post_types'] |
|
438 | + ? (array) $setup_args['custom_post_types'] |
|
439 | 439 | : array(), |
440 | 440 | 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
441 | - ? (array)$setup_args['custom_taxonomies'] |
|
441 | + ? (array) $setup_args['custom_taxonomies'] |
|
442 | 442 | : array(), |
443 | 443 | 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
444 | - ? (array)$setup_args['payment_method_paths'] |
|
444 | + ? (array) $setup_args['payment_method_paths'] |
|
445 | 445 | : array(), |
446 | 446 | 'default_terms' => isset($setup_args['default_terms']) |
447 | - ? (array)$setup_args['default_terms'] |
|
447 | + ? (array) $setup_args['default_terms'] |
|
448 | 448 | : array(), |
449 | 449 | // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
450 | 450 | // that can be used for adding upgrading/marketing info |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $setup_args['namespace']['FQNS'], |
457 | 457 | $setup_args['namespace']['DIR'] |
458 | 458 | ) |
459 | - ? (array)$setup_args['namespace'] |
|
459 | + ? (array) $setup_args['namespace'] |
|
460 | 460 | : array(), |
461 | 461 | ); |
462 | 462 | // if plugin_action_slug is NOT set, but an admin page path IS set, |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | '</span><br />' |
527 | 527 | ); |
528 | 528 | } |
529 | - if (! empty($incompatibility_message)) { |
|
529 | + if ( ! empty($incompatibility_message)) { |
|
530 | 530 | // remove 'activate' from the REQUEST |
531 | 531 | // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
532 | 532 | unset($_GET['activate'], $_REQUEST['activate']); |
@@ -554,19 +554,19 @@ discard block |
||
554 | 554 | */ |
555 | 555 | private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
556 | 556 | { |
557 | - if (! empty($setup_args['pue_options'])) { |
|
557 | + if ( ! empty($setup_args['pue_options'])) { |
|
558 | 558 | self::$_settings[$addon_name]['pue_options'] = array( |
559 | 559 | 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
560 | - ? (string)$setup_args['pue_options']['pue_plugin_slug'] |
|
561 | - : 'espresso_' . strtolower($class_name), |
|
560 | + ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
|
561 | + : 'espresso_'.strtolower($class_name), |
|
562 | 562 | 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
563 | - ? (string)$setup_args['pue_options']['plugin_basename'] |
|
563 | + ? (string) $setup_args['pue_options']['plugin_basename'] |
|
564 | 564 | : plugin_basename($setup_args['main_file_path']), |
565 | 565 | 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
566 | - ? (string)$setup_args['pue_options']['checkPeriod'] |
|
566 | + ? (string) $setup_args['pue_options']['checkPeriod'] |
|
567 | 567 | : '24', |
568 | 568 | 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
569 | - ? (string)$setup_args['pue_options']['use_wp_update'] |
|
569 | + ? (string) $setup_args['pue_options']['use_wp_update'] |
|
570 | 570 | : false, |
571 | 571 | ); |
572 | 572 | add_action( |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | //to find if THIS is the addon that was activated, |
614 | 614 | //just check if we have already registered it or not |
615 | 615 | //(as the newly-activated addon wasn't around the first time addons were registered) |
616 | - if (! isset(self::$_settings[$addon_name])) { |
|
616 | + if ( ! isset(self::$_settings[$addon_name])) { |
|
617 | 617 | self::$_settings[$addon_name] = $addon_settings; |
618 | 618 | $addon = self::_load_and_init_addon_class($addon_name); |
619 | 619 | $addon->set_activation_indicator_option(); |
@@ -657,13 +657,13 @@ discard block |
||
657 | 657 | */ |
658 | 658 | private static function _setup_autoloaders($addon_name) |
659 | 659 | { |
660 | - if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
660 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
661 | 661 | // setup autoloader for single file |
662 | 662 | EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
663 | 663 | } |
664 | 664 | // setup autoloaders for folders |
665 | - if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
666 | - foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
665 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
666 | + foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
667 | 667 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
668 | 668 | } |
669 | 669 | } |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | private static function _register_data_migration_scripts($addon_name) |
717 | 717 | { |
718 | 718 | // setup DMS |
719 | - if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
719 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
720 | 720 | EE_Register_Data_Migration_Scripts::register( |
721 | 721 | $addon_name, |
722 | 722 | array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | private static function _register_config($addon_name) |
734 | 734 | { |
735 | 735 | // if config_class is present let's register config. |
736 | - if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
736 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
737 | 737 | EE_Register_Config::register( |
738 | 738 | self::$_settings[$addon_name]['config_class'], |
739 | 739 | array( |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | */ |
753 | 753 | private static function _register_admin_pages($addon_name) |
754 | 754 | { |
755 | - if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
755 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
756 | 756 | EE_Register_Admin_Page::register( |
757 | 757 | $addon_name, |
758 | 758 | array('page_path' => self::$_settings[$addon_name]['admin_path']) |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | */ |
769 | 769 | private static function _register_modules($addon_name) |
770 | 770 | { |
771 | - if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
771 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
772 | 772 | EE_Register_Module::register( |
773 | 773 | $addon_name, |
774 | 774 | array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | */ |
785 | 785 | private static function _register_shortcodes($addon_name) |
786 | 786 | { |
787 | - if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
787 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
788 | 788 | EE_Register_Shortcode::register( |
789 | 789 | $addon_name, |
790 | 790 | array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']) |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | */ |
801 | 801 | private static function _register_widgets($addon_name) |
802 | 802 | { |
803 | - if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
803 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
804 | 804 | EE_Register_Widget::register( |
805 | 805 | $addon_name, |
806 | 806 | array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | */ |
817 | 817 | private static function _register_capabilities($addon_name) |
818 | 818 | { |
819 | - if (! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
819 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
820 | 820 | EE_Register_Capabilities::register( |
821 | 821 | $addon_name, |
822 | 822 | array( |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | */ |
836 | 836 | private static function _register_message_types($addon_name) |
837 | 837 | { |
838 | - if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
838 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
839 | 839 | add_action( |
840 | 840 | 'EE_Brewing_Regular___messages_caf', |
841 | 841 | array('EE_Register_Addon', 'register_message_types') |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | */ |
875 | 875 | private static function _register_payment_methods($addon_name) |
876 | 876 | { |
877 | - if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
877 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
878 | 878 | EE_Register_Payment_Method::register( |
879 | 879 | $addon_name, |
880 | 880 | array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
@@ -910,7 +910,7 @@ discard block |
||
910 | 910 | //the plugin mainfile's path upon construction. |
911 | 911 | register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
912 | 912 | // call any additional admin_callback functions during load_admin_controller hook |
913 | - if (! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
913 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
914 | 914 | add_action( |
915 | 915 | 'AHEE__EE_System__load_controllers__load_admin_controllers', |
916 | 916 | array($addon, self::$_settings[$addon_name]['admin_callback']) |
@@ -928,10 +928,10 @@ discard block |
||
928 | 928 | public static function load_pue_update() |
929 | 929 | { |
930 | 930 | // load PUE client |
931 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
931 | + require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php'; |
|
932 | 932 | // cycle thru settings |
933 | 933 | foreach (self::$_settings as $settings) { |
934 | - if (! empty($settings['pue_options'])) { |
|
934 | + if ( ! empty($settings['pue_options'])) { |
|
935 | 935 | // initiate the class and start the plugin update engine! |
936 | 936 | new PluginUpdateEngineChecker( |
937 | 937 | // host file URL |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | // plugin slug(s) |
940 | 940 | array( |
941 | 941 | 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
942 | - 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
942 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'), |
|
943 | 943 | ), |
944 | 944 | // options |
945 | 945 | array( |
@@ -968,8 +968,8 @@ discard block |
||
968 | 968 | public static function register_message_types() |
969 | 969 | { |
970 | 970 | foreach (self::$_settings as $addon_name => $settings) { |
971 | - if (! empty($settings['message_types'])) { |
|
972 | - foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) { |
|
971 | + if ( ! empty($settings['message_types'])) { |
|
972 | + foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
|
973 | 973 | EE_Register_Message_Type::register($message_type, $message_type_settings); |
974 | 974 | } |
975 | 975 | } |
@@ -990,46 +990,46 @@ discard block |
||
990 | 990 | if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) { |
991 | 991 | do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
992 | 992 | $class_name = self::$_settings[$addon_name]['class_name']; |
993 | - if (! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
993 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
994 | 994 | // setup DMS |
995 | 995 | EE_Register_Data_Migration_Scripts::deregister($addon_name); |
996 | 996 | } |
997 | - if (! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
997 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
998 | 998 | // register admin page |
999 | 999 | EE_Register_Admin_Page::deregister($addon_name); |
1000 | 1000 | } |
1001 | - if (! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
1001 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
1002 | 1002 | // add to list of modules to be registered |
1003 | 1003 | EE_Register_Module::deregister($addon_name); |
1004 | 1004 | } |
1005 | - if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
1005 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) { |
|
1006 | 1006 | // add to list of shortcodes to be registered |
1007 | 1007 | EE_Register_Shortcode::deregister($addon_name); |
1008 | 1008 | } |
1009 | - if (! empty(self::$_settings[$addon_name]['config_class'])) { |
|
1009 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
1010 | 1010 | // if config_class present let's register config. |
1011 | 1011 | EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
1012 | 1012 | } |
1013 | - if (! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
1013 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
1014 | 1014 | // add to list of widgets to be registered |
1015 | 1015 | EE_Register_Widget::deregister($addon_name); |
1016 | 1016 | } |
1017 | - if (! empty(self::$_settings[$addon_name]['model_paths']) |
|
1017 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) |
|
1018 | 1018 | || |
1019 | 1019 | ! empty(self::$_settings[$addon_name]['class_paths']) |
1020 | 1020 | ) { |
1021 | 1021 | // add to list of shortcodes to be registered |
1022 | 1022 | EE_Register_Model::deregister($addon_name); |
1023 | 1023 | } |
1024 | - if (! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
1024 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
1025 | 1025 | || |
1026 | 1026 | ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
1027 | 1027 | ) { |
1028 | 1028 | // add to list of shortcodes to be registered |
1029 | 1029 | EE_Register_Model_Extensions::deregister($addon_name); |
1030 | 1030 | } |
1031 | - if (! empty(self::$_settings[$addon_name]['message_types'])) { |
|
1032 | - foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
1031 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
1032 | + foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) { |
|
1033 | 1033 | EE_Register_Message_Type::deregister($message_type); |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1041,11 +1041,11 @@ discard block |
||
1041 | 1041 | EE_Register_Capabilities::deregister($addon_name); |
1042 | 1042 | } |
1043 | 1043 | //deregister custom_post_types for addon |
1044 | - if (! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
1044 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
1045 | 1045 | EE_Register_CPT::deregister($addon_name); |
1046 | 1046 | } |
1047 | 1047 | remove_action( |
1048 | - 'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), |
|
1048 | + 'deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), |
|
1049 | 1049 | array(EE_Registry::instance()->addons->{$class_name}, 'deactivation') |
1050 | 1050 | ); |
1051 | 1051 | remove_action( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.38.rc.004'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.38.rc.004'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |