|
1
|
|
|
<?php |
|
2
|
|
|
namespace EventEspresso\core\domain\entities\shortcodes; |
|
3
|
|
|
|
|
4
|
|
|
use EE_Cart; |
|
5
|
|
|
use EE_Registration; |
|
6
|
|
|
use EE_Registry; |
|
7
|
|
|
use EE_Transaction; |
|
8
|
|
|
use EventEspresso\core\services\shortcodes\EspressoShortcode; |
|
9
|
|
|
|
|
10
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class EspressoCancelled |
|
16
|
|
|
* generates content for the ESPRESSO_CANCELLED shortcode |
|
17
|
|
|
* |
|
18
|
|
|
* @package Event Espresso |
|
19
|
|
|
* @author Brent Christensen |
|
20
|
|
|
* @since 4.9.26 |
|
21
|
|
|
*/ |
|
22
|
|
|
class EspressoCancelled extends EspressoShortcode |
|
23
|
|
|
{ |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* the actual shortcode tag that gets registered with WordPress |
|
29
|
|
|
* |
|
30
|
|
|
* @return string |
|
31
|
|
|
*/ |
|
32
|
|
|
public function getTag() |
|
33
|
|
|
{ |
|
34
|
|
|
return 'ESPRESSO_CANCELLED'; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* the time in seconds to cache the results of the processShortcode() method |
|
41
|
|
|
* 0 means the processShortcode() results will NOT be cached at all |
|
42
|
|
|
* |
|
43
|
|
|
* @return int |
|
44
|
|
|
*/ |
|
45
|
|
|
public function cacheExpiration() |
|
46
|
|
|
{ |
|
47
|
|
|
return 0; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* a place for adding any initialization code that needs to run prior to wp_header(). |
|
53
|
|
|
* this may be required for shortcodes that utilize a corresponding module, |
|
54
|
|
|
* and need to enqueue assets for that module |
|
55
|
|
|
* |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
public function initializeShortcode() |
|
59
|
|
|
{ |
|
60
|
|
|
// required by interface, but nothing to do atm |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* callback that runs when the shortcode is encountered in post content. |
|
66
|
|
|
* IMPORTANT !!! |
|
67
|
|
|
* remember that shortcode content should be RETURNED and NOT echoed out |
|
68
|
|
|
* |
|
69
|
|
|
* @param array $attributes |
|
70
|
|
|
* @return string |
|
71
|
|
|
* @throws \EE_Error |
|
72
|
|
|
*/ |
|
73
|
|
|
public function processShortcode($attributes = array()) |
|
74
|
|
|
{ |
|
75
|
|
|
$transaction = EE_Registry::instance()->SSN->get_session_data('transaction'); |
|
76
|
|
|
if ($transaction instanceof EE_Transaction) { |
|
77
|
|
|
do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', $transaction); |
|
78
|
|
|
$registrations = $transaction->registrations(); |
|
79
|
|
|
foreach ($registrations as $registration) { |
|
80
|
|
|
if ($registration instanceof EE_Registration) { |
|
81
|
|
|
do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__registration', $registration); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
do_action('AHEE__EES_Espresso_Cancelled__process_shortcode__clear_session'); |
|
86
|
|
|
// remove all unwanted records from the db |
|
87
|
|
|
if (EE_Registry::instance()->CART instanceof EE_Cart) { |
|
88
|
|
|
EE_Registry::instance()->CART->delete_cart(); |
|
89
|
|
|
} |
|
90
|
|
|
EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
91
|
|
|
return sprintf( |
|
92
|
|
|
__( |
|
93
|
|
|
'%sAll unsaved registration information entered during this session has been deleted.%s', |
|
94
|
|
|
'event_espresso' |
|
95
|
|
|
), |
|
96
|
|
|
'<p class="ee-registrations-cancelled-pg ee-attention">', |
|
97
|
|
|
'</p>' |
|
98
|
|
|
); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
} |
|
102
|
|
|
// End of file EspressoCancelled.php |
|
103
|
|
|
// Location: EventEspresso\core\domain\entities\shortcodes/EspressoCancelled.php |