@@ -16,304 +16,304 @@ |
||
16 | 16 | class EED_Bot_Trap extends EED_Module |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @return EED_Bot_Trap|EED_Module |
|
21 | - */ |
|
22 | - public static function instance() |
|
23 | - { |
|
24 | - return parent::get_instance(__CLASS__); |
|
25 | - } |
|
19 | + /** |
|
20 | + * @return EED_Bot_Trap|EED_Module |
|
21 | + */ |
|
22 | + public static function instance() |
|
23 | + { |
|
24 | + return parent::get_instance(__CLASS__); |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public static function set_hooks() |
|
34 | - { |
|
35 | - if (apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
36 | - EE_Registry::instance()->CFG->registration->use_bot_trap |
|
37 | - ) { |
|
38 | - EED_Bot_Trap::set_trap(); |
|
39 | - // redirect bots to bogus success page |
|
40 | - EE_Config::register_route( |
|
41 | - 'ticket_selection_received', |
|
42 | - 'EED_Bot_Trap', |
|
43 | - 'display_bot_trap_success' |
|
44 | - ); |
|
45 | - } |
|
46 | - } |
|
28 | + /** |
|
29 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public static function set_hooks() |
|
34 | + { |
|
35 | + if (apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) && |
|
36 | + EE_Registry::instance()->CFG->registration->use_bot_trap |
|
37 | + ) { |
|
38 | + EED_Bot_Trap::set_trap(); |
|
39 | + // redirect bots to bogus success page |
|
40 | + EE_Config::register_route( |
|
41 | + 'ticket_selection_received', |
|
42 | + 'EED_Bot_Trap', |
|
43 | + 'display_bot_trap_success' |
|
44 | + ); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
51 | - * |
|
52 | - * @return void |
|
53 | - */ |
|
54 | - public static function set_trap() |
|
55 | - { |
|
56 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
57 | - add_action( |
|
58 | - 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
59 | - array('EED_Bot_Trap', 'generate_bot_trap'), |
|
60 | - 10, |
|
61 | - 2 |
|
62 | - ); |
|
63 | - add_action( |
|
64 | - 'EED_Ticket_Selector__process_ticket_selections__before', |
|
65 | - array('EED_Bot_Trap', 'process_bot_trap'), |
|
66 | - 1, |
|
67 | - 2 |
|
68 | - ); |
|
69 | - } |
|
49 | + /** |
|
50 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
51 | + * |
|
52 | + * @return void |
|
53 | + */ |
|
54 | + public static function set_trap() |
|
55 | + { |
|
56 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
57 | + add_action( |
|
58 | + 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
|
59 | + array('EED_Bot_Trap', 'generate_bot_trap'), |
|
60 | + 10, |
|
61 | + 2 |
|
62 | + ); |
|
63 | + add_action( |
|
64 | + 'EED_Ticket_Selector__process_ticket_selections__before', |
|
65 | + array('EED_Bot_Trap', 'process_bot_trap'), |
|
66 | + 1, |
|
67 | + 2 |
|
68 | + ); |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
74 | - * |
|
75 | - * @return void |
|
76 | - */ |
|
77 | - public static function set_hooks_admin() |
|
78 | - { |
|
79 | - if (defined('DOING_AJAX') |
|
80 | - && DOING_AJAX |
|
81 | - && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
82 | - && EE_Registry::instance()->CFG->registration->use_bot_trap |
|
83 | - ) { |
|
84 | - EED_Bot_Trap::set_trap(); |
|
85 | - } |
|
86 | - add_action( |
|
87 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
88 | - array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
89 | - 5 |
|
90 | - ); |
|
91 | - add_filter( |
|
92 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
93 | - array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
94 | - 10, |
|
95 | - 1 |
|
96 | - ); |
|
97 | - } |
|
72 | + /** |
|
73 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
74 | + * |
|
75 | + * @return void |
|
76 | + */ |
|
77 | + public static function set_hooks_admin() |
|
78 | + { |
|
79 | + if (defined('DOING_AJAX') |
|
80 | + && DOING_AJAX |
|
81 | + && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) |
|
82 | + && EE_Registry::instance()->CFG->registration->use_bot_trap |
|
83 | + ) { |
|
84 | + EED_Bot_Trap::set_trap(); |
|
85 | + } |
|
86 | + add_action( |
|
87 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
88 | + array('EED_Bot_Trap', 'bot_trap_settings_form'), |
|
89 | + 5 |
|
90 | + ); |
|
91 | + add_filter( |
|
92 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
93 | + array('EED_Bot_Trap', 'update_bot_trap_settings_form'), |
|
94 | + 10, |
|
95 | + 1 |
|
96 | + ); |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | - /** |
|
101 | - * run - initial module setup |
|
102 | - * |
|
103 | - * @param WP $WP |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public function run($WP) |
|
107 | - { |
|
108 | - } |
|
100 | + /** |
|
101 | + * run - initial module setup |
|
102 | + * |
|
103 | + * @param WP $WP |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public function run($WP) |
|
107 | + { |
|
108 | + } |
|
109 | 109 | |
110 | 110 | |
111 | - /** |
|
112 | - * generate_bot_trap |
|
113 | - * |
|
114 | - * @return void |
|
115 | - * @throws RuntimeException |
|
116 | - */ |
|
117 | - public static function generate_bot_trap() |
|
118 | - { |
|
119 | - $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
120 | - $time = microtime(true); |
|
121 | - $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
122 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
123 | - $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
124 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
125 | - $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
126 | - echo $html; |
|
127 | - } |
|
111 | + /** |
|
112 | + * generate_bot_trap |
|
113 | + * |
|
114 | + * @return void |
|
115 | + * @throws RuntimeException |
|
116 | + */ |
|
117 | + public static function generate_bot_trap() |
|
118 | + { |
|
119 | + $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
|
120 | + $time = microtime(true); |
|
121 | + $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
|
122 | + $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
123 | + $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
|
124 | + $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
125 | + $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
|
126 | + echo $html; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * process_bot_trap |
|
132 | - * |
|
133 | - * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
134 | - * response if the bot trap is triggered. |
|
135 | - * It should receive one argument: a boolean indicating |
|
136 | - * whether the trap was triggered by suspicious timing or not. |
|
137 | - * @throws RuntimeException |
|
138 | - */ |
|
139 | - public static function process_bot_trap($triggered_trap_callback = array()) |
|
140 | - { |
|
141 | - // what's your email address Mr. Bot ? |
|
142 | - $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
143 | - && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
144 | - // are we human ? |
|
145 | - if ($empty_trap) { |
|
146 | - do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
147 | - return; |
|
148 | - } |
|
149 | - // check the given callback is valid first before executing |
|
150 | - if (! is_callable($triggered_trap_callback)) { |
|
151 | - // invalid callback so lets just sub in our default. |
|
152 | - $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
153 | - } |
|
154 | - call_user_func($triggered_trap_callback); |
|
155 | - } |
|
130 | + /** |
|
131 | + * process_bot_trap |
|
132 | + * |
|
133 | + * @param array|string $triggered_trap_callback Callback that will be executed for handling the |
|
134 | + * response if the bot trap is triggered. |
|
135 | + * It should receive one argument: a boolean indicating |
|
136 | + * whether the trap was triggered by suspicious timing or not. |
|
137 | + * @throws RuntimeException |
|
138 | + */ |
|
139 | + public static function process_bot_trap($triggered_trap_callback = array()) |
|
140 | + { |
|
141 | + // what's your email address Mr. Bot ? |
|
142 | + $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) |
|
143 | + && $_REQUEST['tkt-slctr-request-processor-email'] === ''; |
|
144 | + // are we human ? |
|
145 | + if ($empty_trap) { |
|
146 | + do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered'); |
|
147 | + return; |
|
148 | + } |
|
149 | + // check the given callback is valid first before executing |
|
150 | + if (! is_callable($triggered_trap_callback)) { |
|
151 | + // invalid callback so lets just sub in our default. |
|
152 | + $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
|
153 | + } |
|
154 | + call_user_func($triggered_trap_callback); |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | - /** |
|
159 | - * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
160 | - * |
|
161 | - * @throws InvalidArgumentException |
|
162 | - * @throws InvalidDataTypeException |
|
163 | - * @throws InvalidInterfaceException |
|
164 | - */ |
|
165 | - public static function triggered_trap_response() |
|
166 | - { |
|
167 | - // UH OH... |
|
168 | - $redirect_url = apply_filters( |
|
169 | - 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', |
|
170 | - add_query_arg( |
|
171 | - array('ee' => 'ticket_selection_received'), |
|
172 | - EE_Registry::instance()->CFG->core->reg_page_url() |
|
173 | - ) |
|
174 | - ); |
|
175 | - // if AJAX, return the redirect URL |
|
176 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
177 | - echo wp_json_encode( |
|
178 | - array_merge( |
|
179 | - EE_Error::get_notices(false), |
|
180 | - array( |
|
181 | - 'redirect_url' => $redirect_url, |
|
182 | - ) |
|
183 | - ) |
|
184 | - ); |
|
185 | - exit(); |
|
186 | - } |
|
187 | - wp_safe_redirect($redirect_url); |
|
188 | - exit(); |
|
189 | - } |
|
158 | + /** |
|
159 | + * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response. |
|
160 | + * |
|
161 | + * @throws InvalidArgumentException |
|
162 | + * @throws InvalidDataTypeException |
|
163 | + * @throws InvalidInterfaceException |
|
164 | + */ |
|
165 | + public static function triggered_trap_response() |
|
166 | + { |
|
167 | + // UH OH... |
|
168 | + $redirect_url = apply_filters( |
|
169 | + 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', |
|
170 | + add_query_arg( |
|
171 | + array('ee' => 'ticket_selection_received'), |
|
172 | + EE_Registry::instance()->CFG->core->reg_page_url() |
|
173 | + ) |
|
174 | + ); |
|
175 | + // if AJAX, return the redirect URL |
|
176 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
177 | + echo wp_json_encode( |
|
178 | + array_merge( |
|
179 | + EE_Error::get_notices(false), |
|
180 | + array( |
|
181 | + 'redirect_url' => $redirect_url, |
|
182 | + ) |
|
183 | + ) |
|
184 | + ); |
|
185 | + exit(); |
|
186 | + } |
|
187 | + wp_safe_redirect($redirect_url); |
|
188 | + exit(); |
|
189 | + } |
|
190 | 190 | |
191 | 191 | |
192 | - /** |
|
193 | - * display_bot_trap_success |
|
194 | - * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
195 | - * think the form was submitted successfully |
|
196 | - * |
|
197 | - * @return void |
|
198 | - */ |
|
199 | - public static function display_bot_trap_success() |
|
200 | - { |
|
201 | - add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
202 | - $bot_notice = esc_html__( |
|
203 | - 'Thank you so much. Your ticket selections have been received for consideration.', |
|
204 | - 'event_espresso' |
|
205 | - ); |
|
206 | - $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
207 | - ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
208 | - : $bot_notice; |
|
209 | - EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
210 | - } |
|
192 | + /** |
|
193 | + * display_bot_trap_success |
|
194 | + * shows a "success" screen to bots so that they (ie: the ppl managing them) |
|
195 | + * think the form was submitted successfully |
|
196 | + * |
|
197 | + * @return void |
|
198 | + */ |
|
199 | + public static function display_bot_trap_success() |
|
200 | + { |
|
201 | + add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false'); |
|
202 | + $bot_notice = esc_html__( |
|
203 | + 'Thank you so much. Your ticket selections have been received for consideration.', |
|
204 | + 'event_espresso' |
|
205 | + ); |
|
206 | + $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' |
|
207 | + ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) |
|
208 | + : $bot_notice; |
|
209 | + EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention')); |
|
210 | + } |
|
211 | 211 | |
212 | 212 | |
213 | 213 | |
214 | - /*********************************** ADMIN **********************************/ |
|
214 | + /*********************************** ADMIN **********************************/ |
|
215 | 215 | |
216 | 216 | |
217 | - /** |
|
218 | - * bot_trap_settings_form |
|
219 | - * |
|
220 | - * @return void |
|
221 | - * @throws EE_Error |
|
222 | - * @throws InvalidArgumentException |
|
223 | - * @throws InvalidDataTypeException |
|
224 | - * @throws InvalidInterfaceException |
|
225 | - */ |
|
226 | - public static function bot_trap_settings_form() |
|
227 | - { |
|
228 | - EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
229 | - echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
230 | - } |
|
217 | + /** |
|
218 | + * bot_trap_settings_form |
|
219 | + * |
|
220 | + * @return void |
|
221 | + * @throws EE_Error |
|
222 | + * @throws InvalidArgumentException |
|
223 | + * @throws InvalidDataTypeException |
|
224 | + * @throws InvalidInterfaceException |
|
225 | + */ |
|
226 | + public static function bot_trap_settings_form() |
|
227 | + { |
|
228 | + EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js(); |
|
229 | + echo EED_Bot_Trap::_bot_trap_settings_form()->get_html(); |
|
230 | + } |
|
231 | 231 | |
232 | 232 | |
233 | - /** |
|
234 | - * _bot_trap_settings_form |
|
235 | - * |
|
236 | - * @return EE_Form_Section_Proper |
|
237 | - * @throws EE_Error |
|
238 | - */ |
|
239 | - protected static function _bot_trap_settings_form() |
|
240 | - { |
|
241 | - return new EE_Form_Section_Proper( |
|
242 | - array( |
|
243 | - 'name' => 'bot_trap_settings', |
|
244 | - 'html_id' => 'bot_trap_settings', |
|
245 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
246 | - 'subsections' => array( |
|
247 | - 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
248 | - EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
249 | - ), |
|
250 | - 'use_bot_trap' => new EE_Yes_No_Input( |
|
251 | - array( |
|
252 | - 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
253 | - 'html_help_text' => esc_html__( |
|
254 | - 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', |
|
255 | - 'event_espresso' |
|
256 | - ), |
|
257 | - 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
258 | - ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
259 | - : true, |
|
260 | - 'required' => false, |
|
261 | - ) |
|
262 | - ), |
|
263 | - ), |
|
264 | - ) |
|
265 | - ); |
|
266 | - } |
|
233 | + /** |
|
234 | + * _bot_trap_settings_form |
|
235 | + * |
|
236 | + * @return EE_Form_Section_Proper |
|
237 | + * @throws EE_Error |
|
238 | + */ |
|
239 | + protected static function _bot_trap_settings_form() |
|
240 | + { |
|
241 | + return new EE_Form_Section_Proper( |
|
242 | + array( |
|
243 | + 'name' => 'bot_trap_settings', |
|
244 | + 'html_id' => 'bot_trap_settings', |
|
245 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
246 | + 'subsections' => array( |
|
247 | + 'bot_trap_hdr' => new EE_Form_Section_HTML( |
|
248 | + EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso')) |
|
249 | + ), |
|
250 | + 'use_bot_trap' => new EE_Yes_No_Input( |
|
251 | + array( |
|
252 | + 'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'), |
|
253 | + 'html_help_text' => esc_html__( |
|
254 | + 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', |
|
255 | + 'event_espresso' |
|
256 | + ), |
|
257 | + 'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null |
|
258 | + ? EE_Registry::instance()->CFG->registration->use_bot_trap |
|
259 | + : true, |
|
260 | + 'required' => false, |
|
261 | + ) |
|
262 | + ), |
|
263 | + ), |
|
264 | + ) |
|
265 | + ); |
|
266 | + } |
|
267 | 267 | |
268 | 268 | |
269 | - /** |
|
270 | - * update_bot_trap_settings_form |
|
271 | - * |
|
272 | - * @param EE_Registration_Config $EE_Registration_Config |
|
273 | - * @return EE_Registration_Config |
|
274 | - * @throws EE_Error |
|
275 | - * @throws InvalidArgumentException |
|
276 | - * @throws ReflectionException |
|
277 | - * @throws InvalidDataTypeException |
|
278 | - * @throws InvalidInterfaceException |
|
279 | - */ |
|
280 | - public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
281 | - { |
|
282 | - try { |
|
283 | - $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
284 | - // if not displaying a form, then check for form submission |
|
285 | - if ($bot_trap_settings_form->was_submitted()) { |
|
286 | - // capture form data |
|
287 | - $bot_trap_settings_form->receive_form_submission(); |
|
288 | - // validate form data |
|
289 | - if ($bot_trap_settings_form->is_valid()) { |
|
290 | - // grab validated data from form |
|
291 | - $valid_data = $bot_trap_settings_form->valid_data(); |
|
292 | - if (isset($valid_data['use_bot_trap'])) { |
|
293 | - $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
294 | - } else { |
|
295 | - EE_Error::add_error( |
|
296 | - esc_html__( |
|
297 | - 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
298 | - 'event_espresso' |
|
299 | - ), |
|
300 | - __FILE__, |
|
301 | - __FUNCTION__, |
|
302 | - __LINE__ |
|
303 | - ); |
|
304 | - } |
|
305 | - } elseif ($bot_trap_settings_form->submission_error_message() !== '') { |
|
306 | - EE_Error::add_error( |
|
307 | - $bot_trap_settings_form->submission_error_message(), |
|
308 | - __FILE__, |
|
309 | - __FUNCTION__, |
|
310 | - __LINE__ |
|
311 | - ); |
|
312 | - } |
|
313 | - } |
|
314 | - } catch (EE_Error $e) { |
|
315 | - $e->get_error(); |
|
316 | - } |
|
317 | - return $EE_Registration_Config; |
|
318 | - } |
|
269 | + /** |
|
270 | + * update_bot_trap_settings_form |
|
271 | + * |
|
272 | + * @param EE_Registration_Config $EE_Registration_Config |
|
273 | + * @return EE_Registration_Config |
|
274 | + * @throws EE_Error |
|
275 | + * @throws InvalidArgumentException |
|
276 | + * @throws ReflectionException |
|
277 | + * @throws InvalidDataTypeException |
|
278 | + * @throws InvalidInterfaceException |
|
279 | + */ |
|
280 | + public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
281 | + { |
|
282 | + try { |
|
283 | + $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form(); |
|
284 | + // if not displaying a form, then check for form submission |
|
285 | + if ($bot_trap_settings_form->was_submitted()) { |
|
286 | + // capture form data |
|
287 | + $bot_trap_settings_form->receive_form_submission(); |
|
288 | + // validate form data |
|
289 | + if ($bot_trap_settings_form->is_valid()) { |
|
290 | + // grab validated data from form |
|
291 | + $valid_data = $bot_trap_settings_form->valid_data(); |
|
292 | + if (isset($valid_data['use_bot_trap'])) { |
|
293 | + $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap']; |
|
294 | + } else { |
|
295 | + EE_Error::add_error( |
|
296 | + esc_html__( |
|
297 | + 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', |
|
298 | + 'event_espresso' |
|
299 | + ), |
|
300 | + __FILE__, |
|
301 | + __FUNCTION__, |
|
302 | + __LINE__ |
|
303 | + ); |
|
304 | + } |
|
305 | + } elseif ($bot_trap_settings_form->submission_error_message() !== '') { |
|
306 | + EE_Error::add_error( |
|
307 | + $bot_trap_settings_form->submission_error_message(), |
|
308 | + __FILE__, |
|
309 | + __FUNCTION__, |
|
310 | + __LINE__ |
|
311 | + ); |
|
312 | + } |
|
313 | + } |
|
314 | + } catch (EE_Error $e) { |
|
315 | + $e->get_error(); |
|
316 | + } |
|
317 | + return $EE_Registration_Config; |
|
318 | + } |
|
319 | 319 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public static function set_trap() |
55 | 55 | { |
56 | - define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . '/'); |
|
56 | + define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).'/'); |
|
57 | 57 | add_action( |
58 | 58 | 'AHEE__ticket_selector_chart__template__after_ticket_selector', |
59 | 59 | array('EED_Bot_Trap', 'generate_bot_trap'), |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso'); |
120 | 120 | $time = microtime(true); |
121 | 121 | $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">'; |
122 | - $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>'; |
|
122 | + $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>'; |
|
123 | 123 | $html .= '<input type="email" id="tkt-slctr-request-processor-email-'; |
124 | - $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>'; |
|
124 | + $html .= $time.'" name="tkt-slctr-request-processor-email" value=""/>'; |
|
125 | 125 | $html .= '</div><!-- .tkt-slctr-request-processor-dv -->'; |
126 | 126 | echo $html; |
127 | 127 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | return; |
148 | 148 | } |
149 | 149 | // check the given callback is valid first before executing |
150 | - if (! is_callable($triggered_trap_callback)) { |
|
150 | + if ( ! is_callable($triggered_trap_callback)) { |
|
151 | 151 | // invalid callback so lets just sub in our default. |
152 | 152 | $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response'); |
153 | 153 | } |
@@ -16,1094 +16,1094 @@ discard block |
||
16 | 16 | class EED_Events_Archive extends EED_Module |
17 | 17 | { |
18 | 18 | |
19 | - const EVENT_DETAILS_PRIORITY = 100; |
|
20 | - |
|
21 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
22 | - |
|
23 | - const EVENT_TICKETS_PRIORITY = 120; |
|
24 | - |
|
25 | - const EVENT_VENUES_PRIORITY = 130; |
|
26 | - |
|
27 | - |
|
28 | - public static $espresso_event_list_ID = 0; |
|
29 | - |
|
30 | - public static $espresso_grid_event_lists = array(); |
|
31 | - |
|
32 | - /** |
|
33 | - * @type bool $using_get_the_excerpt |
|
34 | - */ |
|
35 | - protected static $using_get_the_excerpt = false; |
|
36 | - |
|
37 | - /** |
|
38 | - * Used to flag when the event list is being called from an external iframe. |
|
39 | - * |
|
40 | - * @var bool $iframe |
|
41 | - */ |
|
42 | - protected static $iframe = false; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button |
|
46 | - */ |
|
47 | - private static $_iframe_embed_button; |
|
48 | - |
|
49 | - /** |
|
50 | - * @type EE_Template_Part_Manager $template_parts |
|
51 | - */ |
|
52 | - protected $template_parts; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @return EED_Events_Archive |
|
57 | - */ |
|
58 | - public static function instance() |
|
59 | - { |
|
60 | - return parent::get_instance(__CLASS__); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
66 | - * |
|
67 | - * @return void |
|
68 | - * @throws InvalidArgumentException |
|
69 | - * @throws InvalidDataTypeException |
|
70 | - * @throws InvalidInterfaceException |
|
71 | - */ |
|
72 | - public static function set_hooks() |
|
73 | - { |
|
74 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
75 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
76 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
77 | - ); |
|
78 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
79 | - EE_Config::register_route( |
|
80 | - $custom_post_types['espresso_events']['plural_slug'], |
|
81 | - 'Events_Archive', |
|
82 | - 'run' |
|
83 | - ); |
|
84 | - EE_Config::register_route( |
|
85 | - 'event_list', |
|
86 | - 'Events_Archive', |
|
87 | - 'event_list' |
|
88 | - ); |
|
89 | - EE_Config::register_route( |
|
90 | - 'iframe', |
|
91 | - 'Events_Archive', |
|
92 | - 'event_list_iframe', |
|
93 | - 'event_list' |
|
94 | - ); |
|
95 | - add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
101 | - * |
|
102 | - * @access public |
|
103 | - * @return void |
|
104 | - */ |
|
105 | - public static function set_hooks_admin() |
|
106 | - { |
|
107 | - add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
108 | - // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
109 | - // to load assets for "espresso_events" page on the "default" route (action) |
|
110 | - add_action( |
|
111 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
|
112 | - array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
113 | - 10 |
|
114 | - ); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * set_definitions |
|
120 | - * |
|
121 | - * @access public |
|
122 | - * @return void |
|
123 | - */ |
|
124 | - public static function set_definitions() |
|
125 | - { |
|
126 | - define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
127 | - define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * set up EE_Events_Archive_Config |
|
133 | - */ |
|
134 | - protected function set_config() |
|
135 | - { |
|
136 | - $this->set_config_section('template_settings'); |
|
137 | - $this->set_config_class('EE_Events_Archive_Config'); |
|
138 | - $this->set_config_name('EED_Events_Archive'); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @return EventListIframeEmbedButton |
|
144 | - */ |
|
145 | - public static function get_iframe_embed_button() |
|
146 | - { |
|
147 | - if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
148 | - self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
|
149 | - } |
|
150 | - return self::$_iframe_embed_button; |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * event_list_iframe_embed_button |
|
156 | - * |
|
157 | - * @return void |
|
158 | - * @throws \EE_Error |
|
159 | - */ |
|
160 | - public static function event_list_iframe_embed_button() |
|
161 | - { |
|
162 | - $iframe_embed_button = \EED_Events_Archive::get_iframe_embed_button(); |
|
163 | - $iframe_embed_button->addEmbedButton(); |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * initialize_template_parts |
|
169 | - * |
|
170 | - * @access public |
|
171 | - * @param \EE_Events_Archive_Config $config |
|
172 | - * @return \EE_Template_Part_Manager |
|
173 | - */ |
|
174 | - public function initialize_template_parts(EE_Events_Archive_Config $config = null) |
|
175 | - { |
|
176 | - $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
|
177 | - EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
178 | - $template_parts = new EE_Template_Part_Manager(); |
|
179 | - $template_parts->add_template_part( |
|
180 | - 'tickets', |
|
181 | - __('Ticket Selector', 'event_espresso'), |
|
182 | - 'content-espresso_events-tickets.php', |
|
183 | - $config->display_order_tickets |
|
184 | - ); |
|
185 | - $template_parts->add_template_part( |
|
186 | - 'datetimes', |
|
187 | - __('Dates and Times', 'event_espresso'), |
|
188 | - 'content-espresso_events-datetimes.php', |
|
189 | - $config->display_order_datetimes |
|
190 | - ); |
|
191 | - $template_parts->add_template_part( |
|
192 | - 'event', |
|
193 | - __('Event Description', 'event_espresso'), |
|
194 | - 'content-espresso_events-details.php', |
|
195 | - $config->display_order_event |
|
196 | - ); |
|
197 | - $template_parts->add_template_part( |
|
198 | - 'venue', |
|
199 | - __('Venue Information', 'event_espresso'), |
|
200 | - 'content-espresso_events-venues.php', |
|
201 | - $config->display_order_venue |
|
202 | - ); |
|
203 | - do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
204 | - return $template_parts; |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the |
|
210 | - * incoming request |
|
211 | - * |
|
212 | - * @access public |
|
213 | - * @param WP $WP |
|
214 | - * @return void |
|
215 | - */ |
|
216 | - public function run($WP) |
|
217 | - { |
|
218 | - do_action('AHEE__EED_Events_Archive__before_run'); |
|
219 | - // ensure valid EE_Events_Archive_Config() object exists |
|
220 | - $this->set_config(); |
|
221 | - /** @type EE_Events_Archive_Config $config */ |
|
222 | - $config = $this->config(); |
|
223 | - // load other required components |
|
224 | - $this->load_event_list_assets(); |
|
225 | - // filter the WP posts_join, posts_where, and posts_orderby SQL clauses |
|
226 | - // add query filters |
|
227 | - EEH_Event_Query::add_query_filters(); |
|
228 | - // set params that will get used by the filters |
|
229 | - EEH_Event_Query::set_query_params( |
|
230 | - '', // month |
|
231 | - '', // category |
|
232 | - $config->display_expired_events, // show_expired |
|
233 | - 'start_date', // orderby |
|
234 | - 'ASC' // sort |
|
235 | - ); |
|
236 | - // check what template is loaded |
|
237 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
243 | - * |
|
244 | - * @return void |
|
245 | - */ |
|
246 | - public function event_list() |
|
247 | - { |
|
248 | - // ensure valid EE_Events_Archive_Config() object exists |
|
249 | - $this->set_config(); |
|
250 | - // load other required components |
|
251 | - $this->load_event_list_assets(); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * @access public |
|
257 | - * @return void |
|
258 | - * @throws \EE_Error |
|
259 | - * @throws \DomainException |
|
260 | - */ |
|
261 | - public function event_list_iframe() |
|
262 | - { |
|
263 | - \EED_Events_Archive::$iframe = true; |
|
264 | - $event_list_iframe = new EventsArchiveIframe($this); |
|
265 | - $event_list_iframe->display(); |
|
266 | - } |
|
267 | - |
|
268 | - |
|
269 | - /** |
|
270 | - * @access public |
|
271 | - * @return string |
|
272 | - */ |
|
273 | - public static function is_iframe() |
|
274 | - { |
|
275 | - return \EED_Events_Archive::$iframe; |
|
276 | - } |
|
277 | - |
|
278 | - |
|
279 | - /** |
|
280 | - * @access public |
|
281 | - * @return string |
|
282 | - */ |
|
283 | - public static function link_target() |
|
284 | - { |
|
285 | - return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * template_include |
|
291 | - * |
|
292 | - * @access public |
|
293 | - * @param string $template |
|
294 | - * @return string |
|
295 | - */ |
|
296 | - public function template_include($template = '') |
|
297 | - { |
|
298 | - // don't add content filter for dedicated EE child themes or private posts |
|
299 | - if (! EEH_Template::is_espresso_theme()) { |
|
300 | - /** @type EE_Events_Archive_Config $config */ |
|
301 | - $config = $this->config(); |
|
302 | - // add status banner ? |
|
303 | - if ($config->display_status_banner) { |
|
304 | - add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
305 | - } |
|
306 | - // if NOT a custom template |
|
307 | - if (apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
308 | - || EE_Registry::instance() |
|
309 | - ->load_core('Front_Controller') |
|
310 | - ->get_selected_template() !== 'archive-espresso_events.php' |
|
311 | - ) { |
|
312 | - // don't display entry meta because the existing theme will take care of that |
|
313 | - add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
314 | - // load functions.php file for the theme (loaded by WP if using child theme) |
|
315 | - EEH_Template::load_espresso_theme_functions(); |
|
316 | - // because we don't know if the theme is using the_excerpt() |
|
317 | - add_filter( |
|
318 | - 'the_excerpt', |
|
319 | - array('EED_Events_Archive', 'event_details'), |
|
320 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
321 | - ); |
|
322 | - // or the_content |
|
323 | - add_filter( |
|
324 | - 'the_content', |
|
325 | - array('EED_Events_Archive', 'event_details'), |
|
326 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
327 | - ); |
|
328 | - // and just in case they are running get_the_excerpt() which DESTROYS things |
|
329 | - add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
330 | - // don't display entry meta because the existing theme will take care of that |
|
331 | - add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
332 | - } |
|
333 | - } |
|
334 | - return $template; |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters |
|
340 | - * on the_content() |
|
341 | - * |
|
342 | - * @access public |
|
343 | - * @param string $excerpt |
|
344 | - * @return string |
|
345 | - */ |
|
346 | - public static function get_the_excerpt($excerpt = '') |
|
347 | - { |
|
348 | - if (post_password_required()) { |
|
349 | - return $excerpt; |
|
350 | - } |
|
351 | - if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
352 | - remove_filter( |
|
353 | - 'the_excerpt', |
|
354 | - array('EED_Events_Archive', 'event_details'), |
|
355 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
356 | - ); |
|
357 | - remove_filter( |
|
358 | - 'the_content', |
|
359 | - array('EED_Events_Archive', 'event_details'), |
|
360 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
361 | - ); |
|
362 | - $excerpt = EED_Events_Archive::event_details($excerpt); |
|
363 | - } else { |
|
364 | - EED_Events_Archive::$using_get_the_excerpt = true; |
|
365 | - add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
366 | - } |
|
367 | - return $excerpt; |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * end_get_the_excerpt |
|
373 | - * |
|
374 | - * @access public |
|
375 | - * @param string $text |
|
376 | - * @return string |
|
377 | - */ |
|
378 | - public static function end_get_the_excerpt($text = '') |
|
379 | - { |
|
380 | - EED_Events_Archive::$using_get_the_excerpt = false; |
|
381 | - return $text; |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * the_title |
|
387 | - * |
|
388 | - * @access public |
|
389 | - * @param string $title |
|
390 | - * @param string $id |
|
391 | - * @return string |
|
392 | - */ |
|
393 | - public static function the_title($title = '', $id = '') |
|
394 | - { |
|
395 | - global $post; |
|
396 | - if ($post instanceof WP_Post) { |
|
397 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID) . $title : $title; |
|
398 | - } |
|
399 | - return $title; |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * event_details |
|
405 | - * |
|
406 | - * @access public |
|
407 | - * @param string $content |
|
408 | - * @return string |
|
409 | - */ |
|
410 | - public static function event_details($content) |
|
411 | - { |
|
412 | - global $post; |
|
413 | - static $current_post_ID = 0; |
|
414 | - if ($current_post_ID !== $post->ID |
|
415 | - && $post->post_type === 'espresso_events' |
|
416 | - && ! EED_Events_Archive::$using_get_the_excerpt |
|
417 | - && ! post_password_required() |
|
418 | - && ( |
|
419 | - apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
420 | - || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
421 | - ) |
|
422 | - ) { |
|
423 | - // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
424 | - // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
425 | - // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
426 | - // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
427 | - // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
428 | - // so the following allows this filter to be applied multiple times, but only once for real |
|
429 | - $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
430 | - if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
431 | - $content = \EED_Events_Archive::use_sortable_display_order(); |
|
432 | - } else { |
|
433 | - $content = \EED_Events_Archive::use_filterable_display_order(); |
|
434 | - } |
|
435 | - } |
|
436 | - return $content; |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * use_sortable_display_order |
|
442 | - * |
|
443 | - * @access protected |
|
444 | - * @return string |
|
445 | - */ |
|
446 | - protected static function use_sortable_display_order() |
|
447 | - { |
|
448 | - // no further password checks required atm |
|
449 | - add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
450 | - // we need to first remove this callback from being applied to the_content() or the_excerpt() |
|
451 | - // (otherwise it will recurse and blow up the interweb) |
|
452 | - remove_filter( |
|
453 | - 'the_excerpt', |
|
454 | - array('EED_Events_Archive', 'event_details'), |
|
455 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
456 | - ); |
|
457 | - remove_filter( |
|
458 | - 'the_content', |
|
459 | - array('EED_Events_Archive', 'event_details'), |
|
460 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
461 | - ); |
|
462 | - remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
463 | - // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
464 | - EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
|
465 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
466 | - $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
467 | - // re-add our main filters (or else the next event won't have them) |
|
468 | - add_filter( |
|
469 | - 'the_excerpt', |
|
470 | - array('EED_Events_Archive', 'event_details'), |
|
471 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
472 | - ); |
|
473 | - add_filter( |
|
474 | - 'the_content', |
|
475 | - array('EED_Events_Archive', 'event_details'), |
|
476 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
477 | - ); |
|
478 | - add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
479 | - remove_filter( |
|
480 | - 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
481 | - '__return_true' |
|
482 | - ); |
|
483 | - return $content; |
|
484 | - } |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
488 | - * use_filterable_display_order |
|
489 | - * |
|
490 | - * @access protected |
|
491 | - * @return string |
|
492 | - */ |
|
493 | - protected static function use_filterable_display_order() |
|
494 | - { |
|
495 | - // we need to first remove this callback from being applied to the_content() |
|
496 | - // (otherwise it will recurse and blow up the interweb) |
|
497 | - remove_filter( |
|
498 | - 'the_excerpt', |
|
499 | - array('EED_Events_Archive', 'event_details'), |
|
500 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
501 | - ); |
|
502 | - remove_filter( |
|
503 | - 'the_content', |
|
504 | - array('EED_Events_Archive', 'event_details'), |
|
505 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
506 | - ); |
|
507 | - remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
508 | - // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
509 | - EED_Events_Archive::_add_additional_excerpt_filters(); |
|
510 | - EED_Events_Archive::_add_additional_content_filters(); |
|
511 | - do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
512 | - // now load our template |
|
513 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
514 | - // re-add our main filters (or else the next event won't have them) |
|
515 | - add_filter( |
|
516 | - 'the_excerpt', |
|
517 | - array('EED_Events_Archive', 'event_details'), |
|
518 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
519 | - ); |
|
520 | - add_filter( |
|
521 | - 'the_content', |
|
522 | - array('EED_Events_Archive', 'event_details'), |
|
523 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
524 | - ); |
|
525 | - add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
526 | - // but remove the other filters so that they don't get applied to the next post |
|
527 | - EED_Events_Archive::_remove_additional_events_archive_filters(); |
|
528 | - do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
529 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
530 | - // return ! empty( $template ) ? $template : $content; |
|
531 | - return $content; |
|
532 | - } |
|
533 | - |
|
534 | - |
|
535 | - /** |
|
536 | - * event_datetimes - adds datetimes ABOVE content |
|
537 | - * |
|
538 | - * @access public |
|
539 | - * @param string $content |
|
540 | - * @return string |
|
541 | - */ |
|
542 | - public static function event_datetimes($content) |
|
543 | - { |
|
544 | - if (post_password_required()) { |
|
545 | - return $content; |
|
546 | - } |
|
547 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
548 | - } |
|
549 | - |
|
550 | - |
|
551 | - /** |
|
552 | - * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
553 | - * |
|
554 | - * @access public |
|
555 | - * @param string $content |
|
556 | - * @return string |
|
557 | - */ |
|
558 | - public static function event_tickets($content) |
|
559 | - { |
|
560 | - if (post_password_required()) { |
|
561 | - return $content; |
|
562 | - } |
|
563 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
564 | - } |
|
565 | - |
|
566 | - |
|
567 | - /** |
|
568 | - * event_venues - adds venues BELOW content |
|
569 | - * |
|
570 | - * @access public |
|
571 | - * @param string $content |
|
572 | - * @return string |
|
573 | - */ |
|
574 | - public static function event_venue($content) |
|
575 | - { |
|
576 | - return EED_Events_Archive::event_venues($content); |
|
577 | - } |
|
578 | - |
|
579 | - |
|
580 | - /** |
|
581 | - * event_venues - adds venues BELOW content |
|
582 | - * |
|
583 | - * @access public |
|
584 | - * @param string $content |
|
585 | - * @return string |
|
586 | - */ |
|
587 | - public static function event_venues($content) |
|
588 | - { |
|
589 | - if (post_password_required()) { |
|
590 | - return $content; |
|
591 | - } |
|
592 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
593 | - } |
|
594 | - |
|
595 | - |
|
596 | - /** |
|
597 | - * _add_additional_content_filters |
|
598 | - * |
|
599 | - * @access private |
|
600 | - * @return void |
|
601 | - */ |
|
602 | - private static function _add_additional_excerpt_filters() |
|
603 | - { |
|
604 | - add_filter( |
|
605 | - 'the_excerpt', |
|
606 | - array('EED_Events_Archive', 'event_datetimes'), |
|
607 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
608 | - ); |
|
609 | - add_filter( |
|
610 | - 'the_excerpt', |
|
611 | - array('EED_Events_Archive', 'event_tickets'), |
|
612 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
613 | - ); |
|
614 | - add_filter( |
|
615 | - 'the_excerpt', |
|
616 | - array('EED_Events_Archive', 'event_venues'), |
|
617 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
618 | - ); |
|
619 | - } |
|
620 | - |
|
621 | - |
|
622 | - /** |
|
623 | - * _add_additional_content_filters |
|
624 | - * |
|
625 | - * @access private |
|
626 | - * @return void |
|
627 | - */ |
|
628 | - private static function _add_additional_content_filters() |
|
629 | - { |
|
630 | - add_filter( |
|
631 | - 'the_content', |
|
632 | - array('EED_Events_Archive', 'event_datetimes'), |
|
633 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
634 | - ); |
|
635 | - add_filter( |
|
636 | - 'the_content', |
|
637 | - array('EED_Events_Archive', 'event_tickets'), |
|
638 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
639 | - ); |
|
640 | - add_filter( |
|
641 | - 'the_content', |
|
642 | - array('EED_Events_Archive', 'event_venues'), |
|
643 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
644 | - ); |
|
645 | - } |
|
646 | - |
|
647 | - |
|
648 | - /** |
|
649 | - * _remove_additional_events_archive_filters |
|
650 | - * |
|
651 | - * @access private |
|
652 | - * @return void |
|
653 | - */ |
|
654 | - private static function _remove_additional_events_archive_filters() |
|
655 | - { |
|
656 | - remove_filter( |
|
657 | - 'the_excerpt', |
|
658 | - array('EED_Events_Archive', 'event_datetimes'), |
|
659 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
660 | - ); |
|
661 | - remove_filter( |
|
662 | - 'the_excerpt', |
|
663 | - array('EED_Events_Archive', 'event_tickets'), |
|
664 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
665 | - ); |
|
666 | - remove_filter( |
|
667 | - 'the_excerpt', |
|
668 | - array('EED_Events_Archive', 'event_venues'), |
|
669 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
670 | - ); |
|
671 | - remove_filter( |
|
672 | - 'the_content', |
|
673 | - array('EED_Events_Archive', 'event_datetimes'), |
|
674 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
675 | - ); |
|
676 | - remove_filter( |
|
677 | - 'the_content', |
|
678 | - array('EED_Events_Archive', 'event_tickets'), |
|
679 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
680 | - ); |
|
681 | - remove_filter( |
|
682 | - 'the_content', |
|
683 | - array('EED_Events_Archive', 'event_venues'), |
|
684 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
685 | - ); |
|
686 | - } |
|
687 | - |
|
688 | - |
|
689 | - /** |
|
690 | - * remove_all_events_archive_filters |
|
691 | - * |
|
692 | - * @access public |
|
693 | - * @return void |
|
694 | - */ |
|
695 | - public static function remove_all_events_archive_filters() |
|
696 | - { |
|
697 | - // remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
698 | - remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1); |
|
699 | - remove_filter( |
|
700 | - 'the_excerpt', |
|
701 | - array('EED_Events_Archive', 'event_details'), |
|
702 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
703 | - ); |
|
704 | - remove_filter( |
|
705 | - 'the_excerpt', |
|
706 | - array('EED_Events_Archive', 'event_datetimes'), |
|
707 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
708 | - ); |
|
709 | - remove_filter( |
|
710 | - 'the_excerpt', |
|
711 | - array('EED_Events_Archive', 'event_tickets'), |
|
712 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
713 | - ); |
|
714 | - remove_filter( |
|
715 | - 'the_excerpt', |
|
716 | - array('EED_Events_Archive', 'event_venues'), |
|
717 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
718 | - ); |
|
719 | - remove_filter( |
|
720 | - 'the_content', |
|
721 | - array('EED_Events_Archive', 'event_details'), |
|
722 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
723 | - ); |
|
724 | - remove_filter( |
|
725 | - 'the_content', |
|
726 | - array('EED_Events_Archive', 'event_datetimes'), |
|
727 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
728 | - ); |
|
729 | - remove_filter( |
|
730 | - 'the_content', |
|
731 | - array('EED_Events_Archive', 'event_tickets'), |
|
732 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
733 | - ); |
|
734 | - remove_filter( |
|
735 | - 'the_content', |
|
736 | - array('EED_Events_Archive', 'event_venues'), |
|
737 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
738 | - ); |
|
739 | - // don't display entry meta because the existing theme will take care of that |
|
740 | - remove_filter( |
|
741 | - 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
742 | - '__return_false' |
|
743 | - ); |
|
744 | - } |
|
745 | - |
|
746 | - |
|
747 | - /** |
|
748 | - * load_event_list_assets |
|
749 | - * |
|
750 | - * @access public |
|
751 | - * @return void |
|
752 | - */ |
|
753 | - public function load_event_list_assets() |
|
754 | - { |
|
755 | - do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
756 | - add_filter('FHEE_load_EE_Session', '__return_true'); |
|
757 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
758 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
759 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
760 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
761 | - } |
|
762 | - } |
|
763 | - |
|
764 | - |
|
765 | - /** |
|
766 | - * wp_enqueue_scripts |
|
767 | - * |
|
768 | - * @access public |
|
769 | - * @return void |
|
770 | - */ |
|
771 | - public function wp_enqueue_scripts() |
|
772 | - { |
|
773 | - // get some style |
|
774 | - if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
|
775 | - // first check uploads folder |
|
776 | - if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
777 | - wp_register_style( |
|
778 | - $this->theme, |
|
779 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
780 | - array('dashicons', 'espresso_default') |
|
781 | - ); |
|
782 | - } else { |
|
783 | - } |
|
784 | - wp_enqueue_style($this->theme); |
|
785 | - } |
|
786 | - } |
|
787 | - |
|
788 | - |
|
789 | - /** |
|
790 | - * template_settings_form |
|
791 | - * |
|
792 | - * @access public |
|
793 | - * @static |
|
794 | - * @return string |
|
795 | - */ |
|
796 | - public static function template_settings_form() |
|
797 | - { |
|
798 | - $template_settings = EE_Registry::instance()->CFG->template_settings; |
|
799 | - $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) |
|
800 | - ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
801 | - $template_settings->EED_Events_Archive = apply_filters( |
|
802 | - 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
|
803 | - $template_settings->EED_Events_Archive |
|
804 | - ); |
|
805 | - $events_archive_settings = array( |
|
806 | - 'display_status_banner' => 0, |
|
807 | - 'display_description' => 1, |
|
808 | - 'display_ticket_selector' => 0, |
|
809 | - 'display_datetimes' => 1, |
|
810 | - 'display_venue' => 0, |
|
811 | - 'display_expired_events' => 0, |
|
812 | - ); |
|
813 | - $events_archive_settings = array_merge( |
|
814 | - $events_archive_settings, |
|
815 | - (array) $template_settings->EED_Events_Archive |
|
816 | - ); |
|
817 | - EEH_Template::display_template( |
|
818 | - EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
819 | - $events_archive_settings |
|
820 | - ); |
|
821 | - } |
|
822 | - |
|
823 | - |
|
824 | - /** |
|
825 | - * update_template_settings |
|
826 | - * |
|
827 | - * @access public |
|
828 | - * @param EE_Template_Config $CFG |
|
829 | - * @param EE_Request_Handler $REQ |
|
830 | - * @return EE_Template_Config |
|
831 | - */ |
|
832 | - public static function update_template_settings($CFG, $REQ) |
|
833 | - { |
|
834 | - $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
|
835 | - // unless we are resetting the config... |
|
836 | - if (! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
837 | - || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1 |
|
838 | - ) { |
|
839 | - $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) |
|
840 | - ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
841 | - $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) |
|
842 | - ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
843 | - $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) |
|
844 | - ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
845 | - $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint( |
|
846 | - $REQ['EED_Events_Archive_display_datetimes'] |
|
847 | - ) : 1; |
|
848 | - $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint( |
|
849 | - $REQ['EED_Events_Archive_display_venue'] |
|
850 | - ) : 0; |
|
851 | - $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) |
|
852 | - ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; |
|
853 | - } |
|
854 | - return $CFG; |
|
855 | - } |
|
856 | - |
|
857 | - |
|
858 | - /** |
|
859 | - * event_list_css |
|
860 | - * |
|
861 | - * @access public |
|
862 | - * @param string $extra_class |
|
863 | - * @return string |
|
864 | - */ |
|
865 | - public static function event_list_css($extra_class = '') |
|
866 | - { |
|
867 | - $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
868 | - $event_list_css[] = 'espresso-event-list-event'; |
|
869 | - return implode(' ', $event_list_css); |
|
870 | - } |
|
871 | - |
|
872 | - |
|
873 | - /** |
|
874 | - * event_categories |
|
875 | - * |
|
876 | - * @access public |
|
877 | - * @return array |
|
878 | - */ |
|
879 | - public static function event_categories() |
|
880 | - { |
|
881 | - return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
882 | - } |
|
883 | - |
|
884 | - |
|
885 | - /** |
|
886 | - * display_description |
|
887 | - * |
|
888 | - * @access public |
|
889 | - * @param $value |
|
890 | - * @return bool |
|
891 | - */ |
|
892 | - public static function display_description($value) |
|
893 | - { |
|
894 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
895 | - $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
896 | - return $display_description === $value ? true : false; |
|
897 | - } |
|
898 | - |
|
899 | - |
|
900 | - /** |
|
901 | - * display_ticket_selector |
|
902 | - * |
|
903 | - * @access public |
|
904 | - * @return bool |
|
905 | - */ |
|
906 | - public static function display_ticket_selector() |
|
907 | - { |
|
908 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
909 | - return isset($config->display_ticket_selector) && $config->display_ticket_selector ? true : false; |
|
910 | - } |
|
911 | - |
|
912 | - |
|
913 | - /** |
|
914 | - * display_venue |
|
915 | - * |
|
916 | - * @access public |
|
917 | - * @return bool |
|
918 | - */ |
|
919 | - public static function display_venue() |
|
920 | - { |
|
921 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
922 | - return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? true : false; |
|
923 | - } |
|
924 | - |
|
925 | - |
|
926 | - /** |
|
927 | - * display_datetimes |
|
928 | - * |
|
929 | - * @access public |
|
930 | - * @return bool |
|
931 | - */ |
|
932 | - public static function display_datetimes() |
|
933 | - { |
|
934 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
935 | - return isset($config->display_datetimes) && $config->display_datetimes ? true : false; |
|
936 | - } |
|
937 | - |
|
938 | - |
|
939 | - /** |
|
940 | - * event_list_title |
|
941 | - * |
|
942 | - * @access public |
|
943 | - * @return string |
|
944 | - */ |
|
945 | - public static function event_list_title() |
|
946 | - { |
|
947 | - return apply_filters( |
|
948 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
949 | - __('Upcoming Events', 'event_espresso') |
|
950 | - ); |
|
951 | - } |
|
952 | - |
|
953 | - |
|
954 | - // GRAVEYARD |
|
955 | - |
|
956 | - |
|
957 | - /** |
|
958 | - * @since 4.4.0 |
|
959 | - */ |
|
960 | - public static function _doing_it_wrong_notice($function = '') |
|
961 | - { |
|
962 | - EE_Error::doing_it_wrong( |
|
963 | - __FUNCTION__, |
|
964 | - sprintf( |
|
965 | - __( |
|
966 | - 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', |
|
967 | - 'event_espresso' |
|
968 | - ), |
|
969 | - $function, |
|
970 | - '<br />', |
|
971 | - '4.6.0' |
|
972 | - ), |
|
973 | - '4.4.0' |
|
974 | - ); |
|
975 | - } |
|
976 | - |
|
977 | - |
|
978 | - /** |
|
979 | - * @deprecated |
|
980 | - * @since 4.4.0 |
|
981 | - */ |
|
982 | - public function get_post_data() |
|
983 | - { |
|
984 | - EEH_Event_Query::set_query_params(); |
|
985 | - } |
|
986 | - |
|
987 | - |
|
988 | - /** |
|
989 | - * @deprecated |
|
990 | - * @since 4.4.0 |
|
991 | - */ |
|
992 | - public function posts_fields($SQL, WP_Query $wp_query) |
|
993 | - { |
|
994 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
995 | - return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
996 | - } |
|
997 | - |
|
998 | - |
|
999 | - /** |
|
1000 | - * @deprecated |
|
1001 | - * @since 4.4.0 |
|
1002 | - */ |
|
1003 | - public static function posts_fields_sql_for_orderby($orderby_params = array()) |
|
1004 | - { |
|
1005 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1006 | - return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
1007 | - } |
|
1008 | - |
|
1009 | - |
|
1010 | - /** |
|
1011 | - * @deprecated |
|
1012 | - * @since 4.4.0 |
|
1013 | - */ |
|
1014 | - public function posts_join($SQL, WP_Query $wp_query) |
|
1015 | - { |
|
1016 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1017 | - return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
1018 | - } |
|
1019 | - |
|
1020 | - |
|
1021 | - /** |
|
1022 | - * @deprecated |
|
1023 | - * @since 4.4.0 |
|
1024 | - */ |
|
1025 | - public static function posts_join_sql_for_terms($join_terms = null) |
|
1026 | - { |
|
1027 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1028 | - return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
1029 | - } |
|
1030 | - |
|
1031 | - |
|
1032 | - /** |
|
1033 | - * @deprecated |
|
1034 | - * @since 4.4.0 |
|
1035 | - */ |
|
1036 | - public static function posts_join_for_orderby($orderby_params = array()) |
|
1037 | - { |
|
1038 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1039 | - return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
1040 | - } |
|
1041 | - |
|
1042 | - |
|
1043 | - /** |
|
1044 | - * @deprecated |
|
1045 | - * @since 4.4.0 |
|
1046 | - */ |
|
1047 | - public function posts_where($SQL, WP_Query $wp_query) |
|
1048 | - { |
|
1049 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1050 | - return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
1051 | - } |
|
1052 | - |
|
1053 | - |
|
1054 | - /** |
|
1055 | - * @deprecated |
|
1056 | - * @since 4.4.0 |
|
1057 | - */ |
|
1058 | - public static function posts_where_sql_for_show_expired($show_expired = false) |
|
1059 | - { |
|
1060 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1061 | - return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
1062 | - } |
|
1063 | - |
|
1064 | - |
|
1065 | - /** |
|
1066 | - * @deprecated |
|
1067 | - * @since 4.4.0 |
|
1068 | - */ |
|
1069 | - public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
1070 | - { |
|
1071 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1072 | - return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
1073 | - } |
|
1074 | - |
|
1075 | - |
|
1076 | - /** |
|
1077 | - * @deprecated |
|
1078 | - * @since 4.4.0 |
|
1079 | - */ |
|
1080 | - public static function posts_where_sql_for_event_list_month($month = null) |
|
1081 | - { |
|
1082 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1083 | - return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
1084 | - } |
|
1085 | - |
|
1086 | - |
|
1087 | - /** |
|
1088 | - * @deprecated |
|
1089 | - * @since 4.4.0 |
|
1090 | - */ |
|
1091 | - public function posts_orderby($SQL, WP_Query $wp_query) |
|
1092 | - { |
|
1093 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1094 | - return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
1095 | - } |
|
1096 | - |
|
1097 | - |
|
1098 | - /** |
|
1099 | - * @deprecated |
|
1100 | - * @since 4.4.0 |
|
1101 | - */ |
|
1102 | - public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') |
|
1103 | - { |
|
1104 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1105 | - return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
1106 | - } |
|
19 | + const EVENT_DETAILS_PRIORITY = 100; |
|
20 | + |
|
21 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
22 | + |
|
23 | + const EVENT_TICKETS_PRIORITY = 120; |
|
24 | + |
|
25 | + const EVENT_VENUES_PRIORITY = 130; |
|
26 | + |
|
27 | + |
|
28 | + public static $espresso_event_list_ID = 0; |
|
29 | + |
|
30 | + public static $espresso_grid_event_lists = array(); |
|
31 | + |
|
32 | + /** |
|
33 | + * @type bool $using_get_the_excerpt |
|
34 | + */ |
|
35 | + protected static $using_get_the_excerpt = false; |
|
36 | + |
|
37 | + /** |
|
38 | + * Used to flag when the event list is being called from an external iframe. |
|
39 | + * |
|
40 | + * @var bool $iframe |
|
41 | + */ |
|
42 | + protected static $iframe = false; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button |
|
46 | + */ |
|
47 | + private static $_iframe_embed_button; |
|
48 | + |
|
49 | + /** |
|
50 | + * @type EE_Template_Part_Manager $template_parts |
|
51 | + */ |
|
52 | + protected $template_parts; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @return EED_Events_Archive |
|
57 | + */ |
|
58 | + public static function instance() |
|
59 | + { |
|
60 | + return parent::get_instance(__CLASS__); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
66 | + * |
|
67 | + * @return void |
|
68 | + * @throws InvalidArgumentException |
|
69 | + * @throws InvalidDataTypeException |
|
70 | + * @throws InvalidInterfaceException |
|
71 | + */ |
|
72 | + public static function set_hooks() |
|
73 | + { |
|
74 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
75 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
76 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
77 | + ); |
|
78 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
79 | + EE_Config::register_route( |
|
80 | + $custom_post_types['espresso_events']['plural_slug'], |
|
81 | + 'Events_Archive', |
|
82 | + 'run' |
|
83 | + ); |
|
84 | + EE_Config::register_route( |
|
85 | + 'event_list', |
|
86 | + 'Events_Archive', |
|
87 | + 'event_list' |
|
88 | + ); |
|
89 | + EE_Config::register_route( |
|
90 | + 'iframe', |
|
91 | + 'Events_Archive', |
|
92 | + 'event_list_iframe', |
|
93 | + 'event_list' |
|
94 | + ); |
|
95 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
101 | + * |
|
102 | + * @access public |
|
103 | + * @return void |
|
104 | + */ |
|
105 | + public static function set_hooks_admin() |
|
106 | + { |
|
107 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
108 | + // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
109 | + // to load assets for "espresso_events" page on the "default" route (action) |
|
110 | + add_action( |
|
111 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
|
112 | + array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
113 | + 10 |
|
114 | + ); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * set_definitions |
|
120 | + * |
|
121 | + * @access public |
|
122 | + * @return void |
|
123 | + */ |
|
124 | + public static function set_definitions() |
|
125 | + { |
|
126 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
127 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * set up EE_Events_Archive_Config |
|
133 | + */ |
|
134 | + protected function set_config() |
|
135 | + { |
|
136 | + $this->set_config_section('template_settings'); |
|
137 | + $this->set_config_class('EE_Events_Archive_Config'); |
|
138 | + $this->set_config_name('EED_Events_Archive'); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @return EventListIframeEmbedButton |
|
144 | + */ |
|
145 | + public static function get_iframe_embed_button() |
|
146 | + { |
|
147 | + if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
148 | + self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
|
149 | + } |
|
150 | + return self::$_iframe_embed_button; |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * event_list_iframe_embed_button |
|
156 | + * |
|
157 | + * @return void |
|
158 | + * @throws \EE_Error |
|
159 | + */ |
|
160 | + public static function event_list_iframe_embed_button() |
|
161 | + { |
|
162 | + $iframe_embed_button = \EED_Events_Archive::get_iframe_embed_button(); |
|
163 | + $iframe_embed_button->addEmbedButton(); |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * initialize_template_parts |
|
169 | + * |
|
170 | + * @access public |
|
171 | + * @param \EE_Events_Archive_Config $config |
|
172 | + * @return \EE_Template_Part_Manager |
|
173 | + */ |
|
174 | + public function initialize_template_parts(EE_Events_Archive_Config $config = null) |
|
175 | + { |
|
176 | + $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
|
177 | + EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
178 | + $template_parts = new EE_Template_Part_Manager(); |
|
179 | + $template_parts->add_template_part( |
|
180 | + 'tickets', |
|
181 | + __('Ticket Selector', 'event_espresso'), |
|
182 | + 'content-espresso_events-tickets.php', |
|
183 | + $config->display_order_tickets |
|
184 | + ); |
|
185 | + $template_parts->add_template_part( |
|
186 | + 'datetimes', |
|
187 | + __('Dates and Times', 'event_espresso'), |
|
188 | + 'content-espresso_events-datetimes.php', |
|
189 | + $config->display_order_datetimes |
|
190 | + ); |
|
191 | + $template_parts->add_template_part( |
|
192 | + 'event', |
|
193 | + __('Event Description', 'event_espresso'), |
|
194 | + 'content-espresso_events-details.php', |
|
195 | + $config->display_order_event |
|
196 | + ); |
|
197 | + $template_parts->add_template_part( |
|
198 | + 'venue', |
|
199 | + __('Venue Information', 'event_espresso'), |
|
200 | + 'content-espresso_events-venues.php', |
|
201 | + $config->display_order_venue |
|
202 | + ); |
|
203 | + do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
204 | + return $template_parts; |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the |
|
210 | + * incoming request |
|
211 | + * |
|
212 | + * @access public |
|
213 | + * @param WP $WP |
|
214 | + * @return void |
|
215 | + */ |
|
216 | + public function run($WP) |
|
217 | + { |
|
218 | + do_action('AHEE__EED_Events_Archive__before_run'); |
|
219 | + // ensure valid EE_Events_Archive_Config() object exists |
|
220 | + $this->set_config(); |
|
221 | + /** @type EE_Events_Archive_Config $config */ |
|
222 | + $config = $this->config(); |
|
223 | + // load other required components |
|
224 | + $this->load_event_list_assets(); |
|
225 | + // filter the WP posts_join, posts_where, and posts_orderby SQL clauses |
|
226 | + // add query filters |
|
227 | + EEH_Event_Query::add_query_filters(); |
|
228 | + // set params that will get used by the filters |
|
229 | + EEH_Event_Query::set_query_params( |
|
230 | + '', // month |
|
231 | + '', // category |
|
232 | + $config->display_expired_events, // show_expired |
|
233 | + 'start_date', // orderby |
|
234 | + 'ASC' // sort |
|
235 | + ); |
|
236 | + // check what template is loaded |
|
237 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
243 | + * |
|
244 | + * @return void |
|
245 | + */ |
|
246 | + public function event_list() |
|
247 | + { |
|
248 | + // ensure valid EE_Events_Archive_Config() object exists |
|
249 | + $this->set_config(); |
|
250 | + // load other required components |
|
251 | + $this->load_event_list_assets(); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * @access public |
|
257 | + * @return void |
|
258 | + * @throws \EE_Error |
|
259 | + * @throws \DomainException |
|
260 | + */ |
|
261 | + public function event_list_iframe() |
|
262 | + { |
|
263 | + \EED_Events_Archive::$iframe = true; |
|
264 | + $event_list_iframe = new EventsArchiveIframe($this); |
|
265 | + $event_list_iframe->display(); |
|
266 | + } |
|
267 | + |
|
268 | + |
|
269 | + /** |
|
270 | + * @access public |
|
271 | + * @return string |
|
272 | + */ |
|
273 | + public static function is_iframe() |
|
274 | + { |
|
275 | + return \EED_Events_Archive::$iframe; |
|
276 | + } |
|
277 | + |
|
278 | + |
|
279 | + /** |
|
280 | + * @access public |
|
281 | + * @return string |
|
282 | + */ |
|
283 | + public static function link_target() |
|
284 | + { |
|
285 | + return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * template_include |
|
291 | + * |
|
292 | + * @access public |
|
293 | + * @param string $template |
|
294 | + * @return string |
|
295 | + */ |
|
296 | + public function template_include($template = '') |
|
297 | + { |
|
298 | + // don't add content filter for dedicated EE child themes or private posts |
|
299 | + if (! EEH_Template::is_espresso_theme()) { |
|
300 | + /** @type EE_Events_Archive_Config $config */ |
|
301 | + $config = $this->config(); |
|
302 | + // add status banner ? |
|
303 | + if ($config->display_status_banner) { |
|
304 | + add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
305 | + } |
|
306 | + // if NOT a custom template |
|
307 | + if (apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
308 | + || EE_Registry::instance() |
|
309 | + ->load_core('Front_Controller') |
|
310 | + ->get_selected_template() !== 'archive-espresso_events.php' |
|
311 | + ) { |
|
312 | + // don't display entry meta because the existing theme will take care of that |
|
313 | + add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
314 | + // load functions.php file for the theme (loaded by WP if using child theme) |
|
315 | + EEH_Template::load_espresso_theme_functions(); |
|
316 | + // because we don't know if the theme is using the_excerpt() |
|
317 | + add_filter( |
|
318 | + 'the_excerpt', |
|
319 | + array('EED_Events_Archive', 'event_details'), |
|
320 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
321 | + ); |
|
322 | + // or the_content |
|
323 | + add_filter( |
|
324 | + 'the_content', |
|
325 | + array('EED_Events_Archive', 'event_details'), |
|
326 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
327 | + ); |
|
328 | + // and just in case they are running get_the_excerpt() which DESTROYS things |
|
329 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
330 | + // don't display entry meta because the existing theme will take care of that |
|
331 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
332 | + } |
|
333 | + } |
|
334 | + return $template; |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters |
|
340 | + * on the_content() |
|
341 | + * |
|
342 | + * @access public |
|
343 | + * @param string $excerpt |
|
344 | + * @return string |
|
345 | + */ |
|
346 | + public static function get_the_excerpt($excerpt = '') |
|
347 | + { |
|
348 | + if (post_password_required()) { |
|
349 | + return $excerpt; |
|
350 | + } |
|
351 | + if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
352 | + remove_filter( |
|
353 | + 'the_excerpt', |
|
354 | + array('EED_Events_Archive', 'event_details'), |
|
355 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
356 | + ); |
|
357 | + remove_filter( |
|
358 | + 'the_content', |
|
359 | + array('EED_Events_Archive', 'event_details'), |
|
360 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
361 | + ); |
|
362 | + $excerpt = EED_Events_Archive::event_details($excerpt); |
|
363 | + } else { |
|
364 | + EED_Events_Archive::$using_get_the_excerpt = true; |
|
365 | + add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
366 | + } |
|
367 | + return $excerpt; |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * end_get_the_excerpt |
|
373 | + * |
|
374 | + * @access public |
|
375 | + * @param string $text |
|
376 | + * @return string |
|
377 | + */ |
|
378 | + public static function end_get_the_excerpt($text = '') |
|
379 | + { |
|
380 | + EED_Events_Archive::$using_get_the_excerpt = false; |
|
381 | + return $text; |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * the_title |
|
387 | + * |
|
388 | + * @access public |
|
389 | + * @param string $title |
|
390 | + * @param string $id |
|
391 | + * @return string |
|
392 | + */ |
|
393 | + public static function the_title($title = '', $id = '') |
|
394 | + { |
|
395 | + global $post; |
|
396 | + if ($post instanceof WP_Post) { |
|
397 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID) . $title : $title; |
|
398 | + } |
|
399 | + return $title; |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * event_details |
|
405 | + * |
|
406 | + * @access public |
|
407 | + * @param string $content |
|
408 | + * @return string |
|
409 | + */ |
|
410 | + public static function event_details($content) |
|
411 | + { |
|
412 | + global $post; |
|
413 | + static $current_post_ID = 0; |
|
414 | + if ($current_post_ID !== $post->ID |
|
415 | + && $post->post_type === 'espresso_events' |
|
416 | + && ! EED_Events_Archive::$using_get_the_excerpt |
|
417 | + && ! post_password_required() |
|
418 | + && ( |
|
419 | + apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
420 | + || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
421 | + ) |
|
422 | + ) { |
|
423 | + // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
424 | + // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
425 | + // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
426 | + // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
427 | + // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
428 | + // so the following allows this filter to be applied multiple times, but only once for real |
|
429 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
430 | + if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
431 | + $content = \EED_Events_Archive::use_sortable_display_order(); |
|
432 | + } else { |
|
433 | + $content = \EED_Events_Archive::use_filterable_display_order(); |
|
434 | + } |
|
435 | + } |
|
436 | + return $content; |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * use_sortable_display_order |
|
442 | + * |
|
443 | + * @access protected |
|
444 | + * @return string |
|
445 | + */ |
|
446 | + protected static function use_sortable_display_order() |
|
447 | + { |
|
448 | + // no further password checks required atm |
|
449 | + add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
450 | + // we need to first remove this callback from being applied to the_content() or the_excerpt() |
|
451 | + // (otherwise it will recurse and blow up the interweb) |
|
452 | + remove_filter( |
|
453 | + 'the_excerpt', |
|
454 | + array('EED_Events_Archive', 'event_details'), |
|
455 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
456 | + ); |
|
457 | + remove_filter( |
|
458 | + 'the_content', |
|
459 | + array('EED_Events_Archive', 'event_details'), |
|
460 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
461 | + ); |
|
462 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
463 | + // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
464 | + EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
|
465 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
466 | + $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
467 | + // re-add our main filters (or else the next event won't have them) |
|
468 | + add_filter( |
|
469 | + 'the_excerpt', |
|
470 | + array('EED_Events_Archive', 'event_details'), |
|
471 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
472 | + ); |
|
473 | + add_filter( |
|
474 | + 'the_content', |
|
475 | + array('EED_Events_Archive', 'event_details'), |
|
476 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
477 | + ); |
|
478 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
479 | + remove_filter( |
|
480 | + 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
481 | + '__return_true' |
|
482 | + ); |
|
483 | + return $content; |
|
484 | + } |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | + * use_filterable_display_order |
|
489 | + * |
|
490 | + * @access protected |
|
491 | + * @return string |
|
492 | + */ |
|
493 | + protected static function use_filterable_display_order() |
|
494 | + { |
|
495 | + // we need to first remove this callback from being applied to the_content() |
|
496 | + // (otherwise it will recurse and blow up the interweb) |
|
497 | + remove_filter( |
|
498 | + 'the_excerpt', |
|
499 | + array('EED_Events_Archive', 'event_details'), |
|
500 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
501 | + ); |
|
502 | + remove_filter( |
|
503 | + 'the_content', |
|
504 | + array('EED_Events_Archive', 'event_details'), |
|
505 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
506 | + ); |
|
507 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
508 | + // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
509 | + EED_Events_Archive::_add_additional_excerpt_filters(); |
|
510 | + EED_Events_Archive::_add_additional_content_filters(); |
|
511 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
512 | + // now load our template |
|
513 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
514 | + // re-add our main filters (or else the next event won't have them) |
|
515 | + add_filter( |
|
516 | + 'the_excerpt', |
|
517 | + array('EED_Events_Archive', 'event_details'), |
|
518 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
519 | + ); |
|
520 | + add_filter( |
|
521 | + 'the_content', |
|
522 | + array('EED_Events_Archive', 'event_details'), |
|
523 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
524 | + ); |
|
525 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
526 | + // but remove the other filters so that they don't get applied to the next post |
|
527 | + EED_Events_Archive::_remove_additional_events_archive_filters(); |
|
528 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
529 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
530 | + // return ! empty( $template ) ? $template : $content; |
|
531 | + return $content; |
|
532 | + } |
|
533 | + |
|
534 | + |
|
535 | + /** |
|
536 | + * event_datetimes - adds datetimes ABOVE content |
|
537 | + * |
|
538 | + * @access public |
|
539 | + * @param string $content |
|
540 | + * @return string |
|
541 | + */ |
|
542 | + public static function event_datetimes($content) |
|
543 | + { |
|
544 | + if (post_password_required()) { |
|
545 | + return $content; |
|
546 | + } |
|
547 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
548 | + } |
|
549 | + |
|
550 | + |
|
551 | + /** |
|
552 | + * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
553 | + * |
|
554 | + * @access public |
|
555 | + * @param string $content |
|
556 | + * @return string |
|
557 | + */ |
|
558 | + public static function event_tickets($content) |
|
559 | + { |
|
560 | + if (post_password_required()) { |
|
561 | + return $content; |
|
562 | + } |
|
563 | + return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
564 | + } |
|
565 | + |
|
566 | + |
|
567 | + /** |
|
568 | + * event_venues - adds venues BELOW content |
|
569 | + * |
|
570 | + * @access public |
|
571 | + * @param string $content |
|
572 | + * @return string |
|
573 | + */ |
|
574 | + public static function event_venue($content) |
|
575 | + { |
|
576 | + return EED_Events_Archive::event_venues($content); |
|
577 | + } |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * event_venues - adds venues BELOW content |
|
582 | + * |
|
583 | + * @access public |
|
584 | + * @param string $content |
|
585 | + * @return string |
|
586 | + */ |
|
587 | + public static function event_venues($content) |
|
588 | + { |
|
589 | + if (post_password_required()) { |
|
590 | + return $content; |
|
591 | + } |
|
592 | + return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
593 | + } |
|
594 | + |
|
595 | + |
|
596 | + /** |
|
597 | + * _add_additional_content_filters |
|
598 | + * |
|
599 | + * @access private |
|
600 | + * @return void |
|
601 | + */ |
|
602 | + private static function _add_additional_excerpt_filters() |
|
603 | + { |
|
604 | + add_filter( |
|
605 | + 'the_excerpt', |
|
606 | + array('EED_Events_Archive', 'event_datetimes'), |
|
607 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
608 | + ); |
|
609 | + add_filter( |
|
610 | + 'the_excerpt', |
|
611 | + array('EED_Events_Archive', 'event_tickets'), |
|
612 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
613 | + ); |
|
614 | + add_filter( |
|
615 | + 'the_excerpt', |
|
616 | + array('EED_Events_Archive', 'event_venues'), |
|
617 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
618 | + ); |
|
619 | + } |
|
620 | + |
|
621 | + |
|
622 | + /** |
|
623 | + * _add_additional_content_filters |
|
624 | + * |
|
625 | + * @access private |
|
626 | + * @return void |
|
627 | + */ |
|
628 | + private static function _add_additional_content_filters() |
|
629 | + { |
|
630 | + add_filter( |
|
631 | + 'the_content', |
|
632 | + array('EED_Events_Archive', 'event_datetimes'), |
|
633 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
634 | + ); |
|
635 | + add_filter( |
|
636 | + 'the_content', |
|
637 | + array('EED_Events_Archive', 'event_tickets'), |
|
638 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
639 | + ); |
|
640 | + add_filter( |
|
641 | + 'the_content', |
|
642 | + array('EED_Events_Archive', 'event_venues'), |
|
643 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
644 | + ); |
|
645 | + } |
|
646 | + |
|
647 | + |
|
648 | + /** |
|
649 | + * _remove_additional_events_archive_filters |
|
650 | + * |
|
651 | + * @access private |
|
652 | + * @return void |
|
653 | + */ |
|
654 | + private static function _remove_additional_events_archive_filters() |
|
655 | + { |
|
656 | + remove_filter( |
|
657 | + 'the_excerpt', |
|
658 | + array('EED_Events_Archive', 'event_datetimes'), |
|
659 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
660 | + ); |
|
661 | + remove_filter( |
|
662 | + 'the_excerpt', |
|
663 | + array('EED_Events_Archive', 'event_tickets'), |
|
664 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
665 | + ); |
|
666 | + remove_filter( |
|
667 | + 'the_excerpt', |
|
668 | + array('EED_Events_Archive', 'event_venues'), |
|
669 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
670 | + ); |
|
671 | + remove_filter( |
|
672 | + 'the_content', |
|
673 | + array('EED_Events_Archive', 'event_datetimes'), |
|
674 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
675 | + ); |
|
676 | + remove_filter( |
|
677 | + 'the_content', |
|
678 | + array('EED_Events_Archive', 'event_tickets'), |
|
679 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
680 | + ); |
|
681 | + remove_filter( |
|
682 | + 'the_content', |
|
683 | + array('EED_Events_Archive', 'event_venues'), |
|
684 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
685 | + ); |
|
686 | + } |
|
687 | + |
|
688 | + |
|
689 | + /** |
|
690 | + * remove_all_events_archive_filters |
|
691 | + * |
|
692 | + * @access public |
|
693 | + * @return void |
|
694 | + */ |
|
695 | + public static function remove_all_events_archive_filters() |
|
696 | + { |
|
697 | + // remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
698 | + remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1); |
|
699 | + remove_filter( |
|
700 | + 'the_excerpt', |
|
701 | + array('EED_Events_Archive', 'event_details'), |
|
702 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
703 | + ); |
|
704 | + remove_filter( |
|
705 | + 'the_excerpt', |
|
706 | + array('EED_Events_Archive', 'event_datetimes'), |
|
707 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
708 | + ); |
|
709 | + remove_filter( |
|
710 | + 'the_excerpt', |
|
711 | + array('EED_Events_Archive', 'event_tickets'), |
|
712 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
713 | + ); |
|
714 | + remove_filter( |
|
715 | + 'the_excerpt', |
|
716 | + array('EED_Events_Archive', 'event_venues'), |
|
717 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
718 | + ); |
|
719 | + remove_filter( |
|
720 | + 'the_content', |
|
721 | + array('EED_Events_Archive', 'event_details'), |
|
722 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
723 | + ); |
|
724 | + remove_filter( |
|
725 | + 'the_content', |
|
726 | + array('EED_Events_Archive', 'event_datetimes'), |
|
727 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
728 | + ); |
|
729 | + remove_filter( |
|
730 | + 'the_content', |
|
731 | + array('EED_Events_Archive', 'event_tickets'), |
|
732 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
733 | + ); |
|
734 | + remove_filter( |
|
735 | + 'the_content', |
|
736 | + array('EED_Events_Archive', 'event_venues'), |
|
737 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
738 | + ); |
|
739 | + // don't display entry meta because the existing theme will take care of that |
|
740 | + remove_filter( |
|
741 | + 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
742 | + '__return_false' |
|
743 | + ); |
|
744 | + } |
|
745 | + |
|
746 | + |
|
747 | + /** |
|
748 | + * load_event_list_assets |
|
749 | + * |
|
750 | + * @access public |
|
751 | + * @return void |
|
752 | + */ |
|
753 | + public function load_event_list_assets() |
|
754 | + { |
|
755 | + do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
756 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
757 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
758 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
759 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
760 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
761 | + } |
|
762 | + } |
|
763 | + |
|
764 | + |
|
765 | + /** |
|
766 | + * wp_enqueue_scripts |
|
767 | + * |
|
768 | + * @access public |
|
769 | + * @return void |
|
770 | + */ |
|
771 | + public function wp_enqueue_scripts() |
|
772 | + { |
|
773 | + // get some style |
|
774 | + if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
|
775 | + // first check uploads folder |
|
776 | + if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
777 | + wp_register_style( |
|
778 | + $this->theme, |
|
779 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
780 | + array('dashicons', 'espresso_default') |
|
781 | + ); |
|
782 | + } else { |
|
783 | + } |
|
784 | + wp_enqueue_style($this->theme); |
|
785 | + } |
|
786 | + } |
|
787 | + |
|
788 | + |
|
789 | + /** |
|
790 | + * template_settings_form |
|
791 | + * |
|
792 | + * @access public |
|
793 | + * @static |
|
794 | + * @return string |
|
795 | + */ |
|
796 | + public static function template_settings_form() |
|
797 | + { |
|
798 | + $template_settings = EE_Registry::instance()->CFG->template_settings; |
|
799 | + $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) |
|
800 | + ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
801 | + $template_settings->EED_Events_Archive = apply_filters( |
|
802 | + 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
|
803 | + $template_settings->EED_Events_Archive |
|
804 | + ); |
|
805 | + $events_archive_settings = array( |
|
806 | + 'display_status_banner' => 0, |
|
807 | + 'display_description' => 1, |
|
808 | + 'display_ticket_selector' => 0, |
|
809 | + 'display_datetimes' => 1, |
|
810 | + 'display_venue' => 0, |
|
811 | + 'display_expired_events' => 0, |
|
812 | + ); |
|
813 | + $events_archive_settings = array_merge( |
|
814 | + $events_archive_settings, |
|
815 | + (array) $template_settings->EED_Events_Archive |
|
816 | + ); |
|
817 | + EEH_Template::display_template( |
|
818 | + EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
819 | + $events_archive_settings |
|
820 | + ); |
|
821 | + } |
|
822 | + |
|
823 | + |
|
824 | + /** |
|
825 | + * update_template_settings |
|
826 | + * |
|
827 | + * @access public |
|
828 | + * @param EE_Template_Config $CFG |
|
829 | + * @param EE_Request_Handler $REQ |
|
830 | + * @return EE_Template_Config |
|
831 | + */ |
|
832 | + public static function update_template_settings($CFG, $REQ) |
|
833 | + { |
|
834 | + $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
|
835 | + // unless we are resetting the config... |
|
836 | + if (! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
837 | + || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1 |
|
838 | + ) { |
|
839 | + $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) |
|
840 | + ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
841 | + $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) |
|
842 | + ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
843 | + $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) |
|
844 | + ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
845 | + $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint( |
|
846 | + $REQ['EED_Events_Archive_display_datetimes'] |
|
847 | + ) : 1; |
|
848 | + $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint( |
|
849 | + $REQ['EED_Events_Archive_display_venue'] |
|
850 | + ) : 0; |
|
851 | + $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) |
|
852 | + ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; |
|
853 | + } |
|
854 | + return $CFG; |
|
855 | + } |
|
856 | + |
|
857 | + |
|
858 | + /** |
|
859 | + * event_list_css |
|
860 | + * |
|
861 | + * @access public |
|
862 | + * @param string $extra_class |
|
863 | + * @return string |
|
864 | + */ |
|
865 | + public static function event_list_css($extra_class = '') |
|
866 | + { |
|
867 | + $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
868 | + $event_list_css[] = 'espresso-event-list-event'; |
|
869 | + return implode(' ', $event_list_css); |
|
870 | + } |
|
871 | + |
|
872 | + |
|
873 | + /** |
|
874 | + * event_categories |
|
875 | + * |
|
876 | + * @access public |
|
877 | + * @return array |
|
878 | + */ |
|
879 | + public static function event_categories() |
|
880 | + { |
|
881 | + return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
882 | + } |
|
883 | + |
|
884 | + |
|
885 | + /** |
|
886 | + * display_description |
|
887 | + * |
|
888 | + * @access public |
|
889 | + * @param $value |
|
890 | + * @return bool |
|
891 | + */ |
|
892 | + public static function display_description($value) |
|
893 | + { |
|
894 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
895 | + $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
896 | + return $display_description === $value ? true : false; |
|
897 | + } |
|
898 | + |
|
899 | + |
|
900 | + /** |
|
901 | + * display_ticket_selector |
|
902 | + * |
|
903 | + * @access public |
|
904 | + * @return bool |
|
905 | + */ |
|
906 | + public static function display_ticket_selector() |
|
907 | + { |
|
908 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
909 | + return isset($config->display_ticket_selector) && $config->display_ticket_selector ? true : false; |
|
910 | + } |
|
911 | + |
|
912 | + |
|
913 | + /** |
|
914 | + * display_venue |
|
915 | + * |
|
916 | + * @access public |
|
917 | + * @return bool |
|
918 | + */ |
|
919 | + public static function display_venue() |
|
920 | + { |
|
921 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
922 | + return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? true : false; |
|
923 | + } |
|
924 | + |
|
925 | + |
|
926 | + /** |
|
927 | + * display_datetimes |
|
928 | + * |
|
929 | + * @access public |
|
930 | + * @return bool |
|
931 | + */ |
|
932 | + public static function display_datetimes() |
|
933 | + { |
|
934 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
935 | + return isset($config->display_datetimes) && $config->display_datetimes ? true : false; |
|
936 | + } |
|
937 | + |
|
938 | + |
|
939 | + /** |
|
940 | + * event_list_title |
|
941 | + * |
|
942 | + * @access public |
|
943 | + * @return string |
|
944 | + */ |
|
945 | + public static function event_list_title() |
|
946 | + { |
|
947 | + return apply_filters( |
|
948 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
949 | + __('Upcoming Events', 'event_espresso') |
|
950 | + ); |
|
951 | + } |
|
952 | + |
|
953 | + |
|
954 | + // GRAVEYARD |
|
955 | + |
|
956 | + |
|
957 | + /** |
|
958 | + * @since 4.4.0 |
|
959 | + */ |
|
960 | + public static function _doing_it_wrong_notice($function = '') |
|
961 | + { |
|
962 | + EE_Error::doing_it_wrong( |
|
963 | + __FUNCTION__, |
|
964 | + sprintf( |
|
965 | + __( |
|
966 | + 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', |
|
967 | + 'event_espresso' |
|
968 | + ), |
|
969 | + $function, |
|
970 | + '<br />', |
|
971 | + '4.6.0' |
|
972 | + ), |
|
973 | + '4.4.0' |
|
974 | + ); |
|
975 | + } |
|
976 | + |
|
977 | + |
|
978 | + /** |
|
979 | + * @deprecated |
|
980 | + * @since 4.4.0 |
|
981 | + */ |
|
982 | + public function get_post_data() |
|
983 | + { |
|
984 | + EEH_Event_Query::set_query_params(); |
|
985 | + } |
|
986 | + |
|
987 | + |
|
988 | + /** |
|
989 | + * @deprecated |
|
990 | + * @since 4.4.0 |
|
991 | + */ |
|
992 | + public function posts_fields($SQL, WP_Query $wp_query) |
|
993 | + { |
|
994 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
995 | + return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
996 | + } |
|
997 | + |
|
998 | + |
|
999 | + /** |
|
1000 | + * @deprecated |
|
1001 | + * @since 4.4.0 |
|
1002 | + */ |
|
1003 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) |
|
1004 | + { |
|
1005 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1006 | + return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
1007 | + } |
|
1008 | + |
|
1009 | + |
|
1010 | + /** |
|
1011 | + * @deprecated |
|
1012 | + * @since 4.4.0 |
|
1013 | + */ |
|
1014 | + public function posts_join($SQL, WP_Query $wp_query) |
|
1015 | + { |
|
1016 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1017 | + return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
1018 | + } |
|
1019 | + |
|
1020 | + |
|
1021 | + /** |
|
1022 | + * @deprecated |
|
1023 | + * @since 4.4.0 |
|
1024 | + */ |
|
1025 | + public static function posts_join_sql_for_terms($join_terms = null) |
|
1026 | + { |
|
1027 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1028 | + return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
1029 | + } |
|
1030 | + |
|
1031 | + |
|
1032 | + /** |
|
1033 | + * @deprecated |
|
1034 | + * @since 4.4.0 |
|
1035 | + */ |
|
1036 | + public static function posts_join_for_orderby($orderby_params = array()) |
|
1037 | + { |
|
1038 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1039 | + return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
1040 | + } |
|
1041 | + |
|
1042 | + |
|
1043 | + /** |
|
1044 | + * @deprecated |
|
1045 | + * @since 4.4.0 |
|
1046 | + */ |
|
1047 | + public function posts_where($SQL, WP_Query $wp_query) |
|
1048 | + { |
|
1049 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1050 | + return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
1051 | + } |
|
1052 | + |
|
1053 | + |
|
1054 | + /** |
|
1055 | + * @deprecated |
|
1056 | + * @since 4.4.0 |
|
1057 | + */ |
|
1058 | + public static function posts_where_sql_for_show_expired($show_expired = false) |
|
1059 | + { |
|
1060 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1061 | + return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
1062 | + } |
|
1063 | + |
|
1064 | + |
|
1065 | + /** |
|
1066 | + * @deprecated |
|
1067 | + * @since 4.4.0 |
|
1068 | + */ |
|
1069 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
1070 | + { |
|
1071 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1072 | + return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
1073 | + } |
|
1074 | + |
|
1075 | + |
|
1076 | + /** |
|
1077 | + * @deprecated |
|
1078 | + * @since 4.4.0 |
|
1079 | + */ |
|
1080 | + public static function posts_where_sql_for_event_list_month($month = null) |
|
1081 | + { |
|
1082 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1083 | + return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
1084 | + } |
|
1085 | + |
|
1086 | + |
|
1087 | + /** |
|
1088 | + * @deprecated |
|
1089 | + * @since 4.4.0 |
|
1090 | + */ |
|
1091 | + public function posts_orderby($SQL, WP_Query $wp_query) |
|
1092 | + { |
|
1093 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1094 | + return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
1095 | + } |
|
1096 | + |
|
1097 | + |
|
1098 | + /** |
|
1099 | + * @deprecated |
|
1100 | + * @since 4.4.0 |
|
1101 | + */ |
|
1102 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') |
|
1103 | + { |
|
1104 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
1105 | + return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
1106 | + } |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | |
@@ -1112,9 +1112,9 @@ discard block |
||
1112 | 1112 | */ |
1113 | 1113 | function espresso_get_event_list_ID() |
1114 | 1114 | { |
1115 | - EED_Events_Archive::$espresso_event_list_ID++; |
|
1116 | - EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID; |
|
1117 | - return EED_Events_Archive::$espresso_event_list_ID; |
|
1115 | + EED_Events_Archive::$espresso_event_list_ID++; |
|
1116 | + EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID; |
|
1117 | + return EED_Events_Archive::$espresso_event_list_ID; |
|
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | /** |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | */ |
1123 | 1123 | function espresso_event_list_title() |
1124 | 1124 | { |
1125 | - return EED_Events_Archive::event_list_title(); |
|
1125 | + return EED_Events_Archive::event_list_title(); |
|
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | /** |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | */ |
1132 | 1132 | function espresso_event_list_css($extra_class = '') |
1133 | 1133 | { |
1134 | - return EED_Events_Archive::event_list_css($extra_class); |
|
1134 | + return EED_Events_Archive::event_list_css($extra_class); |
|
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | /** |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | */ |
1140 | 1140 | function espresso_get_event_categories() |
1141 | 1141 | { |
1142 | - return EED_Events_Archive::event_categories(); |
|
1142 | + return EED_Events_Archive::event_categories(); |
|
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | /** |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | */ |
1148 | 1148 | function espresso_display_full_description_in_event_list() |
1149 | 1149 | { |
1150 | - return EED_Events_Archive::display_description(2); |
|
1150 | + return EED_Events_Archive::display_description(2); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | /** |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | */ |
1156 | 1156 | function espresso_display_excerpt_in_event_list() |
1157 | 1157 | { |
1158 | - return EED_Events_Archive::display_description(1); |
|
1158 | + return EED_Events_Archive::display_description(1); |
|
1159 | 1159 | } |
1160 | 1160 | |
1161 | 1161 | /** |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | */ |
1164 | 1164 | function espresso_display_ticket_selector_in_event_list() |
1165 | 1165 | { |
1166 | - return EED_Events_Archive::display_ticket_selector(); |
|
1166 | + return EED_Events_Archive::display_ticket_selector(); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | /** |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | */ |
1172 | 1172 | function espresso_display_venue_in_event_list() |
1173 | 1173 | { |
1174 | - return EED_Events_Archive::display_venue(); |
|
1174 | + return EED_Events_Archive::display_venue(); |
|
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | /** |
@@ -1179,5 +1179,5 @@ discard block |
||
1179 | 1179 | */ |
1180 | 1180 | function espresso_display_datetimes_in_event_list() |
1181 | 1181 | { |
1182 | - return EED_Events_Archive::display_datetimes(); |
|
1182 | + return EED_Events_Archive::display_datetimes(); |
|
1183 | 1183 | } |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public static function set_definitions() |
125 | 125 | { |
126 | - define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
127 | - define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
126 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
127 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public static function get_iframe_embed_button() |
146 | 146 | { |
147 | - if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
147 | + if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
148 | 148 | self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
149 | 149 | } |
150 | 150 | return self::$_iframe_embed_button; |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | EEH_Event_Query::add_query_filters(); |
228 | 228 | // set params that will get used by the filters |
229 | 229 | EEH_Event_Query::set_query_params( |
230 | - '', // month |
|
231 | - '', // category |
|
232 | - $config->display_expired_events, // show_expired |
|
233 | - 'start_date', // orderby |
|
230 | + '', // month |
|
231 | + '', // category |
|
232 | + $config->display_expired_events, // show_expired |
|
233 | + 'start_date', // orderby |
|
234 | 234 | 'ASC' // sort |
235 | 235 | ); |
236 | 236 | // check what template is loaded |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | public function template_include($template = '') |
297 | 297 | { |
298 | 298 | // don't add content filter for dedicated EE child themes or private posts |
299 | - if (! EEH_Template::is_espresso_theme()) { |
|
299 | + if ( ! EEH_Template::is_espresso_theme()) { |
|
300 | 300 | /** @type EE_Events_Archive_Config $config */ |
301 | 301 | $config = $this->config(); |
302 | 302 | // add status banner ? |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | { |
395 | 395 | global $post; |
396 | 396 | if ($post instanceof WP_Post) { |
397 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID) . $title : $title; |
|
397 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
398 | 398 | } |
399 | 399 | return $title; |
400 | 400 | } |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | if (post_password_required()) { |
545 | 545 | return $content; |
546 | 546 | } |
547 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
547 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | if (post_password_required()) { |
561 | 561 | return $content; |
562 | 562 | } |
563 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
563 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | if (post_password_required()) { |
590 | 590 | return $content; |
591 | 591 | } |
592 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
592 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | |
@@ -773,10 +773,10 @@ discard block |
||
773 | 773 | // get some style |
774 | 774 | if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
775 | 775 | // first check uploads folder |
776 | - if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
776 | + if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.'/style.css')) { |
|
777 | 777 | wp_register_style( |
778 | 778 | $this->theme, |
779 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
779 | + get_stylesheet_directory_uri().$this->theme.'/style.css', |
|
780 | 780 | array('dashicons', 'espresso_default') |
781 | 781 | ); |
782 | 782 | } else { |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | (array) $template_settings->EED_Events_Archive |
816 | 816 | ); |
817 | 817 | EEH_Template::display_template( |
818 | - EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
818 | + EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', |
|
819 | 819 | $events_archive_settings |
820 | 820 | ); |
821 | 821 | } |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | { |
834 | 834 | $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
835 | 835 | // unless we are resetting the config... |
836 | - if (! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
836 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
837 | 837 | || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1 |
838 | 838 | ) { |
839 | 839 | $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) |
@@ -15,1800 +15,1800 @@ |
||
15 | 15 | class EED_Single_Page_Checkout extends EED_Module |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * $_initialized - has the SPCO controller already been initialized ? |
|
20 | - * |
|
21 | - * @access private |
|
22 | - * @var bool $_initialized |
|
23 | - */ |
|
24 | - private static $_initialized = false; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
29 | - * |
|
30 | - * @access private |
|
31 | - * @var bool $_valid_checkout |
|
32 | - */ |
|
33 | - private static $_checkout_verified = true; |
|
34 | - |
|
35 | - /** |
|
36 | - * $_reg_steps_array - holds initial array of reg steps |
|
37 | - * |
|
38 | - * @access private |
|
39 | - * @var array $_reg_steps_array |
|
40 | - */ |
|
41 | - private static $_reg_steps_array = array(); |
|
42 | - |
|
43 | - /** |
|
44 | - * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
45 | - * |
|
46 | - * @access public |
|
47 | - * @var EE_Checkout $checkout |
|
48 | - */ |
|
49 | - public $checkout; |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * @return EED_Module|EED_Single_Page_Checkout |
|
54 | - */ |
|
55 | - public static function instance() |
|
56 | - { |
|
57 | - add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
58 | - return parent::get_instance(__CLASS__); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @return EE_CART |
|
64 | - */ |
|
65 | - public function cart() |
|
66 | - { |
|
67 | - return $this->checkout->cart; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return EE_Transaction |
|
73 | - */ |
|
74 | - public function transaction() |
|
75 | - { |
|
76 | - return $this->checkout->transaction; |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
82 | - * |
|
83 | - * @access public |
|
84 | - * @return void |
|
85 | - * @throws EE_Error |
|
86 | - */ |
|
87 | - public static function set_hooks() |
|
88 | - { |
|
89 | - EED_Single_Page_Checkout::set_definitions(); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
95 | - * |
|
96 | - * @access public |
|
97 | - * @return void |
|
98 | - * @throws EE_Error |
|
99 | - */ |
|
100 | - public static function set_hooks_admin() |
|
101 | - { |
|
102 | - EED_Single_Page_Checkout::set_definitions(); |
|
103 | - if (! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
104 | - return; |
|
105 | - } |
|
106 | - // going to start an output buffer in case anything gets accidentally output |
|
107 | - // that might disrupt our JSON response |
|
108 | - ob_start(); |
|
109 | - EED_Single_Page_Checkout::load_request_handler(); |
|
110 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
111 | - // set ajax hooks |
|
112 | - add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
113 | - add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
114 | - add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
115 | - add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
116 | - add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
117 | - add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * process ajax request |
|
123 | - * |
|
124 | - * @param string $ajax_action |
|
125 | - * @throws EE_Error |
|
126 | - */ |
|
127 | - public static function process_ajax_request($ajax_action) |
|
128 | - { |
|
129 | - EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
130 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * ajax display registration step |
|
136 | - * |
|
137 | - * @throws EE_Error |
|
138 | - */ |
|
139 | - public static function display_reg_step() |
|
140 | - { |
|
141 | - EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * ajax process registration step |
|
147 | - * |
|
148 | - * @throws EE_Error |
|
149 | - */ |
|
150 | - public static function process_reg_step() |
|
151 | - { |
|
152 | - EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * ajax process registration step |
|
158 | - * |
|
159 | - * @throws EE_Error |
|
160 | - */ |
|
161 | - public static function update_reg_step() |
|
162 | - { |
|
163 | - EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * update_checkout |
|
169 | - * |
|
170 | - * @access public |
|
171 | - * @return void |
|
172 | - * @throws EE_Error |
|
173 | - */ |
|
174 | - public static function update_checkout() |
|
175 | - { |
|
176 | - EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * load_request_handler |
|
182 | - * |
|
183 | - * @access public |
|
184 | - * @return void |
|
185 | - */ |
|
186 | - public static function load_request_handler() |
|
187 | - { |
|
188 | - // load core Request_Handler class |
|
189 | - if (EE_Registry::instance()->REQ !== null) { |
|
190 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
191 | - } |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * set_definitions |
|
197 | - * |
|
198 | - * @access public |
|
199 | - * @return void |
|
200 | - * @throws EE_Error |
|
201 | - */ |
|
202 | - public static function set_definitions() |
|
203 | - { |
|
204 | - if (defined('SPCO_BASE_PATH')) { |
|
205 | - return; |
|
206 | - } |
|
207 | - define( |
|
208 | - 'SPCO_BASE_PATH', |
|
209 | - rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
210 | - ); |
|
211 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css/'); |
|
212 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img/'); |
|
213 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js/'); |
|
214 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc/'); |
|
215 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps/'); |
|
216 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates/'); |
|
217 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
218 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
219 | - ); |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * load_reg_steps |
|
225 | - * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
226 | - * |
|
227 | - * @access private |
|
228 | - * @throws EE_Error |
|
229 | - */ |
|
230 | - public static function load_reg_steps() |
|
231 | - { |
|
232 | - static $reg_steps_loaded = false; |
|
233 | - if ($reg_steps_loaded) { |
|
234 | - return; |
|
235 | - } |
|
236 | - // filter list of reg_steps |
|
237 | - $reg_steps_to_load = (array) apply_filters( |
|
238 | - 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
239 | - EED_Single_Page_Checkout::get_reg_steps() |
|
240 | - ); |
|
241 | - // sort by key (order) |
|
242 | - ksort($reg_steps_to_load); |
|
243 | - // loop through folders |
|
244 | - foreach ($reg_steps_to_load as $order => $reg_step) { |
|
245 | - // we need a |
|
246 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
247 | - // copy over to the reg_steps_array |
|
248 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
249 | - // register custom key route for each reg step |
|
250 | - // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
251 | - EE_Config::register_route( |
|
252 | - $reg_step['slug'], |
|
253 | - 'EED_Single_Page_Checkout', |
|
254 | - 'run', |
|
255 | - 'step' |
|
256 | - ); |
|
257 | - // add AJAX or other hooks |
|
258 | - if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
259 | - // setup autoloaders if necessary |
|
260 | - if (! class_exists($reg_step['class_name'])) { |
|
261 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
262 | - $reg_step['file_path'], |
|
263 | - true |
|
264 | - ); |
|
265 | - } |
|
266 | - if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
267 | - call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
268 | - } |
|
269 | - } |
|
270 | - } |
|
271 | - } |
|
272 | - $reg_steps_loaded = true; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * get_reg_steps |
|
278 | - * |
|
279 | - * @access public |
|
280 | - * @return array |
|
281 | - */ |
|
282 | - public static function get_reg_steps() |
|
283 | - { |
|
284 | - $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
285 | - if (empty($reg_steps)) { |
|
286 | - $reg_steps = array( |
|
287 | - 10 => array( |
|
288 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
289 | - 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
290 | - 'slug' => 'attendee_information', |
|
291 | - 'has_hooks' => false, |
|
292 | - ), |
|
293 | - 30 => array( |
|
294 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
295 | - 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
296 | - 'slug' => 'payment_options', |
|
297 | - 'has_hooks' => true, |
|
298 | - ), |
|
299 | - 999 => array( |
|
300 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
301 | - 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
302 | - 'slug' => 'finalize_registration', |
|
303 | - 'has_hooks' => false, |
|
304 | - ), |
|
305 | - ); |
|
306 | - } |
|
307 | - return $reg_steps; |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * registration_checkout_for_admin |
|
313 | - * |
|
314 | - * @access public |
|
315 | - * @return string |
|
316 | - * @throws EE_Error |
|
317 | - */ |
|
318 | - public static function registration_checkout_for_admin() |
|
319 | - { |
|
320 | - EED_Single_Page_Checkout::load_request_handler(); |
|
321 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
322 | - EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
323 | - EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
324 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
325 | - EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
326 | - return EE_Registry::instance()->REQ->get_output(); |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * process_registration_from_admin |
|
332 | - * |
|
333 | - * @access public |
|
334 | - * @return \EE_Transaction |
|
335 | - * @throws EE_Error |
|
336 | - */ |
|
337 | - public static function process_registration_from_admin() |
|
338 | - { |
|
339 | - EED_Single_Page_Checkout::load_request_handler(); |
|
340 | - EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
341 | - EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
342 | - EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
343 | - EED_Single_Page_Checkout::instance()->_initialize(); |
|
344 | - if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
345 | - $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
346 | - if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
347 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
348 | - if ($final_reg_step->process_reg_step()) { |
|
349 | - $final_reg_step->set_completed(); |
|
350 | - EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
351 | - return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - return null; |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * run |
|
361 | - * |
|
362 | - * @access public |
|
363 | - * @param WP_Query $WP_Query |
|
364 | - * @return void |
|
365 | - * @throws EE_Error |
|
366 | - */ |
|
367 | - public function run($WP_Query) |
|
368 | - { |
|
369 | - if ($WP_Query instanceof WP_Query |
|
370 | - && $WP_Query->is_main_query() |
|
371 | - && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
372 | - && $this->_is_reg_checkout() |
|
373 | - ) { |
|
374 | - $this->_initialize(); |
|
375 | - } |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - /** |
|
380 | - * determines whether current url matches reg page url |
|
381 | - * |
|
382 | - * @return bool |
|
383 | - */ |
|
384 | - protected function _is_reg_checkout() |
|
385 | - { |
|
386 | - // get current permalink for reg page without any extra query args |
|
387 | - $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
388 | - // get request URI for current request, but without the scheme or host |
|
389 | - $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
390 | - $current_request_uri = html_entity_decode($current_request_uri); |
|
391 | - // get array of query args from the current request URI |
|
392 | - $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
393 | - // grab page id if it is set |
|
394 | - $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
395 | - // and remove the page id from the query args (we will re-add it later) |
|
396 | - unset($query_args['page_id']); |
|
397 | - // now strip all query args from current request URI |
|
398 | - $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
399 | - // and re-add the page id if it was set |
|
400 | - if ($page_id) { |
|
401 | - $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
402 | - } |
|
403 | - // remove slashes and ? |
|
404 | - $current_request_uri = trim($current_request_uri, '?/'); |
|
405 | - // is current request URI part of the known full reg page URL ? |
|
406 | - return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * @param WP_Query $wp_query |
|
412 | - * @return void |
|
413 | - * @throws EE_Error |
|
414 | - */ |
|
415 | - public static function init($wp_query) |
|
416 | - { |
|
417 | - EED_Single_Page_Checkout::instance()->run($wp_query); |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * _initialize - initial module setup |
|
423 | - * |
|
424 | - * @access private |
|
425 | - * @throws EE_Error |
|
426 | - * @return void |
|
427 | - */ |
|
428 | - private function _initialize() |
|
429 | - { |
|
430 | - // ensure SPCO doesn't run twice |
|
431 | - if (EED_Single_Page_Checkout::$_initialized) { |
|
432 | - return; |
|
433 | - } |
|
434 | - try { |
|
435 | - EED_Single_Page_Checkout::load_reg_steps(); |
|
436 | - $this->_verify_session(); |
|
437 | - // setup the EE_Checkout object |
|
438 | - $this->checkout = $this->_initialize_checkout(); |
|
439 | - // filter checkout |
|
440 | - $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
441 | - // get the $_GET |
|
442 | - $this->_get_request_vars(); |
|
443 | - if ($this->_block_bots()) { |
|
444 | - return; |
|
445 | - } |
|
446 | - // filter continue_reg |
|
447 | - $this->checkout->continue_reg = apply_filters( |
|
448 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
449 | - true, |
|
450 | - $this->checkout |
|
451 | - ); |
|
452 | - // load the reg steps array |
|
453 | - if (! $this->_load_and_instantiate_reg_steps()) { |
|
454 | - EED_Single_Page_Checkout::$_initialized = true; |
|
455 | - return; |
|
456 | - } |
|
457 | - // set the current step |
|
458 | - $this->checkout->set_current_step($this->checkout->step); |
|
459 | - // and the next step |
|
460 | - $this->checkout->set_next_step(); |
|
461 | - // verify that everything has been setup correctly |
|
462 | - if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
463 | - EED_Single_Page_Checkout::$_initialized = true; |
|
464 | - return; |
|
465 | - } |
|
466 | - // lock the transaction |
|
467 | - $this->checkout->transaction->lock(); |
|
468 | - // make sure all of our cached objects are added to their respective model entity mappers |
|
469 | - $this->checkout->refresh_all_entities(); |
|
470 | - // set amount owing |
|
471 | - $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
472 | - // initialize each reg step, which gives them the chance to potentially alter the process |
|
473 | - $this->_initialize_reg_steps(); |
|
474 | - // DEBUG LOG |
|
475 | - // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
476 | - // get reg form |
|
477 | - if (! $this->_check_form_submission()) { |
|
478 | - EED_Single_Page_Checkout::$_initialized = true; |
|
479 | - return; |
|
480 | - } |
|
481 | - // checkout the action!!! |
|
482 | - $this->_process_form_action(); |
|
483 | - // add some style and make it dance |
|
484 | - $this->add_styles_and_scripts(); |
|
485 | - // kk... SPCO has successfully run |
|
486 | - EED_Single_Page_Checkout::$_initialized = true; |
|
487 | - // set no cache headers and constants |
|
488 | - EE_System::do_not_cache(); |
|
489 | - // add anchor |
|
490 | - add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
491 | - // remove transaction lock |
|
492 | - add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
493 | - } catch (Exception $e) { |
|
494 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
495 | - } |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - /** |
|
500 | - * _verify_session |
|
501 | - * checks that the session is valid and not expired |
|
502 | - * |
|
503 | - * @access private |
|
504 | - * @throws EE_Error |
|
505 | - */ |
|
506 | - private function _verify_session() |
|
507 | - { |
|
508 | - if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
509 | - throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
510 | - } |
|
511 | - $clear_session_requested = filter_var( |
|
512 | - EE_Registry::instance()->REQ->get('clear_session', false), |
|
513 | - FILTER_VALIDATE_BOOLEAN |
|
514 | - ); |
|
515 | - // is session still valid ? |
|
516 | - if ($clear_session_requested |
|
517 | - || (EE_Registry::instance()->SSN->expired() |
|
518 | - && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '' |
|
519 | - ) |
|
520 | - ) { |
|
521 | - $this->checkout = new EE_Checkout(); |
|
522 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
523 | - // EE_Registry::instance()->SSN->reset_cart(); |
|
524 | - // EE_Registry::instance()->SSN->reset_checkout(); |
|
525 | - // EE_Registry::instance()->SSN->reset_transaction(); |
|
526 | - if (! $clear_session_requested) { |
|
527 | - EE_Error::add_attention( |
|
528 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
529 | - __FILE__, |
|
530 | - __FUNCTION__, |
|
531 | - __LINE__ |
|
532 | - ); |
|
533 | - } |
|
534 | - // EE_Registry::instance()->SSN->reset_expired(); |
|
535 | - } |
|
536 | - } |
|
537 | - |
|
538 | - |
|
539 | - /** |
|
540 | - * _initialize_checkout |
|
541 | - * loads and instantiates EE_Checkout |
|
542 | - * |
|
543 | - * @access private |
|
544 | - * @throws EE_Error |
|
545 | - * @return EE_Checkout |
|
546 | - */ |
|
547 | - private function _initialize_checkout() |
|
548 | - { |
|
549 | - // look in session for existing checkout |
|
550 | - /** @type EE_Checkout $checkout */ |
|
551 | - $checkout = EE_Registry::instance()->SSN->checkout(); |
|
552 | - // verify |
|
553 | - if (! $checkout instanceof EE_Checkout) { |
|
554 | - // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
555 | - $checkout = EE_Registry::instance()->load_file( |
|
556 | - SPCO_INC_PATH, |
|
557 | - 'EE_Checkout', |
|
558 | - 'class', |
|
559 | - array(), |
|
560 | - false |
|
561 | - ); |
|
562 | - } else { |
|
563 | - if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
564 | - $this->unlock_transaction(); |
|
565 | - wp_safe_redirect($checkout->redirect_url); |
|
566 | - exit(); |
|
567 | - } |
|
568 | - } |
|
569 | - $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
570 | - // verify again |
|
571 | - if (! $checkout instanceof EE_Checkout) { |
|
572 | - throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
573 | - } |
|
574 | - // reset anything that needs a clean slate for each request |
|
575 | - $checkout->reset_for_current_request(); |
|
576 | - return $checkout; |
|
577 | - } |
|
578 | - |
|
579 | - |
|
580 | - /** |
|
581 | - * _get_request_vars |
|
582 | - * |
|
583 | - * @access private |
|
584 | - * @return void |
|
585 | - * @throws EE_Error |
|
586 | - */ |
|
587 | - private function _get_request_vars() |
|
588 | - { |
|
589 | - // load classes |
|
590 | - EED_Single_Page_Checkout::load_request_handler(); |
|
591 | - // make sure this request is marked as belonging to EE |
|
592 | - EE_Registry::instance()->REQ->set_espresso_page(true); |
|
593 | - // which step is being requested ? |
|
594 | - $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
595 | - // which step is being edited ? |
|
596 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
597 | - // and what we're doing on the current step |
|
598 | - $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
599 | - // timestamp |
|
600 | - $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
601 | - // returning to edit ? |
|
602 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
603 | - // add reg url link to registration query params |
|
604 | - if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
605 | - $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
606 | - } |
|
607 | - // or some other kind of revisit ? |
|
608 | - $this->checkout->revisit = filter_var( |
|
609 | - EE_Registry::instance()->REQ->get('revisit', false), |
|
610 | - FILTER_VALIDATE_BOOLEAN |
|
611 | - ); |
|
612 | - // and whether or not to generate a reg form for this request |
|
613 | - $this->checkout->generate_reg_form = filter_var( |
|
614 | - EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
615 | - FILTER_VALIDATE_BOOLEAN |
|
616 | - ); |
|
617 | - // and whether or not to process a reg form submission for this request |
|
618 | - $this->checkout->process_form_submission = filter_var( |
|
619 | - EE_Registry::instance()->REQ->get( |
|
620 | - 'process_form_submission', |
|
621 | - $this->checkout->action === 'process_reg_step' |
|
622 | - ), |
|
623 | - FILTER_VALIDATE_BOOLEAN |
|
624 | - ); |
|
625 | - $this->checkout->process_form_submission = filter_var( |
|
626 | - $this->checkout->action !== 'display_spco_reg_step' |
|
627 | - ? $this->checkout->process_form_submission |
|
628 | - : false, |
|
629 | - FILTER_VALIDATE_BOOLEAN |
|
630 | - ); |
|
631 | - // $this->_display_request_vars(); |
|
632 | - } |
|
633 | - |
|
634 | - |
|
635 | - /** |
|
636 | - * _display_request_vars |
|
637 | - * |
|
638 | - * @access protected |
|
639 | - * @return void |
|
640 | - */ |
|
641 | - protected function _display_request_vars() |
|
642 | - { |
|
643 | - if (! WP_DEBUG) { |
|
644 | - return; |
|
645 | - } |
|
646 | - EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
647 | - EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
648 | - EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
649 | - EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
650 | - EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
651 | - EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
652 | - EEH_Debug_Tools::printr( |
|
653 | - $this->checkout->generate_reg_form, |
|
654 | - '$this->checkout->generate_reg_form', |
|
655 | - __FILE__, |
|
656 | - __LINE__ |
|
657 | - ); |
|
658 | - EEH_Debug_Tools::printr( |
|
659 | - $this->checkout->process_form_submission, |
|
660 | - '$this->checkout->process_form_submission', |
|
661 | - __FILE__, |
|
662 | - __LINE__ |
|
663 | - ); |
|
664 | - } |
|
665 | - |
|
666 | - |
|
667 | - /** |
|
668 | - * _block_bots |
|
669 | - * checks that the incoming request has either of the following set: |
|
670 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
671 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
672 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
673 | - * then where you coming from man? |
|
674 | - * |
|
675 | - * @return boolean |
|
676 | - */ |
|
677 | - private function _block_bots() |
|
678 | - { |
|
679 | - $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
680 | - if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
681 | - return true; |
|
682 | - } |
|
683 | - return false; |
|
684 | - } |
|
685 | - |
|
686 | - |
|
687 | - /** |
|
688 | - * _get_first_step |
|
689 | - * gets slug for first step in $_reg_steps_array |
|
690 | - * |
|
691 | - * @access private |
|
692 | - * @throws EE_Error |
|
693 | - * @return string |
|
694 | - */ |
|
695 | - private function _get_first_step() |
|
696 | - { |
|
697 | - $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
698 | - return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
699 | - } |
|
700 | - |
|
701 | - |
|
702 | - /** |
|
703 | - * instantiates each reg step based on the loaded reg_steps array |
|
704 | - * |
|
705 | - * @return bool |
|
706 | - * @throws EE_Error |
|
707 | - * @throws InvalidArgumentException |
|
708 | - * @throws InvalidDataTypeException |
|
709 | - * @throws InvalidInterfaceException |
|
710 | - */ |
|
711 | - private function _load_and_instantiate_reg_steps() |
|
712 | - { |
|
713 | - do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
714 | - // have reg_steps already been instantiated ? |
|
715 | - if (empty($this->checkout->reg_steps) |
|
716 | - || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
717 | - ) { |
|
718 | - // if not, then loop through raw reg steps array |
|
719 | - foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
720 | - if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
721 | - return false; |
|
722 | - } |
|
723 | - } |
|
724 | - if (isset($this->checkout->reg_steps['registration_confirmation'])) { |
|
725 | - // skip the registration_confirmation page ? |
|
726 | - if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
727 | - // just remove it from the reg steps array |
|
728 | - $this->checkout->remove_reg_step('registration_confirmation', false); |
|
729 | - } elseif (EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
730 | - ) { |
|
731 | - // set the order to something big like 100 |
|
732 | - $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
733 | - } |
|
734 | - } |
|
735 | - // filter the array for good luck |
|
736 | - $this->checkout->reg_steps = apply_filters( |
|
737 | - 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
738 | - $this->checkout->reg_steps |
|
739 | - ); |
|
740 | - // finally re-sort based on the reg step class order properties |
|
741 | - $this->checkout->sort_reg_steps(); |
|
742 | - } else { |
|
743 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
744 | - // set all current step stati to FALSE |
|
745 | - $reg_step->set_is_current_step(false); |
|
746 | - } |
|
747 | - } |
|
748 | - if (empty($this->checkout->reg_steps)) { |
|
749 | - EE_Error::add_error( |
|
750 | - esc_html__('No Reg Steps were loaded..', 'event_espresso'), |
|
751 | - __FILE__, |
|
752 | - __FUNCTION__, |
|
753 | - __LINE__ |
|
754 | - ); |
|
755 | - return false; |
|
756 | - } |
|
757 | - // make reg step details available to JS |
|
758 | - $this->checkout->set_reg_step_JSON_info(); |
|
759 | - return true; |
|
760 | - } |
|
761 | - |
|
762 | - |
|
763 | - /** |
|
764 | - * _load_and_instantiate_reg_step |
|
765 | - * |
|
766 | - * @access private |
|
767 | - * @param array $reg_step |
|
768 | - * @param int $order |
|
769 | - * @return bool |
|
770 | - */ |
|
771 | - private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
772 | - { |
|
773 | - // we need a file_path, class_name, and slug to add a reg step |
|
774 | - if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
775 | - // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
776 | - if ($this->checkout->reg_url_link |
|
777 | - && $this->checkout->step !== $reg_step['slug'] |
|
778 | - && $reg_step['slug'] !== 'finalize_registration' |
|
779 | - // normally at this point we would NOT load the reg step, but this filter can change that |
|
780 | - && apply_filters( |
|
781 | - 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
782 | - true, |
|
783 | - $reg_step, |
|
784 | - $this->checkout |
|
785 | - ) |
|
786 | - ) { |
|
787 | - return true; |
|
788 | - } |
|
789 | - // instantiate step class using file path and class name |
|
790 | - $reg_step_obj = EE_Registry::instance()->load_file( |
|
791 | - $reg_step['file_path'], |
|
792 | - $reg_step['class_name'], |
|
793 | - 'class', |
|
794 | - $this->checkout, |
|
795 | - false |
|
796 | - ); |
|
797 | - // did we gets the goods ? |
|
798 | - if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
799 | - // set reg step order based on config |
|
800 | - $reg_step_obj->set_order($order); |
|
801 | - // add instantiated reg step object to the master reg steps array |
|
802 | - $this->checkout->add_reg_step($reg_step_obj); |
|
803 | - } else { |
|
804 | - EE_Error::add_error( |
|
805 | - esc_html__('The current step could not be set.', 'event_espresso'), |
|
806 | - __FILE__, |
|
807 | - __FUNCTION__, |
|
808 | - __LINE__ |
|
809 | - ); |
|
810 | - return false; |
|
811 | - } |
|
812 | - } else { |
|
813 | - if (WP_DEBUG) { |
|
814 | - EE_Error::add_error( |
|
815 | - sprintf( |
|
816 | - esc_html__( |
|
817 | - 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
818 | - 'event_espresso' |
|
819 | - ), |
|
820 | - isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
821 | - isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
822 | - isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
823 | - '<ul>', |
|
824 | - '<li>', |
|
825 | - '</li>', |
|
826 | - '</ul>' |
|
827 | - ), |
|
828 | - __FILE__, |
|
829 | - __FUNCTION__, |
|
830 | - __LINE__ |
|
831 | - ); |
|
832 | - } |
|
833 | - return false; |
|
834 | - } |
|
835 | - return true; |
|
836 | - } |
|
837 | - |
|
838 | - |
|
839 | - /** |
|
840 | - * _verify_transaction_and_get_registrations |
|
841 | - * |
|
842 | - * @access private |
|
843 | - * @return bool |
|
844 | - * @throws InvalidDataTypeException |
|
845 | - * @throws InvalidEntityException |
|
846 | - * @throws EE_Error |
|
847 | - */ |
|
848 | - private function _verify_transaction_and_get_registrations() |
|
849 | - { |
|
850 | - // was there already a valid transaction in the checkout from the session ? |
|
851 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
852 | - // get transaction from db or session |
|
853 | - $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
854 | - ? $this->_get_transaction_and_cart_for_previous_visit() |
|
855 | - : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
856 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
857 | - EE_Error::add_error( |
|
858 | - esc_html__( |
|
859 | - 'Your Registration and Transaction information could not be retrieved from the db.', |
|
860 | - 'event_espresso' |
|
861 | - ), |
|
862 | - __FILE__, |
|
863 | - __FUNCTION__, |
|
864 | - __LINE__ |
|
865 | - ); |
|
866 | - $this->checkout->transaction = EE_Transaction::new_instance(); |
|
867 | - // add some style and make it dance |
|
868 | - $this->add_styles_and_scripts(); |
|
869 | - EED_Single_Page_Checkout::$_initialized = true; |
|
870 | - return false; |
|
871 | - } |
|
872 | - // and the registrations for the transaction |
|
873 | - $this->_get_registrations($this->checkout->transaction); |
|
874 | - } |
|
875 | - return true; |
|
876 | - } |
|
877 | - |
|
878 | - |
|
879 | - /** |
|
880 | - * _get_transaction_and_cart_for_previous_visit |
|
881 | - * |
|
882 | - * @access private |
|
883 | - * @return mixed EE_Transaction|NULL |
|
884 | - */ |
|
885 | - private function _get_transaction_and_cart_for_previous_visit() |
|
886 | - { |
|
887 | - /** @var $TXN_model EEM_Transaction */ |
|
888 | - $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
889 | - // because the reg_url_link is present in the request, |
|
890 | - // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
891 | - $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
892 | - // verify transaction |
|
893 | - if ($transaction instanceof EE_Transaction) { |
|
894 | - // and get the cart that was used for that transaction |
|
895 | - $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
896 | - return $transaction; |
|
897 | - } |
|
898 | - EE_Error::add_error( |
|
899 | - esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
900 | - __FILE__, |
|
901 | - __FUNCTION__, |
|
902 | - __LINE__ |
|
903 | - ); |
|
904 | - return null; |
|
905 | - } |
|
906 | - |
|
907 | - |
|
908 | - /** |
|
909 | - * _get_cart_for_transaction |
|
910 | - * |
|
911 | - * @access private |
|
912 | - * @param EE_Transaction $transaction |
|
913 | - * @return EE_Cart |
|
914 | - */ |
|
915 | - private function _get_cart_for_transaction($transaction) |
|
916 | - { |
|
917 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
918 | - } |
|
919 | - |
|
920 | - |
|
921 | - /** |
|
922 | - * get_cart_for_transaction |
|
923 | - * |
|
924 | - * @access public |
|
925 | - * @param EE_Transaction $transaction |
|
926 | - * @return EE_Cart |
|
927 | - */ |
|
928 | - public function get_cart_for_transaction(EE_Transaction $transaction) |
|
929 | - { |
|
930 | - return $this->checkout->get_cart_for_transaction($transaction); |
|
931 | - } |
|
932 | - |
|
933 | - |
|
934 | - /** |
|
935 | - * _get_transaction_and_cart_for_current_session |
|
936 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
937 | - * |
|
938 | - * @access private |
|
939 | - * @return EE_Transaction |
|
940 | - * @throws EE_Error |
|
941 | - */ |
|
942 | - private function _get_cart_for_current_session_and_setup_new_transaction() |
|
943 | - { |
|
944 | - // if there's no transaction, then this is the FIRST visit to SPCO |
|
945 | - // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
946 | - $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
947 | - // and then create a new transaction |
|
948 | - $transaction = $this->_initialize_transaction(); |
|
949 | - // verify transaction |
|
950 | - if ($transaction instanceof EE_Transaction) { |
|
951 | - // save it so that we have an ID for other objects to use |
|
952 | - $transaction->save(); |
|
953 | - // and save TXN data to the cart |
|
954 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
955 | - } else { |
|
956 | - EE_Error::add_error( |
|
957 | - esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
958 | - __FILE__, |
|
959 | - __FUNCTION__, |
|
960 | - __LINE__ |
|
961 | - ); |
|
962 | - } |
|
963 | - return $transaction; |
|
964 | - } |
|
965 | - |
|
966 | - |
|
967 | - /** |
|
968 | - * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
969 | - * |
|
970 | - * @access private |
|
971 | - * @return mixed EE_Transaction|NULL |
|
972 | - */ |
|
973 | - private function _initialize_transaction() |
|
974 | - { |
|
975 | - try { |
|
976 | - // ensure cart totals have been calculated |
|
977 | - $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
978 | - // grab the cart grand total |
|
979 | - $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
980 | - // create new TXN |
|
981 | - $transaction = EE_Transaction::new_instance( |
|
982 | - array( |
|
983 | - 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
984 | - 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
985 | - 'TXN_paid' => 0, |
|
986 | - 'STS_ID' => EEM_Transaction::failed_status_code, |
|
987 | - ) |
|
988 | - ); |
|
989 | - // save it so that we have an ID for other objects to use |
|
990 | - $transaction->save(); |
|
991 | - // set cron job for following up on TXNs after their session has expired |
|
992 | - EE_Cron_Tasks::schedule_expired_transaction_check( |
|
993 | - EE_Registry::instance()->SSN->expiration() + 1, |
|
994 | - $transaction->ID() |
|
995 | - ); |
|
996 | - return $transaction; |
|
997 | - } catch (Exception $e) { |
|
998 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
999 | - } |
|
1000 | - return null; |
|
1001 | - } |
|
1002 | - |
|
1003 | - |
|
1004 | - /** |
|
1005 | - * _get_registrations |
|
1006 | - * |
|
1007 | - * @access private |
|
1008 | - * @param EE_Transaction $transaction |
|
1009 | - * @return void |
|
1010 | - * @throws InvalidDataTypeException |
|
1011 | - * @throws InvalidEntityException |
|
1012 | - * @throws EE_Error |
|
1013 | - */ |
|
1014 | - private function _get_registrations(EE_Transaction $transaction) |
|
1015 | - { |
|
1016 | - // first step: grab the registrants { : o |
|
1017 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
1018 | - $this->checkout->total_ticket_count = count($registrations); |
|
1019 | - // verify registrations have been set |
|
1020 | - if (empty($registrations)) { |
|
1021 | - // if no cached registrations, then check the db |
|
1022 | - $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
1023 | - // still nothing ? well as long as this isn't a revisit |
|
1024 | - if (empty($registrations) && ! $this->checkout->revisit) { |
|
1025 | - // generate new registrations from scratch |
|
1026 | - $registrations = $this->_initialize_registrations($transaction); |
|
1027 | - } |
|
1028 | - } |
|
1029 | - // sort by their original registration order |
|
1030 | - usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
1031 | - // then loop thru the array |
|
1032 | - foreach ($registrations as $registration) { |
|
1033 | - // verify each registration |
|
1034 | - if ($registration instanceof EE_Registration) { |
|
1035 | - // we display all attendee info for the primary registrant |
|
1036 | - if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
1037 | - && $registration->is_primary_registrant() |
|
1038 | - ) { |
|
1039 | - $this->checkout->primary_revisit = true; |
|
1040 | - break; |
|
1041 | - } |
|
1042 | - if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
1043 | - // but hide info if it doesn't belong to you |
|
1044 | - $transaction->clear_cache('Registration', $registration->ID()); |
|
1045 | - $this->checkout->total_ticket_count--; |
|
1046 | - } |
|
1047 | - $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1048 | - } |
|
1049 | - } |
|
1050 | - } |
|
1051 | - |
|
1052 | - |
|
1053 | - /** |
|
1054 | - * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1055 | - * |
|
1056 | - * @access private |
|
1057 | - * @param EE_Transaction $transaction |
|
1058 | - * @return array |
|
1059 | - * @throws InvalidDataTypeException |
|
1060 | - * @throws InvalidEntityException |
|
1061 | - * @throws EE_Error |
|
1062 | - */ |
|
1063 | - private function _initialize_registrations(EE_Transaction $transaction) |
|
1064 | - { |
|
1065 | - $att_nmbr = 0; |
|
1066 | - $registrations = array(); |
|
1067 | - if ($transaction instanceof EE_Transaction) { |
|
1068 | - /** @type EE_Registration_Processor $registration_processor */ |
|
1069 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1070 | - $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1071 | - // now let's add the cart items to the $transaction |
|
1072 | - foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1073 | - // do the following for each ticket of this type they selected |
|
1074 | - for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1075 | - $att_nmbr++; |
|
1076 | - /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1077 | - $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
1078 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1079 | - array( |
|
1080 | - $transaction, |
|
1081 | - $line_item, |
|
1082 | - $att_nmbr, |
|
1083 | - $this->checkout->total_ticket_count, |
|
1084 | - ) |
|
1085 | - ); |
|
1086 | - // override capabilities for frontend registrations |
|
1087 | - if (! is_admin()) { |
|
1088 | - $CreateRegistrationCommand->setCapCheck( |
|
1089 | - new PublicCapabilities('', 'create_new_registration') |
|
1090 | - ); |
|
1091 | - } |
|
1092 | - $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1093 | - if (! $registration instanceof EE_Registration) { |
|
1094 | - throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1095 | - } |
|
1096 | - $registrations[ $registration->ID() ] = $registration; |
|
1097 | - } |
|
1098 | - } |
|
1099 | - $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1100 | - } |
|
1101 | - return $registrations; |
|
1102 | - } |
|
1103 | - |
|
1104 | - |
|
1105 | - /** |
|
1106 | - * sorts registrations by REG_count |
|
1107 | - * |
|
1108 | - * @access public |
|
1109 | - * @param EE_Registration $reg_A |
|
1110 | - * @param EE_Registration $reg_B |
|
1111 | - * @return int |
|
1112 | - */ |
|
1113 | - public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1114 | - { |
|
1115 | - // this shouldn't ever happen within the same TXN, but oh well |
|
1116 | - if ($reg_A->count() === $reg_B->count()) { |
|
1117 | - return 0; |
|
1118 | - } |
|
1119 | - return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1120 | - } |
|
1121 | - |
|
1122 | - |
|
1123 | - /** |
|
1124 | - * _final_verifications |
|
1125 | - * just makes sure that everything is set up correctly before proceeding |
|
1126 | - * |
|
1127 | - * @access private |
|
1128 | - * @return bool |
|
1129 | - * @throws EE_Error |
|
1130 | - */ |
|
1131 | - private function _final_verifications() |
|
1132 | - { |
|
1133 | - // filter checkout |
|
1134 | - $this->checkout = apply_filters( |
|
1135 | - 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
1136 | - $this->checkout |
|
1137 | - ); |
|
1138 | - // verify that current step is still set correctly |
|
1139 | - if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1140 | - EE_Error::add_error( |
|
1141 | - esc_html__( |
|
1142 | - 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', |
|
1143 | - 'event_espresso' |
|
1144 | - ), |
|
1145 | - __FILE__, |
|
1146 | - __FUNCTION__, |
|
1147 | - __LINE__ |
|
1148 | - ); |
|
1149 | - return false; |
|
1150 | - } |
|
1151 | - // if returning to SPCO, then verify that primary registrant is set |
|
1152 | - if (! empty($this->checkout->reg_url_link)) { |
|
1153 | - $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1154 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1155 | - EE_Error::add_error( |
|
1156 | - esc_html__( |
|
1157 | - 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', |
|
1158 | - 'event_espresso' |
|
1159 | - ), |
|
1160 | - __FILE__, |
|
1161 | - __FUNCTION__, |
|
1162 | - __LINE__ |
|
1163 | - ); |
|
1164 | - return false; |
|
1165 | - } |
|
1166 | - $valid_registrant = null; |
|
1167 | - foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1168 | - if ($registration instanceof EE_Registration |
|
1169 | - && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1170 | - ) { |
|
1171 | - $valid_registrant = $registration; |
|
1172 | - } |
|
1173 | - } |
|
1174 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1175 | - // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1176 | - if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1177 | - // clear the session, mark the checkout as unverified, and try again |
|
1178 | - EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1179 | - EED_Single_Page_Checkout::$_initialized = false; |
|
1180 | - EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1181 | - $this->_initialize(); |
|
1182 | - EE_Error::reset_notices(); |
|
1183 | - return false; |
|
1184 | - } |
|
1185 | - EE_Error::add_error( |
|
1186 | - esc_html__( |
|
1187 | - 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
1188 | - 'event_espresso' |
|
1189 | - ), |
|
1190 | - __FILE__, |
|
1191 | - __FUNCTION__, |
|
1192 | - __LINE__ |
|
1193 | - ); |
|
1194 | - return false; |
|
1195 | - } |
|
1196 | - } |
|
1197 | - // now that things have been kinda sufficiently verified, |
|
1198 | - // let's add the checkout to the session so that it's available to other systems |
|
1199 | - EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1200 | - return true; |
|
1201 | - } |
|
1202 | - |
|
1203 | - |
|
1204 | - /** |
|
1205 | - * _initialize_reg_steps |
|
1206 | - * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1207 | - * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1208 | - * |
|
1209 | - * @access private |
|
1210 | - * @param bool $reinitializing |
|
1211 | - * @throws EE_Error |
|
1212 | - */ |
|
1213 | - private function _initialize_reg_steps($reinitializing = false) |
|
1214 | - { |
|
1215 | - $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1216 | - // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1217 | - foreach ($this->checkout->reg_steps as $reg_step) { |
|
1218 | - if (! $reg_step->initialize_reg_step()) { |
|
1219 | - // if not initialized then maybe this step is being removed... |
|
1220 | - if (! $reinitializing && $reg_step->is_current_step()) { |
|
1221 | - // if it was the current step, then we need to start over here |
|
1222 | - $this->_initialize_reg_steps(true); |
|
1223 | - return; |
|
1224 | - } |
|
1225 | - continue; |
|
1226 | - } |
|
1227 | - // add css and JS for current step |
|
1228 | - $reg_step->enqueue_styles_and_scripts(); |
|
1229 | - // i18n |
|
1230 | - $reg_step->translate_js_strings(); |
|
1231 | - if ($reg_step->is_current_step()) { |
|
1232 | - // the text that appears on the reg step form submit button |
|
1233 | - $reg_step->set_submit_button_text(); |
|
1234 | - } |
|
1235 | - } |
|
1236 | - // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1237 | - do_action( |
|
1238 | - "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
1239 | - $this->checkout->current_step |
|
1240 | - ); |
|
1241 | - } |
|
1242 | - |
|
1243 | - |
|
1244 | - /** |
|
1245 | - * _check_form_submission |
|
1246 | - * |
|
1247 | - * @access private |
|
1248 | - * @return boolean |
|
1249 | - */ |
|
1250 | - private function _check_form_submission() |
|
1251 | - { |
|
1252 | - // does this request require the reg form to be generated ? |
|
1253 | - if ($this->checkout->generate_reg_form) { |
|
1254 | - // ever heard that song by Blue Rodeo ? |
|
1255 | - try { |
|
1256 | - $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1257 | - // if not displaying a form, then check for form submission |
|
1258 | - if ($this->checkout->process_form_submission |
|
1259 | - && $this->checkout->current_step->reg_form->was_submitted() |
|
1260 | - ) { |
|
1261 | - // clear out any old data in case this step is being run again |
|
1262 | - $this->checkout->current_step->set_valid_data(array()); |
|
1263 | - // capture submitted form data |
|
1264 | - $this->checkout->current_step->reg_form->receive_form_submission( |
|
1265 | - apply_filters( |
|
1266 | - 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1267 | - EE_Registry::instance()->REQ->params(), |
|
1268 | - $this->checkout |
|
1269 | - ) |
|
1270 | - ); |
|
1271 | - // validate submitted form data |
|
1272 | - if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1273 | - // thou shall not pass !!! |
|
1274 | - $this->checkout->continue_reg = false; |
|
1275 | - // any form validation errors? |
|
1276 | - if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1277 | - EE_Error::add_error( |
|
1278 | - $this->checkout->current_step->reg_form->submission_error_message(), |
|
1279 | - __FILE__, |
|
1280 | - __FUNCTION__, |
|
1281 | - __LINE__ |
|
1282 | - ); |
|
1283 | - } |
|
1284 | - // well not really... what will happen is |
|
1285 | - // we'll just get redirected back to redo the current step |
|
1286 | - $this->go_to_next_step(); |
|
1287 | - return false; |
|
1288 | - } |
|
1289 | - } |
|
1290 | - } catch (EE_Error $e) { |
|
1291 | - $e->get_error(); |
|
1292 | - } |
|
1293 | - } |
|
1294 | - return true; |
|
1295 | - } |
|
1296 | - |
|
1297 | - |
|
1298 | - /** |
|
1299 | - * _process_action |
|
1300 | - * |
|
1301 | - * @access private |
|
1302 | - * @return void |
|
1303 | - * @throws EE_Error |
|
1304 | - */ |
|
1305 | - private function _process_form_action() |
|
1306 | - { |
|
1307 | - // what cha wanna do? |
|
1308 | - switch ($this->checkout->action) { |
|
1309 | - // AJAX next step reg form |
|
1310 | - case 'display_spco_reg_step': |
|
1311 | - $this->checkout->redirect = false; |
|
1312 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1313 | - $this->checkout->json_response->set_reg_step_html( |
|
1314 | - $this->checkout->current_step->display_reg_form() |
|
1315 | - ); |
|
1316 | - } |
|
1317 | - break; |
|
1318 | - default: |
|
1319 | - // meh... do one of those other steps first |
|
1320 | - if (! empty($this->checkout->action) |
|
1321 | - && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
1322 | - ) { |
|
1323 | - // dynamically creates hook point like: |
|
1324 | - // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1325 | - do_action( |
|
1326 | - "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1327 | - $this->checkout->current_step |
|
1328 | - ); |
|
1329 | - // call action on current step |
|
1330 | - if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1331 | - // good registrant, you get to proceed |
|
1332 | - if ($this->checkout->current_step->success_message() !== '' |
|
1333 | - && apply_filters( |
|
1334 | - 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1335 | - false |
|
1336 | - ) |
|
1337 | - ) { |
|
1338 | - EE_Error::add_success( |
|
1339 | - $this->checkout->current_step->success_message() |
|
1340 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1341 | - ); |
|
1342 | - } |
|
1343 | - // pack it up, pack it in... |
|
1344 | - $this->_setup_redirect(); |
|
1345 | - } |
|
1346 | - // dynamically creates hook point like: |
|
1347 | - // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1348 | - do_action( |
|
1349 | - "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1350 | - $this->checkout->current_step |
|
1351 | - ); |
|
1352 | - } else { |
|
1353 | - EE_Error::add_error( |
|
1354 | - sprintf( |
|
1355 | - esc_html__( |
|
1356 | - 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
1357 | - 'event_espresso' |
|
1358 | - ), |
|
1359 | - $this->checkout->action, |
|
1360 | - $this->checkout->current_step->name() |
|
1361 | - ), |
|
1362 | - __FILE__, |
|
1363 | - __FUNCTION__, |
|
1364 | - __LINE__ |
|
1365 | - ); |
|
1366 | - } |
|
1367 | - // end default |
|
1368 | - } |
|
1369 | - // store our progress so far |
|
1370 | - $this->checkout->stash_transaction_and_checkout(); |
|
1371 | - // advance to the next step! If you pass GO, collect $200 |
|
1372 | - $this->go_to_next_step(); |
|
1373 | - } |
|
1374 | - |
|
1375 | - |
|
1376 | - /** |
|
1377 | - * add_styles_and_scripts |
|
1378 | - * |
|
1379 | - * @access public |
|
1380 | - * @return void |
|
1381 | - */ |
|
1382 | - public function add_styles_and_scripts() |
|
1383 | - { |
|
1384 | - // i18n |
|
1385 | - $this->translate_js_strings(); |
|
1386 | - if ($this->checkout->admin_request) { |
|
1387 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1388 | - } else { |
|
1389 | - add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1390 | - } |
|
1391 | - } |
|
1392 | - |
|
1393 | - |
|
1394 | - /** |
|
1395 | - * translate_js_strings |
|
1396 | - * |
|
1397 | - * @access public |
|
1398 | - * @return void |
|
1399 | - */ |
|
1400 | - public function translate_js_strings() |
|
1401 | - { |
|
1402 | - EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1403 | - EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1404 | - EE_Registry::$i18n_js_strings['server_error'] = esc_html__( |
|
1405 | - 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1406 | - 'event_espresso' |
|
1407 | - ); |
|
1408 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__( |
|
1409 | - 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1410 | - 'event_espresso' |
|
1411 | - ); |
|
1412 | - EE_Registry::$i18n_js_strings['validation_error'] = esc_html__( |
|
1413 | - 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
1414 | - 'event_espresso' |
|
1415 | - ); |
|
1416 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__( |
|
1417 | - 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
1418 | - 'event_espresso' |
|
1419 | - ); |
|
1420 | - EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__( |
|
1421 | - 'This registration step could not be completed. Please refresh the page and try again.', |
|
1422 | - 'event_espresso' |
|
1423 | - ); |
|
1424 | - EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__( |
|
1425 | - 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
1426 | - 'event_espresso' |
|
1427 | - ); |
|
1428 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1429 | - esc_html__( |
|
1430 | - 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
1431 | - 'event_espresso' |
|
1432 | - ), |
|
1433 | - '<br/>', |
|
1434 | - '<br/>' |
|
1435 | - ); |
|
1436 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1437 | - EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1438 | - EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1439 | - EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1440 | - EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso'); |
|
1441 | - EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso'); |
|
1442 | - EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso'); |
|
1443 | - EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso'); |
|
1444 | - EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso'); |
|
1445 | - EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso'); |
|
1446 | - EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso'); |
|
1447 | - EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso'); |
|
1448 | - EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso'); |
|
1449 | - EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso'); |
|
1450 | - EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso'); |
|
1451 | - EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso'); |
|
1452 | - EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso'); |
|
1453 | - EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso'); |
|
1454 | - EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
1455 | - ); |
|
1456 | - EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
1457 | - 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
1458 | - true |
|
1459 | - ); |
|
1460 | - EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1461 | - apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1462 | - ); |
|
1463 | - EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1464 | - 'M d, Y H:i:s', |
|
1465 | - EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1466 | - ); |
|
1467 | - } |
|
1468 | - |
|
1469 | - |
|
1470 | - /** |
|
1471 | - * enqueue_styles_and_scripts |
|
1472 | - * |
|
1473 | - * @access public |
|
1474 | - * @return void |
|
1475 | - * @throws EE_Error |
|
1476 | - */ |
|
1477 | - public function enqueue_styles_and_scripts() |
|
1478 | - { |
|
1479 | - // load css |
|
1480 | - wp_register_style( |
|
1481 | - 'single_page_checkout', |
|
1482 | - SPCO_CSS_URL . 'single_page_checkout.css', |
|
1483 | - array('espresso_default'), |
|
1484 | - EVENT_ESPRESSO_VERSION |
|
1485 | - ); |
|
1486 | - wp_enqueue_style('single_page_checkout'); |
|
1487 | - // load JS |
|
1488 | - wp_register_script( |
|
1489 | - 'jquery_plugin', |
|
1490 | - EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', |
|
1491 | - array('jquery'), |
|
1492 | - '1.0.1', |
|
1493 | - true |
|
1494 | - ); |
|
1495 | - wp_register_script( |
|
1496 | - 'jquery_countdown', |
|
1497 | - EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', |
|
1498 | - array('jquery_plugin'), |
|
1499 | - '2.1.0', |
|
1500 | - true |
|
1501 | - ); |
|
1502 | - wp_register_script( |
|
1503 | - 'single_page_checkout', |
|
1504 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
1505 | - array('espresso_core', 'underscore', 'ee_form_section_validation'), |
|
1506 | - EVENT_ESPRESSO_VERSION, |
|
1507 | - true |
|
1508 | - ); |
|
1509 | - if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1510 | - $this->checkout->registration_form->enqueue_js(); |
|
1511 | - } |
|
1512 | - if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1513 | - $this->checkout->current_step->reg_form->enqueue_js(); |
|
1514 | - } |
|
1515 | - wp_enqueue_script('single_page_checkout'); |
|
1516 | - if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) { |
|
1517 | - wp_enqueue_script('jquery_countdown'); |
|
1518 | - } |
|
1519 | - /** |
|
1520 | - * global action hook for enqueueing styles and scripts with |
|
1521 | - * spco calls. |
|
1522 | - */ |
|
1523 | - do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1524 | - /** |
|
1525 | - * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1526 | - * The hook will end up being something like: |
|
1527 | - * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1528 | - */ |
|
1529 | - do_action( |
|
1530 | - 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
1531 | - $this |
|
1532 | - ); |
|
1533 | - } |
|
1534 | - |
|
1535 | - |
|
1536 | - /** |
|
1537 | - * display the Registration Single Page Checkout Form |
|
1538 | - * |
|
1539 | - * @access private |
|
1540 | - * @return void |
|
1541 | - * @throws EE_Error |
|
1542 | - */ |
|
1543 | - private function _display_spco_reg_form() |
|
1544 | - { |
|
1545 | - // if registering via the admin, just display the reg form for the current step |
|
1546 | - if ($this->checkout->admin_request) { |
|
1547 | - EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1548 | - } else { |
|
1549 | - // add powered by EE msg |
|
1550 | - add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1551 | - $empty_cart = count($this->checkout->transaction |
|
1552 | - ->registrations($this->checkout->reg_cache_where_params)) < 1; |
|
1553 | - EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1554 | - $cookies_not_set_msg = ''; |
|
1555 | - if ($empty_cart) { |
|
1556 | - $cookies_not_set_msg = apply_filters( |
|
1557 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1558 | - sprintf( |
|
1559 | - esc_html__( |
|
1560 | - '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
1561 | - 'event_espresso' |
|
1562 | - ), |
|
1563 | - '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">', |
|
1564 | - '</div>', |
|
1565 | - '<h6 class="important-notice">', |
|
1566 | - '</h6>', |
|
1567 | - '<p>', |
|
1568 | - '</p>', |
|
1569 | - '<br />', |
|
1570 | - '<a href="http://www.whatarecookies.com/enable.asp" target="_blank" rel="noopener noreferrer">', |
|
1571 | - '</a>' |
|
1572 | - ) |
|
1573 | - ); |
|
1574 | - } |
|
1575 | - $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1576 | - array( |
|
1577 | - 'name' => 'single-page-checkout', |
|
1578 | - 'html_id' => 'ee-single-page-checkout-dv', |
|
1579 | - 'layout_strategy' => |
|
1580 | - new EE_Template_Layout( |
|
1581 | - array( |
|
1582 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1583 | - 'template_args' => array( |
|
1584 | - 'empty_cart' => $empty_cart, |
|
1585 | - 'revisit' => $this->checkout->revisit, |
|
1586 | - 'reg_steps' => $this->checkout->reg_steps, |
|
1587 | - 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1588 | - ? $this->checkout->next_step->slug() |
|
1589 | - : '', |
|
1590 | - 'empty_msg' => apply_filters( |
|
1591 | - 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1592 | - sprintf( |
|
1593 | - esc_html__( |
|
1594 | - 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1595 | - 'event_espresso' |
|
1596 | - ), |
|
1597 | - '<a href="' |
|
1598 | - . get_post_type_archive_link('espresso_events') |
|
1599 | - . '" title="', |
|
1600 | - '">', |
|
1601 | - '</a>' |
|
1602 | - ) |
|
1603 | - ), |
|
1604 | - 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1605 | - 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1606 | - 'session_expiration' => gmdate( |
|
1607 | - 'M d, Y H:i:s', |
|
1608 | - EE_Registry::instance()->SSN->expiration() |
|
1609 | - + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1610 | - ), |
|
1611 | - ), |
|
1612 | - ) |
|
1613 | - ), |
|
1614 | - ) |
|
1615 | - ); |
|
1616 | - // load template and add to output sent that gets filtered into the_content() |
|
1617 | - EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
1618 | - } |
|
1619 | - } |
|
1620 | - |
|
1621 | - |
|
1622 | - /** |
|
1623 | - * add_extra_finalize_registration_inputs |
|
1624 | - * |
|
1625 | - * @access public |
|
1626 | - * @param $next_step |
|
1627 | - * @internal param string $label |
|
1628 | - * @return void |
|
1629 | - */ |
|
1630 | - public function add_extra_finalize_registration_inputs($next_step) |
|
1631 | - { |
|
1632 | - if ($next_step === 'finalize_registration') { |
|
1633 | - echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1634 | - } |
|
1635 | - } |
|
1636 | - |
|
1637 | - |
|
1638 | - /** |
|
1639 | - * display_registration_footer |
|
1640 | - * |
|
1641 | - * @access public |
|
1642 | - * @return string |
|
1643 | - */ |
|
1644 | - public static function display_registration_footer() |
|
1645 | - { |
|
1646 | - if (apply_filters( |
|
1647 | - 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1648 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1649 | - )) { |
|
1650 | - add_filter( |
|
1651 | - 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1652 | - function ($url) { |
|
1653 | - return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1654 | - } |
|
1655 | - ); |
|
1656 | - echo apply_filters( |
|
1657 | - 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1658 | - \EEH_Template::powered_by_event_espresso( |
|
1659 | - '', |
|
1660 | - 'espresso-registration-footer-dv', |
|
1661 | - array('utm_content' => 'registration_checkout') |
|
1662 | - ) |
|
1663 | - ); |
|
1664 | - } |
|
1665 | - return ''; |
|
1666 | - } |
|
1667 | - |
|
1668 | - |
|
1669 | - /** |
|
1670 | - * unlock_transaction |
|
1671 | - * |
|
1672 | - * @access public |
|
1673 | - * @return void |
|
1674 | - * @throws EE_Error |
|
1675 | - */ |
|
1676 | - public function unlock_transaction() |
|
1677 | - { |
|
1678 | - if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1679 | - $this->checkout->transaction->unlock(); |
|
1680 | - } |
|
1681 | - } |
|
1682 | - |
|
1683 | - |
|
1684 | - /** |
|
1685 | - * _setup_redirect |
|
1686 | - * |
|
1687 | - * @access private |
|
1688 | - * @return void |
|
1689 | - */ |
|
1690 | - private function _setup_redirect() |
|
1691 | - { |
|
1692 | - if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1693 | - $this->checkout->redirect = true; |
|
1694 | - if (empty($this->checkout->redirect_url)) { |
|
1695 | - $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1696 | - } |
|
1697 | - $this->checkout->redirect_url = apply_filters( |
|
1698 | - 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1699 | - $this->checkout->redirect_url, |
|
1700 | - $this->checkout |
|
1701 | - ); |
|
1702 | - } |
|
1703 | - } |
|
1704 | - |
|
1705 | - |
|
1706 | - /** |
|
1707 | - * handle ajax message responses and redirects |
|
1708 | - * |
|
1709 | - * @access public |
|
1710 | - * @return void |
|
1711 | - * @throws EE_Error |
|
1712 | - */ |
|
1713 | - public function go_to_next_step() |
|
1714 | - { |
|
1715 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1716 | - // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1717 | - $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1718 | - } |
|
1719 | - $this->unlock_transaction(); |
|
1720 | - // just return for these conditions |
|
1721 | - if ($this->checkout->admin_request |
|
1722 | - || $this->checkout->action === 'redirect_form' |
|
1723 | - || $this->checkout->action === 'update_checkout' |
|
1724 | - ) { |
|
1725 | - return; |
|
1726 | - } |
|
1727 | - // AJAX response |
|
1728 | - $this->_handle_json_response(); |
|
1729 | - // redirect to next step or the Thank You page |
|
1730 | - $this->_handle_html_redirects(); |
|
1731 | - // hmmm... must be something wrong, so let's just display the form again ! |
|
1732 | - $this->_display_spco_reg_form(); |
|
1733 | - } |
|
1734 | - |
|
1735 | - |
|
1736 | - /** |
|
1737 | - * _handle_json_response |
|
1738 | - * |
|
1739 | - * @access protected |
|
1740 | - * @return void |
|
1741 | - */ |
|
1742 | - protected function _handle_json_response() |
|
1743 | - { |
|
1744 | - // if this is an ajax request |
|
1745 | - if (EE_Registry::instance()->REQ->ajax) { |
|
1746 | - $this->checkout->json_response->set_registration_time_limit( |
|
1747 | - $this->checkout->get_registration_time_limit() |
|
1748 | - ); |
|
1749 | - $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1750 | - // just send the ajax ( |
|
1751 | - $json_response = apply_filters( |
|
1752 | - 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1753 | - $this->checkout->json_response |
|
1754 | - ); |
|
1755 | - echo $json_response; |
|
1756 | - exit(); |
|
1757 | - } |
|
1758 | - } |
|
1759 | - |
|
1760 | - |
|
1761 | - /** |
|
1762 | - * _handle_redirects |
|
1763 | - * |
|
1764 | - * @access protected |
|
1765 | - * @return void |
|
1766 | - */ |
|
1767 | - protected function _handle_html_redirects() |
|
1768 | - { |
|
1769 | - // going somewhere ? |
|
1770 | - if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1771 | - // store notices in a transient |
|
1772 | - EE_Error::get_notices(false, true, true); |
|
1773 | - wp_safe_redirect($this->checkout->redirect_url); |
|
1774 | - exit(); |
|
1775 | - } |
|
1776 | - } |
|
1777 | - |
|
1778 | - |
|
1779 | - /** |
|
1780 | - * set_checkout_anchor |
|
1781 | - * |
|
1782 | - * @access public |
|
1783 | - * @return void |
|
1784 | - */ |
|
1785 | - public function set_checkout_anchor() |
|
1786 | - { |
|
1787 | - echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1788 | - } |
|
1789 | - |
|
1790 | - /** |
|
1791 | - * getRegistrationExpirationNotice |
|
1792 | - * |
|
1793 | - * @since 4.9.59.p |
|
1794 | - * @access public |
|
1795 | - * @return string |
|
1796 | - */ |
|
1797 | - public static function getRegistrationExpirationNotice() |
|
1798 | - { |
|
1799 | - return sprintf( |
|
1800 | - esc_html__( |
|
1801 | - '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s', |
|
1802 | - 'event_espresso' |
|
1803 | - ), |
|
1804 | - '<h4 class="important-notice">', |
|
1805 | - '</h4>', |
|
1806 | - '<br />', |
|
1807 | - '<p>', |
|
1808 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1809 | - '">', |
|
1810 | - '</a>', |
|
1811 | - '</p>' |
|
1812 | - ); |
|
1813 | - } |
|
18 | + /** |
|
19 | + * $_initialized - has the SPCO controller already been initialized ? |
|
20 | + * |
|
21 | + * @access private |
|
22 | + * @var bool $_initialized |
|
23 | + */ |
|
24 | + private static $_initialized = false; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * $_checkout_verified - is the EE_Checkout verified as correct for this request ? |
|
29 | + * |
|
30 | + * @access private |
|
31 | + * @var bool $_valid_checkout |
|
32 | + */ |
|
33 | + private static $_checkout_verified = true; |
|
34 | + |
|
35 | + /** |
|
36 | + * $_reg_steps_array - holds initial array of reg steps |
|
37 | + * |
|
38 | + * @access private |
|
39 | + * @var array $_reg_steps_array |
|
40 | + */ |
|
41 | + private static $_reg_steps_array = array(); |
|
42 | + |
|
43 | + /** |
|
44 | + * $checkout - EE_Checkout object for handling the properties of the current checkout process |
|
45 | + * |
|
46 | + * @access public |
|
47 | + * @var EE_Checkout $checkout |
|
48 | + */ |
|
49 | + public $checkout; |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * @return EED_Module|EED_Single_Page_Checkout |
|
54 | + */ |
|
55 | + public static function instance() |
|
56 | + { |
|
57 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
58 | + return parent::get_instance(__CLASS__); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @return EE_CART |
|
64 | + */ |
|
65 | + public function cart() |
|
66 | + { |
|
67 | + return $this->checkout->cart; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return EE_Transaction |
|
73 | + */ |
|
74 | + public function transaction() |
|
75 | + { |
|
76 | + return $this->checkout->transaction; |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
82 | + * |
|
83 | + * @access public |
|
84 | + * @return void |
|
85 | + * @throws EE_Error |
|
86 | + */ |
|
87 | + public static function set_hooks() |
|
88 | + { |
|
89 | + EED_Single_Page_Checkout::set_definitions(); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
95 | + * |
|
96 | + * @access public |
|
97 | + * @return void |
|
98 | + * @throws EE_Error |
|
99 | + */ |
|
100 | + public static function set_hooks_admin() |
|
101 | + { |
|
102 | + EED_Single_Page_Checkout::set_definitions(); |
|
103 | + if (! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
104 | + return; |
|
105 | + } |
|
106 | + // going to start an output buffer in case anything gets accidentally output |
|
107 | + // that might disrupt our JSON response |
|
108 | + ob_start(); |
|
109 | + EED_Single_Page_Checkout::load_request_handler(); |
|
110 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
111 | + // set ajax hooks |
|
112 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
113 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
114 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
115 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
116 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
117 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * process ajax request |
|
123 | + * |
|
124 | + * @param string $ajax_action |
|
125 | + * @throws EE_Error |
|
126 | + */ |
|
127 | + public static function process_ajax_request($ajax_action) |
|
128 | + { |
|
129 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
130 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * ajax display registration step |
|
136 | + * |
|
137 | + * @throws EE_Error |
|
138 | + */ |
|
139 | + public static function display_reg_step() |
|
140 | + { |
|
141 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * ajax process registration step |
|
147 | + * |
|
148 | + * @throws EE_Error |
|
149 | + */ |
|
150 | + public static function process_reg_step() |
|
151 | + { |
|
152 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * ajax process registration step |
|
158 | + * |
|
159 | + * @throws EE_Error |
|
160 | + */ |
|
161 | + public static function update_reg_step() |
|
162 | + { |
|
163 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * update_checkout |
|
169 | + * |
|
170 | + * @access public |
|
171 | + * @return void |
|
172 | + * @throws EE_Error |
|
173 | + */ |
|
174 | + public static function update_checkout() |
|
175 | + { |
|
176 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * load_request_handler |
|
182 | + * |
|
183 | + * @access public |
|
184 | + * @return void |
|
185 | + */ |
|
186 | + public static function load_request_handler() |
|
187 | + { |
|
188 | + // load core Request_Handler class |
|
189 | + if (EE_Registry::instance()->REQ !== null) { |
|
190 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
191 | + } |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * set_definitions |
|
197 | + * |
|
198 | + * @access public |
|
199 | + * @return void |
|
200 | + * @throws EE_Error |
|
201 | + */ |
|
202 | + public static function set_definitions() |
|
203 | + { |
|
204 | + if (defined('SPCO_BASE_PATH')) { |
|
205 | + return; |
|
206 | + } |
|
207 | + define( |
|
208 | + 'SPCO_BASE_PATH', |
|
209 | + rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
210 | + ); |
|
211 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css/'); |
|
212 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img/'); |
|
213 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js/'); |
|
214 | + define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc/'); |
|
215 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps/'); |
|
216 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates/'); |
|
217 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
|
218 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
219 | + ); |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * load_reg_steps |
|
225 | + * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array |
|
226 | + * |
|
227 | + * @access private |
|
228 | + * @throws EE_Error |
|
229 | + */ |
|
230 | + public static function load_reg_steps() |
|
231 | + { |
|
232 | + static $reg_steps_loaded = false; |
|
233 | + if ($reg_steps_loaded) { |
|
234 | + return; |
|
235 | + } |
|
236 | + // filter list of reg_steps |
|
237 | + $reg_steps_to_load = (array) apply_filters( |
|
238 | + 'AHEE__SPCO__load_reg_steps__reg_steps_to_load', |
|
239 | + EED_Single_Page_Checkout::get_reg_steps() |
|
240 | + ); |
|
241 | + // sort by key (order) |
|
242 | + ksort($reg_steps_to_load); |
|
243 | + // loop through folders |
|
244 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
245 | + // we need a |
|
246 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
247 | + // copy over to the reg_steps_array |
|
248 | + EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
249 | + // register custom key route for each reg step |
|
250 | + // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
|
251 | + EE_Config::register_route( |
|
252 | + $reg_step['slug'], |
|
253 | + 'EED_Single_Page_Checkout', |
|
254 | + 'run', |
|
255 | + 'step' |
|
256 | + ); |
|
257 | + // add AJAX or other hooks |
|
258 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
259 | + // setup autoloaders if necessary |
|
260 | + if (! class_exists($reg_step['class_name'])) { |
|
261 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
|
262 | + $reg_step['file_path'], |
|
263 | + true |
|
264 | + ); |
|
265 | + } |
|
266 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
267 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
268 | + } |
|
269 | + } |
|
270 | + } |
|
271 | + } |
|
272 | + $reg_steps_loaded = true; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * get_reg_steps |
|
278 | + * |
|
279 | + * @access public |
|
280 | + * @return array |
|
281 | + */ |
|
282 | + public static function get_reg_steps() |
|
283 | + { |
|
284 | + $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
|
285 | + if (empty($reg_steps)) { |
|
286 | + $reg_steps = array( |
|
287 | + 10 => array( |
|
288 | + 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
289 | + 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
|
290 | + 'slug' => 'attendee_information', |
|
291 | + 'has_hooks' => false, |
|
292 | + ), |
|
293 | + 30 => array( |
|
294 | + 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
295 | + 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
|
296 | + 'slug' => 'payment_options', |
|
297 | + 'has_hooks' => true, |
|
298 | + ), |
|
299 | + 999 => array( |
|
300 | + 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
301 | + 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
|
302 | + 'slug' => 'finalize_registration', |
|
303 | + 'has_hooks' => false, |
|
304 | + ), |
|
305 | + ); |
|
306 | + } |
|
307 | + return $reg_steps; |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * registration_checkout_for_admin |
|
313 | + * |
|
314 | + * @access public |
|
315 | + * @return string |
|
316 | + * @throws EE_Error |
|
317 | + */ |
|
318 | + public static function registration_checkout_for_admin() |
|
319 | + { |
|
320 | + EED_Single_Page_Checkout::load_request_handler(); |
|
321 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
322 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
323 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
324 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
325 | + EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
|
326 | + return EE_Registry::instance()->REQ->get_output(); |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * process_registration_from_admin |
|
332 | + * |
|
333 | + * @access public |
|
334 | + * @return \EE_Transaction |
|
335 | + * @throws EE_Error |
|
336 | + */ |
|
337 | + public static function process_registration_from_admin() |
|
338 | + { |
|
339 | + EED_Single_Page_Checkout::load_request_handler(); |
|
340 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
341 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
342 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
343 | + EED_Single_Page_Checkout::instance()->_initialize(); |
|
344 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
345 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
346 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
347 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
348 | + if ($final_reg_step->process_reg_step()) { |
|
349 | + $final_reg_step->set_completed(); |
|
350 | + EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
|
351 | + return EED_Single_Page_Checkout::instance()->checkout->transaction; |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + return null; |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * run |
|
361 | + * |
|
362 | + * @access public |
|
363 | + * @param WP_Query $WP_Query |
|
364 | + * @return void |
|
365 | + * @throws EE_Error |
|
366 | + */ |
|
367 | + public function run($WP_Query) |
|
368 | + { |
|
369 | + if ($WP_Query instanceof WP_Query |
|
370 | + && $WP_Query->is_main_query() |
|
371 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
372 | + && $this->_is_reg_checkout() |
|
373 | + ) { |
|
374 | + $this->_initialize(); |
|
375 | + } |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + /** |
|
380 | + * determines whether current url matches reg page url |
|
381 | + * |
|
382 | + * @return bool |
|
383 | + */ |
|
384 | + protected function _is_reg_checkout() |
|
385 | + { |
|
386 | + // get current permalink for reg page without any extra query args |
|
387 | + $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id); |
|
388 | + // get request URI for current request, but without the scheme or host |
|
389 | + $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
390 | + $current_request_uri = html_entity_decode($current_request_uri); |
|
391 | + // get array of query args from the current request URI |
|
392 | + $query_args = \EEH_URL::get_query_string($current_request_uri); |
|
393 | + // grab page id if it is set |
|
394 | + $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0; |
|
395 | + // and remove the page id from the query args (we will re-add it later) |
|
396 | + unset($query_args['page_id']); |
|
397 | + // now strip all query args from current request URI |
|
398 | + $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri); |
|
399 | + // and re-add the page id if it was set |
|
400 | + if ($page_id) { |
|
401 | + $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri); |
|
402 | + } |
|
403 | + // remove slashes and ? |
|
404 | + $current_request_uri = trim($current_request_uri, '?/'); |
|
405 | + // is current request URI part of the known full reg page URL ? |
|
406 | + return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false; |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * @param WP_Query $wp_query |
|
412 | + * @return void |
|
413 | + * @throws EE_Error |
|
414 | + */ |
|
415 | + public static function init($wp_query) |
|
416 | + { |
|
417 | + EED_Single_Page_Checkout::instance()->run($wp_query); |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * _initialize - initial module setup |
|
423 | + * |
|
424 | + * @access private |
|
425 | + * @throws EE_Error |
|
426 | + * @return void |
|
427 | + */ |
|
428 | + private function _initialize() |
|
429 | + { |
|
430 | + // ensure SPCO doesn't run twice |
|
431 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
432 | + return; |
|
433 | + } |
|
434 | + try { |
|
435 | + EED_Single_Page_Checkout::load_reg_steps(); |
|
436 | + $this->_verify_session(); |
|
437 | + // setup the EE_Checkout object |
|
438 | + $this->checkout = $this->_initialize_checkout(); |
|
439 | + // filter checkout |
|
440 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
441 | + // get the $_GET |
|
442 | + $this->_get_request_vars(); |
|
443 | + if ($this->_block_bots()) { |
|
444 | + return; |
|
445 | + } |
|
446 | + // filter continue_reg |
|
447 | + $this->checkout->continue_reg = apply_filters( |
|
448 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
449 | + true, |
|
450 | + $this->checkout |
|
451 | + ); |
|
452 | + // load the reg steps array |
|
453 | + if (! $this->_load_and_instantiate_reg_steps()) { |
|
454 | + EED_Single_Page_Checkout::$_initialized = true; |
|
455 | + return; |
|
456 | + } |
|
457 | + // set the current step |
|
458 | + $this->checkout->set_current_step($this->checkout->step); |
|
459 | + // and the next step |
|
460 | + $this->checkout->set_next_step(); |
|
461 | + // verify that everything has been setup correctly |
|
462 | + if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
463 | + EED_Single_Page_Checkout::$_initialized = true; |
|
464 | + return; |
|
465 | + } |
|
466 | + // lock the transaction |
|
467 | + $this->checkout->transaction->lock(); |
|
468 | + // make sure all of our cached objects are added to their respective model entity mappers |
|
469 | + $this->checkout->refresh_all_entities(); |
|
470 | + // set amount owing |
|
471 | + $this->checkout->amount_owing = $this->checkout->transaction->remaining(); |
|
472 | + // initialize each reg step, which gives them the chance to potentially alter the process |
|
473 | + $this->_initialize_reg_steps(); |
|
474 | + // DEBUG LOG |
|
475 | + // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
|
476 | + // get reg form |
|
477 | + if (! $this->_check_form_submission()) { |
|
478 | + EED_Single_Page_Checkout::$_initialized = true; |
|
479 | + return; |
|
480 | + } |
|
481 | + // checkout the action!!! |
|
482 | + $this->_process_form_action(); |
|
483 | + // add some style and make it dance |
|
484 | + $this->add_styles_and_scripts(); |
|
485 | + // kk... SPCO has successfully run |
|
486 | + EED_Single_Page_Checkout::$_initialized = true; |
|
487 | + // set no cache headers and constants |
|
488 | + EE_System::do_not_cache(); |
|
489 | + // add anchor |
|
490 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
491 | + // remove transaction lock |
|
492 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
493 | + } catch (Exception $e) { |
|
494 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
495 | + } |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + /** |
|
500 | + * _verify_session |
|
501 | + * checks that the session is valid and not expired |
|
502 | + * |
|
503 | + * @access private |
|
504 | + * @throws EE_Error |
|
505 | + */ |
|
506 | + private function _verify_session() |
|
507 | + { |
|
508 | + if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
509 | + throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
510 | + } |
|
511 | + $clear_session_requested = filter_var( |
|
512 | + EE_Registry::instance()->REQ->get('clear_session', false), |
|
513 | + FILTER_VALIDATE_BOOLEAN |
|
514 | + ); |
|
515 | + // is session still valid ? |
|
516 | + if ($clear_session_requested |
|
517 | + || (EE_Registry::instance()->SSN->expired() |
|
518 | + && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '' |
|
519 | + ) |
|
520 | + ) { |
|
521 | + $this->checkout = new EE_Checkout(); |
|
522 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
523 | + // EE_Registry::instance()->SSN->reset_cart(); |
|
524 | + // EE_Registry::instance()->SSN->reset_checkout(); |
|
525 | + // EE_Registry::instance()->SSN->reset_transaction(); |
|
526 | + if (! $clear_session_requested) { |
|
527 | + EE_Error::add_attention( |
|
528 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
|
529 | + __FILE__, |
|
530 | + __FUNCTION__, |
|
531 | + __LINE__ |
|
532 | + ); |
|
533 | + } |
|
534 | + // EE_Registry::instance()->SSN->reset_expired(); |
|
535 | + } |
|
536 | + } |
|
537 | + |
|
538 | + |
|
539 | + /** |
|
540 | + * _initialize_checkout |
|
541 | + * loads and instantiates EE_Checkout |
|
542 | + * |
|
543 | + * @access private |
|
544 | + * @throws EE_Error |
|
545 | + * @return EE_Checkout |
|
546 | + */ |
|
547 | + private function _initialize_checkout() |
|
548 | + { |
|
549 | + // look in session for existing checkout |
|
550 | + /** @type EE_Checkout $checkout */ |
|
551 | + $checkout = EE_Registry::instance()->SSN->checkout(); |
|
552 | + // verify |
|
553 | + if (! $checkout instanceof EE_Checkout) { |
|
554 | + // instantiate EE_Checkout object for handling the properties of the current checkout process |
|
555 | + $checkout = EE_Registry::instance()->load_file( |
|
556 | + SPCO_INC_PATH, |
|
557 | + 'EE_Checkout', |
|
558 | + 'class', |
|
559 | + array(), |
|
560 | + false |
|
561 | + ); |
|
562 | + } else { |
|
563 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
564 | + $this->unlock_transaction(); |
|
565 | + wp_safe_redirect($checkout->redirect_url); |
|
566 | + exit(); |
|
567 | + } |
|
568 | + } |
|
569 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
570 | + // verify again |
|
571 | + if (! $checkout instanceof EE_Checkout) { |
|
572 | + throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
573 | + } |
|
574 | + // reset anything that needs a clean slate for each request |
|
575 | + $checkout->reset_for_current_request(); |
|
576 | + return $checkout; |
|
577 | + } |
|
578 | + |
|
579 | + |
|
580 | + /** |
|
581 | + * _get_request_vars |
|
582 | + * |
|
583 | + * @access private |
|
584 | + * @return void |
|
585 | + * @throws EE_Error |
|
586 | + */ |
|
587 | + private function _get_request_vars() |
|
588 | + { |
|
589 | + // load classes |
|
590 | + EED_Single_Page_Checkout::load_request_handler(); |
|
591 | + // make sure this request is marked as belonging to EE |
|
592 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
593 | + // which step is being requested ? |
|
594 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
595 | + // which step is being edited ? |
|
596 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
597 | + // and what we're doing on the current step |
|
598 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
599 | + // timestamp |
|
600 | + $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0); |
|
601 | + // returning to edit ? |
|
602 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
603 | + // add reg url link to registration query params |
|
604 | + if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) { |
|
605 | + $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link; |
|
606 | + } |
|
607 | + // or some other kind of revisit ? |
|
608 | + $this->checkout->revisit = filter_var( |
|
609 | + EE_Registry::instance()->REQ->get('revisit', false), |
|
610 | + FILTER_VALIDATE_BOOLEAN |
|
611 | + ); |
|
612 | + // and whether or not to generate a reg form for this request |
|
613 | + $this->checkout->generate_reg_form = filter_var( |
|
614 | + EE_Registry::instance()->REQ->get('generate_reg_form', true), |
|
615 | + FILTER_VALIDATE_BOOLEAN |
|
616 | + ); |
|
617 | + // and whether or not to process a reg form submission for this request |
|
618 | + $this->checkout->process_form_submission = filter_var( |
|
619 | + EE_Registry::instance()->REQ->get( |
|
620 | + 'process_form_submission', |
|
621 | + $this->checkout->action === 'process_reg_step' |
|
622 | + ), |
|
623 | + FILTER_VALIDATE_BOOLEAN |
|
624 | + ); |
|
625 | + $this->checkout->process_form_submission = filter_var( |
|
626 | + $this->checkout->action !== 'display_spco_reg_step' |
|
627 | + ? $this->checkout->process_form_submission |
|
628 | + : false, |
|
629 | + FILTER_VALIDATE_BOOLEAN |
|
630 | + ); |
|
631 | + // $this->_display_request_vars(); |
|
632 | + } |
|
633 | + |
|
634 | + |
|
635 | + /** |
|
636 | + * _display_request_vars |
|
637 | + * |
|
638 | + * @access protected |
|
639 | + * @return void |
|
640 | + */ |
|
641 | + protected function _display_request_vars() |
|
642 | + { |
|
643 | + if (! WP_DEBUG) { |
|
644 | + return; |
|
645 | + } |
|
646 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
647 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
648 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
649 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
650 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
651 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
652 | + EEH_Debug_Tools::printr( |
|
653 | + $this->checkout->generate_reg_form, |
|
654 | + '$this->checkout->generate_reg_form', |
|
655 | + __FILE__, |
|
656 | + __LINE__ |
|
657 | + ); |
|
658 | + EEH_Debug_Tools::printr( |
|
659 | + $this->checkout->process_form_submission, |
|
660 | + '$this->checkout->process_form_submission', |
|
661 | + __FILE__, |
|
662 | + __LINE__ |
|
663 | + ); |
|
664 | + } |
|
665 | + |
|
666 | + |
|
667 | + /** |
|
668 | + * _block_bots |
|
669 | + * checks that the incoming request has either of the following set: |
|
670 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
671 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
672 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
673 | + * then where you coming from man? |
|
674 | + * |
|
675 | + * @return boolean |
|
676 | + */ |
|
677 | + private function _block_bots() |
|
678 | + { |
|
679 | + $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess(); |
|
680 | + if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) { |
|
681 | + return true; |
|
682 | + } |
|
683 | + return false; |
|
684 | + } |
|
685 | + |
|
686 | + |
|
687 | + /** |
|
688 | + * _get_first_step |
|
689 | + * gets slug for first step in $_reg_steps_array |
|
690 | + * |
|
691 | + * @access private |
|
692 | + * @throws EE_Error |
|
693 | + * @return string |
|
694 | + */ |
|
695 | + private function _get_first_step() |
|
696 | + { |
|
697 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
698 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
699 | + } |
|
700 | + |
|
701 | + |
|
702 | + /** |
|
703 | + * instantiates each reg step based on the loaded reg_steps array |
|
704 | + * |
|
705 | + * @return bool |
|
706 | + * @throws EE_Error |
|
707 | + * @throws InvalidArgumentException |
|
708 | + * @throws InvalidDataTypeException |
|
709 | + * @throws InvalidInterfaceException |
|
710 | + */ |
|
711 | + private function _load_and_instantiate_reg_steps() |
|
712 | + { |
|
713 | + do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout); |
|
714 | + // have reg_steps already been instantiated ? |
|
715 | + if (empty($this->checkout->reg_steps) |
|
716 | + || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
717 | + ) { |
|
718 | + // if not, then loop through raw reg steps array |
|
719 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
720 | + if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
721 | + return false; |
|
722 | + } |
|
723 | + } |
|
724 | + if (isset($this->checkout->reg_steps['registration_confirmation'])) { |
|
725 | + // skip the registration_confirmation page ? |
|
726 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
727 | + // just remove it from the reg steps array |
|
728 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
729 | + } elseif (EE_Registry::instance()->CFG->registration->reg_confirmation_last |
|
730 | + ) { |
|
731 | + // set the order to something big like 100 |
|
732 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
733 | + } |
|
734 | + } |
|
735 | + // filter the array for good luck |
|
736 | + $this->checkout->reg_steps = apply_filters( |
|
737 | + 'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps', |
|
738 | + $this->checkout->reg_steps |
|
739 | + ); |
|
740 | + // finally re-sort based on the reg step class order properties |
|
741 | + $this->checkout->sort_reg_steps(); |
|
742 | + } else { |
|
743 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
744 | + // set all current step stati to FALSE |
|
745 | + $reg_step->set_is_current_step(false); |
|
746 | + } |
|
747 | + } |
|
748 | + if (empty($this->checkout->reg_steps)) { |
|
749 | + EE_Error::add_error( |
|
750 | + esc_html__('No Reg Steps were loaded..', 'event_espresso'), |
|
751 | + __FILE__, |
|
752 | + __FUNCTION__, |
|
753 | + __LINE__ |
|
754 | + ); |
|
755 | + return false; |
|
756 | + } |
|
757 | + // make reg step details available to JS |
|
758 | + $this->checkout->set_reg_step_JSON_info(); |
|
759 | + return true; |
|
760 | + } |
|
761 | + |
|
762 | + |
|
763 | + /** |
|
764 | + * _load_and_instantiate_reg_step |
|
765 | + * |
|
766 | + * @access private |
|
767 | + * @param array $reg_step |
|
768 | + * @param int $order |
|
769 | + * @return bool |
|
770 | + */ |
|
771 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) |
|
772 | + { |
|
773 | + // we need a file_path, class_name, and slug to add a reg step |
|
774 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
775 | + // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
|
776 | + if ($this->checkout->reg_url_link |
|
777 | + && $this->checkout->step !== $reg_step['slug'] |
|
778 | + && $reg_step['slug'] !== 'finalize_registration' |
|
779 | + // normally at this point we would NOT load the reg step, but this filter can change that |
|
780 | + && apply_filters( |
|
781 | + 'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step', |
|
782 | + true, |
|
783 | + $reg_step, |
|
784 | + $this->checkout |
|
785 | + ) |
|
786 | + ) { |
|
787 | + return true; |
|
788 | + } |
|
789 | + // instantiate step class using file path and class name |
|
790 | + $reg_step_obj = EE_Registry::instance()->load_file( |
|
791 | + $reg_step['file_path'], |
|
792 | + $reg_step['class_name'], |
|
793 | + 'class', |
|
794 | + $this->checkout, |
|
795 | + false |
|
796 | + ); |
|
797 | + // did we gets the goods ? |
|
798 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
799 | + // set reg step order based on config |
|
800 | + $reg_step_obj->set_order($order); |
|
801 | + // add instantiated reg step object to the master reg steps array |
|
802 | + $this->checkout->add_reg_step($reg_step_obj); |
|
803 | + } else { |
|
804 | + EE_Error::add_error( |
|
805 | + esc_html__('The current step could not be set.', 'event_espresso'), |
|
806 | + __FILE__, |
|
807 | + __FUNCTION__, |
|
808 | + __LINE__ |
|
809 | + ); |
|
810 | + return false; |
|
811 | + } |
|
812 | + } else { |
|
813 | + if (WP_DEBUG) { |
|
814 | + EE_Error::add_error( |
|
815 | + sprintf( |
|
816 | + esc_html__( |
|
817 | + 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', |
|
818 | + 'event_espresso' |
|
819 | + ), |
|
820 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
821 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
822 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
823 | + '<ul>', |
|
824 | + '<li>', |
|
825 | + '</li>', |
|
826 | + '</ul>' |
|
827 | + ), |
|
828 | + __FILE__, |
|
829 | + __FUNCTION__, |
|
830 | + __LINE__ |
|
831 | + ); |
|
832 | + } |
|
833 | + return false; |
|
834 | + } |
|
835 | + return true; |
|
836 | + } |
|
837 | + |
|
838 | + |
|
839 | + /** |
|
840 | + * _verify_transaction_and_get_registrations |
|
841 | + * |
|
842 | + * @access private |
|
843 | + * @return bool |
|
844 | + * @throws InvalidDataTypeException |
|
845 | + * @throws InvalidEntityException |
|
846 | + * @throws EE_Error |
|
847 | + */ |
|
848 | + private function _verify_transaction_and_get_registrations() |
|
849 | + { |
|
850 | + // was there already a valid transaction in the checkout from the session ? |
|
851 | + if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
852 | + // get transaction from db or session |
|
853 | + $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
|
854 | + ? $this->_get_transaction_and_cart_for_previous_visit() |
|
855 | + : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
|
856 | + if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
857 | + EE_Error::add_error( |
|
858 | + esc_html__( |
|
859 | + 'Your Registration and Transaction information could not be retrieved from the db.', |
|
860 | + 'event_espresso' |
|
861 | + ), |
|
862 | + __FILE__, |
|
863 | + __FUNCTION__, |
|
864 | + __LINE__ |
|
865 | + ); |
|
866 | + $this->checkout->transaction = EE_Transaction::new_instance(); |
|
867 | + // add some style and make it dance |
|
868 | + $this->add_styles_and_scripts(); |
|
869 | + EED_Single_Page_Checkout::$_initialized = true; |
|
870 | + return false; |
|
871 | + } |
|
872 | + // and the registrations for the transaction |
|
873 | + $this->_get_registrations($this->checkout->transaction); |
|
874 | + } |
|
875 | + return true; |
|
876 | + } |
|
877 | + |
|
878 | + |
|
879 | + /** |
|
880 | + * _get_transaction_and_cart_for_previous_visit |
|
881 | + * |
|
882 | + * @access private |
|
883 | + * @return mixed EE_Transaction|NULL |
|
884 | + */ |
|
885 | + private function _get_transaction_and_cart_for_previous_visit() |
|
886 | + { |
|
887 | + /** @var $TXN_model EEM_Transaction */ |
|
888 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
889 | + // because the reg_url_link is present in the request, |
|
890 | + // this is a return visit to SPCO, so we'll get the transaction data from the db |
|
891 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
892 | + // verify transaction |
|
893 | + if ($transaction instanceof EE_Transaction) { |
|
894 | + // and get the cart that was used for that transaction |
|
895 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
896 | + return $transaction; |
|
897 | + } |
|
898 | + EE_Error::add_error( |
|
899 | + esc_html__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
900 | + __FILE__, |
|
901 | + __FUNCTION__, |
|
902 | + __LINE__ |
|
903 | + ); |
|
904 | + return null; |
|
905 | + } |
|
906 | + |
|
907 | + |
|
908 | + /** |
|
909 | + * _get_cart_for_transaction |
|
910 | + * |
|
911 | + * @access private |
|
912 | + * @param EE_Transaction $transaction |
|
913 | + * @return EE_Cart |
|
914 | + */ |
|
915 | + private function _get_cart_for_transaction($transaction) |
|
916 | + { |
|
917 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
918 | + } |
|
919 | + |
|
920 | + |
|
921 | + /** |
|
922 | + * get_cart_for_transaction |
|
923 | + * |
|
924 | + * @access public |
|
925 | + * @param EE_Transaction $transaction |
|
926 | + * @return EE_Cart |
|
927 | + */ |
|
928 | + public function get_cart_for_transaction(EE_Transaction $transaction) |
|
929 | + { |
|
930 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
931 | + } |
|
932 | + |
|
933 | + |
|
934 | + /** |
|
935 | + * _get_transaction_and_cart_for_current_session |
|
936 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
937 | + * |
|
938 | + * @access private |
|
939 | + * @return EE_Transaction |
|
940 | + * @throws EE_Error |
|
941 | + */ |
|
942 | + private function _get_cart_for_current_session_and_setup_new_transaction() |
|
943 | + { |
|
944 | + // if there's no transaction, then this is the FIRST visit to SPCO |
|
945 | + // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
|
946 | + $this->checkout->cart = $this->_get_cart_for_transaction(null); |
|
947 | + // and then create a new transaction |
|
948 | + $transaction = $this->_initialize_transaction(); |
|
949 | + // verify transaction |
|
950 | + if ($transaction instanceof EE_Transaction) { |
|
951 | + // save it so that we have an ID for other objects to use |
|
952 | + $transaction->save(); |
|
953 | + // and save TXN data to the cart |
|
954 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
955 | + } else { |
|
956 | + EE_Error::add_error( |
|
957 | + esc_html__('A Valid Transaction could not be initialized.', 'event_espresso'), |
|
958 | + __FILE__, |
|
959 | + __FUNCTION__, |
|
960 | + __LINE__ |
|
961 | + ); |
|
962 | + } |
|
963 | + return $transaction; |
|
964 | + } |
|
965 | + |
|
966 | + |
|
967 | + /** |
|
968 | + * generates a new EE_Transaction object and adds it to the $_transaction property. |
|
969 | + * |
|
970 | + * @access private |
|
971 | + * @return mixed EE_Transaction|NULL |
|
972 | + */ |
|
973 | + private function _initialize_transaction() |
|
974 | + { |
|
975 | + try { |
|
976 | + // ensure cart totals have been calculated |
|
977 | + $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes(); |
|
978 | + // grab the cart grand total |
|
979 | + $cart_total = $this->checkout->cart->get_cart_grand_total(); |
|
980 | + // create new TXN |
|
981 | + $transaction = EE_Transaction::new_instance( |
|
982 | + array( |
|
983 | + 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
|
984 | + 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
|
985 | + 'TXN_paid' => 0, |
|
986 | + 'STS_ID' => EEM_Transaction::failed_status_code, |
|
987 | + ) |
|
988 | + ); |
|
989 | + // save it so that we have an ID for other objects to use |
|
990 | + $transaction->save(); |
|
991 | + // set cron job for following up on TXNs after their session has expired |
|
992 | + EE_Cron_Tasks::schedule_expired_transaction_check( |
|
993 | + EE_Registry::instance()->SSN->expiration() + 1, |
|
994 | + $transaction->ID() |
|
995 | + ); |
|
996 | + return $transaction; |
|
997 | + } catch (Exception $e) { |
|
998 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
999 | + } |
|
1000 | + return null; |
|
1001 | + } |
|
1002 | + |
|
1003 | + |
|
1004 | + /** |
|
1005 | + * _get_registrations |
|
1006 | + * |
|
1007 | + * @access private |
|
1008 | + * @param EE_Transaction $transaction |
|
1009 | + * @return void |
|
1010 | + * @throws InvalidDataTypeException |
|
1011 | + * @throws InvalidEntityException |
|
1012 | + * @throws EE_Error |
|
1013 | + */ |
|
1014 | + private function _get_registrations(EE_Transaction $transaction) |
|
1015 | + { |
|
1016 | + // first step: grab the registrants { : o |
|
1017 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
1018 | + $this->checkout->total_ticket_count = count($registrations); |
|
1019 | + // verify registrations have been set |
|
1020 | + if (empty($registrations)) { |
|
1021 | + // if no cached registrations, then check the db |
|
1022 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
1023 | + // still nothing ? well as long as this isn't a revisit |
|
1024 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
1025 | + // generate new registrations from scratch |
|
1026 | + $registrations = $this->_initialize_registrations($transaction); |
|
1027 | + } |
|
1028 | + } |
|
1029 | + // sort by their original registration order |
|
1030 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
1031 | + // then loop thru the array |
|
1032 | + foreach ($registrations as $registration) { |
|
1033 | + // verify each registration |
|
1034 | + if ($registration instanceof EE_Registration) { |
|
1035 | + // we display all attendee info for the primary registrant |
|
1036 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
1037 | + && $registration->is_primary_registrant() |
|
1038 | + ) { |
|
1039 | + $this->checkout->primary_revisit = true; |
|
1040 | + break; |
|
1041 | + } |
|
1042 | + if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) { |
|
1043 | + // but hide info if it doesn't belong to you |
|
1044 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
1045 | + $this->checkout->total_ticket_count--; |
|
1046 | + } |
|
1047 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
1048 | + } |
|
1049 | + } |
|
1050 | + } |
|
1051 | + |
|
1052 | + |
|
1053 | + /** |
|
1054 | + * adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object |
|
1055 | + * |
|
1056 | + * @access private |
|
1057 | + * @param EE_Transaction $transaction |
|
1058 | + * @return array |
|
1059 | + * @throws InvalidDataTypeException |
|
1060 | + * @throws InvalidEntityException |
|
1061 | + * @throws EE_Error |
|
1062 | + */ |
|
1063 | + private function _initialize_registrations(EE_Transaction $transaction) |
|
1064 | + { |
|
1065 | + $att_nmbr = 0; |
|
1066 | + $registrations = array(); |
|
1067 | + if ($transaction instanceof EE_Transaction) { |
|
1068 | + /** @type EE_Registration_Processor $registration_processor */ |
|
1069 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1070 | + $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
|
1071 | + // now let's add the cart items to the $transaction |
|
1072 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
1073 | + // do the following for each ticket of this type they selected |
|
1074 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
1075 | + $att_nmbr++; |
|
1076 | + /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
1077 | + $CreateRegistrationCommand = EE_Registry::instance()->create( |
|
1078 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
1079 | + array( |
|
1080 | + $transaction, |
|
1081 | + $line_item, |
|
1082 | + $att_nmbr, |
|
1083 | + $this->checkout->total_ticket_count, |
|
1084 | + ) |
|
1085 | + ); |
|
1086 | + // override capabilities for frontend registrations |
|
1087 | + if (! is_admin()) { |
|
1088 | + $CreateRegistrationCommand->setCapCheck( |
|
1089 | + new PublicCapabilities('', 'create_new_registration') |
|
1090 | + ); |
|
1091 | + } |
|
1092 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
1093 | + if (! $registration instanceof EE_Registration) { |
|
1094 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
1095 | + } |
|
1096 | + $registrations[ $registration->ID() ] = $registration; |
|
1097 | + } |
|
1098 | + } |
|
1099 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
1100 | + } |
|
1101 | + return $registrations; |
|
1102 | + } |
|
1103 | + |
|
1104 | + |
|
1105 | + /** |
|
1106 | + * sorts registrations by REG_count |
|
1107 | + * |
|
1108 | + * @access public |
|
1109 | + * @param EE_Registration $reg_A |
|
1110 | + * @param EE_Registration $reg_B |
|
1111 | + * @return int |
|
1112 | + */ |
|
1113 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) |
|
1114 | + { |
|
1115 | + // this shouldn't ever happen within the same TXN, but oh well |
|
1116 | + if ($reg_A->count() === $reg_B->count()) { |
|
1117 | + return 0; |
|
1118 | + } |
|
1119 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
1120 | + } |
|
1121 | + |
|
1122 | + |
|
1123 | + /** |
|
1124 | + * _final_verifications |
|
1125 | + * just makes sure that everything is set up correctly before proceeding |
|
1126 | + * |
|
1127 | + * @access private |
|
1128 | + * @return bool |
|
1129 | + * @throws EE_Error |
|
1130 | + */ |
|
1131 | + private function _final_verifications() |
|
1132 | + { |
|
1133 | + // filter checkout |
|
1134 | + $this->checkout = apply_filters( |
|
1135 | + 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', |
|
1136 | + $this->checkout |
|
1137 | + ); |
|
1138 | + // verify that current step is still set correctly |
|
1139 | + if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1140 | + EE_Error::add_error( |
|
1141 | + esc_html__( |
|
1142 | + 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', |
|
1143 | + 'event_espresso' |
|
1144 | + ), |
|
1145 | + __FILE__, |
|
1146 | + __FUNCTION__, |
|
1147 | + __LINE__ |
|
1148 | + ); |
|
1149 | + return false; |
|
1150 | + } |
|
1151 | + // if returning to SPCO, then verify that primary registrant is set |
|
1152 | + if (! empty($this->checkout->reg_url_link)) { |
|
1153 | + $valid_registrant = $this->checkout->transaction->primary_registration(); |
|
1154 | + if (! $valid_registrant instanceof EE_Registration) { |
|
1155 | + EE_Error::add_error( |
|
1156 | + esc_html__( |
|
1157 | + 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', |
|
1158 | + 'event_espresso' |
|
1159 | + ), |
|
1160 | + __FILE__, |
|
1161 | + __FUNCTION__, |
|
1162 | + __LINE__ |
|
1163 | + ); |
|
1164 | + return false; |
|
1165 | + } |
|
1166 | + $valid_registrant = null; |
|
1167 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
1168 | + if ($registration instanceof EE_Registration |
|
1169 | + && $registration->reg_url_link() === $this->checkout->reg_url_link |
|
1170 | + ) { |
|
1171 | + $valid_registrant = $registration; |
|
1172 | + } |
|
1173 | + } |
|
1174 | + if (! $valid_registrant instanceof EE_Registration) { |
|
1175 | + // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
|
1176 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1177 | + // clear the session, mark the checkout as unverified, and try again |
|
1178 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
1179 | + EED_Single_Page_Checkout::$_initialized = false; |
|
1180 | + EED_Single_Page_Checkout::$_checkout_verified = false; |
|
1181 | + $this->_initialize(); |
|
1182 | + EE_Error::reset_notices(); |
|
1183 | + return false; |
|
1184 | + } |
|
1185 | + EE_Error::add_error( |
|
1186 | + esc_html__( |
|
1187 | + 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', |
|
1188 | + 'event_espresso' |
|
1189 | + ), |
|
1190 | + __FILE__, |
|
1191 | + __FUNCTION__, |
|
1192 | + __LINE__ |
|
1193 | + ); |
|
1194 | + return false; |
|
1195 | + } |
|
1196 | + } |
|
1197 | + // now that things have been kinda sufficiently verified, |
|
1198 | + // let's add the checkout to the session so that it's available to other systems |
|
1199 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1200 | + return true; |
|
1201 | + } |
|
1202 | + |
|
1203 | + |
|
1204 | + /** |
|
1205 | + * _initialize_reg_steps |
|
1206 | + * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required |
|
1207 | + * then loops thru all of the active reg steps and calls the initialize_reg_step() method |
|
1208 | + * |
|
1209 | + * @access private |
|
1210 | + * @param bool $reinitializing |
|
1211 | + * @throws EE_Error |
|
1212 | + */ |
|
1213 | + private function _initialize_reg_steps($reinitializing = false) |
|
1214 | + { |
|
1215 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1216 | + // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
|
1217 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
1218 | + if (! $reg_step->initialize_reg_step()) { |
|
1219 | + // if not initialized then maybe this step is being removed... |
|
1220 | + if (! $reinitializing && $reg_step->is_current_step()) { |
|
1221 | + // if it was the current step, then we need to start over here |
|
1222 | + $this->_initialize_reg_steps(true); |
|
1223 | + return; |
|
1224 | + } |
|
1225 | + continue; |
|
1226 | + } |
|
1227 | + // add css and JS for current step |
|
1228 | + $reg_step->enqueue_styles_and_scripts(); |
|
1229 | + // i18n |
|
1230 | + $reg_step->translate_js_strings(); |
|
1231 | + if ($reg_step->is_current_step()) { |
|
1232 | + // the text that appears on the reg step form submit button |
|
1233 | + $reg_step->set_submit_button_text(); |
|
1234 | + } |
|
1235 | + } |
|
1236 | + // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
|
1237 | + do_action( |
|
1238 | + "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", |
|
1239 | + $this->checkout->current_step |
|
1240 | + ); |
|
1241 | + } |
|
1242 | + |
|
1243 | + |
|
1244 | + /** |
|
1245 | + * _check_form_submission |
|
1246 | + * |
|
1247 | + * @access private |
|
1248 | + * @return boolean |
|
1249 | + */ |
|
1250 | + private function _check_form_submission() |
|
1251 | + { |
|
1252 | + // does this request require the reg form to be generated ? |
|
1253 | + if ($this->checkout->generate_reg_form) { |
|
1254 | + // ever heard that song by Blue Rodeo ? |
|
1255 | + try { |
|
1256 | + $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
|
1257 | + // if not displaying a form, then check for form submission |
|
1258 | + if ($this->checkout->process_form_submission |
|
1259 | + && $this->checkout->current_step->reg_form->was_submitted() |
|
1260 | + ) { |
|
1261 | + // clear out any old data in case this step is being run again |
|
1262 | + $this->checkout->current_step->set_valid_data(array()); |
|
1263 | + // capture submitted form data |
|
1264 | + $this->checkout->current_step->reg_form->receive_form_submission( |
|
1265 | + apply_filters( |
|
1266 | + 'FHEE__Single_Page_Checkout___check_form_submission__request_params', |
|
1267 | + EE_Registry::instance()->REQ->params(), |
|
1268 | + $this->checkout |
|
1269 | + ) |
|
1270 | + ); |
|
1271 | + // validate submitted form data |
|
1272 | + if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1273 | + // thou shall not pass !!! |
|
1274 | + $this->checkout->continue_reg = false; |
|
1275 | + // any form validation errors? |
|
1276 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1277 | + EE_Error::add_error( |
|
1278 | + $this->checkout->current_step->reg_form->submission_error_message(), |
|
1279 | + __FILE__, |
|
1280 | + __FUNCTION__, |
|
1281 | + __LINE__ |
|
1282 | + ); |
|
1283 | + } |
|
1284 | + // well not really... what will happen is |
|
1285 | + // we'll just get redirected back to redo the current step |
|
1286 | + $this->go_to_next_step(); |
|
1287 | + return false; |
|
1288 | + } |
|
1289 | + } |
|
1290 | + } catch (EE_Error $e) { |
|
1291 | + $e->get_error(); |
|
1292 | + } |
|
1293 | + } |
|
1294 | + return true; |
|
1295 | + } |
|
1296 | + |
|
1297 | + |
|
1298 | + /** |
|
1299 | + * _process_action |
|
1300 | + * |
|
1301 | + * @access private |
|
1302 | + * @return void |
|
1303 | + * @throws EE_Error |
|
1304 | + */ |
|
1305 | + private function _process_form_action() |
|
1306 | + { |
|
1307 | + // what cha wanna do? |
|
1308 | + switch ($this->checkout->action) { |
|
1309 | + // AJAX next step reg form |
|
1310 | + case 'display_spco_reg_step': |
|
1311 | + $this->checkout->redirect = false; |
|
1312 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1313 | + $this->checkout->json_response->set_reg_step_html( |
|
1314 | + $this->checkout->current_step->display_reg_form() |
|
1315 | + ); |
|
1316 | + } |
|
1317 | + break; |
|
1318 | + default: |
|
1319 | + // meh... do one of those other steps first |
|
1320 | + if (! empty($this->checkout->action) |
|
1321 | + && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
|
1322 | + ) { |
|
1323 | + // dynamically creates hook point like: |
|
1324 | + // AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
|
1325 | + do_action( |
|
1326 | + "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1327 | + $this->checkout->current_step |
|
1328 | + ); |
|
1329 | + // call action on current step |
|
1330 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1331 | + // good registrant, you get to proceed |
|
1332 | + if ($this->checkout->current_step->success_message() !== '' |
|
1333 | + && apply_filters( |
|
1334 | + 'FHEE__Single_Page_Checkout___process_form_action__display_success', |
|
1335 | + false |
|
1336 | + ) |
|
1337 | + ) { |
|
1338 | + EE_Error::add_success( |
|
1339 | + $this->checkout->current_step->success_message() |
|
1340 | + . '<br />' . $this->checkout->next_step->_instructions() |
|
1341 | + ); |
|
1342 | + } |
|
1343 | + // pack it up, pack it in... |
|
1344 | + $this->_setup_redirect(); |
|
1345 | + } |
|
1346 | + // dynamically creates hook point like: |
|
1347 | + // AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
|
1348 | + do_action( |
|
1349 | + "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", |
|
1350 | + $this->checkout->current_step |
|
1351 | + ); |
|
1352 | + } else { |
|
1353 | + EE_Error::add_error( |
|
1354 | + sprintf( |
|
1355 | + esc_html__( |
|
1356 | + 'The requested form action "%s" does not exist for the current "%s" registration step.', |
|
1357 | + 'event_espresso' |
|
1358 | + ), |
|
1359 | + $this->checkout->action, |
|
1360 | + $this->checkout->current_step->name() |
|
1361 | + ), |
|
1362 | + __FILE__, |
|
1363 | + __FUNCTION__, |
|
1364 | + __LINE__ |
|
1365 | + ); |
|
1366 | + } |
|
1367 | + // end default |
|
1368 | + } |
|
1369 | + // store our progress so far |
|
1370 | + $this->checkout->stash_transaction_and_checkout(); |
|
1371 | + // advance to the next step! If you pass GO, collect $200 |
|
1372 | + $this->go_to_next_step(); |
|
1373 | + } |
|
1374 | + |
|
1375 | + |
|
1376 | + /** |
|
1377 | + * add_styles_and_scripts |
|
1378 | + * |
|
1379 | + * @access public |
|
1380 | + * @return void |
|
1381 | + */ |
|
1382 | + public function add_styles_and_scripts() |
|
1383 | + { |
|
1384 | + // i18n |
|
1385 | + $this->translate_js_strings(); |
|
1386 | + if ($this->checkout->admin_request) { |
|
1387 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1388 | + } else { |
|
1389 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1390 | + } |
|
1391 | + } |
|
1392 | + |
|
1393 | + |
|
1394 | + /** |
|
1395 | + * translate_js_strings |
|
1396 | + * |
|
1397 | + * @access public |
|
1398 | + * @return void |
|
1399 | + */ |
|
1400 | + public function translate_js_strings() |
|
1401 | + { |
|
1402 | + EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
|
1403 | + EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
|
1404 | + EE_Registry::$i18n_js_strings['server_error'] = esc_html__( |
|
1405 | + 'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1406 | + 'event_espresso' |
|
1407 | + ); |
|
1408 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = esc_html__( |
|
1409 | + 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', |
|
1410 | + 'event_espresso' |
|
1411 | + ); |
|
1412 | + EE_Registry::$i18n_js_strings['validation_error'] = esc_html__( |
|
1413 | + 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', |
|
1414 | + 'event_espresso' |
|
1415 | + ); |
|
1416 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = esc_html__( |
|
1417 | + 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', |
|
1418 | + 'event_espresso' |
|
1419 | + ); |
|
1420 | + EE_Registry::$i18n_js_strings['reg_step_error'] = esc_html__( |
|
1421 | + 'This registration step could not be completed. Please refresh the page and try again.', |
|
1422 | + 'event_espresso' |
|
1423 | + ); |
|
1424 | + EE_Registry::$i18n_js_strings['invalid_coupon'] = esc_html__( |
|
1425 | + 'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', |
|
1426 | + 'event_espresso' |
|
1427 | + ); |
|
1428 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
|
1429 | + esc_html__( |
|
1430 | + 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', |
|
1431 | + 'event_espresso' |
|
1432 | + ), |
|
1433 | + '<br/>', |
|
1434 | + '<br/>' |
|
1435 | + ); |
|
1436 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1437 | + EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
|
1438 | + EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
|
1439 | + EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
|
1440 | + EE_Registry::$i18n_js_strings['timer_years'] = esc_html__('years', 'event_espresso'); |
|
1441 | + EE_Registry::$i18n_js_strings['timer_months'] = esc_html__('months', 'event_espresso'); |
|
1442 | + EE_Registry::$i18n_js_strings['timer_weeks'] = esc_html__('weeks', 'event_espresso'); |
|
1443 | + EE_Registry::$i18n_js_strings['timer_days'] = esc_html__('days', 'event_espresso'); |
|
1444 | + EE_Registry::$i18n_js_strings['timer_hours'] = esc_html__('hours', 'event_espresso'); |
|
1445 | + EE_Registry::$i18n_js_strings['timer_minutes'] = esc_html__('minutes', 'event_espresso'); |
|
1446 | + EE_Registry::$i18n_js_strings['timer_seconds'] = esc_html__('seconds', 'event_espresso'); |
|
1447 | + EE_Registry::$i18n_js_strings['timer_year'] = esc_html__('year', 'event_espresso'); |
|
1448 | + EE_Registry::$i18n_js_strings['timer_month'] = esc_html__('month', 'event_espresso'); |
|
1449 | + EE_Registry::$i18n_js_strings['timer_week'] = esc_html__('week', 'event_espresso'); |
|
1450 | + EE_Registry::$i18n_js_strings['timer_day'] = esc_html__('day', 'event_espresso'); |
|
1451 | + EE_Registry::$i18n_js_strings['timer_hour'] = esc_html__('hour', 'event_espresso'); |
|
1452 | + EE_Registry::$i18n_js_strings['timer_minute'] = esc_html__('minute', 'event_espresso'); |
|
1453 | + EE_Registry::$i18n_js_strings['timer_second'] = esc_html__('second', 'event_espresso'); |
|
1454 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
|
1455 | + ); |
|
1456 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters( |
|
1457 | + 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
1458 | + true |
|
1459 | + ); |
|
1460 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1461 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1462 | + ); |
|
1463 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1464 | + 'M d, Y H:i:s', |
|
1465 | + EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1466 | + ); |
|
1467 | + } |
|
1468 | + |
|
1469 | + |
|
1470 | + /** |
|
1471 | + * enqueue_styles_and_scripts |
|
1472 | + * |
|
1473 | + * @access public |
|
1474 | + * @return void |
|
1475 | + * @throws EE_Error |
|
1476 | + */ |
|
1477 | + public function enqueue_styles_and_scripts() |
|
1478 | + { |
|
1479 | + // load css |
|
1480 | + wp_register_style( |
|
1481 | + 'single_page_checkout', |
|
1482 | + SPCO_CSS_URL . 'single_page_checkout.css', |
|
1483 | + array('espresso_default'), |
|
1484 | + EVENT_ESPRESSO_VERSION |
|
1485 | + ); |
|
1486 | + wp_enqueue_style('single_page_checkout'); |
|
1487 | + // load JS |
|
1488 | + wp_register_script( |
|
1489 | + 'jquery_plugin', |
|
1490 | + EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', |
|
1491 | + array('jquery'), |
|
1492 | + '1.0.1', |
|
1493 | + true |
|
1494 | + ); |
|
1495 | + wp_register_script( |
|
1496 | + 'jquery_countdown', |
|
1497 | + EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', |
|
1498 | + array('jquery_plugin'), |
|
1499 | + '2.1.0', |
|
1500 | + true |
|
1501 | + ); |
|
1502 | + wp_register_script( |
|
1503 | + 'single_page_checkout', |
|
1504 | + SPCO_JS_URL . 'single_page_checkout.js', |
|
1505 | + array('espresso_core', 'underscore', 'ee_form_section_validation'), |
|
1506 | + EVENT_ESPRESSO_VERSION, |
|
1507 | + true |
|
1508 | + ); |
|
1509 | + if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) { |
|
1510 | + $this->checkout->registration_form->enqueue_js(); |
|
1511 | + } |
|
1512 | + if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) { |
|
1513 | + $this->checkout->current_step->reg_form->enqueue_js(); |
|
1514 | + } |
|
1515 | + wp_enqueue_script('single_page_checkout'); |
|
1516 | + if (apply_filters('FHEE__registration_page_wrapper_template__display_time_limit', false)) { |
|
1517 | + wp_enqueue_script('jquery_countdown'); |
|
1518 | + } |
|
1519 | + /** |
|
1520 | + * global action hook for enqueueing styles and scripts with |
|
1521 | + * spco calls. |
|
1522 | + */ |
|
1523 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1524 | + /** |
|
1525 | + * dynamic action hook for enqueueing styles and scripts with spco calls. |
|
1526 | + * The hook will end up being something like: |
|
1527 | + * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
|
1528 | + */ |
|
1529 | + do_action( |
|
1530 | + 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
1531 | + $this |
|
1532 | + ); |
|
1533 | + } |
|
1534 | + |
|
1535 | + |
|
1536 | + /** |
|
1537 | + * display the Registration Single Page Checkout Form |
|
1538 | + * |
|
1539 | + * @access private |
|
1540 | + * @return void |
|
1541 | + * @throws EE_Error |
|
1542 | + */ |
|
1543 | + private function _display_spco_reg_form() |
|
1544 | + { |
|
1545 | + // if registering via the admin, just display the reg form for the current step |
|
1546 | + if ($this->checkout->admin_request) { |
|
1547 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1548 | + } else { |
|
1549 | + // add powered by EE msg |
|
1550 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1551 | + $empty_cart = count($this->checkout->transaction |
|
1552 | + ->registrations($this->checkout->reg_cache_where_params)) < 1; |
|
1553 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1554 | + $cookies_not_set_msg = ''; |
|
1555 | + if ($empty_cart) { |
|
1556 | + $cookies_not_set_msg = apply_filters( |
|
1557 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
|
1558 | + sprintf( |
|
1559 | + esc_html__( |
|
1560 | + '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', |
|
1561 | + 'event_espresso' |
|
1562 | + ), |
|
1563 | + '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">', |
|
1564 | + '</div>', |
|
1565 | + '<h6 class="important-notice">', |
|
1566 | + '</h6>', |
|
1567 | + '<p>', |
|
1568 | + '</p>', |
|
1569 | + '<br />', |
|
1570 | + '<a href="http://www.whatarecookies.com/enable.asp" target="_blank" rel="noopener noreferrer">', |
|
1571 | + '</a>' |
|
1572 | + ) |
|
1573 | + ); |
|
1574 | + } |
|
1575 | + $this->checkout->registration_form = new EE_Form_Section_Proper( |
|
1576 | + array( |
|
1577 | + 'name' => 'single-page-checkout', |
|
1578 | + 'html_id' => 'ee-single-page-checkout-dv', |
|
1579 | + 'layout_strategy' => |
|
1580 | + new EE_Template_Layout( |
|
1581 | + array( |
|
1582 | + 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1583 | + 'template_args' => array( |
|
1584 | + 'empty_cart' => $empty_cart, |
|
1585 | + 'revisit' => $this->checkout->revisit, |
|
1586 | + 'reg_steps' => $this->checkout->reg_steps, |
|
1587 | + 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
|
1588 | + ? $this->checkout->next_step->slug() |
|
1589 | + : '', |
|
1590 | + 'empty_msg' => apply_filters( |
|
1591 | + 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
|
1592 | + sprintf( |
|
1593 | + esc_html__( |
|
1594 | + 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', |
|
1595 | + 'event_espresso' |
|
1596 | + ), |
|
1597 | + '<a href="' |
|
1598 | + . get_post_type_archive_link('espresso_events') |
|
1599 | + . '" title="', |
|
1600 | + '">', |
|
1601 | + '</a>' |
|
1602 | + ) |
|
1603 | + ), |
|
1604 | + 'cookies_not_set_msg' => $cookies_not_set_msg, |
|
1605 | + 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
|
1606 | + 'session_expiration' => gmdate( |
|
1607 | + 'M d, Y H:i:s', |
|
1608 | + EE_Registry::instance()->SSN->expiration() |
|
1609 | + + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1610 | + ), |
|
1611 | + ), |
|
1612 | + ) |
|
1613 | + ), |
|
1614 | + ) |
|
1615 | + ); |
|
1616 | + // load template and add to output sent that gets filtered into the_content() |
|
1617 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html()); |
|
1618 | + } |
|
1619 | + } |
|
1620 | + |
|
1621 | + |
|
1622 | + /** |
|
1623 | + * add_extra_finalize_registration_inputs |
|
1624 | + * |
|
1625 | + * @access public |
|
1626 | + * @param $next_step |
|
1627 | + * @internal param string $label |
|
1628 | + * @return void |
|
1629 | + */ |
|
1630 | + public function add_extra_finalize_registration_inputs($next_step) |
|
1631 | + { |
|
1632 | + if ($next_step === 'finalize_registration') { |
|
1633 | + echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
|
1634 | + } |
|
1635 | + } |
|
1636 | + |
|
1637 | + |
|
1638 | + /** |
|
1639 | + * display_registration_footer |
|
1640 | + * |
|
1641 | + * @access public |
|
1642 | + * @return string |
|
1643 | + */ |
|
1644 | + public static function display_registration_footer() |
|
1645 | + { |
|
1646 | + if (apply_filters( |
|
1647 | + 'FHEE__EE_Front__Controller__show_reg_footer', |
|
1648 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
1649 | + )) { |
|
1650 | + add_filter( |
|
1651 | + 'FHEE__EEH_Template__powered_by_event_espresso__url', |
|
1652 | + function ($url) { |
|
1653 | + return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1654 | + } |
|
1655 | + ); |
|
1656 | + echo apply_filters( |
|
1657 | + 'FHEE__EE_Front_Controller__display_registration_footer', |
|
1658 | + \EEH_Template::powered_by_event_espresso( |
|
1659 | + '', |
|
1660 | + 'espresso-registration-footer-dv', |
|
1661 | + array('utm_content' => 'registration_checkout') |
|
1662 | + ) |
|
1663 | + ); |
|
1664 | + } |
|
1665 | + return ''; |
|
1666 | + } |
|
1667 | + |
|
1668 | + |
|
1669 | + /** |
|
1670 | + * unlock_transaction |
|
1671 | + * |
|
1672 | + * @access public |
|
1673 | + * @return void |
|
1674 | + * @throws EE_Error |
|
1675 | + */ |
|
1676 | + public function unlock_transaction() |
|
1677 | + { |
|
1678 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1679 | + $this->checkout->transaction->unlock(); |
|
1680 | + } |
|
1681 | + } |
|
1682 | + |
|
1683 | + |
|
1684 | + /** |
|
1685 | + * _setup_redirect |
|
1686 | + * |
|
1687 | + * @access private |
|
1688 | + * @return void |
|
1689 | + */ |
|
1690 | + private function _setup_redirect() |
|
1691 | + { |
|
1692 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1693 | + $this->checkout->redirect = true; |
|
1694 | + if (empty($this->checkout->redirect_url)) { |
|
1695 | + $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
|
1696 | + } |
|
1697 | + $this->checkout->redirect_url = apply_filters( |
|
1698 | + 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', |
|
1699 | + $this->checkout->redirect_url, |
|
1700 | + $this->checkout |
|
1701 | + ); |
|
1702 | + } |
|
1703 | + } |
|
1704 | + |
|
1705 | + |
|
1706 | + /** |
|
1707 | + * handle ajax message responses and redirects |
|
1708 | + * |
|
1709 | + * @access public |
|
1710 | + * @return void |
|
1711 | + * @throws EE_Error |
|
1712 | + */ |
|
1713 | + public function go_to_next_step() |
|
1714 | + { |
|
1715 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1716 | + // capture contents of output buffer we started earlier in the request, and insert into JSON response |
|
1717 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1718 | + } |
|
1719 | + $this->unlock_transaction(); |
|
1720 | + // just return for these conditions |
|
1721 | + if ($this->checkout->admin_request |
|
1722 | + || $this->checkout->action === 'redirect_form' |
|
1723 | + || $this->checkout->action === 'update_checkout' |
|
1724 | + ) { |
|
1725 | + return; |
|
1726 | + } |
|
1727 | + // AJAX response |
|
1728 | + $this->_handle_json_response(); |
|
1729 | + // redirect to next step or the Thank You page |
|
1730 | + $this->_handle_html_redirects(); |
|
1731 | + // hmmm... must be something wrong, so let's just display the form again ! |
|
1732 | + $this->_display_spco_reg_form(); |
|
1733 | + } |
|
1734 | + |
|
1735 | + |
|
1736 | + /** |
|
1737 | + * _handle_json_response |
|
1738 | + * |
|
1739 | + * @access protected |
|
1740 | + * @return void |
|
1741 | + */ |
|
1742 | + protected function _handle_json_response() |
|
1743 | + { |
|
1744 | + // if this is an ajax request |
|
1745 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1746 | + $this->checkout->json_response->set_registration_time_limit( |
|
1747 | + $this->checkout->get_registration_time_limit() |
|
1748 | + ); |
|
1749 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1750 | + // just send the ajax ( |
|
1751 | + $json_response = apply_filters( |
|
1752 | + 'FHEE__EE_Single_Page_Checkout__JSON_response', |
|
1753 | + $this->checkout->json_response |
|
1754 | + ); |
|
1755 | + echo $json_response; |
|
1756 | + exit(); |
|
1757 | + } |
|
1758 | + } |
|
1759 | + |
|
1760 | + |
|
1761 | + /** |
|
1762 | + * _handle_redirects |
|
1763 | + * |
|
1764 | + * @access protected |
|
1765 | + * @return void |
|
1766 | + */ |
|
1767 | + protected function _handle_html_redirects() |
|
1768 | + { |
|
1769 | + // going somewhere ? |
|
1770 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1771 | + // store notices in a transient |
|
1772 | + EE_Error::get_notices(false, true, true); |
|
1773 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1774 | + exit(); |
|
1775 | + } |
|
1776 | + } |
|
1777 | + |
|
1778 | + |
|
1779 | + /** |
|
1780 | + * set_checkout_anchor |
|
1781 | + * |
|
1782 | + * @access public |
|
1783 | + * @return void |
|
1784 | + */ |
|
1785 | + public function set_checkout_anchor() |
|
1786 | + { |
|
1787 | + echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>'; |
|
1788 | + } |
|
1789 | + |
|
1790 | + /** |
|
1791 | + * getRegistrationExpirationNotice |
|
1792 | + * |
|
1793 | + * @since 4.9.59.p |
|
1794 | + * @access public |
|
1795 | + * @return string |
|
1796 | + */ |
|
1797 | + public static function getRegistrationExpirationNotice() |
|
1798 | + { |
|
1799 | + return sprintf( |
|
1800 | + esc_html__( |
|
1801 | + '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s', |
|
1802 | + 'event_espresso' |
|
1803 | + ), |
|
1804 | + '<h4 class="important-notice">', |
|
1805 | + '</h4>', |
|
1806 | + '<br />', |
|
1807 | + '<p>', |
|
1808 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1809 | + '">', |
|
1810 | + '</a>', |
|
1811 | + '</p>' |
|
1812 | + ); |
|
1813 | + } |
|
1814 | 1814 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public static function set_hooks_admin() |
101 | 101 | { |
102 | 102 | EED_Single_Page_Checkout::set_definitions(); |
103 | - if (! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
103 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX)) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | // going to start an output buffer in case anything gets accidentally output |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | } |
207 | 207 | define( |
208 | 208 | 'SPCO_BASE_PATH', |
209 | - rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
209 | + rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/').'/' |
|
210 | 210 | ); |
211 | - define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css/'); |
|
212 | - define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img/'); |
|
213 | - define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js/'); |
|
214 | - define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc/'); |
|
215 | - define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps/'); |
|
216 | - define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates/'); |
|
211 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css/'); |
|
212 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img/'); |
|
213 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js/'); |
|
214 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc/'); |
|
215 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps/'); |
|
216 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates/'); |
|
217 | 217 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true); |
218 | 218 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice( |
219 | 219 | ); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | // we need a |
246 | 246 | if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
247 | 247 | // copy over to the reg_steps_array |
248 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
248 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
249 | 249 | // register custom key route for each reg step |
250 | 250 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
251 | 251 | EE_Config::register_route( |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | // add AJAX or other hooks |
258 | 258 | if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
259 | 259 | // setup autoloaders if necessary |
260 | - if (! class_exists($reg_step['class_name'])) { |
|
260 | + if ( ! class_exists($reg_step['class_name'])) { |
|
261 | 261 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder( |
262 | 262 | $reg_step['file_path'], |
263 | 263 | true |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | if (empty($reg_steps)) { |
286 | 286 | $reg_steps = array( |
287 | 287 | 10 => array( |
288 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
288 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
289 | 289 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
290 | 290 | 'slug' => 'attendee_information', |
291 | 291 | 'has_hooks' => false, |
292 | 292 | ), |
293 | 293 | 30 => array( |
294 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
294 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
295 | 295 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
296 | 296 | 'slug' => 'payment_options', |
297 | 297 | 'has_hooks' => true, |
298 | 298 | ), |
299 | 299 | 999 => array( |
300 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
300 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
301 | 301 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
302 | 302 | 'slug' => 'finalize_registration', |
303 | 303 | 'has_hooks' => false, |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | $this->checkout |
451 | 451 | ); |
452 | 452 | // load the reg steps array |
453 | - if (! $this->_load_and_instantiate_reg_steps()) { |
|
453 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
454 | 454 | EED_Single_Page_Checkout::$_initialized = true; |
455 | 455 | return; |
456 | 456 | } |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | // and the next step |
460 | 460 | $this->checkout->set_next_step(); |
461 | 461 | // verify that everything has been setup correctly |
462 | - if (! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
462 | + if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
463 | 463 | EED_Single_Page_Checkout::$_initialized = true; |
464 | 464 | return; |
465 | 465 | } |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | // DEBUG LOG |
475 | 475 | // $this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
476 | 476 | // get reg form |
477 | - if (! $this->_check_form_submission()) { |
|
477 | + if ( ! $this->_check_form_submission()) { |
|
478 | 478 | EED_Single_Page_Checkout::$_initialized = true; |
479 | 479 | return; |
480 | 480 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | */ |
506 | 506 | private function _verify_session() |
507 | 507 | { |
508 | - if (! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
508 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
509 | 509 | throw new EE_Error(esc_html__('The EE_Session class could not be loaded.', 'event_espresso')); |
510 | 510 | } |
511 | 511 | $clear_session_requested = filter_var( |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | // EE_Registry::instance()->SSN->reset_cart(); |
524 | 524 | // EE_Registry::instance()->SSN->reset_checkout(); |
525 | 525 | // EE_Registry::instance()->SSN->reset_transaction(); |
526 | - if (! $clear_session_requested) { |
|
526 | + if ( ! $clear_session_requested) { |
|
527 | 527 | EE_Error::add_attention( |
528 | 528 | EE_Registry::$i18n_js_strings['registration_expiration_notice'], |
529 | 529 | __FILE__, |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | /** @type EE_Checkout $checkout */ |
551 | 551 | $checkout = EE_Registry::instance()->SSN->checkout(); |
552 | 552 | // verify |
553 | - if (! $checkout instanceof EE_Checkout) { |
|
553 | + if ( ! $checkout instanceof EE_Checkout) { |
|
554 | 554 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
555 | 555 | $checkout = EE_Registry::instance()->load_file( |
556 | 556 | SPCO_INC_PATH, |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | } |
569 | 569 | $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
570 | 570 | // verify again |
571 | - if (! $checkout instanceof EE_Checkout) { |
|
571 | + if ( ! $checkout instanceof EE_Checkout) { |
|
572 | 572 | throw new EE_Error(esc_html__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
573 | 573 | } |
574 | 574 | // reset anything that needs a clean slate for each request |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | */ |
641 | 641 | protected function _display_request_vars() |
642 | 642 | { |
643 | - if (! WP_DEBUG) { |
|
643 | + if ( ! WP_DEBUG) { |
|
644 | 644 | return; |
645 | 645 | } |
646 | 646 | EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | ) { |
718 | 718 | // if not, then loop through raw reg steps array |
719 | 719 | foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
720 | - if (! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
720 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
721 | 721 | return false; |
722 | 722 | } |
723 | 723 | } |
@@ -848,12 +848,12 @@ discard block |
||
848 | 848 | private function _verify_transaction_and_get_registrations() |
849 | 849 | { |
850 | 850 | // was there already a valid transaction in the checkout from the session ? |
851 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
851 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
852 | 852 | // get transaction from db or session |
853 | 853 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
854 | 854 | ? $this->_get_transaction_and_cart_for_previous_visit() |
855 | 855 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
856 | - if (! $this->checkout->transaction instanceof EE_Transaction) { |
|
856 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
857 | 857 | EE_Error::add_error( |
858 | 858 | esc_html__( |
859 | 859 | 'Your Registration and Transaction information could not be retrieved from the db.', |
@@ -1084,16 +1084,16 @@ discard block |
||
1084 | 1084 | ) |
1085 | 1085 | ); |
1086 | 1086 | // override capabilities for frontend registrations |
1087 | - if (! is_admin()) { |
|
1087 | + if ( ! is_admin()) { |
|
1088 | 1088 | $CreateRegistrationCommand->setCapCheck( |
1089 | 1089 | new PublicCapabilities('', 'create_new_registration') |
1090 | 1090 | ); |
1091 | 1091 | } |
1092 | 1092 | $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
1093 | - if (! $registration instanceof EE_Registration) { |
|
1093 | + if ( ! $registration instanceof EE_Registration) { |
|
1094 | 1094 | throw new InvalidEntityException($registration, 'EE_Registration'); |
1095 | 1095 | } |
1096 | - $registrations[ $registration->ID() ] = $registration; |
|
1096 | + $registrations[$registration->ID()] = $registration; |
|
1097 | 1097 | } |
1098 | 1098 | } |
1099 | 1099 | $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | $this->checkout |
1137 | 1137 | ); |
1138 | 1138 | // verify that current step is still set correctly |
1139 | - if (! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1139 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
1140 | 1140 | EE_Error::add_error( |
1141 | 1141 | esc_html__( |
1142 | 1142 | 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', |
@@ -1149,9 +1149,9 @@ discard block |
||
1149 | 1149 | return false; |
1150 | 1150 | } |
1151 | 1151 | // if returning to SPCO, then verify that primary registrant is set |
1152 | - if (! empty($this->checkout->reg_url_link)) { |
|
1152 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
1153 | 1153 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
1154 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1154 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
1155 | 1155 | EE_Error::add_error( |
1156 | 1156 | esc_html__( |
1157 | 1157 | 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | $valid_registrant = $registration; |
1172 | 1172 | } |
1173 | 1173 | } |
1174 | - if (! $valid_registrant instanceof EE_Registration) { |
|
1174 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
1175 | 1175 | // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
1176 | 1176 | if (EED_Single_Page_Checkout::$_checkout_verified) { |
1177 | 1177 | // clear the session, mark the checkout as unverified, and try again |
@@ -1215,9 +1215,9 @@ discard block |
||
1215 | 1215 | $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
1216 | 1216 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
1217 | 1217 | foreach ($this->checkout->reg_steps as $reg_step) { |
1218 | - if (! $reg_step->initialize_reg_step()) { |
|
1218 | + if ( ! $reg_step->initialize_reg_step()) { |
|
1219 | 1219 | // if not initialized then maybe this step is being removed... |
1220 | - if (! $reinitializing && $reg_step->is_current_step()) { |
|
1220 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
1221 | 1221 | // if it was the current step, then we need to start over here |
1222 | 1222 | $this->_initialize_reg_steps(true); |
1223 | 1223 | return; |
@@ -1269,7 +1269,7 @@ discard block |
||
1269 | 1269 | ) |
1270 | 1270 | ); |
1271 | 1271 | // validate submitted form data |
1272 | - if (! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1272 | + if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1273 | 1273 | // thou shall not pass !!! |
1274 | 1274 | $this->checkout->continue_reg = false; |
1275 | 1275 | // any form validation errors? |
@@ -1317,7 +1317,7 @@ discard block |
||
1317 | 1317 | break; |
1318 | 1318 | default: |
1319 | 1319 | // meh... do one of those other steps first |
1320 | - if (! empty($this->checkout->action) |
|
1320 | + if ( ! empty($this->checkout->action) |
|
1321 | 1321 | && is_callable(array($this->checkout->current_step, $this->checkout->action)) |
1322 | 1322 | ) { |
1323 | 1323 | // dynamically creates hook point like: |
@@ -1337,7 +1337,7 @@ discard block |
||
1337 | 1337 | ) { |
1338 | 1338 | EE_Error::add_success( |
1339 | 1339 | $this->checkout->current_step->success_message() |
1340 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1340 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
1341 | 1341 | ); |
1342 | 1342 | } |
1343 | 1343 | // pack it up, pack it in... |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | // load css |
1480 | 1480 | wp_register_style( |
1481 | 1481 | 'single_page_checkout', |
1482 | - SPCO_CSS_URL . 'single_page_checkout.css', |
|
1482 | + SPCO_CSS_URL.'single_page_checkout.css', |
|
1483 | 1483 | array('espresso_default'), |
1484 | 1484 | EVENT_ESPRESSO_VERSION |
1485 | 1485 | ); |
@@ -1487,21 +1487,21 @@ discard block |
||
1487 | 1487 | // load JS |
1488 | 1488 | wp_register_script( |
1489 | 1489 | 'jquery_plugin', |
1490 | - EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', |
|
1490 | + EE_THIRD_PARTY_URL.'jquery .plugin.min.js', |
|
1491 | 1491 | array('jquery'), |
1492 | 1492 | '1.0.1', |
1493 | 1493 | true |
1494 | 1494 | ); |
1495 | 1495 | wp_register_script( |
1496 | 1496 | 'jquery_countdown', |
1497 | - EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', |
|
1497 | + EE_THIRD_PARTY_URL.'jquery .countdown.min.js', |
|
1498 | 1498 | array('jquery_plugin'), |
1499 | 1499 | '2.1.0', |
1500 | 1500 | true |
1501 | 1501 | ); |
1502 | 1502 | wp_register_script( |
1503 | 1503 | 'single_page_checkout', |
1504 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
1504 | + SPCO_JS_URL.'single_page_checkout.js', |
|
1505 | 1505 | array('espresso_core', 'underscore', 'ee_form_section_validation'), |
1506 | 1506 | EVENT_ESPRESSO_VERSION, |
1507 | 1507 | true |
@@ -1527,7 +1527,7 @@ discard block |
||
1527 | 1527 | * AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1528 | 1528 | */ |
1529 | 1529 | do_action( |
1530 | - 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), |
|
1530 | + 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), |
|
1531 | 1531 | $this |
1532 | 1532 | ); |
1533 | 1533 | } |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | 'layout_strategy' => |
1580 | 1580 | new EE_Template_Layout( |
1581 | 1581 | array( |
1582 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1582 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1583 | 1583 | 'template_args' => array( |
1584 | 1584 | 'empty_cart' => $empty_cart, |
1585 | 1585 | 'revisit' => $this->checkout->revisit, |
@@ -1649,7 +1649,7 @@ discard block |
||
1649 | 1649 | )) { |
1650 | 1650 | add_filter( |
1651 | 1651 | 'FHEE__EEH_Template__powered_by_event_espresso__url', |
1652 | - function ($url) { |
|
1652 | + function($url) { |
|
1653 | 1653 | return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
1654 | 1654 | } |
1655 | 1655 | ); |
@@ -1805,7 +1805,7 @@ discard block |
||
1805 | 1805 | '</h4>', |
1806 | 1806 | '<br />', |
1807 | 1807 | '<p>', |
1808 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" title="', |
|
1808 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1809 | 1809 | '">', |
1810 | 1810 | '</a>', |
1811 | 1811 | '</p>' |
@@ -14,472 +14,472 @@ discard block |
||
14 | 14 | class EED_Event_Single extends EED_Module |
15 | 15 | { |
16 | 16 | |
17 | - const EVENT_DETAILS_PRIORITY = 100; |
|
18 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
19 | - const EVENT_TICKETS_PRIORITY = 120; |
|
20 | - const EVENT_VENUES_PRIORITY = 130; |
|
21 | - |
|
22 | - /** |
|
23 | - * @type bool $using_get_the_excerpt |
|
24 | - */ |
|
25 | - protected static $using_get_the_excerpt = false; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @type EE_Template_Part_Manager $template_parts |
|
30 | - */ |
|
31 | - protected $template_parts; |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @return EED_Module|EED_Event_Single |
|
36 | - */ |
|
37 | - public static function instance() |
|
38 | - { |
|
39 | - return parent::get_instance(__CLASS__); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
45 | - * |
|
46 | - * @return void |
|
47 | - * @throws InvalidArgumentException |
|
48 | - * @throws InvalidDataTypeException |
|
49 | - * @throws InvalidInterfaceException |
|
50 | - */ |
|
51 | - public static function set_hooks() |
|
52 | - { |
|
53 | - add_filter('FHEE_run_EE_wp', '__return_true'); |
|
54 | - add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
55 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
56 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
57 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
58 | - ); |
|
59 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
60 | - EE_Config::register_route( |
|
61 | - $custom_post_types['espresso_events']['singular_slug'], |
|
62 | - 'Event_Single', |
|
63 | - 'run' |
|
64 | - ); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
69 | - * |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public static function set_hooks_admin() |
|
73 | - { |
|
74 | - add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * set_definitions |
|
80 | - * |
|
81 | - * @static |
|
82 | - * @return void |
|
83 | - */ |
|
84 | - public static function set_definitions() |
|
85 | - { |
|
86 | - define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
87 | - define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * set_config |
|
93 | - * |
|
94 | - * @void |
|
95 | - */ |
|
96 | - protected function set_config() |
|
97 | - { |
|
98 | - $this->set_config_section('template_settings'); |
|
99 | - $this->set_config_class('EE_Event_Single_Config'); |
|
100 | - $this->set_config_name('EED_Event_Single'); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * initialize_template_parts |
|
106 | - * |
|
107 | - * @param EE_Config_Base|EE_Event_Single_Config $config |
|
108 | - * @return EE_Template_Part_Manager |
|
109 | - */ |
|
110 | - public function initialize_template_parts(EE_Event_Single_Config $config = null) |
|
111 | - { |
|
112 | - /** @type EE_Event_Single_Config $config */ |
|
113 | - $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
114 | - EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
115 | - $template_parts = new EE_Template_Part_Manager(); |
|
116 | - $template_parts->add_template_part( |
|
117 | - 'tickets', |
|
118 | - __('Ticket Selector', 'event_espresso'), |
|
119 | - 'content-espresso_events-tickets.php', |
|
120 | - $config->display_order_tickets |
|
121 | - ); |
|
122 | - $template_parts->add_template_part( |
|
123 | - 'datetimes', |
|
124 | - __('Dates and Times', 'event_espresso'), |
|
125 | - 'content-espresso_events-datetimes.php', |
|
126 | - $config->display_order_datetimes |
|
127 | - ); |
|
128 | - $template_parts->add_template_part( |
|
129 | - 'event', |
|
130 | - __('Event Description', 'event_espresso'), |
|
131 | - 'content-espresso_events-details.php', |
|
132 | - $config->display_order_event |
|
133 | - ); |
|
134 | - $template_parts->add_template_part( |
|
135 | - 'venue', |
|
136 | - __('Venue Information', 'event_espresso'), |
|
137 | - 'content-espresso_events-venues.php', |
|
138 | - $config->display_order_venue |
|
139 | - ); |
|
140 | - do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
141 | - return $template_parts; |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * run - initial module setup |
|
147 | - * |
|
148 | - * @param WP $WP |
|
149 | - * @return void |
|
150 | - */ |
|
151 | - public function run($WP) |
|
152 | - { |
|
153 | - // ensure valid EE_Events_Single_Config() object exists |
|
154 | - $this->set_config(); |
|
155 | - // check what template is loaded |
|
156 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
157 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
158 | - // load css |
|
159 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * template_include |
|
165 | - * |
|
166 | - * @param string $template |
|
167 | - * @return string |
|
168 | - */ |
|
169 | - public function template_include($template) |
|
170 | - { |
|
171 | - global $post; |
|
172 | - /** @type EE_Event_Single_Config $config */ |
|
173 | - $config = $this->config(); |
|
174 | - if ($config->display_status_banner_single) { |
|
175 | - add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
176 | - } |
|
177 | - // not a custom template? |
|
178 | - if (! post_password_required($post) |
|
179 | - && ( |
|
180 | - apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
181 | - || EE_Registry::instance() |
|
182 | - ->load_core('Front_Controller') |
|
183 | - ->get_selected_template() !== 'single-espresso_events.php' |
|
184 | - ) |
|
185 | - |
|
186 | - ) { |
|
187 | - EEH_Template::load_espresso_theme_functions(); |
|
188 | - // then add extra event data via hooks |
|
189 | - add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
190 | - add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
191 | - add_filter( |
|
192 | - 'the_content', |
|
193 | - array('EED_Event_Single', 'event_details'), |
|
194 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
195 | - ); |
|
196 | - add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
197 | - // don't display entry meta because the existing theme will take car of that |
|
198 | - add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
199 | - } |
|
200 | - return $template; |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * loop_start |
|
206 | - * |
|
207 | - * @param array $wp_query_array an array containing the WP_Query object |
|
208 | - * @return void |
|
209 | - */ |
|
210 | - public static function loop_start($wp_query_array) |
|
211 | - { |
|
212 | - global $post; |
|
213 | - do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * the_title |
|
219 | - * |
|
220 | - * @param string $title |
|
221 | - * @param int $id |
|
222 | - * @return string |
|
223 | - */ |
|
224 | - public static function the_title($title = '', $id = 0) |
|
225 | - { |
|
226 | - global $post; |
|
227 | - return in_the_loop() && $post->ID === (int) $id |
|
228 | - ? espresso_event_status_banner($post->ID) . $title |
|
229 | - : $title; |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * get_the_excerpt |
|
235 | - * kinda hacky, but if a theme is using get_the_excerpt(), |
|
236 | - * then we need to remove our filters on the_content() |
|
237 | - * |
|
238 | - * @param string $excerpt |
|
239 | - * @return string |
|
240 | - */ |
|
241 | - public static function get_the_excerpt($excerpt = '') |
|
242 | - { |
|
243 | - EED_Event_Single::$using_get_the_excerpt = true; |
|
244 | - add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
245 | - return $excerpt; |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - /** |
|
250 | - * end_get_the_excerpt |
|
251 | - * |
|
252 | - * @param string $text |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public static function end_get_the_excerpt($text = '') |
|
256 | - { |
|
257 | - EED_Event_Single::$using_get_the_excerpt = false; |
|
258 | - return $text; |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * event_details |
|
264 | - * |
|
265 | - * @param string $content |
|
266 | - * @return string |
|
267 | - */ |
|
268 | - public static function event_details($content) |
|
269 | - { |
|
270 | - global $post; |
|
271 | - static $current_post_ID = 0; |
|
272 | - if ($current_post_ID !== $post->ID |
|
273 | - && $post->post_type === 'espresso_events' |
|
274 | - && ! EED_Event_Single::$using_get_the_excerpt |
|
275 | - && ! post_password_required() |
|
276 | - ) { |
|
277 | - // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
278 | - // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
279 | - // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
280 | - // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
281 | - // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
282 | - // so the following allows this filter to be applied multiple times, but only once for real |
|
283 | - $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
284 | - if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
285 | - // we need to first remove this callback from being applied to the_content() |
|
286 | - // (otherwise it will recurse and blow up the interweb) |
|
287 | - remove_filter( |
|
288 | - 'the_content', |
|
289 | - array('EED_Event_Single', 'event_details'), |
|
290 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
291 | - ); |
|
292 | - EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts( |
|
293 | - ); |
|
294 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
295 | - $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
296 | - add_filter( |
|
297 | - 'the_content', |
|
298 | - array('EED_Event_Single', 'event_details'), |
|
299 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
300 | - ); |
|
301 | - } else { |
|
302 | - $content = EED_Event_Single::use_filterable_display_order(); |
|
303 | - } |
|
304 | - } |
|
305 | - return $content; |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * use_filterable_display_order |
|
311 | - * |
|
312 | - * @return string |
|
313 | - */ |
|
314 | - protected static function use_filterable_display_order() |
|
315 | - { |
|
316 | - // since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
317 | - // it uses the_content() for displaying the $post->post_content |
|
318 | - // so in order to load a template that uses the_content() |
|
319 | - // from within a callback being used to filter the_content(), |
|
320 | - // we need to first remove this callback from being applied to the_content() |
|
321 | - // (otherwise it will recurse and blow up the interweb) |
|
322 | - remove_filter( |
|
323 | - 'the_content', |
|
324 | - array('EED_Event_Single', 'event_details'), |
|
325 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
326 | - ); |
|
327 | - // now add additional content |
|
328 | - add_filter( |
|
329 | - 'the_content', |
|
330 | - array('EED_Event_Single', 'event_datetimes'), |
|
331 | - EED_Event_Single::EVENT_DATETIMES_PRIORITY, |
|
332 | - 1 |
|
333 | - ); |
|
334 | - add_filter( |
|
335 | - 'the_content', |
|
336 | - array('EED_Event_Single', 'event_tickets'), |
|
337 | - EED_Event_Single::EVENT_TICKETS_PRIORITY, |
|
338 | - 1 |
|
339 | - ); |
|
340 | - add_filter( |
|
341 | - 'the_content', |
|
342 | - array('EED_Event_Single', 'event_venues'), |
|
343 | - EED_Event_Single::EVENT_VENUES_PRIORITY, |
|
344 | - 1 |
|
345 | - ); |
|
346 | - do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
347 | - // now load our template |
|
348 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
349 | - // now add our filter back in, plus some others |
|
350 | - add_filter( |
|
351 | - 'the_content', |
|
352 | - array('EED_Event_Single', 'event_details'), |
|
353 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
354 | - ); |
|
355 | - remove_filter( |
|
356 | - 'the_content', |
|
357 | - array('EED_Event_Single', 'event_datetimes'), |
|
358 | - EED_Event_Single::EVENT_DATETIMES_PRIORITY |
|
359 | - ); |
|
360 | - remove_filter( |
|
361 | - 'the_content', |
|
362 | - array('EED_Event_Single', 'event_tickets'), |
|
363 | - EED_Event_Single::EVENT_TICKETS_PRIORITY |
|
364 | - ); |
|
365 | - remove_filter( |
|
366 | - 'the_content', |
|
367 | - array('EED_Event_Single', 'event_venues'), |
|
368 | - EED_Event_Single::EVENT_VENUES_PRIORITY |
|
369 | - ); |
|
370 | - do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
371 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
372 | - return $content; |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * event_datetimes - adds datetimes ABOVE content |
|
378 | - * |
|
379 | - * @param string $content |
|
380 | - * @return string |
|
381 | - */ |
|
382 | - public static function event_datetimes($content) |
|
383 | - { |
|
384 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
385 | - } |
|
386 | - |
|
387 | - |
|
388 | - /** |
|
389 | - * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
390 | - * |
|
391 | - * @param string $content |
|
392 | - * @return string |
|
393 | - */ |
|
394 | - public static function event_tickets($content) |
|
395 | - { |
|
396 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
397 | - } |
|
398 | - |
|
399 | - |
|
400 | - /** |
|
401 | - * event_venues |
|
402 | - * |
|
403 | - * @param string $content |
|
404 | - * @return string |
|
405 | - */ |
|
406 | - public static function event_venue($content) |
|
407 | - { |
|
408 | - return EED_Event_Single::event_venues($content); |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - /** |
|
413 | - * event_venues - adds venues BELOW content |
|
414 | - * |
|
415 | - * @param string $content |
|
416 | - * @return string |
|
417 | - */ |
|
418 | - public static function event_venues($content) |
|
419 | - { |
|
420 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
421 | - } |
|
422 | - |
|
423 | - |
|
424 | - /** |
|
425 | - * loop_end |
|
426 | - * |
|
427 | - * @param array $wp_query_array an array containing the WP_Query object |
|
428 | - * @return void |
|
429 | - */ |
|
430 | - public static function loop_end($wp_query_array) |
|
431 | - { |
|
432 | - global $post; |
|
433 | - do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
434 | - } |
|
435 | - |
|
436 | - |
|
437 | - /** |
|
438 | - * wp_enqueue_scripts |
|
439 | - * |
|
440 | - * @return void |
|
441 | - */ |
|
442 | - public function wp_enqueue_scripts() |
|
443 | - { |
|
444 | - // get some style |
|
445 | - if (apply_filters('FHEE_enable_default_espresso_css', true) |
|
446 | - && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true) |
|
447 | - ) { |
|
448 | - // first check uploads folder |
|
449 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
450 | - wp_register_style( |
|
451 | - $this->theme, |
|
452 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
453 | - array('dashicons', 'espresso_default') |
|
454 | - ); |
|
455 | - } else { |
|
456 | - wp_register_style( |
|
457 | - $this->theme, |
|
458 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
459 | - array('dashicons', 'espresso_default') |
|
460 | - ); |
|
461 | - } |
|
462 | - wp_enqueue_script($this->theme); |
|
463 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
464 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
465 | - } |
|
466 | - } |
|
467 | - } |
|
468 | - |
|
469 | - |
|
470 | - /** |
|
471 | - * display_venue |
|
472 | - * |
|
473 | - * @return bool |
|
474 | - */ |
|
475 | - public static function display_venue() |
|
476 | - { |
|
477 | - /** @type EE_Event_Single_Config $config */ |
|
478 | - $config = EED_Event_Single::instance()->config(); |
|
479 | - $display_venue = $config->display_venue === null ? true : $config->display_venue; |
|
480 | - $venue_name = EEH_Venue_View::venue_name(); |
|
481 | - return $display_venue && ! empty($venue_name); |
|
482 | - } |
|
17 | + const EVENT_DETAILS_PRIORITY = 100; |
|
18 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
19 | + const EVENT_TICKETS_PRIORITY = 120; |
|
20 | + const EVENT_VENUES_PRIORITY = 130; |
|
21 | + |
|
22 | + /** |
|
23 | + * @type bool $using_get_the_excerpt |
|
24 | + */ |
|
25 | + protected static $using_get_the_excerpt = false; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @type EE_Template_Part_Manager $template_parts |
|
30 | + */ |
|
31 | + protected $template_parts; |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @return EED_Module|EED_Event_Single |
|
36 | + */ |
|
37 | + public static function instance() |
|
38 | + { |
|
39 | + return parent::get_instance(__CLASS__); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
45 | + * |
|
46 | + * @return void |
|
47 | + * @throws InvalidArgumentException |
|
48 | + * @throws InvalidDataTypeException |
|
49 | + * @throws InvalidInterfaceException |
|
50 | + */ |
|
51 | + public static function set_hooks() |
|
52 | + { |
|
53 | + add_filter('FHEE_run_EE_wp', '__return_true'); |
|
54 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
55 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
56 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
57 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
58 | + ); |
|
59 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
60 | + EE_Config::register_route( |
|
61 | + $custom_post_types['espresso_events']['singular_slug'], |
|
62 | + 'Event_Single', |
|
63 | + 'run' |
|
64 | + ); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
69 | + * |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public static function set_hooks_admin() |
|
73 | + { |
|
74 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * set_definitions |
|
80 | + * |
|
81 | + * @static |
|
82 | + * @return void |
|
83 | + */ |
|
84 | + public static function set_definitions() |
|
85 | + { |
|
86 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
87 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * set_config |
|
93 | + * |
|
94 | + * @void |
|
95 | + */ |
|
96 | + protected function set_config() |
|
97 | + { |
|
98 | + $this->set_config_section('template_settings'); |
|
99 | + $this->set_config_class('EE_Event_Single_Config'); |
|
100 | + $this->set_config_name('EED_Event_Single'); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * initialize_template_parts |
|
106 | + * |
|
107 | + * @param EE_Config_Base|EE_Event_Single_Config $config |
|
108 | + * @return EE_Template_Part_Manager |
|
109 | + */ |
|
110 | + public function initialize_template_parts(EE_Event_Single_Config $config = null) |
|
111 | + { |
|
112 | + /** @type EE_Event_Single_Config $config */ |
|
113 | + $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
114 | + EEH_Autoloader::instance()->register_template_part_autoloaders(); |
|
115 | + $template_parts = new EE_Template_Part_Manager(); |
|
116 | + $template_parts->add_template_part( |
|
117 | + 'tickets', |
|
118 | + __('Ticket Selector', 'event_espresso'), |
|
119 | + 'content-espresso_events-tickets.php', |
|
120 | + $config->display_order_tickets |
|
121 | + ); |
|
122 | + $template_parts->add_template_part( |
|
123 | + 'datetimes', |
|
124 | + __('Dates and Times', 'event_espresso'), |
|
125 | + 'content-espresso_events-datetimes.php', |
|
126 | + $config->display_order_datetimes |
|
127 | + ); |
|
128 | + $template_parts->add_template_part( |
|
129 | + 'event', |
|
130 | + __('Event Description', 'event_espresso'), |
|
131 | + 'content-espresso_events-details.php', |
|
132 | + $config->display_order_event |
|
133 | + ); |
|
134 | + $template_parts->add_template_part( |
|
135 | + 'venue', |
|
136 | + __('Venue Information', 'event_espresso'), |
|
137 | + 'content-espresso_events-venues.php', |
|
138 | + $config->display_order_venue |
|
139 | + ); |
|
140 | + do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
141 | + return $template_parts; |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * run - initial module setup |
|
147 | + * |
|
148 | + * @param WP $WP |
|
149 | + * @return void |
|
150 | + */ |
|
151 | + public function run($WP) |
|
152 | + { |
|
153 | + // ensure valid EE_Events_Single_Config() object exists |
|
154 | + $this->set_config(); |
|
155 | + // check what template is loaded |
|
156 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
157 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
158 | + // load css |
|
159 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * template_include |
|
165 | + * |
|
166 | + * @param string $template |
|
167 | + * @return string |
|
168 | + */ |
|
169 | + public function template_include($template) |
|
170 | + { |
|
171 | + global $post; |
|
172 | + /** @type EE_Event_Single_Config $config */ |
|
173 | + $config = $this->config(); |
|
174 | + if ($config->display_status_banner_single) { |
|
175 | + add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
176 | + } |
|
177 | + // not a custom template? |
|
178 | + if (! post_password_required($post) |
|
179 | + && ( |
|
180 | + apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
181 | + || EE_Registry::instance() |
|
182 | + ->load_core('Front_Controller') |
|
183 | + ->get_selected_template() !== 'single-espresso_events.php' |
|
184 | + ) |
|
185 | + |
|
186 | + ) { |
|
187 | + EEH_Template::load_espresso_theme_functions(); |
|
188 | + // then add extra event data via hooks |
|
189 | + add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
190 | + add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
191 | + add_filter( |
|
192 | + 'the_content', |
|
193 | + array('EED_Event_Single', 'event_details'), |
|
194 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
195 | + ); |
|
196 | + add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
197 | + // don't display entry meta because the existing theme will take car of that |
|
198 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
199 | + } |
|
200 | + return $template; |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * loop_start |
|
206 | + * |
|
207 | + * @param array $wp_query_array an array containing the WP_Query object |
|
208 | + * @return void |
|
209 | + */ |
|
210 | + public static function loop_start($wp_query_array) |
|
211 | + { |
|
212 | + global $post; |
|
213 | + do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * the_title |
|
219 | + * |
|
220 | + * @param string $title |
|
221 | + * @param int $id |
|
222 | + * @return string |
|
223 | + */ |
|
224 | + public static function the_title($title = '', $id = 0) |
|
225 | + { |
|
226 | + global $post; |
|
227 | + return in_the_loop() && $post->ID === (int) $id |
|
228 | + ? espresso_event_status_banner($post->ID) . $title |
|
229 | + : $title; |
|
230 | + } |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * get_the_excerpt |
|
235 | + * kinda hacky, but if a theme is using get_the_excerpt(), |
|
236 | + * then we need to remove our filters on the_content() |
|
237 | + * |
|
238 | + * @param string $excerpt |
|
239 | + * @return string |
|
240 | + */ |
|
241 | + public static function get_the_excerpt($excerpt = '') |
|
242 | + { |
|
243 | + EED_Event_Single::$using_get_the_excerpt = true; |
|
244 | + add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
245 | + return $excerpt; |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + /** |
|
250 | + * end_get_the_excerpt |
|
251 | + * |
|
252 | + * @param string $text |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public static function end_get_the_excerpt($text = '') |
|
256 | + { |
|
257 | + EED_Event_Single::$using_get_the_excerpt = false; |
|
258 | + return $text; |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * event_details |
|
264 | + * |
|
265 | + * @param string $content |
|
266 | + * @return string |
|
267 | + */ |
|
268 | + public static function event_details($content) |
|
269 | + { |
|
270 | + global $post; |
|
271 | + static $current_post_ID = 0; |
|
272 | + if ($current_post_ID !== $post->ID |
|
273 | + && $post->post_type === 'espresso_events' |
|
274 | + && ! EED_Event_Single::$using_get_the_excerpt |
|
275 | + && ! post_password_required() |
|
276 | + ) { |
|
277 | + // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
278 | + // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
279 | + // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
280 | + // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
281 | + // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
282 | + // so the following allows this filter to be applied multiple times, but only once for real |
|
283 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
284 | + if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
285 | + // we need to first remove this callback from being applied to the_content() |
|
286 | + // (otherwise it will recurse and blow up the interweb) |
|
287 | + remove_filter( |
|
288 | + 'the_content', |
|
289 | + array('EED_Event_Single', 'event_details'), |
|
290 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
291 | + ); |
|
292 | + EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts( |
|
293 | + ); |
|
294 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
295 | + $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
296 | + add_filter( |
|
297 | + 'the_content', |
|
298 | + array('EED_Event_Single', 'event_details'), |
|
299 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
300 | + ); |
|
301 | + } else { |
|
302 | + $content = EED_Event_Single::use_filterable_display_order(); |
|
303 | + } |
|
304 | + } |
|
305 | + return $content; |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * use_filterable_display_order |
|
311 | + * |
|
312 | + * @return string |
|
313 | + */ |
|
314 | + protected static function use_filterable_display_order() |
|
315 | + { |
|
316 | + // since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
317 | + // it uses the_content() for displaying the $post->post_content |
|
318 | + // so in order to load a template that uses the_content() |
|
319 | + // from within a callback being used to filter the_content(), |
|
320 | + // we need to first remove this callback from being applied to the_content() |
|
321 | + // (otherwise it will recurse and blow up the interweb) |
|
322 | + remove_filter( |
|
323 | + 'the_content', |
|
324 | + array('EED_Event_Single', 'event_details'), |
|
325 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
326 | + ); |
|
327 | + // now add additional content |
|
328 | + add_filter( |
|
329 | + 'the_content', |
|
330 | + array('EED_Event_Single', 'event_datetimes'), |
|
331 | + EED_Event_Single::EVENT_DATETIMES_PRIORITY, |
|
332 | + 1 |
|
333 | + ); |
|
334 | + add_filter( |
|
335 | + 'the_content', |
|
336 | + array('EED_Event_Single', 'event_tickets'), |
|
337 | + EED_Event_Single::EVENT_TICKETS_PRIORITY, |
|
338 | + 1 |
|
339 | + ); |
|
340 | + add_filter( |
|
341 | + 'the_content', |
|
342 | + array('EED_Event_Single', 'event_venues'), |
|
343 | + EED_Event_Single::EVENT_VENUES_PRIORITY, |
|
344 | + 1 |
|
345 | + ); |
|
346 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
347 | + // now load our template |
|
348 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
349 | + // now add our filter back in, plus some others |
|
350 | + add_filter( |
|
351 | + 'the_content', |
|
352 | + array('EED_Event_Single', 'event_details'), |
|
353 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
354 | + ); |
|
355 | + remove_filter( |
|
356 | + 'the_content', |
|
357 | + array('EED_Event_Single', 'event_datetimes'), |
|
358 | + EED_Event_Single::EVENT_DATETIMES_PRIORITY |
|
359 | + ); |
|
360 | + remove_filter( |
|
361 | + 'the_content', |
|
362 | + array('EED_Event_Single', 'event_tickets'), |
|
363 | + EED_Event_Single::EVENT_TICKETS_PRIORITY |
|
364 | + ); |
|
365 | + remove_filter( |
|
366 | + 'the_content', |
|
367 | + array('EED_Event_Single', 'event_venues'), |
|
368 | + EED_Event_Single::EVENT_VENUES_PRIORITY |
|
369 | + ); |
|
370 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
371 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
372 | + return $content; |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * event_datetimes - adds datetimes ABOVE content |
|
378 | + * |
|
379 | + * @param string $content |
|
380 | + * @return string |
|
381 | + */ |
|
382 | + public static function event_datetimes($content) |
|
383 | + { |
|
384 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
385 | + } |
|
386 | + |
|
387 | + |
|
388 | + /** |
|
389 | + * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
390 | + * |
|
391 | + * @param string $content |
|
392 | + * @return string |
|
393 | + */ |
|
394 | + public static function event_tickets($content) |
|
395 | + { |
|
396 | + return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
397 | + } |
|
398 | + |
|
399 | + |
|
400 | + /** |
|
401 | + * event_venues |
|
402 | + * |
|
403 | + * @param string $content |
|
404 | + * @return string |
|
405 | + */ |
|
406 | + public static function event_venue($content) |
|
407 | + { |
|
408 | + return EED_Event_Single::event_venues($content); |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + /** |
|
413 | + * event_venues - adds venues BELOW content |
|
414 | + * |
|
415 | + * @param string $content |
|
416 | + * @return string |
|
417 | + */ |
|
418 | + public static function event_venues($content) |
|
419 | + { |
|
420 | + return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
421 | + } |
|
422 | + |
|
423 | + |
|
424 | + /** |
|
425 | + * loop_end |
|
426 | + * |
|
427 | + * @param array $wp_query_array an array containing the WP_Query object |
|
428 | + * @return void |
|
429 | + */ |
|
430 | + public static function loop_end($wp_query_array) |
|
431 | + { |
|
432 | + global $post; |
|
433 | + do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
434 | + } |
|
435 | + |
|
436 | + |
|
437 | + /** |
|
438 | + * wp_enqueue_scripts |
|
439 | + * |
|
440 | + * @return void |
|
441 | + */ |
|
442 | + public function wp_enqueue_scripts() |
|
443 | + { |
|
444 | + // get some style |
|
445 | + if (apply_filters('FHEE_enable_default_espresso_css', true) |
|
446 | + && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true) |
|
447 | + ) { |
|
448 | + // first check uploads folder |
|
449 | + if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
450 | + wp_register_style( |
|
451 | + $this->theme, |
|
452 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
453 | + array('dashicons', 'espresso_default') |
|
454 | + ); |
|
455 | + } else { |
|
456 | + wp_register_style( |
|
457 | + $this->theme, |
|
458 | + EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
459 | + array('dashicons', 'espresso_default') |
|
460 | + ); |
|
461 | + } |
|
462 | + wp_enqueue_script($this->theme); |
|
463 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
464 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
465 | + } |
|
466 | + } |
|
467 | + } |
|
468 | + |
|
469 | + |
|
470 | + /** |
|
471 | + * display_venue |
|
472 | + * |
|
473 | + * @return bool |
|
474 | + */ |
|
475 | + public static function display_venue() |
|
476 | + { |
|
477 | + /** @type EE_Event_Single_Config $config */ |
|
478 | + $config = EED_Event_Single::instance()->config(); |
|
479 | + $display_venue = $config->display_venue === null ? true : $config->display_venue; |
|
480 | + $venue_name = EEH_Venue_View::venue_name(); |
|
481 | + return $display_venue && ! empty($venue_name); |
|
482 | + } |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -491,5 +491,5 @@ discard block |
||
491 | 491 | */ |
492 | 492 | function espresso_display_venue_in_event_details() |
493 | 493 | { |
494 | - return EED_Event_Single::display_venue(); |
|
494 | + return EED_Event_Single::display_venue(); |
|
495 | 495 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public static function set_definitions() |
85 | 85 | { |
86 | - define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
87 | - define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
86 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
87 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates/'); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
176 | 176 | } |
177 | 177 | // not a custom template? |
178 | - if (! post_password_required($post) |
|
178 | + if ( ! post_password_required($post) |
|
179 | 179 | && ( |
180 | 180 | apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
181 | 181 | || EE_Registry::instance() |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | { |
226 | 226 | global $post; |
227 | 227 | return in_the_loop() && $post->ID === (int) $id |
228 | - ? espresso_event_status_banner($post->ID) . $title |
|
228 | + ? espresso_event_status_banner($post->ID).$title |
|
229 | 229 | : $title; |
230 | 230 | } |
231 | 231 | |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | */ |
382 | 382 | public static function event_datetimes($content) |
383 | 383 | { |
384 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
384 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | */ |
394 | 394 | public static function event_tickets($content) |
395 | 395 | { |
396 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
396 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public static function event_venues($content) |
419 | 419 | { |
420 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
420 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | |
@@ -446,16 +446,16 @@ discard block |
||
446 | 446 | && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true) |
447 | 447 | ) { |
448 | 448 | // first check uploads folder |
449 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
449 | + if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) { |
|
450 | 450 | wp_register_style( |
451 | 451 | $this->theme, |
452 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
452 | + get_stylesheet_directory_uri().$this->theme.'/style.css', |
|
453 | 453 | array('dashicons', 'espresso_default') |
454 | 454 | ); |
455 | 455 | } else { |
456 | 456 | wp_register_style( |
457 | 457 | $this->theme, |
458 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
458 | + EE_TEMPLATES_URL.$this->theme.'/style.css', |
|
459 | 459 | array('dashicons', 'espresso_default') |
460 | 460 | ); |
461 | 461 | } |
@@ -12,217 +12,217 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * @return EED_Feeds |
|
17 | - */ |
|
18 | - public static function instance() |
|
19 | - { |
|
20 | - return parent::get_instance(__CLASS__); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
26 | - * |
|
27 | - * @access public |
|
28 | - * @return void |
|
29 | - */ |
|
30 | - public static function set_hooks() |
|
31 | - { |
|
32 | - add_action('parse_request', array('EED_Feeds', 'parse_request'), 10); |
|
33 | - add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1); |
|
34 | - add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2); |
|
35 | - add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2); |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
40 | - * |
|
41 | - * @access public |
|
42 | - * @return void |
|
43 | - */ |
|
44 | - public static function set_hooks_admin() |
|
45 | - { |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * run - initial module setup |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function run($WP) |
|
56 | - { |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * default_feed |
|
62 | - * |
|
63 | - * @access public |
|
64 | - * @param type rss2, atom, rss, rdf, rssjs |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public static function default_feed($type = 'rss2') |
|
68 | - { |
|
69 | - // rss2, atom, rss, rdf, rssjs |
|
70 | - $type = 'rss2'; |
|
71 | - return $type; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * parse_request |
|
77 | - * |
|
78 | - * @access public |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - public static function parse_request() |
|
82 | - { |
|
83 | - if (EE_Registry::instance()->REQ->is_set('post_type')) { |
|
84 | - // define path to templates |
|
85 | - define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
86 | - // what kinda post_type are we dealing with ? |
|
87 | - switch (EE_Registry::instance()->REQ->get('post_type')) { |
|
88 | - case 'espresso_events': |
|
89 | - // for rss2, atom, rss, rdf |
|
90 | - add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
91 | - add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
92 | - // for json ( also uses the above filter ) |
|
93 | - add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1); |
|
94 | - break; |
|
95 | - case 'espresso_venues': |
|
96 | - // for rss2, atom, rss, rdf |
|
97 | - add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
98 | - add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
99 | - // for json ( also uses the above filter ) |
|
100 | - add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1); |
|
101 | - break; |
|
102 | - } |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
109 | - * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
110 | - * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
111 | - * espresso_attendees post_type |
|
112 | - * |
|
113 | - * @access public |
|
114 | - * @param string $SQL the JOIN clause for the comment feed query |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - public static function comment_feed_join($SQL) |
|
118 | - { |
|
119 | - global $wpdb; |
|
120 | - // check for wp_posts table in JOIN clause |
|
121 | - if (strpos($SQL, $wpdb->posts) !== false) { |
|
122 | - add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true'); |
|
123 | - } |
|
124 | - return $SQL; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
130 | - * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
131 | - * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
132 | - * espresso_attendees post_type |
|
133 | - * |
|
134 | - * @access public |
|
135 | - * @param string $SQL the WHERE clause for the comment feed query |
|
136 | - * @return void |
|
137 | - */ |
|
138 | - public static function comment_feed_where($SQL) |
|
139 | - { |
|
140 | - global $wp_query, $wpdb; |
|
141 | - if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) { |
|
142 | - $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'"; |
|
143 | - } |
|
144 | - return $SQL; |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * the_event_feed |
|
150 | - * |
|
151 | - * @access public |
|
152 | - * @param string $content |
|
153 | - * @return void |
|
154 | - */ |
|
155 | - public static function the_event_feed($content) |
|
156 | - { |
|
157 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) { |
|
158 | - global $post; |
|
159 | - $template_args = array( |
|
160 | - 'EVT_ID' => $post->ID, |
|
161 | - 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
162 | - ); |
|
163 | - $content = EEH_Template::display_template( |
|
164 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php', |
|
165 | - $template_args, |
|
166 | - true |
|
167 | - ); |
|
168 | - } |
|
169 | - return $content; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * the_event_rssjs_feed |
|
175 | - * |
|
176 | - * @access public |
|
177 | - * @param object $item |
|
178 | - * @return void |
|
179 | - */ |
|
180 | - public static function the_event_rssjs_feed($item) |
|
181 | - { |
|
182 | - if (is_feed() && isset($item->description)) { |
|
183 | - $item->description = EED_Feeds::the_event_feed($item->description); |
|
184 | - } |
|
185 | - return $item; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * the_venue_feed |
|
191 | - * |
|
192 | - * @access public |
|
193 | - * @param string $content |
|
194 | - * @return void |
|
195 | - */ |
|
196 | - public static function the_venue_feed($content) |
|
197 | - { |
|
198 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) { |
|
199 | - global $post; |
|
200 | - $template_args = array( |
|
201 | - 'VNU_ID' => $post->ID, |
|
202 | - 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
203 | - ); |
|
204 | - $content = EEH_Template::display_template( |
|
205 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php', |
|
206 | - $template_args, |
|
207 | - true |
|
208 | - ); |
|
209 | - } |
|
210 | - return $content; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * the_venue_rssjs_feed |
|
216 | - * |
|
217 | - * @access public |
|
218 | - * @param object $item |
|
219 | - * @return void |
|
220 | - */ |
|
221 | - public static function the_venue_rssjs_feed($item) |
|
222 | - { |
|
223 | - if (is_feed() && isset($item->description)) { |
|
224 | - $item->description = EED_Feeds::the_venue_feed($item->description); |
|
225 | - } |
|
226 | - return $item; |
|
227 | - } |
|
15 | + /** |
|
16 | + * @return EED_Feeds |
|
17 | + */ |
|
18 | + public static function instance() |
|
19 | + { |
|
20 | + return parent::get_instance(__CLASS__); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
26 | + * |
|
27 | + * @access public |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public static function set_hooks() |
|
31 | + { |
|
32 | + add_action('parse_request', array('EED_Feeds', 'parse_request'), 10); |
|
33 | + add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1); |
|
34 | + add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2); |
|
35 | + add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2); |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
40 | + * |
|
41 | + * @access public |
|
42 | + * @return void |
|
43 | + */ |
|
44 | + public static function set_hooks_admin() |
|
45 | + { |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * run - initial module setup |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function run($WP) |
|
56 | + { |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * default_feed |
|
62 | + * |
|
63 | + * @access public |
|
64 | + * @param type rss2, atom, rss, rdf, rssjs |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public static function default_feed($type = 'rss2') |
|
68 | + { |
|
69 | + // rss2, atom, rss, rdf, rssjs |
|
70 | + $type = 'rss2'; |
|
71 | + return $type; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * parse_request |
|
77 | + * |
|
78 | + * @access public |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + public static function parse_request() |
|
82 | + { |
|
83 | + if (EE_Registry::instance()->REQ->is_set('post_type')) { |
|
84 | + // define path to templates |
|
85 | + define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
86 | + // what kinda post_type are we dealing with ? |
|
87 | + switch (EE_Registry::instance()->REQ->get('post_type')) { |
|
88 | + case 'espresso_events': |
|
89 | + // for rss2, atom, rss, rdf |
|
90 | + add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
91 | + add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
92 | + // for json ( also uses the above filter ) |
|
93 | + add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1); |
|
94 | + break; |
|
95 | + case 'espresso_venues': |
|
96 | + // for rss2, atom, rss, rdf |
|
97 | + add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
98 | + add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
99 | + // for json ( also uses the above filter ) |
|
100 | + add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1); |
|
101 | + break; |
|
102 | + } |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * comment_feed_join - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
109 | + * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
110 | + * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
111 | + * espresso_attendees post_type |
|
112 | + * |
|
113 | + * @access public |
|
114 | + * @param string $SQL the JOIN clause for the comment feed query |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + public static function comment_feed_join($SQL) |
|
118 | + { |
|
119 | + global $wpdb; |
|
120 | + // check for wp_posts table in JOIN clause |
|
121 | + if (strpos($SQL, $wpdb->posts) !== false) { |
|
122 | + add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true'); |
|
123 | + } |
|
124 | + return $SQL; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * comment_feed_where - EVEN THOUGH... our espresso_attendees custom post type is set to NOT PUBLIC |
|
130 | + * WordPress thought it would be a good idea to display the comments for them in the RSS feeds... we think NOT |
|
131 | + * so this little snippet of SQL taps into the comment feed query and removes comments for the |
|
132 | + * espresso_attendees post_type |
|
133 | + * |
|
134 | + * @access public |
|
135 | + * @param string $SQL the WHERE clause for the comment feed query |
|
136 | + * @return void |
|
137 | + */ |
|
138 | + public static function comment_feed_where($SQL) |
|
139 | + { |
|
140 | + global $wp_query, $wpdb; |
|
141 | + if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', false)) { |
|
142 | + $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'"; |
|
143 | + } |
|
144 | + return $SQL; |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * the_event_feed |
|
150 | + * |
|
151 | + * @access public |
|
152 | + * @param string $content |
|
153 | + * @return void |
|
154 | + */ |
|
155 | + public static function the_event_feed($content) |
|
156 | + { |
|
157 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) { |
|
158 | + global $post; |
|
159 | + $template_args = array( |
|
160 | + 'EVT_ID' => $post->ID, |
|
161 | + 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
162 | + ); |
|
163 | + $content = EEH_Template::display_template( |
|
164 | + RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php', |
|
165 | + $template_args, |
|
166 | + true |
|
167 | + ); |
|
168 | + } |
|
169 | + return $content; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * the_event_rssjs_feed |
|
175 | + * |
|
176 | + * @access public |
|
177 | + * @param object $item |
|
178 | + * @return void |
|
179 | + */ |
|
180 | + public static function the_event_rssjs_feed($item) |
|
181 | + { |
|
182 | + if (is_feed() && isset($item->description)) { |
|
183 | + $item->description = EED_Feeds::the_event_feed($item->description); |
|
184 | + } |
|
185 | + return $item; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * the_venue_feed |
|
191 | + * |
|
192 | + * @access public |
|
193 | + * @param string $content |
|
194 | + * @return void |
|
195 | + */ |
|
196 | + public static function the_venue_feed($content) |
|
197 | + { |
|
198 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) { |
|
199 | + global $post; |
|
200 | + $template_args = array( |
|
201 | + 'VNU_ID' => $post->ID, |
|
202 | + 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
|
203 | + ); |
|
204 | + $content = EEH_Template::display_template( |
|
205 | + RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php', |
|
206 | + $template_args, |
|
207 | + true |
|
208 | + ); |
|
209 | + } |
|
210 | + return $content; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * the_venue_rssjs_feed |
|
216 | + * |
|
217 | + * @access public |
|
218 | + * @param object $item |
|
219 | + * @return void |
|
220 | + */ |
|
221 | + public static function the_venue_rssjs_feed($item) |
|
222 | + { |
|
223 | + if (is_feed() && isset($item->description)) { |
|
224 | + $item->description = EED_Feeds::the_venue_feed($item->description); |
|
225 | + } |
|
226 | + return $item; |
|
227 | + } |
|
228 | 228 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | if (EE_Registry::instance()->REQ->is_set('post_type')) { |
84 | 84 | // define path to templates |
85 | - define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
85 | + define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/'); |
|
86 | 86 | // what kinda post_type are we dealing with ? |
87 | 87 | switch (EE_Registry::instance()->REQ->get('post_type')) { |
88 | 88 | case 'espresso_events': |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public static function the_event_feed($content) |
156 | 156 | { |
157 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php')) { |
|
157 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php')) { |
|
158 | 158 | global $post; |
159 | 159 | $template_args = array( |
160 | 160 | 'EVT_ID' => $post->ID, |
161 | 161 | 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
162 | 162 | ); |
163 | 163 | $content = EEH_Template::display_template( |
164 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php', |
|
164 | + RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php', |
|
165 | 165 | $template_args, |
166 | 166 | true |
167 | 167 | ); |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public static function the_venue_feed($content) |
197 | 197 | { |
198 | - if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php')) { |
|
198 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php')) { |
|
199 | 199 | global $post; |
200 | 200 | $template_args = array( |
201 | 201 | 'VNU_ID' => $post->ID, |
202 | 202 | 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content, |
203 | 203 | ); |
204 | 204 | $content = EEH_Template::display_template( |
205 | - RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php', |
|
205 | + RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php', |
|
206 | 206 | $template_args, |
207 | 207 | true |
208 | 208 | ); |
@@ -29,176 +29,176 @@ |
||
29 | 29 | class EED_Venues_Archive extends EED_Module |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @return EED_Venues_Archive |
|
34 | - */ |
|
35 | - public static function instance() |
|
36 | - { |
|
37 | - return parent::get_instance(__CLASS__); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | - * |
|
44 | - * @return void |
|
45 | - * @throws InvalidArgumentException |
|
46 | - * @throws InvalidDataTypeException |
|
47 | - * @throws InvalidInterfaceException |
|
48 | - */ |
|
49 | - public static function set_hooks() |
|
50 | - { |
|
51 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | - ); |
|
55 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | - EE_Config::register_route( |
|
57 | - $custom_post_types['espresso_venues']['plural_slug'], |
|
58 | - 'Venues_Archive', |
|
59 | - 'run' |
|
60 | - ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public static function set_hooks_admin() |
|
70 | - { |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * run - initial module setup |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @param \WP $WP |
|
79 | - */ |
|
80 | - public function run($WP) |
|
81 | - { |
|
82 | - // check what template is loaded |
|
83 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * template_include |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @param string $template |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function template_include($template) |
|
96 | - { |
|
97 | - // not a custom template? |
|
98 | - if (EE_Registry::instance()->load_core('Front_Controller', array(), false, true) |
|
99 | - ->get_selected_template() != 'archive-espresso_venues.php' |
|
100 | - ) { |
|
101 | - EEH_Template::load_espresso_theme_functions(); |
|
102 | - // then add extra event data via hooks |
|
103 | - add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
104 | - // don't know if theme uses the_excerpt |
|
105 | - add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
106 | - // or the_content |
|
107 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
108 | - // don't display entry meta because the existing theme will take care of that |
|
109 | - add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
110 | - } |
|
111 | - return $template; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * the_title |
|
117 | - * |
|
118 | - * @access public |
|
119 | - * @param string $title |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function the_title($title = '') |
|
123 | - { |
|
124 | - return $title; |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * venue_details |
|
130 | - * |
|
131 | - * @access public |
|
132 | - * @param string $content |
|
133 | - * @return string |
|
134 | - */ |
|
135 | - public function venue_details($content) |
|
136 | - { |
|
137 | - global $post; |
|
138 | - if ($post->post_type == 'espresso_venues' |
|
139 | - && ! post_password_required() |
|
140 | - ) { |
|
141 | - // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
142 | - // it uses the_content() for displaying the $post->post_content |
|
143 | - // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
144 | - // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
145 | - remove_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
146 | - remove_filter('the_content', array($this, 'venue_details'), 100); |
|
147 | - // add filters we want |
|
148 | - add_filter('the_content', array($this, 'venue_location'), 110); |
|
149 | - add_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
150 | - // now load our template |
|
151 | - $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
152 | - // now add our filter back in, plus some others |
|
153 | - add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
154 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
155 | - // remove other filters we added so they won't get applied to the next post |
|
156 | - remove_filter('the_content', array($this, 'venue_location'), 110); |
|
157 | - remove_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
158 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
159 | - } |
|
160 | - return ! empty($template) ? $template : $content; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * venue_location |
|
166 | - * |
|
167 | - * @access public |
|
168 | - * @param string $content |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function venue_location($content) |
|
172 | - { |
|
173 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * wp_enqueue_scripts |
|
179 | - * |
|
180 | - * @access public |
|
181 | - * @return void |
|
182 | - */ |
|
183 | - public function wp_enqueue_scripts() |
|
184 | - { |
|
185 | - // get some style |
|
186 | - if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
|
187 | - // first check theme folder |
|
188 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
189 | - wp_register_style( |
|
190 | - $this->theme, |
|
191 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
192 | - array('dashicons', 'espresso_default') |
|
193 | - ); |
|
194 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
195 | - wp_register_style( |
|
196 | - $this->theme, |
|
197 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
198 | - array('dashicons', 'espresso_default') |
|
199 | - ); |
|
200 | - } |
|
201 | - wp_enqueue_style($this->theme); |
|
202 | - } |
|
203 | - } |
|
32 | + /** |
|
33 | + * @return EED_Venues_Archive |
|
34 | + */ |
|
35 | + public static function instance() |
|
36 | + { |
|
37 | + return parent::get_instance(__CLASS__); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | + * |
|
44 | + * @return void |
|
45 | + * @throws InvalidArgumentException |
|
46 | + * @throws InvalidDataTypeException |
|
47 | + * @throws InvalidInterfaceException |
|
48 | + */ |
|
49 | + public static function set_hooks() |
|
50 | + { |
|
51 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | + ); |
|
55 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | + EE_Config::register_route( |
|
57 | + $custom_post_types['espresso_venues']['plural_slug'], |
|
58 | + 'Venues_Archive', |
|
59 | + 'run' |
|
60 | + ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public static function set_hooks_admin() |
|
70 | + { |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * run - initial module setup |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @param \WP $WP |
|
79 | + */ |
|
80 | + public function run($WP) |
|
81 | + { |
|
82 | + // check what template is loaded |
|
83 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * template_include |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @param string $template |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function template_include($template) |
|
96 | + { |
|
97 | + // not a custom template? |
|
98 | + if (EE_Registry::instance()->load_core('Front_Controller', array(), false, true) |
|
99 | + ->get_selected_template() != 'archive-espresso_venues.php' |
|
100 | + ) { |
|
101 | + EEH_Template::load_espresso_theme_functions(); |
|
102 | + // then add extra event data via hooks |
|
103 | + add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
104 | + // don't know if theme uses the_excerpt |
|
105 | + add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
106 | + // or the_content |
|
107 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
108 | + // don't display entry meta because the existing theme will take care of that |
|
109 | + add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
110 | + } |
|
111 | + return $template; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * the_title |
|
117 | + * |
|
118 | + * @access public |
|
119 | + * @param string $title |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function the_title($title = '') |
|
123 | + { |
|
124 | + return $title; |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * venue_details |
|
130 | + * |
|
131 | + * @access public |
|
132 | + * @param string $content |
|
133 | + * @return string |
|
134 | + */ |
|
135 | + public function venue_details($content) |
|
136 | + { |
|
137 | + global $post; |
|
138 | + if ($post->post_type == 'espresso_venues' |
|
139 | + && ! post_password_required() |
|
140 | + ) { |
|
141 | + // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
142 | + // it uses the_content() for displaying the $post->post_content |
|
143 | + // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
144 | + // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
145 | + remove_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
146 | + remove_filter('the_content', array($this, 'venue_details'), 100); |
|
147 | + // add filters we want |
|
148 | + add_filter('the_content', array($this, 'venue_location'), 110); |
|
149 | + add_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
150 | + // now load our template |
|
151 | + $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
152 | + // now add our filter back in, plus some others |
|
153 | + add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
154 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
155 | + // remove other filters we added so they won't get applied to the next post |
|
156 | + remove_filter('the_content', array($this, 'venue_location'), 110); |
|
157 | + remove_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
158 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
159 | + } |
|
160 | + return ! empty($template) ? $template : $content; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * venue_location |
|
166 | + * |
|
167 | + * @access public |
|
168 | + * @param string $content |
|
169 | + * @return string |
|
170 | + */ |
|
171 | + public function venue_location($content) |
|
172 | + { |
|
173 | + return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * wp_enqueue_scripts |
|
179 | + * |
|
180 | + * @access public |
|
181 | + * @return void |
|
182 | + */ |
|
183 | + public function wp_enqueue_scripts() |
|
184 | + { |
|
185 | + // get some style |
|
186 | + if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
|
187 | + // first check theme folder |
|
188 | + if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
189 | + wp_register_style( |
|
190 | + $this->theme, |
|
191 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
192 | + array('dashicons', 'espresso_default') |
|
193 | + ); |
|
194 | + } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
195 | + wp_register_style( |
|
196 | + $this->theme, |
|
197 | + EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
198 | + array('dashicons', 'espresso_default') |
|
199 | + ); |
|
200 | + } |
|
201 | + wp_enqueue_style($this->theme); |
|
202 | + } |
|
203 | + } |
|
204 | 204 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function venue_location($content) |
172 | 172 | { |
173 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
173 | + return $content.EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | // get some style |
186 | 186 | if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
187 | 187 | // first check theme folder |
188 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
188 | + if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) { |
|
189 | 189 | wp_register_style( |
190 | 190 | $this->theme, |
191 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
191 | + get_stylesheet_directory_uri().$this->theme.'/style.css', |
|
192 | 192 | array('dashicons', 'espresso_default') |
193 | 193 | ); |
194 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
194 | + } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) { |
|
195 | 195 | wp_register_style( |
196 | 196 | $this->theme, |
197 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
197 | + EE_TEMPLATES_URL.$this->theme.'/style.css', |
|
198 | 198 | array('dashicons', 'espresso_default') |
199 | 199 | ); |
200 | 200 | } |
@@ -17,442 +17,442 @@ |
||
17 | 17 | class EED_Ticket_Selector extends EED_Module |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var DisplayTicketSelector $ticket_selector |
|
22 | - */ |
|
23 | - private static $ticket_selector; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var TicketSelectorIframeEmbedButton $iframe_embed_button |
|
27 | - */ |
|
28 | - private static $iframe_embed_button; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @return EED_Module|EED_Ticket_Selector |
|
33 | - */ |
|
34 | - public static function instance() |
|
35 | - { |
|
36 | - return parent::get_instance(__CLASS__); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - protected function set_config() |
|
44 | - { |
|
45 | - $this->set_config_section('template_settings'); |
|
46 | - $this->set_config_class('EE_Ticket_Selector_Config'); |
|
47 | - $this->set_config_name('EED_Ticket_Selector'); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
53 | - * |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public static function set_hooks() |
|
57 | - { |
|
58 | - // routing |
|
59 | - EE_Config::register_route( |
|
60 | - 'iframe', |
|
61 | - 'EED_Ticket_Selector', |
|
62 | - 'ticket_selector_iframe', |
|
63 | - 'ticket_selector' |
|
64 | - ); |
|
65 | - EE_Config::register_route( |
|
66 | - 'process_ticket_selections', |
|
67 | - 'EED_Ticket_Selector', |
|
68 | - 'process_ticket_selections' |
|
69 | - ); |
|
70 | - EE_Config::register_route( |
|
71 | - 'cancel_ticket_selections', |
|
72 | - 'EED_Ticket_Selector', |
|
73 | - 'cancel_ticket_selections' |
|
74 | - ); |
|
75 | - add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
76 | - add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
77 | - add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0); |
|
78 | - add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
79 | - EED_Ticket_Selector::loadIframeAssets(); |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
85 | - * |
|
86 | - * @return void |
|
87 | - */ |
|
88 | - public static function set_hooks_admin() |
|
89 | - { |
|
90 | - // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
91 | - // to load assets for "espresso_events" page on the "edit" route (action) |
|
92 | - add_action( |
|
93 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit', |
|
94 | - array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'), |
|
95 | - 10 |
|
96 | - ); |
|
97 | - /** |
|
98 | - * Make sure assets for the ticket selector are loaded on the espresso registrations route so admin side |
|
99 | - * registrations work. |
|
100 | - */ |
|
101 | - add_action( |
|
102 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration', |
|
103 | - array('EED_Ticket_Selector', 'set_definitions'), |
|
104 | - 10 |
|
105 | - ); |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * set_definitions |
|
111 | - * |
|
112 | - * @return void |
|
113 | - * @throws InvalidArgumentException |
|
114 | - * @throws InvalidDataTypeException |
|
115 | - * @throws InvalidInterfaceException |
|
116 | - */ |
|
117 | - public static function set_definitions() |
|
118 | - { |
|
119 | - // don't do this twice |
|
120 | - if (defined('TICKET_SELECTOR_ASSETS_URL')) { |
|
121 | - return; |
|
122 | - } |
|
123 | - define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
124 | - define( |
|
125 | - 'TICKET_SELECTOR_TEMPLATES_PATH', |
|
126 | - str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/' |
|
127 | - ); |
|
128 | - // if config is not set, initialize |
|
129 | - if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
130 | - ) { |
|
131 | - EED_Ticket_Selector::instance()->set_config(); |
|
132 | - EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance( |
|
133 | - )->config(); |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * @return DisplayTicketSelector |
|
140 | - */ |
|
141 | - public static function ticketSelector() |
|
142 | - { |
|
143 | - if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
144 | - EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe()); |
|
145 | - } |
|
146 | - return EED_Ticket_Selector::$ticket_selector; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * gets the ball rolling |
|
152 | - * |
|
153 | - * @param WP $WP |
|
154 | - * @return void |
|
155 | - */ |
|
156 | - public function run($WP) |
|
157 | - { |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @return TicketSelectorIframeEmbedButton |
|
163 | - */ |
|
164 | - public static function getIframeEmbedButton() |
|
165 | - { |
|
166 | - if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) { |
|
167 | - self::$iframe_embed_button = new TicketSelectorIframeEmbedButton(); |
|
168 | - } |
|
169 | - return self::$iframe_embed_button; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * ticket_selector_iframe_embed_button |
|
175 | - * |
|
176 | - * @return void |
|
177 | - * @throws EE_Error |
|
178 | - */ |
|
179 | - public static function ticket_selector_iframe_embed_button() |
|
180 | - { |
|
181 | - $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
182 | - $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * ticket_selector_iframe |
|
188 | - * |
|
189 | - * @return void |
|
190 | - * @throws DomainException |
|
191 | - * @throws EE_Error |
|
192 | - */ |
|
193 | - public function ticket_selector_iframe() |
|
194 | - { |
|
195 | - $ticket_selector_iframe = new TicketSelectorIframe(); |
|
196 | - $ticket_selector_iframe->display(); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * creates buttons for selecting number of attendees for an event |
|
202 | - * |
|
203 | - * @param WP_Post|int $event |
|
204 | - * @param bool $view_details |
|
205 | - * @return string |
|
206 | - * @throws EE_Error |
|
207 | - */ |
|
208 | - public static function display_ticket_selector($event = null, $view_details = false) |
|
209 | - { |
|
210 | - return EED_Ticket_Selector::ticketSelector()->display($event, $view_details); |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * @return array or FALSE |
|
216 | - * @throws \ReflectionException |
|
217 | - * @throws \EE_Error |
|
218 | - * @throws InvalidArgumentException |
|
219 | - * @throws InvalidInterfaceException |
|
220 | - * @throws InvalidDataTypeException |
|
221 | - */ |
|
222 | - public function process_ticket_selections() |
|
223 | - { |
|
224 | - /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */ |
|
225 | - $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector'); |
|
226 | - return $form->processTicketSelections(); |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * @return string |
|
232 | - * @throws InvalidArgumentException |
|
233 | - * @throws InvalidInterfaceException |
|
234 | - * @throws InvalidDataTypeException |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - public static function cancel_ticket_selections() |
|
238 | - { |
|
239 | - /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */ |
|
240 | - $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector'); |
|
241 | - return $form->cancelTicketSelections(); |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * @return void |
|
247 | - */ |
|
248 | - public static function translate_js_strings() |
|
249 | - { |
|
250 | - EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__( |
|
251 | - 'please select a datetime', |
|
252 | - 'event_espresso' |
|
253 | - ); |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * @return void |
|
259 | - */ |
|
260 | - public static function load_tckt_slctr_assets() |
|
261 | - { |
|
262 | - if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) { |
|
263 | - // add some style |
|
264 | - wp_register_style( |
|
265 | - 'ticket_selector', |
|
266 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css', |
|
267 | - array(), |
|
268 | - EVENT_ESPRESSO_VERSION |
|
269 | - ); |
|
270 | - wp_enqueue_style('ticket_selector'); |
|
271 | - // make it dance |
|
272 | - wp_register_script( |
|
273 | - 'ticket_selector', |
|
274 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', |
|
275 | - array('espresso_core'), |
|
276 | - EVENT_ESPRESSO_VERSION, |
|
277 | - true |
|
278 | - ); |
|
279 | - wp_enqueue_script('ticket_selector'); |
|
280 | - require_once EE_LIBRARIES |
|
281 | - . 'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'; |
|
282 | - \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
283 | - } |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * @return void |
|
289 | - */ |
|
290 | - public static function loadIframeAssets() |
|
291 | - { |
|
292 | - // for event lists |
|
293 | - add_filter( |
|
294 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
295 | - array('EED_Ticket_Selector', 'iframeCss') |
|
296 | - ); |
|
297 | - add_filter( |
|
298 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
299 | - array('EED_Ticket_Selector', 'iframeJs') |
|
300 | - ); |
|
301 | - // for ticket selectors |
|
302 | - add_filter( |
|
303 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
304 | - array('EED_Ticket_Selector', 'iframeCss') |
|
305 | - ); |
|
306 | - add_filter( |
|
307 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
308 | - array('EED_Ticket_Selector', 'iframeJs') |
|
309 | - ); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
315 | - * |
|
316 | - * @param array $iframe_css |
|
317 | - * @return array |
|
318 | - */ |
|
319 | - public static function iframeCss(array $iframe_css) |
|
320 | - { |
|
321 | - $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
322 | - return $iframe_css; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
328 | - * |
|
329 | - * @param array $iframe_js |
|
330 | - * @return array |
|
331 | - */ |
|
332 | - public static function iframeJs(array $iframe_js) |
|
333 | - { |
|
334 | - $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
335 | - return $iframe_js; |
|
336 | - } |
|
337 | - |
|
338 | - |
|
339 | - /****************************** DEPRECATED ******************************/ |
|
340 | - |
|
341 | - |
|
342 | - /** |
|
343 | - * @deprecated |
|
344 | - * @return string |
|
345 | - * @throws EE_Error |
|
346 | - */ |
|
347 | - public static function display_view_details_btn() |
|
348 | - { |
|
349 | - // todo add doing_it_wrong() notice during next major version |
|
350 | - return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * @deprecated |
|
356 | - * @return string |
|
357 | - * @throws EE_Error |
|
358 | - */ |
|
359 | - public static function display_ticket_selector_submit() |
|
360 | - { |
|
361 | - // todo add doing_it_wrong() notice during next major version |
|
362 | - return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - /** |
|
367 | - * @deprecated |
|
368 | - * @param string $permalink_string |
|
369 | - * @param int $id |
|
370 | - * @param string $new_title |
|
371 | - * @param string $new_slug |
|
372 | - * @return string |
|
373 | - * @throws InvalidArgumentException |
|
374 | - * @throws InvalidDataTypeException |
|
375 | - * @throws InvalidInterfaceException |
|
376 | - */ |
|
377 | - public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
378 | - { |
|
379 | - // todo add doing_it_wrong() notice during next major version |
|
380 | - if (EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
381 | - && EE_Registry::instance()->REQ->get('action') === 'edit' |
|
382 | - ) { |
|
383 | - $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
384 | - $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
385 | - } |
|
386 | - return ''; |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - /** |
|
391 | - * @deprecated |
|
392 | - * @param int $ID |
|
393 | - * @param string $external_url |
|
394 | - * @return string |
|
395 | - */ |
|
396 | - public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
397 | - { |
|
398 | - // todo add doing_it_wrong() notice during next major version |
|
399 | - return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * @deprecated |
|
405 | - * @return string |
|
406 | - */ |
|
407 | - public static function ticket_selector_form_close() |
|
408 | - { |
|
409 | - // todo add doing_it_wrong() notice during next major version |
|
410 | - return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * @deprecated |
|
416 | - * @return string |
|
417 | - */ |
|
418 | - public static function no_tkt_slctr_end_dv() |
|
419 | - { |
|
420 | - // todo add doing_it_wrong() notice during next major version |
|
421 | - return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - /** |
|
426 | - * @deprecated 4.9.13 |
|
427 | - * @return string |
|
428 | - */ |
|
429 | - public static function tkt_slctr_end_dv() |
|
430 | - { |
|
431 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
432 | - } |
|
433 | - |
|
434 | - |
|
435 | - /** |
|
436 | - * @deprecated |
|
437 | - * @return string |
|
438 | - */ |
|
439 | - public static function clear_tkt_slctr() |
|
440 | - { |
|
441 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
442 | - } |
|
443 | - |
|
444 | - |
|
445 | - /** |
|
446 | - * @deprecated |
|
447 | - */ |
|
448 | - public static function load_tckt_slctr_assets_admin() |
|
449 | - { |
|
450 | - // todo add doing_it_wrong() notice during next major version |
|
451 | - if (EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
452 | - && EE_Registry::instance()->REQ->get('action') === 'edit' |
|
453 | - ) { |
|
454 | - $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
455 | - $iframe_embed_button->embedButtonAssets(); |
|
456 | - } |
|
457 | - } |
|
20 | + /** |
|
21 | + * @var DisplayTicketSelector $ticket_selector |
|
22 | + */ |
|
23 | + private static $ticket_selector; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var TicketSelectorIframeEmbedButton $iframe_embed_button |
|
27 | + */ |
|
28 | + private static $iframe_embed_button; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @return EED_Module|EED_Ticket_Selector |
|
33 | + */ |
|
34 | + public static function instance() |
|
35 | + { |
|
36 | + return parent::get_instance(__CLASS__); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + protected function set_config() |
|
44 | + { |
|
45 | + $this->set_config_section('template_settings'); |
|
46 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
47 | + $this->set_config_name('EED_Ticket_Selector'); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
53 | + * |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public static function set_hooks() |
|
57 | + { |
|
58 | + // routing |
|
59 | + EE_Config::register_route( |
|
60 | + 'iframe', |
|
61 | + 'EED_Ticket_Selector', |
|
62 | + 'ticket_selector_iframe', |
|
63 | + 'ticket_selector' |
|
64 | + ); |
|
65 | + EE_Config::register_route( |
|
66 | + 'process_ticket_selections', |
|
67 | + 'EED_Ticket_Selector', |
|
68 | + 'process_ticket_selections' |
|
69 | + ); |
|
70 | + EE_Config::register_route( |
|
71 | + 'cancel_ticket_selections', |
|
72 | + 'EED_Ticket_Selector', |
|
73 | + 'cancel_ticket_selections' |
|
74 | + ); |
|
75 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
76 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
77 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'translate_js_strings'), 0); |
|
78 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
79 | + EED_Ticket_Selector::loadIframeAssets(); |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
85 | + * |
|
86 | + * @return void |
|
87 | + */ |
|
88 | + public static function set_hooks_admin() |
|
89 | + { |
|
90 | + // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
91 | + // to load assets for "espresso_events" page on the "edit" route (action) |
|
92 | + add_action( |
|
93 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit', |
|
94 | + array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'), |
|
95 | + 10 |
|
96 | + ); |
|
97 | + /** |
|
98 | + * Make sure assets for the ticket selector are loaded on the espresso registrations route so admin side |
|
99 | + * registrations work. |
|
100 | + */ |
|
101 | + add_action( |
|
102 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_registrations__new_registration', |
|
103 | + array('EED_Ticket_Selector', 'set_definitions'), |
|
104 | + 10 |
|
105 | + ); |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * set_definitions |
|
111 | + * |
|
112 | + * @return void |
|
113 | + * @throws InvalidArgumentException |
|
114 | + * @throws InvalidDataTypeException |
|
115 | + * @throws InvalidInterfaceException |
|
116 | + */ |
|
117 | + public static function set_definitions() |
|
118 | + { |
|
119 | + // don't do this twice |
|
120 | + if (defined('TICKET_SELECTOR_ASSETS_URL')) { |
|
121 | + return; |
|
122 | + } |
|
123 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
124 | + define( |
|
125 | + 'TICKET_SELECTOR_TEMPLATES_PATH', |
|
126 | + str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/' |
|
127 | + ); |
|
128 | + // if config is not set, initialize |
|
129 | + if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
130 | + ) { |
|
131 | + EED_Ticket_Selector::instance()->set_config(); |
|
132 | + EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance( |
|
133 | + )->config(); |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * @return DisplayTicketSelector |
|
140 | + */ |
|
141 | + public static function ticketSelector() |
|
142 | + { |
|
143 | + if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
144 | + EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe()); |
|
145 | + } |
|
146 | + return EED_Ticket_Selector::$ticket_selector; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * gets the ball rolling |
|
152 | + * |
|
153 | + * @param WP $WP |
|
154 | + * @return void |
|
155 | + */ |
|
156 | + public function run($WP) |
|
157 | + { |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @return TicketSelectorIframeEmbedButton |
|
163 | + */ |
|
164 | + public static function getIframeEmbedButton() |
|
165 | + { |
|
166 | + if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) { |
|
167 | + self::$iframe_embed_button = new TicketSelectorIframeEmbedButton(); |
|
168 | + } |
|
169 | + return self::$iframe_embed_button; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * ticket_selector_iframe_embed_button |
|
175 | + * |
|
176 | + * @return void |
|
177 | + * @throws EE_Error |
|
178 | + */ |
|
179 | + public static function ticket_selector_iframe_embed_button() |
|
180 | + { |
|
181 | + $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
182 | + $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * ticket_selector_iframe |
|
188 | + * |
|
189 | + * @return void |
|
190 | + * @throws DomainException |
|
191 | + * @throws EE_Error |
|
192 | + */ |
|
193 | + public function ticket_selector_iframe() |
|
194 | + { |
|
195 | + $ticket_selector_iframe = new TicketSelectorIframe(); |
|
196 | + $ticket_selector_iframe->display(); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * creates buttons for selecting number of attendees for an event |
|
202 | + * |
|
203 | + * @param WP_Post|int $event |
|
204 | + * @param bool $view_details |
|
205 | + * @return string |
|
206 | + * @throws EE_Error |
|
207 | + */ |
|
208 | + public static function display_ticket_selector($event = null, $view_details = false) |
|
209 | + { |
|
210 | + return EED_Ticket_Selector::ticketSelector()->display($event, $view_details); |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * @return array or FALSE |
|
216 | + * @throws \ReflectionException |
|
217 | + * @throws \EE_Error |
|
218 | + * @throws InvalidArgumentException |
|
219 | + * @throws InvalidInterfaceException |
|
220 | + * @throws InvalidDataTypeException |
|
221 | + */ |
|
222 | + public function process_ticket_selections() |
|
223 | + { |
|
224 | + /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */ |
|
225 | + $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector'); |
|
226 | + return $form->processTicketSelections(); |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * @return string |
|
232 | + * @throws InvalidArgumentException |
|
233 | + * @throws InvalidInterfaceException |
|
234 | + * @throws InvalidDataTypeException |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + public static function cancel_ticket_selections() |
|
238 | + { |
|
239 | + /** @var EventEspresso\modules\ticket_selector\ProcessTicketSelector $form */ |
|
240 | + $form = LoaderFactory::getLoader()->getShared('EventEspresso\modules\ticket_selector\ProcessTicketSelector'); |
|
241 | + return $form->cancelTicketSelections(); |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * @return void |
|
247 | + */ |
|
248 | + public static function translate_js_strings() |
|
249 | + { |
|
250 | + EE_Registry::$i18n_js_strings['please_select_date_filter_notice'] = esc_html__( |
|
251 | + 'please select a datetime', |
|
252 | + 'event_espresso' |
|
253 | + ); |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * @return void |
|
259 | + */ |
|
260 | + public static function load_tckt_slctr_assets() |
|
261 | + { |
|
262 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', false)) { |
|
263 | + // add some style |
|
264 | + wp_register_style( |
|
265 | + 'ticket_selector', |
|
266 | + TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css', |
|
267 | + array(), |
|
268 | + EVENT_ESPRESSO_VERSION |
|
269 | + ); |
|
270 | + wp_enqueue_style('ticket_selector'); |
|
271 | + // make it dance |
|
272 | + wp_register_script( |
|
273 | + 'ticket_selector', |
|
274 | + TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', |
|
275 | + array('espresso_core'), |
|
276 | + EVENT_ESPRESSO_VERSION, |
|
277 | + true |
|
278 | + ); |
|
279 | + wp_enqueue_script('ticket_selector'); |
|
280 | + require_once EE_LIBRARIES |
|
281 | + . 'form_sections/strategies/display/EE_Checkbox_Dropdown_Selector_Display_Strategy.strategy.php'; |
|
282 | + \EE_Checkbox_Dropdown_Selector_Display_Strategy::enqueue_styles_and_scripts(); |
|
283 | + } |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * @return void |
|
289 | + */ |
|
290 | + public static function loadIframeAssets() |
|
291 | + { |
|
292 | + // for event lists |
|
293 | + add_filter( |
|
294 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
295 | + array('EED_Ticket_Selector', 'iframeCss') |
|
296 | + ); |
|
297 | + add_filter( |
|
298 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
299 | + array('EED_Ticket_Selector', 'iframeJs') |
|
300 | + ); |
|
301 | + // for ticket selectors |
|
302 | + add_filter( |
|
303 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
304 | + array('EED_Ticket_Selector', 'iframeCss') |
|
305 | + ); |
|
306 | + add_filter( |
|
307 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
308 | + array('EED_Ticket_Selector', 'iframeJs') |
|
309 | + ); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
315 | + * |
|
316 | + * @param array $iframe_css |
|
317 | + * @return array |
|
318 | + */ |
|
319 | + public static function iframeCss(array $iframe_css) |
|
320 | + { |
|
321 | + $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
322 | + return $iframe_css; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * Informs the rest of the forms system what CSS and JS is needed to display the input |
|
328 | + * |
|
329 | + * @param array $iframe_js |
|
330 | + * @return array |
|
331 | + */ |
|
332 | + public static function iframeJs(array $iframe_js) |
|
333 | + { |
|
334 | + $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
335 | + return $iframe_js; |
|
336 | + } |
|
337 | + |
|
338 | + |
|
339 | + /****************************** DEPRECATED ******************************/ |
|
340 | + |
|
341 | + |
|
342 | + /** |
|
343 | + * @deprecated |
|
344 | + * @return string |
|
345 | + * @throws EE_Error |
|
346 | + */ |
|
347 | + public static function display_view_details_btn() |
|
348 | + { |
|
349 | + // todo add doing_it_wrong() notice during next major version |
|
350 | + return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * @deprecated |
|
356 | + * @return string |
|
357 | + * @throws EE_Error |
|
358 | + */ |
|
359 | + public static function display_ticket_selector_submit() |
|
360 | + { |
|
361 | + // todo add doing_it_wrong() notice during next major version |
|
362 | + return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + /** |
|
367 | + * @deprecated |
|
368 | + * @param string $permalink_string |
|
369 | + * @param int $id |
|
370 | + * @param string $new_title |
|
371 | + * @param string $new_slug |
|
372 | + * @return string |
|
373 | + * @throws InvalidArgumentException |
|
374 | + * @throws InvalidDataTypeException |
|
375 | + * @throws InvalidInterfaceException |
|
376 | + */ |
|
377 | + public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
378 | + { |
|
379 | + // todo add doing_it_wrong() notice during next major version |
|
380 | + if (EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
381 | + && EE_Registry::instance()->REQ->get('action') === 'edit' |
|
382 | + ) { |
|
383 | + $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
384 | + $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
385 | + } |
|
386 | + return ''; |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + /** |
|
391 | + * @deprecated |
|
392 | + * @param int $ID |
|
393 | + * @param string $external_url |
|
394 | + * @return string |
|
395 | + */ |
|
396 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
397 | + { |
|
398 | + // todo add doing_it_wrong() notice during next major version |
|
399 | + return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * @deprecated |
|
405 | + * @return string |
|
406 | + */ |
|
407 | + public static function ticket_selector_form_close() |
|
408 | + { |
|
409 | + // todo add doing_it_wrong() notice during next major version |
|
410 | + return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * @deprecated |
|
416 | + * @return string |
|
417 | + */ |
|
418 | + public static function no_tkt_slctr_end_dv() |
|
419 | + { |
|
420 | + // todo add doing_it_wrong() notice during next major version |
|
421 | + return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + /** |
|
426 | + * @deprecated 4.9.13 |
|
427 | + * @return string |
|
428 | + */ |
|
429 | + public static function tkt_slctr_end_dv() |
|
430 | + { |
|
431 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
432 | + } |
|
433 | + |
|
434 | + |
|
435 | + /** |
|
436 | + * @deprecated |
|
437 | + * @return string |
|
438 | + */ |
|
439 | + public static function clear_tkt_slctr() |
|
440 | + { |
|
441 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
442 | + } |
|
443 | + |
|
444 | + |
|
445 | + /** |
|
446 | + * @deprecated |
|
447 | + */ |
|
448 | + public static function load_tckt_slctr_assets_admin() |
|
449 | + { |
|
450 | + // todo add doing_it_wrong() notice during next major version |
|
451 | + if (EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
452 | + && EE_Registry::instance()->REQ->get('action') === 'edit' |
|
453 | + ) { |
|
454 | + $iframe_embed_button = EED_Ticket_Selector::getIframeEmbedButton(); |
|
455 | + $iframe_embed_button->embedButtonAssets(); |
|
456 | + } |
|
457 | + } |
|
458 | 458 | } |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | if (defined('TICKET_SELECTOR_ASSETS_URL')) { |
121 | 121 | return; |
122 | 122 | } |
123 | - define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
123 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets/'); |
|
124 | 124 | define( |
125 | 125 | 'TICKET_SELECTOR_TEMPLATES_PATH', |
126 | - str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/' |
|
126 | + str_replace('\\', '/', plugin_dir_path(__FILE__)).'templates/' |
|
127 | 127 | ); |
128 | 128 | // if config is not set, initialize |
129 | - if (! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
129 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config |
|
130 | 130 | ) { |
131 | 131 | EED_Ticket_Selector::instance()->set_config(); |
132 | 132 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = EED_Ticket_Selector::instance( |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public static function ticketSelector() |
142 | 142 | { |
143 | - if (! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
143 | + if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
144 | 144 | EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(EED_Events_Archive::is_iframe()); |
145 | 145 | } |
146 | 146 | return EED_Ticket_Selector::$ticket_selector; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public static function getIframeEmbedButton() |
165 | 165 | { |
166 | - if (! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) { |
|
166 | + if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) { |
|
167 | 167 | self::$iframe_embed_button = new TicketSelectorIframeEmbedButton(); |
168 | 168 | } |
169 | 169 | return self::$iframe_embed_button; |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | // add some style |
264 | 264 | wp_register_style( |
265 | 265 | 'ticket_selector', |
266 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css', |
|
266 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css', |
|
267 | 267 | array(), |
268 | 268 | EVENT_ESPRESSO_VERSION |
269 | 269 | ); |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | // make it dance |
272 | 272 | wp_register_script( |
273 | 273 | 'ticket_selector', |
274 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', |
|
274 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js', |
|
275 | 275 | array('espresso_core'), |
276 | 276 | EVENT_ESPRESSO_VERSION, |
277 | 277 | true |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public static function iframeCss(array $iframe_css) |
320 | 320 | { |
321 | - $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'; |
|
321 | + $iframe_css['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'; |
|
322 | 322 | return $iframe_css; |
323 | 323 | } |
324 | 324 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | */ |
332 | 332 | public static function iframeJs(array $iframe_js) |
333 | 333 | { |
334 | - $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js'; |
|
334 | + $iframe_js['ticket_selector'] = TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js'; |
|
335 | 335 | return $iframe_js; |
336 | 336 | } |
337 | 337 |
@@ -21,812 +21,812 @@ |
||
21 | 21 | abstract class EE_PMT_Base |
22 | 22 | { |
23 | 23 | |
24 | - const onsite = 'on-site'; |
|
25 | - const offsite = 'off-site'; |
|
26 | - const offline = 'off-line'; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var EE_Payment_Method |
|
30 | - */ |
|
31 | - protected $_pm_instance = null; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var boolean |
|
35 | - */ |
|
36 | - protected $_requires_https = false; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var boolean |
|
40 | - */ |
|
41 | - protected $_has_billing_form; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var EE_Gateway |
|
45 | - */ |
|
46 | - protected $_gateway = null; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var EE_Payment_Method_Form |
|
50 | - */ |
|
51 | - protected $_settings_form = null; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var EE_Form_Section_Proper |
|
55 | - */ |
|
56 | - protected $_billing_form = null; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var boolean |
|
60 | - */ |
|
61 | - protected $_cache_billing_form = true; |
|
62 | - |
|
63 | - /** |
|
64 | - * String of the absolute path to the folder containing this file, with a trailing slash. |
|
65 | - * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/' |
|
66 | - * |
|
67 | - * @var string |
|
68 | - */ |
|
69 | - protected $_file_folder = null; |
|
70 | - |
|
71 | - /** |
|
72 | - * String to the absolute URL to this file (useful for getting its web-accessible resources |
|
73 | - * like images, js, or css) |
|
74 | - * |
|
75 | - * @var string |
|
76 | - */ |
|
77 | - protected $_file_url = null; |
|
78 | - |
|
79 | - /** |
|
80 | - * Pretty name for the payment method |
|
81 | - * |
|
82 | - * @var string |
|
83 | - */ |
|
84 | - protected $_pretty_name = null; |
|
85 | - |
|
86 | - /** |
|
87 | - * |
|
88 | - * @var string |
|
89 | - */ |
|
90 | - protected $_default_button_url = null; |
|
91 | - |
|
92 | - /** |
|
93 | - * |
|
94 | - * @var string |
|
95 | - */ |
|
96 | - protected $_default_description = null; |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * |
|
101 | - * @param EE_Payment_Method $pm_instance |
|
102 | - * @throws EE_Error |
|
103 | - * @return EE_PMT_Base |
|
104 | - */ |
|
105 | - public function __construct($pm_instance = null) |
|
106 | - { |
|
107 | - if ($pm_instance instanceof EE_Payment_Method) { |
|
108 | - $this->set_instance($pm_instance); |
|
109 | - } |
|
110 | - if ($this->_gateway) { |
|
111 | - $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
112 | - $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
113 | - $this->_gateway->set_template_helper(new EEH_Template()); |
|
114 | - $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
115 | - $this->_gateway->set_money_helper(new EEH_Money()); |
|
116 | - $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
117 | - $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
118 | - do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
|
119 | - } |
|
120 | - if (! isset($this->_has_billing_form)) { |
|
121 | - // by default, On Site gateways have a billing form |
|
122 | - if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
123 | - $this->set_has_billing_form(true); |
|
124 | - } else { |
|
125 | - $this->set_has_billing_form(false); |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - if (! $this->_pretty_name) { |
|
130 | - throw new EE_Error( |
|
131 | - sprintf( |
|
132 | - __( |
|
133 | - "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", |
|
134 | - "event_espresso" |
|
135 | - ) |
|
136 | - ) |
|
137 | - ); |
|
138 | - } |
|
139 | - // if the child didn't specify a default button, use the credit card one |
|
140 | - if ($this->_default_button_url === null) { |
|
141 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png'; |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @param boolean $has_billing_form |
|
148 | - */ |
|
149 | - public function set_has_billing_form($has_billing_form) |
|
150 | - { |
|
151 | - $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * sets the file_folder property |
|
157 | - */ |
|
158 | - protected function _set_file_folder() |
|
159 | - { |
|
160 | - $reflector = new ReflectionClass(get_class($this)); |
|
161 | - $fn = $reflector->getFileName(); |
|
162 | - $this->_file_folder = dirname($fn) . '/'; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * sets the file URL with a trailing slash for this PMT |
|
168 | - */ |
|
169 | - protected function _set_file_url() |
|
170 | - { |
|
171 | - $plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR); |
|
172 | - $file_folder_fixed = str_replace('\\', '/', $this->file_folder()); |
|
173 | - $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
174 | - $this->_file_url = set_url_scheme($file_path); |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Gets the default description on all payment methods of this type |
|
179 | - * |
|
180 | - * @return string |
|
181 | - */ |
|
182 | - public function default_description() |
|
183 | - { |
|
184 | - return $this->_default_description; |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * Returns the folder containing the PMT child class, with a trailing slash |
|
190 | - * |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public function file_folder() |
|
194 | - { |
|
195 | - if (! $this->_file_folder) { |
|
196 | - $this->_set_file_folder(); |
|
197 | - } |
|
198 | - return $this->_file_folder; |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - public function file_url() |
|
206 | - { |
|
207 | - if (! $this->_file_url) { |
|
208 | - $this->_set_file_url(); |
|
209 | - } |
|
210 | - return $this->_file_url; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * Sets the payment method instance this payment method type is for. |
|
216 | - * Its important teh payment method instance is set before |
|
217 | - * |
|
218 | - * @param EE_Payment_Method $payment_method_instance |
|
219 | - */ |
|
220 | - public function set_instance($payment_method_instance) |
|
221 | - { |
|
222 | - $this->_pm_instance = $payment_method_instance; |
|
223 | - // if they have already requested the settings form, make sure its |
|
224 | - // data matches this model object |
|
225 | - if ($this->_settings_form) { |
|
226 | - $this->settings_form()->populate_model_obj($payment_method_instance); |
|
227 | - } |
|
228 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
229 | - $this->_gateway->set_settings($payment_method_instance->settings_array()); |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - |
|
234 | - /** |
|
235 | - * Gets teh form for displaying to admins where they setup the payment method |
|
236 | - * |
|
237 | - * @return EE_Payment_Method_Form |
|
238 | - */ |
|
239 | - public function settings_form() |
|
240 | - { |
|
241 | - if (! $this->_settings_form) { |
|
242 | - $this->_settings_form = $this->generate_new_settings_form(); |
|
243 | - $this->_settings_form->set_payment_method_type($this); |
|
244 | - // if we have already assigned a model object to this pmt, make |
|
245 | - // sure its reflected in teh form we just generated |
|
246 | - if ($this->_pm_instance) { |
|
247 | - $this->_settings_form->populate_model_obj($this->_pm_instance); |
|
248 | - } |
|
249 | - } |
|
250 | - return $this->_settings_form; |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * Gets the form for all the settings related to this payment method type |
|
256 | - * |
|
257 | - * @return EE_Payment_Method_Form |
|
258 | - */ |
|
259 | - abstract public function generate_new_settings_form(); |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * Sets the form for settings. This may be useful if we have already received |
|
264 | - * a form submission and have form data it in, and want to use it anytime we're showing |
|
265 | - * this payment method type's settings form later in the request |
|
266 | - * |
|
267 | - * @param EE_Payment_Method_Form $form |
|
268 | - */ |
|
269 | - public function set_settings_form($form) |
|
270 | - { |
|
271 | - $this->_settings_form = $form; |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * @return boolean |
|
277 | - */ |
|
278 | - public function has_billing_form() |
|
279 | - { |
|
280 | - return $this->_has_billing_form; |
|
281 | - } |
|
282 | - |
|
283 | - |
|
284 | - /** |
|
285 | - * Gets the form for displaying to attendees where they can enter their billing info |
|
286 | - * which will be sent to teh gateway (can be null) |
|
287 | - * |
|
288 | - * @param \EE_Transaction $transaction |
|
289 | - * @param array $extra_args |
|
290 | - * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
|
291 | - */ |
|
292 | - public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
|
293 | - { |
|
294 | - // has billing form already been regenerated ? or overwrite cache? |
|
295 | - if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
296 | - $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
297 | - } |
|
298 | - // if we know who the attendee is, and this is a billing form |
|
299 | - // that uses attendee info, populate it |
|
300 | - if (apply_filters( |
|
301 | - 'FHEE__populate_billing_form_fields_from_attendee', |
|
302 | - ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
303 | - && $transaction instanceof EE_Transaction |
|
304 | - && $transaction->primary_registration() instanceof EE_Registration |
|
305 | - && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
306 | - ), |
|
307 | - $this->_billing_form, |
|
308 | - $transaction |
|
309 | - )) { |
|
310 | - $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
311 | - } |
|
312 | - return $this->_billing_form; |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * Creates the billing form for this payment method type |
|
318 | - * |
|
319 | - * @param \EE_Transaction $transaction |
|
320 | - * @return \EE_Billing_Info_Form |
|
321 | - */ |
|
322 | - abstract public function generate_new_billing_form(EE_Transaction $transaction = null); |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * apply_billing_form_debug_settings |
|
327 | - * applies debug data to the form |
|
328 | - * |
|
329 | - * @param \EE_Billing_Info_Form $billing_form |
|
330 | - * @return \EE_Billing_Info_Form |
|
331 | - */ |
|
332 | - public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
333 | - { |
|
334 | - return $billing_form; |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * Sets the billing form for this payment method type. You may want to use this |
|
340 | - * if you have form |
|
341 | - * |
|
342 | - * @param EE_Payment_Method $form |
|
343 | - */ |
|
344 | - public function set_billing_form($form) |
|
345 | - { |
|
346 | - $this->_billing_form = $form; |
|
347 | - } |
|
348 | - |
|
349 | - |
|
350 | - /** |
|
351 | - * Returns whether or not this payment method requires HTTPS to be used |
|
352 | - * |
|
353 | - * @return boolean |
|
354 | - */ |
|
355 | - public function requires_https() |
|
356 | - { |
|
357 | - return $this->_requires_https; |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * |
|
363 | - * @param EE_Transaction $transaction |
|
364 | - * @param float $amount |
|
365 | - * @param EE_Billing_Info_Form $billing_info |
|
366 | - * @param string $return_url |
|
367 | - * @param string $fail_url |
|
368 | - * @param string $method |
|
369 | - * @param bool $by_admin |
|
370 | - * @return EE_Payment |
|
371 | - * @throws EE_Error |
|
372 | - */ |
|
373 | - public function process_payment( |
|
374 | - EE_Transaction $transaction, |
|
375 | - $amount = null, |
|
376 | - $billing_info = null, |
|
377 | - $return_url = null, |
|
378 | - $fail_url = '', |
|
379 | - $method = 'CART', |
|
380 | - $by_admin = false |
|
381 | - ) { |
|
382 | - // @todo: add surcharge for the payment method, if any |
|
383 | - if ($this->_gateway) { |
|
384 | - // there is a gateway, so we're going to make a payment object |
|
385 | - // but wait! do they already have a payment in progress that we thought was failed? |
|
386 | - $duplicate_properties = array( |
|
387 | - 'STS_ID' => EEM_Payment::status_id_failed, |
|
388 | - 'TXN_ID' => $transaction->ID(), |
|
389 | - 'PMD_ID' => $this->_pm_instance->ID(), |
|
390 | - 'PAY_source' => $method, |
|
391 | - 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
|
392 | - 'PAY_gateway_response' => null, |
|
393 | - ); |
|
394 | - $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
395 | - // if we didn't already have a payment in progress for the same thing, |
|
396 | - // then we actually want to make a new payment |
|
397 | - if (! $payment instanceof EE_Payment) { |
|
398 | - $payment = EE_Payment::new_instance( |
|
399 | - array_merge( |
|
400 | - $duplicate_properties, |
|
401 | - array( |
|
402 | - 'PAY_timestamp' => time(), |
|
403 | - 'PAY_txn_id_chq_nmbr' => null, |
|
404 | - 'PAY_po_number' => null, |
|
405 | - 'PAY_extra_accntng' => null, |
|
406 | - 'PAY_details' => null, |
|
407 | - ) |
|
408 | - ) |
|
409 | - ); |
|
410 | - } |
|
411 | - // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
|
412 | - $payment->save(); |
|
413 | - $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
414 | - |
|
415 | - // Offsite Gateway |
|
416 | - if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
417 | - $payment = $this->_gateway->set_redirection_info( |
|
418 | - $payment, |
|
419 | - $billing_values, |
|
420 | - $return_url, |
|
421 | - EE_Config::instance()->core->txn_page_url( |
|
422 | - array( |
|
423 | - 'e_reg_url_link' => $transaction->primary_registration()->reg_url_link(), |
|
424 | - 'ee_payment_method' => $this->_pm_instance->slug(), |
|
425 | - ) |
|
426 | - ), |
|
427 | - $fail_url |
|
428 | - ); |
|
429 | - $payment->save(); |
|
430 | - // Onsite Gateway |
|
431 | - } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
432 | - $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
433 | - $payment->save(); |
|
434 | - } else { |
|
435 | - throw new EE_Error( |
|
436 | - sprintf( |
|
437 | - __( |
|
438 | - 'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', |
|
439 | - 'event_espresso' |
|
440 | - ), |
|
441 | - get_class($this), |
|
442 | - gettype($this->_gateway) |
|
443 | - ) |
|
444 | - ); |
|
445 | - } |
|
446 | - } else { |
|
447 | - // no gateway provided |
|
448 | - // there is no payment. Must be an offline gateway |
|
449 | - // create a payment object anyways, but dont save it |
|
450 | - $payment = EE_Payment::new_instance( |
|
451 | - array( |
|
452 | - 'STS_ID' => EEM_Payment::status_id_pending, |
|
453 | - 'TXN_ID' => $transaction->ID(), |
|
454 | - 'PMD_ID' => $transaction->payment_method_ID(), |
|
455 | - 'PAY_amount' => 0.00, |
|
456 | - 'PAY_timestamp' => time(), |
|
457 | - ) |
|
458 | - ); |
|
459 | - } |
|
460 | - |
|
461 | - // if there is billing info, clean it and save it now |
|
462 | - if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
463 | - $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
464 | - } |
|
465 | - |
|
466 | - return $payment; |
|
467 | - } |
|
468 | - |
|
469 | - /** |
|
470 | - * Gets the values we want to pass onto the gateway. Normally these |
|
471 | - * are just the 'pretty' values, but there may be times the data may need |
|
472 | - * a little massaging. Proper subsections will become arrays of inputs |
|
473 | - * |
|
474 | - * @param EE_Billing_Info_Form $billing_form |
|
475 | - * @return array |
|
476 | - */ |
|
477 | - protected function _get_billing_values_from_form($billing_form) |
|
478 | - { |
|
479 | - if ($billing_form instanceof EE_Form_Section_Proper) { |
|
480 | - return $billing_form->input_pretty_values(true); |
|
481 | - } else { |
|
482 | - return null; |
|
483 | - } |
|
484 | - } |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
488 | - * Handles an instant payment notification when the transaction is known (by default). |
|
489 | - * |
|
490 | - * @param array $req_data |
|
491 | - * @param EE_Transaction $transaction |
|
492 | - * @return EE_Payment |
|
493 | - * @throws EE_Error |
|
494 | - */ |
|
495 | - public function handle_ipn($req_data, $transaction) |
|
496 | - { |
|
497 | - $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
498 | - if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
499 | - throw new EE_Error( |
|
500 | - sprintf( |
|
501 | - __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
|
502 | - print_r($this->_gateway, true) |
|
503 | - ) |
|
504 | - ); |
|
505 | - } |
|
506 | - $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
507 | - return $payment; |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * Saves the billing info onto the attendee of the primary registrant on this transaction, and |
|
513 | - * cleans it first. |
|
514 | - * |
|
515 | - * @param EE_Billing_Attendee_Info_Form $billing_form |
|
516 | - * @param EE_Transaction $transaction |
|
517 | - * @return boolean success |
|
518 | - */ |
|
519 | - protected function _save_billing_info_to_attendee($billing_form, $transaction) |
|
520 | - { |
|
521 | - if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
522 | - EE_Error::add_error( |
|
523 | - __("Cannot save billing info because no transaction was specified", "event_espresso"), |
|
524 | - __FILE__, |
|
525 | - __FUNCTION__, |
|
526 | - __LINE__ |
|
527 | - ); |
|
528 | - return false; |
|
529 | - } |
|
530 | - $primary_reg = $transaction->primary_registration(); |
|
531 | - if (! $primary_reg) { |
|
532 | - EE_Error::add_error( |
|
533 | - __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
|
534 | - __FILE__, |
|
535 | - __FUNCTION__, |
|
536 | - __LINE__ |
|
537 | - ); |
|
538 | - return false; |
|
539 | - } |
|
540 | - $attendee = $primary_reg->attendee(); |
|
541 | - if (! $attendee) { |
|
542 | - EE_Error::add_error( |
|
543 | - __( |
|
544 | - "Cannot save billing info because the transaction's primary registration has no attendee!", |
|
545 | - "event_espresso" |
|
546 | - ), |
|
547 | - __FILE__, |
|
548 | - __FUNCTION__, |
|
549 | - __LINE__ |
|
550 | - ); |
|
551 | - return false; |
|
552 | - } |
|
553 | - return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * Gets the payment this IPN is for. Children may often want to |
|
559 | - * override this to inspect the request |
|
560 | - * |
|
561 | - * @param EE_Transaction $transaction |
|
562 | - * @param array $req_data |
|
563 | - * @return EE_Payment |
|
564 | - */ |
|
565 | - protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) |
|
566 | - { |
|
567 | - return $transaction->last_payment(); |
|
568 | - } |
|
569 | - |
|
570 | - |
|
571 | - /** |
|
572 | - * In case generic code cannot provide the payment processor with a specific payment method |
|
573 | - * and transaction, it will try calling this method on each activate payment method. |
|
574 | - * If the payment method is able to identify the request as being for it, it should fetch |
|
575 | - * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot |
|
576 | - * handle the IPN |
|
577 | - * |
|
578 | - * @param array $req_data |
|
579 | - * @return EE_Payment only if this payment method can find the info its needs from $req_data |
|
580 | - * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
|
581 | - * @throws EE_Error |
|
582 | - */ |
|
583 | - public function handle_unclaimed_ipn($req_data = array()) |
|
584 | - { |
|
585 | - throw new EE_Error( |
|
586 | - sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this)) |
|
587 | - ); |
|
588 | - } |
|
589 | - |
|
590 | - |
|
591 | - /** |
|
592 | - * Logic to be accomplished when the payment attempt is complete. |
|
593 | - * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
594 | - * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
595 | - * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
596 | - * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
597 | - * we're dealing with. Returns that last payment (if there is one) |
|
598 | - * |
|
599 | - * @param EE_Transaction $transaction |
|
600 | - * @return EE_Payment |
|
601 | - */ |
|
602 | - public function finalize_payment_for($transaction) |
|
603 | - { |
|
604 | - return $transaction->last_payment(); |
|
605 | - } |
|
606 | - |
|
607 | - |
|
608 | - /** |
|
609 | - * Whether or not this payment method's gateway supports sending refund requests |
|
610 | - * |
|
611 | - * @return boolean |
|
612 | - */ |
|
613 | - public function supports_sending_refunds() |
|
614 | - { |
|
615 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
616 | - return $this->_gateway->supports_sending_refunds(); |
|
617 | - } else { |
|
618 | - return false; |
|
619 | - } |
|
620 | - } |
|
621 | - |
|
622 | - |
|
623 | - /** |
|
624 | - * |
|
625 | - * @param EE_Payment $payment |
|
626 | - * @param array $refund_info |
|
627 | - * @throws EE_Error |
|
628 | - * @return EE_Payment |
|
629 | - */ |
|
630 | - public function process_refund(EE_Payment $payment, $refund_info = array()) |
|
631 | - { |
|
632 | - if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
633 | - return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
634 | - } else { |
|
635 | - throw new EE_Error( |
|
636 | - sprintf( |
|
637 | - __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
638 | - get_class($this) |
|
639 | - ) |
|
640 | - ); |
|
641 | - } |
|
642 | - } |
|
643 | - |
|
644 | - |
|
645 | - /** |
|
646 | - * Returns one the class's constants onsite,offsite, or offline, depending on this |
|
647 | - * payment method's gateway. |
|
648 | - * |
|
649 | - * @return string |
|
650 | - * @throws EE_Error |
|
651 | - */ |
|
652 | - public function payment_occurs() |
|
653 | - { |
|
654 | - if (! $this->_gateway) { |
|
655 | - return EE_PMT_Base::offline; |
|
656 | - } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
657 | - return EE_PMT_Base::onsite; |
|
658 | - } elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
659 | - return EE_PMT_Base::offsite; |
|
660 | - } else { |
|
661 | - throw new EE_Error( |
|
662 | - sprintf( |
|
663 | - __( |
|
664 | - "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", |
|
665 | - "event_espresso" |
|
666 | - ), |
|
667 | - get_class($this) |
|
668 | - ) |
|
669 | - ); |
|
670 | - } |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - /** |
|
675 | - * For adding any html output ab ove the payment overview. |
|
676 | - * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
677 | - * Other gateways may want to override this, such as offline gateways. |
|
678 | - * |
|
679 | - * @param EE_Payment $payment |
|
680 | - * @return string |
|
681 | - */ |
|
682 | - public function payment_overview_content(EE_Payment $payment) |
|
683 | - { |
|
684 | - return EEH_Template::display_template( |
|
685 | - EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php', |
|
686 | - array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
|
687 | - true |
|
688 | - ); |
|
689 | - } |
|
690 | - |
|
691 | - |
|
692 | - /** |
|
693 | - * @return array where keys are the help tab name, |
|
694 | - * values are: array { |
|
695 | - * @type string $title i18n name for the help tab |
|
696 | - * @type string $filename name of the file located in ./help_tabs/ (ie, in a folder next to this file) |
|
697 | - * @type array $template_args any arguments you want passed to the template file while rendering. |
|
698 | - * Keys will be variable names and values with be their values. |
|
699 | - */ |
|
700 | - public function help_tabs_config() |
|
701 | - { |
|
702 | - return array(); |
|
703 | - } |
|
704 | - |
|
705 | - |
|
706 | - /** |
|
707 | - * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into |
|
708 | - * the payment method's table's PMT_type column) |
|
709 | - * |
|
710 | - * @return string |
|
711 | - */ |
|
712 | - public function system_name() |
|
713 | - { |
|
714 | - $classname = get_class($this); |
|
715 | - return str_replace("EE_PMT_", '', $classname); |
|
716 | - } |
|
717 | - |
|
718 | - |
|
719 | - /** |
|
720 | - * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding |
|
721 | - * this method. |
|
722 | - * @return string |
|
723 | - */ |
|
724 | - public function defaultFrontendName() |
|
725 | - { |
|
726 | - return $this->pretty_name(); |
|
727 | - } |
|
728 | - |
|
729 | - |
|
730 | - /** |
|
731 | - * A pretty i18n version of the PMT name |
|
732 | - * |
|
733 | - * @return string |
|
734 | - */ |
|
735 | - public function pretty_name() |
|
736 | - { |
|
737 | - return $this->_pretty_name; |
|
738 | - } |
|
739 | - |
|
740 | - |
|
741 | - /** |
|
742 | - * Gets the default absolute URL to the payment method type's button |
|
743 | - * |
|
744 | - * @return string |
|
745 | - */ |
|
746 | - public function default_button_url() |
|
747 | - { |
|
748 | - return $this->_default_button_url; |
|
749 | - } |
|
750 | - |
|
751 | - |
|
752 | - /** |
|
753 | - * Gets the gateway used by this payment method (if any) |
|
754 | - * |
|
755 | - * @return EE_Gateway |
|
756 | - */ |
|
757 | - public function get_gateway() |
|
758 | - { |
|
759 | - return $this->_gateway; |
|
760 | - } |
|
761 | - |
|
762 | - |
|
763 | - /** |
|
764 | - * @return string html for the link to a help tab |
|
765 | - */ |
|
766 | - public function get_help_tab_link() |
|
767 | - { |
|
768 | - return EEH_Template::get_help_tab_link( |
|
769 | - $this->get_help_tab_name(), |
|
770 | - 'espresso_payment_settings', |
|
771 | - 'default' |
|
772 | - ); |
|
773 | - } |
|
774 | - |
|
775 | - |
|
776 | - /** |
|
777 | - * Returns the name of the help tab for this PMT |
|
778 | - * |
|
779 | - * @return string |
|
780 | - */ |
|
781 | - public function get_help_tab_name() |
|
782 | - { |
|
783 | - return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
784 | - } |
|
785 | - |
|
786 | - /** |
|
787 | - * The name of the wp capability that should be associated with the usage of |
|
788 | - * this PMT by an admin |
|
789 | - * |
|
790 | - * @return string |
|
791 | - */ |
|
792 | - public function cap_name() |
|
793 | - { |
|
794 | - return 'ee_payment_method_' . strtolower($this->system_name()); |
|
795 | - } |
|
796 | - |
|
797 | - /** |
|
798 | - * Called by client code to tell the gateway that if it wants to change |
|
799 | - * the transaction or line items or registrations related to teh payment it already |
|
800 | - * processed (we think, but possibly not) that now's the time to do it. |
|
801 | - * It is expected that gateways will store any info they need for this on the PAY_details, |
|
802 | - * or maybe an extra meta value |
|
803 | - * |
|
804 | - * @param EE_Payment $payment |
|
805 | - * @return void |
|
806 | - */ |
|
807 | - public function update_txn_based_on_payment($payment) |
|
808 | - { |
|
809 | - if ($this->_gateway instanceof EE_Gateway) { |
|
810 | - $this->_gateway->update_txn_based_on_payment($payment); |
|
811 | - } |
|
812 | - } |
|
813 | - |
|
814 | - /** |
|
815 | - * Returns a string of HTML describing this payment method type for an admin, |
|
816 | - * primarily intended for them to read before activating it. |
|
817 | - * The easiest way to set this is to create a folder 'templates' alongside |
|
818 | - * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php". |
|
819 | - * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php", |
|
820 | - * then you'd create a file named "templates" in the same folder as it, and name the file |
|
821 | - * "foo_bar_intro.template.php", and its content will be returned by this method |
|
822 | - * |
|
823 | - * @return string |
|
824 | - */ |
|
825 | - public function introductory_html() |
|
826 | - { |
|
827 | - return EEH_Template::locate_template( |
|
828 | - $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php', |
|
829 | - array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
|
830 | - ); |
|
831 | - } |
|
24 | + const onsite = 'on-site'; |
|
25 | + const offsite = 'off-site'; |
|
26 | + const offline = 'off-line'; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var EE_Payment_Method |
|
30 | + */ |
|
31 | + protected $_pm_instance = null; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var boolean |
|
35 | + */ |
|
36 | + protected $_requires_https = false; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var boolean |
|
40 | + */ |
|
41 | + protected $_has_billing_form; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var EE_Gateway |
|
45 | + */ |
|
46 | + protected $_gateway = null; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var EE_Payment_Method_Form |
|
50 | + */ |
|
51 | + protected $_settings_form = null; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var EE_Form_Section_Proper |
|
55 | + */ |
|
56 | + protected $_billing_form = null; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var boolean |
|
60 | + */ |
|
61 | + protected $_cache_billing_form = true; |
|
62 | + |
|
63 | + /** |
|
64 | + * String of the absolute path to the folder containing this file, with a trailing slash. |
|
65 | + * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/' |
|
66 | + * |
|
67 | + * @var string |
|
68 | + */ |
|
69 | + protected $_file_folder = null; |
|
70 | + |
|
71 | + /** |
|
72 | + * String to the absolute URL to this file (useful for getting its web-accessible resources |
|
73 | + * like images, js, or css) |
|
74 | + * |
|
75 | + * @var string |
|
76 | + */ |
|
77 | + protected $_file_url = null; |
|
78 | + |
|
79 | + /** |
|
80 | + * Pretty name for the payment method |
|
81 | + * |
|
82 | + * @var string |
|
83 | + */ |
|
84 | + protected $_pretty_name = null; |
|
85 | + |
|
86 | + /** |
|
87 | + * |
|
88 | + * @var string |
|
89 | + */ |
|
90 | + protected $_default_button_url = null; |
|
91 | + |
|
92 | + /** |
|
93 | + * |
|
94 | + * @var string |
|
95 | + */ |
|
96 | + protected $_default_description = null; |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * |
|
101 | + * @param EE_Payment_Method $pm_instance |
|
102 | + * @throws EE_Error |
|
103 | + * @return EE_PMT_Base |
|
104 | + */ |
|
105 | + public function __construct($pm_instance = null) |
|
106 | + { |
|
107 | + if ($pm_instance instanceof EE_Payment_Method) { |
|
108 | + $this->set_instance($pm_instance); |
|
109 | + } |
|
110 | + if ($this->_gateway) { |
|
111 | + $this->_gateway->set_payment_model(EEM_Payment::instance()); |
|
112 | + $this->_gateway->set_payment_log(EEM_Change_Log::instance()); |
|
113 | + $this->_gateway->set_template_helper(new EEH_Template()); |
|
114 | + $this->_gateway->set_line_item_helper(new EEH_Line_Item()); |
|
115 | + $this->_gateway->set_money_helper(new EEH_Money()); |
|
116 | + $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter()); |
|
117 | + $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
|
118 | + do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
|
119 | + } |
|
120 | + if (! isset($this->_has_billing_form)) { |
|
121 | + // by default, On Site gateways have a billing form |
|
122 | + if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
|
123 | + $this->set_has_billing_form(true); |
|
124 | + } else { |
|
125 | + $this->set_has_billing_form(false); |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + if (! $this->_pretty_name) { |
|
130 | + throw new EE_Error( |
|
131 | + sprintf( |
|
132 | + __( |
|
133 | + "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized", |
|
134 | + "event_espresso" |
|
135 | + ) |
|
136 | + ) |
|
137 | + ); |
|
138 | + } |
|
139 | + // if the child didn't specify a default button, use the credit card one |
|
140 | + if ($this->_default_button_url === null) { |
|
141 | + $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png'; |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @param boolean $has_billing_form |
|
148 | + */ |
|
149 | + public function set_has_billing_form($has_billing_form) |
|
150 | + { |
|
151 | + $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN); |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * sets the file_folder property |
|
157 | + */ |
|
158 | + protected function _set_file_folder() |
|
159 | + { |
|
160 | + $reflector = new ReflectionClass(get_class($this)); |
|
161 | + $fn = $reflector->getFileName(); |
|
162 | + $this->_file_folder = dirname($fn) . '/'; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * sets the file URL with a trailing slash for this PMT |
|
168 | + */ |
|
169 | + protected function _set_file_url() |
|
170 | + { |
|
171 | + $plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR); |
|
172 | + $file_folder_fixed = str_replace('\\', '/', $this->file_folder()); |
|
173 | + $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed); |
|
174 | + $this->_file_url = set_url_scheme($file_path); |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Gets the default description on all payment methods of this type |
|
179 | + * |
|
180 | + * @return string |
|
181 | + */ |
|
182 | + public function default_description() |
|
183 | + { |
|
184 | + return $this->_default_description; |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * Returns the folder containing the PMT child class, with a trailing slash |
|
190 | + * |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public function file_folder() |
|
194 | + { |
|
195 | + if (! $this->_file_folder) { |
|
196 | + $this->_set_file_folder(); |
|
197 | + } |
|
198 | + return $this->_file_folder; |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + public function file_url() |
|
206 | + { |
|
207 | + if (! $this->_file_url) { |
|
208 | + $this->_set_file_url(); |
|
209 | + } |
|
210 | + return $this->_file_url; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * Sets the payment method instance this payment method type is for. |
|
216 | + * Its important teh payment method instance is set before |
|
217 | + * |
|
218 | + * @param EE_Payment_Method $payment_method_instance |
|
219 | + */ |
|
220 | + public function set_instance($payment_method_instance) |
|
221 | + { |
|
222 | + $this->_pm_instance = $payment_method_instance; |
|
223 | + // if they have already requested the settings form, make sure its |
|
224 | + // data matches this model object |
|
225 | + if ($this->_settings_form) { |
|
226 | + $this->settings_form()->populate_model_obj($payment_method_instance); |
|
227 | + } |
|
228 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
229 | + $this->_gateway->set_settings($payment_method_instance->settings_array()); |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + |
|
234 | + /** |
|
235 | + * Gets teh form for displaying to admins where they setup the payment method |
|
236 | + * |
|
237 | + * @return EE_Payment_Method_Form |
|
238 | + */ |
|
239 | + public function settings_form() |
|
240 | + { |
|
241 | + if (! $this->_settings_form) { |
|
242 | + $this->_settings_form = $this->generate_new_settings_form(); |
|
243 | + $this->_settings_form->set_payment_method_type($this); |
|
244 | + // if we have already assigned a model object to this pmt, make |
|
245 | + // sure its reflected in teh form we just generated |
|
246 | + if ($this->_pm_instance) { |
|
247 | + $this->_settings_form->populate_model_obj($this->_pm_instance); |
|
248 | + } |
|
249 | + } |
|
250 | + return $this->_settings_form; |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * Gets the form for all the settings related to this payment method type |
|
256 | + * |
|
257 | + * @return EE_Payment_Method_Form |
|
258 | + */ |
|
259 | + abstract public function generate_new_settings_form(); |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * Sets the form for settings. This may be useful if we have already received |
|
264 | + * a form submission and have form data it in, and want to use it anytime we're showing |
|
265 | + * this payment method type's settings form later in the request |
|
266 | + * |
|
267 | + * @param EE_Payment_Method_Form $form |
|
268 | + */ |
|
269 | + public function set_settings_form($form) |
|
270 | + { |
|
271 | + $this->_settings_form = $form; |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * @return boolean |
|
277 | + */ |
|
278 | + public function has_billing_form() |
|
279 | + { |
|
280 | + return $this->_has_billing_form; |
|
281 | + } |
|
282 | + |
|
283 | + |
|
284 | + /** |
|
285 | + * Gets the form for displaying to attendees where they can enter their billing info |
|
286 | + * which will be sent to teh gateway (can be null) |
|
287 | + * |
|
288 | + * @param \EE_Transaction $transaction |
|
289 | + * @param array $extra_args |
|
290 | + * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null |
|
291 | + */ |
|
292 | + public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
|
293 | + { |
|
294 | + // has billing form already been regenerated ? or overwrite cache? |
|
295 | + if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
296 | + $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
|
297 | + } |
|
298 | + // if we know who the attendee is, and this is a billing form |
|
299 | + // that uses attendee info, populate it |
|
300 | + if (apply_filters( |
|
301 | + 'FHEE__populate_billing_form_fields_from_attendee', |
|
302 | + ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form |
|
303 | + && $transaction instanceof EE_Transaction |
|
304 | + && $transaction->primary_registration() instanceof EE_Registration |
|
305 | + && $transaction->primary_registration()->attendee() instanceof EE_Attendee |
|
306 | + ), |
|
307 | + $this->_billing_form, |
|
308 | + $transaction |
|
309 | + )) { |
|
310 | + $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee()); |
|
311 | + } |
|
312 | + return $this->_billing_form; |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * Creates the billing form for this payment method type |
|
318 | + * |
|
319 | + * @param \EE_Transaction $transaction |
|
320 | + * @return \EE_Billing_Info_Form |
|
321 | + */ |
|
322 | + abstract public function generate_new_billing_form(EE_Transaction $transaction = null); |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * apply_billing_form_debug_settings |
|
327 | + * applies debug data to the form |
|
328 | + * |
|
329 | + * @param \EE_Billing_Info_Form $billing_form |
|
330 | + * @return \EE_Billing_Info_Form |
|
331 | + */ |
|
332 | + public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form) |
|
333 | + { |
|
334 | + return $billing_form; |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * Sets the billing form for this payment method type. You may want to use this |
|
340 | + * if you have form |
|
341 | + * |
|
342 | + * @param EE_Payment_Method $form |
|
343 | + */ |
|
344 | + public function set_billing_form($form) |
|
345 | + { |
|
346 | + $this->_billing_form = $form; |
|
347 | + } |
|
348 | + |
|
349 | + |
|
350 | + /** |
|
351 | + * Returns whether or not this payment method requires HTTPS to be used |
|
352 | + * |
|
353 | + * @return boolean |
|
354 | + */ |
|
355 | + public function requires_https() |
|
356 | + { |
|
357 | + return $this->_requires_https; |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * |
|
363 | + * @param EE_Transaction $transaction |
|
364 | + * @param float $amount |
|
365 | + * @param EE_Billing_Info_Form $billing_info |
|
366 | + * @param string $return_url |
|
367 | + * @param string $fail_url |
|
368 | + * @param string $method |
|
369 | + * @param bool $by_admin |
|
370 | + * @return EE_Payment |
|
371 | + * @throws EE_Error |
|
372 | + */ |
|
373 | + public function process_payment( |
|
374 | + EE_Transaction $transaction, |
|
375 | + $amount = null, |
|
376 | + $billing_info = null, |
|
377 | + $return_url = null, |
|
378 | + $fail_url = '', |
|
379 | + $method = 'CART', |
|
380 | + $by_admin = false |
|
381 | + ) { |
|
382 | + // @todo: add surcharge for the payment method, if any |
|
383 | + if ($this->_gateway) { |
|
384 | + // there is a gateway, so we're going to make a payment object |
|
385 | + // but wait! do they already have a payment in progress that we thought was failed? |
|
386 | + $duplicate_properties = array( |
|
387 | + 'STS_ID' => EEM_Payment::status_id_failed, |
|
388 | + 'TXN_ID' => $transaction->ID(), |
|
389 | + 'PMD_ID' => $this->_pm_instance->ID(), |
|
390 | + 'PAY_source' => $method, |
|
391 | + 'PAY_amount' => $amount !== null ? $amount : $transaction->remaining(), |
|
392 | + 'PAY_gateway_response' => null, |
|
393 | + ); |
|
394 | + $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
|
395 | + // if we didn't already have a payment in progress for the same thing, |
|
396 | + // then we actually want to make a new payment |
|
397 | + if (! $payment instanceof EE_Payment) { |
|
398 | + $payment = EE_Payment::new_instance( |
|
399 | + array_merge( |
|
400 | + $duplicate_properties, |
|
401 | + array( |
|
402 | + 'PAY_timestamp' => time(), |
|
403 | + 'PAY_txn_id_chq_nmbr' => null, |
|
404 | + 'PAY_po_number' => null, |
|
405 | + 'PAY_extra_accntng' => null, |
|
406 | + 'PAY_details' => null, |
|
407 | + ) |
|
408 | + ) |
|
409 | + ); |
|
410 | + } |
|
411 | + // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it |
|
412 | + $payment->save(); |
|
413 | + $billing_values = $this->_get_billing_values_from_form($billing_info); |
|
414 | + |
|
415 | + // Offsite Gateway |
|
416 | + if ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
417 | + $payment = $this->_gateway->set_redirection_info( |
|
418 | + $payment, |
|
419 | + $billing_values, |
|
420 | + $return_url, |
|
421 | + EE_Config::instance()->core->txn_page_url( |
|
422 | + array( |
|
423 | + 'e_reg_url_link' => $transaction->primary_registration()->reg_url_link(), |
|
424 | + 'ee_payment_method' => $this->_pm_instance->slug(), |
|
425 | + ) |
|
426 | + ), |
|
427 | + $fail_url |
|
428 | + ); |
|
429 | + $payment->save(); |
|
430 | + // Onsite Gateway |
|
431 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
432 | + $payment = $this->_gateway->do_direct_payment($payment, $billing_values); |
|
433 | + $payment->save(); |
|
434 | + } else { |
|
435 | + throw new EE_Error( |
|
436 | + sprintf( |
|
437 | + __( |
|
438 | + 'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)', |
|
439 | + 'event_espresso' |
|
440 | + ), |
|
441 | + get_class($this), |
|
442 | + gettype($this->_gateway) |
|
443 | + ) |
|
444 | + ); |
|
445 | + } |
|
446 | + } else { |
|
447 | + // no gateway provided |
|
448 | + // there is no payment. Must be an offline gateway |
|
449 | + // create a payment object anyways, but dont save it |
|
450 | + $payment = EE_Payment::new_instance( |
|
451 | + array( |
|
452 | + 'STS_ID' => EEM_Payment::status_id_pending, |
|
453 | + 'TXN_ID' => $transaction->ID(), |
|
454 | + 'PMD_ID' => $transaction->payment_method_ID(), |
|
455 | + 'PAY_amount' => 0.00, |
|
456 | + 'PAY_timestamp' => time(), |
|
457 | + ) |
|
458 | + ); |
|
459 | + } |
|
460 | + |
|
461 | + // if there is billing info, clean it and save it now |
|
462 | + if ($billing_info instanceof EE_Billing_Attendee_Info_Form) { |
|
463 | + $this->_save_billing_info_to_attendee($billing_info, $transaction); |
|
464 | + } |
|
465 | + |
|
466 | + return $payment; |
|
467 | + } |
|
468 | + |
|
469 | + /** |
|
470 | + * Gets the values we want to pass onto the gateway. Normally these |
|
471 | + * are just the 'pretty' values, but there may be times the data may need |
|
472 | + * a little massaging. Proper subsections will become arrays of inputs |
|
473 | + * |
|
474 | + * @param EE_Billing_Info_Form $billing_form |
|
475 | + * @return array |
|
476 | + */ |
|
477 | + protected function _get_billing_values_from_form($billing_form) |
|
478 | + { |
|
479 | + if ($billing_form instanceof EE_Form_Section_Proper) { |
|
480 | + return $billing_form->input_pretty_values(true); |
|
481 | + } else { |
|
482 | + return null; |
|
483 | + } |
|
484 | + } |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | + * Handles an instant payment notification when the transaction is known (by default). |
|
489 | + * |
|
490 | + * @param array $req_data |
|
491 | + * @param EE_Transaction $transaction |
|
492 | + * @return EE_Payment |
|
493 | + * @throws EE_Error |
|
494 | + */ |
|
495 | + public function handle_ipn($req_data, $transaction) |
|
496 | + { |
|
497 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
498 | + if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
499 | + throw new EE_Error( |
|
500 | + sprintf( |
|
501 | + __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
|
502 | + print_r($this->_gateway, true) |
|
503 | + ) |
|
504 | + ); |
|
505 | + } |
|
506 | + $payment = $this->_gateway->handle_payment_update($req_data, $transaction); |
|
507 | + return $payment; |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * Saves the billing info onto the attendee of the primary registrant on this transaction, and |
|
513 | + * cleans it first. |
|
514 | + * |
|
515 | + * @param EE_Billing_Attendee_Info_Form $billing_form |
|
516 | + * @param EE_Transaction $transaction |
|
517 | + * @return boolean success |
|
518 | + */ |
|
519 | + protected function _save_billing_info_to_attendee($billing_form, $transaction) |
|
520 | + { |
|
521 | + if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
522 | + EE_Error::add_error( |
|
523 | + __("Cannot save billing info because no transaction was specified", "event_espresso"), |
|
524 | + __FILE__, |
|
525 | + __FUNCTION__, |
|
526 | + __LINE__ |
|
527 | + ); |
|
528 | + return false; |
|
529 | + } |
|
530 | + $primary_reg = $transaction->primary_registration(); |
|
531 | + if (! $primary_reg) { |
|
532 | + EE_Error::add_error( |
|
533 | + __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
|
534 | + __FILE__, |
|
535 | + __FUNCTION__, |
|
536 | + __LINE__ |
|
537 | + ); |
|
538 | + return false; |
|
539 | + } |
|
540 | + $attendee = $primary_reg->attendee(); |
|
541 | + if (! $attendee) { |
|
542 | + EE_Error::add_error( |
|
543 | + __( |
|
544 | + "Cannot save billing info because the transaction's primary registration has no attendee!", |
|
545 | + "event_espresso" |
|
546 | + ), |
|
547 | + __FILE__, |
|
548 | + __FUNCTION__, |
|
549 | + __LINE__ |
|
550 | + ); |
|
551 | + return false; |
|
552 | + } |
|
553 | + return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method()); |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * Gets the payment this IPN is for. Children may often want to |
|
559 | + * override this to inspect the request |
|
560 | + * |
|
561 | + * @param EE_Transaction $transaction |
|
562 | + * @param array $req_data |
|
563 | + * @return EE_Payment |
|
564 | + */ |
|
565 | + protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array()) |
|
566 | + { |
|
567 | + return $transaction->last_payment(); |
|
568 | + } |
|
569 | + |
|
570 | + |
|
571 | + /** |
|
572 | + * In case generic code cannot provide the payment processor with a specific payment method |
|
573 | + * and transaction, it will try calling this method on each activate payment method. |
|
574 | + * If the payment method is able to identify the request as being for it, it should fetch |
|
575 | + * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot |
|
576 | + * handle the IPN |
|
577 | + * |
|
578 | + * @param array $req_data |
|
579 | + * @return EE_Payment only if this payment method can find the info its needs from $req_data |
|
580 | + * and identifies the IPN as being for this payment method (not just fo ra payment method of this type) |
|
581 | + * @throws EE_Error |
|
582 | + */ |
|
583 | + public function handle_unclaimed_ipn($req_data = array()) |
|
584 | + { |
|
585 | + throw new EE_Error( |
|
586 | + sprintf(__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this)) |
|
587 | + ); |
|
588 | + } |
|
589 | + |
|
590 | + |
|
591 | + /** |
|
592 | + * Logic to be accomplished when the payment attempt is complete. |
|
593 | + * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
594 | + * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
595 | + * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
596 | + * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
597 | + * we're dealing with. Returns that last payment (if there is one) |
|
598 | + * |
|
599 | + * @param EE_Transaction $transaction |
|
600 | + * @return EE_Payment |
|
601 | + */ |
|
602 | + public function finalize_payment_for($transaction) |
|
603 | + { |
|
604 | + return $transaction->last_payment(); |
|
605 | + } |
|
606 | + |
|
607 | + |
|
608 | + /** |
|
609 | + * Whether or not this payment method's gateway supports sending refund requests |
|
610 | + * |
|
611 | + * @return boolean |
|
612 | + */ |
|
613 | + public function supports_sending_refunds() |
|
614 | + { |
|
615 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
616 | + return $this->_gateway->supports_sending_refunds(); |
|
617 | + } else { |
|
618 | + return false; |
|
619 | + } |
|
620 | + } |
|
621 | + |
|
622 | + |
|
623 | + /** |
|
624 | + * |
|
625 | + * @param EE_Payment $payment |
|
626 | + * @param array $refund_info |
|
627 | + * @throws EE_Error |
|
628 | + * @return EE_Payment |
|
629 | + */ |
|
630 | + public function process_refund(EE_Payment $payment, $refund_info = array()) |
|
631 | + { |
|
632 | + if ($this->_gateway && $this->_gateway instanceof EE_Gateway) { |
|
633 | + return $this->_gateway->do_direct_refund($payment, $refund_info); |
|
634 | + } else { |
|
635 | + throw new EE_Error( |
|
636 | + sprintf( |
|
637 | + __('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'), |
|
638 | + get_class($this) |
|
639 | + ) |
|
640 | + ); |
|
641 | + } |
|
642 | + } |
|
643 | + |
|
644 | + |
|
645 | + /** |
|
646 | + * Returns one the class's constants onsite,offsite, or offline, depending on this |
|
647 | + * payment method's gateway. |
|
648 | + * |
|
649 | + * @return string |
|
650 | + * @throws EE_Error |
|
651 | + */ |
|
652 | + public function payment_occurs() |
|
653 | + { |
|
654 | + if (! $this->_gateway) { |
|
655 | + return EE_PMT_Base::offline; |
|
656 | + } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
|
657 | + return EE_PMT_Base::onsite; |
|
658 | + } elseif ($this->_gateway instanceof EE_Offsite_Gateway) { |
|
659 | + return EE_PMT_Base::offsite; |
|
660 | + } else { |
|
661 | + throw new EE_Error( |
|
662 | + sprintf( |
|
663 | + __( |
|
664 | + "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those", |
|
665 | + "event_espresso" |
|
666 | + ), |
|
667 | + get_class($this) |
|
668 | + ) |
|
669 | + ); |
|
670 | + } |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + /** |
|
675 | + * For adding any html output ab ove the payment overview. |
|
676 | + * Many gateways won't want ot display anything, so this function just returns an empty string. |
|
677 | + * Other gateways may want to override this, such as offline gateways. |
|
678 | + * |
|
679 | + * @param EE_Payment $payment |
|
680 | + * @return string |
|
681 | + */ |
|
682 | + public function payment_overview_content(EE_Payment $payment) |
|
683 | + { |
|
684 | + return EEH_Template::display_template( |
|
685 | + EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php', |
|
686 | + array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
|
687 | + true |
|
688 | + ); |
|
689 | + } |
|
690 | + |
|
691 | + |
|
692 | + /** |
|
693 | + * @return array where keys are the help tab name, |
|
694 | + * values are: array { |
|
695 | + * @type string $title i18n name for the help tab |
|
696 | + * @type string $filename name of the file located in ./help_tabs/ (ie, in a folder next to this file) |
|
697 | + * @type array $template_args any arguments you want passed to the template file while rendering. |
|
698 | + * Keys will be variable names and values with be their values. |
|
699 | + */ |
|
700 | + public function help_tabs_config() |
|
701 | + { |
|
702 | + return array(); |
|
703 | + } |
|
704 | + |
|
705 | + |
|
706 | + /** |
|
707 | + * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into |
|
708 | + * the payment method's table's PMT_type column) |
|
709 | + * |
|
710 | + * @return string |
|
711 | + */ |
|
712 | + public function system_name() |
|
713 | + { |
|
714 | + $classname = get_class($this); |
|
715 | + return str_replace("EE_PMT_", '', $classname); |
|
716 | + } |
|
717 | + |
|
718 | + |
|
719 | + /** |
|
720 | + * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding |
|
721 | + * this method. |
|
722 | + * @return string |
|
723 | + */ |
|
724 | + public function defaultFrontendName() |
|
725 | + { |
|
726 | + return $this->pretty_name(); |
|
727 | + } |
|
728 | + |
|
729 | + |
|
730 | + /** |
|
731 | + * A pretty i18n version of the PMT name |
|
732 | + * |
|
733 | + * @return string |
|
734 | + */ |
|
735 | + public function pretty_name() |
|
736 | + { |
|
737 | + return $this->_pretty_name; |
|
738 | + } |
|
739 | + |
|
740 | + |
|
741 | + /** |
|
742 | + * Gets the default absolute URL to the payment method type's button |
|
743 | + * |
|
744 | + * @return string |
|
745 | + */ |
|
746 | + public function default_button_url() |
|
747 | + { |
|
748 | + return $this->_default_button_url; |
|
749 | + } |
|
750 | + |
|
751 | + |
|
752 | + /** |
|
753 | + * Gets the gateway used by this payment method (if any) |
|
754 | + * |
|
755 | + * @return EE_Gateway |
|
756 | + */ |
|
757 | + public function get_gateway() |
|
758 | + { |
|
759 | + return $this->_gateway; |
|
760 | + } |
|
761 | + |
|
762 | + |
|
763 | + /** |
|
764 | + * @return string html for the link to a help tab |
|
765 | + */ |
|
766 | + public function get_help_tab_link() |
|
767 | + { |
|
768 | + return EEH_Template::get_help_tab_link( |
|
769 | + $this->get_help_tab_name(), |
|
770 | + 'espresso_payment_settings', |
|
771 | + 'default' |
|
772 | + ); |
|
773 | + } |
|
774 | + |
|
775 | + |
|
776 | + /** |
|
777 | + * Returns the name of the help tab for this PMT |
|
778 | + * |
|
779 | + * @return string |
|
780 | + */ |
|
781 | + public function get_help_tab_name() |
|
782 | + { |
|
783 | + return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
784 | + } |
|
785 | + |
|
786 | + /** |
|
787 | + * The name of the wp capability that should be associated with the usage of |
|
788 | + * this PMT by an admin |
|
789 | + * |
|
790 | + * @return string |
|
791 | + */ |
|
792 | + public function cap_name() |
|
793 | + { |
|
794 | + return 'ee_payment_method_' . strtolower($this->system_name()); |
|
795 | + } |
|
796 | + |
|
797 | + /** |
|
798 | + * Called by client code to tell the gateway that if it wants to change |
|
799 | + * the transaction or line items or registrations related to teh payment it already |
|
800 | + * processed (we think, but possibly not) that now's the time to do it. |
|
801 | + * It is expected that gateways will store any info they need for this on the PAY_details, |
|
802 | + * or maybe an extra meta value |
|
803 | + * |
|
804 | + * @param EE_Payment $payment |
|
805 | + * @return void |
|
806 | + */ |
|
807 | + public function update_txn_based_on_payment($payment) |
|
808 | + { |
|
809 | + if ($this->_gateway instanceof EE_Gateway) { |
|
810 | + $this->_gateway->update_txn_based_on_payment($payment); |
|
811 | + } |
|
812 | + } |
|
813 | + |
|
814 | + /** |
|
815 | + * Returns a string of HTML describing this payment method type for an admin, |
|
816 | + * primarily intended for them to read before activating it. |
|
817 | + * The easiest way to set this is to create a folder 'templates' alongside |
|
818 | + * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php". |
|
819 | + * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php", |
|
820 | + * then you'd create a file named "templates" in the same folder as it, and name the file |
|
821 | + * "foo_bar_intro.template.php", and its content will be returned by this method |
|
822 | + * |
|
823 | + * @return string |
|
824 | + */ |
|
825 | + public function introductory_html() |
|
826 | + { |
|
827 | + return EEH_Template::locate_template( |
|
828 | + $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php', |
|
829 | + array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
|
830 | + ); |
|
831 | + } |
|
832 | 832 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | $this->_gateway->set_unsupported_character_remover(new AsciiOnly()); |
118 | 118 | do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway); |
119 | 119 | } |
120 | - if (! isset($this->_has_billing_form)) { |
|
120 | + if ( ! isset($this->_has_billing_form)) { |
|
121 | 121 | // by default, On Site gateways have a billing form |
122 | 122 | if ($this->payment_occurs() == EE_PMT_Base::onsite) { |
123 | 123 | $this->set_has_billing_form(true); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | - if (! $this->_pretty_name) { |
|
129 | + if ( ! $this->_pretty_name) { |
|
130 | 130 | throw new EE_Error( |
131 | 131 | sprintf( |
132 | 132 | __( |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | // if the child didn't specify a default button, use the credit card one |
140 | 140 | if ($this->_default_button_url === null) { |
141 | - $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png'; |
|
141 | + $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods/pay-by-credit-card.png'; |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | { |
160 | 160 | $reflector = new ReflectionClass(get_class($this)); |
161 | 161 | $fn = $reflector->getFileName(); |
162 | - $this->_file_folder = dirname($fn) . '/'; |
|
162 | + $this->_file_folder = dirname($fn).'/'; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | public function file_folder() |
194 | 194 | { |
195 | - if (! $this->_file_folder) { |
|
195 | + if ( ! $this->_file_folder) { |
|
196 | 196 | $this->_set_file_folder(); |
197 | 197 | } |
198 | 198 | return $this->_file_folder; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function file_url() |
206 | 206 | { |
207 | - if (! $this->_file_url) { |
|
207 | + if ( ! $this->_file_url) { |
|
208 | 208 | $this->_set_file_url(); |
209 | 209 | } |
210 | 210 | return $this->_file_url; |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function settings_form() |
240 | 240 | { |
241 | - if (! $this->_settings_form) { |
|
241 | + if ( ! $this->_settings_form) { |
|
242 | 242 | $this->_settings_form = $this->generate_new_settings_form(); |
243 | 243 | $this->_settings_form->set_payment_method_type($this); |
244 | 244 | // if we have already assigned a model object to this pmt, make |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | public function billing_form(EE_Transaction $transaction = null, $extra_args = array()) |
293 | 293 | { |
294 | 294 | // has billing form already been regenerated ? or overwrite cache? |
295 | - if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
295 | + if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) { |
|
296 | 296 | $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args); |
297 | 297 | } |
298 | 298 | // if we know who the attendee is, and this is a billing form |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $payment = EEM_Payment::instance()->get_one(array($duplicate_properties)); |
395 | 395 | // if we didn't already have a payment in progress for the same thing, |
396 | 396 | // then we actually want to make a new payment |
397 | - if (! $payment instanceof EE_Payment) { |
|
397 | + if ( ! $payment instanceof EE_Payment) { |
|
398 | 398 | $payment = EE_Payment::new_instance( |
399 | 399 | array_merge( |
400 | 400 | $duplicate_properties, |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | public function handle_ipn($req_data, $transaction) |
496 | 496 | { |
497 | 497 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
498 | - if (! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
498 | + if ( ! $this->_gateway instanceof EE_Offsite_Gateway) { |
|
499 | 499 | throw new EE_Error( |
500 | 500 | sprintf( |
501 | 501 | __("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"), |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | */ |
519 | 519 | protected function _save_billing_info_to_attendee($billing_form, $transaction) |
520 | 520 | { |
521 | - if (! $transaction || ! $transaction instanceof EE_Transaction) { |
|
521 | + if ( ! $transaction || ! $transaction instanceof EE_Transaction) { |
|
522 | 522 | EE_Error::add_error( |
523 | 523 | __("Cannot save billing info because no transaction was specified", "event_espresso"), |
524 | 524 | __FILE__, |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | return false; |
529 | 529 | } |
530 | 530 | $primary_reg = $transaction->primary_registration(); |
531 | - if (! $primary_reg) { |
|
531 | + if ( ! $primary_reg) { |
|
532 | 532 | EE_Error::add_error( |
533 | 533 | __("Cannot save billing info because the transaction has no primary registration", "event_espresso"), |
534 | 534 | __FILE__, |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | return false; |
539 | 539 | } |
540 | 540 | $attendee = $primary_reg->attendee(); |
541 | - if (! $attendee) { |
|
541 | + if ( ! $attendee) { |
|
542 | 542 | EE_Error::add_error( |
543 | 543 | __( |
544 | 544 | "Cannot save billing info because the transaction's primary registration has no attendee!", |
@@ -651,7 +651,7 @@ discard block |
||
651 | 651 | */ |
652 | 652 | public function payment_occurs() |
653 | 653 | { |
654 | - if (! $this->_gateway) { |
|
654 | + if ( ! $this->_gateway) { |
|
655 | 655 | return EE_PMT_Base::offline; |
656 | 656 | } elseif ($this->_gateway instanceof EE_Onsite_Gateway) { |
657 | 657 | return EE_PMT_Base::onsite; |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | public function payment_overview_content(EE_Payment $payment) |
683 | 683 | { |
684 | 684 | return EEH_Template::display_template( |
685 | - EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php', |
|
685 | + EE_LIBRARIES.'payment_methods/templates/payment_details_content.template.php', |
|
686 | 686 | array('payment_method' => $this->_pm_instance, 'payment' => $payment), |
687 | 687 | true |
688 | 688 | ); |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | */ |
781 | 781 | public function get_help_tab_name() |
782 | 782 | { |
783 | - return 'ee_' . strtolower($this->system_name()) . '_help_tab'; |
|
783 | + return 'ee_'.strtolower($this->system_name()).'_help_tab'; |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | /** |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | */ |
792 | 792 | public function cap_name() |
793 | 793 | { |
794 | - return 'ee_payment_method_' . strtolower($this->system_name()); |
|
794 | + return 'ee_payment_method_'.strtolower($this->system_name()); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | /** |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | public function introductory_html() |
826 | 826 | { |
827 | 827 | return EEH_Template::locate_template( |
828 | - $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php', |
|
828 | + $this->file_folder().'templates/'.strtolower($this->system_name()).'_intro.template.php', |
|
829 | 829 | array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance) |
830 | 830 | ); |
831 | 831 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <p class="about-description"> |
2 | 2 | <?php esc_html_e( |
3 | - 'Event Espresso is created by an international team of passionate individuals with a drive to empower your events!', |
|
4 | - 'event_espresso' |
|
5 | - ); ?></p> |
|
3 | + 'Event Espresso is created by an international team of passionate individuals with a drive to empower your events!', |
|
4 | + 'event_espresso' |
|
5 | + ); ?></p> |
|
6 | 6 | <h3 class="wp-people-group"><?php esc_html_e('Founders', 'event_espresso'); ?></h3> |
7 | 7 | <ul class="wp-people-group" id="ee-people-group-owners"> |
8 | 8 | <li class="wp-person" id="ee-person-sshoultes"> |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | <h3 class="wp-people-group"><?php esc_html_e('Contributor Recognition', 'event_espresso'); ?></h3> |
86 | 86 | <p class="description"> |
87 | 87 | <?php printf( |
88 | - esc_html__( |
|
89 | - '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.', |
|
90 | - 'event_espresso' |
|
91 | - ), |
|
92 | - '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">', |
|
93 | - '</a>' |
|
94 | - ); ?> |
|
88 | + esc_html__( |
|
89 | + '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.', |
|
90 | + 'event_espresso' |
|
91 | + ), |
|
92 | + '<a href="https://github.com/eventespresso/event-espresso-core" title="Contribute to Event Espresso by making a pull request via GitHub">', |
|
93 | + '</a>' |
|
94 | + ); ?> |
|
95 | 95 | </p> |
96 | 96 | <p class="wp-credits-list"> |
97 | 97 | <ul> |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | <h3 class="wp-people-group"><?php esc_html_e('External Libraries', 'event_espresso'); ?></h3> |
107 | 107 | <p class="description"> |
108 | 108 | <?php printf( |
109 | - esc_html__( |
|
110 | - 'Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', |
|
111 | - 'event_espresso' |
|
112 | - ), |
|
113 | - '<a href="credits.php">', |
|
114 | - '</a>' |
|
115 | - ); ?> |
|
109 | + esc_html__( |
|
110 | + 'Along with the libraries %sincluded with WordPress%s, Event Espresso utilizes the following third party libraries:', |
|
111 | + 'event_espresso' |
|
112 | + ), |
|
113 | + '<a href="credits.php">', |
|
114 | + '</a>' |
|
115 | + ); ?> |
|
116 | 116 | </p> |
117 | 117 | <p class="wp-credits-list"> |
118 | 118 | <a href="https://openexchangerates.github.io/accounting.js/">accounting.js</a>, |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | <?php |
130 | 130 | function esp_gravatar_profile($email) |
131 | 131 | { |
132 | - echo 'https://www.gravatar.com/' . md5($email); |
|
132 | + echo 'https://www.gravatar.com/' . md5($email); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | function esp_gravatar_image($email, $name) |
136 | 136 | { |
137 | - echo '<img src="https://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>'; |
|
137 | + echo '<img src="https://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>'; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | ?> |
@@ -129,12 +129,12 @@ |
||
129 | 129 | <?php |
130 | 130 | function esp_gravatar_profile($email) |
131 | 131 | { |
132 | - echo 'https://www.gravatar.com/' . md5($email); |
|
132 | + echo 'https://www.gravatar.com/'.md5($email); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | function esp_gravatar_image($email, $name) |
136 | 136 | { |
137 | - echo '<img src="https://0.gravatar.com/avatar/' . md5($email) . '?s=60" class="gravatar" alt="' . $name . '"/>'; |
|
137 | + echo '<img src="https://0.gravatar.com/avatar/'.md5($email).'?s=60" class="gravatar" alt="'.$name.'"/>'; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | ?> |