@@ -21,62 +21,62 @@ |
||
21 | 21 | |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * the actual shortcode tag that gets registered with WordPress |
|
26 | - * |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function getTag() |
|
30 | - { |
|
31 | - return 'ESPRESSO_TICKET_SELECTOR'; |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * the time in seconds to cache the results of the processShortcode() method |
|
38 | - * 0 means the processShortcode() results will NOT be cached at all |
|
39 | - * |
|
40 | - * @return int |
|
41 | - */ |
|
42 | - public function cacheExpiration() |
|
43 | - { |
|
44 | - return MINUTE_IN_SECONDS * 5; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | - * this may be required for shortcodes that utilize a corresponding module, |
|
51 | - * and need to enqueue assets for that module |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function initializeShortcode() |
|
56 | - { |
|
57 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * callback that runs when the shortcode is encountered in post content. |
|
64 | - * IMPORTANT !!! |
|
65 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
66 | - * |
|
67 | - * @param array $attributes |
|
68 | - * @return string |
|
69 | - */ |
|
70 | - public function processShortcode($attributes = array()) |
|
71 | - { |
|
72 | - extract($attributes, EXTR_OVERWRITE); |
|
73 | - $event_id = isset($event_id) ? $event_id : 0; |
|
74 | - $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
75 | - ob_start(); |
|
76 | - do_action('AHEE_event_details_before_post', $event_id); |
|
77 | - espresso_ticket_selector($event); |
|
78 | - do_action('AHEE_event_details_after_post'); |
|
79 | - return ob_get_clean(); } |
|
24 | + /** |
|
25 | + * the actual shortcode tag that gets registered with WordPress |
|
26 | + * |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function getTag() |
|
30 | + { |
|
31 | + return 'ESPRESSO_TICKET_SELECTOR'; |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * the time in seconds to cache the results of the processShortcode() method |
|
38 | + * 0 means the processShortcode() results will NOT be cached at all |
|
39 | + * |
|
40 | + * @return int |
|
41 | + */ |
|
42 | + public function cacheExpiration() |
|
43 | + { |
|
44 | + return MINUTE_IN_SECONDS * 5; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | + * this may be required for shortcodes that utilize a corresponding module, |
|
51 | + * and need to enqueue assets for that module |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function initializeShortcode() |
|
56 | + { |
|
57 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * callback that runs when the shortcode is encountered in post content. |
|
64 | + * IMPORTANT !!! |
|
65 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
66 | + * |
|
67 | + * @param array $attributes |
|
68 | + * @return string |
|
69 | + */ |
|
70 | + public function processShortcode($attributes = array()) |
|
71 | + { |
|
72 | + extract($attributes, EXTR_OVERWRITE); |
|
73 | + $event_id = isset($event_id) ? $event_id : 0; |
|
74 | + $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($event_id); |
|
75 | + ob_start(); |
|
76 | + do_action('AHEE_event_details_before_post', $event_id); |
|
77 | + espresso_ticket_selector($event); |
|
78 | + do_action('AHEE_event_details_after_post'); |
|
79 | + return ob_get_clean(); } |
|
80 | 80 | } |
81 | 81 | // End of file EspressoTicketSelector.php |
82 | 82 | // Location: EventEspresso\core\domain\entities\shortcodes/EspressoTicketSelector.php |
83 | 83 | \ No newline at end of file |
@@ -20,74 +20,74 @@ |
||
20 | 20 | class EspressoThankYou extends EspressoShortcode |
21 | 21 | { |
22 | 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 | - } |
|
73 | - |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * callback that runs when the shortcode is encountered in post content. |
|
78 | - * IMPORTANT !!! |
|
79 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
80 | - * |
|
81 | - * @param array $attributes |
|
82 | - * @return string |
|
83 | - * @throws \EE_Error |
|
84 | - */ |
|
85 | - public function processShortcode($attributes = array()) |
|
86 | - { |
|
87 | - return $this->is_thank_you_page |
|
88 | - ? \EED_Thank_You_Page::instance()->thank_you_page_results() |
|
89 | - : ''; |
|
90 | - } |
|
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 | + } |
|
73 | + |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * callback that runs when the shortcode is encountered in post content. |
|
78 | + * IMPORTANT !!! |
|
79 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
80 | + * |
|
81 | + * @param array $attributes |
|
82 | + * @return string |
|
83 | + * @throws \EE_Error |
|
84 | + */ |
|
85 | + public function processShortcode($attributes = array()) |
|
86 | + { |
|
87 | + return $this->is_thank_you_page |
|
88 | + ? \EED_Thank_You_Page::instance()->thank_you_page_results() |
|
89 | + : ''; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | |
93 | 93 |
@@ -27,91 +27,91 @@ |
||
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * the actual shortcode tag that gets registered with WordPress |
|
32 | - * |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function getTag() |
|
36 | - { |
|
37 | - return 'ESPRESSO_TXN_PAGE'; |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * the time in seconds to cache the results of the processShortcode() method |
|
44 | - * 0 means the processShortcode() results will NOT be cached at all |
|
45 | - * |
|
46 | - * @return int |
|
47 | - */ |
|
48 | - public function cacheExpiration() |
|
49 | - { |
|
50 | - return 0; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
56 | - * this may be required for shortcodes that utilize a corresponding module, |
|
57 | - * and need to enqueue assets for that module |
|
58 | - * |
|
59 | - * @return void |
|
60 | - * @throws \Exception |
|
61 | - * @throws \EE_Error |
|
62 | - */ |
|
63 | - public function initializeShortcode() |
|
64 | - { |
|
65 | - $transaction = null; |
|
66 | - if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
67 | - /** @var EEM_Transaction $EEM_Transaction */ |
|
68 | - $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
69 | - $transaction = $EEM_Transaction->get_transaction_from_reg_url_link(); |
|
70 | - } |
|
71 | - if ($transaction instanceof EE_Transaction) { |
|
72 | - $payment_method = null; |
|
73 | - $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null); |
|
74 | - if ($payment_method_slug) { |
|
75 | - $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug); |
|
76 | - } |
|
77 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) { |
|
78 | - $gateway = $payment_method->type_obj()->get_gateway(); |
|
79 | - if ( |
|
80 | - $gateway instanceof EE_Offsite_Gateway |
|
81 | - && $gateway->handle_IPN_in_this_request( |
|
82 | - \EE_Registry::instance()->REQ->params(), |
|
83 | - true |
|
84 | - ) |
|
85 | - ) { |
|
86 | - /** @type EE_Payment_Processor $payment_processor */ |
|
87 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
88 | - $payment_processor->process_ipn($_REQUEST, $transaction, $payment_method); |
|
89 | - } |
|
90 | - } |
|
91 | - //allow gateways to add a filter to stop rendering the page |
|
92 | - if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) { |
|
93 | - exit; |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * callback that runs when the shortcode is encountered in post content. |
|
102 | - * IMPORTANT !!! |
|
103 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
104 | - * |
|
105 | - * @param array $attributes |
|
106 | - * @return string |
|
107 | - */ |
|
108 | - public function processShortcode($attributes = array()) |
|
109 | - { |
|
110 | - return esc_html__( |
|
111 | - 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', |
|
112 | - 'event_espresso' |
|
113 | - ); |
|
114 | - } |
|
30 | + /** |
|
31 | + * the actual shortcode tag that gets registered with WordPress |
|
32 | + * |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function getTag() |
|
36 | + { |
|
37 | + return 'ESPRESSO_TXN_PAGE'; |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * the time in seconds to cache the results of the processShortcode() method |
|
44 | + * 0 means the processShortcode() results will NOT be cached at all |
|
45 | + * |
|
46 | + * @return int |
|
47 | + */ |
|
48 | + public function cacheExpiration() |
|
49 | + { |
|
50 | + return 0; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
56 | + * this may be required for shortcodes that utilize a corresponding module, |
|
57 | + * and need to enqueue assets for that module |
|
58 | + * |
|
59 | + * @return void |
|
60 | + * @throws \Exception |
|
61 | + * @throws \EE_Error |
|
62 | + */ |
|
63 | + public function initializeShortcode() |
|
64 | + { |
|
65 | + $transaction = null; |
|
66 | + if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
67 | + /** @var EEM_Transaction $EEM_Transaction */ |
|
68 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
69 | + $transaction = $EEM_Transaction->get_transaction_from_reg_url_link(); |
|
70 | + } |
|
71 | + if ($transaction instanceof EE_Transaction) { |
|
72 | + $payment_method = null; |
|
73 | + $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null); |
|
74 | + if ($payment_method_slug) { |
|
75 | + $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug); |
|
76 | + } |
|
77 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) { |
|
78 | + $gateway = $payment_method->type_obj()->get_gateway(); |
|
79 | + if ( |
|
80 | + $gateway instanceof EE_Offsite_Gateway |
|
81 | + && $gateway->handle_IPN_in_this_request( |
|
82 | + \EE_Registry::instance()->REQ->params(), |
|
83 | + true |
|
84 | + ) |
|
85 | + ) { |
|
86 | + /** @type EE_Payment_Processor $payment_processor */ |
|
87 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
88 | + $payment_processor->process_ipn($_REQUEST, $transaction, $payment_method); |
|
89 | + } |
|
90 | + } |
|
91 | + //allow gateways to add a filter to stop rendering the page |
|
92 | + if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) { |
|
93 | + exit; |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * callback that runs when the shortcode is encountered in post content. |
|
102 | + * IMPORTANT !!! |
|
103 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
104 | + * |
|
105 | + * @param array $attributes |
|
106 | + * @return string |
|
107 | + */ |
|
108 | + public function processShortcode($attributes = array()) |
|
109 | + { |
|
110 | + return esc_html__( |
|
111 | + 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', |
|
112 | + 'event_espresso' |
|
113 | + ); |
|
114 | + } |
|
115 | 115 | } |
116 | 116 | // End of file EspressoTxnPage.php |
117 | 117 | // Location: EventEspresso\core\domain\entities\shortcodes/EspressoTxnPage.php |
118 | 118 | \ No newline at end of file |
@@ -28,245 +28,245 @@ |
||
28 | 28 | class EspressoEventAttendees extends EspressoShortcode |
29 | 29 | { |
30 | 30 | |
31 | - private $query_params = array( |
|
32 | - 0 => array() |
|
33 | - ); |
|
34 | - |
|
35 | - private $template_args = array( |
|
36 | - 'contacts' => array(), |
|
37 | - 'event' => null, |
|
38 | - 'datetime' => null, |
|
39 | - 'ticket' => null, |
|
40 | - ); |
|
41 | - |
|
42 | - /** |
|
43 | - * the actual shortcode tag that gets registered with WordPress |
|
44 | - * |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function getTag() |
|
48 | - { |
|
49 | - return 'ESPRESSO_EVENT_ATTENDEES'; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * the time in seconds to cache the results of the processShortcode() method |
|
56 | - * 0 means the processShortcode() results will NOT be cached at all |
|
57 | - * |
|
58 | - * @return int |
|
59 | - */ |
|
60 | - public function cacheExpiration() |
|
61 | - { |
|
62 | - return HOUR_IN_SECONDS; |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
69 | - * this may be required for shortcodes that utilize a corresponding module, |
|
70 | - * and need to enqueue assets for that module |
|
71 | - * |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - public function initializeShortcode() |
|
75 | - { |
|
76 | - // required by interface, but nothing to do atm |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event. |
|
83 | - * [ESPRESSO_EVENT_ATTENDEES] - defaults to attendees for earliest active event, or earliest upcoming event. |
|
84 | - * [ESPRESSO_EVENT_ATTENDEES event_id=123] - attendees for specific event. |
|
85 | - * [ESPRESSO_EVENT_ATTENDEES datetime_id=245] - attendees for a specific datetime. |
|
86 | - * [ESPRESSO_EVENT_ATTENDEES ticket_id=123] - attendees for a specific ticket. |
|
87 | - * [ESPRESSO_EVENT_ATTENDEES status=all] - specific registration status (use status id) or all for all attendees |
|
88 | - * regardless of status. Note default is to only return approved attendees |
|
89 | - * [ESPRESSO_EVENT_ATTENDEES show_gravatar=true] - default is to not return gravatar. Otherwise if this is set |
|
90 | - * then return gravatar for email address given. |
|
91 | - * Note: because of the relationship between event_id, ticket_id, and datetime_id. |
|
92 | - * If more than one of those params is included then preference is given to the following: |
|
93 | - * - event_id is used whenever its present and any others are ignored. |
|
94 | - * - if no event_id then datetime is used whenever its present and any others are ignored. |
|
95 | - * - otherwise ticket_id is used if present. |
|
96 | - * |
|
97 | - * @param array $attributes |
|
98 | - * @return string |
|
99 | - * @throws \EE_Error |
|
100 | - */ |
|
101 | - public function processShortcode($attributes = array()) |
|
102 | - { |
|
103 | - // grab attributes and merge with defaults |
|
104 | - $attributes = $this->getAttributes((array)$attributes); |
|
105 | - // add attributes to template args |
|
106 | - $this->template_args['show_gravatar'] = $attributes['show_gravatar']; |
|
107 | - // add required objects: event, datetime, and ticket |
|
108 | - $this->template_args['event'] = $this->getEventAndQueryParams($attributes); |
|
109 | - $this->template_args['datetime'] = $this->getDatetimeAndQueryParams($attributes); |
|
110 | - $this->template_args['ticket'] = $this->getTicketAndQueryParams($attributes); |
|
111 | - |
|
112 | - // if any of the above objects is invalid or missing, |
|
113 | - // then there was an invalid parameter or the shortcode was used incorrectly |
|
114 | - // so when WP_DEBUG is set and true, we'll show a message, |
|
115 | - // otherwise we'll just return an empty string. |
|
116 | - if ( |
|
117 | - ! $this->template_args['event'] instanceof EE_Event |
|
118 | - || empty($this->query_params[0]) |
|
119 | - || ($attributes['datetime_id'] && ! $this->template_args['datetime'] instanceof EE_Datetime) |
|
120 | - || ($attributes['ticket_id'] && ! $this->template_args['ticket'] instanceof EE_Ticket) |
|
121 | - ) { |
|
122 | - if (WP_DEBUG) { |
|
123 | - return '<div class="important-notice ee-attention">' |
|
124 | - . esc_html__('The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly. Please double check the arguments you used for any typos. In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.', |
|
125 | - 'event_espresso') |
|
126 | - . '</div>'; |
|
127 | - } else { |
|
128 | - return ''; |
|
129 | - } |
|
130 | - } |
|
131 | - $this->setAdditionalQueryParams($attributes); |
|
132 | - //get contacts! |
|
133 | - $this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params); |
|
134 | - //all set let's load up the template and return. |
|
135 | - return EEH_Template::locate_template('loop-espresso_event_attendees.php', $this->template_args, true, true); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * merge incoming attributes with filtered defaults |
|
142 | - * |
|
143 | - * @param array $attributes |
|
144 | - * @return array |
|
145 | - */ |
|
146 | - private function getAttributes(array $attributes) |
|
147 | - { |
|
148 | - return array_merge( |
|
149 | - (array) apply_filters( |
|
150 | - 'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts', |
|
151 | - array( |
|
152 | - 'event_id' => null, |
|
153 | - 'datetime_id' => null, |
|
154 | - 'ticket_id' => null, |
|
155 | - 'status' => EEM_Registration::status_id_approved, |
|
156 | - 'show_gravatar' => false |
|
157 | - ) |
|
158 | - ), |
|
159 | - $attributes |
|
160 | - ); |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * @param array $attributes |
|
167 | - * @return EE_Event|null |
|
168 | - * @throws \EE_Error |
|
169 | - */ |
|
170 | - private function getEventAndQueryParams(array $attributes){ |
|
171 | - if ( ! empty($attributes['event_id'])) { |
|
172 | - $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']); |
|
173 | - if ($event instanceof EE_Event) { |
|
174 | - $this->query_params[0]['Registration.EVT_ID'] = $attributes['event_id']; |
|
175 | - return $event; |
|
176 | - } |
|
177 | - } |
|
178 | - //seems like is_espresso_event_single() isn't working as expected. So using alternate method. |
|
179 | - if (is_single() && is_espresso_event()) { |
|
180 | - $event = EEH_Event_View::get_event(); |
|
181 | - if ($event instanceof EE_Event) { |
|
182 | - $this->query_params[0]['Registration.EVT_ID'] = $event->ID(); |
|
183 | - return $event; |
|
184 | - } |
|
185 | - } |
|
186 | - // one last shot... |
|
187 | - // try getting the earliest active event |
|
188 | - $events = EEM_Event::instance()->get_active_events(array( |
|
189 | - 'limit' => 1, |
|
190 | - 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') |
|
191 | - )); |
|
192 | - // if none then get the next upcoming |
|
193 | - $events = empty($events) |
|
194 | - ? EEM_Event::instance()->get_upcoming_events(array( |
|
195 | - 'limit' => 1, |
|
196 | - 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') |
|
197 | - )) |
|
198 | - : $events; |
|
199 | - $event = reset($events); |
|
200 | - if ($event instanceof EE_Event) { |
|
201 | - $this->query_params[0]['Registration.EVT_ID'] = $event->ID(); |
|
202 | - return $event; |
|
203 | - } |
|
204 | - return null; |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * @param array $attributes |
|
211 | - * @return EE_Datetime|null |
|
212 | - */ |
|
213 | - private function getDatetimeAndQueryParams(array $attributes) |
|
214 | - { |
|
215 | - if ( ! empty($attributes['datetime_id'])) { |
|
216 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']); |
|
217 | - if ($datetime instanceof EE_Datetime) { |
|
218 | - $this->query_params[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id']; |
|
219 | - $this->query_params['default_where_conditions'] = 'this_model_only'; |
|
220 | - if ( ! $this->template_args['event'] instanceof EE_Event) { |
|
221 | - $this->template_args['event'] = $datetime->event(); |
|
222 | - } |
|
223 | - return $datetime; |
|
224 | - } |
|
225 | - } |
|
226 | - return null; |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * @param array $attributes |
|
233 | - * @return \EE_Base_Class|null |
|
234 | - * @throws \EE_Error |
|
235 | - */ |
|
236 | - private function getTicketAndQueryParams(array $attributes) |
|
237 | - { |
|
238 | - if ( ! empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) { |
|
239 | - $ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']); |
|
240 | - if ($ticket instanceof EE_Ticket) { |
|
241 | - $this->query_params[0]['Registration.TKT_ID'] = $attributes['ticket_id']; |
|
242 | - if ( ! $this->template_args['event'] instanceof EE_Event) { |
|
243 | - $this->template_args['event'] = $ticket->first_datetime() instanceof EE_Datetime |
|
244 | - ? $ticket->first_datetime()->event() |
|
245 | - : null; |
|
246 | - } |
|
247 | - return $ticket; |
|
248 | - } |
|
249 | - } |
|
250 | - return null; |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * @param array $attributes |
|
257 | - */ |
|
258 | - private function setAdditionalQueryParams(array $attributes) |
|
259 | - { |
|
260 | - $reg_status_array = EEM_Registration::reg_status_array(); |
|
261 | - if ($attributes['status'] !== 'all' && isset($reg_status_array[$attributes['status']])) { |
|
262 | - $this->query_params[0]['Registration.STS_ID'] = $attributes['status']; |
|
263 | - } |
|
264 | - $this->query_params['group_by'] = array('ATT_ID'); |
|
265 | - $this->query_params['order_by'] = (array) apply_filters( |
|
266 | - 'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by', |
|
267 | - array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC') |
|
268 | - ); |
|
269 | - } |
|
31 | + private $query_params = array( |
|
32 | + 0 => array() |
|
33 | + ); |
|
34 | + |
|
35 | + private $template_args = array( |
|
36 | + 'contacts' => array(), |
|
37 | + 'event' => null, |
|
38 | + 'datetime' => null, |
|
39 | + 'ticket' => null, |
|
40 | + ); |
|
41 | + |
|
42 | + /** |
|
43 | + * the actual shortcode tag that gets registered with WordPress |
|
44 | + * |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function getTag() |
|
48 | + { |
|
49 | + return 'ESPRESSO_EVENT_ATTENDEES'; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * the time in seconds to cache the results of the processShortcode() method |
|
56 | + * 0 means the processShortcode() results will NOT be cached at all |
|
57 | + * |
|
58 | + * @return int |
|
59 | + */ |
|
60 | + public function cacheExpiration() |
|
61 | + { |
|
62 | + return HOUR_IN_SECONDS; |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
69 | + * this may be required for shortcodes that utilize a corresponding module, |
|
70 | + * and need to enqueue assets for that module |
|
71 | + * |
|
72 | + * @return void |
|
73 | + */ |
|
74 | + public function initializeShortcode() |
|
75 | + { |
|
76 | + // required by interface, but nothing to do atm |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * process_shortcode - ESPRESSO_EVENT_ATTENDEES - Returns a list of attendees to an event. |
|
83 | + * [ESPRESSO_EVENT_ATTENDEES] - defaults to attendees for earliest active event, or earliest upcoming event. |
|
84 | + * [ESPRESSO_EVENT_ATTENDEES event_id=123] - attendees for specific event. |
|
85 | + * [ESPRESSO_EVENT_ATTENDEES datetime_id=245] - attendees for a specific datetime. |
|
86 | + * [ESPRESSO_EVENT_ATTENDEES ticket_id=123] - attendees for a specific ticket. |
|
87 | + * [ESPRESSO_EVENT_ATTENDEES status=all] - specific registration status (use status id) or all for all attendees |
|
88 | + * regardless of status. Note default is to only return approved attendees |
|
89 | + * [ESPRESSO_EVENT_ATTENDEES show_gravatar=true] - default is to not return gravatar. Otherwise if this is set |
|
90 | + * then return gravatar for email address given. |
|
91 | + * Note: because of the relationship between event_id, ticket_id, and datetime_id. |
|
92 | + * If more than one of those params is included then preference is given to the following: |
|
93 | + * - event_id is used whenever its present and any others are ignored. |
|
94 | + * - if no event_id then datetime is used whenever its present and any others are ignored. |
|
95 | + * - otherwise ticket_id is used if present. |
|
96 | + * |
|
97 | + * @param array $attributes |
|
98 | + * @return string |
|
99 | + * @throws \EE_Error |
|
100 | + */ |
|
101 | + public function processShortcode($attributes = array()) |
|
102 | + { |
|
103 | + // grab attributes and merge with defaults |
|
104 | + $attributes = $this->getAttributes((array)$attributes); |
|
105 | + // add attributes to template args |
|
106 | + $this->template_args['show_gravatar'] = $attributes['show_gravatar']; |
|
107 | + // add required objects: event, datetime, and ticket |
|
108 | + $this->template_args['event'] = $this->getEventAndQueryParams($attributes); |
|
109 | + $this->template_args['datetime'] = $this->getDatetimeAndQueryParams($attributes); |
|
110 | + $this->template_args['ticket'] = $this->getTicketAndQueryParams($attributes); |
|
111 | + |
|
112 | + // if any of the above objects is invalid or missing, |
|
113 | + // then there was an invalid parameter or the shortcode was used incorrectly |
|
114 | + // so when WP_DEBUG is set and true, we'll show a message, |
|
115 | + // otherwise we'll just return an empty string. |
|
116 | + if ( |
|
117 | + ! $this->template_args['event'] instanceof EE_Event |
|
118 | + || empty($this->query_params[0]) |
|
119 | + || ($attributes['datetime_id'] && ! $this->template_args['datetime'] instanceof EE_Datetime) |
|
120 | + || ($attributes['ticket_id'] && ! $this->template_args['ticket'] instanceof EE_Ticket) |
|
121 | + ) { |
|
122 | + if (WP_DEBUG) { |
|
123 | + return '<div class="important-notice ee-attention">' |
|
124 | + . esc_html__('The [ESPRESSO_EVENT_ATTENDEES] shortcode has been used incorrectly. Please double check the arguments you used for any typos. In the case of ID type arguments, its possible the given ID does not correspond to existing data in the database.', |
|
125 | + 'event_espresso') |
|
126 | + . '</div>'; |
|
127 | + } else { |
|
128 | + return ''; |
|
129 | + } |
|
130 | + } |
|
131 | + $this->setAdditionalQueryParams($attributes); |
|
132 | + //get contacts! |
|
133 | + $this->template_args['contacts'] = EEM_Attendee::instance()->get_all($this->query_params); |
|
134 | + //all set let's load up the template and return. |
|
135 | + return EEH_Template::locate_template('loop-espresso_event_attendees.php', $this->template_args, true, true); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * merge incoming attributes with filtered defaults |
|
142 | + * |
|
143 | + * @param array $attributes |
|
144 | + * @return array |
|
145 | + */ |
|
146 | + private function getAttributes(array $attributes) |
|
147 | + { |
|
148 | + return array_merge( |
|
149 | + (array) apply_filters( |
|
150 | + 'EES_Espresso_Event_Attendees__process_shortcode__default_shortcode_atts', |
|
151 | + array( |
|
152 | + 'event_id' => null, |
|
153 | + 'datetime_id' => null, |
|
154 | + 'ticket_id' => null, |
|
155 | + 'status' => EEM_Registration::status_id_approved, |
|
156 | + 'show_gravatar' => false |
|
157 | + ) |
|
158 | + ), |
|
159 | + $attributes |
|
160 | + ); |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * @param array $attributes |
|
167 | + * @return EE_Event|null |
|
168 | + * @throws \EE_Error |
|
169 | + */ |
|
170 | + private function getEventAndQueryParams(array $attributes){ |
|
171 | + if ( ! empty($attributes['event_id'])) { |
|
172 | + $event = EEM_Event::instance()->get_one_by_ID($attributes['event_id']); |
|
173 | + if ($event instanceof EE_Event) { |
|
174 | + $this->query_params[0]['Registration.EVT_ID'] = $attributes['event_id']; |
|
175 | + return $event; |
|
176 | + } |
|
177 | + } |
|
178 | + //seems like is_espresso_event_single() isn't working as expected. So using alternate method. |
|
179 | + if (is_single() && is_espresso_event()) { |
|
180 | + $event = EEH_Event_View::get_event(); |
|
181 | + if ($event instanceof EE_Event) { |
|
182 | + $this->query_params[0]['Registration.EVT_ID'] = $event->ID(); |
|
183 | + return $event; |
|
184 | + } |
|
185 | + } |
|
186 | + // one last shot... |
|
187 | + // try getting the earliest active event |
|
188 | + $events = EEM_Event::instance()->get_active_events(array( |
|
189 | + 'limit' => 1, |
|
190 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') |
|
191 | + )); |
|
192 | + // if none then get the next upcoming |
|
193 | + $events = empty($events) |
|
194 | + ? EEM_Event::instance()->get_upcoming_events(array( |
|
195 | + 'limit' => 1, |
|
196 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'ASC') |
|
197 | + )) |
|
198 | + : $events; |
|
199 | + $event = reset($events); |
|
200 | + if ($event instanceof EE_Event) { |
|
201 | + $this->query_params[0]['Registration.EVT_ID'] = $event->ID(); |
|
202 | + return $event; |
|
203 | + } |
|
204 | + return null; |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * @param array $attributes |
|
211 | + * @return EE_Datetime|null |
|
212 | + */ |
|
213 | + private function getDatetimeAndQueryParams(array $attributes) |
|
214 | + { |
|
215 | + if ( ! empty($attributes['datetime_id'])) { |
|
216 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($attributes['datetime_id']); |
|
217 | + if ($datetime instanceof EE_Datetime) { |
|
218 | + $this->query_params[0]['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetime_id']; |
|
219 | + $this->query_params['default_where_conditions'] = 'this_model_only'; |
|
220 | + if ( ! $this->template_args['event'] instanceof EE_Event) { |
|
221 | + $this->template_args['event'] = $datetime->event(); |
|
222 | + } |
|
223 | + return $datetime; |
|
224 | + } |
|
225 | + } |
|
226 | + return null; |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * @param array $attributes |
|
233 | + * @return \EE_Base_Class|null |
|
234 | + * @throws \EE_Error |
|
235 | + */ |
|
236 | + private function getTicketAndQueryParams(array $attributes) |
|
237 | + { |
|
238 | + if ( ! empty($attributes['ticket_id']) && empty($attributes['event_id']) && empty($attributes['datetime_id'])) { |
|
239 | + $ticket = EEM_Ticket::instance()->get_one_by_ID($attributes['ticket_id']); |
|
240 | + if ($ticket instanceof EE_Ticket) { |
|
241 | + $this->query_params[0]['Registration.TKT_ID'] = $attributes['ticket_id']; |
|
242 | + if ( ! $this->template_args['event'] instanceof EE_Event) { |
|
243 | + $this->template_args['event'] = $ticket->first_datetime() instanceof EE_Datetime |
|
244 | + ? $ticket->first_datetime()->event() |
|
245 | + : null; |
|
246 | + } |
|
247 | + return $ticket; |
|
248 | + } |
|
249 | + } |
|
250 | + return null; |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * @param array $attributes |
|
257 | + */ |
|
258 | + private function setAdditionalQueryParams(array $attributes) |
|
259 | + { |
|
260 | + $reg_status_array = EEM_Registration::reg_status_array(); |
|
261 | + if ($attributes['status'] !== 'all' && isset($reg_status_array[$attributes['status']])) { |
|
262 | + $this->query_params[0]['Registration.STS_ID'] = $attributes['status']; |
|
263 | + } |
|
264 | + $this->query_params['group_by'] = array('ATT_ID'); |
|
265 | + $this->query_params['order_by'] = (array) apply_filters( |
|
266 | + 'FHEE__EES_Espresso_Event_Attendees__process_shortcode__order_by', |
|
267 | + array('ATT_lname' => 'ASC', 'ATT_fname' => 'ASC') |
|
268 | + ); |
|
269 | + } |
|
270 | 270 | |
271 | 271 | |
272 | 272 |
@@ -24,79 +24,79 @@ |
||
24 | 24 | |
25 | 25 | |
26 | 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 | - } |
|
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 | 100 | |
101 | 101 | } |
102 | 102 | // End of file EspressoCancelled.php |
@@ -21,58 +21,58 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * the actual shortcode tag that gets registered with WordPress |
|
26 | - * |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function getTag() |
|
30 | - { |
|
31 | - return 'ESPRESSO_CHECKOUT'; |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * the time in seconds to cache the results of the processShortcode() method |
|
38 | - * 0 means the processShortcode() results will NOT be cached at all |
|
39 | - * |
|
40 | - * @return int |
|
41 | - */ |
|
42 | - public function cacheExpiration() |
|
43 | - { |
|
44 | - return 0; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | - * this may be required for shortcodes that utilize a corresponding module, |
|
51 | - * and need to enqueue assets for that module |
|
52 | - * |
|
53 | - * @return void |
|
54 | - * @throws \EE_Error |
|
55 | - */ |
|
56 | - public function initializeShortcode() |
|
57 | - { |
|
58 | - global $wp_query; |
|
59 | - EED_Single_Page_Checkout::init($wp_query); |
|
60 | - } |
|
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 | - */ |
|
72 | - public function processShortcode($attributes = array()) |
|
73 | - { |
|
74 | - return EE_Registry::instance()->REQ->get_output(); |
|
75 | - } |
|
24 | + /** |
|
25 | + * the actual shortcode tag that gets registered with WordPress |
|
26 | + * |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function getTag() |
|
30 | + { |
|
31 | + return 'ESPRESSO_CHECKOUT'; |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * the time in seconds to cache the results of the processShortcode() method |
|
38 | + * 0 means the processShortcode() results will NOT be cached at all |
|
39 | + * |
|
40 | + * @return int |
|
41 | + */ |
|
42 | + public function cacheExpiration() |
|
43 | + { |
|
44 | + return 0; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | + * this may be required for shortcodes that utilize a corresponding module, |
|
51 | + * and need to enqueue assets for that module |
|
52 | + * |
|
53 | + * @return void |
|
54 | + * @throws \EE_Error |
|
55 | + */ |
|
56 | + public function initializeShortcode() |
|
57 | + { |
|
58 | + global $wp_query; |
|
59 | + EED_Single_Page_Checkout::init($wp_query); |
|
60 | + } |
|
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 | + */ |
|
72 | + public function processShortcode($attributes = array()) |
|
73 | + { |
|
74 | + return EE_Registry::instance()->REQ->get_output(); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 |
@@ -23,107 +23,107 @@ |
||
23 | 23 | |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * the actual shortcode tag that gets registered with WordPress |
|
28 | - * |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - public function getTag() |
|
32 | - { |
|
33 | - return 'ESPRESSO_EVENTS'; |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * the time in seconds to cache the results of the processShortcode() method |
|
40 | - * 0 means the processShortcode() results will NOT be cached at all |
|
41 | - * |
|
42 | - * @return int |
|
43 | - */ |
|
44 | - public function cacheExpiration() |
|
45 | - { |
|
46 | - return MINUTE_IN_SECONDS * 15; |
|
47 | - } |
|
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 | - EED_Events_Archive::instance()->event_list(); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * callback that runs when the shortcode is encountered in post content. |
|
67 | - * IMPORTANT !!! |
|
68 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
69 | - * |
|
70 | - * @param array $attributes |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function processShortcode($attributes = array()) |
|
74 | - { |
|
75 | - // grab attributes and merge with defaults |
|
76 | - $attributes = $this->getAttributes((array)$attributes); |
|
77 | - // make sure we use the_excerpt() |
|
78 | - add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
79 | - // apply query filters |
|
80 | - add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
81 | - // run the query |
|
82 | - global $wp_query; |
|
83 | - // yes we have to overwrite the main wp query, but it's ok... |
|
84 | - // we're going to reset it again below, so everything will be Hunky Dory (amazing album) |
|
85 | - $wp_query = new EventListQuery($attributes); |
|
86 | - // check what template is loaded and load filters accordingly |
|
87 | - EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
88 | - // load our template |
|
89 | - $event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), true, true); |
|
90 | - // now reset the query and postdata |
|
91 | - wp_reset_query(); |
|
92 | - wp_reset_postdata(); |
|
93 | - EED_Events_Archive::remove_all_events_archive_filters(); |
|
94 | - // remove query filters |
|
95 | - remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
96 | - // pull our content from the output buffer and return it |
|
97 | - return $event_list; |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * merge incoming attributes with filtered defaults |
|
104 | - * |
|
105 | - * @param array $attributes |
|
106 | - * @return array |
|
107 | - */ |
|
108 | - private function getAttributes(array $attributes) |
|
109 | - { |
|
110 | - return array_merge( |
|
111 | - (array)apply_filters( |
|
112 | - 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
113 | - array( |
|
114 | - 'title' => null, |
|
115 | - 'limit' => 10, |
|
116 | - 'css_class' => null, |
|
117 | - 'show_expired' => false, |
|
118 | - 'month' => null, |
|
119 | - 'category_slug' => null, |
|
120 | - 'order_by' => 'start_date', |
|
121 | - 'sort' => 'ASC', |
|
122 | - ) |
|
123 | - ), |
|
124 | - $attributes |
|
125 | - ); |
|
126 | - } |
|
26 | + /** |
|
27 | + * the actual shortcode tag that gets registered with WordPress |
|
28 | + * |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + public function getTag() |
|
32 | + { |
|
33 | + return 'ESPRESSO_EVENTS'; |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * the time in seconds to cache the results of the processShortcode() method |
|
40 | + * 0 means the processShortcode() results will NOT be cached at all |
|
41 | + * |
|
42 | + * @return int |
|
43 | + */ |
|
44 | + public function cacheExpiration() |
|
45 | + { |
|
46 | + return MINUTE_IN_SECONDS * 15; |
|
47 | + } |
|
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 | + EED_Events_Archive::instance()->event_list(); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * callback that runs when the shortcode is encountered in post content. |
|
67 | + * IMPORTANT !!! |
|
68 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
69 | + * |
|
70 | + * @param array $attributes |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function processShortcode($attributes = array()) |
|
74 | + { |
|
75 | + // grab attributes and merge with defaults |
|
76 | + $attributes = $this->getAttributes((array)$attributes); |
|
77 | + // make sure we use the_excerpt() |
|
78 | + add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
79 | + // apply query filters |
|
80 | + add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
81 | + // run the query |
|
82 | + global $wp_query; |
|
83 | + // yes we have to overwrite the main wp query, but it's ok... |
|
84 | + // we're going to reset it again below, so everything will be Hunky Dory (amazing album) |
|
85 | + $wp_query = new EventListQuery($attributes); |
|
86 | + // check what template is loaded and load filters accordingly |
|
87 | + EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
88 | + // load our template |
|
89 | + $event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), true, true); |
|
90 | + // now reset the query and postdata |
|
91 | + wp_reset_query(); |
|
92 | + wp_reset_postdata(); |
|
93 | + EED_Events_Archive::remove_all_events_archive_filters(); |
|
94 | + // remove query filters |
|
95 | + remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
96 | + // pull our content from the output buffer and return it |
|
97 | + return $event_list; |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * merge incoming attributes with filtered defaults |
|
104 | + * |
|
105 | + * @param array $attributes |
|
106 | + * @return array |
|
107 | + */ |
|
108 | + private function getAttributes(array $attributes) |
|
109 | + { |
|
110 | + return array_merge( |
|
111 | + (array)apply_filters( |
|
112 | + 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
113 | + array( |
|
114 | + 'title' => null, |
|
115 | + 'limit' => 10, |
|
116 | + 'css_class' => null, |
|
117 | + 'show_expired' => false, |
|
118 | + 'month' => null, |
|
119 | + 'category_slug' => null, |
|
120 | + 'order_by' => 'start_date', |
|
121 | + 'sort' => 'ASC', |
|
122 | + ) |
|
123 | + ), |
|
124 | + $attributes |
|
125 | + ); |
|
126 | + } |
|
127 | 127 | |
128 | 128 | |
129 | 129 | } |