@@ -286,41 +286,41 @@ discard block |
||
286 | 286 | $this->checkout->revisit |
287 | 287 | ); |
288 | 288 | foreach ( $registrations as $REG_ID => $registration ) { |
289 | - /** @var $registration EE_Registration */ |
|
290 | - // has this registration lost it's space ? |
|
289 | + /** @var $registration EE_Registration */ |
|
290 | + // has this registration lost it's space ? |
|
291 | 291 | if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
292 | 292 | $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
293 | 293 | continue; |
294 | 294 | } |
295 | - // event requires admin approval |
|
296 | - if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
297 | - // add event to list of events with pre-approval reg status |
|
298 | - $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
299 | - do_action( |
|
300 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
|
301 | - $registration->event(), |
|
302 | - $this |
|
303 | - ); |
|
304 | - continue; |
|
305 | - } |
|
306 | - if ( |
|
295 | + // event requires admin approval |
|
296 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
297 | + // add event to list of events with pre-approval reg status |
|
298 | + $registrations_requiring_pre_approval[$REG_ID] = $registration; |
|
299 | + do_action( |
|
300 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
|
301 | + $registration->event(), |
|
302 | + $this |
|
303 | + ); |
|
304 | + continue; |
|
305 | + } |
|
306 | + if ( |
|
307 | 307 | // returning registrant |
308 | 308 | $this->checkout->revisit |
309 | 309 | // anything other than Approved |
310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_approved |
311 | - && ( |
|
312 | - $registration->event()->is_sold_out() |
|
313 | - || $registration->event()->is_sold_out( true ) |
|
314 | - ) |
|
315 | - ) { |
|
316 | - // add event to list of events that are sold out |
|
317 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
318 | - do_action( |
|
319 | - 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
|
320 | - $registration->event(), |
|
321 | - $this |
|
322 | - ); |
|
323 | - continue; |
|
311 | + && ( |
|
312 | + $registration->event()->is_sold_out() |
|
313 | + || $registration->event()->is_sold_out( true ) |
|
314 | + ) |
|
315 | + ) { |
|
316 | + // add event to list of events that are sold out |
|
317 | + $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
318 | + do_action( |
|
319 | + 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
|
320 | + $registration->event(), |
|
321 | + $this |
|
322 | + ); |
|
323 | + continue; |
|
324 | 324 | } |
325 | 325 | // are they allowed to pay now and is there monies owing? |
326 | 326 | if ( $registration->owes_monies_and_can_pay() ) { |
@@ -428,11 +428,11 @@ discard block |
||
428 | 428 | new EE_Billable_Line_Item_Filter( |
429 | 429 | EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations( |
430 | 430 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
431 | - EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
432 | - ) |
|
431 | + EE_Registry::instance()->SSN->checkout()->reg_cache_where_params |
|
432 | + ) |
|
433 | 433 | ) |
434 | 434 | ) |
435 | - ); |
|
435 | + ); |
|
436 | 436 | $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
437 | 437 | return $line_item_filter_collection; |
438 | 438 | } |
@@ -481,46 +481,46 @@ discard block |
||
481 | 481 | * @throws \EE_Error |
482 | 482 | */ |
483 | 483 | public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
484 | - // registrations per event |
|
484 | + // registrations per event |
|
485 | 485 | $event_reg_count = array(); |
486 | 486 | // spaces left per event |
487 | 487 | $event_spaces_remaining = array(); |
488 | - // tickets left sorted by ID |
|
489 | - $tickets_remaining = array(); |
|
490 | - // registrations that have lost their space |
|
488 | + // tickets left sorted by ID |
|
489 | + $tickets_remaining = array(); |
|
490 | + // registrations that have lost their space |
|
491 | 491 | $ejected_registrations = array(); |
492 | 492 | foreach ( $registrations as $REG_ID => $registration ) { |
493 | - if ( |
|
494 | - $registration->status_ID() === EEM_Registration::status_id_approved |
|
495 | - || apply_filters( |
|
496 | - 'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment', |
|
497 | - false, |
|
498 | - $registration, |
|
499 | - $revisit |
|
500 | - ) |
|
501 | - ) { |
|
502 | - continue; |
|
493 | + if ( |
|
494 | + $registration->status_ID() === EEM_Registration::status_id_approved |
|
495 | + || apply_filters( |
|
496 | + 'FHEE__EE_SPCO_Reg_Step_Payment_Options__find_registrations_that_lost_their_space__allow_reg_payment', |
|
497 | + false, |
|
498 | + $registration, |
|
499 | + $revisit |
|
500 | + ) |
|
501 | + ) { |
|
502 | + continue; |
|
503 | 503 | } |
504 | 504 | $EVT_ID = $registration->event_ID(); |
505 | - $ticket = $registration->ticket(); |
|
506 | - if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
507 | - $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
508 | - } |
|
509 | - if ($tickets_remaining[$ticket->ID()] > 0) { |
|
510 | - if ( ! isset($event_reg_count[$EVT_ID])) { |
|
511 | - $event_reg_count[$EVT_ID] = 0; |
|
512 | - } |
|
513 | - $event_reg_count[$EVT_ID]++; |
|
514 | - if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
515 | - $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
516 | - } |
|
517 | - } |
|
505 | + $ticket = $registration->ticket(); |
|
506 | + if ( ! isset($tickets_remaining[$ticket->ID()])) { |
|
507 | + $tickets_remaining[$ticket->ID()] = $ticket->remaining(); |
|
508 | + } |
|
509 | + if ($tickets_remaining[$ticket->ID()] > 0) { |
|
510 | + if ( ! isset($event_reg_count[$EVT_ID])) { |
|
511 | + $event_reg_count[$EVT_ID] = 0; |
|
512 | + } |
|
513 | + $event_reg_count[$EVT_ID]++; |
|
514 | + if ( ! isset($event_spaces_remaining[$EVT_ID])) { |
|
515 | + $event_spaces_remaining[$EVT_ID] = $registration->event()->spaces_remaining_for_sale(); |
|
516 | + } |
|
517 | + } |
|
518 | 518 | if ( |
519 | 519 | $revisit |
520 | 520 | && ( |
521 | - $tickets_remaining[$ticket->ID()] === 0 |
|
522 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
523 | - ) |
|
521 | + $tickets_remaining[$ticket->ID()] === 0 |
|
522 | + || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
523 | + ) |
|
524 | 524 | ) { |
525 | 525 | $ejected_registrations[ $REG_ID ] = $registration->event(); |
526 | 526 | if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
@@ -589,9 +589,9 @@ discard block |
||
589 | 589 | 'layout_strategy' => new EE_Template_Layout( |
590 | 590 | array( |
591 | 591 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
592 | - . $this->_slug |
|
593 | - . DS |
|
594 | - . 'sold_out_events.template.php', |
|
592 | + . $this->_slug |
|
593 | + . DS |
|
594 | + . 'sold_out_events.template.php', |
|
595 | 595 | 'template_args' => apply_filters( |
596 | 596 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
597 | 597 | array( |
@@ -644,9 +644,9 @@ discard block |
||
644 | 644 | 'layout_strategy' => new EE_Template_Layout( |
645 | 645 | array( |
646 | 646 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
647 | - . $this->_slug |
|
648 | - . DS |
|
649 | - . 'sold_out_events.template.php', |
|
647 | + . $this->_slug |
|
648 | + . DS |
|
649 | + . 'sold_out_events.template.php', |
|
650 | 650 | 'template_args' => apply_filters( |
651 | 651 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___insufficient_spaces_available__template_args', |
652 | 652 | array( |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | 'layout_strategy' => new EE_Template_Layout( |
695 | 695 | array( |
696 | 696 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
697 | - . $this->_slug |
|
698 | - . DS |
|
699 | - . 'events_requiring_pre_approval.template.php', // layout_template |
|
697 | + . $this->_slug |
|
698 | + . DS |
|
699 | + . 'events_requiring_pre_approval.template.php', // layout_template |
|
700 | 700 | 'template_args' => apply_filters( |
701 | 701 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
702 | 702 | array( |
@@ -734,9 +734,9 @@ discard block |
||
734 | 734 | 'layout_strategy' => new EE_Template_Layout( |
735 | 735 | array( |
736 | 736 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
737 | - . $this->_slug |
|
738 | - . DS |
|
739 | - . 'no_payment_required.template.php', // layout_template |
|
737 | + . $this->_slug |
|
738 | + . DS |
|
739 | + . 'no_payment_required.template.php', // layout_template |
|
740 | 740 | 'template_args' => apply_filters( |
741 | 741 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
742 | 742 | array( |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
965 | 965 | } |
966 | 966 | $payment_methods_billing_info[ $payment_method->slug() |
967 | - . '-info' ] = $this->_payment_method_billing_info( |
|
967 | + . '-info' ] = $this->_payment_method_billing_info( |
|
968 | 968 | $payment_method |
969 | 969 | ); |
970 | 970 | } |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | // fill form with attendee info if applicable |
1153 | 1153 | if ( |
1154 | 1154 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
1155 | - && $this->checkout->transaction_has_primary_registrant() |
|
1155 | + && $this->checkout->transaction_has_primary_registrant() |
|
1156 | 1156 | ) { |
1157 | 1157 | $payment_method_billing_form->populate_from_attendee( |
1158 | 1158 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | // and debug content |
1162 | 1162 | if ( |
1163 | 1163 | $payment_method_billing_form instanceof EE_Billing_Info_Form |
1164 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1164 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1165 | 1165 | ) { |
1166 | 1166 | $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1167 | 1167 | $payment_method_billing_form |
@@ -1336,7 +1336,7 @@ discard block |
||
1336 | 1336 | } |
1337 | 1337 | // and debug content |
1338 | 1338 | if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
1339 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1339 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1340 | 1340 | ) { |
1341 | 1341 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1342 | 1342 | $this->checkout->billing_form |
@@ -1506,8 +1506,8 @@ discard block |
||
1506 | 1506 | } |
1507 | 1507 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1508 | 1508 | if ( ! empty( $attendee_data['ATT_fname'] ) |
1509 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1510 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1509 | + && ! empty( $attendee_data['ATT_lname'] ) |
|
1510 | + && ! empty( $attendee_data['ATT_email'] ) |
|
1511 | 1511 | ) { |
1512 | 1512 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1513 | 1513 | array( |
@@ -1754,7 +1754,7 @@ discard block |
||
1754 | 1754 | $payment_status = $payment->status(); |
1755 | 1755 | if ( |
1756 | 1756 | $payment_status === EEM_Payment::status_id_approved |
1757 | - || $payment_status === EEM_Payment::status_id_pending |
|
1757 | + || $payment_status === EEM_Payment::status_id_pending |
|
1758 | 1758 | ) { |
1759 | 1759 | return true; |
1760 | 1760 | } else { |
@@ -1980,8 +1980,8 @@ discard block |
||
1980 | 1980 | return false; |
1981 | 1981 | } |
1982 | 1982 | if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
1983 | - instanceof |
|
1984 | - EE_Attendee |
|
1983 | + instanceof |
|
1984 | + EE_Attendee |
|
1985 | 1985 | ) { |
1986 | 1986 | EE_Error::add_error( |
1987 | 1987 | sprintf( |
@@ -2454,14 +2454,14 @@ discard block |
||
2454 | 2454 | |
2455 | 2455 | |
2456 | 2456 | |
2457 | - /** |
|
2458 | - * _validate_return |
|
2459 | - * |
|
2460 | - * @access private |
|
2461 | - * @return void |
|
2462 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
2463 | - * @throws \EE_Error |
|
2464 | - */ |
|
2457 | + /** |
|
2458 | + * _validate_return |
|
2459 | + * |
|
2460 | + * @access private |
|
2461 | + * @return void |
|
2462 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
2463 | + * @throws \EE_Error |
|
2464 | + */ |
|
2465 | 2465 | private function _validate_offsite_return() { |
2466 | 2466 | $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
2467 | 2467 | if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
@@ -2487,20 +2487,20 @@ discard block |
||
2487 | 2487 | ? $primary_registrant->session_ID() |
2488 | 2488 | : null; |
2489 | 2489 | // validate current Session ID and compare against valid TXN session ID |
2490 | - if ( |
|
2491 | - $invalid_TXN // if this is already true, then skip other checks |
|
2492 | - || EE_Session::instance()->id() === null |
|
2493 | - || ( |
|
2494 | - // WARNING !!! |
|
2495 | - // this could be PayPal sending back duplicate requests (ya they do that) |
|
2496 | - // or it **could** mean someone is simply registering AGAIN after having just done so |
|
2497 | - // so now we need to determine if this current TXN looks valid or not |
|
2498 | - // and whether this reg step has even been started ? |
|
2499 | - EE_Session::instance()->id() === $valid_TXN_SID |
|
2500 | - // really? you're half way through this reg step, but you never started it ? |
|
2501 | - && $this->checkout->transaction->reg_step_completed($this->slug()) === false |
|
2502 | - ) |
|
2503 | - ) { |
|
2490 | + if ( |
|
2491 | + $invalid_TXN // if this is already true, then skip other checks |
|
2492 | + || EE_Session::instance()->id() === null |
|
2493 | + || ( |
|
2494 | + // WARNING !!! |
|
2495 | + // this could be PayPal sending back duplicate requests (ya they do that) |
|
2496 | + // or it **could** mean someone is simply registering AGAIN after having just done so |
|
2497 | + // so now we need to determine if this current TXN looks valid or not |
|
2498 | + // and whether this reg step has even been started ? |
|
2499 | + EE_Session::instance()->id() === $valid_TXN_SID |
|
2500 | + // really? you're half way through this reg step, but you never started it ? |
|
2501 | + && $this->checkout->transaction->reg_step_completed($this->slug()) === false |
|
2502 | + ) |
|
2503 | + ) { |
|
2504 | 2504 | $invalid_TXN = true; |
2505 | 2505 | } |
2506 | 2506 | if ( $invalid_TXN ) { |
@@ -2702,19 +2702,19 @@ discard block |
||
2702 | 2702 | |
2703 | 2703 | |
2704 | 2704 | |
2705 | - /** |
|
2706 | - * __sleep |
|
2707 | - * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization |
|
2708 | - * EE_Checkout will handle the reimplementation of itself upon waking, |
|
2709 | - * but we won't bother with the reg form, because if needed, it will be regenerated anyways |
|
2710 | - * |
|
2711 | - * @return array |
|
2712 | - */ |
|
2713 | - public function __sleep() |
|
2714 | - { |
|
2715 | - // remove the reg form and the checkout |
|
2716 | - return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
2717 | - } |
|
2705 | + /** |
|
2706 | + * __sleep |
|
2707 | + * to conserve db space, let's remove the reg_form and the EE_Checkout object from EE_SPCO_Reg_Step objects upon serialization |
|
2708 | + * EE_Checkout will handle the reimplementation of itself upon waking, |
|
2709 | + * but we won't bother with the reg form, because if needed, it will be regenerated anyways |
|
2710 | + * |
|
2711 | + * @return array |
|
2712 | + */ |
|
2713 | + public function __sleep() |
|
2714 | + { |
|
2715 | + // remove the reg form and the checkout |
|
2716 | + return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
2717 | + } |
|
2718 | 2718 | |
2719 | 2719 | |
2720 | 2720 |
@@ -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 | |
@@ -38,32 +38,32 @@ discard block |
||
38 | 38 | public static function set_hooks() { |
39 | 39 | add_filter( |
40 | 40 | 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
41 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) |
|
41 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
42 | 42 | ); |
43 | 43 | add_action( |
44 | 44 | 'wp_ajax_switch_spco_billing_form', |
45 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
45 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'wp_ajax_nopriv_switch_spco_billing_form', |
49 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
49 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
50 | 50 | ); |
51 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) ); |
|
51 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
52 | 52 | add_action( |
53 | 53 | 'wp_ajax_nopriv_save_payer_details', |
54 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) |
|
54 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
55 | 55 | ); |
56 | 56 | add_action( |
57 | 57 | 'wp_ajax_get_transaction_details_for_gateways', |
58 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
58 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
59 | 59 | ); |
60 | 60 | add_action( |
61 | 61 | 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
62 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
62 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
63 | 63 | ); |
64 | 64 | add_filter( |
65 | 65 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
66 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), |
|
66 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
67 | 67 | 10, |
68 | 68 | 1 |
69 | 69 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws \EE_Error |
78 | 78 | */ |
79 | 79 | public static function switch_spco_billing_form() { |
80 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
80 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @throws \EE_Error |
89 | 89 | */ |
90 | 90 | public static function save_payer_details() { |
91 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
91 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | 101 | public static function get_transaction_details() { |
102 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
102 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * @access public |
127 | 127 | * @param EE_Checkout $checkout |
128 | 128 | */ |
129 | - public function __construct( EE_Checkout $checkout ) { |
|
129 | + public function __construct(EE_Checkout $checkout) { |
|
130 | 130 | $this->_slug = 'payment_options'; |
131 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
132 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
131 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
132 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
133 | 133 | $this->checkout = $checkout; |
134 | 134 | $this->_reset_success_message(); |
135 | 135 | $this->set_instructions( |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /** |
155 | 155 | * @param null $line_item_display |
156 | 156 | */ |
157 | - public function set_line_item_display( $line_item_display ) { |
|
157 | + public function set_line_item_display($line_item_display) { |
|
158 | 158 | $this->line_item_display = $line_item_display; |
159 | 159 | } |
160 | 160 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | /** |
173 | 173 | * @param boolean $handle_IPN_in_this_request |
174 | 174 | */ |
175 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
176 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
175 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
176 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | public function enqueue_styles_and_scripts() { |
209 | 209 | $transaction = $this->checkout->transaction; |
210 | 210 | //if the transaction isn't set or nothing is owed on it, don't enqueue any JS |
211 | - if( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) { |
|
211 | + if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | - foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) { |
|
214 | + foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) { |
|
215 | 215 | $type_obj = $payment_method->type_obj(); |
216 | - if( $type_obj instanceof EE_PMT_Base ) { |
|
217 | - $billing_form = $type_obj->generate_new_billing_form( $transaction ); |
|
218 | - if( $billing_form instanceof EE_Form_Section_Proper ) { |
|
216 | + if ($type_obj instanceof EE_PMT_Base) { |
|
217 | + $billing_form = $type_obj->generate_new_billing_form($transaction); |
|
218 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
219 | 219 | $billing_form->enqueue_js(); |
220 | 220 | } |
221 | 221 | } |
@@ -240,20 +240,20 @@ discard block |
||
240 | 240 | // $ 0.00 transactions (no payment required) |
241 | 241 | ! $this->checkout->payment_required() |
242 | 242 | // but do NOT remove if current action being called belongs to this reg step |
243 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
243 | + && ! is_callable(array($this, $this->checkout->action)) |
|
244 | 244 | && ! $this->completed() |
245 | 245 | ) { |
246 | 246 | // and if so, then we no longer need the Payment Options step |
247 | - if ( $this->is_current_step() ) { |
|
247 | + if ($this->is_current_step()) { |
|
248 | 248 | $this->checkout->generate_reg_form = false; |
249 | 249 | } |
250 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
250 | + $this->checkout->remove_reg_step($this->_slug); |
|
251 | 251 | // DEBUG LOG |
252 | 252 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | // load EEM_Payment_Method |
256 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
256 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
257 | 257 | // get all active payment methods |
258 | 258 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
259 | 259 | $this->checkout->transaction, |
@@ -280,16 +280,16 @@ discard block |
||
280 | 280 | $insufficient_spaces_available = array(); |
281 | 281 | $no_payment_required = true; |
282 | 282 | // loop thru registrations to gather info |
283 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
283 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
284 | 284 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
285 | 285 | $registrations, |
286 | 286 | $this->checkout->revisit |
287 | 287 | ); |
288 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
288 | + foreach ($registrations as $REG_ID => $registration) { |
|
289 | 289 | /** @var $registration EE_Registration */ |
290 | 290 | // has this registration lost it's space ? |
291 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
292 | - $insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event(); |
|
291 | + if (isset($ejected_registrations[$REG_ID])) { |
|
292 | + $insufficient_spaces_available[$registration->event()->ID()] = $registration->event(); |
|
293 | 293 | continue; |
294 | 294 | } |
295 | 295 | // event requires admin approval |
@@ -310,11 +310,11 @@ discard block |
||
310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_approved |
311 | 311 | && ( |
312 | 312 | $registration->event()->is_sold_out() |
313 | - || $registration->event()->is_sold_out( true ) |
|
313 | + || $registration->event()->is_sold_out(true) |
|
314 | 314 | ) |
315 | 315 | ) { |
316 | 316 | // add event to list of events that are sold out |
317 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
317 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
318 | 318 | do_action( |
319 | 319 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
320 | 320 | $registration->event(), |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | continue; |
324 | 324 | } |
325 | 325 | // are they allowed to pay now and is there monies owing? |
326 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
327 | - $registrations_requiring_payment[ $REG_ID ] = $registration; |
|
326 | + if ($registration->owes_monies_and_can_pay()) { |
|
327 | + $registrations_requiring_payment[$REG_ID] = $registration; |
|
328 | 328 | do_action( |
329 | 329 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
330 | 330 | $registration->event(), |
@@ -335,29 +335,29 @@ discard block |
||
335 | 335 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
336 | 336 | && $registration->ticket()->is_free() |
337 | 337 | ) { |
338 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
338 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | $subsections = array(); |
342 | 342 | // now decide which template to load |
343 | - if ( ! empty( $sold_out_events ) ) { |
|
344 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
343 | + if ( ! empty($sold_out_events)) { |
|
344 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
345 | 345 | } |
346 | - if ( ! empty( $insufficient_spaces_available ) ) { |
|
346 | + if ( ! empty($insufficient_spaces_available)) { |
|
347 | 347 | $subsections['insufficient_space'] = $this->_insufficient_spaces_available( |
348 | 348 | $insufficient_spaces_available |
349 | 349 | ); |
350 | 350 | } |
351 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
351 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
352 | 352 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
353 | 353 | $registrations_requiring_pre_approval |
354 | 354 | ); |
355 | 355 | } |
356 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
357 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
356 | + if ( ! empty($registrations_for_free_events)) { |
|
357 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
358 | 358 | } |
359 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
360 | - if ( $this->checkout->amount_owing > 0 ) { |
|
359 | + if ( ! empty($registrations_requiring_payment)) { |
|
360 | + if ($this->checkout->amount_owing > 0) { |
|
361 | 361 | // autoload Line_Item_Display classes |
362 | 362 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
363 | 363 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -370,15 +370,15 @@ discard block |
||
370 | 370 | /** @var EE_Line_Item $filtered_line_item_tree */ |
371 | 371 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
372 | 372 | EEH_Autoloader::register_line_item_display_autoloaders(); |
373 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
373 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
374 | 374 | $subsections['payment_options'] = $this->_display_payment_options( |
375 | 375 | $this->line_item_display->display_line_item( |
376 | 376 | $filtered_line_item_tree, |
377 | - array( 'registrations' => $registrations ) |
|
377 | + array('registrations' => $registrations) |
|
378 | 378 | ) |
379 | 379 | ); |
380 | 380 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
381 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
381 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
382 | 382 | } |
383 | 383 | $no_payment_required = false; |
384 | 384 | } else { |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $this->_save_selected_method_of_payment(); |
388 | 388 | |
389 | 389 | $subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs(); |
390 | - $subsections['extra_hidden_inputs' ] = $this->_extra_hidden_inputs( $no_payment_required ); |
|
390 | + $subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required); |
|
391 | 391 | |
392 | 392 | return new EE_Form_Section_Proper( |
393 | 393 | array( |
@@ -414,14 +414,14 @@ discard block |
||
414 | 414 | * @return \EE_Line_Item_Filter_Collection |
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
418 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
417 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
418 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
419 | 419 | return $line_item_filter_collection; |
420 | 420 | } |
421 | - if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout ) { |
|
421 | + if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) { |
|
422 | 422 | return $line_item_filter_collection; |
423 | 423 | } |
424 | - if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction ) { |
|
424 | + if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) { |
|
425 | 425 | return $line_item_filter_collection; |
426 | 426 | } |
427 | 427 | $line_item_filter_collection->add( |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | ) |
434 | 434 | ) |
435 | 435 | ); |
436 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
436 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
437 | 437 | return $line_item_filter_collection; |
438 | 438 | } |
439 | 439 | |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * @return \EE_Registration[] |
450 | 450 | * @throws \EE_Error |
451 | 451 | */ |
452 | - public static function remove_ejected_registrations( array $registrations ) { |
|
452 | + public static function remove_ejected_registrations(array $registrations) { |
|
453 | 453 | $ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space( |
454 | 454 | $registrations, |
455 | 455 | EE_Registry::instance()->SSN->checkout()->revisit |
456 | 456 | ); |
457 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
457 | + foreach ($registrations as $REG_ID => $registration) { |
|
458 | 458 | // has this registration lost it's space ? |
459 | - if ( isset( $ejected_registrations[ $REG_ID ] ) ) { |
|
460 | - unset( $registrations[ $REG_ID ] ); |
|
459 | + if (isset($ejected_registrations[$REG_ID])) { |
|
460 | + unset($registrations[$REG_ID]); |
|
461 | 461 | continue; |
462 | 462 | } |
463 | 463 | } |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * @return array |
481 | 481 | * @throws \EE_Error |
482 | 482 | */ |
483 | - public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) { |
|
483 | + public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) { |
|
484 | 484 | // registrations per event |
485 | 485 | $event_reg_count = array(); |
486 | 486 | // spaces left per event |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | $tickets_remaining = array(); |
490 | 490 | // registrations that have lost their space |
491 | 491 | $ejected_registrations = array(); |
492 | - foreach ( $registrations as $REG_ID => $registration ) { |
|
492 | + foreach ($registrations as $REG_ID => $registration) { |
|
493 | 493 | if ( |
494 | 494 | $registration->status_ID() === EEM_Registration::status_id_approved |
495 | 495 | || apply_filters( |
@@ -519,13 +519,13 @@ discard block |
||
519 | 519 | $revisit |
520 | 520 | && ( |
521 | 521 | $tickets_remaining[$ticket->ID()] === 0 |
522 | - || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ] |
|
522 | + || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID] |
|
523 | 523 | ) |
524 | 524 | ) { |
525 | - $ejected_registrations[ $REG_ID ] = $registration->event(); |
|
526 | - if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) { |
|
525 | + $ejected_registrations[$REG_ID] = $registration->event(); |
|
526 | + if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) { |
|
527 | 527 | /** @type EE_Registration_Processor $registration_processor */ |
528 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
528 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
529 | 529 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
530 | 530 | $registration_processor->manually_update_registration_status( |
531 | 531 | $registration, |
@@ -560,8 +560,8 @@ discard block |
||
560 | 560 | * @return void |
561 | 561 | */ |
562 | 562 | protected function _hide_reg_step_submit_button_if_revisit() { |
563 | - if ( $this->checkout->revisit ) { |
|
564 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
563 | + if ($this->checkout->revisit) { |
|
564 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
565 | 565 | } |
566 | 566 | } |
567 | 567 | |
@@ -575,13 +575,13 @@ discard block |
||
575 | 575 | * @return \EE_Form_Section_Proper |
576 | 576 | * @throws \EE_Error |
577 | 577 | */ |
578 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
578 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
579 | 579 | // set some defaults |
580 | 580 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
581 | 581 | $sold_out_events = ''; |
582 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
582 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
583 | 583 | $sold_out_events .= EEH_HTML::li( |
584 | - EEH_HTML::span( ' ' .$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
584 | + EEH_HTML::span(' '.$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
585 | 585 | ); |
586 | 586 | } |
587 | 587 | return new EE_Form_Section_Proper( |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | 'sold_out_events_msg' => apply_filters( |
600 | 600 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
601 | 601 | sprintf( |
602 | - __( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso' ), |
|
602 | + __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.%3$s%3$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%2$s', 'event_espresso'), |
|
603 | 603 | '<strong>', |
604 | 604 | '</strong>', |
605 | 605 | '<br />' |
@@ -624,14 +624,14 @@ discard block |
||
624 | 624 | * @return \EE_Form_Section_Proper |
625 | 625 | * @throws \EE_Error |
626 | 626 | */ |
627 | - private function _insufficient_spaces_available( $insufficient_spaces_events_array = array() ) { |
|
627 | + private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) { |
|
628 | 628 | // set some defaults |
629 | 629 | $this->checkout->selected_method_of_payment = 'invoice'; |
630 | 630 | $insufficient_space_events = ''; |
631 | - foreach ( $insufficient_spaces_events_array as $event ) { |
|
632 | - if ( $event instanceof EE_Event ) { |
|
631 | + foreach ($insufficient_spaces_events_array as $event) { |
|
632 | + if ($event instanceof EE_Event) { |
|
633 | 633 | $insufficient_space_events .= EEH_HTML::li( |
634 | - EEH_HTML::span( ' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
634 | + EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
635 | 635 | ); |
636 | 636 | } |
637 | 637 | } |
@@ -675,17 +675,17 @@ discard block |
||
675 | 675 | * @return \EE_Form_Section_Proper |
676 | 676 | * @throws \EE_Error |
677 | 677 | */ |
678 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
678 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
679 | 679 | $events_requiring_pre_approval = ''; |
680 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
681 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
682 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
680 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
681 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
682 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
683 | 683 | EEH_HTML::span( |
684 | 684 | '', |
685 | 685 | '', |
686 | 686 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
687 | 687 | ) |
688 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
688 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
689 | 689 | ); |
690 | 690 | } |
691 | 691 | } |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | 'template_args' => apply_filters( |
701 | 701 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
702 | 702 | array( |
703 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
703 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
704 | 704 | 'events_requiring_pre_approval_msg' => apply_filters( |
705 | 705 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
706 | 706 | __( |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | * @return \EE_Form_Section_Proper |
726 | 726 | * @throws \EE_Error |
727 | 727 | */ |
728 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
728 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
729 | 729 | // set some defaults |
730 | 730 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
731 | 731 | // generate no_payment_required form |
@@ -745,7 +745,7 @@ discard block |
||
745 | 745 | 'ticket_count' => array(), |
746 | 746 | 'registrations_for_free_events' => $registrations_for_free_events, |
747 | 747 | 'no_payment_required_msg' => EEH_HTML::p( |
748 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
748 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
749 | 749 | ) |
750 | 750 | ) |
751 | 751 | ), |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | * @return \EE_Form_Section_Proper |
765 | 765 | * @throws \EE_Error |
766 | 766 | */ |
767 | - private function _display_payment_options( $transaction_details = '' ) { |
|
767 | + private function _display_payment_options($transaction_details = '') { |
|
768 | 768 | // has method_of_payment been set by no-js user? |
769 | 769 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
770 | 770 | // build payment options form |
@@ -776,14 +776,14 @@ discard block |
||
776 | 776 | 'before_payment_options' => apply_filters( |
777 | 777 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
778 | 778 | new EE_Form_Section_Proper( |
779 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
779 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
780 | 780 | ) |
781 | 781 | ), |
782 | 782 | 'payment_options' => $this->_setup_payment_options(), |
783 | 783 | 'after_payment_options' => apply_filters( |
784 | 784 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
785 | 785 | new EE_Form_Section_Proper( |
786 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
786 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
787 | 787 | ) |
788 | 788 | ), |
789 | 789 | ), |
@@ -814,10 +814,10 @@ discard block |
||
814 | 814 | * @return \EE_Form_Section_Proper |
815 | 815 | * @throws \EE_Error |
816 | 816 | */ |
817 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
817 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
818 | 818 | return new EE_Form_Section_Proper( |
819 | 819 | array( |
820 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
820 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
821 | 821 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
822 | 822 | 'subsections' => array( |
823 | 823 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -849,16 +849,16 @@ discard block |
||
849 | 849 | * @access protected |
850 | 850 | * @param array $registrations |
851 | 851 | */ |
852 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
852 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
853 | 853 | $payments = array(); |
854 | - foreach ( $registrations as $registration ) { |
|
855 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
854 | + foreach ($registrations as $registration) { |
|
855 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
856 | 856 | $payments += $registration->registration_payments(); |
857 | 857 | } |
858 | 858 | } |
859 | - if ( ! empty( $payments ) ) { |
|
860 | - foreach ( $payments as $payment ) { |
|
861 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
859 | + if ( ! empty($payments)) { |
|
860 | + foreach ($payments as $payment) { |
|
861 | + if ($payment instanceof EE_Registration_Payment) { |
|
862 | 862 | $this->checkout->amount_owing -= $payment->amount(); |
863 | 863 | } |
864 | 864 | } |
@@ -874,11 +874,11 @@ discard block |
||
874 | 874 | * @param bool $force_reset |
875 | 875 | * @return void |
876 | 876 | */ |
877 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
877 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
878 | 878 | $reset_payment_method = $force_reset |
879 | 879 | ? true |
880 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
881 | - if ( $reset_payment_method ) { |
|
880 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
881 | + if ($reset_payment_method) { |
|
882 | 882 | $this->checkout->selected_method_of_payment = null; |
883 | 883 | $this->checkout->payment_method = null; |
884 | 884 | $this->checkout->billing_form = null; |
@@ -897,12 +897,12 @@ discard block |
||
897 | 897 | * @param string $selected_method_of_payment |
898 | 898 | * @return void |
899 | 899 | */ |
900 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
901 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
900 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
901 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
902 | 902 | ? $selected_method_of_payment |
903 | 903 | : $this->checkout->selected_method_of_payment; |
904 | 904 | EE_Registry::instance()->SSN->set_session_data( |
905 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
905 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
906 | 906 | ); |
907 | 907 | } |
908 | 908 | |
@@ -918,19 +918,19 @@ discard block |
||
918 | 918 | // load payment method classes |
919 | 919 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
920 | 920 | // switch up header depending on number of available payment methods |
921 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
921 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
922 | 922 | ? apply_filters( |
923 | 923 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
924 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
924 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
925 | 925 | ) |
926 | 926 | : apply_filters( |
927 | 927 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
928 | - __( 'Method of Payment', 'event_espresso' ) |
|
928 | + __('Method of Payment', 'event_espresso') |
|
929 | 929 | ); |
930 | 930 | $available_payment_methods = array( |
931 | 931 | // display the "Payment Method" header |
932 | 932 | 'payment_method_header' => new EE_Form_Section_HTML( |
933 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
933 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
934 | 934 | ) |
935 | 935 | ); |
936 | 936 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -939,32 +939,32 @@ discard block |
||
939 | 939 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
940 | 940 | $payment_methods_billing_info = array( |
941 | 941 | new EE_Form_Section_HTML( |
942 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
942 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
943 | 943 | ) |
944 | 944 | ); |
945 | 945 | // loop through payment methods |
946 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
947 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
946 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
947 | + if ($payment_method instanceof EE_Payment_Method) { |
|
948 | 948 | $payment_method_button = EEH_HTML::img( |
949 | 949 | $payment_method->button_url(), |
950 | 950 | $payment_method->name(), |
951 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
951 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
952 | 952 | 'spco-payment-method-btn-img' |
953 | 953 | ); |
954 | 954 | // check if any payment methods are set as default |
955 | 955 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
956 | 956 | if ( |
957 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
958 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
957 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
958 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
959 | 959 | ) { |
960 | 960 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
961 | 961 | $this->_save_selected_method_of_payment(); |
962 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
962 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
963 | 963 | } else { |
964 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
964 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
965 | 965 | } |
966 | - $payment_methods_billing_info[ $payment_method->slug() |
|
967 | - . '-info' ] = $this->_payment_method_billing_info( |
|
966 | + $payment_methods_billing_info[$payment_method->slug() |
|
967 | + . '-info'] = $this->_payment_method_billing_info( |
|
968 | 968 | $payment_method |
969 | 969 | ); |
970 | 970 | } |
@@ -994,12 +994,12 @@ discard block |
||
994 | 994 | * @return EE_Payment_Method[] |
995 | 995 | */ |
996 | 996 | protected function _get_available_payment_methods() { |
997 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
997 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
998 | 998 | return $this->checkout->available_payment_methods; |
999 | 999 | } |
1000 | 1000 | $available_payment_methods = array(); |
1001 | 1001 | // load EEM_Payment_Method |
1002 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1002 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1003 | 1003 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1004 | 1004 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1005 | 1005 | // get all active payment methods |
@@ -1007,9 +1007,9 @@ discard block |
||
1007 | 1007 | $this->checkout->transaction, |
1008 | 1008 | EEM_Payment_Method::scope_cart |
1009 | 1009 | ); |
1010 | - foreach ( $payment_methods as $payment_method ) { |
|
1011 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
1012 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
1010 | + foreach ($payment_methods as $payment_method) { |
|
1011 | + if ($payment_method instanceof EE_Payment_Method) { |
|
1012 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
1013 | 1013 | } |
1014 | 1014 | } |
1015 | 1015 | return $available_payment_methods; |
@@ -1024,14 +1024,14 @@ discard block |
||
1024 | 1024 | * @param array $available_payment_method_options |
1025 | 1025 | * @return \EE_Form_Section_Proper |
1026 | 1026 | */ |
1027 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
1027 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
1028 | 1028 | // generate inputs |
1029 | 1029 | return new EE_Form_Section_Proper( |
1030 | 1030 | array( |
1031 | 1031 | 'html_id' => 'ee-available-payment-method-inputs', |
1032 | 1032 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1033 | 1033 | 'subsections' => array( |
1034 | - '' => new EE_Radio_Button_Input ( |
|
1034 | + '' => new EE_Radio_Button_Input( |
|
1035 | 1035 | $available_payment_method_options, |
1036 | 1036 | array( |
1037 | 1037 | 'html_name' => 'selected_method_of_payment', |
@@ -1056,28 +1056,28 @@ discard block |
||
1056 | 1056 | * @return \EE_Form_Section_Proper |
1057 | 1057 | * @throws \EE_Error |
1058 | 1058 | */ |
1059 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
1059 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
1060 | 1060 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
1061 | 1061 | ? true |
1062 | 1062 | : false; |
1063 | 1063 | // generate the billing form for payment method |
1064 | 1064 | $billing_form = $currently_selected |
1065 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
1065 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
1066 | 1066 | : new EE_Form_Section_HTML(); |
1067 | 1067 | $this->checkout->billing_form = $currently_selected |
1068 | 1068 | ? $billing_form |
1069 | 1069 | : $this->checkout->billing_form; |
1070 | 1070 | // it's all in the details |
1071 | 1071 | $info_html = EEH_HTML::h3( |
1072 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
1072 | + __('Important information regarding your payment', 'event_espresso'), |
|
1073 | 1073 | '', |
1074 | 1074 | 'spco-payment-method-hdr' |
1075 | 1075 | ); |
1076 | 1076 | // add some info regarding the step, either from what's saved in the admin, |
1077 | 1077 | // or a default string depending on whether the PM has a billing form or not |
1078 | - if ( $payment_method->description() ) { |
|
1078 | + if ($payment_method->description()) { |
|
1079 | 1079 | $payment_method_info = $payment_method->description(); |
1080 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1080 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
1081 | 1081 | $payment_method_info = sprintf( |
1082 | 1082 | __( |
1083 | 1083 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | ); |
1088 | 1088 | } else { |
1089 | 1089 | $payment_method_info = sprintf( |
1090 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
1090 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
1091 | 1091 | $this->submit_button_text() |
1092 | 1092 | ); |
1093 | 1093 | } |
@@ -1101,13 +1101,13 @@ discard block |
||
1101 | 1101 | ); |
1102 | 1102 | return new EE_Form_Section_Proper( |
1103 | 1103 | array( |
1104 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
1104 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
1105 | 1105 | 'html_class' => 'spco-payment-method-info-dv', |
1106 | 1106 | // only display the selected or default PM |
1107 | 1107 | 'html_style' => $currently_selected ? '' : 'display:none;', |
1108 | 1108 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
1109 | 1109 | 'subsections' => array( |
1110 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
1110 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
1111 | 1111 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
1112 | 1112 | ) |
1113 | 1113 | ) |
@@ -1125,15 +1125,15 @@ discard block |
||
1125 | 1125 | */ |
1126 | 1126 | public function get_billing_form_html_for_payment_method() { |
1127 | 1127 | // how have they chosen to pay? |
1128 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1128 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1129 | 1129 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1130 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1130 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1131 | 1131 | return false; |
1132 | 1132 | } |
1133 | - if ( apply_filters( |
|
1133 | + if (apply_filters( |
|
1134 | 1134 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1135 | 1135 | false |
1136 | - ) ) { |
|
1136 | + )) { |
|
1137 | 1137 | EE_Error::add_success( |
1138 | 1138 | apply_filters( |
1139 | 1139 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | ); |
1149 | 1149 | } |
1150 | 1150 | // now generate billing form for selected method of payment |
1151 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1151 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1152 | 1152 | // fill form with attendee info if applicable |
1153 | 1153 | if ( |
1154 | 1154 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -1170,10 +1170,10 @@ discard block |
||
1170 | 1170 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
1171 | 1171 | ? $payment_method_billing_form->get_html() |
1172 | 1172 | : ''; |
1173 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
1173 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
1174 | 1174 | // localize validation rules for main form |
1175 | 1175 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
1176 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1176 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1177 | 1177 | return true; |
1178 | 1178 | } |
1179 | 1179 | |
@@ -1187,18 +1187,18 @@ discard block |
||
1187 | 1187 | * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML |
1188 | 1188 | * @throws \EE_Error |
1189 | 1189 | */ |
1190 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
1190 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
1191 | 1191 | $billing_form = $payment_method->type_obj()->billing_form( |
1192 | 1192 | $this->checkout->transaction, |
1193 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
1193 | + array('amount_owing' => $this->checkout->amount_owing) |
|
1194 | 1194 | ); |
1195 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
1195 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
1196 | 1196 | if ( |
1197 | 1197 | apply_filters( |
1198 | 1198 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1199 | 1199 | false |
1200 | 1200 | ) |
1201 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
1201 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
1202 | 1202 | ) { |
1203 | 1203 | EE_Error::add_success( |
1204 | 1204 | apply_filters( |
@@ -1240,15 +1240,15 @@ discard block |
||
1240 | 1240 | $request_param = 'selected_method_of_payment' |
1241 | 1241 | ) { |
1242 | 1242 | // is selected_method_of_payment set in the request ? |
1243 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
1244 | - if ( $selected_method_of_payment ) { |
|
1243 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
1244 | + if ($selected_method_of_payment) { |
|
1245 | 1245 | // sanitize it |
1246 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
1247 | - ? array_shift( $selected_method_of_payment ) |
|
1246 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
1247 | + ? array_shift($selected_method_of_payment) |
|
1248 | 1248 | : $selected_method_of_payment; |
1249 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
1249 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
1250 | 1250 | // store it in the session so that it's available for all subsequent requests including AJAX |
1251 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
1251 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
1252 | 1252 | } else { |
1253 | 1253 | // or is is set in the session ? |
1254 | 1254 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | ); |
1257 | 1257 | } |
1258 | 1258 | // do ya really really gotta have it? |
1259 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
1259 | + if (empty($selected_method_of_payment) && $required) { |
|
1260 | 1260 | EE_Error::add_error( |
1261 | 1261 | sprintf( |
1262 | 1262 | __( |
@@ -1265,7 +1265,7 @@ discard block |
||
1265 | 1265 | ), |
1266 | 1266 | '<br/>', |
1267 | 1267 | '<br/>', |
1268 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1268 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1269 | 1269 | ), |
1270 | 1270 | __FILE__, |
1271 | 1271 | __FUNCTION__, |
@@ -1292,13 +1292,13 @@ discard block |
||
1292 | 1292 | * @throws \EE_Error |
1293 | 1293 | */ |
1294 | 1294 | public function switch_payment_method() { |
1295 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1295 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1296 | 1296 | return false; |
1297 | 1297 | } |
1298 | - if ( apply_filters( |
|
1298 | + if (apply_filters( |
|
1299 | 1299 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1300 | 1300 | false |
1301 | - ) ) { |
|
1301 | + )) { |
|
1302 | 1302 | EE_Error::add_success( |
1303 | 1303 | apply_filters( |
1304 | 1304 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1313,7 +1313,7 @@ discard block |
||
1313 | 1313 | ); |
1314 | 1314 | } |
1315 | 1315 | // generate billing form for selected method of payment if it hasn't been done already |
1316 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1316 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1317 | 1317 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1318 | 1318 | $this->checkout->payment_method |
1319 | 1319 | ); |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | ); |
1336 | 1336 | } |
1337 | 1337 | // and debug content |
1338 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1338 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1339 | 1339 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
1340 | 1340 | ) { |
1341 | 1341 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1343,15 +1343,15 @@ discard block |
||
1343 | 1343 | ); |
1344 | 1344 | } |
1345 | 1345 | // get html and validation rules for form |
1346 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
1346 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
1347 | 1347 | $this->checkout->json_response->set_return_data( |
1348 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
1348 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
1349 | 1349 | ); |
1350 | 1350 | // localize validation rules for main form |
1351 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
1352 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1351 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
1352 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1353 | 1353 | } else { |
1354 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
1354 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
1355 | 1355 | } |
1356 | 1356 | //prevents advancement to next step |
1357 | 1357 | $this->checkout->continue_reg = false; |
@@ -1368,18 +1368,18 @@ discard block |
||
1368 | 1368 | */ |
1369 | 1369 | protected function _verify_payment_method_is_set() { |
1370 | 1370 | // generate billing form for selected method of payment if it hasn't been done already |
1371 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1371 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1372 | 1372 | // how have they chosen to pay? |
1373 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1373 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1374 | 1374 | } else { |
1375 | 1375 | // choose your own adventure based on method_of_payment |
1376 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1376 | + switch ($this->checkout->selected_method_of_payment) { |
|
1377 | 1377 | case 'events_sold_out' : |
1378 | 1378 | EE_Error::add_attention( |
1379 | 1379 | apply_filters( |
1380 | 1380 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg', |
1381 | - __( 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
1382 | - 'event_espresso' ) |
|
1381 | + __('It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.', |
|
1382 | + 'event_espresso') |
|
1383 | 1383 | ), |
1384 | 1384 | __FILE__, __FUNCTION__, __LINE__ |
1385 | 1385 | ); |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | EE_Error::add_attention( |
1390 | 1390 | apply_filters( |
1391 | 1391 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg', |
1392 | - __( 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
1392 | + __('It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
1393 | 1393 | ), |
1394 | 1394 | __FILE__, __FUNCTION__, __LINE__ |
1395 | 1395 | ); |
@@ -1399,7 +1399,7 @@ discard block |
||
1399 | 1399 | EE_Error::add_attention( |
1400 | 1400 | apply_filters( |
1401 | 1401 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg', |
1402 | - __( 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso' ) |
|
1402 | + __('It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso') |
|
1403 | 1403 | ), |
1404 | 1404 | __FILE__, __FUNCTION__, __LINE__ |
1405 | 1405 | ); |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | } |
1410 | 1410 | } |
1411 | 1411 | // verify payment method |
1412 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1412 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1413 | 1413 | // get payment method for selected method of payment |
1414 | 1414 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1415 | 1415 | } |
@@ -1428,25 +1428,25 @@ discard block |
||
1428 | 1428 | * @throws \EE_Error |
1429 | 1429 | */ |
1430 | 1430 | public function save_payer_details_via_ajax() { |
1431 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1431 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1432 | 1432 | return; |
1433 | 1433 | } |
1434 | 1434 | // generate billing form for selected method of payment if it hasn't been done already |
1435 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1435 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1436 | 1436 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1437 | 1437 | $this->checkout->payment_method |
1438 | 1438 | ); |
1439 | 1439 | } |
1440 | 1440 | // generate primary attendee from payer info if applicable |
1441 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1441 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1442 | 1442 | $attendee = $this->_create_attendee_from_request_data(); |
1443 | - if ( $attendee instanceof EE_Attendee ) { |
|
1444 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
1445 | - if ( $registration->is_primary_registrant() ) { |
|
1443 | + if ($attendee instanceof EE_Attendee) { |
|
1444 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
1445 | + if ($registration->is_primary_registrant()) { |
|
1446 | 1446 | $this->checkout->primary_attendee_obj = $attendee; |
1447 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1448 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1449 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1447 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1448 | + $registration->set_attendee_id($attendee->ID()); |
|
1449 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1450 | 1450 | } |
1451 | 1451 | } |
1452 | 1452 | } |
@@ -1464,50 +1464,50 @@ discard block |
||
1464 | 1464 | */ |
1465 | 1465 | protected function _create_attendee_from_request_data() { |
1466 | 1466 | // get State ID |
1467 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
1468 | - if ( ! empty( $STA_ID ) ) { |
|
1467 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
1468 | + if ( ! empty($STA_ID)) { |
|
1469 | 1469 | // can we get state object from name ? |
1470 | - EE_Registry::instance()->load_model( 'State' ); |
|
1471 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
1472 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
1470 | + EE_Registry::instance()->load_model('State'); |
|
1471 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
1472 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
1473 | 1473 | } |
1474 | 1474 | // get Country ISO |
1475 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
1476 | - if ( ! empty( $CNT_ISO ) ) { |
|
1475 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
1476 | + if ( ! empty($CNT_ISO)) { |
|
1477 | 1477 | // can we get country object from name ? |
1478 | - EE_Registry::instance()->load_model( 'Country' ); |
|
1478 | + EE_Registry::instance()->load_model('Country'); |
|
1479 | 1479 | $country = EEM_Country::instance()->get_col( |
1480 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
1480 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
1481 | 1481 | 'CNT_ISO' |
1482 | 1482 | ); |
1483 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
1483 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
1484 | 1484 | } |
1485 | 1485 | // grab attendee data |
1486 | 1486 | $attendee_data = array( |
1487 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
1488 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1489 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1490 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1491 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1492 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
1487 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
1488 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1489 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1490 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1491 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1492 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1493 | 1493 | 'STA_ID' => $STA_ID, |
1494 | 1494 | 'CNT_ISO' => $CNT_ISO, |
1495 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1496 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1495 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1496 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1497 | 1497 | ); |
1498 | 1498 | // validate the email address since it is the most important piece of info |
1499 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
1499 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
1500 | 1500 | EE_Error::add_error( |
1501 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
1501 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
1502 | 1502 | __FILE__, |
1503 | 1503 | __FUNCTION__, |
1504 | 1504 | __LINE__ |
1505 | 1505 | ); |
1506 | 1506 | } |
1507 | 1507 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1508 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
1509 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1510 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1508 | + if ( ! empty($attendee_data['ATT_fname']) |
|
1509 | + && ! empty($attendee_data['ATT_lname']) |
|
1510 | + && ! empty($attendee_data['ATT_email']) |
|
1511 | 1511 | ) { |
1512 | 1512 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1513 | 1513 | array( |
@@ -1516,19 +1516,19 @@ discard block |
||
1516 | 1516 | 'ATT_email' => $attendee_data['ATT_email'] |
1517 | 1517 | ) |
1518 | 1518 | ); |
1519 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1519 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1520 | 1520 | return $existing_attendee; |
1521 | 1521 | } |
1522 | 1522 | } |
1523 | 1523 | // no existing attendee? kk let's create a new one |
1524 | 1524 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1525 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
1525 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
1526 | 1526 | ? $attendee_data['ATT_fname'] |
1527 | 1527 | : $attendee_data['ATT_email']; |
1528 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
1528 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
1529 | 1529 | ? $attendee_data['ATT_lname'] |
1530 | 1530 | : $attendee_data['ATT_email']; |
1531 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1531 | + return EE_Attendee::new_instance($attendee_data); |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | |
@@ -1546,26 +1546,26 @@ discard block |
||
1546 | 1546 | // how have they chosen to pay? |
1547 | 1547 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
1548 | 1548 | ? 'no_payment_required' |
1549 | - : $this->_get_selected_method_of_payment( true ); |
|
1549 | + : $this->_get_selected_method_of_payment(true); |
|
1550 | 1550 | // choose your own adventure based on method_of_payment |
1551 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1551 | + switch ($this->checkout->selected_method_of_payment) { |
|
1552 | 1552 | |
1553 | 1553 | case 'events_sold_out' : |
1554 | 1554 | $this->checkout->redirect = true; |
1555 | 1555 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1556 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1556 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1557 | 1557 | // mark this reg step as completed |
1558 | 1558 | $this->set_completed(); |
1559 | 1559 | return false; |
1560 | 1560 | break; |
1561 | 1561 | |
1562 | 1562 | case 'payments_closed' : |
1563 | - if ( apply_filters( |
|
1563 | + if (apply_filters( |
|
1564 | 1564 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
1565 | 1565 | false |
1566 | - ) ) { |
|
1566 | + )) { |
|
1567 | 1567 | EE_Error::add_success( |
1568 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
1568 | + __('no payment required at this time.', 'event_espresso'), |
|
1569 | 1569 | __FILE__, |
1570 | 1570 | __FUNCTION__, |
1571 | 1571 | __LINE__ |
@@ -1577,12 +1577,12 @@ discard block |
||
1577 | 1577 | break; |
1578 | 1578 | |
1579 | 1579 | case 'no_payment_required' : |
1580 | - if ( apply_filters( |
|
1580 | + if (apply_filters( |
|
1581 | 1581 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
1582 | 1582 | false |
1583 | - ) ) { |
|
1583 | + )) { |
|
1584 | 1584 | EE_Error::add_success( |
1585 | - __( 'no payment required.', 'event_espresso' ), |
|
1585 | + __('no payment required.', 'event_espresso'), |
|
1586 | 1586 | __FILE__, |
1587 | 1587 | __FUNCTION__, |
1588 | 1588 | __LINE__ |
@@ -1602,15 +1602,15 @@ discard block |
||
1602 | 1602 | EE_Registry::instance()->SSN->checkout()->revisit |
1603 | 1603 | ); |
1604 | 1604 | // calculate difference between the two arrays |
1605 | - $registrations = array_diff( $registrations, $ejected_registrations ); |
|
1606 | - if ( empty( $registrations ) ) { |
|
1605 | + $registrations = array_diff($registrations, $ejected_registrations); |
|
1606 | + if (empty($registrations)) { |
|
1607 | 1607 | $this->_redirect_because_event_sold_out(); |
1608 | 1608 | return false; |
1609 | 1609 | } |
1610 | 1610 | $payment_successful = $this->_process_payment(); |
1611 | - if ( $payment_successful ) { |
|
1611 | + if ($payment_successful) { |
|
1612 | 1612 | $this->checkout->continue_reg = true; |
1613 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1613 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1614 | 1614 | } else { |
1615 | 1615 | $this->checkout->continue_reg = false; |
1616 | 1616 | } |
@@ -1631,10 +1631,10 @@ discard block |
||
1631 | 1631 | $this->checkout->continue_reg = false; |
1632 | 1632 | // set redirect URL |
1633 | 1633 | $this->checkout->redirect_url = add_query_arg( |
1634 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1634 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1635 | 1635 | $this->checkout->current_step->reg_step_url() |
1636 | 1636 | ); |
1637 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1637 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1638 | 1638 | } |
1639 | 1639 | |
1640 | 1640 | |
@@ -1647,8 +1647,8 @@ discard block |
||
1647 | 1647 | * @return void |
1648 | 1648 | * @throws \EE_Error |
1649 | 1649 | */ |
1650 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1651 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1650 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1651 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1652 | 1652 | case EE_PMT_Base::offsite : |
1653 | 1653 | break; |
1654 | 1654 | case EE_PMT_Base::onsite : |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | public function update_reg_step() { |
1672 | 1672 | $success = true; |
1673 | 1673 | // if payment required |
1674 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1674 | + if ($this->checkout->transaction->total() > 0) { |
|
1675 | 1675 | do_action( |
1676 | 1676 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
1677 | 1677 | $this->checkout->transaction |
@@ -1679,13 +1679,13 @@ discard block |
||
1679 | 1679 | // attempt payment via payment method |
1680 | 1680 | $success = $this->process_reg_step(); |
1681 | 1681 | } |
1682 | - if ( $success && ! $this->checkout->redirect ) { |
|
1682 | + if ($success && ! $this->checkout->redirect) { |
|
1683 | 1683 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
1684 | 1684 | $this->checkout->transaction->ID() |
1685 | 1685 | ); |
1686 | 1686 | // set return URL |
1687 | 1687 | $this->checkout->redirect_url = add_query_arg( |
1688 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1688 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1689 | 1689 | $this->checkout->thank_you_page_url |
1690 | 1690 | ); |
1691 | 1691 | } |
@@ -1703,36 +1703,36 @@ discard block |
||
1703 | 1703 | */ |
1704 | 1704 | private function _process_payment() { |
1705 | 1705 | // basically confirm that the event hasn't sold out since they hit the page |
1706 | - if ( ! $this->_last_second_ticket_verifications() ) { |
|
1706 | + if ( ! $this->_last_second_ticket_verifications()) { |
|
1707 | 1707 | return false; |
1708 | 1708 | } |
1709 | 1709 | // ya gotta make a choice man |
1710 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1710 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1711 | 1711 | $this->checkout->json_response->set_plz_select_method_of_payment( |
1712 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1712 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1713 | 1713 | ); |
1714 | 1714 | return false; |
1715 | 1715 | } |
1716 | 1716 | // get EE_Payment_Method object |
1717 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1717 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1718 | 1718 | return false; |
1719 | 1719 | } |
1720 | 1720 | // setup billing form |
1721 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1721 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1722 | 1722 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1723 | 1723 | $this->checkout->payment_method |
1724 | 1724 | ); |
1725 | 1725 | // bad billing form ? |
1726 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1726 | + if ( ! $this->_billing_form_is_valid()) { |
|
1727 | 1727 | return false; |
1728 | 1728 | } |
1729 | 1729 | } |
1730 | 1730 | // ensure primary registrant has been fully processed |
1731 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1731 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1732 | 1732 | return false; |
1733 | 1733 | } |
1734 | 1734 | // if session is close to expiring (under 10 minutes by default) |
1735 | - if ( ( time() - EE_Registry::instance()->SSN->expiration() ) < EE_Registry::instance()->SSN->extension() ) { |
|
1735 | + if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) { |
|
1736 | 1736 | // add some time to session expiration so that payment can be completed |
1737 | 1737 | EE_Registry::instance()->SSN->extend_expiration(); |
1738 | 1738 | } |
@@ -1741,12 +1741,12 @@ discard block |
||
1741 | 1741 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1742 | 1742 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1743 | 1743 | // attempt payment |
1744 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1744 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1745 | 1745 | // process results |
1746 | - $payment = $this->_validate_payment( $payment ); |
|
1747 | - $payment = $this->_post_payment_processing( $payment ); |
|
1746 | + $payment = $this->_validate_payment($payment); |
|
1747 | + $payment = $this->_post_payment_processing($payment); |
|
1748 | 1748 | // verify payment |
1749 | - if ( $payment instanceof EE_Payment ) { |
|
1749 | + if ($payment instanceof EE_Payment) { |
|
1750 | 1750 | // store that for later |
1751 | 1751 | $this->checkout->payment = $payment; |
1752 | 1752 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
@@ -1760,7 +1760,7 @@ discard block |
||
1760 | 1760 | } else { |
1761 | 1761 | return false; |
1762 | 1762 | } |
1763 | - } else if ( $payment === true ) { |
|
1763 | + } else if ($payment === true) { |
|
1764 | 1764 | // please note that offline payment methods will NOT make a payment, |
1765 | 1765 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1766 | 1766 | $this->checkout->payment = $payment; |
@@ -1780,22 +1780,22 @@ discard block |
||
1780 | 1780 | */ |
1781 | 1781 | protected function _last_second_ticket_verifications() { |
1782 | 1782 | // don't bother re-validating if not a return visit |
1783 | - if ( ! $this->checkout->revisit ) { |
|
1783 | + if ( ! $this->checkout->revisit) { |
|
1784 | 1784 | return true; |
1785 | 1785 | } |
1786 | 1786 | $registrations = $this->checkout->transaction->registrations(); |
1787 | - if ( empty( $registrations ) ) { |
|
1787 | + if (empty($registrations)) { |
|
1788 | 1788 | return false; |
1789 | 1789 | } |
1790 | - foreach ( $registrations as $registration ) { |
|
1791 | - if ( $registration instanceof EE_Registration ) { |
|
1790 | + foreach ($registrations as $registration) { |
|
1791 | + if ($registration instanceof EE_Registration) { |
|
1792 | 1792 | $event = $registration->event_obj(); |
1793 | - if ( $event instanceof EE_Event && $event->is_sold_out( true ) ) { |
|
1793 | + if ($event instanceof EE_Event && $event->is_sold_out(true)) { |
|
1794 | 1794 | EE_Error::add_error( |
1795 | 1795 | apply_filters( |
1796 | 1796 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg', |
1797 | 1797 | sprintf( |
1798 | - __( 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ), |
|
1798 | + __('It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso'), |
|
1799 | 1799 | $event->name() |
1800 | 1800 | ) |
1801 | 1801 | ), |
@@ -1825,7 +1825,7 @@ discard block |
||
1825 | 1825 | ); |
1826 | 1826 | $html = $payment_method_billing_info->get_html(); |
1827 | 1827 | $html .= $this->checkout->redirect_form; |
1828 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1828 | + EE_Registry::instance()->REQ->add_output($html); |
|
1829 | 1829 | return true; |
1830 | 1830 | } |
1831 | 1831 | |
@@ -1839,28 +1839,28 @@ discard block |
||
1839 | 1839 | * @throws \EE_Error |
1840 | 1840 | */ |
1841 | 1841 | private function _billing_form_is_valid() { |
1842 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1842 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1843 | 1843 | return true; |
1844 | 1844 | } |
1845 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1846 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1845 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1846 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1847 | 1847 | $this->checkout->billing_form->receive_form_submission(); |
1848 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1848 | + if ($this->checkout->billing_form->is_valid()) { |
|
1849 | 1849 | return true; |
1850 | 1850 | } |
1851 | 1851 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1852 | 1852 | $error_strings = array(); |
1853 | - foreach ( $validation_errors as $validation_error ) { |
|
1854 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1853 | + foreach ($validation_errors as $validation_error) { |
|
1854 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1855 | 1855 | $form_section = $validation_error->get_form_section(); |
1856 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
1856 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1857 | 1857 | $label = $form_section->html_label_text(); |
1858 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
1858 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1859 | 1859 | $label = $form_section->name(); |
1860 | 1860 | } else { |
1861 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1861 | + $label = __('Validation Error', 'event_espresso'); |
|
1862 | 1862 | } |
1863 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1863 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1864 | 1864 | } |
1865 | 1865 | } |
1866 | 1866 | EE_Error::add_error( |
@@ -1870,7 +1870,7 @@ discard block |
||
1870 | 1870 | 'event_espresso' |
1871 | 1871 | ), |
1872 | 1872 | '<br/>', |
1873 | - implode( '<br/>', $error_strings ) |
|
1873 | + implode('<br/>', $error_strings) |
|
1874 | 1874 | ), |
1875 | 1875 | __FILE__, |
1876 | 1876 | __FUNCTION__, |
@@ -1889,7 +1889,7 @@ discard block |
||
1889 | 1889 | } |
1890 | 1890 | } else { |
1891 | 1891 | EE_Error::add_error( |
1892 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
1892 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
1893 | 1893 | __FILE__, |
1894 | 1894 | __FUNCTION__, |
1895 | 1895 | __LINE__ |
@@ -1928,7 +1928,7 @@ discard block |
||
1928 | 1928 | // save the TXN ( which clears cached copy of primary_registration) |
1929 | 1929 | $this->checkout->transaction->save(); |
1930 | 1930 | // grab TXN ID and save it to the primary_registration |
1931 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1931 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1932 | 1932 | // save what we have so far |
1933 | 1933 | $primary_registration->save(); |
1934 | 1934 | return true; |
@@ -1946,7 +1946,7 @@ discard block |
||
1946 | 1946 | private function _capture_primary_registration_data_from_billing_form() { |
1947 | 1947 | // convert billing form data into an attendee |
1948 | 1948 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1949 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1949 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1950 | 1950 | EE_Error::add_error( |
1951 | 1951 | sprintf( |
1952 | 1952 | __( |
@@ -1954,7 +1954,7 @@ discard block |
||
1954 | 1954 | 'event_espresso' |
1955 | 1955 | ), |
1956 | 1956 | '<br/>', |
1957 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1957 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1958 | 1958 | ), |
1959 | 1959 | __FILE__, |
1960 | 1960 | __FUNCTION__, |
@@ -1963,7 +1963,7 @@ discard block |
||
1963 | 1963 | return false; |
1964 | 1964 | } |
1965 | 1965 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1966 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1966 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1967 | 1967 | EE_Error::add_error( |
1968 | 1968 | sprintf( |
1969 | 1969 | __( |
@@ -1971,7 +1971,7 @@ discard block |
||
1971 | 1971 | 'event_espresso' |
1972 | 1972 | ), |
1973 | 1973 | '<br/>', |
1974 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1974 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1975 | 1975 | ), |
1976 | 1976 | __FILE__, |
1977 | 1977 | __FUNCTION__, |
@@ -1979,7 +1979,7 @@ discard block |
||
1979 | 1979 | ); |
1980 | 1980 | return false; |
1981 | 1981 | } |
1982 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
1982 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
1983 | 1983 | instanceof |
1984 | 1984 | EE_Attendee |
1985 | 1985 | ) { |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | 'event_espresso' |
1991 | 1991 | ), |
1992 | 1992 | '<br/>', |
1993 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1993 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1994 | 1994 | ), |
1995 | 1995 | __FILE__, |
1996 | 1996 | __FUNCTION__, |
@@ -1999,9 +1999,9 @@ discard block |
||
1999 | 1999 | return false; |
2000 | 2000 | } |
2001 | 2001 | /** @type EE_Registration_Processor $registration_processor */ |
2002 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
2002 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
2003 | 2003 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
2004 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
2004 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
2005 | 2005 | return true; |
2006 | 2006 | } |
2007 | 2007 | |
@@ -2016,22 +2016,22 @@ discard block |
||
2016 | 2016 | * @throws \EE_Error |
2017 | 2017 | */ |
2018 | 2018 | private function _get_payment_method_for_selected_method_of_payment() { |
2019 | - if ( $this->checkout->selected_method_of_payment === 'events_sold_out' ) { |
|
2019 | + if ($this->checkout->selected_method_of_payment === 'events_sold_out') { |
|
2020 | 2020 | $this->_redirect_because_event_sold_out(); |
2021 | 2021 | return null; |
2022 | 2022 | } |
2023 | 2023 | // get EE_Payment_Method object |
2024 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
2025 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
2024 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
2025 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
2026 | 2026 | } else { |
2027 | 2027 | // load EEM_Payment_Method |
2028 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
2028 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
2029 | 2029 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
2030 | 2030 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
2031 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
2031 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
2032 | 2032 | } |
2033 | 2033 | // verify $payment_method |
2034 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
2034 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
2035 | 2035 | // not a payment |
2036 | 2036 | EE_Error::add_error( |
2037 | 2037 | sprintf( |
@@ -2040,7 +2040,7 @@ discard block |
||
2040 | 2040 | 'event_espresso' |
2041 | 2041 | ), |
2042 | 2042 | '<br/>', |
2043 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2043 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2044 | 2044 | ), |
2045 | 2045 | __FILE__, |
2046 | 2046 | __FUNCTION__, |
@@ -2049,7 +2049,7 @@ discard block |
||
2049 | 2049 | return null; |
2050 | 2050 | } |
2051 | 2051 | // and verify it has a valid Payment_Method Type object |
2052 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
2052 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
2053 | 2053 | // not a payment |
2054 | 2054 | EE_Error::add_error( |
2055 | 2055 | sprintf( |
@@ -2058,7 +2058,7 @@ discard block |
||
2058 | 2058 | 'event_espresso' |
2059 | 2059 | ), |
2060 | 2060 | '<br/>', |
2061 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2061 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2062 | 2062 | ), |
2063 | 2063 | __FILE__, |
2064 | 2064 | __FUNCTION__, |
@@ -2079,29 +2079,29 @@ discard block |
||
2079 | 2079 | * @return mixed EE_Payment | boolean |
2080 | 2080 | * @throws \EE_Error |
2081 | 2081 | */ |
2082 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
2082 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
2083 | 2083 | $payment = null; |
2084 | 2084 | $this->checkout->transaction->save(); |
2085 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2086 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
2085 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2086 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
2087 | 2087 | return false; |
2088 | 2088 | } |
2089 | 2089 | try { |
2090 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
2090 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
2091 | 2091 | // generate payment object |
2092 | 2092 | $payment = $payment_processor->process_payment( |
2093 | 2093 | $payment_method, |
2094 | 2094 | $this->checkout->transaction, |
2095 | 2095 | $this->checkout->amount_owing, |
2096 | 2096 | $this->checkout->billing_form, |
2097 | - $this->_get_return_url( $payment_method ), |
|
2097 | + $this->_get_return_url($payment_method), |
|
2098 | 2098 | 'CART', |
2099 | 2099 | $this->checkout->admin_request, |
2100 | 2100 | true, |
2101 | 2101 | $this->reg_step_url() |
2102 | 2102 | ); |
2103 | - } catch ( Exception $e ) { |
|
2104 | - $this->_handle_payment_processor_exception( $e ); |
|
2103 | + } catch (Exception $e) { |
|
2104 | + $this->_handle_payment_processor_exception($e); |
|
2105 | 2105 | } |
2106 | 2106 | return $payment; |
2107 | 2107 | } |
@@ -2116,7 +2116,7 @@ discard block |
||
2116 | 2116 | * @return void |
2117 | 2117 | * @throws \EE_Error |
2118 | 2118 | */ |
2119 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
2119 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
2120 | 2120 | EE_Error::add_error( |
2121 | 2121 | sprintf( |
2122 | 2122 | __( |
@@ -2124,7 +2124,7 @@ discard block |
||
2124 | 2124 | 'event_espresso' |
2125 | 2125 | ), |
2126 | 2126 | '<br/>', |
2127 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
2127 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
2128 | 2128 | $e->getMessage(), |
2129 | 2129 | $e->getFile(), |
2130 | 2130 | $e->getLine() |
@@ -2145,9 +2145,9 @@ discard block |
||
2145 | 2145 | * @return string |
2146 | 2146 | * @throws \EE_Error |
2147 | 2147 | */ |
2148 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
2148 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
2149 | 2149 | $return_url = ''; |
2150 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
2150 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
2151 | 2151 | case EE_PMT_Base::offsite : |
2152 | 2152 | $return_url = add_query_arg( |
2153 | 2153 | array( |
@@ -2176,12 +2176,12 @@ discard block |
||
2176 | 2176 | * @return EE_Payment | FALSE |
2177 | 2177 | * @throws \EE_Error |
2178 | 2178 | */ |
2179 | - private function _validate_payment( $payment = null ) { |
|
2180 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
2179 | + private function _validate_payment($payment = null) { |
|
2180 | + if ($this->checkout->payment_method->is_off_line()) { |
|
2181 | 2181 | return true; |
2182 | 2182 | } |
2183 | 2183 | // verify payment object |
2184 | - if ( ! $payment instanceof EE_Payment ) { |
|
2184 | + if ( ! $payment instanceof EE_Payment) { |
|
2185 | 2185 | // not a payment |
2186 | 2186 | EE_Error::add_error( |
2187 | 2187 | sprintf( |
@@ -2190,7 +2190,7 @@ discard block |
||
2190 | 2190 | 'event_espresso' |
2191 | 2191 | ), |
2192 | 2192 | '<br/>', |
2193 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2193 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2194 | 2194 | ), |
2195 | 2195 | __FILE__, |
2196 | 2196 | __FUNCTION__, |
@@ -2211,27 +2211,27 @@ discard block |
||
2211 | 2211 | * @return bool |
2212 | 2212 | * @throws \EE_Error |
2213 | 2213 | */ |
2214 | - private function _post_payment_processing( $payment = null ) { |
|
2214 | + private function _post_payment_processing($payment = null) { |
|
2215 | 2215 | // Off-Line payment? |
2216 | - if ( $payment === true ) { |
|
2216 | + if ($payment === true) { |
|
2217 | 2217 | //$this->_setup_redirect_for_next_step(); |
2218 | 2218 | return true; |
2219 | 2219 | // On-Site payment? |
2220 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
2221 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
2220 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
2221 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
2222 | 2222 | //$this->_setup_redirect_for_next_step(); |
2223 | 2223 | $this->checkout->continue_reg = false; |
2224 | 2224 | } |
2225 | 2225 | // Off-Site payment? |
2226 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
2226 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
2227 | 2227 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
2228 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
2229 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
2228 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
2229 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
2230 | 2230 | $this->checkout->redirect = true; |
2231 | 2231 | $this->checkout->redirect_form = $payment->redirect_form(); |
2232 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
2232 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
2233 | 2233 | // set JSON response |
2234 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
2234 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
2235 | 2235 | // set cron job for finalizing the TXN |
2236 | 2236 | // in case the user does not return from the off-site gateway |
2237 | 2237 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -2239,7 +2239,7 @@ discard block |
||
2239 | 2239 | $this->checkout->transaction->ID() |
2240 | 2240 | ); |
2241 | 2241 | // and lastly, let's bump the payment status to pending |
2242 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
2242 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
2243 | 2243 | $payment->save(); |
2244 | 2244 | } else { |
2245 | 2245 | // not a payment |
@@ -2251,7 +2251,7 @@ discard block |
||
2251 | 2251 | 'event_espresso' |
2252 | 2252 | ), |
2253 | 2253 | '<br/>', |
2254 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2254 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2255 | 2255 | ), |
2256 | 2256 | __FILE__, |
2257 | 2257 | __FUNCTION__, |
@@ -2289,21 +2289,21 @@ discard block |
||
2289 | 2289 | * @return bool |
2290 | 2290 | * @throws \EE_Error |
2291 | 2291 | */ |
2292 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
2292 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
2293 | 2293 | // off-line payment? carry on |
2294 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
2294 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
2295 | 2295 | return true; |
2296 | 2296 | } |
2297 | 2297 | // verify payment validity |
2298 | - if ( $payment instanceof EE_Payment ) { |
|
2299 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
2298 | + if ($payment instanceof EE_Payment) { |
|
2299 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
2300 | 2300 | $msg = $payment->gateway_response(); |
2301 | 2301 | // check results |
2302 | - switch ( $payment->status() ) { |
|
2302 | + switch ($payment->status()) { |
|
2303 | 2303 | // good payment |
2304 | 2304 | case EEM_Payment::status_id_approved : |
2305 | 2305 | EE_Error::add_success( |
2306 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
2306 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
2307 | 2307 | __FILE__, |
2308 | 2308 | __FUNCTION__, |
2309 | 2309 | __LINE__ |
@@ -2312,45 +2312,45 @@ discard block |
||
2312 | 2312 | break; |
2313 | 2313 | // slow payment |
2314 | 2314 | case EEM_Payment::status_id_pending : |
2315 | - if ( empty( $msg ) ) { |
|
2315 | + if (empty($msg)) { |
|
2316 | 2316 | $msg = __( |
2317 | 2317 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
2318 | 2318 | 'event_espresso' |
2319 | 2319 | ); |
2320 | 2320 | } |
2321 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2321 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2322 | 2322 | return true; |
2323 | 2323 | break; |
2324 | 2324 | // don't wanna payment |
2325 | 2325 | case EEM_Payment::status_id_cancelled : |
2326 | - if ( empty( $msg ) ) { |
|
2326 | + if (empty($msg)) { |
|
2327 | 2327 | $msg = _n( |
2328 | 2328 | 'Payment cancelled. Please try again.', |
2329 | 2329 | 'Payment cancelled. Please try again or select another method of payment.', |
2330 | - count( $this->checkout->available_payment_methods ), |
|
2330 | + count($this->checkout->available_payment_methods), |
|
2331 | 2331 | 'event_espresso' |
2332 | 2332 | ); |
2333 | 2333 | } |
2334 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2334 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2335 | 2335 | return false; |
2336 | 2336 | break; |
2337 | 2337 | // not enough payment |
2338 | 2338 | case EEM_Payment::status_id_declined : |
2339 | - if ( empty( $msg ) ) { |
|
2339 | + if (empty($msg)) { |
|
2340 | 2340 | $msg = _n( |
2341 | 2341 | 'We\'re sorry but your payment was declined. Please try again.', |
2342 | 2342 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
2343 | - count( $this->checkout->available_payment_methods ), |
|
2343 | + count($this->checkout->available_payment_methods), |
|
2344 | 2344 | 'event_espresso' |
2345 | 2345 | ); |
2346 | 2346 | } |
2347 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2347 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2348 | 2348 | return false; |
2349 | 2349 | break; |
2350 | 2350 | // bad payment |
2351 | 2351 | case EEM_Payment::status_id_failed : |
2352 | - if ( ! empty( $msg ) ) { |
|
2353 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2352 | + if ( ! empty($msg)) { |
|
2353 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2354 | 2354 | return false; |
2355 | 2355 | } |
2356 | 2356 | // default to error below |
@@ -2359,7 +2359,7 @@ discard block |
||
2359 | 2359 | } |
2360 | 2360 | // off-site payment gateway responses are too unreliable, so let's just assume that |
2361 | 2361 | // the payment processing is just running slower than the registrant's request |
2362 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
2362 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
2363 | 2363 | return true; |
2364 | 2364 | } |
2365 | 2365 | EE_Error::add_error( |
@@ -2369,7 +2369,7 @@ discard block |
||
2369 | 2369 | 'event_espresso' |
2370 | 2370 | ), |
2371 | 2371 | '<br/>', |
2372 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2372 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2373 | 2373 | ), |
2374 | 2374 | __FILE__, |
2375 | 2375 | __FUNCTION__, |
@@ -2402,13 +2402,13 @@ discard block |
||
2402 | 2402 | public function process_gateway_response() { |
2403 | 2403 | $payment = null; |
2404 | 2404 | // how have they chosen to pay? |
2405 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
2405 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
2406 | 2406 | // get EE_Payment_Method object |
2407 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
2407 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
2408 | 2408 | $this->checkout->continue_reg = false; |
2409 | 2409 | return false; |
2410 | 2410 | } |
2411 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
2411 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
2412 | 2412 | return false; |
2413 | 2413 | } |
2414 | 2414 | $this->_validate_offsite_return(); |
@@ -2422,23 +2422,23 @@ discard block |
||
2422 | 2422 | // true |
2423 | 2423 | //); |
2424 | 2424 | // verify TXN |
2425 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
2425 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
2426 | 2426 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
2427 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
2427 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
2428 | 2428 | $this->checkout->continue_reg = false; |
2429 | 2429 | return false; |
2430 | 2430 | } |
2431 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
2432 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
2433 | - $payment = $this->_validate_payment( $payment ); |
|
2431 | + $payment = $this->_process_off_site_payment($gateway); |
|
2432 | + $payment = $this->_process_cancelled_payments($payment); |
|
2433 | + $payment = $this->_validate_payment($payment); |
|
2434 | 2434 | // if payment was not declined by the payment gateway or cancelled by the registrant |
2435 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
2435 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
2436 | 2436 | //$this->_setup_redirect_for_next_step(); |
2437 | 2437 | // store that for later |
2438 | 2438 | $this->checkout->payment = $payment; |
2439 | 2439 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
2440 | 2440 | // because we will complete this step during the IPN processing then |
2441 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
2441 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
2442 | 2442 | $this->set_completed(); |
2443 | 2443 | } |
2444 | 2444 | return true; |
@@ -2463,21 +2463,21 @@ discard block |
||
2463 | 2463 | * @throws \EE_Error |
2464 | 2464 | */ |
2465 | 2465 | private function _validate_offsite_return() { |
2466 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
2467 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
2466 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
2467 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
2468 | 2468 | // Houston... we might have a problem |
2469 | 2469 | $invalid_TXN = false; |
2470 | 2470 | // first gather some info |
2471 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
2471 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2472 | 2472 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
2473 | 2473 | ? $valid_TXN->primary_registration() |
2474 | 2474 | : null; |
2475 | 2475 | // let's start by retrieving the cart for this TXN |
2476 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
2477 | - if ( $cart instanceof EE_Cart ) { |
|
2476 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
2477 | + if ($cart instanceof EE_Cart) { |
|
2478 | 2478 | // verify that the current cart has tickets |
2479 | 2479 | $tickets = $cart->get_tickets(); |
2480 | - if ( empty( $tickets ) ) { |
|
2480 | + if (empty($tickets)) { |
|
2481 | 2481 | $invalid_TXN = true; |
2482 | 2482 | } |
2483 | 2483 | } else { |
@@ -2503,21 +2503,21 @@ discard block |
||
2503 | 2503 | ) { |
2504 | 2504 | $invalid_TXN = true; |
2505 | 2505 | } |
2506 | - if ( $invalid_TXN ) { |
|
2506 | + if ($invalid_TXN) { |
|
2507 | 2507 | // is the valid TXN completed ? |
2508 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
2508 | + if ($valid_TXN instanceof EE_Transaction) { |
|
2509 | 2509 | // has this step even been started ? |
2510 | - $reg_step_completed = $valid_TXN->reg_step_completed( $this->slug() ); |
|
2511 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
2510 | + $reg_step_completed = $valid_TXN->reg_step_completed($this->slug()); |
|
2511 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
2512 | 2512 | // so it **looks** like this is a double request from PayPal |
2513 | 2513 | // so let's try to pick up where we left off |
2514 | 2514 | $this->checkout->transaction = $valid_TXN; |
2515 | - $this->checkout->refresh_all_entities( true ); |
|
2515 | + $this->checkout->refresh_all_entities(true); |
|
2516 | 2516 | return; |
2517 | 2517 | } |
2518 | 2518 | } |
2519 | 2519 | // you appear to be lost? |
2520 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
2520 | + $this->_redirect_wayward_request($primary_registrant); |
|
2521 | 2521 | } |
2522 | 2522 | } |
2523 | 2523 | } |
@@ -2532,14 +2532,14 @@ discard block |
||
2532 | 2532 | * @return bool |
2533 | 2533 | * @throws \EE_Error |
2534 | 2534 | */ |
2535 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
2536 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2535 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
2536 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2537 | 2537 | // try redirecting based on the current TXN |
2538 | 2538 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
2539 | 2539 | ? $this->checkout->transaction->primary_registration() |
2540 | 2540 | : null; |
2541 | 2541 | } |
2542 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2542 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2543 | 2543 | EE_Error::add_error( |
2544 | 2544 | sprintf( |
2545 | 2545 | __( |
@@ -2547,7 +2547,7 @@ discard block |
||
2547 | 2547 | 'event_espresso' |
2548 | 2548 | ), |
2549 | 2549 | '<br/>', |
2550 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2550 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2551 | 2551 | ), |
2552 | 2552 | __FILE__, |
2553 | 2553 | __FUNCTION__, |
@@ -2578,17 +2578,17 @@ discard block |
||
2578 | 2578 | * @return \EE_Payment |
2579 | 2579 | * @throws \EE_Error |
2580 | 2580 | */ |
2581 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
2581 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
2582 | 2582 | try { |
2583 | 2583 | $request_data = \EE_Registry::instance()->REQ->params(); |
2584 | 2584 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
2585 | 2585 | $this->set_handle_IPN_in_this_request( |
2586 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
2586 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
2587 | 2587 | ); |
2588 | - if ( $this->handle_IPN_in_this_request() ) { |
|
2588 | + if ($this->handle_IPN_in_this_request()) { |
|
2589 | 2589 | // get payment details and process results |
2590 | 2590 | /** @type EE_Payment_Processor $payment_processor */ |
2591 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2591 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2592 | 2592 | $payment = $payment_processor->process_ipn( |
2593 | 2593 | $request_data, |
2594 | 2594 | $this->checkout->transaction, |
@@ -2601,14 +2601,14 @@ discard block |
||
2601 | 2601 | $payment = $this->checkout->transaction->last_payment(); |
2602 | 2602 | //$payment_source = 'last_payment'; |
2603 | 2603 | } |
2604 | - } catch ( Exception $e ) { |
|
2604 | + } catch (Exception $e) { |
|
2605 | 2605 | // let's just eat the exception and try to move on using any previously set payment info |
2606 | 2606 | $payment = $this->checkout->transaction->last_payment(); |
2607 | 2607 | //$payment_source = 'last_payment after Exception'; |
2608 | 2608 | // but if we STILL don't have a payment object |
2609 | - if ( ! $payment instanceof EE_Payment ) { |
|
2609 | + if ( ! $payment instanceof EE_Payment) { |
|
2610 | 2610 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
2611 | - $this->_handle_payment_processor_exception( $e ); |
|
2611 | + $this->_handle_payment_processor_exception($e); |
|
2612 | 2612 | } |
2613 | 2613 | } |
2614 | 2614 | // DEBUG LOG |
@@ -2633,13 +2633,13 @@ discard block |
||
2633 | 2633 | * @return EE_Payment | FALSE |
2634 | 2634 | * @throws \EE_Error |
2635 | 2635 | */ |
2636 | - private function _process_cancelled_payments( $payment = null ) { |
|
2636 | + private function _process_cancelled_payments($payment = null) { |
|
2637 | 2637 | if ( |
2638 | 2638 | $payment instanceof EE_Payment |
2639 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
2639 | + && isset($_REQUEST['ee_cancel_payment']) |
|
2640 | 2640 | && $payment->status() === EEM_Payment::status_id_failed |
2641 | 2641 | ) { |
2642 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
2642 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
2643 | 2643 | } |
2644 | 2644 | return $payment; |
2645 | 2645 | } |
@@ -2656,14 +2656,14 @@ discard block |
||
2656 | 2656 | public function get_transaction_details_for_gateways() { |
2657 | 2657 | $txn_details = array(); |
2658 | 2658 | // ya gotta make a choice man |
2659 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
2659 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
2660 | 2660 | $txn_details = array( |
2661 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
2661 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
2662 | 2662 | ); |
2663 | 2663 | } |
2664 | 2664 | // get EE_Payment_Method object |
2665 | 2665 | if ( |
2666 | - empty( $txn_details ) |
|
2666 | + empty($txn_details) |
|
2667 | 2667 | && |
2668 | 2668 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
2669 | 2669 | ) { |
@@ -2675,8 +2675,8 @@ discard block |
||
2675 | 2675 | ) |
2676 | 2676 | ); |
2677 | 2677 | } |
2678 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
2679 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
2678 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
2679 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
2680 | 2680 | $txn_details = array( |
2681 | 2681 | 'TXN_ID' => $this->checkout->transaction->ID(), |
2682 | 2682 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2687,7 +2687,7 @@ discard block |
||
2687 | 2687 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
2688 | 2688 | 'payment_amount' => $this->checkout->amount_owing, |
2689 | 2689 | 'return_url' => $return_url, |
2690 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
2690 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
2691 | 2691 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
2692 | 2692 | array( |
2693 | 2693 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2696,7 +2696,7 @@ discard block |
||
2696 | 2696 | ) |
2697 | 2697 | ); |
2698 | 2698 | } |
2699 | - echo wp_json_encode( $txn_details ); |
|
2699 | + echo wp_json_encode($txn_details); |
|
2700 | 2700 | exit(); |
2701 | 2701 | } |
2702 | 2702 | |
@@ -2713,7 +2713,7 @@ discard block |
||
2713 | 2713 | public function __sleep() |
2714 | 2714 | { |
2715 | 2715 | // remove the reg form and the checkout |
2716 | - return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) ); |
|
2716 | + return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display')); |
|
2717 | 2717 | } |
2718 | 2718 | |
2719 | 2719 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public static function instance() |
61 | 61 | { |
62 | 62 | //check if instantiated, and if not do so. |
63 | - if (! self::$_instance instanceof EE_Capabilities) { |
|
63 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
64 | 64 | self::$_instance = new self(); |
65 | 65 | } |
66 | 66 | return self::$_instance; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
113 | 113 | $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
114 | 114 | //add filter for map_meta_caps but only if models can query. |
115 | - if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
115 | + if ( ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
116 | 116 | add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
117 | 117 | } |
118 | 118 | } |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
271 | 271 | //loop through our _meta_caps array |
272 | 272 | foreach ($this->_meta_caps as $meta_map) { |
273 | - if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
273 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
274 | 274 | continue; |
275 | 275 | } |
276 | 276 | // don't load models if there is no object ID in the args |
277 | - if(!empty($args[0])){ |
|
277 | + if ( ! empty($args[0])) { |
|
278 | 278 | $meta_map->ensure_is_model(); |
279 | 279 | } |
280 | 280 | $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | foreach ($caps_map as $role => $caps_for_role) { |
633 | 633 | foreach ($caps_for_role as $cap) { |
634 | 634 | //first check we haven't already added this cap before, or it's a reset |
635 | - if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
635 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
636 | 636 | if ($this->add_cap_to_role($role, $cap)) { |
637 | - $caps_set_before[ $role ][] = $cap; |
|
637 | + $caps_set_before[$role][] = $cap; |
|
638 | 638 | } |
639 | 639 | } |
640 | 640 | } |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | { |
665 | 665 | $role_object = get_role($role); |
666 | 666 | //if the role isn't available then we create it. |
667 | - if (! $role_object instanceof WP_Role) { |
|
667 | + if ( ! $role_object instanceof WP_Role) { |
|
668 | 668 | //if a plugin wants to create a specific role name then they should create the role before |
669 | 669 | //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
670 | 670 | // - removes any `ee_` namespacing from the start of the slug. |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | public function current_user_can($cap, $context, $id = 0) |
722 | 722 | { |
723 | 723 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
724 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
724 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
725 | 725 | $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
726 | 726 | $id); |
727 | 727 | return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | public function user_can($user, $cap, $context, $id = 0) |
743 | 743 | { |
744 | 744 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
745 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
745 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
746 | 746 | $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
747 | 747 | $id); |
748 | 748 | return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | : current_user_can($blog_id, $cap); |
774 | 774 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
775 | 775 | $user_can = apply_filters( |
776 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
776 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, |
|
777 | 777 | $user_can, |
778 | 778 | $blog_id, |
779 | 779 | $cap, |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | if (empty($role)) { |
810 | 810 | return $capabilities; |
811 | 811 | } |
812 | - return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
812 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | |
@@ -875,16 +875,16 @@ discard block |
||
875 | 875 | 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
876 | 876 | 'event_espresso' |
877 | 877 | ), |
878 | - '<br>' . print_r($map_values, true) |
|
878 | + '<br>'.print_r($map_values, true) |
|
879 | 879 | ) |
880 | 880 | ); |
881 | 881 | } |
882 | 882 | //set properties |
883 | 883 | $this->_model = null; |
884 | 884 | $this->_model_name = $map_values[0]; |
885 | - $this->published_cap = (string)$map_values[1]; |
|
886 | - $this->others_cap = (string)$map_values[2]; |
|
887 | - $this->private_cap = (string)$map_values[3]; |
|
885 | + $this->published_cap = (string) $map_values[1]; |
|
886 | + $this->others_cap = (string) $map_values[2]; |
|
887 | + $this->private_cap = (string) $map_values[3]; |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
@@ -911,11 +911,11 @@ discard block |
||
911 | 911 | return; |
912 | 912 | } |
913 | 913 | //ensure model name is string |
914 | - $this->_model_name = (string)$this->_model_name; |
|
914 | + $this->_model_name = (string) $this->_model_name; |
|
915 | 915 | //error proof if the name has EEM in it |
916 | 916 | $this->_model_name = str_replace('EEM', '', $this->_model_name); |
917 | 917 | $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
918 | - if (! $this->_model instanceof EEM_Base) { |
|
918 | + if ( ! $this->_model instanceof EEM_Base) { |
|
919 | 919 | throw new EE_Error( |
920 | 920 | sprintf( |
921 | 921 | __( |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | /** @var EE_Base_Class $obj */ |
1006 | 1006 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1007 | 1007 | //if no obj then let's just do cap |
1008 | - if (! $obj instanceof EE_Base_Class) { |
|
1008 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1009 | 1009 | $caps[] = $cap; |
1010 | 1010 | return $caps; |
1011 | 1011 | } |
@@ -1024,12 +1024,12 @@ discard block |
||
1024 | 1024 | } |
1025 | 1025 | } else { |
1026 | 1026 | //the user is trying to edit someone else's obj |
1027 | - if (! empty($this->others_cap)) { |
|
1027 | + if ( ! empty($this->others_cap)) { |
|
1028 | 1028 | $caps[] = $this->others_cap; |
1029 | 1029 | } |
1030 | - if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1030 | + if ( ! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | 1031 | $caps[] = $this->published_cap; |
1032 | - } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1032 | + } elseif ( ! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | 1033 | $caps[] = $this->private_cap; |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | if ($has_cap) { |
1049 | 1049 | $caps[] = $cap; |
1050 | 1050 | } else { |
1051 | - if (! empty($this->others_cap)) { |
|
1051 | + if ( ! empty($this->others_cap)) { |
|
1052 | 1052 | $caps[] = $this->others_cap; |
1053 | 1053 | } |
1054 | 1054 | } |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1132 | 1132 | //if no obj then let's just do cap |
1133 | - if (! $obj instanceof EE_Base_Class) { |
|
1133 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1134 | 1134 | $caps[] = $cap; |
1135 | 1135 | return $caps; |
1136 | 1136 | } |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | } elseif ($status_obj->private && ! empty($this->private_cap)) { |
1147 | 1147 | //the user is trying to view someone else's obj |
1148 | 1148 | $caps[] = $this->private_cap; |
1149 | - } elseif (! empty($this->others_cap)) { |
|
1149 | + } elseif ( ! empty($this->others_cap)) { |
|
1150 | 1150 | $caps[] = $this->others_cap; |
1151 | 1151 | } else { |
1152 | 1152 | $caps[] = $cap; |
@@ -1163,9 +1163,9 @@ discard block |
||
1163 | 1163 | } |
1164 | 1164 | if ($has_cap) { |
1165 | 1165 | $caps[] = $cap; |
1166 | - } elseif (! empty($this->private_cap)) { |
|
1166 | + } elseif ( ! empty($this->private_cap)) { |
|
1167 | 1167 | $caps[] = $this->private_cap; |
1168 | - } elseif (! empty($this->others_cap)) { |
|
1168 | + } elseif ( ! empty($this->others_cap)) { |
|
1169 | 1169 | $caps[] = $this->others_cap; |
1170 | 1170 | } else { |
1171 | 1171 | $caps[] = $cap; |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | |
1216 | 1216 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1217 | 1217 | //if no obj then let's just do cap |
1218 | - if (! $obj instanceof EE_Message_Template_Group) { |
|
1218 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
1219 | 1219 | $caps[] = $cap; |
1220 | 1220 | return $caps; |
1221 | 1221 | } |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | } |
1274 | 1274 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1275 | 1275 | //if no obj then let's just do cap |
1276 | - if (! $obj instanceof EE_Base_Class) { |
|
1276 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1277 | 1277 | $caps[] = $cap; |
1278 | 1278 | return $caps; |
1279 | 1279 | } |
@@ -16,811 +16,811 @@ discard block |
||
16 | 16 | final class EE_Capabilities extends EE_Base |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * the name of the wp option used to store caps previously initialized |
|
21 | - */ |
|
22 | - const option_name = 'ee_caps_initialized'; |
|
23 | - |
|
24 | - /** |
|
25 | - * instance of EE_Capabilities object |
|
26 | - * |
|
27 | - * @var EE_Capabilities |
|
28 | - */ |
|
29 | - private static $_instance; |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * This is a map of caps that correspond to a default WP_Role. |
|
34 | - * Array is indexed by Role and values are ee capabilities. |
|
35 | - * |
|
36 | - * @since 4.5.0 |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - private $_caps_map = array(); |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
44 | - * a user depending on context. |
|
45 | - * |
|
46 | - * @var EE_Meta_Capability_Map[] |
|
47 | - */ |
|
48 | - private $_meta_caps = array(); |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * singleton method used to instantiate class object |
|
53 | - * |
|
54 | - * @since 4.5.0 |
|
55 | - * @return EE_Capabilities |
|
56 | - */ |
|
57 | - public static function instance() |
|
58 | - { |
|
59 | - //check if instantiated, and if not do so. |
|
60 | - if (! self::$_instance instanceof EE_Capabilities) { |
|
61 | - self::$_instance = new self(); |
|
62 | - } |
|
63 | - return self::$_instance; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * private constructor |
|
69 | - * |
|
70 | - * @since 4.5.0 |
|
71 | - */ |
|
72 | - private function __construct() |
|
73 | - { |
|
74 | - if (is_admin()) { |
|
75 | - add_filter( |
|
76 | - 'FHEE__EE_Capabilities__init_caps_map__caps', |
|
77 | - array($this, 'register_additional_capabilities'), |
|
78 | - 10 |
|
79 | - ); |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
86 | - * |
|
87 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
88 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
89 | - * ensures that they are up to date. |
|
90 | - * @since 4.5.0 |
|
91 | - * @return void |
|
92 | - */ |
|
93 | - public function init_caps($reset = false) |
|
94 | - { |
|
95 | - /** |
|
96 | - * Note, this means that caps can only initialized on the default roles when: |
|
97 | - * - models are queryable |
|
98 | - * - All addons have been registered (which happens at plugins_loaded priority 1) |
|
99 | - * In practice, currently this method is usually called around `init`. |
|
100 | - */ |
|
101 | - if ( |
|
102 | - did_action('AHEE__EE_System__load_espresso_addons__complete') |
|
103 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
104 | - ) { |
|
105 | - $this->_caps_map = $this->_init_caps_map(); |
|
106 | - $this->init_role_caps($reset); |
|
107 | - $this->_set_meta_caps(); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * This sets the meta caps property. |
|
114 | - * |
|
115 | - * @since 4.5.0 |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - private function _set_meta_caps() |
|
119 | - { |
|
120 | - //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
121 | - $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
122 | - $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
123 | - //add filter for map_meta_caps but only if models can query. |
|
124 | - if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
125 | - add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * This builds and returns the default meta_caps array only once. |
|
132 | - * |
|
133 | - * @since 4.8.28.rc.012 |
|
134 | - * @return array |
|
135 | - * @throws \EE_Error |
|
136 | - */ |
|
137 | - private function _get_default_meta_caps_array() |
|
138 | - { |
|
139 | - static $default_meta_caps = array(); |
|
140 | - if (empty($default_meta_caps)) { |
|
141 | - $default_meta_caps = array( |
|
142 | - //edits |
|
143 | - new EE_Meta_Capability_Map_Edit( |
|
144 | - 'ee_edit_event', |
|
145 | - array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events') |
|
146 | - ), |
|
147 | - new EE_Meta_Capability_Map_Edit( |
|
148 | - 'ee_edit_venue', |
|
149 | - array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues') |
|
150 | - ), |
|
151 | - new EE_Meta_Capability_Map_Edit( |
|
152 | - 'ee_edit_registration', |
|
153 | - array('Registration', '', 'ee_edit_others_registrations', '') |
|
154 | - ), |
|
155 | - new EE_Meta_Capability_Map_Edit( |
|
156 | - 'ee_edit_checkin', |
|
157 | - array('Registration', '', 'ee_edit_others_checkins', '') |
|
158 | - ), |
|
159 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
160 | - 'ee_edit_message', |
|
161 | - array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages') |
|
162 | - ), |
|
163 | - new EE_Meta_Capability_Map_Edit( |
|
164 | - 'ee_edit_default_ticket', |
|
165 | - array('Ticket', '', 'ee_edit_others_default_tickets', '') |
|
166 | - ), |
|
167 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
168 | - 'ee_edit_question', |
|
169 | - array('Question', '', '', 'ee_edit_system_questions') |
|
170 | - ), |
|
171 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
172 | - 'ee_edit_question_group', |
|
173 | - array('Question_Group', '', '', 'ee_edit_system_question_groups') |
|
174 | - ), |
|
175 | - new EE_Meta_Capability_Map_Edit( |
|
176 | - 'ee_edit_payment_method', |
|
177 | - array('Payment_Method', '', 'ee_edit_others_payment_methods', '') |
|
178 | - ), |
|
179 | - //reads |
|
180 | - new EE_Meta_Capability_Map_Read( |
|
181 | - 'ee_read_event', |
|
182 | - array('Event', '', 'ee_read_others_events', 'ee_read_private_events') |
|
183 | - ), |
|
184 | - new EE_Meta_Capability_Map_Read( |
|
185 | - 'ee_read_venue', |
|
186 | - array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues') |
|
187 | - ), |
|
188 | - new EE_Meta_Capability_Map_Read( |
|
189 | - 'ee_read_registration', |
|
190 | - array('Registration', '', '', 'ee_edit_others_registrations') |
|
191 | - ), |
|
192 | - new EE_Meta_Capability_Map_Read( |
|
193 | - 'ee_read_checkin', |
|
194 | - array('Registration', '', '', 'ee_read_others_checkins') |
|
195 | - ), |
|
196 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
197 | - 'ee_read_message', |
|
198 | - array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages') |
|
199 | - ), |
|
200 | - new EE_Meta_Capability_Map_Read( |
|
201 | - 'ee_read_default_ticket', |
|
202 | - array('Ticket', '', '', 'ee_read_others_default_tickets') |
|
203 | - ), |
|
204 | - new EE_Meta_Capability_Map_Read( |
|
205 | - 'ee_read_payment_method', |
|
206 | - array('Payment_Method', '', '', 'ee_read_others_payment_methods') |
|
207 | - ), |
|
208 | - //deletes |
|
209 | - new EE_Meta_Capability_Map_Delete( |
|
210 | - 'ee_delete_event', |
|
211 | - array( |
|
212 | - 'Event', |
|
213 | - 'ee_delete_published_events', |
|
214 | - 'ee_delete_others_events', |
|
215 | - 'ee_delete_private_events', |
|
216 | - ) |
|
217 | - ), |
|
218 | - new EE_Meta_Capability_Map_Delete( |
|
219 | - 'ee_delete_venue', |
|
220 | - array( |
|
221 | - 'Venue', |
|
222 | - 'ee_delete_published_venues', |
|
223 | - 'ee_delete_others_venues', |
|
224 | - 'ee_delete_private_venues', |
|
225 | - ) |
|
226 | - ), |
|
227 | - new EE_Meta_Capability_Map_Delete( |
|
228 | - 'ee_delete_registration', |
|
229 | - array('Registration', '', 'ee_delete_others_registrations', '') |
|
230 | - ), |
|
231 | - new EE_Meta_Capability_Map_Delete( |
|
232 | - 'ee_delete_checkin', |
|
233 | - array('Registration', '', 'ee_delete_others_checkins', '') |
|
234 | - ), |
|
235 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
236 | - 'ee_delete_message', |
|
237 | - array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages') |
|
238 | - ), |
|
239 | - new EE_Meta_Capability_Map_Delete( |
|
240 | - 'ee_delete_default_ticket', |
|
241 | - array('Ticket', '', 'ee_delete_others_default_tickets', '') |
|
242 | - ), |
|
243 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
244 | - 'ee_delete_question', |
|
245 | - array('Question', '', '', 'delete_system_questions') |
|
246 | - ), |
|
247 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
248 | - 'ee_delete_question_group', |
|
249 | - array('Question_Group', '', '', 'delete_system_question_groups') |
|
250 | - ), |
|
251 | - new EE_Meta_Capability_Map_Delete( |
|
252 | - 'ee_delete_payment_method', |
|
253 | - array('Payment_Method', '', 'ee_delete_others_payment_methods', '') |
|
254 | - ), |
|
255 | - ); |
|
256 | - } |
|
257 | - return $default_meta_caps; |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
263 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
264 | - * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
265 | - * |
|
266 | - * @since 4.5.0 |
|
267 | - * @see wp-includes/capabilities.php |
|
268 | - * @param array $caps actual users capabilities |
|
269 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
270 | - * @param int $user_id The user id |
|
271 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
272 | - * @return array actual users capabilities |
|
273 | - * @throws EE_Error |
|
274 | - */ |
|
275 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
276 | - { |
|
277 | - if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
278 | - //loop through our _meta_caps array |
|
279 | - foreach ($this->_meta_caps as $meta_map) { |
|
280 | - if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
281 | - continue; |
|
282 | - } |
|
283 | - // don't load models if there is no object ID in the args |
|
284 | - if(!empty($args[0])){ |
|
285 | - $meta_map->ensure_is_model(); |
|
286 | - } |
|
287 | - $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
288 | - } |
|
289 | - } |
|
290 | - return $caps; |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * This sets up and returns the initial capabilities map for Event Espresso |
|
296 | - * |
|
297 | - * @since 4.5.0 |
|
298 | - * @return array |
|
299 | - */ |
|
300 | - private function _init_caps_map() |
|
301 | - { |
|
302 | - $caps = array( |
|
303 | - 'administrator' => array( |
|
304 | - //basic access |
|
305 | - 'ee_read_ee', |
|
306 | - //gateways |
|
307 | - /** |
|
308 | - * note that with payment method capabilities, although we've implemented |
|
309 | - * capability mapping which will be used for accessing payment methods owned by |
|
310 | - * other users. This is not fully implemented yet in the payment method ui. |
|
311 | - * Currently only the "plural" caps are in active use. |
|
312 | - * (Specific payment method caps are in use as well). |
|
313 | - **/ |
|
314 | - 'ee_manage_gateways', |
|
315 | - 'ee_read_payment_method', |
|
316 | - 'ee_read_payment_methods', |
|
317 | - 'ee_read_others_payment_methods', |
|
318 | - 'ee_edit_payment_method', |
|
319 | - 'ee_edit_payment_methods', |
|
320 | - 'ee_edit_others_payment_methods', |
|
321 | - 'ee_delete_payment_method', |
|
322 | - 'ee_delete_payment_methods', |
|
323 | - //events |
|
324 | - 'ee_publish_events', |
|
325 | - 'ee_read_private_events', |
|
326 | - 'ee_read_others_events', |
|
327 | - 'ee_read_event', |
|
328 | - 'ee_read_events', |
|
329 | - 'ee_edit_event', |
|
330 | - 'ee_edit_events', |
|
331 | - 'ee_edit_published_events', |
|
332 | - 'ee_edit_others_events', |
|
333 | - 'ee_edit_private_events', |
|
334 | - 'ee_delete_published_events', |
|
335 | - 'ee_delete_private_events', |
|
336 | - 'ee_delete_event', |
|
337 | - 'ee_delete_events', |
|
338 | - 'ee_delete_others_events', |
|
339 | - //event categories |
|
340 | - 'ee_manage_event_categories', |
|
341 | - 'ee_edit_event_category', |
|
342 | - 'ee_delete_event_category', |
|
343 | - 'ee_assign_event_category', |
|
344 | - //venues |
|
345 | - 'ee_publish_venues', |
|
346 | - 'ee_read_venue', |
|
347 | - 'ee_read_venues', |
|
348 | - 'ee_read_others_venues', |
|
349 | - 'ee_read_private_venues', |
|
350 | - 'ee_edit_venue', |
|
351 | - 'ee_edit_venues', |
|
352 | - 'ee_edit_others_venues', |
|
353 | - 'ee_edit_published_venues', |
|
354 | - 'ee_edit_private_venues', |
|
355 | - 'ee_delete_venue', |
|
356 | - 'ee_delete_venues', |
|
357 | - 'ee_delete_others_venues', |
|
358 | - 'ee_delete_private_venues', |
|
359 | - 'ee_delete_published_venues', |
|
360 | - //venue categories |
|
361 | - 'ee_manage_venue_categories', |
|
362 | - 'ee_edit_venue_category', |
|
363 | - 'ee_delete_venue_category', |
|
364 | - 'ee_assign_venue_category', |
|
365 | - //contacts |
|
366 | - 'ee_read_contact', |
|
367 | - 'ee_read_contacts', |
|
368 | - 'ee_edit_contact', |
|
369 | - 'ee_edit_contacts', |
|
370 | - 'ee_delete_contact', |
|
371 | - 'ee_delete_contacts', |
|
372 | - //registrations |
|
373 | - 'ee_read_registration', |
|
374 | - 'ee_read_registrations', |
|
375 | - 'ee_read_others_registrations', |
|
376 | - 'ee_edit_registration', |
|
377 | - 'ee_edit_registrations', |
|
378 | - 'ee_edit_others_registrations', |
|
379 | - 'ee_delete_registration', |
|
380 | - 'ee_delete_registrations', |
|
381 | - //checkins |
|
382 | - 'ee_read_checkin', |
|
383 | - 'ee_read_others_checkins', |
|
384 | - 'ee_read_checkins', |
|
385 | - 'ee_edit_checkin', |
|
386 | - 'ee_edit_checkins', |
|
387 | - 'ee_edit_others_checkins', |
|
388 | - 'ee_delete_checkin', |
|
389 | - 'ee_delete_checkins', |
|
390 | - 'ee_delete_others_checkins', |
|
391 | - //transactions && payments |
|
392 | - 'ee_read_transaction', |
|
393 | - 'ee_read_transactions', |
|
394 | - 'ee_edit_payments', |
|
395 | - 'ee_delete_payments', |
|
396 | - //messages |
|
397 | - 'ee_read_message', |
|
398 | - 'ee_read_messages', |
|
399 | - 'ee_read_others_messages', |
|
400 | - 'ee_read_global_messages', |
|
401 | - 'ee_edit_global_messages', |
|
402 | - 'ee_edit_message', |
|
403 | - 'ee_edit_messages', |
|
404 | - 'ee_edit_others_messages', |
|
405 | - 'ee_delete_message', |
|
406 | - 'ee_delete_messages', |
|
407 | - 'ee_delete_others_messages', |
|
408 | - 'ee_delete_global_messages', |
|
409 | - 'ee_send_message', |
|
410 | - //tickets |
|
411 | - 'ee_read_default_ticket', |
|
412 | - 'ee_read_default_tickets', |
|
413 | - 'ee_read_others_default_tickets', |
|
414 | - 'ee_edit_default_ticket', |
|
415 | - 'ee_edit_default_tickets', |
|
416 | - 'ee_edit_others_default_tickets', |
|
417 | - 'ee_delete_default_ticket', |
|
418 | - 'ee_delete_default_tickets', |
|
419 | - 'ee_delete_others_default_tickets', |
|
420 | - //prices |
|
421 | - 'ee_edit_default_price', |
|
422 | - 'ee_edit_default_prices', |
|
423 | - 'ee_delete_default_price', |
|
424 | - 'ee_delete_default_prices', |
|
425 | - 'ee_edit_default_price_type', |
|
426 | - 'ee_edit_default_price_types', |
|
427 | - 'ee_delete_default_price_type', |
|
428 | - 'ee_delete_default_price_types', |
|
429 | - 'ee_read_default_prices', |
|
430 | - 'ee_read_default_price_types', |
|
431 | - //registration form |
|
432 | - 'ee_edit_question', |
|
433 | - 'ee_edit_questions', |
|
434 | - 'ee_edit_system_questions', |
|
435 | - 'ee_read_questions', |
|
436 | - 'ee_delete_question', |
|
437 | - 'ee_delete_questions', |
|
438 | - 'ee_edit_question_group', |
|
439 | - 'ee_edit_question_groups', |
|
440 | - 'ee_read_question_groups', |
|
441 | - 'ee_edit_system_question_groups', |
|
442 | - 'ee_delete_question_group', |
|
443 | - 'ee_delete_question_groups', |
|
444 | - //event_type taxonomy |
|
445 | - 'ee_assign_event_type', |
|
446 | - 'ee_manage_event_types', |
|
447 | - 'ee_edit_event_type', |
|
448 | - 'ee_delete_event_type', |
|
449 | - ), |
|
450 | - 'ee_events_administrator' => array( |
|
451 | - //core wp caps |
|
452 | - 'read', |
|
453 | - 'read_private_pages', |
|
454 | - 'read_private_posts', |
|
455 | - 'edit_users', |
|
456 | - 'edit_posts', |
|
457 | - 'edit_pages', |
|
458 | - 'edit_published_posts', |
|
459 | - 'edit_published_pages', |
|
460 | - 'edit_private_pages', |
|
461 | - 'edit_private_posts', |
|
462 | - 'edit_others_posts', |
|
463 | - 'edit_others_pages', |
|
464 | - 'publish_posts', |
|
465 | - 'publish_pages', |
|
466 | - 'delete_posts', |
|
467 | - 'delete_pages', |
|
468 | - 'delete_private_pages', |
|
469 | - 'delete_private_posts', |
|
470 | - 'delete_published_pages', |
|
471 | - 'delete_published_posts', |
|
472 | - 'delete_others_posts', |
|
473 | - 'delete_others_pages', |
|
474 | - 'manage_categories', |
|
475 | - 'manage_links', |
|
476 | - 'moderate_comments', |
|
477 | - 'unfiltered_html', |
|
478 | - 'upload_files', |
|
479 | - 'export', |
|
480 | - 'import', |
|
481 | - 'list_users', |
|
482 | - 'level_1', //required if user with this role shows up in author dropdowns |
|
483 | - //basic ee access |
|
484 | - 'ee_read_ee', |
|
485 | - //events |
|
486 | - 'ee_publish_events', |
|
487 | - 'ee_read_private_events', |
|
488 | - 'ee_read_others_events', |
|
489 | - 'ee_read_event', |
|
490 | - 'ee_read_events', |
|
491 | - 'ee_edit_event', |
|
492 | - 'ee_edit_events', |
|
493 | - 'ee_edit_published_events', |
|
494 | - 'ee_edit_others_events', |
|
495 | - 'ee_edit_private_events', |
|
496 | - 'ee_delete_published_events', |
|
497 | - 'ee_delete_private_events', |
|
498 | - 'ee_delete_event', |
|
499 | - 'ee_delete_events', |
|
500 | - 'ee_delete_others_events', |
|
501 | - //event categories |
|
502 | - 'ee_manage_event_categories', |
|
503 | - 'ee_edit_event_category', |
|
504 | - 'ee_delete_event_category', |
|
505 | - 'ee_assign_event_category', |
|
506 | - //venues |
|
507 | - 'ee_publish_venues', |
|
508 | - 'ee_read_venue', |
|
509 | - 'ee_read_venues', |
|
510 | - 'ee_read_others_venues', |
|
511 | - 'ee_read_private_venues', |
|
512 | - 'ee_edit_venue', |
|
513 | - 'ee_edit_venues', |
|
514 | - 'ee_edit_others_venues', |
|
515 | - 'ee_edit_published_venues', |
|
516 | - 'ee_edit_private_venues', |
|
517 | - 'ee_delete_venue', |
|
518 | - 'ee_delete_venues', |
|
519 | - 'ee_delete_others_venues', |
|
520 | - 'ee_delete_private_venues', |
|
521 | - 'ee_delete_published_venues', |
|
522 | - //venue categories |
|
523 | - 'ee_manage_venue_categories', |
|
524 | - 'ee_edit_venue_category', |
|
525 | - 'ee_delete_venue_category', |
|
526 | - 'ee_assign_venue_category', |
|
527 | - //contacts |
|
528 | - 'ee_read_contact', |
|
529 | - 'ee_read_contacts', |
|
530 | - 'ee_edit_contact', |
|
531 | - 'ee_edit_contacts', |
|
532 | - 'ee_delete_contact', |
|
533 | - 'ee_delete_contacts', |
|
534 | - //registrations |
|
535 | - 'ee_read_registration', |
|
536 | - 'ee_read_registrations', |
|
537 | - 'ee_read_others_registrations', |
|
538 | - 'ee_edit_registration', |
|
539 | - 'ee_edit_registrations', |
|
540 | - 'ee_edit_others_registrations', |
|
541 | - 'ee_delete_registration', |
|
542 | - 'ee_delete_registrations', |
|
543 | - //checkins |
|
544 | - 'ee_read_checkin', |
|
545 | - 'ee_read_others_checkins', |
|
546 | - 'ee_read_checkins', |
|
547 | - 'ee_edit_checkin', |
|
548 | - 'ee_edit_checkins', |
|
549 | - 'ee_edit_others_checkins', |
|
550 | - 'ee_delete_checkin', |
|
551 | - 'ee_delete_checkins', |
|
552 | - 'ee_delete_others_checkins', |
|
553 | - //transactions && payments |
|
554 | - 'ee_read_transaction', |
|
555 | - 'ee_read_transactions', |
|
556 | - 'ee_edit_payments', |
|
557 | - 'ee_delete_payments', |
|
558 | - //messages |
|
559 | - 'ee_read_message', |
|
560 | - 'ee_read_messages', |
|
561 | - 'ee_read_others_messages', |
|
562 | - 'ee_read_global_messages', |
|
563 | - 'ee_edit_global_messages', |
|
564 | - 'ee_edit_message', |
|
565 | - 'ee_edit_messages', |
|
566 | - 'ee_edit_others_messages', |
|
567 | - 'ee_delete_message', |
|
568 | - 'ee_delete_messages', |
|
569 | - 'ee_delete_others_messages', |
|
570 | - 'ee_delete_global_messages', |
|
571 | - 'ee_send_message', |
|
572 | - //tickets |
|
573 | - 'ee_read_default_ticket', |
|
574 | - 'ee_read_default_tickets', |
|
575 | - 'ee_read_others_default_tickets', |
|
576 | - 'ee_edit_default_ticket', |
|
577 | - 'ee_edit_default_tickets', |
|
578 | - 'ee_edit_others_default_tickets', |
|
579 | - 'ee_delete_default_ticket', |
|
580 | - 'ee_delete_default_tickets', |
|
581 | - 'ee_delete_others_default_tickets', |
|
582 | - //prices |
|
583 | - 'ee_edit_default_price', |
|
584 | - 'ee_edit_default_prices', |
|
585 | - 'ee_delete_default_price', |
|
586 | - 'ee_delete_default_prices', |
|
587 | - 'ee_edit_default_price_type', |
|
588 | - 'ee_edit_default_price_types', |
|
589 | - 'ee_delete_default_price_type', |
|
590 | - 'ee_delete_default_price_types', |
|
591 | - 'ee_read_default_prices', |
|
592 | - 'ee_read_default_price_types', |
|
593 | - //registration form |
|
594 | - 'ee_edit_question', |
|
595 | - 'ee_edit_questions', |
|
596 | - 'ee_edit_system_questions', |
|
597 | - 'ee_read_questions', |
|
598 | - 'ee_delete_question', |
|
599 | - 'ee_delete_questions', |
|
600 | - 'ee_edit_question_group', |
|
601 | - 'ee_edit_question_groups', |
|
602 | - 'ee_read_question_groups', |
|
603 | - 'ee_edit_system_question_groups', |
|
604 | - 'ee_delete_question_group', |
|
605 | - 'ee_delete_question_groups', |
|
606 | - //event_type taxonomy |
|
607 | - 'ee_assign_event_type', |
|
608 | - 'ee_manage_event_types', |
|
609 | - 'ee_edit_event_type', |
|
610 | - 'ee_delete_event_type', |
|
611 | - ), |
|
612 | - ); |
|
613 | - $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
614 | - return $caps; |
|
615 | - } |
|
616 | - |
|
617 | - |
|
618 | - /** |
|
619 | - * Callback for FHEE__EE_Capabilities__init_caps_map__caps that is used for registering additional core |
|
620 | - * capabilities that get added. |
|
621 | - * This is typically done for more dynamic cap additions such as what is registered via the |
|
622 | - * `EE_Payment_Method_Manager` |
|
623 | - * |
|
624 | - * @param array $caps The existing $role=>$capability array. |
|
625 | - * @return array. |
|
626 | - */ |
|
627 | - public function register_additional_capabilities($caps) |
|
628 | - { |
|
629 | - //take care of dynamic capabilities for payment methods |
|
630 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
631 | - $caps = EE_Payment_Method_Manager::instance()->add_payment_method_caps($caps); |
|
632 | - return $caps; |
|
633 | - } |
|
634 | - |
|
635 | - |
|
636 | - /** |
|
637 | - * This adds all the default caps to roles as registered in the _caps_map property. |
|
638 | - * |
|
639 | - * @since 4.5.0 |
|
640 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
641 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
642 | - * and ensures that they are up to date. |
|
643 | - * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
644 | - * up. Note that this should ONLY be called on activation hook or some other one-time |
|
645 | - * task otherwise the caps will be added on every request. |
|
646 | - * @return void |
|
647 | - */ |
|
648 | - public function init_role_caps($reset = false, $custom_map = array()) |
|
649 | - { |
|
650 | - $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
651 | - //first let's determine if these caps have already been set. |
|
652 | - $caps_set_before = get_option(self::option_name, array()); |
|
653 | - //if not reset, see what caps are new for each role. if they're new, add them. |
|
654 | - foreach ($caps_map as $role => $caps_for_role) { |
|
655 | - foreach ($caps_for_role as $cap) { |
|
656 | - //first check we haven't already added this cap before, or it's a reset |
|
657 | - if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
658 | - if ($this->add_cap_to_role($role, $cap)) { |
|
659 | - $caps_set_before[ $role ][] = $cap; |
|
660 | - } |
|
661 | - } |
|
662 | - } |
|
663 | - } |
|
664 | - //now let's just save the cap that has been set. |
|
665 | - update_option(self::option_name, $caps_set_before); |
|
666 | - do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
667 | - } |
|
668 | - |
|
669 | - |
|
670 | - /** |
|
671 | - * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
672 | - * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
673 | - * this is a wrapper for $wp_role->add_cap() |
|
674 | - * |
|
675 | - * @see wp-includes/capabilities.php |
|
676 | - * @since 4.5.0 |
|
677 | - * @param string $role A WordPress role the capability is being added to |
|
678 | - * @param string $cap The capability being added to the role |
|
679 | - * @param bool $grant Whether to grant access to this cap on this role. |
|
680 | - * @return bool |
|
681 | - */ |
|
682 | - public function add_cap_to_role($role, $cap, $grant = true) |
|
683 | - { |
|
684 | - $role_object = get_role($role); |
|
685 | - //if the role isn't available then we create it. |
|
686 | - if (! $role_object instanceof WP_Role) { |
|
687 | - //if a plugin wants to create a specific role name then they should create the role before |
|
688 | - //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
689 | - // - removes any `ee_` namespacing from the start of the slug. |
|
690 | - // - replaces `_` with ` ` (empty space). |
|
691 | - // - sentence case on the resulting string. |
|
692 | - $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
693 | - $role_object = add_role($role, $role_label); |
|
694 | - } |
|
695 | - if ($role_object instanceof WP_Role) { |
|
696 | - $role_object->add_cap($cap, $grant); |
|
697 | - return true; |
|
698 | - } |
|
699 | - return false; |
|
700 | - } |
|
701 | - |
|
702 | - |
|
703 | - /** |
|
704 | - * Functions similarly to add_cap_to_role except removes cap from given role. |
|
705 | - * Wrapper for $wp_role->remove_cap() |
|
706 | - * |
|
707 | - * @see wp-includes/capabilities.php |
|
708 | - * @since 4.5.0 |
|
709 | - * @param string $role A WordPress role the capability is being removed from. |
|
710 | - * @param string $cap The capability being removed |
|
711 | - * @return void |
|
712 | - */ |
|
713 | - public function remove_cap_from_role($role, $cap) |
|
714 | - { |
|
715 | - $role = get_role($role); |
|
716 | - if ($role instanceof WP_Role) { |
|
717 | - $role->remove_cap($cap); |
|
718 | - } |
|
719 | - } |
|
720 | - |
|
721 | - |
|
722 | - /** |
|
723 | - * Wrapper for the native WP current_user_can() method. |
|
724 | - * This is provided as a handy method for a couple things: |
|
725 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
726 | - * write those filters wherever current_user_can is called). |
|
727 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
728 | - * |
|
729 | - * @since 4.5.0 |
|
730 | - * @param string $cap The cap being checked. |
|
731 | - * @param string $context The context where the current_user_can is being called from. |
|
732 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
733 | - * filters. |
|
734 | - * @return bool Whether user can or not. |
|
735 | - */ |
|
736 | - public function current_user_can($cap, $context, $id = 0) |
|
737 | - { |
|
738 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
739 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
740 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
|
741 | - $id); |
|
742 | - return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
743 | - } |
|
744 | - |
|
745 | - |
|
746 | - /** |
|
747 | - * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
748 | - * |
|
749 | - * @param int|WP_User $user Either the user_id or a WP_User object |
|
750 | - * @param string $cap The capability string being checked |
|
751 | - * @param string $context The context where the user_can is being called from (used in filters). |
|
752 | - * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
753 | - * filters) |
|
754 | - * @return bool Whether user can or not. |
|
755 | - */ |
|
756 | - public function user_can($user, $cap, $context, $id = 0) |
|
757 | - { |
|
758 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
759 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
760 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
|
761 | - $id); |
|
762 | - return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
763 | - } |
|
764 | - |
|
765 | - |
|
766 | - /** |
|
767 | - * Wrapper for the native WP current_user_can_for_blog() method. |
|
768 | - * This is provided as a handy method for a couple things: |
|
769 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
770 | - * write those filters wherever current_user_can is called). |
|
771 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
772 | - * |
|
773 | - * @since 4.5.0 |
|
774 | - * @param int $blog_id The blog id that is being checked for. |
|
775 | - * @param string $cap The cap being checked. |
|
776 | - * @param string $context The context where the current_user_can is being called from. |
|
777 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
778 | - * filters. |
|
779 | - * @return bool Whether user can or not. |
|
780 | - */ |
|
781 | - public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
782 | - { |
|
783 | - $user_can = ! empty($id) |
|
784 | - ? current_user_can_for_blog($blog_id, $cap, $id) |
|
785 | - : current_user_can($blog_id, $cap); |
|
786 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
787 | - $user_can = apply_filters( |
|
788 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
789 | - $user_can, |
|
790 | - $blog_id, |
|
791 | - $cap, |
|
792 | - $id |
|
793 | - ); |
|
794 | - $user_can = apply_filters( |
|
795 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', |
|
796 | - $user_can, |
|
797 | - $context, |
|
798 | - $blog_id, |
|
799 | - $cap, |
|
800 | - $id |
|
801 | - ); |
|
802 | - return $user_can; |
|
803 | - } |
|
804 | - |
|
805 | - |
|
806 | - /** |
|
807 | - * This helper method just returns an array of registered EE capabilities. |
|
808 | - * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
809 | - * role. |
|
810 | - * |
|
811 | - * @since 4.5.0 |
|
812 | - * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
813 | - * for the given role are returned. |
|
814 | - * @return array |
|
815 | - */ |
|
816 | - public function get_ee_capabilities($role = 'administrator') |
|
817 | - { |
|
818 | - $capabilities = $this->_init_caps_map(); |
|
819 | - if (empty($role)) { |
|
820 | - return $capabilities; |
|
821 | - } |
|
822 | - return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
823 | - } |
|
19 | + /** |
|
20 | + * the name of the wp option used to store caps previously initialized |
|
21 | + */ |
|
22 | + const option_name = 'ee_caps_initialized'; |
|
23 | + |
|
24 | + /** |
|
25 | + * instance of EE_Capabilities object |
|
26 | + * |
|
27 | + * @var EE_Capabilities |
|
28 | + */ |
|
29 | + private static $_instance; |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * This is a map of caps that correspond to a default WP_Role. |
|
34 | + * Array is indexed by Role and values are ee capabilities. |
|
35 | + * |
|
36 | + * @since 4.5.0 |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + private $_caps_map = array(); |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
44 | + * a user depending on context. |
|
45 | + * |
|
46 | + * @var EE_Meta_Capability_Map[] |
|
47 | + */ |
|
48 | + private $_meta_caps = array(); |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * singleton method used to instantiate class object |
|
53 | + * |
|
54 | + * @since 4.5.0 |
|
55 | + * @return EE_Capabilities |
|
56 | + */ |
|
57 | + public static function instance() |
|
58 | + { |
|
59 | + //check if instantiated, and if not do so. |
|
60 | + if (! self::$_instance instanceof EE_Capabilities) { |
|
61 | + self::$_instance = new self(); |
|
62 | + } |
|
63 | + return self::$_instance; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * private constructor |
|
69 | + * |
|
70 | + * @since 4.5.0 |
|
71 | + */ |
|
72 | + private function __construct() |
|
73 | + { |
|
74 | + if (is_admin()) { |
|
75 | + add_filter( |
|
76 | + 'FHEE__EE_Capabilities__init_caps_map__caps', |
|
77 | + array($this, 'register_additional_capabilities'), |
|
78 | + 10 |
|
79 | + ); |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
86 | + * |
|
87 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
88 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
89 | + * ensures that they are up to date. |
|
90 | + * @since 4.5.0 |
|
91 | + * @return void |
|
92 | + */ |
|
93 | + public function init_caps($reset = false) |
|
94 | + { |
|
95 | + /** |
|
96 | + * Note, this means that caps can only initialized on the default roles when: |
|
97 | + * - models are queryable |
|
98 | + * - All addons have been registered (which happens at plugins_loaded priority 1) |
|
99 | + * In practice, currently this method is usually called around `init`. |
|
100 | + */ |
|
101 | + if ( |
|
102 | + did_action('AHEE__EE_System__load_espresso_addons__complete') |
|
103 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
104 | + ) { |
|
105 | + $this->_caps_map = $this->_init_caps_map(); |
|
106 | + $this->init_role_caps($reset); |
|
107 | + $this->_set_meta_caps(); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * This sets the meta caps property. |
|
114 | + * |
|
115 | + * @since 4.5.0 |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + private function _set_meta_caps() |
|
119 | + { |
|
120 | + //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
121 | + $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
122 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
123 | + //add filter for map_meta_caps but only if models can query. |
|
124 | + if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
125 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * This builds and returns the default meta_caps array only once. |
|
132 | + * |
|
133 | + * @since 4.8.28.rc.012 |
|
134 | + * @return array |
|
135 | + * @throws \EE_Error |
|
136 | + */ |
|
137 | + private function _get_default_meta_caps_array() |
|
138 | + { |
|
139 | + static $default_meta_caps = array(); |
|
140 | + if (empty($default_meta_caps)) { |
|
141 | + $default_meta_caps = array( |
|
142 | + //edits |
|
143 | + new EE_Meta_Capability_Map_Edit( |
|
144 | + 'ee_edit_event', |
|
145 | + array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events') |
|
146 | + ), |
|
147 | + new EE_Meta_Capability_Map_Edit( |
|
148 | + 'ee_edit_venue', |
|
149 | + array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues') |
|
150 | + ), |
|
151 | + new EE_Meta_Capability_Map_Edit( |
|
152 | + 'ee_edit_registration', |
|
153 | + array('Registration', '', 'ee_edit_others_registrations', '') |
|
154 | + ), |
|
155 | + new EE_Meta_Capability_Map_Edit( |
|
156 | + 'ee_edit_checkin', |
|
157 | + array('Registration', '', 'ee_edit_others_checkins', '') |
|
158 | + ), |
|
159 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
160 | + 'ee_edit_message', |
|
161 | + array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages') |
|
162 | + ), |
|
163 | + new EE_Meta_Capability_Map_Edit( |
|
164 | + 'ee_edit_default_ticket', |
|
165 | + array('Ticket', '', 'ee_edit_others_default_tickets', '') |
|
166 | + ), |
|
167 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
168 | + 'ee_edit_question', |
|
169 | + array('Question', '', '', 'ee_edit_system_questions') |
|
170 | + ), |
|
171 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
172 | + 'ee_edit_question_group', |
|
173 | + array('Question_Group', '', '', 'ee_edit_system_question_groups') |
|
174 | + ), |
|
175 | + new EE_Meta_Capability_Map_Edit( |
|
176 | + 'ee_edit_payment_method', |
|
177 | + array('Payment_Method', '', 'ee_edit_others_payment_methods', '') |
|
178 | + ), |
|
179 | + //reads |
|
180 | + new EE_Meta_Capability_Map_Read( |
|
181 | + 'ee_read_event', |
|
182 | + array('Event', '', 'ee_read_others_events', 'ee_read_private_events') |
|
183 | + ), |
|
184 | + new EE_Meta_Capability_Map_Read( |
|
185 | + 'ee_read_venue', |
|
186 | + array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues') |
|
187 | + ), |
|
188 | + new EE_Meta_Capability_Map_Read( |
|
189 | + 'ee_read_registration', |
|
190 | + array('Registration', '', '', 'ee_edit_others_registrations') |
|
191 | + ), |
|
192 | + new EE_Meta_Capability_Map_Read( |
|
193 | + 'ee_read_checkin', |
|
194 | + array('Registration', '', '', 'ee_read_others_checkins') |
|
195 | + ), |
|
196 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
197 | + 'ee_read_message', |
|
198 | + array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages') |
|
199 | + ), |
|
200 | + new EE_Meta_Capability_Map_Read( |
|
201 | + 'ee_read_default_ticket', |
|
202 | + array('Ticket', '', '', 'ee_read_others_default_tickets') |
|
203 | + ), |
|
204 | + new EE_Meta_Capability_Map_Read( |
|
205 | + 'ee_read_payment_method', |
|
206 | + array('Payment_Method', '', '', 'ee_read_others_payment_methods') |
|
207 | + ), |
|
208 | + //deletes |
|
209 | + new EE_Meta_Capability_Map_Delete( |
|
210 | + 'ee_delete_event', |
|
211 | + array( |
|
212 | + 'Event', |
|
213 | + 'ee_delete_published_events', |
|
214 | + 'ee_delete_others_events', |
|
215 | + 'ee_delete_private_events', |
|
216 | + ) |
|
217 | + ), |
|
218 | + new EE_Meta_Capability_Map_Delete( |
|
219 | + 'ee_delete_venue', |
|
220 | + array( |
|
221 | + 'Venue', |
|
222 | + 'ee_delete_published_venues', |
|
223 | + 'ee_delete_others_venues', |
|
224 | + 'ee_delete_private_venues', |
|
225 | + ) |
|
226 | + ), |
|
227 | + new EE_Meta_Capability_Map_Delete( |
|
228 | + 'ee_delete_registration', |
|
229 | + array('Registration', '', 'ee_delete_others_registrations', '') |
|
230 | + ), |
|
231 | + new EE_Meta_Capability_Map_Delete( |
|
232 | + 'ee_delete_checkin', |
|
233 | + array('Registration', '', 'ee_delete_others_checkins', '') |
|
234 | + ), |
|
235 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
236 | + 'ee_delete_message', |
|
237 | + array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages') |
|
238 | + ), |
|
239 | + new EE_Meta_Capability_Map_Delete( |
|
240 | + 'ee_delete_default_ticket', |
|
241 | + array('Ticket', '', 'ee_delete_others_default_tickets', '') |
|
242 | + ), |
|
243 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
244 | + 'ee_delete_question', |
|
245 | + array('Question', '', '', 'delete_system_questions') |
|
246 | + ), |
|
247 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
248 | + 'ee_delete_question_group', |
|
249 | + array('Question_Group', '', '', 'delete_system_question_groups') |
|
250 | + ), |
|
251 | + new EE_Meta_Capability_Map_Delete( |
|
252 | + 'ee_delete_payment_method', |
|
253 | + array('Payment_Method', '', 'ee_delete_others_payment_methods', '') |
|
254 | + ), |
|
255 | + ); |
|
256 | + } |
|
257 | + return $default_meta_caps; |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
263 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
264 | + * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
265 | + * |
|
266 | + * @since 4.5.0 |
|
267 | + * @see wp-includes/capabilities.php |
|
268 | + * @param array $caps actual users capabilities |
|
269 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
270 | + * @param int $user_id The user id |
|
271 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
272 | + * @return array actual users capabilities |
|
273 | + * @throws EE_Error |
|
274 | + */ |
|
275 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
276 | + { |
|
277 | + if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
278 | + //loop through our _meta_caps array |
|
279 | + foreach ($this->_meta_caps as $meta_map) { |
|
280 | + if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
281 | + continue; |
|
282 | + } |
|
283 | + // don't load models if there is no object ID in the args |
|
284 | + if(!empty($args[0])){ |
|
285 | + $meta_map->ensure_is_model(); |
|
286 | + } |
|
287 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
288 | + } |
|
289 | + } |
|
290 | + return $caps; |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * This sets up and returns the initial capabilities map for Event Espresso |
|
296 | + * |
|
297 | + * @since 4.5.0 |
|
298 | + * @return array |
|
299 | + */ |
|
300 | + private function _init_caps_map() |
|
301 | + { |
|
302 | + $caps = array( |
|
303 | + 'administrator' => array( |
|
304 | + //basic access |
|
305 | + 'ee_read_ee', |
|
306 | + //gateways |
|
307 | + /** |
|
308 | + * note that with payment method capabilities, although we've implemented |
|
309 | + * capability mapping which will be used for accessing payment methods owned by |
|
310 | + * other users. This is not fully implemented yet in the payment method ui. |
|
311 | + * Currently only the "plural" caps are in active use. |
|
312 | + * (Specific payment method caps are in use as well). |
|
313 | + **/ |
|
314 | + 'ee_manage_gateways', |
|
315 | + 'ee_read_payment_method', |
|
316 | + 'ee_read_payment_methods', |
|
317 | + 'ee_read_others_payment_methods', |
|
318 | + 'ee_edit_payment_method', |
|
319 | + 'ee_edit_payment_methods', |
|
320 | + 'ee_edit_others_payment_methods', |
|
321 | + 'ee_delete_payment_method', |
|
322 | + 'ee_delete_payment_methods', |
|
323 | + //events |
|
324 | + 'ee_publish_events', |
|
325 | + 'ee_read_private_events', |
|
326 | + 'ee_read_others_events', |
|
327 | + 'ee_read_event', |
|
328 | + 'ee_read_events', |
|
329 | + 'ee_edit_event', |
|
330 | + 'ee_edit_events', |
|
331 | + 'ee_edit_published_events', |
|
332 | + 'ee_edit_others_events', |
|
333 | + 'ee_edit_private_events', |
|
334 | + 'ee_delete_published_events', |
|
335 | + 'ee_delete_private_events', |
|
336 | + 'ee_delete_event', |
|
337 | + 'ee_delete_events', |
|
338 | + 'ee_delete_others_events', |
|
339 | + //event categories |
|
340 | + 'ee_manage_event_categories', |
|
341 | + 'ee_edit_event_category', |
|
342 | + 'ee_delete_event_category', |
|
343 | + 'ee_assign_event_category', |
|
344 | + //venues |
|
345 | + 'ee_publish_venues', |
|
346 | + 'ee_read_venue', |
|
347 | + 'ee_read_venues', |
|
348 | + 'ee_read_others_venues', |
|
349 | + 'ee_read_private_venues', |
|
350 | + 'ee_edit_venue', |
|
351 | + 'ee_edit_venues', |
|
352 | + 'ee_edit_others_venues', |
|
353 | + 'ee_edit_published_venues', |
|
354 | + 'ee_edit_private_venues', |
|
355 | + 'ee_delete_venue', |
|
356 | + 'ee_delete_venues', |
|
357 | + 'ee_delete_others_venues', |
|
358 | + 'ee_delete_private_venues', |
|
359 | + 'ee_delete_published_venues', |
|
360 | + //venue categories |
|
361 | + 'ee_manage_venue_categories', |
|
362 | + 'ee_edit_venue_category', |
|
363 | + 'ee_delete_venue_category', |
|
364 | + 'ee_assign_venue_category', |
|
365 | + //contacts |
|
366 | + 'ee_read_contact', |
|
367 | + 'ee_read_contacts', |
|
368 | + 'ee_edit_contact', |
|
369 | + 'ee_edit_contacts', |
|
370 | + 'ee_delete_contact', |
|
371 | + 'ee_delete_contacts', |
|
372 | + //registrations |
|
373 | + 'ee_read_registration', |
|
374 | + 'ee_read_registrations', |
|
375 | + 'ee_read_others_registrations', |
|
376 | + 'ee_edit_registration', |
|
377 | + 'ee_edit_registrations', |
|
378 | + 'ee_edit_others_registrations', |
|
379 | + 'ee_delete_registration', |
|
380 | + 'ee_delete_registrations', |
|
381 | + //checkins |
|
382 | + 'ee_read_checkin', |
|
383 | + 'ee_read_others_checkins', |
|
384 | + 'ee_read_checkins', |
|
385 | + 'ee_edit_checkin', |
|
386 | + 'ee_edit_checkins', |
|
387 | + 'ee_edit_others_checkins', |
|
388 | + 'ee_delete_checkin', |
|
389 | + 'ee_delete_checkins', |
|
390 | + 'ee_delete_others_checkins', |
|
391 | + //transactions && payments |
|
392 | + 'ee_read_transaction', |
|
393 | + 'ee_read_transactions', |
|
394 | + 'ee_edit_payments', |
|
395 | + 'ee_delete_payments', |
|
396 | + //messages |
|
397 | + 'ee_read_message', |
|
398 | + 'ee_read_messages', |
|
399 | + 'ee_read_others_messages', |
|
400 | + 'ee_read_global_messages', |
|
401 | + 'ee_edit_global_messages', |
|
402 | + 'ee_edit_message', |
|
403 | + 'ee_edit_messages', |
|
404 | + 'ee_edit_others_messages', |
|
405 | + 'ee_delete_message', |
|
406 | + 'ee_delete_messages', |
|
407 | + 'ee_delete_others_messages', |
|
408 | + 'ee_delete_global_messages', |
|
409 | + 'ee_send_message', |
|
410 | + //tickets |
|
411 | + 'ee_read_default_ticket', |
|
412 | + 'ee_read_default_tickets', |
|
413 | + 'ee_read_others_default_tickets', |
|
414 | + 'ee_edit_default_ticket', |
|
415 | + 'ee_edit_default_tickets', |
|
416 | + 'ee_edit_others_default_tickets', |
|
417 | + 'ee_delete_default_ticket', |
|
418 | + 'ee_delete_default_tickets', |
|
419 | + 'ee_delete_others_default_tickets', |
|
420 | + //prices |
|
421 | + 'ee_edit_default_price', |
|
422 | + 'ee_edit_default_prices', |
|
423 | + 'ee_delete_default_price', |
|
424 | + 'ee_delete_default_prices', |
|
425 | + 'ee_edit_default_price_type', |
|
426 | + 'ee_edit_default_price_types', |
|
427 | + 'ee_delete_default_price_type', |
|
428 | + 'ee_delete_default_price_types', |
|
429 | + 'ee_read_default_prices', |
|
430 | + 'ee_read_default_price_types', |
|
431 | + //registration form |
|
432 | + 'ee_edit_question', |
|
433 | + 'ee_edit_questions', |
|
434 | + 'ee_edit_system_questions', |
|
435 | + 'ee_read_questions', |
|
436 | + 'ee_delete_question', |
|
437 | + 'ee_delete_questions', |
|
438 | + 'ee_edit_question_group', |
|
439 | + 'ee_edit_question_groups', |
|
440 | + 'ee_read_question_groups', |
|
441 | + 'ee_edit_system_question_groups', |
|
442 | + 'ee_delete_question_group', |
|
443 | + 'ee_delete_question_groups', |
|
444 | + //event_type taxonomy |
|
445 | + 'ee_assign_event_type', |
|
446 | + 'ee_manage_event_types', |
|
447 | + 'ee_edit_event_type', |
|
448 | + 'ee_delete_event_type', |
|
449 | + ), |
|
450 | + 'ee_events_administrator' => array( |
|
451 | + //core wp caps |
|
452 | + 'read', |
|
453 | + 'read_private_pages', |
|
454 | + 'read_private_posts', |
|
455 | + 'edit_users', |
|
456 | + 'edit_posts', |
|
457 | + 'edit_pages', |
|
458 | + 'edit_published_posts', |
|
459 | + 'edit_published_pages', |
|
460 | + 'edit_private_pages', |
|
461 | + 'edit_private_posts', |
|
462 | + 'edit_others_posts', |
|
463 | + 'edit_others_pages', |
|
464 | + 'publish_posts', |
|
465 | + 'publish_pages', |
|
466 | + 'delete_posts', |
|
467 | + 'delete_pages', |
|
468 | + 'delete_private_pages', |
|
469 | + 'delete_private_posts', |
|
470 | + 'delete_published_pages', |
|
471 | + 'delete_published_posts', |
|
472 | + 'delete_others_posts', |
|
473 | + 'delete_others_pages', |
|
474 | + 'manage_categories', |
|
475 | + 'manage_links', |
|
476 | + 'moderate_comments', |
|
477 | + 'unfiltered_html', |
|
478 | + 'upload_files', |
|
479 | + 'export', |
|
480 | + 'import', |
|
481 | + 'list_users', |
|
482 | + 'level_1', //required if user with this role shows up in author dropdowns |
|
483 | + //basic ee access |
|
484 | + 'ee_read_ee', |
|
485 | + //events |
|
486 | + 'ee_publish_events', |
|
487 | + 'ee_read_private_events', |
|
488 | + 'ee_read_others_events', |
|
489 | + 'ee_read_event', |
|
490 | + 'ee_read_events', |
|
491 | + 'ee_edit_event', |
|
492 | + 'ee_edit_events', |
|
493 | + 'ee_edit_published_events', |
|
494 | + 'ee_edit_others_events', |
|
495 | + 'ee_edit_private_events', |
|
496 | + 'ee_delete_published_events', |
|
497 | + 'ee_delete_private_events', |
|
498 | + 'ee_delete_event', |
|
499 | + 'ee_delete_events', |
|
500 | + 'ee_delete_others_events', |
|
501 | + //event categories |
|
502 | + 'ee_manage_event_categories', |
|
503 | + 'ee_edit_event_category', |
|
504 | + 'ee_delete_event_category', |
|
505 | + 'ee_assign_event_category', |
|
506 | + //venues |
|
507 | + 'ee_publish_venues', |
|
508 | + 'ee_read_venue', |
|
509 | + 'ee_read_venues', |
|
510 | + 'ee_read_others_venues', |
|
511 | + 'ee_read_private_venues', |
|
512 | + 'ee_edit_venue', |
|
513 | + 'ee_edit_venues', |
|
514 | + 'ee_edit_others_venues', |
|
515 | + 'ee_edit_published_venues', |
|
516 | + 'ee_edit_private_venues', |
|
517 | + 'ee_delete_venue', |
|
518 | + 'ee_delete_venues', |
|
519 | + 'ee_delete_others_venues', |
|
520 | + 'ee_delete_private_venues', |
|
521 | + 'ee_delete_published_venues', |
|
522 | + //venue categories |
|
523 | + 'ee_manage_venue_categories', |
|
524 | + 'ee_edit_venue_category', |
|
525 | + 'ee_delete_venue_category', |
|
526 | + 'ee_assign_venue_category', |
|
527 | + //contacts |
|
528 | + 'ee_read_contact', |
|
529 | + 'ee_read_contacts', |
|
530 | + 'ee_edit_contact', |
|
531 | + 'ee_edit_contacts', |
|
532 | + 'ee_delete_contact', |
|
533 | + 'ee_delete_contacts', |
|
534 | + //registrations |
|
535 | + 'ee_read_registration', |
|
536 | + 'ee_read_registrations', |
|
537 | + 'ee_read_others_registrations', |
|
538 | + 'ee_edit_registration', |
|
539 | + 'ee_edit_registrations', |
|
540 | + 'ee_edit_others_registrations', |
|
541 | + 'ee_delete_registration', |
|
542 | + 'ee_delete_registrations', |
|
543 | + //checkins |
|
544 | + 'ee_read_checkin', |
|
545 | + 'ee_read_others_checkins', |
|
546 | + 'ee_read_checkins', |
|
547 | + 'ee_edit_checkin', |
|
548 | + 'ee_edit_checkins', |
|
549 | + 'ee_edit_others_checkins', |
|
550 | + 'ee_delete_checkin', |
|
551 | + 'ee_delete_checkins', |
|
552 | + 'ee_delete_others_checkins', |
|
553 | + //transactions && payments |
|
554 | + 'ee_read_transaction', |
|
555 | + 'ee_read_transactions', |
|
556 | + 'ee_edit_payments', |
|
557 | + 'ee_delete_payments', |
|
558 | + //messages |
|
559 | + 'ee_read_message', |
|
560 | + 'ee_read_messages', |
|
561 | + 'ee_read_others_messages', |
|
562 | + 'ee_read_global_messages', |
|
563 | + 'ee_edit_global_messages', |
|
564 | + 'ee_edit_message', |
|
565 | + 'ee_edit_messages', |
|
566 | + 'ee_edit_others_messages', |
|
567 | + 'ee_delete_message', |
|
568 | + 'ee_delete_messages', |
|
569 | + 'ee_delete_others_messages', |
|
570 | + 'ee_delete_global_messages', |
|
571 | + 'ee_send_message', |
|
572 | + //tickets |
|
573 | + 'ee_read_default_ticket', |
|
574 | + 'ee_read_default_tickets', |
|
575 | + 'ee_read_others_default_tickets', |
|
576 | + 'ee_edit_default_ticket', |
|
577 | + 'ee_edit_default_tickets', |
|
578 | + 'ee_edit_others_default_tickets', |
|
579 | + 'ee_delete_default_ticket', |
|
580 | + 'ee_delete_default_tickets', |
|
581 | + 'ee_delete_others_default_tickets', |
|
582 | + //prices |
|
583 | + 'ee_edit_default_price', |
|
584 | + 'ee_edit_default_prices', |
|
585 | + 'ee_delete_default_price', |
|
586 | + 'ee_delete_default_prices', |
|
587 | + 'ee_edit_default_price_type', |
|
588 | + 'ee_edit_default_price_types', |
|
589 | + 'ee_delete_default_price_type', |
|
590 | + 'ee_delete_default_price_types', |
|
591 | + 'ee_read_default_prices', |
|
592 | + 'ee_read_default_price_types', |
|
593 | + //registration form |
|
594 | + 'ee_edit_question', |
|
595 | + 'ee_edit_questions', |
|
596 | + 'ee_edit_system_questions', |
|
597 | + 'ee_read_questions', |
|
598 | + 'ee_delete_question', |
|
599 | + 'ee_delete_questions', |
|
600 | + 'ee_edit_question_group', |
|
601 | + 'ee_edit_question_groups', |
|
602 | + 'ee_read_question_groups', |
|
603 | + 'ee_edit_system_question_groups', |
|
604 | + 'ee_delete_question_group', |
|
605 | + 'ee_delete_question_groups', |
|
606 | + //event_type taxonomy |
|
607 | + 'ee_assign_event_type', |
|
608 | + 'ee_manage_event_types', |
|
609 | + 'ee_edit_event_type', |
|
610 | + 'ee_delete_event_type', |
|
611 | + ), |
|
612 | + ); |
|
613 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
614 | + return $caps; |
|
615 | + } |
|
616 | + |
|
617 | + |
|
618 | + /** |
|
619 | + * Callback for FHEE__EE_Capabilities__init_caps_map__caps that is used for registering additional core |
|
620 | + * capabilities that get added. |
|
621 | + * This is typically done for more dynamic cap additions such as what is registered via the |
|
622 | + * `EE_Payment_Method_Manager` |
|
623 | + * |
|
624 | + * @param array $caps The existing $role=>$capability array. |
|
625 | + * @return array. |
|
626 | + */ |
|
627 | + public function register_additional_capabilities($caps) |
|
628 | + { |
|
629 | + //take care of dynamic capabilities for payment methods |
|
630 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
631 | + $caps = EE_Payment_Method_Manager::instance()->add_payment_method_caps($caps); |
|
632 | + return $caps; |
|
633 | + } |
|
634 | + |
|
635 | + |
|
636 | + /** |
|
637 | + * This adds all the default caps to roles as registered in the _caps_map property. |
|
638 | + * |
|
639 | + * @since 4.5.0 |
|
640 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
641 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
642 | + * and ensures that they are up to date. |
|
643 | + * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
644 | + * up. Note that this should ONLY be called on activation hook or some other one-time |
|
645 | + * task otherwise the caps will be added on every request. |
|
646 | + * @return void |
|
647 | + */ |
|
648 | + public function init_role_caps($reset = false, $custom_map = array()) |
|
649 | + { |
|
650 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
651 | + //first let's determine if these caps have already been set. |
|
652 | + $caps_set_before = get_option(self::option_name, array()); |
|
653 | + //if not reset, see what caps are new for each role. if they're new, add them. |
|
654 | + foreach ($caps_map as $role => $caps_for_role) { |
|
655 | + foreach ($caps_for_role as $cap) { |
|
656 | + //first check we haven't already added this cap before, or it's a reset |
|
657 | + if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
658 | + if ($this->add_cap_to_role($role, $cap)) { |
|
659 | + $caps_set_before[ $role ][] = $cap; |
|
660 | + } |
|
661 | + } |
|
662 | + } |
|
663 | + } |
|
664 | + //now let's just save the cap that has been set. |
|
665 | + update_option(self::option_name, $caps_set_before); |
|
666 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
667 | + } |
|
668 | + |
|
669 | + |
|
670 | + /** |
|
671 | + * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
672 | + * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
673 | + * this is a wrapper for $wp_role->add_cap() |
|
674 | + * |
|
675 | + * @see wp-includes/capabilities.php |
|
676 | + * @since 4.5.0 |
|
677 | + * @param string $role A WordPress role the capability is being added to |
|
678 | + * @param string $cap The capability being added to the role |
|
679 | + * @param bool $grant Whether to grant access to this cap on this role. |
|
680 | + * @return bool |
|
681 | + */ |
|
682 | + public function add_cap_to_role($role, $cap, $grant = true) |
|
683 | + { |
|
684 | + $role_object = get_role($role); |
|
685 | + //if the role isn't available then we create it. |
|
686 | + if (! $role_object instanceof WP_Role) { |
|
687 | + //if a plugin wants to create a specific role name then they should create the role before |
|
688 | + //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
689 | + // - removes any `ee_` namespacing from the start of the slug. |
|
690 | + // - replaces `_` with ` ` (empty space). |
|
691 | + // - sentence case on the resulting string. |
|
692 | + $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
693 | + $role_object = add_role($role, $role_label); |
|
694 | + } |
|
695 | + if ($role_object instanceof WP_Role) { |
|
696 | + $role_object->add_cap($cap, $grant); |
|
697 | + return true; |
|
698 | + } |
|
699 | + return false; |
|
700 | + } |
|
701 | + |
|
702 | + |
|
703 | + /** |
|
704 | + * Functions similarly to add_cap_to_role except removes cap from given role. |
|
705 | + * Wrapper for $wp_role->remove_cap() |
|
706 | + * |
|
707 | + * @see wp-includes/capabilities.php |
|
708 | + * @since 4.5.0 |
|
709 | + * @param string $role A WordPress role the capability is being removed from. |
|
710 | + * @param string $cap The capability being removed |
|
711 | + * @return void |
|
712 | + */ |
|
713 | + public function remove_cap_from_role($role, $cap) |
|
714 | + { |
|
715 | + $role = get_role($role); |
|
716 | + if ($role instanceof WP_Role) { |
|
717 | + $role->remove_cap($cap); |
|
718 | + } |
|
719 | + } |
|
720 | + |
|
721 | + |
|
722 | + /** |
|
723 | + * Wrapper for the native WP current_user_can() method. |
|
724 | + * This is provided as a handy method for a couple things: |
|
725 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
726 | + * write those filters wherever current_user_can is called). |
|
727 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
728 | + * |
|
729 | + * @since 4.5.0 |
|
730 | + * @param string $cap The cap being checked. |
|
731 | + * @param string $context The context where the current_user_can is being called from. |
|
732 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
733 | + * filters. |
|
734 | + * @return bool Whether user can or not. |
|
735 | + */ |
|
736 | + public function current_user_can($cap, $context, $id = 0) |
|
737 | + { |
|
738 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
739 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
740 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
|
741 | + $id); |
|
742 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
743 | + } |
|
744 | + |
|
745 | + |
|
746 | + /** |
|
747 | + * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
748 | + * |
|
749 | + * @param int|WP_User $user Either the user_id or a WP_User object |
|
750 | + * @param string $cap The capability string being checked |
|
751 | + * @param string $context The context where the user_can is being called from (used in filters). |
|
752 | + * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
753 | + * filters) |
|
754 | + * @return bool Whether user can or not. |
|
755 | + */ |
|
756 | + public function user_can($user, $cap, $context, $id = 0) |
|
757 | + { |
|
758 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
759 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
760 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
|
761 | + $id); |
|
762 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
763 | + } |
|
764 | + |
|
765 | + |
|
766 | + /** |
|
767 | + * Wrapper for the native WP current_user_can_for_blog() method. |
|
768 | + * This is provided as a handy method for a couple things: |
|
769 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
770 | + * write those filters wherever current_user_can is called). |
|
771 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
772 | + * |
|
773 | + * @since 4.5.0 |
|
774 | + * @param int $blog_id The blog id that is being checked for. |
|
775 | + * @param string $cap The cap being checked. |
|
776 | + * @param string $context The context where the current_user_can is being called from. |
|
777 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
778 | + * filters. |
|
779 | + * @return bool Whether user can or not. |
|
780 | + */ |
|
781 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
782 | + { |
|
783 | + $user_can = ! empty($id) |
|
784 | + ? current_user_can_for_blog($blog_id, $cap, $id) |
|
785 | + : current_user_can($blog_id, $cap); |
|
786 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
787 | + $user_can = apply_filters( |
|
788 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
789 | + $user_can, |
|
790 | + $blog_id, |
|
791 | + $cap, |
|
792 | + $id |
|
793 | + ); |
|
794 | + $user_can = apply_filters( |
|
795 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', |
|
796 | + $user_can, |
|
797 | + $context, |
|
798 | + $blog_id, |
|
799 | + $cap, |
|
800 | + $id |
|
801 | + ); |
|
802 | + return $user_can; |
|
803 | + } |
|
804 | + |
|
805 | + |
|
806 | + /** |
|
807 | + * This helper method just returns an array of registered EE capabilities. |
|
808 | + * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
809 | + * role. |
|
810 | + * |
|
811 | + * @since 4.5.0 |
|
812 | + * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
813 | + * for the given role are returned. |
|
814 | + * @return array |
|
815 | + */ |
|
816 | + public function get_ee_capabilities($role = 'administrator') |
|
817 | + { |
|
818 | + $capabilities = $this->_init_caps_map(); |
|
819 | + if (empty($role)) { |
|
820 | + return $capabilities; |
|
821 | + } |
|
822 | + return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
823 | + } |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -837,134 +837,134 @@ discard block |
||
837 | 837 | abstract class EE_Meta_Capability_Map |
838 | 838 | { |
839 | 839 | |
840 | - public $meta_cap; |
|
841 | - |
|
842 | - /** |
|
843 | - * @var EEM_Base |
|
844 | - */ |
|
845 | - protected $_model; |
|
846 | - |
|
847 | - protected $_model_name; |
|
848 | - |
|
849 | - public $published_cap = ''; |
|
850 | - |
|
851 | - public $others_cap = ''; |
|
852 | - |
|
853 | - public $private_cap = ''; |
|
854 | - |
|
855 | - |
|
856 | - /** |
|
857 | - * constructor. |
|
858 | - * Receives the setup arguments for the map. |
|
859 | - * |
|
860 | - * @since 4.5.0 |
|
861 | - * @param string $meta_cap What meta capability is this mapping. |
|
862 | - * @param array $map_values array { |
|
863 | - * //array of values that MUST match a count of 4. It's okay to send an empty string |
|
864 | - * for capabilities that don't get mapped to. |
|
865 | - * @type $map_values [0] string A string representing the model name. Required. String's |
|
866 | - * should always be used when Menu Maps are registered via the |
|
867 | - * plugin API as models are not allowed to be instantiated when |
|
868 | - * in maintenance mode 2 (migrations). |
|
869 | - * @type $map_values [1] string represents the capability used for published. Optional. |
|
870 | - * @type $map_values [2] string represents the capability used for "others". Optional. |
|
871 | - * @type $map_values [3] string represents the capability used for private. Optional. |
|
872 | - * } |
|
873 | - * @throws EE_Error |
|
874 | - */ |
|
875 | - public function __construct($meta_cap, $map_values) |
|
876 | - { |
|
877 | - $this->meta_cap = $meta_cap; |
|
878 | - //verify there are four args in the $map_values array; |
|
879 | - if (count($map_values) !== 4) { |
|
880 | - throw new EE_Error( |
|
881 | - sprintf( |
|
882 | - __( |
|
883 | - 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
884 | - 'event_espresso' |
|
885 | - ), |
|
886 | - '<br>' . print_r($map_values, true) |
|
887 | - ) |
|
888 | - ); |
|
889 | - } |
|
890 | - //set properties |
|
891 | - $this->_model = null; |
|
892 | - $this->_model_name = $map_values[0]; |
|
893 | - $this->published_cap = (string)$map_values[1]; |
|
894 | - $this->others_cap = (string)$map_values[2]; |
|
895 | - $this->private_cap = (string)$map_values[3]; |
|
896 | - } |
|
897 | - |
|
898 | - /** |
|
899 | - * Makes it so this object stops filtering caps |
|
900 | - */ |
|
901 | - public function remove_filters() |
|
902 | - { |
|
903 | - remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
904 | - } |
|
905 | - |
|
906 | - |
|
907 | - /** |
|
908 | - * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
909 | - * |
|
910 | - * @since 4.5.0 |
|
911 | - * @throws EE_Error |
|
912 | - * @return void |
|
913 | - */ |
|
914 | - public function ensure_is_model() |
|
915 | - { |
|
916 | - //is it already instantiated? |
|
917 | - if ($this->_model instanceof EEM_Base) { |
|
918 | - return; |
|
919 | - } |
|
920 | - //ensure model name is string |
|
921 | - $this->_model_name = (string)$this->_model_name; |
|
922 | - //error proof if the name has EEM in it |
|
923 | - $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
924 | - $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
925 | - if (! $this->_model instanceof EEM_Base) { |
|
926 | - throw new EE_Error( |
|
927 | - sprintf( |
|
928 | - __( |
|
929 | - 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
930 | - 'event_espresso' |
|
931 | - ), |
|
932 | - get_class($this), |
|
933 | - $this->_model |
|
934 | - ) |
|
935 | - ); |
|
936 | - } |
|
937 | - } |
|
938 | - |
|
939 | - |
|
940 | - /** |
|
941 | - * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
942 | - * @since 4.6.x |
|
943 | - * @param $caps |
|
944 | - * @param $cap |
|
945 | - * @param $user_id |
|
946 | - * @param $args |
|
947 | - * @return array |
|
948 | - */ |
|
949 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
950 | - { |
|
951 | - return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
952 | - } |
|
953 | - |
|
954 | - |
|
955 | - /** |
|
956 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
957 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
958 | - * |
|
959 | - * @since 4.5.0 |
|
960 | - * @see wp-includes/capabilities.php |
|
961 | - * @param array $caps actual users capabilities |
|
962 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
963 | - * @param int $user_id The user id |
|
964 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
965 | - * @return array actual users capabilities |
|
966 | - */ |
|
967 | - abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
840 | + public $meta_cap; |
|
841 | + |
|
842 | + /** |
|
843 | + * @var EEM_Base |
|
844 | + */ |
|
845 | + protected $_model; |
|
846 | + |
|
847 | + protected $_model_name; |
|
848 | + |
|
849 | + public $published_cap = ''; |
|
850 | + |
|
851 | + public $others_cap = ''; |
|
852 | + |
|
853 | + public $private_cap = ''; |
|
854 | + |
|
855 | + |
|
856 | + /** |
|
857 | + * constructor. |
|
858 | + * Receives the setup arguments for the map. |
|
859 | + * |
|
860 | + * @since 4.5.0 |
|
861 | + * @param string $meta_cap What meta capability is this mapping. |
|
862 | + * @param array $map_values array { |
|
863 | + * //array of values that MUST match a count of 4. It's okay to send an empty string |
|
864 | + * for capabilities that don't get mapped to. |
|
865 | + * @type $map_values [0] string A string representing the model name. Required. String's |
|
866 | + * should always be used when Menu Maps are registered via the |
|
867 | + * plugin API as models are not allowed to be instantiated when |
|
868 | + * in maintenance mode 2 (migrations). |
|
869 | + * @type $map_values [1] string represents the capability used for published. Optional. |
|
870 | + * @type $map_values [2] string represents the capability used for "others". Optional. |
|
871 | + * @type $map_values [3] string represents the capability used for private. Optional. |
|
872 | + * } |
|
873 | + * @throws EE_Error |
|
874 | + */ |
|
875 | + public function __construct($meta_cap, $map_values) |
|
876 | + { |
|
877 | + $this->meta_cap = $meta_cap; |
|
878 | + //verify there are four args in the $map_values array; |
|
879 | + if (count($map_values) !== 4) { |
|
880 | + throw new EE_Error( |
|
881 | + sprintf( |
|
882 | + __( |
|
883 | + 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
884 | + 'event_espresso' |
|
885 | + ), |
|
886 | + '<br>' . print_r($map_values, true) |
|
887 | + ) |
|
888 | + ); |
|
889 | + } |
|
890 | + //set properties |
|
891 | + $this->_model = null; |
|
892 | + $this->_model_name = $map_values[0]; |
|
893 | + $this->published_cap = (string)$map_values[1]; |
|
894 | + $this->others_cap = (string)$map_values[2]; |
|
895 | + $this->private_cap = (string)$map_values[3]; |
|
896 | + } |
|
897 | + |
|
898 | + /** |
|
899 | + * Makes it so this object stops filtering caps |
|
900 | + */ |
|
901 | + public function remove_filters() |
|
902 | + { |
|
903 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
904 | + } |
|
905 | + |
|
906 | + |
|
907 | + /** |
|
908 | + * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
909 | + * |
|
910 | + * @since 4.5.0 |
|
911 | + * @throws EE_Error |
|
912 | + * @return void |
|
913 | + */ |
|
914 | + public function ensure_is_model() |
|
915 | + { |
|
916 | + //is it already instantiated? |
|
917 | + if ($this->_model instanceof EEM_Base) { |
|
918 | + return; |
|
919 | + } |
|
920 | + //ensure model name is string |
|
921 | + $this->_model_name = (string)$this->_model_name; |
|
922 | + //error proof if the name has EEM in it |
|
923 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
924 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
925 | + if (! $this->_model instanceof EEM_Base) { |
|
926 | + throw new EE_Error( |
|
927 | + sprintf( |
|
928 | + __( |
|
929 | + 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
930 | + 'event_espresso' |
|
931 | + ), |
|
932 | + get_class($this), |
|
933 | + $this->_model |
|
934 | + ) |
|
935 | + ); |
|
936 | + } |
|
937 | + } |
|
938 | + |
|
939 | + |
|
940 | + /** |
|
941 | + * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
942 | + * @since 4.6.x |
|
943 | + * @param $caps |
|
944 | + * @param $cap |
|
945 | + * @param $user_id |
|
946 | + * @param $args |
|
947 | + * @return array |
|
948 | + */ |
|
949 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
950 | + { |
|
951 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
952 | + } |
|
953 | + |
|
954 | + |
|
955 | + /** |
|
956 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
957 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
958 | + * |
|
959 | + * @since 4.5.0 |
|
960 | + * @see wp-includes/capabilities.php |
|
961 | + * @param array $caps actual users capabilities |
|
962 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
963 | + * @param int $user_id The user id |
|
964 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
965 | + * @return array actual users capabilities |
|
966 | + */ |
|
967 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | |
@@ -980,81 +980,81 @@ discard block |
||
980 | 980 | class EE_Meta_Capability_Map_Edit extends EE_Meta_Capability_Map |
981 | 981 | { |
982 | 982 | |
983 | - /** |
|
984 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
985 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
986 | - * |
|
987 | - * @since 4.5.0 |
|
988 | - * @see wp-includes/capabilities.php |
|
989 | - * @param array $caps actual users capabilities |
|
990 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
991 | - * @param int $user_id The user id |
|
992 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
993 | - * @return array actual users capabilities |
|
994 | - */ |
|
995 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
996 | - { |
|
997 | - //only process if we're checking our mapped_cap |
|
998 | - if ($cap !== $this->meta_cap) { |
|
999 | - return $caps; |
|
1000 | - } |
|
1001 | - |
|
1002 | - //cast $user_id to int for later explicit comparisons |
|
1003 | - $user_id = (int) $user_id; |
|
1004 | - |
|
1005 | - /** @var EE_Base_Class $obj */ |
|
1006 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1007 | - //if no obj then let's just do cap |
|
1008 | - if (! $obj instanceof EE_Base_Class) { |
|
1009 | - $caps[] = $cap; |
|
1010 | - return $caps; |
|
1011 | - } |
|
1012 | - if ($obj instanceof EE_CPT_Base) { |
|
1013 | - //if the item author is set and the user is the author... |
|
1014 | - if ($obj->wp_user() && $user_id === $obj->wp_user()) { |
|
1015 | - if (empty($this->published_cap)) { |
|
1016 | - $caps[] = $cap; |
|
1017 | - } else { |
|
1018 | - //if obj is published... |
|
1019 | - if ($obj->status() === 'publish') { |
|
1020 | - $caps[] = $this->published_cap; |
|
1021 | - } else { |
|
1022 | - $caps[] = $cap; |
|
1023 | - } |
|
1024 | - } |
|
1025 | - } else { |
|
1026 | - //the user is trying to edit someone else's obj |
|
1027 | - if (! empty($this->others_cap)) { |
|
1028 | - $caps[] = $this->others_cap; |
|
1029 | - } |
|
1030 | - if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | - $caps[] = $this->published_cap; |
|
1032 | - } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | - $caps[] = $this->private_cap; |
|
1034 | - } |
|
1035 | - } |
|
1036 | - } else { |
|
1037 | - //not a cpt object so handled differently |
|
1038 | - $has_cap = false; |
|
1039 | - try { |
|
1040 | - $has_cap = method_exists($obj, 'wp_user') |
|
1041 | - && $obj->wp_user() |
|
1042 | - && $obj->wp_user() === $user_id; |
|
1043 | - } catch (Exception $e) { |
|
1044 | - if (WP_DEBUG) { |
|
1045 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1046 | - } |
|
1047 | - } |
|
1048 | - if ($has_cap) { |
|
1049 | - $caps[] = $cap; |
|
1050 | - } else { |
|
1051 | - if (! empty($this->others_cap)) { |
|
1052 | - $caps[] = $this->others_cap; |
|
1053 | - } |
|
1054 | - } |
|
1055 | - } |
|
1056 | - return $caps; |
|
1057 | - } |
|
983 | + /** |
|
984 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
985 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
986 | + * |
|
987 | + * @since 4.5.0 |
|
988 | + * @see wp-includes/capabilities.php |
|
989 | + * @param array $caps actual users capabilities |
|
990 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
991 | + * @param int $user_id The user id |
|
992 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
993 | + * @return array actual users capabilities |
|
994 | + */ |
|
995 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
996 | + { |
|
997 | + //only process if we're checking our mapped_cap |
|
998 | + if ($cap !== $this->meta_cap) { |
|
999 | + return $caps; |
|
1000 | + } |
|
1001 | + |
|
1002 | + //cast $user_id to int for later explicit comparisons |
|
1003 | + $user_id = (int) $user_id; |
|
1004 | + |
|
1005 | + /** @var EE_Base_Class $obj */ |
|
1006 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1007 | + //if no obj then let's just do cap |
|
1008 | + if (! $obj instanceof EE_Base_Class) { |
|
1009 | + $caps[] = $cap; |
|
1010 | + return $caps; |
|
1011 | + } |
|
1012 | + if ($obj instanceof EE_CPT_Base) { |
|
1013 | + //if the item author is set and the user is the author... |
|
1014 | + if ($obj->wp_user() && $user_id === $obj->wp_user()) { |
|
1015 | + if (empty($this->published_cap)) { |
|
1016 | + $caps[] = $cap; |
|
1017 | + } else { |
|
1018 | + //if obj is published... |
|
1019 | + if ($obj->status() === 'publish') { |
|
1020 | + $caps[] = $this->published_cap; |
|
1021 | + } else { |
|
1022 | + $caps[] = $cap; |
|
1023 | + } |
|
1024 | + } |
|
1025 | + } else { |
|
1026 | + //the user is trying to edit someone else's obj |
|
1027 | + if (! empty($this->others_cap)) { |
|
1028 | + $caps[] = $this->others_cap; |
|
1029 | + } |
|
1030 | + if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | + $caps[] = $this->published_cap; |
|
1032 | + } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | + $caps[] = $this->private_cap; |
|
1034 | + } |
|
1035 | + } |
|
1036 | + } else { |
|
1037 | + //not a cpt object so handled differently |
|
1038 | + $has_cap = false; |
|
1039 | + try { |
|
1040 | + $has_cap = method_exists($obj, 'wp_user') |
|
1041 | + && $obj->wp_user() |
|
1042 | + && $obj->wp_user() === $user_id; |
|
1043 | + } catch (Exception $e) { |
|
1044 | + if (WP_DEBUG) { |
|
1045 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1046 | + } |
|
1047 | + } |
|
1048 | + if ($has_cap) { |
|
1049 | + $caps[] = $cap; |
|
1050 | + } else { |
|
1051 | + if (! empty($this->others_cap)) { |
|
1052 | + $caps[] = $this->others_cap; |
|
1053 | + } |
|
1054 | + } |
|
1055 | + } |
|
1056 | + return $caps; |
|
1057 | + } |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | |
@@ -1071,22 +1071,22 @@ discard block |
||
1071 | 1071 | class EE_Meta_Capability_Map_Delete extends EE_Meta_Capability_Map_Edit |
1072 | 1072 | { |
1073 | 1073 | |
1074 | - /** |
|
1075 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1076 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1077 | - * |
|
1078 | - * @since 4.5.0 |
|
1079 | - * @see wp-includes/capabilities.php |
|
1080 | - * @param array $caps actual users capabilities |
|
1081 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1082 | - * @param int $user_id The user id |
|
1083 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1084 | - * @return array actual users capabilities |
|
1085 | - */ |
|
1086 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1087 | - { |
|
1088 | - return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1089 | - } |
|
1074 | + /** |
|
1075 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1076 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1077 | + * |
|
1078 | + * @since 4.5.0 |
|
1079 | + * @see wp-includes/capabilities.php |
|
1080 | + * @param array $caps actual users capabilities |
|
1081 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1082 | + * @param int $user_id The user id |
|
1083 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1084 | + * @return array actual users capabilities |
|
1085 | + */ |
|
1086 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1087 | + { |
|
1088 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1089 | + } |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | |
@@ -1102,73 +1102,73 @@ discard block |
||
1102 | 1102 | class EE_Meta_Capability_Map_Read extends EE_Meta_Capability_Map |
1103 | 1103 | { |
1104 | 1104 | |
1105 | - /** |
|
1106 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1107 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1108 | - * |
|
1109 | - * @since 4.5.0 |
|
1110 | - * @see wp-includes/capabilities.php |
|
1111 | - * @param array $caps actual users capabilities |
|
1112 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1113 | - * @param int $user_id The user id |
|
1114 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1115 | - * @return array actual users capabilities |
|
1116 | - */ |
|
1117 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1118 | - { |
|
1119 | - //only process if we're checking our mapped cap; |
|
1120 | - if ($cap !== $this->meta_cap) { |
|
1121 | - return $caps; |
|
1122 | - } |
|
1123 | - |
|
1124 | - //cast $user_id to int for later explicit comparisons |
|
1125 | - $user_id = (int) $user_id; |
|
1126 | - |
|
1127 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1128 | - //if no obj then let's just do cap |
|
1129 | - if (! $obj instanceof EE_Base_Class) { |
|
1130 | - $caps[] = $cap; |
|
1131 | - return $caps; |
|
1132 | - } |
|
1133 | - if ($obj instanceof EE_CPT_Base) { |
|
1134 | - $status_obj = get_post_status_object($obj->status()); |
|
1135 | - if ($status_obj->public) { |
|
1136 | - $caps[] = $cap; |
|
1137 | - return $caps; |
|
1138 | - } |
|
1139 | - //if the item author is set and the user is the author... |
|
1140 | - if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1141 | - $caps[] = $cap; |
|
1142 | - } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1143 | - //the user is trying to view someone else's obj |
|
1144 | - $caps[] = $this->private_cap; |
|
1145 | - } elseif (! empty($this->others_cap)) { |
|
1146 | - $caps[] = $this->others_cap; |
|
1147 | - } else { |
|
1148 | - $caps[] = $cap; |
|
1149 | - } |
|
1150 | - } else { |
|
1151 | - //not a cpt object so handled differently |
|
1152 | - $has_cap = false; |
|
1153 | - try { |
|
1154 | - $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $obj->wp_user() === $user_id; |
|
1155 | - } catch (Exception $e) { |
|
1156 | - if (WP_DEBUG) { |
|
1157 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1158 | - } |
|
1159 | - } |
|
1160 | - if ($has_cap) { |
|
1161 | - $caps[] = $cap; |
|
1162 | - } elseif (! empty($this->private_cap)) { |
|
1163 | - $caps[] = $this->private_cap; |
|
1164 | - } elseif (! empty($this->others_cap)) { |
|
1165 | - $caps[] = $this->others_cap; |
|
1166 | - } else { |
|
1167 | - $caps[] = $cap; |
|
1168 | - } |
|
1169 | - } |
|
1170 | - return $caps; |
|
1171 | - } |
|
1105 | + /** |
|
1106 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1107 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1108 | + * |
|
1109 | + * @since 4.5.0 |
|
1110 | + * @see wp-includes/capabilities.php |
|
1111 | + * @param array $caps actual users capabilities |
|
1112 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1113 | + * @param int $user_id The user id |
|
1114 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1115 | + * @return array actual users capabilities |
|
1116 | + */ |
|
1117 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1118 | + { |
|
1119 | + //only process if we're checking our mapped cap; |
|
1120 | + if ($cap !== $this->meta_cap) { |
|
1121 | + return $caps; |
|
1122 | + } |
|
1123 | + |
|
1124 | + //cast $user_id to int for later explicit comparisons |
|
1125 | + $user_id = (int) $user_id; |
|
1126 | + |
|
1127 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1128 | + //if no obj then let's just do cap |
|
1129 | + if (! $obj instanceof EE_Base_Class) { |
|
1130 | + $caps[] = $cap; |
|
1131 | + return $caps; |
|
1132 | + } |
|
1133 | + if ($obj instanceof EE_CPT_Base) { |
|
1134 | + $status_obj = get_post_status_object($obj->status()); |
|
1135 | + if ($status_obj->public) { |
|
1136 | + $caps[] = $cap; |
|
1137 | + return $caps; |
|
1138 | + } |
|
1139 | + //if the item author is set and the user is the author... |
|
1140 | + if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1141 | + $caps[] = $cap; |
|
1142 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1143 | + //the user is trying to view someone else's obj |
|
1144 | + $caps[] = $this->private_cap; |
|
1145 | + } elseif (! empty($this->others_cap)) { |
|
1146 | + $caps[] = $this->others_cap; |
|
1147 | + } else { |
|
1148 | + $caps[] = $cap; |
|
1149 | + } |
|
1150 | + } else { |
|
1151 | + //not a cpt object so handled differently |
|
1152 | + $has_cap = false; |
|
1153 | + try { |
|
1154 | + $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $obj->wp_user() === $user_id; |
|
1155 | + } catch (Exception $e) { |
|
1156 | + if (WP_DEBUG) { |
|
1157 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1158 | + } |
|
1159 | + } |
|
1160 | + if ($has_cap) { |
|
1161 | + $caps[] = $cap; |
|
1162 | + } elseif (! empty($this->private_cap)) { |
|
1163 | + $caps[] = $this->private_cap; |
|
1164 | + } elseif (! empty($this->others_cap)) { |
|
1165 | + $caps[] = $this->others_cap; |
|
1166 | + } else { |
|
1167 | + $caps[] = $cap; |
|
1168 | + } |
|
1169 | + } |
|
1170 | + return $caps; |
|
1171 | + } |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | |
@@ -1185,50 +1185,50 @@ discard block |
||
1185 | 1185 | class EE_Meta_Capability_Map_Messages_Cap extends EE_Meta_Capability_Map |
1186 | 1186 | { |
1187 | 1187 | |
1188 | - /** |
|
1189 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1190 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1191 | - * |
|
1192 | - * @since 4.5.0 |
|
1193 | - * @see wp-includes/capabilities.php |
|
1194 | - * @param array $caps actual users capabilities |
|
1195 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1196 | - * @param int $user_id The user id |
|
1197 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1198 | - * @return array actual users capabilities |
|
1199 | - */ |
|
1200 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1201 | - { |
|
1202 | - //only process if we're checking our mapped_cap |
|
1203 | - if ($cap !== $this->meta_cap) { |
|
1204 | - return $caps; |
|
1205 | - } |
|
1206 | - |
|
1207 | - //cast $user_id to int for later explicit comparisons |
|
1208 | - $user_id = (int) $user_id; |
|
1209 | - |
|
1210 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1211 | - //if no obj then let's just do cap |
|
1212 | - if (! $obj instanceof EE_Message_Template_Group) { |
|
1213 | - $caps[] = $cap; |
|
1214 | - return $caps; |
|
1215 | - } |
|
1216 | - $is_global = $obj->is_global(); |
|
1217 | - if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1218 | - if ($is_global) { |
|
1219 | - $caps[] = $this->private_cap; |
|
1220 | - } else { |
|
1221 | - $caps[] = $cap; |
|
1222 | - } |
|
1223 | - } else { |
|
1224 | - if ($is_global) { |
|
1225 | - $caps[] = $this->private_cap; |
|
1226 | - } else { |
|
1227 | - $caps[] = $this->others_cap; |
|
1228 | - } |
|
1229 | - } |
|
1230 | - return $caps; |
|
1231 | - } |
|
1188 | + /** |
|
1189 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1190 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1191 | + * |
|
1192 | + * @since 4.5.0 |
|
1193 | + * @see wp-includes/capabilities.php |
|
1194 | + * @param array $caps actual users capabilities |
|
1195 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1196 | + * @param int $user_id The user id |
|
1197 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1198 | + * @return array actual users capabilities |
|
1199 | + */ |
|
1200 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1201 | + { |
|
1202 | + //only process if we're checking our mapped_cap |
|
1203 | + if ($cap !== $this->meta_cap) { |
|
1204 | + return $caps; |
|
1205 | + } |
|
1206 | + |
|
1207 | + //cast $user_id to int for later explicit comparisons |
|
1208 | + $user_id = (int) $user_id; |
|
1209 | + |
|
1210 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1211 | + //if no obj then let's just do cap |
|
1212 | + if (! $obj instanceof EE_Message_Template_Group) { |
|
1213 | + $caps[] = $cap; |
|
1214 | + return $caps; |
|
1215 | + } |
|
1216 | + $is_global = $obj->is_global(); |
|
1217 | + if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1218 | + if ($is_global) { |
|
1219 | + $caps[] = $this->private_cap; |
|
1220 | + } else { |
|
1221 | + $caps[] = $cap; |
|
1222 | + } |
|
1223 | + } else { |
|
1224 | + if ($is_global) { |
|
1225 | + $caps[] = $this->private_cap; |
|
1226 | + } else { |
|
1227 | + $caps[] = $this->others_cap; |
|
1228 | + } |
|
1229 | + } |
|
1230 | + return $caps; |
|
1231 | + } |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | |
@@ -1245,39 +1245,39 @@ discard block |
||
1245 | 1245 | class EE_Meta_Capability_Map_Registration_Form_Cap extends EE_Meta_Capability_Map |
1246 | 1246 | { |
1247 | 1247 | |
1248 | - /** |
|
1249 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1250 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1251 | - * |
|
1252 | - * @since 4.5.0 |
|
1253 | - * @see wp-includes/capabilities.php |
|
1254 | - * @param array $caps actual users capabilities |
|
1255 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1256 | - * @param int $user_id The user id |
|
1257 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1258 | - * @return array actual users capabilities |
|
1259 | - */ |
|
1260 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1261 | - { |
|
1262 | - //only process if we're checking our mapped_cap |
|
1263 | - if ($cap !== $this->meta_cap) { |
|
1264 | - return $caps; |
|
1265 | - } |
|
1266 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1267 | - //if no obj then let's just do cap |
|
1268 | - if (! $obj instanceof EE_Base_Class) { |
|
1269 | - $caps[] = $cap; |
|
1270 | - return $caps; |
|
1271 | - } |
|
1272 | - $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1273 | - $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1274 | - if ($is_system) { |
|
1275 | - $caps[] = $this->private_cap; |
|
1276 | - } else { |
|
1277 | - $caps[] = $cap; |
|
1278 | - } |
|
1279 | - return $caps; |
|
1280 | - } |
|
1248 | + /** |
|
1249 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1250 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1251 | + * |
|
1252 | + * @since 4.5.0 |
|
1253 | + * @see wp-includes/capabilities.php |
|
1254 | + * @param array $caps actual users capabilities |
|
1255 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1256 | + * @param int $user_id The user id |
|
1257 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1258 | + * @return array actual users capabilities |
|
1259 | + */ |
|
1260 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1261 | + { |
|
1262 | + //only process if we're checking our mapped_cap |
|
1263 | + if ($cap !== $this->meta_cap) { |
|
1264 | + return $caps; |
|
1265 | + } |
|
1266 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1267 | + //if no obj then let's just do cap |
|
1268 | + if (! $obj instanceof EE_Base_Class) { |
|
1269 | + $caps[] = $cap; |
|
1270 | + return $caps; |
|
1271 | + } |
|
1272 | + $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1273 | + $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1274 | + if ($is_system) { |
|
1275 | + $caps[] = $this->private_cap; |
|
1276 | + } else { |
|
1277 | + $caps[] = $cap; |
|
1278 | + } |
|
1279 | + return $caps; |
|
1280 | + } |
|
1281 | 1281 | |
1282 | 1282 | |
1283 | 1283 | } |
@@ -32,49 +32,49 @@ discard block |
||
32 | 32 | |
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * get_event |
|
37 | - * attempts to retrieve an EE_Event object any way it can |
|
38 | - * |
|
39 | - * @param int|WP_Post $EVT_ID |
|
40 | - * @return EE_Event|null |
|
41 | - * @throws \EE_Error |
|
42 | - */ |
|
35 | + /** |
|
36 | + * get_event |
|
37 | + * attempts to retrieve an EE_Event object any way it can |
|
38 | + * |
|
39 | + * @param int|WP_Post $EVT_ID |
|
40 | + * @return EE_Event|null |
|
41 | + * @throws \EE_Error |
|
42 | + */ |
|
43 | 43 | public static function get_event( $EVT_ID = 0 ) { |
44 | - // international newspaper? |
|
45 | - global $post; |
|
46 | - $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events' |
|
47 | - ? $EVT_ID->ID |
|
48 | - : absint($EVT_ID); |
|
49 | - // do we already have the Event you are looking for? |
|
50 | - if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
51 | - return EEH_Event_View::$_event; |
|
52 | - } |
|
53 | - //reset property so that the new event is cached. |
|
54 | - EEH_Event_View::$_event = null; |
|
55 | - |
|
56 | - if ($EVT_ID || $post instanceof WP_Post) { |
|
57 | - //if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID |
|
58 | - //then let's just use that cached event on the $post object. |
|
59 | - if (($post instanceof WP_Post |
|
60 | - && $post->post_type === 'espresso_events' |
|
61 | - ) |
|
62 | - && isset($post->EE_Event) |
|
63 | - && ($EVT_ID === 0 |
|
64 | - || $EVT_ID === $post->ID |
|
65 | - ) |
|
66 | - ) { |
|
67 | - EEH_Event_View::$_event = $post->EE_Event; |
|
68 | - } |
|
69 | - |
|
70 | - //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID. |
|
71 | - if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
72 | - EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
73 | - } |
|
74 | - } |
|
75 | - |
|
76 | - return EEH_Event_View::$_event; |
|
77 | - } |
|
44 | + // international newspaper? |
|
45 | + global $post; |
|
46 | + $EVT_ID = $EVT_ID instanceof WP_Post && $EVT_ID->post_type === 'espresso_events' |
|
47 | + ? $EVT_ID->ID |
|
48 | + : absint($EVT_ID); |
|
49 | + // do we already have the Event you are looking for? |
|
50 | + if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) { |
|
51 | + return EEH_Event_View::$_event; |
|
52 | + } |
|
53 | + //reset property so that the new event is cached. |
|
54 | + EEH_Event_View::$_event = null; |
|
55 | + |
|
56 | + if ($EVT_ID || $post instanceof WP_Post) { |
|
57 | + //if the post type is for an event and it has a cached event and we don't have a different incoming $EVT_ID |
|
58 | + //then let's just use that cached event on the $post object. |
|
59 | + if (($post instanceof WP_Post |
|
60 | + && $post->post_type === 'espresso_events' |
|
61 | + ) |
|
62 | + && isset($post->EE_Event) |
|
63 | + && ($EVT_ID === 0 |
|
64 | + || $EVT_ID === $post->ID |
|
65 | + ) |
|
66 | + ) { |
|
67 | + EEH_Event_View::$_event = $post->EE_Event; |
|
68 | + } |
|
69 | + |
|
70 | + //If the event we have isn't an event but we do have an EVT_ID, let's try getting the event using the ID. |
|
71 | + if (! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) { |
|
72 | + EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
73 | + } |
|
74 | + } |
|
75 | + |
|
76 | + return EEH_Event_View::$_event; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | 80 | |
@@ -150,58 +150,58 @@ discard block |
||
150 | 150 | * @return string |
151 | 151 | */ |
152 | 152 | public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) { |
153 | - global $post; |
|
153 | + global $post; |
|
154 | 154 | ob_start(); |
155 | 155 | if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) { |
156 | 156 | // admin has chosen "full description" |
157 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
157 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
158 | 158 | the_content(); |
159 | 159 | } else if (( is_archive() && espresso_display_excerpt_in_event_list() ) ) { |
160 | - if ( has_excerpt( $post->ID )) { |
|
161 | - // admin has chosen "excerpt (short desc)" |
|
162 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
163 | - // AND an excerpt actually exists |
|
164 | - the_excerpt(); |
|
165 | - } else { |
|
166 | - // admin has chosen "excerpt (short desc)" |
|
167 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
168 | - // but NO excerpt actually exists, so we need to create one |
|
169 | - if ( ! empty( $num_words )) { |
|
170 | - if ( empty( $more )) { |
|
171 | - $more_link_text = __( '(more…)' ); |
|
172 | - $more = ' <a href="' . get_permalink() . '"'; |
|
173 | - $more .= ' class="more-link"'; |
|
174 | - $more .= \EED_Events_Archive::link_target(); |
|
175 | - $more .= '>' . $more_link_text . '</a>'; |
|
176 | - $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
177 | - } |
|
178 | - $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
179 | - |
|
180 | - $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
181 | - } else { |
|
182 | - $content = get_the_content(); |
|
183 | - } |
|
184 | - global $allowedtags; |
|
185 | - // make sure links are allowed |
|
186 | - $allowedtags['a'] = isset($allowedtags['a']) |
|
187 | - ? $allowedtags['a'] |
|
188 | - : array(); |
|
189 | - // as well as target attribute |
|
190 | - $allowedtags['a']['target'] = isset($allowedtags['a']['target']) |
|
191 | - ? $allowedtags['a']['target'] |
|
192 | - : false; |
|
193 | - // but get previous value so we can reset it |
|
194 | - $prev_value = $allowedtags['a']['target']; |
|
195 | - $allowedtags['a']['target'] = true; |
|
196 | - $content = wp_kses( $content, $allowedtags ); |
|
197 | - $content = strip_shortcodes( $content ); |
|
198 | - echo apply_filters( 'the_content', $content ); |
|
199 | - $allowedtags['a']['target'] = $prev_value; |
|
200 | - } |
|
201 | - } else { |
|
202 | - // admin has chosen "none" |
|
203 | - // for the "Event Espresso - Events > Templates > Display Description" option |
|
204 | - echo apply_filters( 'the_content', '' ); |
|
160 | + if ( has_excerpt( $post->ID )) { |
|
161 | + // admin has chosen "excerpt (short desc)" |
|
162 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
163 | + // AND an excerpt actually exists |
|
164 | + the_excerpt(); |
|
165 | + } else { |
|
166 | + // admin has chosen "excerpt (short desc)" |
|
167 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
168 | + // but NO excerpt actually exists, so we need to create one |
|
169 | + if ( ! empty( $num_words )) { |
|
170 | + if ( empty( $more )) { |
|
171 | + $more_link_text = __( '(more…)' ); |
|
172 | + $more = ' <a href="' . get_permalink() . '"'; |
|
173 | + $more .= ' class="more-link"'; |
|
174 | + $more .= \EED_Events_Archive::link_target(); |
|
175 | + $more .= '>' . $more_link_text . '</a>'; |
|
176 | + $more = apply_filters( 'the_content_more_link', $more, $more_link_text ); |
|
177 | + } |
|
178 | + $content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' )); |
|
179 | + |
|
180 | + $content = wp_trim_words( $content, $num_words, ' ' ) . $more; |
|
181 | + } else { |
|
182 | + $content = get_the_content(); |
|
183 | + } |
|
184 | + global $allowedtags; |
|
185 | + // make sure links are allowed |
|
186 | + $allowedtags['a'] = isset($allowedtags['a']) |
|
187 | + ? $allowedtags['a'] |
|
188 | + : array(); |
|
189 | + // as well as target attribute |
|
190 | + $allowedtags['a']['target'] = isset($allowedtags['a']['target']) |
|
191 | + ? $allowedtags['a']['target'] |
|
192 | + : false; |
|
193 | + // but get previous value so we can reset it |
|
194 | + $prev_value = $allowedtags['a']['target']; |
|
195 | + $allowedtags['a']['target'] = true; |
|
196 | + $content = wp_kses( $content, $allowedtags ); |
|
197 | + $content = strip_shortcodes( $content ); |
|
198 | + echo apply_filters( 'the_content', $content ); |
|
199 | + $allowedtags['a']['target'] = $prev_value; |
|
200 | + } |
|
201 | + } else { |
|
202 | + // admin has chosen "none" |
|
203 | + // for the "Event Espresso - Events > Templates > Display Description" option |
|
204 | + echo apply_filters( 'the_content', '' ); |
|
205 | 205 | } |
206 | 206 | return ob_get_clean(); |
207 | 207 | } |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | $url = get_term_link( $term, 'espresso_venue_categories' ); |
249 | 249 | if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) { |
250 | 250 | $category_links[] = '<a href="' . esc_url( $url ) |
251 | - . '" rel="tag"' |
|
252 | - . \EED_Events_Archive::link_target() |
|
253 | - .'>' |
|
254 | - . $term->name |
|
255 | - . '</a>'; |
|
251 | + . '" rel="tag"' |
|
252 | + . \EED_Events_Archive::link_target() |
|
253 | + .'>' |
|
254 | + . $term->name |
|
255 | + . '</a>'; |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | <ul class="wp-people-group" id="ee-people-group-owners"> |
4 | 4 | <li class="wp-person" id="ee-person-sshoultes"> |
5 | 5 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
6 | - <?php echo esp_gravatar_image( '[email protected]', 'Seth Shoultes' ); ?> |
|
6 | + <?php echo esp_gravatar_image('[email protected]', 'Seth Shoultes'); ?> |
|
7 | 7 | </a> |
8 | 8 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
9 | 9 | Seth Shoultes |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | </li> |
13 | 13 | <li class="wp-person" id="ee-person-gkoyle"> |
14 | 14 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
15 | - <?php echo esp_gravatar_image( '[email protected]', 'Garth Koyle' ); ?> |
|
15 | + <?php echo esp_gravatar_image('[email protected]', 'Garth Koyle'); ?> |
|
16 | 16 | </a> |
17 | 17 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
18 | 18 | Garth Koyle |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | <ul class="wp-people-group" id="ee-people-group-core-developers"> |
25 | 25 | <li class="wp-person" id="ee-person-bchristensen"> |
26 | 26 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
27 | - <?php echo esp_gravatar_image( '[email protected]', 'Brent Christensen' ); ?> |
|
27 | + <?php echo esp_gravatar_image('[email protected]', 'Brent Christensen'); ?> |
|
28 | 28 | </a> |
29 | 29 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
30 | 30 | Brent Christensen |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | </li> |
34 | 34 | <li class="wp-person" id="ee-person-dethier"> |
35 | 35 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
36 | - <?php echo esp_gravatar_image( '[email protected]', 'Darren Ethier' ); ?> |
|
36 | + <?php echo esp_gravatar_image('[email protected]', 'Darren Ethier'); ?> |
|
37 | 37 | </a> |
38 | 38 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
39 | 39 | Darren Ethier |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | </li> |
43 | 43 | <li class="wp-person" id="ee-person-mnelson"> |
44 | 44 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
45 | - <?php echo esp_gravatar_image( '[email protected]', 'Michael Nelson' ); ?> |
|
45 | + <?php echo esp_gravatar_image('[email protected]', 'Michael Nelson'); ?> |
|
46 | 46 | </a> |
47 | 47 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
48 | 48 | Michael Nelson |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | </li> |
52 | 52 | <li class="wp-person" id="ee-person-nkolivoshka"> |
53 | 53 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
54 | - <?php echo esp_gravatar_image( '[email protected]', 'Nazar Kolivoshka' ); ?> |
|
54 | + <?php echo esp_gravatar_image('[email protected]', 'Nazar Kolivoshka'); ?> |
|
55 | 55 | </a> |
56 | 56 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
57 | 57 | Nazar Kolivoshka |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | <ul class="wp-people-group" id="ee-people-group-support-staff"> |
64 | 64 | <li class="wp-person" id="ee-person-jfeck"> |
65 | 65 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
66 | - <?php echo esp_gravatar_image( '[email protected]', 'Josh Feck' ); ?> |
|
66 | + <?php echo esp_gravatar_image('[email protected]', 'Josh Feck'); ?> |
|
67 | 67 | </a> |
68 | 68 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
69 | 69 | Josh Feck |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | </li> |
72 | 72 | <li class="wp-person" id="ee-person-twarwick"> |
73 | 73 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
74 | - <?php echo esp_gravatar_image( '[email protected]', 'Tony Warwick' ); ?> |
|
74 | + <?php echo esp_gravatar_image('[email protected]', 'Tony Warwick'); ?> |
|
75 | 75 | </a> |
76 | 76 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
77 | 77 | Tony Warwick |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | </li> |
80 | 80 | <li class="wp-person" id="ee-person-lcaum"> |
81 | 81 | <a href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
82 | - <?php echo esp_gravatar_image( '[email protected]', 'Lorenzo Caum' ); ?> |
|
82 | + <?php echo esp_gravatar_image('[email protected]', 'Lorenzo Caum'); ?> |
|
83 | 83 | </a> |
84 | 84 | <a class="web" href="<?php esp_gravatar_profile('[email protected]'); ?>"> |
85 | 85 | Lorenzo Caum |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | </ul> |
90 | 90 | <h3 class="wp-people-group"><?php _e('Contributor Recognition', 'event_espresso'); ?></h3> |
91 | 91 | <p class="description"> |
92 | - <?php printf( __('For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.', 'event_espresso'), '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">', '</a>' ); ?> |
|
92 | + <?php printf(__('For every major release we want to recognize the people who contributed to the release via a GitHub pull request. Want to see your name listed here? %sWhen you submit a pull request that gets included in a major release%s, we\'ll add your name here linked to your GitHub profile.', 'event_espresso'), '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">', '</a>'); ?> |
|
93 | 93 | </p> |
94 | 94 | <p class="wp-credits-list"> |
95 | 95 | <ul> |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | </p> |
104 | 104 | <h3 class="wp-people-group"><?php _e('External Libraries', 'event_espresso'); ?></h3> |
105 | 105 | <p class="description"> |
106 | - <?php printf( __('Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', 'event_espresso'), '<a href="credits.php">', '</a>' ); ?> |
|
106 | + <?php printf(__('Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', 'event_espresso'), '<a href="credits.php">', '</a>'); ?> |
|
107 | 107 | </p> |
108 | 108 | <p class="wp-credits-list"> |
109 | 109 | <a href="http://josscrowcroft.github.io/accounting.js/"><?php _e('accounting.js', 'event_espresso'); ?></a>, |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | |
120 | 120 | <?php |
121 | 121 | function esp_gravatar_profile($email) { |
122 | - echo 'http://www.gravatar.com/' . md5($email); |
|
122 | + echo 'http://www.gravatar.com/'.md5($email); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | function esp_gravatar_image($email, $name) { |
126 | - echo '<img src="http://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>'; |
|
126 | + echo '<img src="http://0.gravatar.com/avatar/'.md5($email).'?s=60" class="gravatar" alt="'.$name.'"/>'; |
|
127 | 127 | } |
128 | 128 | ?> |
@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | // if you're a dev and want to receive all errors via email |
6 | 6 | // add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE ); |
7 | 7 | if (defined('WP_DEBUG') && WP_DEBUG === true && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === true) { |
8 | - set_error_handler(array('EE_Error', 'error_handler')); |
|
9 | - register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
8 | + set_error_handler(array('EE_Error', 'error_handler')); |
|
9 | + register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | |
@@ -23,259 +23,259 @@ discard block |
||
23 | 23 | { |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * name of the file to log exceptions to |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - private static $_exception_log_file = 'espresso_error_log.txt'; |
|
32 | - |
|
33 | - /** |
|
34 | - * stores details for all exception |
|
35 | - * |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - private static $_all_exceptions = array(); |
|
39 | - |
|
40 | - /** |
|
41 | - * tracks number of errors |
|
42 | - * |
|
43 | - * @var int |
|
44 | - */ |
|
45 | - private static $_error_count = 0; |
|
46 | - |
|
47 | - /** |
|
48 | - * has shutdown action been added ? |
|
49 | - * |
|
50 | - * @var array $_espresso_notices |
|
51 | - */ |
|
52 | - private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false); |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @override default exception handling |
|
58 | - * @param string $message |
|
59 | - * @param int $code |
|
60 | - * @param Exception|null $previous |
|
61 | - */ |
|
62 | - public function __construct($message, $code = 0, Exception $previous = null) |
|
63 | - { |
|
64 | - if (version_compare(PHP_VERSION, '5.3.0', '<')) { |
|
65 | - parent::__construct($message, $code); |
|
66 | - } else { |
|
67 | - parent::__construct($message, $code, $previous); |
|
68 | - } |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * error_handler |
|
75 | - * |
|
76 | - * @param $code |
|
77 | - * @param $message |
|
78 | - * @param $file |
|
79 | - * @param $line |
|
80 | - * @return void |
|
81 | - */ |
|
82 | - public static function error_handler($code, $message, $file, $line) |
|
83 | - { |
|
84 | - $type = EE_Error::error_type($code); |
|
85 | - $site = site_url(); |
|
86 | - switch ($site) { |
|
87 | - case 'http://ee4.eventespresso.com/' : |
|
88 | - case 'http://ee4decaf.eventespresso.com/' : |
|
89 | - case 'http://ee4hf.eventespresso.com/' : |
|
90 | - case 'http://ee4a.eventespresso.com/' : |
|
91 | - case 'http://ee4ad.eventespresso.com/' : |
|
92 | - case 'http://ee4b.eventespresso.com/' : |
|
93 | - case 'http://ee4bd.eventespresso.com/' : |
|
94 | - case 'http://ee4d.eventespresso.com/' : |
|
95 | - case 'http://ee4dd.eventespresso.com/' : |
|
96 | - $to = '[email protected]'; |
|
97 | - break; |
|
98 | - default : |
|
99 | - $to = get_option('admin_email'); |
|
100 | - } |
|
101 | - $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
102 | - $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
103 | - if (function_exists('wp_mail')) { |
|
104 | - add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
105 | - wp_mail($to, $subject, $msg); |
|
106 | - } |
|
107 | - echo '<div id="message" class="espresso-notices error"><p>'; |
|
108 | - echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
109 | - echo '<br /></p></div>'; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * error_type |
|
116 | - * http://www.php.net/manual/en/errorfunc.constants.php#109430 |
|
117 | - * |
|
118 | - * @param $code |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public static function error_type($code) |
|
122 | - { |
|
123 | - switch ($code) { |
|
124 | - case E_ERROR: // 1 // |
|
125 | - return 'E_ERROR'; |
|
126 | - case E_WARNING: // 2 // |
|
127 | - return 'E_WARNING'; |
|
128 | - case E_PARSE: // 4 // |
|
129 | - return 'E_PARSE'; |
|
130 | - case E_NOTICE: // 8 // |
|
131 | - return 'E_NOTICE'; |
|
132 | - case E_CORE_ERROR: // 16 // |
|
133 | - return 'E_CORE_ERROR'; |
|
134 | - case E_CORE_WARNING: // 32 // |
|
135 | - return 'E_CORE_WARNING'; |
|
136 | - case E_COMPILE_ERROR: // 64 // |
|
137 | - return 'E_COMPILE_ERROR'; |
|
138 | - case E_COMPILE_WARNING: // 128 // |
|
139 | - return 'E_COMPILE_WARNING'; |
|
140 | - case E_USER_ERROR: // 256 // |
|
141 | - return 'E_USER_ERROR'; |
|
142 | - case E_USER_WARNING: // 512 // |
|
143 | - return 'E_USER_WARNING'; |
|
144 | - case E_USER_NOTICE: // 1024 // |
|
145 | - return 'E_USER_NOTICE'; |
|
146 | - case E_STRICT: // 2048 // |
|
147 | - return 'E_STRICT'; |
|
148 | - case E_RECOVERABLE_ERROR: // 4096 // |
|
149 | - return 'E_RECOVERABLE_ERROR'; |
|
150 | - case E_DEPRECATED: // 8192 // |
|
151 | - return 'E_DEPRECATED'; |
|
152 | - case E_USER_DEPRECATED: // 16384 // |
|
153 | - return 'E_USER_DEPRECATED'; |
|
154 | - case E_ALL: // 16384 // |
|
155 | - return 'E_ALL'; |
|
156 | - } |
|
157 | - return ''; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * fatal_error_handler |
|
164 | - * |
|
165 | - * @return void |
|
166 | - */ |
|
167 | - public static function fatal_error_handler() |
|
168 | - { |
|
169 | - $last_error = error_get_last(); |
|
170 | - if ($last_error['type'] === E_ERROR) { |
|
171 | - EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * _format_error |
|
179 | - * |
|
180 | - * @param $code |
|
181 | - * @param $message |
|
182 | - * @param $file |
|
183 | - * @param $line |
|
184 | - * @return string |
|
185 | - */ |
|
186 | - private static function _format_error($code, $message, $file, $line) |
|
187 | - { |
|
188 | - $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
|
189 | - $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
|
190 | - $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
|
191 | - $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>"; |
|
192 | - $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>"; |
|
193 | - $html .= '</tbody></table>'; |
|
194 | - return $html; |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * set_content_type |
|
201 | - * |
|
202 | - * @param $content_type |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - public static function set_content_type($content_type) |
|
206 | - { |
|
207 | - return 'text/html'; |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * @return void |
|
214 | - * @throws EE_Error |
|
215 | - * @throws ReflectionException |
|
216 | - */ |
|
217 | - public function get_error() |
|
218 | - { |
|
219 | - if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) { |
|
220 | - throw $this; |
|
221 | - } |
|
222 | - // get separate user and developer messages if they exist |
|
223 | - $msg = explode('||', $this->getMessage()); |
|
224 | - $user_msg = $msg[0]; |
|
225 | - $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
226 | - $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
227 | - // add details to _all_exceptions array |
|
228 | - $x_time = time(); |
|
229 | - self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
230 | - self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
231 | - self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
232 | - self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
233 | - self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
234 | - self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
235 | - self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
236 | - self::$_error_count++; |
|
237 | - //add_action( 'shutdown', array( $this, 'display_errors' )); |
|
238 | - $this->display_errors(); |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * has_error |
|
245 | - * |
|
246 | - * @param bool $check_stored |
|
247 | - * @param string $type_to_check |
|
248 | - * @return bool |
|
249 | - */ |
|
250 | - public static function has_error($check_stored = false, $type_to_check = 'errors') |
|
251 | - { |
|
252 | - $has_error = isset(self::$_espresso_notices[$type_to_check]) |
|
253 | - && ! empty(self::$_espresso_notices[$type_to_check]) |
|
254 | - ? true |
|
255 | - : false; |
|
256 | - if ($check_stored && ! $has_error) { |
|
257 | - $notices = (array)get_option('ee_notices', array()); |
|
258 | - foreach ($notices as $type => $notice) { |
|
259 | - if ($type === $type_to_check && $notice) { |
|
260 | - return true; |
|
261 | - } |
|
262 | - } |
|
263 | - } |
|
264 | - return $has_error; |
|
265 | - } |
|
266 | - |
|
267 | - |
|
268 | - |
|
269 | - /** |
|
270 | - * display_errors |
|
271 | - * |
|
272 | - * @echo string |
|
273 | - * @throws \ReflectionException |
|
274 | - */ |
|
275 | - public function display_errors() |
|
276 | - { |
|
277 | - $trace_details = ''; |
|
278 | - $output = ' |
|
26 | + /** |
|
27 | + * name of the file to log exceptions to |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + private static $_exception_log_file = 'espresso_error_log.txt'; |
|
32 | + |
|
33 | + /** |
|
34 | + * stores details for all exception |
|
35 | + * |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + private static $_all_exceptions = array(); |
|
39 | + |
|
40 | + /** |
|
41 | + * tracks number of errors |
|
42 | + * |
|
43 | + * @var int |
|
44 | + */ |
|
45 | + private static $_error_count = 0; |
|
46 | + |
|
47 | + /** |
|
48 | + * has shutdown action been added ? |
|
49 | + * |
|
50 | + * @var array $_espresso_notices |
|
51 | + */ |
|
52 | + private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false); |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @override default exception handling |
|
58 | + * @param string $message |
|
59 | + * @param int $code |
|
60 | + * @param Exception|null $previous |
|
61 | + */ |
|
62 | + public function __construct($message, $code = 0, Exception $previous = null) |
|
63 | + { |
|
64 | + if (version_compare(PHP_VERSION, '5.3.0', '<')) { |
|
65 | + parent::__construct($message, $code); |
|
66 | + } else { |
|
67 | + parent::__construct($message, $code, $previous); |
|
68 | + } |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * error_handler |
|
75 | + * |
|
76 | + * @param $code |
|
77 | + * @param $message |
|
78 | + * @param $file |
|
79 | + * @param $line |
|
80 | + * @return void |
|
81 | + */ |
|
82 | + public static function error_handler($code, $message, $file, $line) |
|
83 | + { |
|
84 | + $type = EE_Error::error_type($code); |
|
85 | + $site = site_url(); |
|
86 | + switch ($site) { |
|
87 | + case 'http://ee4.eventespresso.com/' : |
|
88 | + case 'http://ee4decaf.eventespresso.com/' : |
|
89 | + case 'http://ee4hf.eventespresso.com/' : |
|
90 | + case 'http://ee4a.eventespresso.com/' : |
|
91 | + case 'http://ee4ad.eventespresso.com/' : |
|
92 | + case 'http://ee4b.eventespresso.com/' : |
|
93 | + case 'http://ee4bd.eventespresso.com/' : |
|
94 | + case 'http://ee4d.eventespresso.com/' : |
|
95 | + case 'http://ee4dd.eventespresso.com/' : |
|
96 | + $to = '[email protected]'; |
|
97 | + break; |
|
98 | + default : |
|
99 | + $to = get_option('admin_email'); |
|
100 | + } |
|
101 | + $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
102 | + $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
103 | + if (function_exists('wp_mail')) { |
|
104 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
105 | + wp_mail($to, $subject, $msg); |
|
106 | + } |
|
107 | + echo '<div id="message" class="espresso-notices error"><p>'; |
|
108 | + echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
109 | + echo '<br /></p></div>'; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * error_type |
|
116 | + * http://www.php.net/manual/en/errorfunc.constants.php#109430 |
|
117 | + * |
|
118 | + * @param $code |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public static function error_type($code) |
|
122 | + { |
|
123 | + switch ($code) { |
|
124 | + case E_ERROR: // 1 // |
|
125 | + return 'E_ERROR'; |
|
126 | + case E_WARNING: // 2 // |
|
127 | + return 'E_WARNING'; |
|
128 | + case E_PARSE: // 4 // |
|
129 | + return 'E_PARSE'; |
|
130 | + case E_NOTICE: // 8 // |
|
131 | + return 'E_NOTICE'; |
|
132 | + case E_CORE_ERROR: // 16 // |
|
133 | + return 'E_CORE_ERROR'; |
|
134 | + case E_CORE_WARNING: // 32 // |
|
135 | + return 'E_CORE_WARNING'; |
|
136 | + case E_COMPILE_ERROR: // 64 // |
|
137 | + return 'E_COMPILE_ERROR'; |
|
138 | + case E_COMPILE_WARNING: // 128 // |
|
139 | + return 'E_COMPILE_WARNING'; |
|
140 | + case E_USER_ERROR: // 256 // |
|
141 | + return 'E_USER_ERROR'; |
|
142 | + case E_USER_WARNING: // 512 // |
|
143 | + return 'E_USER_WARNING'; |
|
144 | + case E_USER_NOTICE: // 1024 // |
|
145 | + return 'E_USER_NOTICE'; |
|
146 | + case E_STRICT: // 2048 // |
|
147 | + return 'E_STRICT'; |
|
148 | + case E_RECOVERABLE_ERROR: // 4096 // |
|
149 | + return 'E_RECOVERABLE_ERROR'; |
|
150 | + case E_DEPRECATED: // 8192 // |
|
151 | + return 'E_DEPRECATED'; |
|
152 | + case E_USER_DEPRECATED: // 16384 // |
|
153 | + return 'E_USER_DEPRECATED'; |
|
154 | + case E_ALL: // 16384 // |
|
155 | + return 'E_ALL'; |
|
156 | + } |
|
157 | + return ''; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * fatal_error_handler |
|
164 | + * |
|
165 | + * @return void |
|
166 | + */ |
|
167 | + public static function fatal_error_handler() |
|
168 | + { |
|
169 | + $last_error = error_get_last(); |
|
170 | + if ($last_error['type'] === E_ERROR) { |
|
171 | + EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * _format_error |
|
179 | + * |
|
180 | + * @param $code |
|
181 | + * @param $message |
|
182 | + * @param $file |
|
183 | + * @param $line |
|
184 | + * @return string |
|
185 | + */ |
|
186 | + private static function _format_error($code, $message, $file, $line) |
|
187 | + { |
|
188 | + $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
|
189 | + $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
|
190 | + $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
|
191 | + $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>"; |
|
192 | + $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>"; |
|
193 | + $html .= '</tbody></table>'; |
|
194 | + return $html; |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * set_content_type |
|
201 | + * |
|
202 | + * @param $content_type |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + public static function set_content_type($content_type) |
|
206 | + { |
|
207 | + return 'text/html'; |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * @return void |
|
214 | + * @throws EE_Error |
|
215 | + * @throws ReflectionException |
|
216 | + */ |
|
217 | + public function get_error() |
|
218 | + { |
|
219 | + if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) { |
|
220 | + throw $this; |
|
221 | + } |
|
222 | + // get separate user and developer messages if they exist |
|
223 | + $msg = explode('||', $this->getMessage()); |
|
224 | + $user_msg = $msg[0]; |
|
225 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
226 | + $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
227 | + // add details to _all_exceptions array |
|
228 | + $x_time = time(); |
|
229 | + self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
230 | + self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
231 | + self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
232 | + self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
233 | + self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
234 | + self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
235 | + self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
236 | + self::$_error_count++; |
|
237 | + //add_action( 'shutdown', array( $this, 'display_errors' )); |
|
238 | + $this->display_errors(); |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * has_error |
|
245 | + * |
|
246 | + * @param bool $check_stored |
|
247 | + * @param string $type_to_check |
|
248 | + * @return bool |
|
249 | + */ |
|
250 | + public static function has_error($check_stored = false, $type_to_check = 'errors') |
|
251 | + { |
|
252 | + $has_error = isset(self::$_espresso_notices[$type_to_check]) |
|
253 | + && ! empty(self::$_espresso_notices[$type_to_check]) |
|
254 | + ? true |
|
255 | + : false; |
|
256 | + if ($check_stored && ! $has_error) { |
|
257 | + $notices = (array)get_option('ee_notices', array()); |
|
258 | + foreach ($notices as $type => $notice) { |
|
259 | + if ($type === $type_to_check && $notice) { |
|
260 | + return true; |
|
261 | + } |
|
262 | + } |
|
263 | + } |
|
264 | + return $has_error; |
|
265 | + } |
|
266 | + |
|
267 | + |
|
268 | + |
|
269 | + /** |
|
270 | + * display_errors |
|
271 | + * |
|
272 | + * @echo string |
|
273 | + * @throws \ReflectionException |
|
274 | + */ |
|
275 | + public function display_errors() |
|
276 | + { |
|
277 | + $trace_details = ''; |
|
278 | + $output = ' |
|
279 | 279 | <style type="text/css"> |
280 | 280 | #ee-error-message { |
281 | 281 | max-width:90% !important; |
@@ -331,19 +331,19 @@ discard block |
||
331 | 331 | } |
332 | 332 | </style> |
333 | 333 | <div id="ee-error-message" class="error">'; |
334 | - if (! WP_DEBUG) { |
|
335 | - $output .= ' |
|
334 | + if (! WP_DEBUG) { |
|
335 | + $output .= ' |
|
336 | 336 | <p>'; |
337 | - } |
|
338 | - // cycle thru errors |
|
339 | - foreach (self::$_all_exceptions as $time => $ex) { |
|
340 | - $error_code = ''; |
|
341 | - // process trace info |
|
342 | - if (empty($ex['trace'])) { |
|
343 | - $trace_details .= __('Sorry, but no trace information was available for this exception.', |
|
344 | - 'event_espresso'); |
|
345 | - } else { |
|
346 | - $trace_details .= ' |
|
337 | + } |
|
338 | + // cycle thru errors |
|
339 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
340 | + $error_code = ''; |
|
341 | + // process trace info |
|
342 | + if (empty($ex['trace'])) { |
|
343 | + $trace_details .= __('Sorry, but no trace information was available for this exception.', |
|
344 | + 'event_espresso'); |
|
345 | + } else { |
|
346 | + $trace_details .= ' |
|
347 | 347 | <div id="ee-trace-details"> |
348 | 348 | <table width="100%" border="0" cellpadding="5" cellspacing="0"> |
349 | 349 | <tr> |
@@ -353,38 +353,38 @@ discard block |
||
353 | 353 | <th scope="col" align="left">Class</th> |
354 | 354 | <th scope="col" align="left">Method( arguments )</th> |
355 | 355 | </tr>'; |
356 | - $last_on_stack = count($ex['trace']) - 1; |
|
357 | - // reverse array so that stack is in proper chronological order |
|
358 | - $sorted_trace = array_reverse($ex['trace']); |
|
359 | - foreach ($sorted_trace as $nmbr => $trace) { |
|
360 | - $file = isset($trace['file']) ? $trace['file'] : ''; |
|
361 | - $class = isset($trace['class']) ? $trace['class'] : ''; |
|
362 | - $type = isset($trace['type']) ? $trace['type'] : ''; |
|
363 | - $function = isset($trace['function']) ? $trace['function'] : ''; |
|
364 | - $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
365 | - $line = isset($trace['line']) ? $trace['line'] : ''; |
|
366 | - $zebra = ($nmbr % 2) ? ' odd' : ''; |
|
367 | - if (empty($file) && ! empty($class)) { |
|
368 | - $a = new ReflectionClass($class); |
|
369 | - $file = $a->getFileName(); |
|
370 | - if (empty($line) && ! empty($function)) { |
|
371 | - $b = new ReflectionMethod($class, $function); |
|
372 | - $line = $b->getStartLine(); |
|
373 | - } |
|
374 | - } |
|
375 | - if ($nmbr === $last_on_stack) { |
|
376 | - $file = $ex['file'] !== '' ? $ex['file'] : $file; |
|
377 | - $line = $ex['line'] !== '' ? $ex['line'] : $line; |
|
378 | - $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
379 | - } |
|
380 | - $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
381 | - $line_dsply = ! empty($line) ? $line : ' '; |
|
382 | - $file_dsply = ! empty($file) ? $file : ' '; |
|
383 | - $class_dsply = ! empty($class) ? $class : ' '; |
|
384 | - $type_dsply = ! empty($type) ? $type : ' '; |
|
385 | - $function_dsply = ! empty($function) ? $function : ' '; |
|
386 | - $args_dsply = ! empty($args) ? '( ' . $args . ' )' : ''; |
|
387 | - $trace_details .= ' |
|
356 | + $last_on_stack = count($ex['trace']) - 1; |
|
357 | + // reverse array so that stack is in proper chronological order |
|
358 | + $sorted_trace = array_reverse($ex['trace']); |
|
359 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
360 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
361 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
362 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
363 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
364 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
365 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
366 | + $zebra = ($nmbr % 2) ? ' odd' : ''; |
|
367 | + if (empty($file) && ! empty($class)) { |
|
368 | + $a = new ReflectionClass($class); |
|
369 | + $file = $a->getFileName(); |
|
370 | + if (empty($line) && ! empty($function)) { |
|
371 | + $b = new ReflectionMethod($class, $function); |
|
372 | + $line = $b->getStartLine(); |
|
373 | + } |
|
374 | + } |
|
375 | + if ($nmbr === $last_on_stack) { |
|
376 | + $file = $ex['file'] !== '' ? $ex['file'] : $file; |
|
377 | + $line = $ex['line'] !== '' ? $ex['line'] : $line; |
|
378 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
379 | + } |
|
380 | + $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
381 | + $line_dsply = ! empty($line) ? $line : ' '; |
|
382 | + $file_dsply = ! empty($file) ? $file : ' '; |
|
383 | + $class_dsply = ! empty($class) ? $class : ' '; |
|
384 | + $type_dsply = ! empty($type) ? $type : ' '; |
|
385 | + $function_dsply = ! empty($function) ? $function : ' '; |
|
386 | + $args_dsply = ! empty($args) ? '( ' . $args . ' )' : ''; |
|
387 | + $trace_details .= ' |
|
388 | 388 | <tr> |
389 | 389 | <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
390 | 390 | <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
@@ -392,669 +392,669 @@ discard block |
||
392 | 392 | <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
393 | 393 | <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
394 | 394 | </tr>'; |
395 | - } |
|
396 | - $trace_details .= ' |
|
395 | + } |
|
396 | + $trace_details .= ' |
|
397 | 397 | </table> |
398 | 398 | </div>'; |
399 | - } |
|
400 | - $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
|
401 | - // add generic non-identifying messages for non-privileged users |
|
402 | - if (! WP_DEBUG) { |
|
403 | - $output .= '<span class="ee-error-user-msg-spn">' |
|
404 | - . trim($ex['msg']) |
|
405 | - . '</span> <sup>' |
|
406 | - . $ex['code'] |
|
407 | - . '</sup><br />'; |
|
408 | - } else { |
|
409 | - // or helpful developer messages if debugging is on |
|
410 | - $output .= ' |
|
399 | + } |
|
400 | + $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
|
401 | + // add generic non-identifying messages for non-privileged users |
|
402 | + if (! WP_DEBUG) { |
|
403 | + $output .= '<span class="ee-error-user-msg-spn">' |
|
404 | + . trim($ex['msg']) |
|
405 | + . '</span> <sup>' |
|
406 | + . $ex['code'] |
|
407 | + . '</sup><br />'; |
|
408 | + } else { |
|
409 | + // or helpful developer messages if debugging is on |
|
410 | + $output .= ' |
|
411 | 411 | <div class="ee-error-dev-msg-dv"> |
412 | 412 | <p class="ee-error-dev-msg-pg"> |
413 | 413 | <strong class="ee-error-dev-msg-str">An ' |
414 | - . $ex['name'] |
|
415 | - . ' exception was thrown!</strong> <span>code: ' |
|
416 | - . $ex['code'] |
|
417 | - . '</span><br /> |
|
414 | + . $ex['name'] |
|
415 | + . ' exception was thrown!</strong> <span>code: ' |
|
416 | + . $ex['code'] |
|
417 | + . '</span><br /> |
|
418 | 418 | <span class="big-text">"' |
419 | - . trim($ex['msg']) |
|
420 | - . '"</span><br/> |
|
419 | + . trim($ex['msg']) |
|
420 | + . '"</span><br/> |
|
421 | 421 | <a id="display-ee-error-trace-' |
422 | - . self::$_error_count |
|
423 | - . $time |
|
424 | - . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' |
|
425 | - . self::$_error_count |
|
426 | - . $time |
|
427 | - . '"> |
|
422 | + . self::$_error_count |
|
423 | + . $time |
|
424 | + . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' |
|
425 | + . self::$_error_count |
|
426 | + . $time |
|
427 | + . '"> |
|
428 | 428 | ' |
429 | - . __('click to view backtrace and class/method details', 'event_espresso') |
|
430 | - . ' |
|
429 | + . __('click to view backtrace and class/method details', 'event_espresso') |
|
430 | + . ' |
|
431 | 431 | </a><br /> |
432 | 432 | <span class="small-text lt-grey-text">' |
433 | - . $ex['file'] |
|
434 | - . ' ( line no: ' |
|
435 | - . $ex['line'] |
|
436 | - . ' )</span> |
|
433 | + . $ex['file'] |
|
434 | + . ' ( line no: ' |
|
435 | + . $ex['line'] |
|
436 | + . ' )</span> |
|
437 | 437 | </p> |
438 | 438 | <div id="ee-error-trace-' |
439 | - . self::$_error_count |
|
440 | - . $time |
|
441 | - . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
439 | + . self::$_error_count |
|
440 | + . $time |
|
441 | + . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
442 | 442 | ' |
443 | - . $trace_details; |
|
444 | - if (! empty($class)) { |
|
445 | - $output .= ' |
|
443 | + . $trace_details; |
|
444 | + if (! empty($class)) { |
|
445 | + $output .= ' |
|
446 | 446 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
447 | 447 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
448 | 448 | <h3>Class Details</h3>'; |
449 | - $a = new ReflectionClass($class); |
|
450 | - $output .= ' |
|
449 | + $a = new ReflectionClass($class); |
|
450 | + $output .= ' |
|
451 | 451 | <pre>' . $a . '</pre> |
452 | 452 | </div> |
453 | 453 | </div>'; |
454 | - } |
|
455 | - $output .= ' |
|
454 | + } |
|
455 | + $output .= ' |
|
456 | 456 | </div> |
457 | 457 | </div> |
458 | 458 | <br />'; |
459 | - } |
|
460 | - $this->write_to_error_log($time, $ex); |
|
461 | - } |
|
462 | - // remove last linebreak |
|
463 | - $output = substr($output, 0, -6); |
|
464 | - if (! WP_DEBUG) { |
|
465 | - $output .= ' |
|
459 | + } |
|
460 | + $this->write_to_error_log($time, $ex); |
|
461 | + } |
|
462 | + // remove last linebreak |
|
463 | + $output = substr($output, 0, -6); |
|
464 | + if (! WP_DEBUG) { |
|
465 | + $output .= ' |
|
466 | 466 | </p>'; |
467 | - } |
|
468 | - $output .= ' |
|
467 | + } |
|
468 | + $output .= ' |
|
469 | 469 | </div>'; |
470 | - $output .= self::_print_scripts(true); |
|
471 | - if (defined('DOING_AJAX')) { |
|
472 | - echo wp_json_encode(array('error' => $output)); |
|
473 | - exit(); |
|
474 | - } |
|
475 | - echo $output; |
|
476 | - die(); |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - |
|
481 | - /** |
|
482 | - * generate string from exception trace args |
|
483 | - * |
|
484 | - * @param array $arguments |
|
485 | - * @param bool $array |
|
486 | - * @return string |
|
487 | - */ |
|
488 | - private function _convert_args_to_string($arguments = array(), $array = false) |
|
489 | - { |
|
490 | - $arg_string = ''; |
|
491 | - if (! empty($arguments)) { |
|
492 | - $args = array(); |
|
493 | - foreach ($arguments as $arg) { |
|
494 | - if (! empty($arg)) { |
|
495 | - if (is_string($arg)) { |
|
496 | - $args[] = " '" . $arg . "'"; |
|
497 | - } elseif (is_array($arg)) { |
|
498 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true); |
|
499 | - } elseif ($arg === null) { |
|
500 | - $args[] = ' NULL'; |
|
501 | - } elseif (is_bool($arg)) { |
|
502 | - $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
503 | - } elseif (is_object($arg)) { |
|
504 | - $args[] = ' OBJECT ' . get_class($arg); |
|
505 | - } elseif (is_resource($arg)) { |
|
506 | - $args[] = get_resource_type($arg); |
|
507 | - } else { |
|
508 | - $args[] = $arg; |
|
509 | - } |
|
510 | - } |
|
511 | - } |
|
512 | - $arg_string = implode(', ', $args); |
|
513 | - } |
|
514 | - if ($array) { |
|
515 | - $arg_string .= ' )'; |
|
516 | - } |
|
517 | - return $arg_string; |
|
518 | - } |
|
519 | - |
|
520 | - |
|
521 | - |
|
522 | - /** |
|
523 | - * add error message |
|
524 | - * |
|
525 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
526 | - * separate messages for user || dev |
|
527 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
528 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
529 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
530 | - * @return void |
|
531 | - */ |
|
532 | - public static function add_error($msg = null, $file = null, $func = null, $line = null) |
|
533 | - { |
|
534 | - self::_add_notice('errors', $msg, $file, $func, $line); |
|
535 | - self::$_error_count++; |
|
536 | - } |
|
537 | - |
|
538 | - |
|
539 | - |
|
540 | - /** |
|
541 | - * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just |
|
542 | - * adds an error |
|
543 | - * |
|
544 | - * @param string $msg |
|
545 | - * @param string $file |
|
546 | - * @param string $func |
|
547 | - * @param string $line |
|
548 | - * @throws EE_Error |
|
549 | - */ |
|
550 | - public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null) |
|
551 | - { |
|
552 | - if (WP_DEBUG) { |
|
553 | - throw new EE_Error($msg); |
|
554 | - } |
|
555 | - EE_Error::add_error($msg, $file, $func, $line); |
|
556 | - } |
|
557 | - |
|
558 | - |
|
559 | - |
|
560 | - /** |
|
561 | - * add success message |
|
562 | - * |
|
563 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
564 | - * separate messages for user || dev |
|
565 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
566 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
567 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
568 | - * @return void |
|
569 | - */ |
|
570 | - public static function add_success($msg = null, $file = null, $func = null, $line = null) |
|
571 | - { |
|
572 | - self::_add_notice('success', $msg, $file, $func, $line); |
|
573 | - } |
|
574 | - |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * add attention message |
|
579 | - * |
|
580 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
581 | - * separate messages for user || dev |
|
582 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
583 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
584 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
585 | - * @return void |
|
586 | - */ |
|
587 | - public static function add_attention($msg = null, $file = null, $func = null, $line = null) |
|
588 | - { |
|
589 | - self::_add_notice('attention', $msg, $file, $func, $line); |
|
590 | - } |
|
591 | - |
|
592 | - |
|
593 | - |
|
594 | - /** |
|
595 | - * add success message |
|
596 | - * |
|
597 | - * @param string $type whether the message is for a success or error notification |
|
598 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
599 | - * separate messages for user || dev |
|
600 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
601 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
602 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
603 | - * @return void |
|
604 | - */ |
|
605 | - private static function _add_notice($type = 'success', $msg = null, $file = null, $func = null, $line = null) |
|
606 | - { |
|
607 | - if (empty($msg)) { |
|
608 | - EE_Error::doing_it_wrong( |
|
609 | - 'EE_Error::add_' . $type . '()', |
|
610 | - sprintf( |
|
611 | - __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', |
|
612 | - 'event_espresso'), |
|
613 | - $type, |
|
614 | - $file, |
|
615 | - $line |
|
616 | - ), |
|
617 | - EVENT_ESPRESSO_VERSION |
|
618 | - ); |
|
619 | - } |
|
620 | - if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
621 | - EE_Error::doing_it_wrong( |
|
622 | - 'EE_Error::add_error()', |
|
623 | - __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', |
|
624 | - 'event_espresso'), |
|
625 | - EVENT_ESPRESSO_VERSION |
|
626 | - ); |
|
627 | - } |
|
628 | - // get separate user and developer messages if they exist |
|
629 | - $msg = explode('||', $msg); |
|
630 | - $user_msg = $msg[0]; |
|
631 | - $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
632 | - /** |
|
633 | - * Do an action so other code can be triggered when a notice is created |
|
634 | - * |
|
635 | - * @param string $type can be 'errors', 'attention', or 'success' |
|
636 | - * @param string $user_msg message displayed to user when WP_DEBUG is off |
|
637 | - * @param string $user_msg message displayed to user when WP_DEBUG is on |
|
638 | - * @param string $file file where error was generated |
|
639 | - * @param string $func function where error was generated |
|
640 | - * @param string $line line where error was generated |
|
641 | - */ |
|
642 | - do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line); |
|
643 | - $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
644 | - // add notice if message exists |
|
645 | - if (! empty($msg)) { |
|
646 | - // get error code |
|
647 | - $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
648 | - if (WP_DEBUG && $type === 'errors') { |
|
649 | - $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
650 | - } |
|
651 | - // add notice. Index by code if it's not blank |
|
652 | - if ($notice_code) { |
|
653 | - self::$_espresso_notices[$type][$notice_code] = $msg; |
|
654 | - } else { |
|
655 | - self::$_espresso_notices[$type][] = $msg; |
|
656 | - } |
|
657 | - add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
658 | - } |
|
659 | - } |
|
660 | - |
|
661 | - |
|
662 | - |
|
663 | - /** |
|
664 | - * in some case it may be necessary to overwrite the existing success messages |
|
665 | - * |
|
666 | - * @return void |
|
667 | - */ |
|
668 | - public static function overwrite_success() |
|
669 | - { |
|
670 | - self::$_espresso_notices['success'] = false; |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - |
|
675 | - /** |
|
676 | - * in some case it may be necessary to overwrite the existing attention messages |
|
677 | - * |
|
678 | - * @return void |
|
679 | - */ |
|
680 | - public static function overwrite_attention() |
|
681 | - { |
|
682 | - self::$_espresso_notices['attention'] = false; |
|
683 | - } |
|
684 | - |
|
685 | - |
|
686 | - |
|
687 | - /** |
|
688 | - * in some case it may be necessary to overwrite the existing error messages |
|
689 | - * |
|
690 | - * @return void |
|
691 | - */ |
|
692 | - public static function overwrite_errors() |
|
693 | - { |
|
694 | - self::$_espresso_notices['errors'] = false; |
|
695 | - } |
|
696 | - |
|
697 | - |
|
698 | - |
|
699 | - /** |
|
700 | - * reset_notices |
|
701 | - * |
|
702 | - * @return void |
|
703 | - */ |
|
704 | - public static function reset_notices() |
|
705 | - { |
|
706 | - self::$_espresso_notices['success'] = false; |
|
707 | - self::$_espresso_notices['attention'] = false; |
|
708 | - self::$_espresso_notices['errors'] = false; |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * has_errors |
|
715 | - * |
|
716 | - * @return int |
|
717 | - */ |
|
718 | - public static function has_notices() |
|
719 | - { |
|
720 | - $has_notices = 0; |
|
721 | - // check for success messages |
|
722 | - $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 |
|
723 | - : $has_notices; |
|
724 | - // check for attention messages |
|
725 | - $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 |
|
726 | - : $has_notices; |
|
727 | - // check for error messages |
|
728 | - $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 |
|
729 | - : $has_notices; |
|
730 | - return $has_notices; |
|
731 | - } |
|
732 | - |
|
733 | - |
|
734 | - |
|
735 | - /** |
|
736 | - * This simply returns non formatted error notices as they were sent into the EE_Error object. |
|
737 | - * |
|
738 | - * @since 4.9.0 |
|
739 | - * @return array |
|
740 | - */ |
|
741 | - public static function get_vanilla_notices() |
|
742 | - { |
|
743 | - return array( |
|
744 | - 'success' => isset(self::$_espresso_notices['success']) ? self::$_espresso_notices['success'] : array(), |
|
745 | - 'attention' => isset(self::$_espresso_notices['attention']) ? self::$_espresso_notices['attention'] |
|
746 | - : array(), |
|
747 | - 'errors' => isset(self::$_espresso_notices['errors']) ? self::$_espresso_notices['errors'] : array(), |
|
748 | - ); |
|
749 | - } |
|
750 | - |
|
751 | - |
|
752 | - |
|
753 | - /** |
|
754 | - * compile all error or success messages into one string |
|
755 | - * |
|
756 | - * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them |
|
757 | - * @param boolean $format_output whether or not to format the messages for display in the WP admin |
|
758 | - * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request |
|
759 | - * - ONLY do this just before redirecting |
|
760 | - * @param boolean $remove_empty whether or not to unset empty messages |
|
761 | - * @return array |
|
762 | - */ |
|
763 | - public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true) |
|
764 | - { |
|
765 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
766 | - $success_messages = ''; |
|
767 | - $attention_messages = ''; |
|
768 | - $error_messages = ''; |
|
769 | - $print_scripts = false; |
|
770 | - // either save notices to the db |
|
771 | - if ($save_to_transient) { |
|
772 | - update_option('ee_notices', self::$_espresso_notices); |
|
773 | - return array(); |
|
774 | - } |
|
775 | - // grab any notices that have been previously saved |
|
776 | - if ($notices = get_option('ee_notices', false)) { |
|
777 | - foreach ($notices as $type => $notice) { |
|
778 | - if (is_array($notice) && ! empty($notice)) { |
|
779 | - // make sure that existing notice type is an array |
|
780 | - self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) |
|
781 | - && ! empty(self::$_espresso_notices[$type]) |
|
782 | - ? self::$_espresso_notices[$type] : array(); |
|
783 | - // merge stored notices with any newly created ones |
|
784 | - self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
785 | - $print_scripts = true; |
|
786 | - } |
|
787 | - } |
|
788 | - // now clear any stored notices |
|
789 | - update_option('ee_notices', false); |
|
790 | - } |
|
791 | - // check for success messages |
|
792 | - if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
793 | - // combine messages |
|
794 | - $success_messages .= implode(self::$_espresso_notices['success'], '<br /><br />'); |
|
795 | - $print_scripts = true; |
|
796 | - } |
|
797 | - // check for attention messages |
|
798 | - if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
799 | - // combine messages |
|
800 | - $attention_messages .= implode(self::$_espresso_notices['attention'], '<br /><br />'); |
|
801 | - $print_scripts = true; |
|
802 | - } |
|
803 | - // check for error messages |
|
804 | - if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
805 | - $error_messages .= count(self::$_espresso_notices['errors']) > 1 |
|
806 | - ? __('The following errors have occurred:<br />', 'event_espresso') |
|
807 | - : __('An error has occurred:<br />', 'event_espresso'); |
|
808 | - // combine messages |
|
809 | - $error_messages .= implode(self::$_espresso_notices['errors'], '<br /><br />'); |
|
810 | - $print_scripts = true; |
|
811 | - } |
|
812 | - if ($format_output) { |
|
813 | - $notices = '<div id="espresso-notices">'; |
|
814 | - $close = is_admin() ? '' |
|
815 | - : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"></span></a>'; |
|
816 | - if ($success_messages !== '') { |
|
817 | - $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
|
818 | - $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
|
819 | - //showMessage( $success_messages ); |
|
820 | - $notices .= '<div id="' |
|
821 | - . $css_id |
|
822 | - . '" class="espresso-notices ' |
|
823 | - . $css_class |
|
824 | - . '" style="display:none;"><p>' |
|
825 | - . $success_messages |
|
826 | - . '</p>' |
|
827 | - . $close |
|
828 | - . '</div>'; |
|
829 | - } |
|
830 | - if ($attention_messages !== '') { |
|
831 | - $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
|
832 | - $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
|
833 | - //showMessage( $error_messages, TRUE ); |
|
834 | - $notices .= '<div id="' |
|
835 | - . $css_id |
|
836 | - . '" class="espresso-notices ' |
|
837 | - . $css_class |
|
838 | - . '" style="display:none;"><p>' |
|
839 | - . $attention_messages |
|
840 | - . '</p>' |
|
841 | - . $close |
|
842 | - . '</div>'; |
|
843 | - } |
|
844 | - if ($error_messages !== '') { |
|
845 | - $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
|
846 | - $css_class = is_admin() ? 'error' : 'error fade-away'; |
|
847 | - //showMessage( $error_messages, TRUE ); |
|
848 | - $notices .= '<div id="' |
|
849 | - . $css_id |
|
850 | - . '" class="espresso-notices ' |
|
851 | - . $css_class |
|
852 | - . '" style="display:none;"><p>' |
|
853 | - . $error_messages |
|
854 | - . '</p>' |
|
855 | - . $close |
|
856 | - . '</div>'; |
|
857 | - } |
|
858 | - $notices .= '</div>'; |
|
859 | - } else { |
|
860 | - $notices = array( |
|
861 | - 'success' => $success_messages, |
|
862 | - 'attention' => $attention_messages, |
|
863 | - 'errors' => $error_messages, |
|
864 | - ); |
|
865 | - if ($remove_empty) { |
|
866 | - // remove empty notices |
|
867 | - foreach ($notices as $type => $notice) { |
|
868 | - if (empty($notice)) { |
|
869 | - unset($notices[$type]); |
|
870 | - } |
|
871 | - } |
|
872 | - } |
|
873 | - } |
|
874 | - if ($print_scripts) { |
|
875 | - self::_print_scripts(); |
|
876 | - } |
|
877 | - return $notices; |
|
878 | - } |
|
879 | - |
|
880 | - |
|
881 | - |
|
882 | - /** |
|
883 | - * add_persistent_admin_notice |
|
884 | - * |
|
885 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
886 | - * @param string $pan_message the message to be stored persistently until dismissed |
|
887 | - * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
|
888 | - * @return void |
|
889 | - */ |
|
890 | - public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false) |
|
891 | - { |
|
892 | - if (! empty($pan_name) && ! empty($pan_message)) { |
|
893 | - $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
894 | - //maybe initialize persistent_admin_notices |
|
895 | - if (empty($persistent_admin_notices)) { |
|
896 | - add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
897 | - } |
|
898 | - $pan_name = sanitize_key($pan_name); |
|
899 | - if (! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
900 | - $persistent_admin_notices[$pan_name] = $pan_message; |
|
901 | - update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
902 | - } |
|
903 | - } |
|
904 | - } |
|
905 | - |
|
906 | - |
|
907 | - |
|
908 | - /** |
|
909 | - * dismiss_persistent_admin_notice |
|
910 | - * |
|
911 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed |
|
912 | - * @param bool $purge |
|
913 | - * @param bool $return_immediately |
|
914 | - * @return void |
|
915 | - */ |
|
916 | - public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return_immediately = false) |
|
917 | - { |
|
918 | - $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') |
|
919 | - ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
920 | - if (! empty($pan_name)) { |
|
921 | - $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
922 | - // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
|
923 | - if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
924 | - // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
|
925 | - if ($purge) { |
|
926 | - unset($persistent_admin_notices[$pan_name]); |
|
927 | - } else { |
|
928 | - $persistent_admin_notices[$pan_name] = null; |
|
929 | - } |
|
930 | - if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === false) { |
|
931 | - EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', |
|
932 | - 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
933 | - } |
|
934 | - } |
|
935 | - } |
|
936 | - if ($return_immediately) { |
|
937 | - return; |
|
938 | - } |
|
939 | - if (EE_Registry::instance()->REQ->ajax) { |
|
940 | - // grab any notices and concatenate into string |
|
941 | - echo wp_json_encode(array('errors' => implode('<br />', EE_Error::get_notices(false)))); |
|
942 | - exit(); |
|
943 | - } |
|
944 | - // save errors to a transient to be displayed on next request (after redirect) |
|
945 | - EE_Error::get_notices(false, true); |
|
946 | - $return_url = EE_Registry::instance()->REQ->is_set('return_url') |
|
947 | - ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
948 | - wp_safe_redirect(urldecode($return_url)); |
|
949 | - } |
|
950 | - |
|
951 | - |
|
952 | - |
|
953 | - /** |
|
954 | - * display_persistent_admin_notices |
|
955 | - * |
|
956 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
957 | - * @param string $pan_message the message to be stored persistently until dismissed |
|
958 | - * @param string $return_url URL to go back to after nag notice is dismissed |
|
959 | - * @return string |
|
960 | - */ |
|
961 | - public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') |
|
962 | - { |
|
963 | - if (! empty($pan_name) && ! empty($pan_message)) { |
|
964 | - $args = array( |
|
965 | - 'nag_notice' => $pan_name, |
|
966 | - 'return_url' => urlencode($return_url), |
|
967 | - 'ajax_url' => WP_AJAX_URL, |
|
968 | - 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', |
|
969 | - 'event_espresso'), |
|
970 | - ); |
|
971 | - wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
972 | - return ' |
|
470 | + $output .= self::_print_scripts(true); |
|
471 | + if (defined('DOING_AJAX')) { |
|
472 | + echo wp_json_encode(array('error' => $output)); |
|
473 | + exit(); |
|
474 | + } |
|
475 | + echo $output; |
|
476 | + die(); |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + |
|
481 | + /** |
|
482 | + * generate string from exception trace args |
|
483 | + * |
|
484 | + * @param array $arguments |
|
485 | + * @param bool $array |
|
486 | + * @return string |
|
487 | + */ |
|
488 | + private function _convert_args_to_string($arguments = array(), $array = false) |
|
489 | + { |
|
490 | + $arg_string = ''; |
|
491 | + if (! empty($arguments)) { |
|
492 | + $args = array(); |
|
493 | + foreach ($arguments as $arg) { |
|
494 | + if (! empty($arg)) { |
|
495 | + if (is_string($arg)) { |
|
496 | + $args[] = " '" . $arg . "'"; |
|
497 | + } elseif (is_array($arg)) { |
|
498 | + $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true); |
|
499 | + } elseif ($arg === null) { |
|
500 | + $args[] = ' NULL'; |
|
501 | + } elseif (is_bool($arg)) { |
|
502 | + $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
503 | + } elseif (is_object($arg)) { |
|
504 | + $args[] = ' OBJECT ' . get_class($arg); |
|
505 | + } elseif (is_resource($arg)) { |
|
506 | + $args[] = get_resource_type($arg); |
|
507 | + } else { |
|
508 | + $args[] = $arg; |
|
509 | + } |
|
510 | + } |
|
511 | + } |
|
512 | + $arg_string = implode(', ', $args); |
|
513 | + } |
|
514 | + if ($array) { |
|
515 | + $arg_string .= ' )'; |
|
516 | + } |
|
517 | + return $arg_string; |
|
518 | + } |
|
519 | + |
|
520 | + |
|
521 | + |
|
522 | + /** |
|
523 | + * add error message |
|
524 | + * |
|
525 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
526 | + * separate messages for user || dev |
|
527 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
528 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
529 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
530 | + * @return void |
|
531 | + */ |
|
532 | + public static function add_error($msg = null, $file = null, $func = null, $line = null) |
|
533 | + { |
|
534 | + self::_add_notice('errors', $msg, $file, $func, $line); |
|
535 | + self::$_error_count++; |
|
536 | + } |
|
537 | + |
|
538 | + |
|
539 | + |
|
540 | + /** |
|
541 | + * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just |
|
542 | + * adds an error |
|
543 | + * |
|
544 | + * @param string $msg |
|
545 | + * @param string $file |
|
546 | + * @param string $func |
|
547 | + * @param string $line |
|
548 | + * @throws EE_Error |
|
549 | + */ |
|
550 | + public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null) |
|
551 | + { |
|
552 | + if (WP_DEBUG) { |
|
553 | + throw new EE_Error($msg); |
|
554 | + } |
|
555 | + EE_Error::add_error($msg, $file, $func, $line); |
|
556 | + } |
|
557 | + |
|
558 | + |
|
559 | + |
|
560 | + /** |
|
561 | + * add success message |
|
562 | + * |
|
563 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
564 | + * separate messages for user || dev |
|
565 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
566 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
567 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
568 | + * @return void |
|
569 | + */ |
|
570 | + public static function add_success($msg = null, $file = null, $func = null, $line = null) |
|
571 | + { |
|
572 | + self::_add_notice('success', $msg, $file, $func, $line); |
|
573 | + } |
|
574 | + |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * add attention message |
|
579 | + * |
|
580 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
581 | + * separate messages for user || dev |
|
582 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
583 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
584 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
585 | + * @return void |
|
586 | + */ |
|
587 | + public static function add_attention($msg = null, $file = null, $func = null, $line = null) |
|
588 | + { |
|
589 | + self::_add_notice('attention', $msg, $file, $func, $line); |
|
590 | + } |
|
591 | + |
|
592 | + |
|
593 | + |
|
594 | + /** |
|
595 | + * add success message |
|
596 | + * |
|
597 | + * @param string $type whether the message is for a success or error notification |
|
598 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
599 | + * separate messages for user || dev |
|
600 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
601 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
602 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
603 | + * @return void |
|
604 | + */ |
|
605 | + private static function _add_notice($type = 'success', $msg = null, $file = null, $func = null, $line = null) |
|
606 | + { |
|
607 | + if (empty($msg)) { |
|
608 | + EE_Error::doing_it_wrong( |
|
609 | + 'EE_Error::add_' . $type . '()', |
|
610 | + sprintf( |
|
611 | + __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', |
|
612 | + 'event_espresso'), |
|
613 | + $type, |
|
614 | + $file, |
|
615 | + $line |
|
616 | + ), |
|
617 | + EVENT_ESPRESSO_VERSION |
|
618 | + ); |
|
619 | + } |
|
620 | + if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
621 | + EE_Error::doing_it_wrong( |
|
622 | + 'EE_Error::add_error()', |
|
623 | + __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', |
|
624 | + 'event_espresso'), |
|
625 | + EVENT_ESPRESSO_VERSION |
|
626 | + ); |
|
627 | + } |
|
628 | + // get separate user and developer messages if they exist |
|
629 | + $msg = explode('||', $msg); |
|
630 | + $user_msg = $msg[0]; |
|
631 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
632 | + /** |
|
633 | + * Do an action so other code can be triggered when a notice is created |
|
634 | + * |
|
635 | + * @param string $type can be 'errors', 'attention', or 'success' |
|
636 | + * @param string $user_msg message displayed to user when WP_DEBUG is off |
|
637 | + * @param string $user_msg message displayed to user when WP_DEBUG is on |
|
638 | + * @param string $file file where error was generated |
|
639 | + * @param string $func function where error was generated |
|
640 | + * @param string $line line where error was generated |
|
641 | + */ |
|
642 | + do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line); |
|
643 | + $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
644 | + // add notice if message exists |
|
645 | + if (! empty($msg)) { |
|
646 | + // get error code |
|
647 | + $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
648 | + if (WP_DEBUG && $type === 'errors') { |
|
649 | + $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
650 | + } |
|
651 | + // add notice. Index by code if it's not blank |
|
652 | + if ($notice_code) { |
|
653 | + self::$_espresso_notices[$type][$notice_code] = $msg; |
|
654 | + } else { |
|
655 | + self::$_espresso_notices[$type][] = $msg; |
|
656 | + } |
|
657 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
658 | + } |
|
659 | + } |
|
660 | + |
|
661 | + |
|
662 | + |
|
663 | + /** |
|
664 | + * in some case it may be necessary to overwrite the existing success messages |
|
665 | + * |
|
666 | + * @return void |
|
667 | + */ |
|
668 | + public static function overwrite_success() |
|
669 | + { |
|
670 | + self::$_espresso_notices['success'] = false; |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + |
|
675 | + /** |
|
676 | + * in some case it may be necessary to overwrite the existing attention messages |
|
677 | + * |
|
678 | + * @return void |
|
679 | + */ |
|
680 | + public static function overwrite_attention() |
|
681 | + { |
|
682 | + self::$_espresso_notices['attention'] = false; |
|
683 | + } |
|
684 | + |
|
685 | + |
|
686 | + |
|
687 | + /** |
|
688 | + * in some case it may be necessary to overwrite the existing error messages |
|
689 | + * |
|
690 | + * @return void |
|
691 | + */ |
|
692 | + public static function overwrite_errors() |
|
693 | + { |
|
694 | + self::$_espresso_notices['errors'] = false; |
|
695 | + } |
|
696 | + |
|
697 | + |
|
698 | + |
|
699 | + /** |
|
700 | + * reset_notices |
|
701 | + * |
|
702 | + * @return void |
|
703 | + */ |
|
704 | + public static function reset_notices() |
|
705 | + { |
|
706 | + self::$_espresso_notices['success'] = false; |
|
707 | + self::$_espresso_notices['attention'] = false; |
|
708 | + self::$_espresso_notices['errors'] = false; |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * has_errors |
|
715 | + * |
|
716 | + * @return int |
|
717 | + */ |
|
718 | + public static function has_notices() |
|
719 | + { |
|
720 | + $has_notices = 0; |
|
721 | + // check for success messages |
|
722 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 |
|
723 | + : $has_notices; |
|
724 | + // check for attention messages |
|
725 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 |
|
726 | + : $has_notices; |
|
727 | + // check for error messages |
|
728 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 |
|
729 | + : $has_notices; |
|
730 | + return $has_notices; |
|
731 | + } |
|
732 | + |
|
733 | + |
|
734 | + |
|
735 | + /** |
|
736 | + * This simply returns non formatted error notices as they were sent into the EE_Error object. |
|
737 | + * |
|
738 | + * @since 4.9.0 |
|
739 | + * @return array |
|
740 | + */ |
|
741 | + public static function get_vanilla_notices() |
|
742 | + { |
|
743 | + return array( |
|
744 | + 'success' => isset(self::$_espresso_notices['success']) ? self::$_espresso_notices['success'] : array(), |
|
745 | + 'attention' => isset(self::$_espresso_notices['attention']) ? self::$_espresso_notices['attention'] |
|
746 | + : array(), |
|
747 | + 'errors' => isset(self::$_espresso_notices['errors']) ? self::$_espresso_notices['errors'] : array(), |
|
748 | + ); |
|
749 | + } |
|
750 | + |
|
751 | + |
|
752 | + |
|
753 | + /** |
|
754 | + * compile all error or success messages into one string |
|
755 | + * |
|
756 | + * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them |
|
757 | + * @param boolean $format_output whether or not to format the messages for display in the WP admin |
|
758 | + * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request |
|
759 | + * - ONLY do this just before redirecting |
|
760 | + * @param boolean $remove_empty whether or not to unset empty messages |
|
761 | + * @return array |
|
762 | + */ |
|
763 | + public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true) |
|
764 | + { |
|
765 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
766 | + $success_messages = ''; |
|
767 | + $attention_messages = ''; |
|
768 | + $error_messages = ''; |
|
769 | + $print_scripts = false; |
|
770 | + // either save notices to the db |
|
771 | + if ($save_to_transient) { |
|
772 | + update_option('ee_notices', self::$_espresso_notices); |
|
773 | + return array(); |
|
774 | + } |
|
775 | + // grab any notices that have been previously saved |
|
776 | + if ($notices = get_option('ee_notices', false)) { |
|
777 | + foreach ($notices as $type => $notice) { |
|
778 | + if (is_array($notice) && ! empty($notice)) { |
|
779 | + // make sure that existing notice type is an array |
|
780 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) |
|
781 | + && ! empty(self::$_espresso_notices[$type]) |
|
782 | + ? self::$_espresso_notices[$type] : array(); |
|
783 | + // merge stored notices with any newly created ones |
|
784 | + self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
785 | + $print_scripts = true; |
|
786 | + } |
|
787 | + } |
|
788 | + // now clear any stored notices |
|
789 | + update_option('ee_notices', false); |
|
790 | + } |
|
791 | + // check for success messages |
|
792 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
793 | + // combine messages |
|
794 | + $success_messages .= implode(self::$_espresso_notices['success'], '<br /><br />'); |
|
795 | + $print_scripts = true; |
|
796 | + } |
|
797 | + // check for attention messages |
|
798 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
799 | + // combine messages |
|
800 | + $attention_messages .= implode(self::$_espresso_notices['attention'], '<br /><br />'); |
|
801 | + $print_scripts = true; |
|
802 | + } |
|
803 | + // check for error messages |
|
804 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
805 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 |
|
806 | + ? __('The following errors have occurred:<br />', 'event_espresso') |
|
807 | + : __('An error has occurred:<br />', 'event_espresso'); |
|
808 | + // combine messages |
|
809 | + $error_messages .= implode(self::$_espresso_notices['errors'], '<br /><br />'); |
|
810 | + $print_scripts = true; |
|
811 | + } |
|
812 | + if ($format_output) { |
|
813 | + $notices = '<div id="espresso-notices">'; |
|
814 | + $close = is_admin() ? '' |
|
815 | + : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"></span></a>'; |
|
816 | + if ($success_messages !== '') { |
|
817 | + $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
|
818 | + $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
|
819 | + //showMessage( $success_messages ); |
|
820 | + $notices .= '<div id="' |
|
821 | + . $css_id |
|
822 | + . '" class="espresso-notices ' |
|
823 | + . $css_class |
|
824 | + . '" style="display:none;"><p>' |
|
825 | + . $success_messages |
|
826 | + . '</p>' |
|
827 | + . $close |
|
828 | + . '</div>'; |
|
829 | + } |
|
830 | + if ($attention_messages !== '') { |
|
831 | + $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
|
832 | + $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
|
833 | + //showMessage( $error_messages, TRUE ); |
|
834 | + $notices .= '<div id="' |
|
835 | + . $css_id |
|
836 | + . '" class="espresso-notices ' |
|
837 | + . $css_class |
|
838 | + . '" style="display:none;"><p>' |
|
839 | + . $attention_messages |
|
840 | + . '</p>' |
|
841 | + . $close |
|
842 | + . '</div>'; |
|
843 | + } |
|
844 | + if ($error_messages !== '') { |
|
845 | + $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
|
846 | + $css_class = is_admin() ? 'error' : 'error fade-away'; |
|
847 | + //showMessage( $error_messages, TRUE ); |
|
848 | + $notices .= '<div id="' |
|
849 | + . $css_id |
|
850 | + . '" class="espresso-notices ' |
|
851 | + . $css_class |
|
852 | + . '" style="display:none;"><p>' |
|
853 | + . $error_messages |
|
854 | + . '</p>' |
|
855 | + . $close |
|
856 | + . '</div>'; |
|
857 | + } |
|
858 | + $notices .= '</div>'; |
|
859 | + } else { |
|
860 | + $notices = array( |
|
861 | + 'success' => $success_messages, |
|
862 | + 'attention' => $attention_messages, |
|
863 | + 'errors' => $error_messages, |
|
864 | + ); |
|
865 | + if ($remove_empty) { |
|
866 | + // remove empty notices |
|
867 | + foreach ($notices as $type => $notice) { |
|
868 | + if (empty($notice)) { |
|
869 | + unset($notices[$type]); |
|
870 | + } |
|
871 | + } |
|
872 | + } |
|
873 | + } |
|
874 | + if ($print_scripts) { |
|
875 | + self::_print_scripts(); |
|
876 | + } |
|
877 | + return $notices; |
|
878 | + } |
|
879 | + |
|
880 | + |
|
881 | + |
|
882 | + /** |
|
883 | + * add_persistent_admin_notice |
|
884 | + * |
|
885 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
886 | + * @param string $pan_message the message to be stored persistently until dismissed |
|
887 | + * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
|
888 | + * @return void |
|
889 | + */ |
|
890 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false) |
|
891 | + { |
|
892 | + if (! empty($pan_name) && ! empty($pan_message)) { |
|
893 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
894 | + //maybe initialize persistent_admin_notices |
|
895 | + if (empty($persistent_admin_notices)) { |
|
896 | + add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
897 | + } |
|
898 | + $pan_name = sanitize_key($pan_name); |
|
899 | + if (! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
900 | + $persistent_admin_notices[$pan_name] = $pan_message; |
|
901 | + update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
902 | + } |
|
903 | + } |
|
904 | + } |
|
905 | + |
|
906 | + |
|
907 | + |
|
908 | + /** |
|
909 | + * dismiss_persistent_admin_notice |
|
910 | + * |
|
911 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed |
|
912 | + * @param bool $purge |
|
913 | + * @param bool $return_immediately |
|
914 | + * @return void |
|
915 | + */ |
|
916 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return_immediately = false) |
|
917 | + { |
|
918 | + $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') |
|
919 | + ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
920 | + if (! empty($pan_name)) { |
|
921 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
922 | + // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
|
923 | + if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
924 | + // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
|
925 | + if ($purge) { |
|
926 | + unset($persistent_admin_notices[$pan_name]); |
|
927 | + } else { |
|
928 | + $persistent_admin_notices[$pan_name] = null; |
|
929 | + } |
|
930 | + if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === false) { |
|
931 | + EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', |
|
932 | + 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
933 | + } |
|
934 | + } |
|
935 | + } |
|
936 | + if ($return_immediately) { |
|
937 | + return; |
|
938 | + } |
|
939 | + if (EE_Registry::instance()->REQ->ajax) { |
|
940 | + // grab any notices and concatenate into string |
|
941 | + echo wp_json_encode(array('errors' => implode('<br />', EE_Error::get_notices(false)))); |
|
942 | + exit(); |
|
943 | + } |
|
944 | + // save errors to a transient to be displayed on next request (after redirect) |
|
945 | + EE_Error::get_notices(false, true); |
|
946 | + $return_url = EE_Registry::instance()->REQ->is_set('return_url') |
|
947 | + ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
948 | + wp_safe_redirect(urldecode($return_url)); |
|
949 | + } |
|
950 | + |
|
951 | + |
|
952 | + |
|
953 | + /** |
|
954 | + * display_persistent_admin_notices |
|
955 | + * |
|
956 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
957 | + * @param string $pan_message the message to be stored persistently until dismissed |
|
958 | + * @param string $return_url URL to go back to after nag notice is dismissed |
|
959 | + * @return string |
|
960 | + */ |
|
961 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') |
|
962 | + { |
|
963 | + if (! empty($pan_name) && ! empty($pan_message)) { |
|
964 | + $args = array( |
|
965 | + 'nag_notice' => $pan_name, |
|
966 | + 'return_url' => urlencode($return_url), |
|
967 | + 'ajax_url' => WP_AJAX_URL, |
|
968 | + 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', |
|
969 | + 'event_espresso'), |
|
970 | + ); |
|
971 | + wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
972 | + return ' |
|
973 | 973 | <div id="' |
974 | - . $pan_name |
|
975 | - . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
974 | + . $pan_name |
|
975 | + . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
976 | 976 | <p>' |
977 | - . $pan_message |
|
978 | - . '</p> |
|
977 | + . $pan_message |
|
978 | + . '</p> |
|
979 | 979 | <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' |
980 | - . $pan_name |
|
981 | - . '"> |
|
980 | + . $pan_name |
|
981 | + . '"> |
|
982 | 982 | <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>' |
983 | - . __('Dismiss', 'event_espresso') |
|
984 | - . ' |
|
983 | + . __('Dismiss', 'event_espresso') |
|
984 | + . ' |
|
985 | 985 | </a> |
986 | 986 | <div style="clear:both;"></div> |
987 | 987 | </div>'; |
988 | - } |
|
989 | - return ''; |
|
990 | - } |
|
991 | - |
|
992 | - |
|
993 | - |
|
994 | - /** |
|
995 | - * get_persistent_admin_notices |
|
996 | - * |
|
997 | - * @param string $return_url |
|
998 | - * @return string |
|
999 | - */ |
|
1000 | - public static function get_persistent_admin_notices($return_url = '') |
|
1001 | - { |
|
1002 | - $notices = ''; |
|
1003 | - // check for persistent admin notices |
|
1004 | - //filter the list though so plugins can notify the admin in a different way if they want |
|
1005 | - $persistent_admin_notices = apply_filters( |
|
1006 | - 'FHEE__EE_Error__get_persistent_admin_notices', |
|
1007 | - get_option('ee_pers_admin_notices', false), |
|
1008 | - 'ee_pers_admin_notices', |
|
1009 | - $return_url |
|
1010 | - ); |
|
1011 | - if ($persistent_admin_notices) { |
|
1012 | - // load scripts |
|
1013 | - wp_register_script( |
|
1014 | - 'espresso_core', |
|
1015 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1016 | - array('jquery'), |
|
1017 | - EVENT_ESPRESSO_VERSION, |
|
1018 | - true |
|
1019 | - ); |
|
1020 | - wp_register_script( |
|
1021 | - 'ee_error_js', |
|
1022 | - EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1023 | - array('espresso_core'), |
|
1024 | - EVENT_ESPRESSO_VERSION, |
|
1025 | - true |
|
1026 | - ); |
|
1027 | - wp_enqueue_script('ee_error_js'); |
|
1028 | - // and display notices |
|
1029 | - foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
1030 | - $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
1031 | - } |
|
1032 | - } |
|
1033 | - return $notices; |
|
1034 | - } |
|
1035 | - |
|
1036 | - |
|
1037 | - |
|
1038 | - /** |
|
1039 | - * _print_scripts |
|
1040 | - * |
|
1041 | - * @param bool $force_print |
|
1042 | - * @return string |
|
1043 | - */ |
|
1044 | - private static function _print_scripts($force_print = false) |
|
1045 | - { |
|
1046 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
1047 | - if (wp_script_is('ee_error_js', 'enqueued')) { |
|
1048 | - return ''; |
|
1049 | - } |
|
1050 | - if (wp_script_is('ee_error_js', 'registered')) { |
|
1051 | - wp_enqueue_style('espresso_default'); |
|
1052 | - wp_enqueue_style('espresso_custom_css'); |
|
1053 | - wp_enqueue_script('ee_error_js'); |
|
1054 | - wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
1055 | - } |
|
1056 | - } else { |
|
1057 | - return ' |
|
988 | + } |
|
989 | + return ''; |
|
990 | + } |
|
991 | + |
|
992 | + |
|
993 | + |
|
994 | + /** |
|
995 | + * get_persistent_admin_notices |
|
996 | + * |
|
997 | + * @param string $return_url |
|
998 | + * @return string |
|
999 | + */ |
|
1000 | + public static function get_persistent_admin_notices($return_url = '') |
|
1001 | + { |
|
1002 | + $notices = ''; |
|
1003 | + // check for persistent admin notices |
|
1004 | + //filter the list though so plugins can notify the admin in a different way if they want |
|
1005 | + $persistent_admin_notices = apply_filters( |
|
1006 | + 'FHEE__EE_Error__get_persistent_admin_notices', |
|
1007 | + get_option('ee_pers_admin_notices', false), |
|
1008 | + 'ee_pers_admin_notices', |
|
1009 | + $return_url |
|
1010 | + ); |
|
1011 | + if ($persistent_admin_notices) { |
|
1012 | + // load scripts |
|
1013 | + wp_register_script( |
|
1014 | + 'espresso_core', |
|
1015 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1016 | + array('jquery'), |
|
1017 | + EVENT_ESPRESSO_VERSION, |
|
1018 | + true |
|
1019 | + ); |
|
1020 | + wp_register_script( |
|
1021 | + 'ee_error_js', |
|
1022 | + EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1023 | + array('espresso_core'), |
|
1024 | + EVENT_ESPRESSO_VERSION, |
|
1025 | + true |
|
1026 | + ); |
|
1027 | + wp_enqueue_script('ee_error_js'); |
|
1028 | + // and display notices |
|
1029 | + foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
1030 | + $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
1031 | + } |
|
1032 | + } |
|
1033 | + return $notices; |
|
1034 | + } |
|
1035 | + |
|
1036 | + |
|
1037 | + |
|
1038 | + /** |
|
1039 | + * _print_scripts |
|
1040 | + * |
|
1041 | + * @param bool $force_print |
|
1042 | + * @return string |
|
1043 | + */ |
|
1044 | + private static function _print_scripts($force_print = false) |
|
1045 | + { |
|
1046 | + if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
1047 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
1048 | + return ''; |
|
1049 | + } |
|
1050 | + if (wp_script_is('ee_error_js', 'registered')) { |
|
1051 | + wp_enqueue_style('espresso_default'); |
|
1052 | + wp_enqueue_style('espresso_custom_css'); |
|
1053 | + wp_enqueue_script('ee_error_js'); |
|
1054 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
1055 | + } |
|
1056 | + } else { |
|
1057 | + return ' |
|
1058 | 1058 | <script> |
1059 | 1059 | /* <![CDATA[ */ |
1060 | 1060 | var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
@@ -1064,143 +1064,143 @@ discard block |
||
1064 | 1064 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
1065 | 1065 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
1066 | 1066 | '; |
1067 | - } |
|
1068 | - return ''; |
|
1069 | - } |
|
1070 | - |
|
1071 | - |
|
1072 | - |
|
1073 | - /** |
|
1074 | - * enqueue_error_scripts |
|
1075 | - * |
|
1076 | - * @return void |
|
1077 | - */ |
|
1078 | - public static function enqueue_error_scripts() |
|
1079 | - { |
|
1080 | - self::_print_scripts(); |
|
1081 | - } |
|
1082 | - |
|
1083 | - |
|
1084 | - |
|
1085 | - /** |
|
1086 | - * create error code from filepath, function name, |
|
1087 | - * and line number where exception or error was thrown |
|
1088 | - * |
|
1089 | - * @param string $file |
|
1090 | - * @param string $func |
|
1091 | - * @param string $line |
|
1092 | - * @return string |
|
1093 | - */ |
|
1094 | - public static function generate_error_code($file = '', $func = '', $line = '') |
|
1095 | - { |
|
1096 | - $file = explode('.', basename($file)); |
|
1097 | - $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1098 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
1099 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
1100 | - return $error_code; |
|
1101 | - } |
|
1102 | - |
|
1103 | - |
|
1104 | - |
|
1105 | - /** |
|
1106 | - * write exception details to log file |
|
1107 | - * |
|
1108 | - * @param int $time |
|
1109 | - * @param array $ex |
|
1110 | - * @param bool $clear |
|
1111 | - * @return void |
|
1112 | - */ |
|
1113 | - public function write_to_error_log($time = 0, $ex = array(), $clear = false) |
|
1114 | - { |
|
1115 | - if (empty($ex)) { |
|
1116 | - return; |
|
1117 | - } |
|
1118 | - if (! $time) { |
|
1119 | - $time = time(); |
|
1120 | - } |
|
1121 | - $exception_log = '----------------------------------------------------------------------------------------' |
|
1122 | - . PHP_EOL; |
|
1123 | - $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; |
|
1124 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1125 | - $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL; |
|
1126 | - $exception_log .= 'File: ' . $ex['file'] . PHP_EOL; |
|
1127 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1128 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1129 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
1130 | - $exception_log .= '----------------------------------------------------------------------------------------' |
|
1131 | - . PHP_EOL; |
|
1132 | - try { |
|
1133 | - EEH_File::ensure_file_exists_and_is_writable( |
|
1134 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file |
|
1135 | - ); |
|
1136 | - EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs'); |
|
1137 | - if (! $clear) { |
|
1138 | - //get existing log file and append new log info |
|
1139 | - $exception_log = EEH_File::get_file_contents( |
|
1140 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file |
|
1141 | - ) . $exception_log; |
|
1142 | - } |
|
1143 | - EEH_File::write_to_file( |
|
1144 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, |
|
1145 | - $exception_log |
|
1146 | - ); |
|
1147 | - } catch (EE_Error $e) { |
|
1148 | - EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', |
|
1149 | - 'event_espresso'), $e->getMessage())); |
|
1150 | - return; |
|
1151 | - } |
|
1152 | - } |
|
1153 | - |
|
1154 | - |
|
1155 | - |
|
1156 | - /** |
|
1157 | - * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method. |
|
1158 | - * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown, |
|
1159 | - * but the code execution is done in a manner that could lead to unexpected results |
|
1160 | - * (i.e. running to early, or too late in WP or EE loading process). |
|
1161 | - * A good test for knowing whether to use this method is: |
|
1162 | - * 1. Is there going to be a PHP error if something isn't setup/used correctly? |
|
1163 | - * Yes -> use EE_Error::add_error() or throw new EE_Error() |
|
1164 | - * 2. If this is loaded before something else, it won't break anything, |
|
1165 | - * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong() |
|
1166 | - * |
|
1167 | - * @uses constant WP_DEBUG test if wp_debug is on or not |
|
1168 | - * @param string $function The function that was called |
|
1169 | - * @param string $message A message explaining what has been done incorrectly |
|
1170 | - * @param string $version The version of Event Espresso where the error was added |
|
1171 | - * @param string $applies_when a version string for when you want the doing_it_wrong notice to begin appearing |
|
1172 | - * for a deprecated function. This allows deprecation to occur during one version, |
|
1173 | - * but not have any notices appear until a later version. This allows developers |
|
1174 | - * extra time to update their code before notices appear. |
|
1175 | - * @param int $error_type |
|
1176 | - */ |
|
1177 | - public static function doing_it_wrong( |
|
1178 | - $function, |
|
1179 | - $message, |
|
1180 | - $version, |
|
1181 | - $applies_when = '', |
|
1182 | - $error_type = null |
|
1183 | - ) { |
|
1184 | - if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1185 | - EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type); |
|
1186 | - } |
|
1187 | - } |
|
1188 | - |
|
1189 | - |
|
1190 | - |
|
1191 | - /** |
|
1192 | - * Like get_notices, but returns an array of all the notices of the given type. |
|
1193 | - * |
|
1194 | - * @return array { |
|
1195 | - * @type array $success all the success messages |
|
1196 | - * @type array $errors all the error messages |
|
1197 | - * @type array $attention all the attention messages |
|
1198 | - * } |
|
1199 | - */ |
|
1200 | - public static function get_raw_notices() |
|
1201 | - { |
|
1202 | - return self::$_espresso_notices; |
|
1203 | - } |
|
1067 | + } |
|
1068 | + return ''; |
|
1069 | + } |
|
1070 | + |
|
1071 | + |
|
1072 | + |
|
1073 | + /** |
|
1074 | + * enqueue_error_scripts |
|
1075 | + * |
|
1076 | + * @return void |
|
1077 | + */ |
|
1078 | + public static function enqueue_error_scripts() |
|
1079 | + { |
|
1080 | + self::_print_scripts(); |
|
1081 | + } |
|
1082 | + |
|
1083 | + |
|
1084 | + |
|
1085 | + /** |
|
1086 | + * create error code from filepath, function name, |
|
1087 | + * and line number where exception or error was thrown |
|
1088 | + * |
|
1089 | + * @param string $file |
|
1090 | + * @param string $func |
|
1091 | + * @param string $line |
|
1092 | + * @return string |
|
1093 | + */ |
|
1094 | + public static function generate_error_code($file = '', $func = '', $line = '') |
|
1095 | + { |
|
1096 | + $file = explode('.', basename($file)); |
|
1097 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1098 | + $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
1099 | + $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
1100 | + return $error_code; |
|
1101 | + } |
|
1102 | + |
|
1103 | + |
|
1104 | + |
|
1105 | + /** |
|
1106 | + * write exception details to log file |
|
1107 | + * |
|
1108 | + * @param int $time |
|
1109 | + * @param array $ex |
|
1110 | + * @param bool $clear |
|
1111 | + * @return void |
|
1112 | + */ |
|
1113 | + public function write_to_error_log($time = 0, $ex = array(), $clear = false) |
|
1114 | + { |
|
1115 | + if (empty($ex)) { |
|
1116 | + return; |
|
1117 | + } |
|
1118 | + if (! $time) { |
|
1119 | + $time = time(); |
|
1120 | + } |
|
1121 | + $exception_log = '----------------------------------------------------------------------------------------' |
|
1122 | + . PHP_EOL; |
|
1123 | + $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; |
|
1124 | + $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1125 | + $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL; |
|
1126 | + $exception_log .= 'File: ' . $ex['file'] . PHP_EOL; |
|
1127 | + $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1128 | + $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1129 | + $exception_log .= $ex['string'] . PHP_EOL; |
|
1130 | + $exception_log .= '----------------------------------------------------------------------------------------' |
|
1131 | + . PHP_EOL; |
|
1132 | + try { |
|
1133 | + EEH_File::ensure_file_exists_and_is_writable( |
|
1134 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file |
|
1135 | + ); |
|
1136 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs'); |
|
1137 | + if (! $clear) { |
|
1138 | + //get existing log file and append new log info |
|
1139 | + $exception_log = EEH_File::get_file_contents( |
|
1140 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file |
|
1141 | + ) . $exception_log; |
|
1142 | + } |
|
1143 | + EEH_File::write_to_file( |
|
1144 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, |
|
1145 | + $exception_log |
|
1146 | + ); |
|
1147 | + } catch (EE_Error $e) { |
|
1148 | + EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', |
|
1149 | + 'event_espresso'), $e->getMessage())); |
|
1150 | + return; |
|
1151 | + } |
|
1152 | + } |
|
1153 | + |
|
1154 | + |
|
1155 | + |
|
1156 | + /** |
|
1157 | + * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method. |
|
1158 | + * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown, |
|
1159 | + * but the code execution is done in a manner that could lead to unexpected results |
|
1160 | + * (i.e. running to early, or too late in WP or EE loading process). |
|
1161 | + * A good test for knowing whether to use this method is: |
|
1162 | + * 1. Is there going to be a PHP error if something isn't setup/used correctly? |
|
1163 | + * Yes -> use EE_Error::add_error() or throw new EE_Error() |
|
1164 | + * 2. If this is loaded before something else, it won't break anything, |
|
1165 | + * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong() |
|
1166 | + * |
|
1167 | + * @uses constant WP_DEBUG test if wp_debug is on or not |
|
1168 | + * @param string $function The function that was called |
|
1169 | + * @param string $message A message explaining what has been done incorrectly |
|
1170 | + * @param string $version The version of Event Espresso where the error was added |
|
1171 | + * @param string $applies_when a version string for when you want the doing_it_wrong notice to begin appearing |
|
1172 | + * for a deprecated function. This allows deprecation to occur during one version, |
|
1173 | + * but not have any notices appear until a later version. This allows developers |
|
1174 | + * extra time to update their code before notices appear. |
|
1175 | + * @param int $error_type |
|
1176 | + */ |
|
1177 | + public static function doing_it_wrong( |
|
1178 | + $function, |
|
1179 | + $message, |
|
1180 | + $version, |
|
1181 | + $applies_when = '', |
|
1182 | + $error_type = null |
|
1183 | + ) { |
|
1184 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1185 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type); |
|
1186 | + } |
|
1187 | + } |
|
1188 | + |
|
1189 | + |
|
1190 | + |
|
1191 | + /** |
|
1192 | + * Like get_notices, but returns an array of all the notices of the given type. |
|
1193 | + * |
|
1194 | + * @return array { |
|
1195 | + * @type array $success all the success messages |
|
1196 | + * @type array $errors all the error messages |
|
1197 | + * @type array $attention all the attention messages |
|
1198 | + * } |
|
1199 | + */ |
|
1200 | + public static function get_raw_notices() |
|
1201 | + { |
|
1202 | + return self::$_espresso_notices; |
|
1203 | + } |
|
1204 | 1204 | |
1205 | 1205 | |
1206 | 1206 | |
@@ -1216,27 +1216,27 @@ discard block |
||
1216 | 1216 | */ |
1217 | 1217 | function espresso_error_enqueue_scripts() |
1218 | 1218 | { |
1219 | - // js for error handling |
|
1220 | - wp_register_script( |
|
1221 | - 'espresso_core', |
|
1222 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1223 | - array('jquery'), |
|
1224 | - EVENT_ESPRESSO_VERSION, |
|
1225 | - false |
|
1226 | - ); |
|
1227 | - wp_register_script( |
|
1228 | - 'ee_error_js', |
|
1229 | - EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1230 | - array('espresso_core'), |
|
1231 | - EVENT_ESPRESSO_VERSION, |
|
1232 | - false |
|
1233 | - ); |
|
1219 | + // js for error handling |
|
1220 | + wp_register_script( |
|
1221 | + 'espresso_core', |
|
1222 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1223 | + array('jquery'), |
|
1224 | + EVENT_ESPRESSO_VERSION, |
|
1225 | + false |
|
1226 | + ); |
|
1227 | + wp_register_script( |
|
1228 | + 'ee_error_js', |
|
1229 | + EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1230 | + array('espresso_core'), |
|
1231 | + EVENT_ESPRESSO_VERSION, |
|
1232 | + false |
|
1233 | + ); |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | if (is_admin()) { |
1237 | - add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1237 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1238 | 1238 | } else { |
1239 | - add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1239 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | } |
6 | 6 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @deprecated in 4.9.40 because the currency payment method table has been deprecated |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage{ |
|
17 | +class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage { |
|
18 | 18 | protected $_currency_table_name; |
19 | 19 | protected $_currency_payment_method_table_name; |
20 | 20 | protected $_payment_method_table_name; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | ); |
91 | 91 | public function __construct() { |
92 | 92 | global $wpdb; |
93 | - $this->_pretty_name = __( 'Payment Method Currencies', 'event_espresso' ); |
|
93 | + $this->_pretty_name = __('Payment Method Currencies', 'event_espresso'); |
|
94 | 94 | $this->_payment_method_table_name = $wpdb->prefix.'esp_payment_method'; |
95 | 95 | $this->_currency_payment_method_table_name = $wpdb->prefix.'esp_currency_payment_method'; |
96 | 96 | $this->_currency_table_name = $wpdb->prefix.'esp_currency'; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | protected function _count_records_to_migrate() { |
101 | 101 | $count = 0; |
102 | - foreach($this->_gateway_currencies as $currencies){ |
|
103 | - if( $currencies == 'all'){ |
|
102 | + foreach ($this->_gateway_currencies as $currencies) { |
|
103 | + if ($currencies == 'all') { |
|
104 | 104 | $currencies = $this->_get_all_currencies(); |
105 | 105 | } |
106 | 106 | $count += count($currencies); |
@@ -110,20 +110,20 @@ discard block |
||
110 | 110 | |
111 | 111 | |
112 | 112 | |
113 | - protected function _migration_step( $num_items_to_migrate = 50 ) { |
|
113 | + protected function _migration_step($num_items_to_migrate = 50) { |
|
114 | 114 | $items_actually_migrated = 0; |
115 | 115 | $relations_to_add_this_step = $this->_gather_relations_to_add($num_items_to_migrate); |
116 | - foreach($relations_to_add_this_step as $pm_slug => $currencies){ |
|
116 | + foreach ($relations_to_add_this_step as $pm_slug => $currencies) { |
|
117 | 117 | |
118 | - $id = $this->get_migration_script()->get_mapping_new_pk( 'EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name ); |
|
119 | - foreach( $currencies as $currency ){ |
|
120 | - if( $id ){ |
|
121 | - $this->_add_currency_relations( $id, $currency ); |
|
118 | + $id = $this->get_migration_script()->get_mapping_new_pk('EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name); |
|
119 | + foreach ($currencies as $currency) { |
|
120 | + if ($id) { |
|
121 | + $this->_add_currency_relations($id, $currency); |
|
122 | 122 | } |
123 | 123 | $items_actually_migrated++; |
124 | 124 | } |
125 | 125 | } |
126 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
126 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
127 | 127 | $this->set_completed(); |
128 | 128 | } |
129 | 129 | return $items_actually_migrated; |
@@ -133,14 +133,14 @@ discard block |
||
133 | 133 | $relations_to_add_this_step = array(); |
134 | 134 | $migrate_up_to_count = $this->count_records_migrated() + $num_items_to_migrate; |
135 | 135 | $iterator = 0; |
136 | - foreach($this->_gateway_currencies as $pm_slug => $currencies){ |
|
137 | - if( $currencies == 'all' ){ |
|
136 | + foreach ($this->_gateway_currencies as $pm_slug => $currencies) { |
|
137 | + if ($currencies == 'all') { |
|
138 | 138 | $currencies = $this->_get_all_currencies(); |
139 | 139 | } |
140 | - foreach($currencies as $currency_code){ |
|
141 | - if( $this->count_records_migrated() <= $iterator && |
|
142 | - $iterator < $migrate_up_to_count ){ |
|
143 | - $relations_to_add_this_step[ $pm_slug ] [] = $currency_code; |
|
140 | + foreach ($currencies as $currency_code) { |
|
141 | + if ($this->count_records_migrated() <= $iterator && |
|
142 | + $iterator < $migrate_up_to_count) { |
|
143 | + $relations_to_add_this_step[$pm_slug] [] = $currency_code; |
|
144 | 144 | } |
145 | 145 | $iterator++; |
146 | 146 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * Gets all the currency codes in the database |
152 | 152 | * @return array |
153 | 153 | */ |
154 | - private function _get_all_currencies(){ |
|
154 | + private function _get_all_currencies() { |
|
155 | 155 | global $wpdb; |
156 | 156 | $currencies = $wpdb->get_col("SELECT CUR_code FROM {$this->_currency_table_name}"); |
157 | 157 | return $currencies; |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * @param int $id |
163 | 163 | * @param string $gateway_slug |
164 | 164 | */ |
165 | - private function _add_currency_relations($pm_id,$currency_code){ |
|
165 | + private function _add_currency_relations($pm_id, $currency_code) { |
|
166 | 166 | global $wpdb; |
167 | 167 | $cur_pm_relation = array( |
168 | 168 | 'CUR_code'=>$currency_code, |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | $success = $wpdb->insert($this->_currency_payment_method_table_name, |
172 | 172 | $cur_pm_relation, |
173 | 173 | array( |
174 | - '%s',//CUR_code |
|
175 | - '%d',//PMD_ID |
|
174 | + '%s', //CUR_code |
|
175 | + '%d', //PMD_ID |
|
176 | 176 | )); |
177 | - if( ! $success ){ |
|
178 | - $this->add_error( sprintf( __( 'Could not add currency relation %s because %s', "event_espresso" ), wp_json_encode( $cur_pm_relation ), $wpdb->last_error ) ); |
|
177 | + if ( ! $success) { |
|
178 | + $this->add_error(sprintf(__('Could not add currency relation %s because %s', "event_espresso"), wp_json_encode($cur_pm_relation), $wpdb->last_error)); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | $stages = glob(EE_CORE . 'data_migration_scripts/4_6_0_stages/*'); |
15 | 15 | $class_to_filepath = array(); |
16 | 16 | foreach ($stages as $filepath) { |
17 | - $matches = array(); |
|
18 | - preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
19 | - $class_to_filepath[$matches[1]] = $filepath; |
|
17 | + $matches = array(); |
|
18 | + preg_match('~4_6_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
19 | + $class_to_filepath[$matches[1]] = $filepath; |
|
20 | 20 | } |
21 | 21 | //give addons a chance to autoload their stages too |
22 | 22 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_6_0__autoloaded_stages', $class_to_filepath); |
@@ -35,69 +35,69 @@ discard block |
||
35 | 35 | class EE_DMS_Core_4_6_0 extends EE_Data_Migration_Script_Base |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * return EE_DMS_Core_4_6_0 |
|
40 | - * |
|
41 | - * @param TableManager $table_manager |
|
42 | - * @param TableAnalysis $table_analysis |
|
43 | - */ |
|
44 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
45 | - { |
|
46 | - $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
47 | - $this->_priority = 10; |
|
48 | - $this->_migration_stages = array( |
|
49 | - new EE_DMS_4_6_0_gateways(), |
|
50 | - new EE_DMS_4_6_0_question_types(), |
|
51 | - new EE_DMS_4_6_0_country_system_question(), |
|
52 | - new EE_DMS_4_6_0_state_system_question(), |
|
53 | - new EE_DMS_4_6_0_billing_info(), |
|
54 | - new EE_DMS_4_6_0_transactions(), |
|
55 | - new EE_DMS_4_6_0_payments(), |
|
56 | - new EE_DMS_4_6_0_invoice_settings(), |
|
57 | - ); |
|
58 | - parent::__construct($table_manager, $table_analysis); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * @param array $version_array |
|
65 | - * @return bool |
|
66 | - */ |
|
67 | - public function can_migrate_from_version($version_array) |
|
68 | - { |
|
69 | - $version_string = $version_array['Core']; |
|
70 | - if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) { |
|
38 | + /** |
|
39 | + * return EE_DMS_Core_4_6_0 |
|
40 | + * |
|
41 | + * @param TableManager $table_manager |
|
42 | + * @param TableAnalysis $table_analysis |
|
43 | + */ |
|
44 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
45 | + { |
|
46 | + $this->_pretty_name = __("Data Update to Event Espresso 4.6.0", "event_espresso"); |
|
47 | + $this->_priority = 10; |
|
48 | + $this->_migration_stages = array( |
|
49 | + new EE_DMS_4_6_0_gateways(), |
|
50 | + new EE_DMS_4_6_0_question_types(), |
|
51 | + new EE_DMS_4_6_0_country_system_question(), |
|
52 | + new EE_DMS_4_6_0_state_system_question(), |
|
53 | + new EE_DMS_4_6_0_billing_info(), |
|
54 | + new EE_DMS_4_6_0_transactions(), |
|
55 | + new EE_DMS_4_6_0_payments(), |
|
56 | + new EE_DMS_4_6_0_invoice_settings(), |
|
57 | + ); |
|
58 | + parent::__construct($table_manager, $table_analysis); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * @param array $version_array |
|
65 | + * @return bool |
|
66 | + */ |
|
67 | + public function can_migrate_from_version($version_array) |
|
68 | + { |
|
69 | + $version_string = $version_array['Core']; |
|
70 | + if (version_compare($version_string, '4.6.0', '<=') && version_compare($version_string, '4.5.0', '>=')) { |
|
71 | 71 | // echo "$version_string can be migrated from"; |
72 | - return true; |
|
73 | - } elseif ( ! $version_string) { |
|
72 | + return true; |
|
73 | + } elseif ( ! $version_string) { |
|
74 | 74 | // echo "no version string provided: $version_string"; |
75 | - //no version string provided... this must be pre 4.3 |
|
76 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | - } else { |
|
75 | + //no version string provided... this must be pre 4.3 |
|
76 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
77 | + } else { |
|
78 | 78 | // echo "$version_string doesnt apply"; |
79 | - return false; |
|
80 | - } |
|
81 | - } |
|
79 | + return false; |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @return bool |
|
87 | - */ |
|
88 | - public function schema_changes_before_migration() |
|
89 | - { |
|
90 | - //relies on 4.1's EEH_Activation::create_table |
|
91 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | - $table_name = 'esp_answer'; |
|
93 | - $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
85 | + /** |
|
86 | + * @return bool |
|
87 | + */ |
|
88 | + public function schema_changes_before_migration() |
|
89 | + { |
|
90 | + //relies on 4.1's EEH_Activation::create_table |
|
91 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
92 | + $table_name = 'esp_answer'; |
|
93 | + $sql = " ANS_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
94 | 94 | REG_ID INT UNSIGNED NOT NULL, |
95 | 95 | QST_ID INT UNSIGNED NOT NULL, |
96 | 96 | ANS_value TEXT NOT NULL, |
97 | 97 | PRIMARY KEY (ANS_ID)"; |
98 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
99 | - $table_name = 'esp_attendee_meta'; |
|
100 | - $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
98 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
99 | + $table_name = 'esp_attendee_meta'; |
|
100 | + $sql = "ATTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
101 | 101 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
102 | 102 | ATT_fname VARCHAR(45) NOT NULL, |
103 | 103 | ATT_lname VARCHAR(45) NOT NULL, |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | KEY ATT_fname (ATT_fname), |
114 | 114 | KEY ATT_lname (ATT_lname), |
115 | 115 | KEY ATT_email (ATT_email)"; |
116 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
117 | - $table_name = 'esp_country'; |
|
118 | - $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
116 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
117 | + $table_name = 'esp_country'; |
|
118 | + $sql = "CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
|
119 | 119 | CNT_ISO3 VARCHAR(3) COLLATE utf8_bin NOT NULL, |
120 | 120 | RGN_ID TINYINT(3) UNSIGNED DEFAULT NULL, |
121 | 121 | CNT_name VARCHAR(45) COLLATE utf8_bin NOT NULL, |
@@ -131,24 +131,24 @@ discard block |
||
131 | 131 | CNT_is_EU TINYINT(1) DEFAULT '0', |
132 | 132 | CNT_active TINYINT(1) DEFAULT '0', |
133 | 133 | PRIMARY KEY (CNT_ISO)"; |
134 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | - $table_name = 'esp_currency'; |
|
136 | - $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
134 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
135 | + $table_name = 'esp_currency'; |
|
136 | + $sql = "CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
|
137 | 137 | CUR_single VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollar', |
138 | 138 | CUR_plural VARCHAR(45) COLLATE utf8_bin DEFAULT 'dollars', |
139 | 139 | CUR_sign VARCHAR(45) COLLATE utf8_bin DEFAULT '$', |
140 | 140 | CUR_dec_plc VARCHAR(1) COLLATE utf8_bin NOT NULL DEFAULT '2', |
141 | 141 | CUR_active TINYINT(1) DEFAULT '0', |
142 | 142 | PRIMARY KEY (CUR_code)"; |
143 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | - $table_name = 'esp_currency_payment_method'; |
|
145 | - $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
143 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
144 | + $table_name = 'esp_currency_payment_method'; |
|
145 | + $sql = "CPM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
146 | 146 | CUR_code VARCHAR(6) COLLATE utf8_bin NOT NULL, |
147 | 147 | PMD_ID INT(11) NOT NULL, |
148 | 148 | PRIMARY KEY (CPM_ID)"; |
149 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
150 | - $table_name = 'esp_datetime'; |
|
151 | - $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
149 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
150 | + $table_name = 'esp_datetime'; |
|
151 | + $sql = "DTT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
152 | 152 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
153 | 153 | DTT_name VARCHAR(255) NOT NULL DEFAULT '', |
154 | 154 | DTT_description TEXT NOT NULL, |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | PRIMARY KEY (DTT_ID), |
164 | 164 | KEY EVT_ID (EVT_ID), |
165 | 165 | KEY DTT_is_primary (DTT_is_primary)"; |
166 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
167 | - $table_name = 'esp_event_meta'; |
|
168 | - $sql = " |
|
166 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
167 | + $table_name = 'esp_event_meta'; |
|
168 | + $sql = " |
|
169 | 169 | EVTM_ID INT NOT NULL AUTO_INCREMENT, |
170 | 170 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
171 | 171 | EVT_display_desc TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
@@ -180,31 +180,31 @@ discard block |
||
180 | 180 | EVT_external_URL VARCHAR(200) NULL, |
181 | 181 | EVT_donations TINYINT(1) NULL, |
182 | 182 | PRIMARY KEY (EVTM_ID)"; |
183 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | - $table_name = 'esp_event_question_group'; |
|
185 | - $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
183 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
184 | + $table_name = 'esp_event_question_group'; |
|
185 | + $sql = "EQG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
186 | 186 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
187 | 187 | QSG_ID INT UNSIGNED NOT NULL, |
188 | 188 | EQG_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
189 | 189 | PRIMARY KEY (EQG_ID)"; |
190 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | - $table_name = 'esp_event_venue'; |
|
192 | - $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
190 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
191 | + $table_name = 'esp_event_venue'; |
|
192 | + $sql = "EVV_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
193 | 193 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
194 | 194 | VNU_ID BIGINT(20) UNSIGNED NOT NULL, |
195 | 195 | EVV_primary TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
196 | 196 | PRIMARY KEY (EVV_ID)"; |
197 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | - $table_name = 'esp_extra_meta'; |
|
199 | - $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
197 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
198 | + $table_name = 'esp_extra_meta'; |
|
199 | + $sql = "EXM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
200 | 200 | OBJ_ID INT(11) DEFAULT NULL, |
201 | 201 | EXM_type VARCHAR(45) DEFAULT NULL, |
202 | 202 | EXM_key VARCHAR(45) DEFAULT NULL, |
203 | 203 | EXM_value TEXT, |
204 | 204 | PRIMARY KEY (EXM_ID)"; |
205 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
206 | - $table_name = 'esp_line_item'; |
|
207 | - $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
205 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
206 | + $table_name = 'esp_line_item'; |
|
207 | + $sql = "LIN_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
208 | 208 | LIN_code VARCHAR(245) NOT NULL DEFAULT '', |
209 | 209 | TXN_ID INT(11) DEFAULT NULL, |
210 | 210 | LIN_name VARCHAR(245) NOT NULL DEFAULT '', |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | OBJ_ID INT(11) DEFAULT NULL, |
221 | 221 | OBJ_type VARCHAR(45)DEFAULT NULL, |
222 | 222 | PRIMARY KEY (LIN_ID)"; |
223 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | - $table_name = 'esp_log'; |
|
225 | - $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
223 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
224 | + $table_name = 'esp_log'; |
|
225 | + $sql = "LOG_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
226 | 226 | LOG_time DATETIME DEFAULT NULL, |
227 | 227 | OBJ_ID VARCHAR(45) DEFAULT NULL, |
228 | 228 | OBJ_type VARCHAR(45) DEFAULT NULL, |
@@ -230,19 +230,19 @@ discard block |
||
230 | 230 | LOG_message TEXT, |
231 | 231 | LOG_wp_user INT(11) DEFAULT NULL, |
232 | 232 | PRIMARY KEY (LOG_ID)"; |
233 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | - $table_name = 'esp_message_template'; |
|
235 | - $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
233 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
234 | + $table_name = 'esp_message_template'; |
|
235 | + $sql = "MTP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
236 | 236 | GRP_ID INT(10) UNSIGNED NOT NULL, |
237 | 237 | MTP_context VARCHAR(50) NOT NULL, |
238 | 238 | MTP_template_field VARCHAR(30) NOT NULL, |
239 | 239 | MTP_content TEXT NOT NULL, |
240 | 240 | PRIMARY KEY (MTP_ID), |
241 | 241 | KEY GRP_ID (GRP_ID)"; |
242 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
243 | - $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
244 | - $table_name = 'esp_message_template_group'; |
|
245 | - $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
242 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
243 | + $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID'); |
|
244 | + $table_name = 'esp_message_template_group'; |
|
245 | + $sql = "GRP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
246 | 246 | MTP_user_id INT(10) NOT NULL DEFAULT '1', |
247 | 247 | MTP_name VARCHAR(245) NOT NULL DEFAULT '', |
248 | 248 | MTP_description VARCHAR(245) NOT NULL DEFAULT '', |
@@ -254,17 +254,17 @@ discard block |
||
254 | 254 | MTP_is_active TINYINT(1) NOT NULL DEFAULT '1', |
255 | 255 | PRIMARY KEY (GRP_ID), |
256 | 256 | KEY MTP_user_id (MTP_user_id)"; |
257 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | - $table_name = 'esp_event_message_template'; |
|
259 | - $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
257 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
258 | + $table_name = 'esp_event_message_template'; |
|
259 | + $sql = "EMT_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
260 | 260 | EVT_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
261 | 261 | GRP_ID INT(10) UNSIGNED NOT NULL DEFAULT 0, |
262 | 262 | PRIMARY KEY (EMT_ID), |
263 | 263 | KEY EVT_ID (EVT_ID), |
264 | 264 | KEY GRP_ID (GRP_ID)"; |
265 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
266 | - $table_name = 'esp_payment'; |
|
267 | - $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
265 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
266 | + $table_name = 'esp_payment'; |
|
267 | + $sql = "PAY_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
268 | 268 | TXN_ID INT(10) UNSIGNED DEFAULT NULL, |
269 | 269 | STS_ID VARCHAR(3) COLLATE utf8_bin DEFAULT NULL, |
270 | 270 | PAY_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -281,9 +281,9 @@ discard block |
||
281 | 281 | PRIMARY KEY (PAY_ID), |
282 | 282 | KEY TXN_ID (TXN_ID), |
283 | 283 | KEY PAY_timestamp (PAY_timestamp)"; |
284 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
285 | - $table_name = 'esp_payment_method'; |
|
286 | - $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
284 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
285 | + $table_name = 'esp_payment_method'; |
|
286 | + $sql = "PMD_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
287 | 287 | PMD_type VARCHAR(124) DEFAULT NULL, |
288 | 288 | PMD_name VARCHAR(255) DEFAULT NULL, |
289 | 289 | PMD_desc TEXT, |
@@ -298,28 +298,28 @@ discard block |
||
298 | 298 | PMD_scope VARCHAR(255) NULL DEFAULT 'frontend', |
299 | 299 | PRIMARY KEY (PMD_ID), |
300 | 300 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug)"; |
301 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
302 | - $table_name = "esp_ticket_price"; |
|
303 | - $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
301 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
302 | + $table_name = "esp_ticket_price"; |
|
303 | + $sql = "TKP_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
304 | 304 | TKT_ID INT(10) UNSIGNED NOT NULL, |
305 | 305 | PRC_ID INT(10) UNSIGNED NOT NULL, |
306 | 306 | PRIMARY KEY (TKP_ID)"; |
307 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
308 | - $table_name = "esp_datetime_ticket"; |
|
309 | - $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
307 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
308 | + $table_name = "esp_datetime_ticket"; |
|
309 | + $sql = "DTK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
310 | 310 | DTT_ID INT(10) UNSIGNED NOT NULL, |
311 | 311 | TKT_ID INT(10) UNSIGNED NOT NULL, |
312 | 312 | PRIMARY KEY (DTK_ID)"; |
313 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
314 | - $table_name = "esp_ticket_template"; |
|
315 | - $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
313 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
314 | + $table_name = "esp_ticket_template"; |
|
315 | + $sql = "TTM_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
316 | 316 | TTM_name VARCHAR(45) NOT NULL, |
317 | 317 | TTM_description TEXT, |
318 | 318 | TTM_file VARCHAR(45), |
319 | 319 | PRIMARY KEY (TTM_ID)"; |
320 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | - $table_name = 'esp_question'; |
|
322 | - $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
320 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
321 | + $table_name = 'esp_question'; |
|
322 | + $sql = 'QST_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
323 | 323 | QST_display_text TEXT NOT NULL, |
324 | 324 | QST_admin_label VARCHAR(255) NOT NULL, |
325 | 325 | QST_system VARCHAR(25) DEFAULT NULL, |
@@ -331,25 +331,25 @@ discard block |
||
331 | 331 | QST_wp_user BIGINT UNSIGNED NULL, |
332 | 332 | QST_deleted TINYINT UNSIGNED NOT NULL DEFAULT 0, |
333 | 333 | PRIMARY KEY (QST_ID)'; |
334 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
335 | - $table_name = 'esp_question_group_question'; |
|
336 | - $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
334 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
335 | + $table_name = 'esp_question_group_question'; |
|
336 | + $sql = "QGQ_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
337 | 337 | QSG_ID INT UNSIGNED NOT NULL, |
338 | 338 | QST_ID INT UNSIGNED NOT NULL, |
339 | 339 | QGQ_order INT UNSIGNED NOT NULL DEFAULT 0, |
340 | 340 | PRIMARY KEY (QGQ_ID) "; |
341 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | - $table_name = 'esp_question_option'; |
|
343 | - $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
341 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
342 | + $table_name = 'esp_question_option'; |
|
343 | + $sql = "QSO_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
344 | 344 | QSO_value VARCHAR(255) NOT NULL, |
345 | 345 | QSO_desc TEXT NOT NULL, |
346 | 346 | QST_ID INT UNSIGNED NOT NULL, |
347 | 347 | QSO_order INT UNSIGNED NOT NULL DEFAULT 0, |
348 | 348 | QSO_deleted TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, |
349 | 349 | PRIMARY KEY (QSO_ID)"; |
350 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | - $table_name = 'esp_registration'; |
|
352 | - $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
350 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
351 | + $table_name = 'esp_registration'; |
|
352 | + $sql = "REG_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
353 | 353 | EVT_ID BIGINT(20) UNSIGNED NOT NULL, |
354 | 354 | ATT_ID BIGINT(20) UNSIGNED NOT NULL, |
355 | 355 | TXN_ID INT(10) UNSIGNED NOT NULL, |
@@ -372,25 +372,25 @@ discard block |
||
372 | 372 | KEY STS_ID (STS_ID), |
373 | 373 | KEY REG_url_link (REG_url_link), |
374 | 374 | KEY REG_code (REG_code)"; |
375 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
376 | - $table_name = 'esp_checkin'; |
|
377 | - $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
375 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
376 | + $table_name = 'esp_checkin'; |
|
377 | + $sql = "CHK_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
378 | 378 | REG_ID INT(10) UNSIGNED NOT NULL, |
379 | 379 | DTT_ID INT(10) UNSIGNED NOT NULL, |
380 | 380 | CHK_in TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, |
381 | 381 | CHK_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
382 | 382 | PRIMARY KEY (CHK_ID)"; |
383 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | - $table_name = 'esp_state'; |
|
385 | - $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
383 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
384 | + $table_name = 'esp_state'; |
|
385 | + $sql = "STA_ID smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
386 | 386 | CNT_ISO VARCHAR(2) COLLATE utf8_bin NOT NULL, |
387 | 387 | STA_abbrev VARCHAR(24) COLLATE utf8_bin NOT NULL, |
388 | 388 | STA_name VARCHAR(100) COLLATE utf8_bin NOT NULL, |
389 | 389 | STA_active TINYINT(1) DEFAULT '1', |
390 | 390 | PRIMARY KEY (STA_ID)"; |
391 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | - $table_name = 'esp_status'; |
|
393 | - $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
391 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | + $table_name = 'esp_status'; |
|
393 | + $sql = "STS_ID VARCHAR(3) COLLATE utf8_bin NOT NULL, |
|
394 | 394 | STS_code VARCHAR(45) COLLATE utf8_bin NOT NULL, |
395 | 395 | STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL, |
396 | 396 | STS_can_edit TINYINT(1) NOT NULL DEFAULT 0, |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | STS_open TINYINT(1) NOT NULL DEFAULT 1, |
399 | 399 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
400 | 400 | KEY STS_type (STS_type)"; |
401 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
402 | - $table_name = 'esp_transaction'; |
|
403 | - $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
401 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
402 | + $table_name = 'esp_transaction'; |
|
403 | + $sql = "TXN_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
404 | 404 | TXN_timestamp DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', |
405 | 405 | TXN_total DECIMAL(10,3) DEFAULT '0.00', |
406 | 406 | TXN_paid DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | PRIMARY KEY (TXN_ID), |
413 | 413 | KEY TXN_timestamp (TXN_timestamp), |
414 | 414 | KEY STS_ID (STS_ID)"; |
415 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | - $table_name = 'esp_venue_meta'; |
|
417 | - $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
415 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
416 | + $table_name = 'esp_venue_meta'; |
|
417 | + $sql = "VNUM_ID INT(11) NOT NULL AUTO_INCREMENT, |
|
418 | 418 | VNU_ID BIGINT(20) UNSIGNED NOT NULL DEFAULT 0, |
419 | 419 | VNU_address VARCHAR(255) DEFAULT NULL, |
420 | 420 | VNU_address2 VARCHAR(255) DEFAULT NULL, |
@@ -432,10 +432,10 @@ discard block |
||
432 | 432 | PRIMARY KEY (VNUM_ID), |
433 | 433 | KEY STA_ID (STA_ID), |
434 | 434 | KEY CNT_ISO (CNT_ISO)"; |
435 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
436 | - //modified tables |
|
437 | - $table_name = "esp_price"; |
|
438 | - $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
435 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
436 | + //modified tables |
|
437 | + $table_name = "esp_price"; |
|
438 | + $sql = "PRC_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
439 | 439 | PRT_ID TINYINT(3) UNSIGNED NOT NULL, |
440 | 440 | PRC_amount DECIMAL(10,3) NOT NULL DEFAULT '0.00', |
441 | 441 | PRC_name VARCHAR(245) NOT NULL, |
@@ -447,9 +447,9 @@ discard block |
||
447 | 447 | PRC_wp_user BIGINT UNSIGNED NULL, |
448 | 448 | PRC_parent INT(10) UNSIGNED DEFAULT 0, |
449 | 449 | PRIMARY KEY (PRC_ID)"; |
450 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
451 | - $table_name = "esp_price_type"; |
|
452 | - $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
450 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
451 | + $table_name = "esp_price_type"; |
|
452 | + $sql = "PRT_ID TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
453 | 453 | PRT_name VARCHAR(45) NOT NULL, |
454 | 454 | PBT_ID TINYINT(3) UNSIGNED NOT NULL DEFAULT '1', |
455 | 455 | PRT_is_percent TINYINT(1) NOT NULL DEFAULT '0', |
@@ -458,9 +458,9 @@ discard block |
||
458 | 458 | PRT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
459 | 459 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
460 | 460 | PRIMARY KEY (PRT_ID)"; |
461 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
462 | - $table_name = "esp_ticket"; |
|
463 | - $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
461 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB '); |
|
462 | + $table_name = "esp_ticket"; |
|
463 | + $sql = "TKT_ID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
|
464 | 464 | TTM_ID INT(10) UNSIGNED NOT NULL, |
465 | 465 | TKT_name VARCHAR(245) NOT NULL DEFAULT '', |
466 | 466 | TKT_description TEXT NOT NULL, |
@@ -481,10 +481,10 @@ discard block |
||
481 | 481 | TKT_parent INT(10) UNSIGNED DEFAULT '0', |
482 | 482 | TKT_deleted TINYINT(1) NOT NULL DEFAULT '0', |
483 | 483 | PRIMARY KEY (TKT_ID)"; |
484 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
485 | - $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
486 | - $table_name = 'esp_question_group'; |
|
487 | - $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
484 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
485 | + $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE'); |
|
486 | + $table_name = 'esp_question_group'; |
|
487 | + $sql = 'QSG_ID INT UNSIGNED NOT NULL AUTO_INCREMENT, |
|
488 | 488 | QSG_name VARCHAR(255) NOT NULL, |
489 | 489 | QSG_identifier VARCHAR(100) NOT NULL, |
490 | 490 | QSG_desc TEXT NULL, |
@@ -496,119 +496,119 @@ discard block |
||
496 | 496 | QSG_wp_user BIGINT UNSIGNED NULL, |
497 | 497 | PRIMARY KEY (QSG_ID), |
498 | 498 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)'; |
499 | - $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
500 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
501 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
502 | - //(because many need to convert old string states to foreign keys into the states table) |
|
503 | - $script_4_1_defaults->insert_default_states(); |
|
504 | - $script_4_1_defaults->insert_default_countries(); |
|
505 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
506 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
507 | - $script_4_5_defaults->insert_default_price_types(); |
|
508 | - $script_4_5_defaults->insert_default_prices(); |
|
509 | - $script_4_5_defaults->insert_default_tickets(); |
|
510 | - //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
511 | - EE_Config::instance()->update_espresso_config(false, true); |
|
512 | - $this->add_default_admin_only_payments(); |
|
513 | - $this->insert_default_currencies(); |
|
514 | - return true; |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - |
|
519 | - /** |
|
520 | - * @return boolean |
|
521 | - */ |
|
522 | - public function schema_changes_after_migration() |
|
523 | - { |
|
524 | - return true; |
|
525 | - } |
|
526 | - |
|
527 | - |
|
528 | - |
|
529 | - public function migration_page_hooks() |
|
530 | - { |
|
531 | - } |
|
532 | - |
|
533 | - |
|
534 | - |
|
535 | - public function add_default_admin_only_payments() |
|
536 | - { |
|
537 | - global $wpdb; |
|
538 | - $table_name = $wpdb->prefix . "esp_payment_method"; |
|
539 | - $user_id = EEH_Activation::get_default_creator_id(); |
|
540 | - if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
541 | - $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
542 | - $existing_payment_methods = $wpdb->get_var($SQL); |
|
543 | - $default_admin_only_payment_methods = apply_filters( |
|
544 | - 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
545 | - array( |
|
546 | - __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
547 | - __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
548 | - __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
549 | - __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
550 | - __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
551 | - __("Invoice", 'event_espresso') => __("Invoice received with monies included", |
|
552 | - 'event_espresso'), |
|
553 | - __("Money Order", 'event_espresso') => '', |
|
554 | - __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
555 | - __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
556 | - )); |
|
557 | - //make sure we hae payment method records for the following |
|
558 | - //so admins can record payments for them from the admin page |
|
559 | - foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
560 | - $slug = sanitize_key($nicename); |
|
561 | - //check that such a payment method exists |
|
562 | - $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
563 | - if ( ! $exists) { |
|
564 | - $values = array( |
|
565 | - 'PMD_type' => 'Admin_Only', |
|
566 | - 'PMD_name' => $nicename, |
|
567 | - 'PMD_admin_name' => $nicename, |
|
568 | - 'PMD_admin_desc' => $description, |
|
569 | - 'PMD_slug' => $slug, |
|
570 | - 'PMD_wp_user' => $user_id, |
|
571 | - 'PMD_scope' => serialize(array('ADMIN')), |
|
572 | - ); |
|
573 | - $success = $wpdb->insert( |
|
574 | - $table_name, |
|
575 | - $values, |
|
576 | - array( |
|
577 | - '%s',//PMD_type |
|
578 | - '%s',//PMD_name |
|
579 | - '%s',//PMD_admin_name |
|
580 | - '%s',//PMD_admin_desc |
|
581 | - '%s',//PMD_slug |
|
582 | - '%d',//PMD_wp_user |
|
583 | - '%s',//PMD_scope |
|
584 | - ) |
|
585 | - ); |
|
586 | - if ( ! $success) { |
|
587 | - $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", |
|
588 | - "event_espresso"), $this->_json_encode($values))); |
|
589 | - } |
|
590 | - } |
|
591 | - } |
|
592 | - } |
|
593 | - } |
|
594 | - |
|
595 | - |
|
596 | - |
|
597 | - /** |
|
598 | - * insert_default_countries |
|
599 | - * |
|
600 | - * @static |
|
601 | - * @return void |
|
602 | - */ |
|
603 | - public function insert_default_currencies() |
|
604 | - { |
|
605 | - global $wpdb; |
|
606 | - $currency_table = $wpdb->prefix . "esp_currency"; |
|
607 | - if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
608 | - $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
609 | - $countries = $wpdb->get_var($SQL); |
|
610 | - if ( ! $countries) { |
|
611 | - $SQL = "INSERT INTO $currency_table |
|
499 | + $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB'); |
|
500 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
501 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
502 | + //(because many need to convert old string states to foreign keys into the states table) |
|
503 | + $script_4_1_defaults->insert_default_states(); |
|
504 | + $script_4_1_defaults->insert_default_countries(); |
|
505 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
506 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
507 | + $script_4_5_defaults->insert_default_price_types(); |
|
508 | + $script_4_5_defaults->insert_default_prices(); |
|
509 | + $script_4_5_defaults->insert_default_tickets(); |
|
510 | + //setting up the config wp option pretty well counts as a 'schema change', or at least should happen here |
|
511 | + EE_Config::instance()->update_espresso_config(false, true); |
|
512 | + $this->add_default_admin_only_payments(); |
|
513 | + $this->insert_default_currencies(); |
|
514 | + return true; |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + |
|
519 | + /** |
|
520 | + * @return boolean |
|
521 | + */ |
|
522 | + public function schema_changes_after_migration() |
|
523 | + { |
|
524 | + return true; |
|
525 | + } |
|
526 | + |
|
527 | + |
|
528 | + |
|
529 | + public function migration_page_hooks() |
|
530 | + { |
|
531 | + } |
|
532 | + |
|
533 | + |
|
534 | + |
|
535 | + public function add_default_admin_only_payments() |
|
536 | + { |
|
537 | + global $wpdb; |
|
538 | + $table_name = $wpdb->prefix . "esp_payment_method"; |
|
539 | + $user_id = EEH_Activation::get_default_creator_id(); |
|
540 | + if ($this->_get_table_analysis()->tableExists($table_name)) { |
|
541 | + $SQL = "SELECT COUNT( * ) FROM $table_name"; |
|
542 | + $existing_payment_methods = $wpdb->get_var($SQL); |
|
543 | + $default_admin_only_payment_methods = apply_filters( |
|
544 | + 'FHEE__EEH_Activation__add_default_admin_only_payments__default_admin_only_payment_methods', |
|
545 | + array( |
|
546 | + __("Bank", 'event_espresso') => __("Bank Draft", 'event_espresso'), |
|
547 | + __("Cash", 'event_espresso') => __("Cash Delivered Physically", 'event_espresso'), |
|
548 | + __("Check", 'event_espresso') => __("Paper Check", 'event_espresso'), |
|
549 | + __("Credit Card", 'event_espresso') => __("Offline Credit Card Payment", 'event_espresso'), |
|
550 | + __("Debit Card", 'event_espresso') => __("Offline Debit Payment", 'event_espresso'), |
|
551 | + __("Invoice", 'event_espresso') => __("Invoice received with monies included", |
|
552 | + 'event_espresso'), |
|
553 | + __("Money Order", 'event_espresso') => '', |
|
554 | + __("Paypal", 'event_espresso') => __("Paypal eCheck, Invoice, etc", 'event_espresso'), |
|
555 | + __('Other', 'event_espresso') => __('Other method of payment', 'event_espresso'), |
|
556 | + )); |
|
557 | + //make sure we hae payment method records for the following |
|
558 | + //so admins can record payments for them from the admin page |
|
559 | + foreach ($default_admin_only_payment_methods as $nicename => $description) { |
|
560 | + $slug = sanitize_key($nicename); |
|
561 | + //check that such a payment method exists |
|
562 | + $exists = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $table_name WHERE PMD_slug = %s", $slug)); |
|
563 | + if ( ! $exists) { |
|
564 | + $values = array( |
|
565 | + 'PMD_type' => 'Admin_Only', |
|
566 | + 'PMD_name' => $nicename, |
|
567 | + 'PMD_admin_name' => $nicename, |
|
568 | + 'PMD_admin_desc' => $description, |
|
569 | + 'PMD_slug' => $slug, |
|
570 | + 'PMD_wp_user' => $user_id, |
|
571 | + 'PMD_scope' => serialize(array('ADMIN')), |
|
572 | + ); |
|
573 | + $success = $wpdb->insert( |
|
574 | + $table_name, |
|
575 | + $values, |
|
576 | + array( |
|
577 | + '%s',//PMD_type |
|
578 | + '%s',//PMD_name |
|
579 | + '%s',//PMD_admin_name |
|
580 | + '%s',//PMD_admin_desc |
|
581 | + '%s',//PMD_slug |
|
582 | + '%d',//PMD_wp_user |
|
583 | + '%s',//PMD_scope |
|
584 | + ) |
|
585 | + ); |
|
586 | + if ( ! $success) { |
|
587 | + $this->add_error(sprintf(__("Could not insert new admin-only payment method with values %s during migration", |
|
588 | + "event_espresso"), $this->_json_encode($values))); |
|
589 | + } |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + |
|
595 | + |
|
596 | + |
|
597 | + /** |
|
598 | + * insert_default_countries |
|
599 | + * |
|
600 | + * @static |
|
601 | + * @return void |
|
602 | + */ |
|
603 | + public function insert_default_currencies() |
|
604 | + { |
|
605 | + global $wpdb; |
|
606 | + $currency_table = $wpdb->prefix . "esp_currency"; |
|
607 | + if ($this->_get_table_analysis()->tableExists($currency_table)) { |
|
608 | + $SQL = "SELECT COUNT('CUR_code') FROM $currency_table"; |
|
609 | + $countries = $wpdb->get_var($SQL); |
|
610 | + if ( ! $countries) { |
|
611 | + $SQL = "INSERT INTO $currency_table |
|
612 | 612 | ( CUR_code, CUR_single, CUR_plural, CUR_sign, CUR_dec_plc, CUR_active) VALUES |
613 | 613 | ( 'EUR', 'Euro', 'Euros', '€', 2,1), |
614 | 614 | ( 'AED', 'Dirham', 'Dirhams', 'د.إ',2,1), |
@@ -762,10 +762,10 @@ discard block |
||
762 | 762 | ( 'ZAR', 'Rand', 'Rands', 'R', 2,1), |
763 | 763 | ( 'ZMK', 'Kwacha', 'Kwachas', '', 2,1), |
764 | 764 | ( 'ZWD', 'Dollar', 'Dollars', 'Z$', 2,1);"; |
765 | - $wpdb->query($SQL); |
|
766 | - } |
|
767 | - } |
|
768 | - } |
|
765 | + $wpdb->query($SQL); |
|
766 | + } |
|
767 | + } |
|
768 | + } |
|
769 | 769 | |
770 | 770 | } |
771 | 771 |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @param array $query_params like EEM_Base::get_all |
207 | 207 | * @param string $field_to_sum |
208 | - * @return int |
|
208 | + * @return double |
|
209 | 209 | */ |
210 | 210 | public function sum_deleted($query_params = null, $field_to_sum = null) |
211 | 211 | { |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
271 | 271 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
272 | 272 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
273 | - * @return boolean success |
|
273 | + * @return integer success |
|
274 | 274 | */ |
275 | 275 | public function delete_permanently($query_params = array(), $allow_blocking = true) |
276 | 276 | { |
@@ -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 | require_once(EE_MODELS . 'EEM_Base.model.php'); |
5 | 5 | |
@@ -32,362 +32,362 @@ discard block |
||
32 | 32 | abstract class EEM_Soft_Delete_Base extends EEM_Base |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * @param null $timezone |
|
37 | - */ |
|
38 | - protected function __construct($timezone = null) |
|
39 | - { |
|
40 | - if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | - $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
|
42 | - } |
|
43 | - parent::__construct($timezone); |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Searches for field on this model of type 'deleted_flag'. if it is found, |
|
50 | - * returns it's name. |
|
51 | - * |
|
52 | - * @return string |
|
53 | - * @throws EE_Error |
|
54 | - */ |
|
55 | - public function deleted_field_name() |
|
56 | - { |
|
57 | - $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
58 | - if ($field) { |
|
59 | - return $field->get_name(); |
|
60 | - } else { |
|
61 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
62 | - 'event_espresso'), get_class($this), get_class($this))); |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * Gets one item that's been deleted, according to $query_params |
|
70 | - * |
|
71 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
72 | - * @return EE_Soft_Delete_Base_Class |
|
73 | - */ |
|
74 | - public function get_one_deleted($query_params = array()) |
|
75 | - { |
|
76 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
77 | - return parent::get_one($query_params); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * Gets one item from the DB, regardless of whether it's been soft-deleted or not |
|
84 | - * |
|
85 | - * @param array $query_params like EEM_base::get_all's $query_params |
|
86 | - * @return EE_Soft_Delete_Base_Class |
|
87 | - */ |
|
88 | - public function get_one_deleted_or_undeleted($query_params = array()) |
|
89 | - { |
|
90 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
91 | - return parent::get_one($query_params); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. |
|
98 | - * |
|
99 | - * @param int|string $id |
|
100 | - * @return EE_Soft_Delete_Base_Class |
|
101 | - */ |
|
102 | - public function get_one_by_ID_but_ignore_deleted($id) |
|
103 | - { |
|
104 | - return $this->get_one( |
|
105 | - $this->alter_query_params_to_restrict_by_ID( |
|
106 | - $id, |
|
107 | - array('default_where_conditions' => 'default') |
|
108 | - ) |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Counts all the deleted/trashed items |
|
116 | - * |
|
117 | - * @param array $query_params like EEM_Base::get_all |
|
118 | - * @param string $field_to_count |
|
119 | - * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
120 | - * @return int |
|
121 | - */ |
|
122 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = false) |
|
123 | - { |
|
124 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
125 | - return parent::count($query_params, $field_to_count, $distinct); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
132 | - * |
|
133 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
134 | - * @return array like EEM_Base::get_all's $query_params |
|
135 | - */ |
|
136 | - protected function _alter_query_params_so_only_trashed_items_included($query_params) |
|
137 | - { |
|
138 | - $deletedFlagFieldName = $this->deleted_field_name(); |
|
139 | - $query_params[0][$deletedFlagFieldName] = true; |
|
140 | - return $query_params; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
147 | - * |
|
148 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
149 | - * @return array like EEM_Base::get_all's $query_params |
|
150 | - */ |
|
151 | - public function alter_query_params_so_only_trashed_items_included($query_params) |
|
152 | - { |
|
153 | - return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * Alters the query params so each item's deleted status is ignored. |
|
160 | - * |
|
161 | - * @param array $query_params |
|
162 | - * @return array |
|
163 | - */ |
|
164 | - public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) |
|
165 | - { |
|
166 | - return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Alters the query params so each item's deleted status is ignored. |
|
173 | - * |
|
174 | - * @param array $query_params |
|
175 | - * @return array |
|
176 | - */ |
|
177 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
|
178 | - { |
|
179 | - if (! isset($query_params['default_where_conditions'])) { |
|
180 | - $query_params['default_where_conditions'] = 'minimum'; |
|
181 | - } |
|
182 | - return $query_params; |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * Counts all deleted and undeleted items |
|
189 | - * |
|
190 | - * @param array $query_params like EEM_Base::get_all |
|
191 | - * @param string $field_to_count |
|
192 | - * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
193 | - * @return int |
|
194 | - */ |
|
195 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false) |
|
196 | - { |
|
197 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
198 | - return parent::count($query_params, $field_to_count, $distinct); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * Sum all the deleted items. |
|
205 | - * |
|
206 | - * @param array $query_params like EEM_Base::get_all |
|
207 | - * @param string $field_to_sum |
|
208 | - * @return int |
|
209 | - */ |
|
210 | - public function sum_deleted($query_params = null, $field_to_sum = null) |
|
211 | - { |
|
212 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
213 | - return parent::sum($query_params, $field_to_sum); |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * Sums all the deleted and undeleted items. |
|
220 | - * |
|
221 | - * @param array $query_params lik eEEM_Base::get_all |
|
222 | - * @param string $field_to_sum |
|
223 | - * @return int |
|
224 | - */ |
|
225 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) |
|
226 | - { |
|
227 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
228 | - parent::sum($query_params, $field_to_sum); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of |
|
235 | - * whether they've been soft-deleted or not |
|
236 | - * |
|
237 | - * @param array $query_params like EEM_Base::get_all |
|
238 | - * @return EE_Soft_Delete_Base_Class[] |
|
239 | - */ |
|
240 | - public function get_all_deleted_and_undeleted($query_params = array()) |
|
241 | - { |
|
242 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
243 | - return parent::get_all($query_params); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params. |
|
250 | - * |
|
251 | - * @param array $query_params like EEM_Base::get_all |
|
252 | - * @return EE_Soft_Delete_Base_Class[] |
|
253 | - */ |
|
254 | - public function get_all_deleted($query_params = array()) |
|
255 | - { |
|
256 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
257 | - return parent::get_all($query_params); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * Permanently deletes the selected rows. When selecting rows for deletion, ignores |
|
264 | - * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects |
|
265 | - * before you can permanently delete them). |
|
266 | - * Because this will cause a real deletion, related models may block this deletion (ie, add an error |
|
267 | - * and abort the delete) |
|
268 | - * |
|
269 | - * @param array $query_params like EEM_Base::get_all |
|
270 | - * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
271 | - * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
272 | - * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
273 | - * @return boolean success |
|
274 | - */ |
|
275 | - public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
276 | - { |
|
277 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
278 | - return parent::delete_permanently($query_params, $allow_blocking); |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
|
285 | - * has been soft-deleted or not. |
|
286 | - * |
|
287 | - * @param mixed $ID int if primary key is an int, string otherwise |
|
288 | - * @return boolean success |
|
289 | - */ |
|
290 | - public function restore_by_ID($ID = false) |
|
291 | - { |
|
292 | - return $this->delete_or_restore_by_ID(false, $ID); |
|
293 | - } |
|
294 | - |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
|
299 | - * this function will ignore whether the items have been soft-deleted or not. |
|
300 | - * |
|
301 | - * @param boolean $delete true for delete, false for restore |
|
302 | - * @param mixed $ID int if primary key is an int, string otherwise |
|
303 | - * @return boolean |
|
304 | - */ |
|
305 | - public function delete_or_restore_by_ID($delete = true, $ID = false) |
|
306 | - { |
|
307 | - if (! $ID) { |
|
308 | - return false; |
|
309 | - } |
|
310 | - if ( |
|
311 | - $this->delete_or_restore( |
|
312 | - $delete, |
|
313 | - $this->alter_query_params_to_restrict_by_ID($ID) |
|
314 | - ) |
|
315 | - ) { |
|
316 | - return true; |
|
317 | - } else { |
|
318 | - return false; |
|
319 | - } |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * Overrides parent's 'delete' method to instead do a soft delete on all rows that |
|
326 | - * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not. |
|
327 | - * Note: because this item will be soft-deleted only, |
|
328 | - * doesn't block because of model dependencies |
|
329 | - * |
|
330 | - * @param array $query_params like EEM_Base::get_all |
|
331 | - * @param bool $block_deletes |
|
332 | - * @return boolean |
|
333 | - */ |
|
334 | - public function delete($query_params = array(), $block_deletes = false) |
|
335 | - { |
|
336 | - //no matter what, we WON'T block soft deletes. |
|
337 | - return $this->delete_or_restore(true, $query_params); |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - |
|
342 | - /** |
|
343 | - * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted |
|
344 | - * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not. |
|
345 | - * |
|
346 | - * @param array $query_params like EEM_Base::get_all |
|
347 | - * @return boolean |
|
348 | - */ |
|
349 | - public function restore($query_params = array()) |
|
350 | - { |
|
351 | - return $this->delete_or_restore(false, $query_params); |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered. |
|
358 | - * |
|
359 | - * @param boolean $delete true to indicate deletion, false to indicate restoration |
|
360 | - * @param array $query_params like EEM_Base::get_all |
|
361 | - * @return boolean |
|
362 | - */ |
|
363 | - function delete_or_restore($delete = true, $query_params = array()) |
|
364 | - { |
|
365 | - $deletedFlagFieldName = $this->deleted_field_name(); |
|
366 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
367 | - if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) { |
|
368 | - return true; |
|
369 | - } else { |
|
370 | - return false; |
|
371 | - } |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * Updates all the items of this model which match the $query params, regardless of whether |
|
378 | - * they've been soft-deleted or not |
|
379 | - * |
|
380 | - * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
381 | - * @param array $query_params like EEM_base::get_all's $query_params |
|
382 | - * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
383 | - * in this model's entity map according to $fields_n_values that match $query_params. This |
|
384 | - * obviously has some overhead, so you can disable it by setting this to FALSE, but |
|
385 | - * be aware that model objects being used could get out-of-sync with the database |
|
386 | - * @return int number of items updated |
|
387 | - */ |
|
388 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
389 | - { |
|
390 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
391 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
392 | - } |
|
35 | + /** |
|
36 | + * @param null $timezone |
|
37 | + */ |
|
38 | + protected function __construct($timezone = null) |
|
39 | + { |
|
40 | + if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | + $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
|
42 | + } |
|
43 | + parent::__construct($timezone); |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Searches for field on this model of type 'deleted_flag'. if it is found, |
|
50 | + * returns it's name. |
|
51 | + * |
|
52 | + * @return string |
|
53 | + * @throws EE_Error |
|
54 | + */ |
|
55 | + public function deleted_field_name() |
|
56 | + { |
|
57 | + $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
58 | + if ($field) { |
|
59 | + return $field->get_name(); |
|
60 | + } else { |
|
61 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
62 | + 'event_espresso'), get_class($this), get_class($this))); |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * Gets one item that's been deleted, according to $query_params |
|
70 | + * |
|
71 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
72 | + * @return EE_Soft_Delete_Base_Class |
|
73 | + */ |
|
74 | + public function get_one_deleted($query_params = array()) |
|
75 | + { |
|
76 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
77 | + return parent::get_one($query_params); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * Gets one item from the DB, regardless of whether it's been soft-deleted or not |
|
84 | + * |
|
85 | + * @param array $query_params like EEM_base::get_all's $query_params |
|
86 | + * @return EE_Soft_Delete_Base_Class |
|
87 | + */ |
|
88 | + public function get_one_deleted_or_undeleted($query_params = array()) |
|
89 | + { |
|
90 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
91 | + return parent::get_one($query_params); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. |
|
98 | + * |
|
99 | + * @param int|string $id |
|
100 | + * @return EE_Soft_Delete_Base_Class |
|
101 | + */ |
|
102 | + public function get_one_by_ID_but_ignore_deleted($id) |
|
103 | + { |
|
104 | + return $this->get_one( |
|
105 | + $this->alter_query_params_to_restrict_by_ID( |
|
106 | + $id, |
|
107 | + array('default_where_conditions' => 'default') |
|
108 | + ) |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Counts all the deleted/trashed items |
|
116 | + * |
|
117 | + * @param array $query_params like EEM_Base::get_all |
|
118 | + * @param string $field_to_count |
|
119 | + * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
120 | + * @return int |
|
121 | + */ |
|
122 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = false) |
|
123 | + { |
|
124 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
125 | + return parent::count($query_params, $field_to_count, $distinct); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
132 | + * |
|
133 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
134 | + * @return array like EEM_Base::get_all's $query_params |
|
135 | + */ |
|
136 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) |
|
137 | + { |
|
138 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
139 | + $query_params[0][$deletedFlagFieldName] = true; |
|
140 | + return $query_params; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
147 | + * |
|
148 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
149 | + * @return array like EEM_Base::get_all's $query_params |
|
150 | + */ |
|
151 | + public function alter_query_params_so_only_trashed_items_included($query_params) |
|
152 | + { |
|
153 | + return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * Alters the query params so each item's deleted status is ignored. |
|
160 | + * |
|
161 | + * @param array $query_params |
|
162 | + * @return array |
|
163 | + */ |
|
164 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) |
|
165 | + { |
|
166 | + return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Alters the query params so each item's deleted status is ignored. |
|
173 | + * |
|
174 | + * @param array $query_params |
|
175 | + * @return array |
|
176 | + */ |
|
177 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
|
178 | + { |
|
179 | + if (! isset($query_params['default_where_conditions'])) { |
|
180 | + $query_params['default_where_conditions'] = 'minimum'; |
|
181 | + } |
|
182 | + return $query_params; |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * Counts all deleted and undeleted items |
|
189 | + * |
|
190 | + * @param array $query_params like EEM_Base::get_all |
|
191 | + * @param string $field_to_count |
|
192 | + * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
193 | + * @return int |
|
194 | + */ |
|
195 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false) |
|
196 | + { |
|
197 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
198 | + return parent::count($query_params, $field_to_count, $distinct); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * Sum all the deleted items. |
|
205 | + * |
|
206 | + * @param array $query_params like EEM_Base::get_all |
|
207 | + * @param string $field_to_sum |
|
208 | + * @return int |
|
209 | + */ |
|
210 | + public function sum_deleted($query_params = null, $field_to_sum = null) |
|
211 | + { |
|
212 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
213 | + return parent::sum($query_params, $field_to_sum); |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * Sums all the deleted and undeleted items. |
|
220 | + * |
|
221 | + * @param array $query_params lik eEEM_Base::get_all |
|
222 | + * @param string $field_to_sum |
|
223 | + * @return int |
|
224 | + */ |
|
225 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) |
|
226 | + { |
|
227 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
228 | + parent::sum($query_params, $field_to_sum); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of |
|
235 | + * whether they've been soft-deleted or not |
|
236 | + * |
|
237 | + * @param array $query_params like EEM_Base::get_all |
|
238 | + * @return EE_Soft_Delete_Base_Class[] |
|
239 | + */ |
|
240 | + public function get_all_deleted_and_undeleted($query_params = array()) |
|
241 | + { |
|
242 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
243 | + return parent::get_all($query_params); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params. |
|
250 | + * |
|
251 | + * @param array $query_params like EEM_Base::get_all |
|
252 | + * @return EE_Soft_Delete_Base_Class[] |
|
253 | + */ |
|
254 | + public function get_all_deleted($query_params = array()) |
|
255 | + { |
|
256 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
257 | + return parent::get_all($query_params); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * Permanently deletes the selected rows. When selecting rows for deletion, ignores |
|
264 | + * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects |
|
265 | + * before you can permanently delete them). |
|
266 | + * Because this will cause a real deletion, related models may block this deletion (ie, add an error |
|
267 | + * and abort the delete) |
|
268 | + * |
|
269 | + * @param array $query_params like EEM_Base::get_all |
|
270 | + * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
271 | + * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
272 | + * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
273 | + * @return boolean success |
|
274 | + */ |
|
275 | + public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
276 | + { |
|
277 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
278 | + return parent::delete_permanently($query_params, $allow_blocking); |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
|
285 | + * has been soft-deleted or not. |
|
286 | + * |
|
287 | + * @param mixed $ID int if primary key is an int, string otherwise |
|
288 | + * @return boolean success |
|
289 | + */ |
|
290 | + public function restore_by_ID($ID = false) |
|
291 | + { |
|
292 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
293 | + } |
|
294 | + |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
|
299 | + * this function will ignore whether the items have been soft-deleted or not. |
|
300 | + * |
|
301 | + * @param boolean $delete true for delete, false for restore |
|
302 | + * @param mixed $ID int if primary key is an int, string otherwise |
|
303 | + * @return boolean |
|
304 | + */ |
|
305 | + public function delete_or_restore_by_ID($delete = true, $ID = false) |
|
306 | + { |
|
307 | + if (! $ID) { |
|
308 | + return false; |
|
309 | + } |
|
310 | + if ( |
|
311 | + $this->delete_or_restore( |
|
312 | + $delete, |
|
313 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
314 | + ) |
|
315 | + ) { |
|
316 | + return true; |
|
317 | + } else { |
|
318 | + return false; |
|
319 | + } |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * Overrides parent's 'delete' method to instead do a soft delete on all rows that |
|
326 | + * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not. |
|
327 | + * Note: because this item will be soft-deleted only, |
|
328 | + * doesn't block because of model dependencies |
|
329 | + * |
|
330 | + * @param array $query_params like EEM_Base::get_all |
|
331 | + * @param bool $block_deletes |
|
332 | + * @return boolean |
|
333 | + */ |
|
334 | + public function delete($query_params = array(), $block_deletes = false) |
|
335 | + { |
|
336 | + //no matter what, we WON'T block soft deletes. |
|
337 | + return $this->delete_or_restore(true, $query_params); |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + |
|
342 | + /** |
|
343 | + * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted |
|
344 | + * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not. |
|
345 | + * |
|
346 | + * @param array $query_params like EEM_Base::get_all |
|
347 | + * @return boolean |
|
348 | + */ |
|
349 | + public function restore($query_params = array()) |
|
350 | + { |
|
351 | + return $this->delete_or_restore(false, $query_params); |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered. |
|
358 | + * |
|
359 | + * @param boolean $delete true to indicate deletion, false to indicate restoration |
|
360 | + * @param array $query_params like EEM_Base::get_all |
|
361 | + * @return boolean |
|
362 | + */ |
|
363 | + function delete_or_restore($delete = true, $query_params = array()) |
|
364 | + { |
|
365 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
366 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
367 | + if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) { |
|
368 | + return true; |
|
369 | + } else { |
|
370 | + return false; |
|
371 | + } |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * Updates all the items of this model which match the $query params, regardless of whether |
|
378 | + * they've been soft-deleted or not |
|
379 | + * |
|
380 | + * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
381 | + * @param array $query_params like EEM_base::get_all's $query_params |
|
382 | + * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
383 | + * in this model's entity map according to $fields_n_values that match $query_params. This |
|
384 | + * obviously has some overhead, so you can disable it by setting this to FALSE, but |
|
385 | + * be aware that model objects being used could get out-of-sync with the database |
|
386 | + * @return int number of items updated |
|
387 | + */ |
|
388 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
389 | + { |
|
390 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
391 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
392 | + } |
|
393 | 393 | } |
@@ -1,7 +1,7 @@ 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 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
4 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected function __construct($timezone = null) |
39 | 39 | { |
40 | - if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
40 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | 41 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
42 | 42 | } |
43 | 43 | parent::__construct($timezone); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
178 | 178 | { |
179 | - if (! isset($query_params['default_where_conditions'])) { |
|
179 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
180 | 180 | $query_params['default_where_conditions'] = 'minimum'; |
181 | 181 | } |
182 | 182 | return $query_params; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function delete_or_restore_by_ID($delete = true, $ID = false) |
306 | 306 | { |
307 | - if (! $ID) { |
|
307 | + if ( ! $ID) { |
|
308 | 308 | return false; |
309 | 309 | } |
310 | 310 | if ( |
@@ -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 | * Event Espresso |
@@ -26,55 +26,55 @@ discard block |
||
26 | 26 | { |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * Overrides parent _delete() so that we do soft deletes. |
|
31 | - * |
|
32 | - * @return bool|int |
|
33 | - */ |
|
34 | - protected function _delete() |
|
35 | - { |
|
36 | - return $this->delete_or_restore(); |
|
37 | - } |
|
29 | + /** |
|
30 | + * Overrides parent _delete() so that we do soft deletes. |
|
31 | + * |
|
32 | + * @return bool|int |
|
33 | + */ |
|
34 | + protected function _delete() |
|
35 | + { |
|
36 | + return $this->delete_or_restore(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Deletes or restores this object. |
|
43 | - * |
|
44 | - * @param bool $delete true=>delete, false=>restore |
|
45 | - * @return bool|int |
|
46 | - */ |
|
47 | - public function delete_or_restore($delete = true) |
|
48 | - { |
|
49 | - /** |
|
50 | - * Called just before trashing (soft delete) or restoring a trashed item. |
|
51 | - * |
|
52 | - * @param EE_Base_Class $model_object about to be trashed or restored |
|
53 | - * @param bool $delete true the item is being trashed, false the item is being restored. |
|
54 | - */ |
|
55 | - do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete); |
|
56 | - $model = $this->get_model(); |
|
57 | - $result = $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
58 | - /** |
|
59 | - * Called just after trashing (soft delete) or restoring a trashed item. |
|
60 | - * |
|
61 | - * @param EE_Base_Class $model_object that was just trashed or restored. |
|
62 | - * @param bool $delete true the item is being trashed, false the item is being restored. |
|
63 | - * @param bool|int $result |
|
64 | - */ |
|
65 | - do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result); |
|
66 | - return $result; |
|
67 | - } |
|
41 | + /** |
|
42 | + * Deletes or restores this object. |
|
43 | + * |
|
44 | + * @param bool $delete true=>delete, false=>restore |
|
45 | + * @return bool|int |
|
46 | + */ |
|
47 | + public function delete_or_restore($delete = true) |
|
48 | + { |
|
49 | + /** |
|
50 | + * Called just before trashing (soft delete) or restoring a trashed item. |
|
51 | + * |
|
52 | + * @param EE_Base_Class $model_object about to be trashed or restored |
|
53 | + * @param bool $delete true the item is being trashed, false the item is being restored. |
|
54 | + */ |
|
55 | + do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete); |
|
56 | + $model = $this->get_model(); |
|
57 | + $result = $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
58 | + /** |
|
59 | + * Called just after trashing (soft delete) or restoring a trashed item. |
|
60 | + * |
|
61 | + * @param EE_Base_Class $model_object that was just trashed or restored. |
|
62 | + * @param bool $delete true the item is being trashed, false the item is being restored. |
|
63 | + * @param bool|int $result |
|
64 | + */ |
|
65 | + do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result); |
|
66 | + return $result; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * Performs a restoration (un-deletes) this object |
|
73 | - * |
|
74 | - * @return bool|int |
|
75 | - */ |
|
76 | - public function restore() |
|
77 | - { |
|
78 | - return $this->delete_or_restore(false); |
|
79 | - } |
|
71 | + /** |
|
72 | + * Performs a restoration (un-deletes) this object |
|
73 | + * |
|
74 | + * @return bool|int |
|
75 | + */ |
|
76 | + public function restore() |
|
77 | + { |
|
78 | + return $this->delete_or_restore(false); |
|
79 | + } |
|
80 | 80 | } |
81 | 81 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
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 | /** |