|
1
|
|
|
<?php |
|
2
|
|
|
namespace EventEspresso\core\domain\entities\shortcodes; |
|
3
|
|
|
|
|
4
|
|
|
use EE_Registry; |
|
5
|
|
|
use EventEspresso\core\services\shortcodes\EspressoShortcode; |
|
6
|
|
|
use WP_Post; |
|
7
|
|
|
|
|
8
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class EspressoThankYou |
|
14
|
|
|
* ESPRESSO_THANK_YOU shortcode |
|
15
|
|
|
* |
|
16
|
|
|
* @package Event Espresso |
|
17
|
|
|
* @author Brent Christensen |
|
18
|
|
|
* @since $VID:$ |
|
19
|
|
|
*/ |
|
20
|
|
|
class EspressoThankYou extends EspressoShortcode |
|
21
|
|
|
{ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var boolean $is_thank_you_page |
|
25
|
|
|
*/ |
|
26
|
|
|
private $is_thank_you_page = false; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* the actual shortcode tag that gets registered with WordPress |
|
30
|
|
|
* |
|
31
|
|
|
* @return string |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getTag() |
|
34
|
|
|
{ |
|
35
|
|
|
return 'ESPRESSO_THANK_YOU'; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* the time in seconds to cache the results of the processShortcode() method |
|
42
|
|
|
* 0 means the processShortcode() results will NOT be cached at all |
|
43
|
|
|
* |
|
44
|
|
|
* @return int |
|
45
|
|
|
*/ |
|
46
|
|
|
public function cacheExpiration() |
|
47
|
|
|
{ |
|
48
|
|
|
return 0; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* a place for adding any initialization code that needs to run prior to wp_header(). |
|
54
|
|
|
* this may be required for shortcodes that utilize a corresponding module, |
|
55
|
|
|
* and need to enqueue assets for that module |
|
56
|
|
|
* |
|
57
|
|
|
* @return void |
|
58
|
|
|
* @throws \EE_Error |
|
59
|
|
|
*/ |
|
60
|
|
|
public function initializeShortcode() |
|
61
|
|
|
{ |
|
62
|
|
|
global $wp_query; |
|
63
|
|
|
if (empty($wp_query->posts) || count($wp_query->posts) > 1) { |
|
64
|
|
|
return; |
|
65
|
|
|
} |
|
66
|
|
|
$post = reset($wp_query->posts); |
|
67
|
|
|
if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) { |
|
|
|
|
|
|
68
|
|
|
return; |
|
69
|
|
|
} |
|
70
|
|
|
$this->is_thank_you_page = true; |
|
71
|
|
|
\EED_Thank_You_Page::instance()->load_resources(); |
|
72
|
|
|
$this->shortcodeHasBeenInitialized(); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* callback that runs when the shortcode is encountered in post content. |
|
79
|
|
|
* IMPORTANT !!! |
|
80
|
|
|
* remember that shortcode content should be RETURNED and NOT echoed out |
|
81
|
|
|
* |
|
82
|
|
|
* @param array $attributes |
|
83
|
|
|
* @return string |
|
84
|
|
|
* @throws \EE_Error |
|
85
|
|
|
*/ |
|
86
|
|
|
public function processShortcode($attributes = array()) |
|
87
|
|
|
{ |
|
88
|
|
|
return $this->is_thank_you_page |
|
89
|
|
|
? \EED_Thank_You_Page::instance()->thank_you_page_results() |
|
90
|
|
|
: ''; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
|
|
95
|
|
|
} |
|
96
|
|
|
// End of file EspressoThankYou.php |
|
97
|
|
|
// Location: EventEspresso\core\domain\entities\shortcodes/EspressoThankYou.php |