@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * EE_Form_Input_Base |
|
4 | - * For representing a single form input. Extends EE_Form_Section_Base because |
|
5 | - * it is a part of a form and shares a surprisingly large amount of functionality |
|
6 | - * |
|
7 | - * @package Event Espresso |
|
8 | - * @subpackage |
|
9 | - * @author Mike Nelson |
|
10 | - */ |
|
3 | + * EE_Form_Input_Base |
|
4 | + * For representing a single form input. Extends EE_Form_Section_Base because |
|
5 | + * it is a part of a form and shares a surprisingly large amount of functionality |
|
6 | + * |
|
7 | + * @package Event Espresso |
|
8 | + * @subpackage |
|
9 | + * @author Mike Nelson |
|
10 | + */ |
|
11 | 11 | abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
12 | 12 | |
13 | 13 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * the input's name attribute |
@@ -141,66 +141,66 @@ discard block |
||
141 | 141 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
142 | 142 | * } |
143 | 143 | */ |
144 | - public function __construct( $input_args = array() ){ |
|
145 | - $input_args = apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
144 | + public function __construct($input_args = array()) { |
|
145 | + $input_args = apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
146 | 146 | // the following properties must be cast as arrays |
147 | 147 | $set_as_array = array( |
148 | 148 | 'validation_strategies' => true |
149 | 149 | ); |
150 | 150 | // loop thru incoming options |
151 | - foreach( $input_args as $key => $value ) { |
|
151 | + foreach ($input_args as $key => $value) { |
|
152 | 152 | // add underscore to $key to match property names |
153 | - $_key = '_' . $key; |
|
154 | - if ( property_exists( $this, $_key )) { |
|
153 | + $_key = '_'.$key; |
|
154 | + if (property_exists($this, $_key)) { |
|
155 | 155 | // first check if this property needs to be set as an array |
156 | - if ( isset( $set_as_array[ $key ] )) { |
|
156 | + if (isset($set_as_array[$key])) { |
|
157 | 157 | // ensure value is an array |
158 | - $value = is_array( $value ) ? $value : array( get_class( $value ), $value ); |
|
158 | + $value = is_array($value) ? $value : array(get_class($value), $value); |
|
159 | 159 | // and merge with existing values |
160 | - $this->{$_key} = array_merge( $this->{$_key}, $value ); |
|
160 | + $this->{$_key} = array_merge($this->{$_key}, $value); |
|
161 | 161 | } else { |
162 | 162 | $this->{$_key} = $value; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
166 | 166 | // ensure that "required" is set correctly |
167 | - $this->set_required( $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) ? $input_args[ 'required_validation_error_message' ] : NULL ); |
|
167 | + $this->set_required($this->_required, isset($input_args['required_validation_error_message']) ? $input_args['required_validation_error_message'] : NULL); |
|
168 | 168 | |
169 | 169 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
170 | 170 | |
171 | 171 | $this->_display_strategy->_construct_finalize($this); |
172 | - if ( $this->_validation_strategies ){ |
|
173 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
172 | + if ($this->_validation_strategies) { |
|
173 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
174 | 174 | $validation_strategy->_construct_finalize($this); |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | - if( ! $this->_normalization_strategy){ |
|
178 | + if ( ! $this->_normalization_strategy) { |
|
179 | 179 | $this->_normalization_strategy = new EE_Text_Normalization(); |
180 | 180 | } |
181 | 181 | $this->_normalization_strategy->_construct_finalize($this); |
182 | 182 | |
183 | 183 | //at least we can use the normalization strategy to populate the default |
184 | - if( isset( $input_args[ 'default' ] ) ) { |
|
185 | - $this->set_default( $input_args[ 'default' ] ); |
|
184 | + if (isset($input_args['default'])) { |
|
185 | + $this->set_default($input_args['default']); |
|
186 | 186 | } |
187 | 187 | |
188 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
188 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
189 | 189 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
190 | 190 | } |
191 | 191 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
192 | - parent::__construct( $input_args ); |
|
192 | + parent::__construct($input_args); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
196 | 196 | * Sets the html_name to its default value, if none was specified in teh constructor. |
197 | 197 | * Calculation involves using the name and the parent's html_name |
198 | 198 | */ |
199 | - protected function _set_default_html_name_if_empty(){ |
|
200 | - if( ! $this->_html_name){ |
|
201 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
202 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
203 | - }else{ |
|
199 | + protected function _set_default_html_name_if_empty() { |
|
200 | + if ( ! $this->_html_name) { |
|
201 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
202 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
203 | + } else { |
|
204 | 204 | $this->_html_name = $this->name(); |
205 | 205 | } |
206 | 206 | } |
@@ -215,12 +215,12 @@ discard block |
||
215 | 215 | function _construct_finalize($parent_form_section, $name) { |
216 | 216 | parent::_construct_finalize($parent_form_section, $name); |
217 | 217 | $this->_set_default_html_name_if_empty(); |
218 | - if( ! $this->_html_label ){ |
|
219 | - if( ! $this->_html_label_text){ |
|
220 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
218 | + if ( ! $this->_html_label) { |
|
219 | + if ( ! $this->_html_label_text) { |
|
220 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
221 | 221 | } |
222 | 222 | } |
223 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
223 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | * @return EE_Display_Strategy_Base |
229 | 229 | * @throws EE_Error |
230 | 230 | */ |
231 | - protected function _get_display_strategy(){ |
|
232 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
233 | - throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id())); |
|
234 | - }else{ |
|
231 | + protected function _get_display_strategy() { |
|
232 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
233 | + throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"), $this->html_name(), $this->html_id())); |
|
234 | + } else { |
|
235 | 235 | return $this->_display_strategy; |
236 | 236 | } |
237 | 237 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * Sets the display strategy. |
240 | 240 | * @param EE_Display_Strategy_Base $strategy |
241 | 241 | */ |
242 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
242 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
243 | 243 | $this->_display_strategy = $strategy; |
244 | 244 | } |
245 | 245 | |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * Sets the sanitization strategy |
248 | 248 | * @param EE_Normalization_Strategy_Base $strategy |
249 | 249 | */ |
250 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
250 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
251 | 251 | $this->_normalization_strategy = $strategy; |
252 | 252 | } |
253 | 253 | |
@@ -273,14 +273,14 @@ discard block |
||
273 | 273 | * Gets the display strategy for this input |
274 | 274 | * @return EE_Display_Strategy_Base |
275 | 275 | */ |
276 | - public function get_display_strategy(){ |
|
276 | + public function get_display_strategy() { |
|
277 | 277 | return $this->_display_strategy; |
278 | 278 | } |
279 | 279 | /** |
280 | 280 | * Overwrites the display strategy |
281 | 281 | * @param EE_Display_Strategy_Base $display_strategy |
282 | 282 | */ |
283 | - public function set_display_strategy($display_strategy){ |
|
283 | + public function set_display_strategy($display_strategy) { |
|
284 | 284 | $this->_display_strategy = $display_strategy; |
285 | 285 | $this->_display_strategy->_construct_finalize($this); |
286 | 286 | } |
@@ -288,14 +288,14 @@ discard block |
||
288 | 288 | * Gets the normalization strategy set on this input |
289 | 289 | * @return EE_Normalization_Strategy_Base |
290 | 290 | */ |
291 | - public function get_normalization_strategy(){ |
|
291 | + public function get_normalization_strategy() { |
|
292 | 292 | return $this->_normalization_strategy; |
293 | 293 | } |
294 | 294 | /** |
295 | 295 | * Overwrites the normalization strategy |
296 | 296 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
297 | 297 | */ |
298 | - public function set_normalization_strategy($normalization_strategy){ |
|
298 | + public function set_normalization_strategy($normalization_strategy) { |
|
299 | 299 | $this->_normalization_strategy = $normalization_strategy; |
300 | 300 | $this->_normalization_strategy->_construct_finalize($this); |
301 | 301 | } |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | * Returns all teh validation strategies which apply to this field, numerically indexed |
305 | 305 | * @return EE_Validation_Strategy_Base[] |
306 | 306 | */ |
307 | - public function get_validation_strategies(){ |
|
308 | - if(is_array($this->_validation_strategies)){ |
|
307 | + public function get_validation_strategies() { |
|
308 | + if (is_array($this->_validation_strategies)) { |
|
309 | 309 | return $this->_validation_strategies; |
310 | - }else{ |
|
310 | + } else { |
|
311 | 311 | return array(); |
312 | 312 | } |
313 | 313 | |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | * @param EE_Validation_Strategy_Base $validation_strategy |
318 | 318 | * @return void |
319 | 319 | */ |
320 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
321 | - $validation_strategy->_construct_finalize( $this ); |
|
322 | - $this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy; |
|
320 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
321 | + $validation_strategy->_construct_finalize($this); |
|
322 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | /** |
@@ -327,18 +327,18 @@ discard block |
||
327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
331 | - $this->_add_validation_strategy( $validation_strategy ); |
|
330 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
331 | + $this->_add_validation_strategy($validation_strategy); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | 335 | * The classname of the validation strategy to remove |
336 | 336 | * @param string $validation_strategy_classname |
337 | 337 | */ |
338 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
339 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
340 | - if( is_subclass_of( $validation_strategy, $validation_strategy_classname ) ){ |
|
341 | - unset( $this->_validation_strategies[ $key ] ); |
|
338 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
339 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
340 | + if (is_subclass_of($validation_strategy, $validation_strategy_classname)) { |
|
341 | + unset($this->_validation_strategies[$key]); |
|
342 | 342 | } |
343 | 343 | } |
344 | 344 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * to the parent form's layout strategy |
348 | 348 | * @return string |
349 | 349 | */ |
350 | - public function get_html_and_js(){ |
|
350 | + public function get_html_and_js() { |
|
351 | 351 | return $this->_parent_section->get_html_for_input($this); |
352 | 352 | } |
353 | 353 | /** |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * Makes sure the JS and CSS are enqueued for it |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - public function get_html_for_input(){ |
|
359 | + public function get_html_for_input() { |
|
360 | 360 | return $this->_get_display_strategy()->display(); |
361 | 361 | } |
362 | 362 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | * @return string |
367 | 367 | */ |
368 | 368 | public function html_other_attributes() { |
369 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
369 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | /** |
375 | 375 | * @param string $html_other_attributes |
376 | 376 | */ |
377 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
377 | + public function set_html_other_attributes($html_other_attributes) { |
|
378 | 378 | $this->_html_other_attributes = $html_other_attributes; |
379 | 379 | } |
380 | 380 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * according to the form section's layout strategy |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - public function get_html_for_label(){ |
|
386 | + public function get_html_for_label() { |
|
387 | 387 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
388 | 388 | } |
389 | 389 | /** |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * according to the form section's layout strategy |
392 | 392 | * @return string |
393 | 393 | */ |
394 | - public function get_html_for_errors(){ |
|
394 | + public function get_html_for_errors() { |
|
395 | 395 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
396 | 396 | } |
397 | 397 | /** |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * according to the form section's layout strategy |
400 | 400 | * @return string |
401 | 401 | */ |
402 | - public function get_html_for_help(){ |
|
402 | + public function get_html_for_help() { |
|
403 | 403 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
404 | 404 | } |
405 | 405 | /** |
@@ -408,20 +408,20 @@ discard block |
||
408 | 408 | * @return boolean |
409 | 409 | */ |
410 | 410 | protected function _validate() { |
411 | - if(is_array($this->_validation_strategies)){ |
|
412 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
413 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
414 | - try{ |
|
411 | + if (is_array($this->_validation_strategies)) { |
|
412 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
413 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
414 | + try { |
|
415 | 415 | $validation_strategy->validate($this->normalized_value()); |
416 | - }catch(EE_Validation_Error $e){ |
|
416 | + } catch (EE_Validation_Error $e) { |
|
417 | 417 | $this->add_validation_error($e); |
418 | 418 | } |
419 | 419 | } |
420 | 420 | } |
421 | 421 | } |
422 | - if( $this->get_validation_errors()){ |
|
422 | + if ($this->get_validation_errors()) { |
|
423 | 423 | return false; |
424 | - }else{ |
|
424 | + } else { |
|
425 | 425 | return true; |
426 | 426 | } |
427 | 427 | } |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | * @param string $value |
435 | 435 | * @return null|string |
436 | 436 | */ |
437 | - private function _sanitize($value){ |
|
438 | - return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field |
|
437 | + private function _sanitize($value) { |
|
438 | + return $value !== NULL ? stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | |
@@ -447,24 +447,24 @@ discard block |
||
447 | 447 | * @param array $req_data like $_POST |
448 | 448 | * @return boolean whether or not there was an error |
449 | 449 | */ |
450 | - protected function _normalize( $req_data ) { |
|
450 | + protected function _normalize($req_data) { |
|
451 | 451 | //any existing validation errors don't apply so clear them |
452 | 452 | $this->_validation_errors = array(); |
453 | 453 | try { |
454 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
454 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
455 | 455 | //super simple sanitization for now |
456 | - if ( is_array( $raw_input )) { |
|
456 | + if (is_array($raw_input)) { |
|
457 | 457 | $this->_raw_value = array(); |
458 | - foreach( $raw_input as $key => $value ) { |
|
459 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
458 | + foreach ($raw_input as $key => $value) { |
|
459 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
460 | 460 | } |
461 | 461 | } else { |
462 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
462 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
463 | 463 | } |
464 | 464 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
465 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
466 | - } catch ( EE_Validation_Error $e ) { |
|
467 | - $this->add_validation_error( $e ); |
|
465 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
466 | + } catch (EE_Validation_Error $e) { |
|
467 | + $this->add_validation_error($e); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | /** |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - public function html_name(){ |
|
476 | + public function html_name() { |
|
477 | 477 | return $this->_html_name; |
478 | 478 | } |
479 | 479 | |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | /** |
483 | 483 | * @return string |
484 | 484 | */ |
485 | - function html_label_id(){ |
|
486 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
485 | + function html_label_id() { |
|
486 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | /** |
492 | 492 | * @return string |
493 | 493 | */ |
494 | - function html_label_class(){ |
|
494 | + function html_label_class() { |
|
495 | 495 | return $this->_html_label_class; |
496 | 496 | } |
497 | 497 | |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | /** |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - function html_label_style(){ |
|
503 | + function html_label_style() { |
|
504 | 504 | return $this->_html_label_style; |
505 | 505 | } |
506 | 506 | |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | /** |
510 | 510 | * @return string |
511 | 511 | */ |
512 | - function html_label_text(){ |
|
512 | + function html_label_text() { |
|
513 | 513 | return $this->_html_label_text; |
514 | 514 | } |
515 | 515 | |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | /** |
519 | 519 | * @return string |
520 | 520 | */ |
521 | - function html_help_text(){ |
|
521 | + function html_help_text() { |
|
522 | 522 | return $this->_html_help_text; |
523 | 523 | } |
524 | 524 | |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | /** |
528 | 528 | * @return string |
529 | 529 | */ |
530 | - function html_help_class(){ |
|
530 | + function html_help_class() { |
|
531 | 531 | return $this->_html_help_class; |
532 | 532 | } |
533 | 533 | |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | /** |
537 | 537 | * @return string |
538 | 538 | */ |
539 | - function html_help_style(){ |
|
539 | + function html_help_style() { |
|
540 | 540 | return $this->_html_style; |
541 | 541 | } |
542 | 542 | /** |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | * in which case, we would have stored the malicious content to our database. |
550 | 550 | * @return string |
551 | 551 | */ |
552 | - function raw_value(){ |
|
552 | + function raw_value() { |
|
553 | 553 | return $this->_raw_value; |
554 | 554 | } |
555 | 555 | /** |
@@ -557,15 +557,15 @@ discard block |
||
557 | 557 | * it escapes all html entities |
558 | 558 | * @return string |
559 | 559 | */ |
560 | - function raw_value_in_form(){ |
|
561 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
560 | + function raw_value_in_form() { |
|
561 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
562 | 562 | } |
563 | 563 | /** |
564 | 564 | * returns the value after it's been sanitized, and then converted into it's proper type |
565 | 565 | * in PHP. Eg, a string, an int, an array, |
566 | 566 | * @return mixed |
567 | 567 | */ |
568 | - function normalized_value(){ |
|
568 | + function normalized_value() { |
|
569 | 569 | return $this->_normalized_value; |
570 | 570 | } |
571 | 571 | |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * the best thing to display |
576 | 576 | * @return string |
577 | 577 | */ |
578 | - function pretty_value(){ |
|
578 | + function pretty_value() { |
|
579 | 579 | return $this->_normalized_value; |
580 | 580 | } |
581 | 581 | /** |
@@ -594,19 +594,19 @@ discard block |
||
594 | 594 | }</code> |
595 | 595 | * @return array |
596 | 596 | */ |
597 | - function get_jquery_validation_rules(){ |
|
597 | + function get_jquery_validation_rules() { |
|
598 | 598 | |
599 | 599 | $jquery_validation_rules = array(); |
600 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
600 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
601 | 601 | $jquery_validation_rules = array_replace_recursive( |
602 | 602 | $jquery_validation_rules, |
603 | 603 | $validation_strategy->get_jquery_validation_rule_array() |
604 | 604 | ); |
605 | 605 | } |
606 | 606 | |
607 | - if(! empty($jquery_validation_rules)){ |
|
608 | - $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
|
609 | - }else{ |
|
607 | + if ( ! empty($jquery_validation_rules)) { |
|
608 | + $jquery_validation_js[$this->html_id(TRUE)] = $jquery_validation_rules; |
|
609 | + } else { |
|
610 | 610 | return array(); |
611 | 611 | } |
612 | 612 | return $jquery_validation_js; |
@@ -618,9 +618,9 @@ discard block |
||
618 | 618 | * @param mixed $value |
619 | 619 | * @return void |
620 | 620 | */ |
621 | - function set_default($value){ |
|
621 | + function set_default($value) { |
|
622 | 622 | $this->_normalized_value = $value; |
623 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
623 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | /** |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | * @param string $label |
629 | 629 | * @return void |
630 | 630 | */ |
631 | - function set_html_label_text($label){ |
|
631 | + function set_html_label_text($label) { |
|
632 | 632 | $this->_html_label_text = $label; |
633 | 633 | } |
634 | 634 | |
@@ -640,12 +640,12 @@ discard block |
||
640 | 640 | * @param boolean $required |
641 | 641 | * @param null $required_text |
642 | 642 | */ |
643 | - function set_required($required = true, $required_text = NULL ){ |
|
644 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
645 | - if ( $required ) { |
|
646 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
643 | + function set_required($required = true, $required_text = NULL) { |
|
644 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
645 | + if ($required) { |
|
646 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
647 | 647 | } else { |
648 | - unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] ); |
|
648 | + unset($this->_validation_strategies['EE_Required_Validation_Strategy']); |
|
649 | 649 | } |
650 | 650 | $this->_required = $required; |
651 | 651 | } |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * Returns whether or not this field is required |
654 | 654 | * @return boolean |
655 | 655 | */ |
656 | - public function required(){ |
|
656 | + public function required() { |
|
657 | 657 | return $this->_required; |
658 | 658 | } |
659 | 659 | |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | /** |
663 | 663 | * @param string $required_css_class |
664 | 664 | */ |
665 | - public function set_required_css_class( $required_css_class ) { |
|
665 | + public function set_required_css_class($required_css_class) { |
|
666 | 666 | $this->_required_css_class = $required_css_class; |
667 | 667 | } |
668 | 668 | |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * Sets the help text, in case |
682 | 682 | * @param string $text |
683 | 683 | */ |
684 | - public function set_html_help_text($text){ |
|
684 | + public function set_html_help_text($text) { |
|
685 | 685 | $this->_html_help_text = $text; |
686 | 686 | } |
687 | 687 | /** |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | public function clean_sensitive_data() { |
694 | 694 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
695 | 695 | //if we need more logic than this we'll make a strategy for it |
696 | - if( $this->_sensitive_data_removal_strategy && |
|
697 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
696 | + if ($this->_sensitive_data_removal_strategy && |
|
697 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
698 | 698 | $this->_raw_value = NULL; |
699 | 699 | } |
700 | 700 | //and clean the normalized value according to the appropriate strategy |
@@ -708,10 +708,10 @@ discard block |
||
708 | 708 | * @param string $button_size |
709 | 709 | * @param string $other_attributes |
710 | 710 | */ |
711 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
711 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
712 | 712 | $button_css_attributes = 'button'; |
713 | 713 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
714 | - switch ( $button_size ) { |
|
714 | + switch ($button_size) { |
|
715 | 715 | case 'xs' : |
716 | 716 | case 'extra-small' : |
717 | 717 | $button_css_attributes .= ' button-xs'; |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | default : |
733 | 733 | $button_css_attributes .= ''; |
734 | 734 | } |
735 | - $this->_button_css_attributes .= ! empty( $other_attributes ) ? $button_css_attributes . ' ' . $other_attributes : $button_css_attributes; |
|
735 | + $this->_button_css_attributes .= ! empty($other_attributes) ? $button_css_attributes.' '.$other_attributes : $button_css_attributes; |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | * @return string |
742 | 742 | */ |
743 | 743 | public function button_css_attributes() { |
744 | - if ( empty( $this->_button_css_attributes )) { |
|
744 | + if (empty($this->_button_css_attributes)) { |
|
745 | 745 | $this->set_button_css_attributes(); |
746 | 746 | } |
747 | 747 | return $this->_button_css_attributes; |
@@ -761,27 +761,27 @@ discard block |
||
761 | 761 | * @param array $req_data |
762 | 762 | * @return mixed whatever the raw value of this form section is in the request data |
763 | 763 | */ |
764 | - public function find_form_data_for_this_section( $req_data ){ |
|
764 | + public function find_form_data_for_this_section($req_data) { |
|
765 | 765 | // break up the html name by "[]" |
766 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
767 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
766 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
767 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
768 | 768 | } else { |
769 | 769 | $before_any_brackets = $this->html_name(); |
770 | 770 | } |
771 | 771 | // grab all of the segments |
772 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
773 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
774 | - $name_parts = $matches[ 1 ]; |
|
772 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
773 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
774 | + $name_parts = $matches[1]; |
|
775 | 775 | array_unshift($name_parts, $before_any_brackets); |
776 | - }else{ |
|
777 | - $name_parts = array( $before_any_brackets ); |
|
776 | + } else { |
|
777 | + $name_parts = array($before_any_brackets); |
|
778 | 778 | } |
779 | 779 | // now get the value for the input |
780 | 780 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
781 | - if( $value === NULL ){ |
|
781 | + if ($value === NULL) { |
|
782 | 782 | //check if this thing's name is at the TOP level of the request data |
783 | - if( isset( $req_data[ $this->name() ] ) ){ |
|
784 | - $value = $req_data[ $this->name() ]; |
|
783 | + if (isset($req_data[$this->name()])) { |
|
784 | + $value = $req_data[$this->name()]; |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | return $value; |
@@ -795,15 +795,15 @@ discard block |
||
795 | 795 | * @param array $req_data |
796 | 796 | * @return array | NULL |
797 | 797 | */ |
798 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
799 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
800 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
801 | - if( empty($html_name_parts ) ){ |
|
802 | - return $req_data[ $first_part_to_consider ]; |
|
803 | - }else{ |
|
804 | - return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] ); |
|
798 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
799 | + $first_part_to_consider = array_shift($html_name_parts); |
|
800 | + if (isset($req_data[$first_part_to_consider])) { |
|
801 | + if (empty($html_name_parts)) { |
|
802 | + return $req_data[$first_part_to_consider]; |
|
803 | + } else { |
|
804 | + return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[$first_part_to_consider]); |
|
805 | 805 | } |
806 | - }else{ |
|
806 | + } else { |
|
807 | 807 | return NULL; |
808 | 808 | } |
809 | 809 | } |
@@ -815,14 +815,14 @@ discard block |
||
815 | 815 | * @param array $req_data like $_POST |
816 | 816 | * @return boolean |
817 | 817 | */ |
818 | - public function form_data_present_in($req_data = NULL){ |
|
819 | - if( $req_data === NULL ){ |
|
818 | + public function form_data_present_in($req_data = NULL) { |
|
819 | + if ($req_data === NULL) { |
|
820 | 820 | $req_data = $_POST; |
821 | 821 | } |
822 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
823 | - if( $checked_value !== null ){ |
|
822 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
823 | + if ($checked_value !== null) { |
|
824 | 824 | return TRUE; |
825 | - }else{ |
|
825 | + } else { |
|
826 | 826 | return FALSE; |
827 | 827 | } |
828 | 828 | } |
@@ -1,26 +1,26 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Event Espresso |
|
4 | - * |
|
5 | - * Event Registration and Management Plugin for WordPress |
|
6 | - * |
|
7 | - * @ package Event Espresso |
|
8 | - * @ author Event Espresso |
|
9 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | - * @ link http://www.eventespresso.com |
|
12 | - * @ version 4.0 |
|
13 | - * |
|
14 | - * ------------------------------------------------------------------------ |
|
15 | - * |
|
16 | - * EES_Shortcode |
|
17 | - * |
|
18 | - * @package Event Espresso |
|
19 | - * @subpackage /shortcodes/ |
|
20 | - * @author Brent Christensen |
|
21 | - * |
|
22 | - * ------------------------------------------------------------------------ |
|
23 | - */ |
|
3 | + * Event Espresso |
|
4 | + * |
|
5 | + * Event Registration and Management Plugin for WordPress |
|
6 | + * |
|
7 | + * @ package Event Espresso |
|
8 | + * @ author Event Espresso |
|
9 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
10 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
11 | + * @ link http://www.eventespresso.com |
|
12 | + * @ version 4.0 |
|
13 | + * |
|
14 | + * ------------------------------------------------------------------------ |
|
15 | + * |
|
16 | + * EES_Shortcode |
|
17 | + * |
|
18 | + * @package Event Espresso |
|
19 | + * @subpackage /shortcodes/ |
|
20 | + * @author Brent Christensen |
|
21 | + * |
|
22 | + * ------------------------------------------------------------------------ |
|
23 | + */ |
|
24 | 24 | abstract class EES_Shortcode extends EE_Base { |
25 | 25 | |
26 | 26 | /** |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param WP $WP |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - public abstract function run( WP $WP ); |
|
45 | + public abstract function run(WP $WP); |
|
46 | 46 | |
47 | 47 | |
48 | 48 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param array $attributes |
55 | 55 | * @return mixed |
56 | 56 | */ |
57 | - public abstract function process_shortcode( $attributes = array() ); |
|
57 | + public abstract function process_shortcode($attributes = array()); |
|
58 | 58 | |
59 | 59 | |
60 | 60 | |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * @param string $shortcode_class |
66 | 66 | * @return \EES_Shortcode |
67 | 67 | */ |
68 | - final public static function instance( $shortcode_class = NULL ) { |
|
69 | - $shortcode_class = ! empty( $shortcode_class ) ? $shortcode_class : get_called_class(); |
|
70 | - if ( $shortcode_class == 'EES_Shortcode' || empty( $shortcode_class )) { |
|
68 | + final public static function instance($shortcode_class = NULL) { |
|
69 | + $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
70 | + if ($shortcode_class == 'EES_Shortcode' || empty($shortcode_class)) { |
|
71 | 71 | return NULL; |
72 | 72 | } |
73 | - $shortcode = str_replace( 'EES_', '', strtoupper( $shortcode_class )); |
|
74 | - $shortcode_obj = isset( EE_Registry::instance()->shortcodes->{$shortcode} ) ? EE_Registry::instance()->shortcodes->{$shortcode} : NULL; |
|
73 | + $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
74 | + $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode} ) ? EE_Registry::instance()->shortcodes->{$shortcode} : NULL; |
|
75 | 75 | return $shortcode_obj instanceof $shortcode_class || $shortcode_class == 'self' ? $shortcode_obj : new $shortcode_class(); |
76 | 76 | } |
77 | 77 | |
@@ -86,23 +86,23 @@ discard block |
||
86 | 86 | * @param $attributes |
87 | 87 | * @return mixed |
88 | 88 | */ |
89 | - final public static function fallback_shortcode_processor( $attributes ) { |
|
90 | - if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) { |
|
89 | + final public static function fallback_shortcode_processor($attributes) { |
|
90 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
91 | 91 | return null; |
92 | 92 | } |
93 | 93 | // what shortcode was actually parsed ? |
94 | 94 | $shortcode_class = get_called_class(); |
95 | 95 | // notify rest of system that fallback processor was triggered |
96 | - add_filter( 'FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true' ); |
|
96 | + add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true'); |
|
97 | 97 | // get instance of actual shortcode |
98 | - $shortcode_obj = self::instance( $shortcode_class ); |
|
98 | + $shortcode_obj = self::instance($shortcode_class); |
|
99 | 99 | // verify class |
100 | - if ( $shortcode_obj instanceof EES_Shortcode ) { |
|
100 | + if ($shortcode_obj instanceof EES_Shortcode) { |
|
101 | 101 | global $wp; |
102 | - $shortcode_obj->run( $wp ); |
|
102 | + $shortcode_obj->run($wp); |
|
103 | 103 | // set attributes and run the shortcode |
104 | - $shortcode_obj->_attributes = (array)$attributes; |
|
105 | - return $shortcode_obj->process_shortcode( $shortcode_obj->_attributes ); |
|
104 | + $shortcode_obj->_attributes = (array) $attributes; |
|
105 | + return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
106 | 106 | } else { |
107 | 107 | return NULL; |
108 | 108 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param $attributes |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - final public static function invalid_shortcode_processor( $attributes ) { |
|
121 | + final public static function invalid_shortcode_processor($attributes) { |
|
122 | 122 | return ''; |
123 | 123 | } |
124 | 124 | |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | */ |
133 | 133 | final public function __construct() { |
134 | 134 | // get classname, remove EES_prefix, and convert to UPPERCASE |
135 | - $shortcode = strtoupper( str_replace( 'EES_', '', get_class( $this ))); |
|
135 | + $shortcode = strtoupper(str_replace('EES_', '', get_class($this))); |
|
136 | 136 | // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
137 | - add_shortcode( $shortcode, array( $this, 'process_shortcode' )); |
|
137 | + add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
138 | 138 | // make sure system knows this is an EE page |
139 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
139 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 |
@@ -1,21 +1,21 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | EE_Registry::instance()->load_class( 'Processor_Base' ); |
3 | 3 | /** |
4 | - * |
|
5 | - * EE_Payment_Processor |
|
6 | - * |
|
7 | - * Class for handling processing of payments for transactions. |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage core/libraries/payment_methods |
|
11 | - * @author Mike Nelson |
|
12 | - * |
|
13 | - */ |
|
4 | + * |
|
5 | + * EE_Payment_Processor |
|
6 | + * |
|
7 | + * Class for handling processing of payments for transactions. |
|
8 | + * |
|
9 | + * @package Event Espresso |
|
10 | + * @subpackage core/libraries/payment_methods |
|
11 | + * @author Mike Nelson |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_Payment_Processor extends EE_Processor_Base { |
15 | 15 | /** |
16 | - * @var EE_Payment_Processor $_instance |
|
16 | + * @var EE_Payment_Processor $_instance |
|
17 | 17 | * @access private |
18 | - */ |
|
18 | + */ |
|
19 | 19 | private static $_instance = NULL; |
20 | 20 | |
21 | 21 | |
@@ -48,9 +48,8 @@ discard block |
||
48 | 48 | |
49 | 49 | |
50 | 50 | /** |
51 | - |
|
52 | 51 | * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately. |
53 | - * Saves the payment that is generated |
|
52 | + * Saves the payment that is generated |
|
54 | 53 | * |
55 | 54 | * @param EE_Payment_Method $payment_method |
56 | 55 | * @param EE_Transaction $transaction |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * EE_Payment_Processor |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function instance() { |
29 | 29 | // check if class object is instantiated |
30 | - if ( ! self::$_instance instanceof EE_Payment_Processor ) { |
|
30 | + if ( ! self::$_instance instanceof EE_Payment_Processor) { |
|
31 | 31 | self::$_instance = new self(); |
32 | 32 | } |
33 | 33 | return self::$_instance; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | *@return EE_Payment_Processor |
43 | 43 | */ |
44 | 44 | private function __construct() { |
45 | - do_action( 'AHEE__EE_Payment_Processor__construct' ); |
|
45 | + do_action('AHEE__EE_Payment_Processor__construct'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -64,42 +64,42 @@ discard block |
||
64 | 64 | * @param string $cancel_url URL to return to if off-site payments are cancelled |
65 | 65 | * @return EE_Payment |
66 | 66 | */ |
67 | - public function process_payment( EE_Payment_Method $payment_method, EE_Transaction $transaction, $amount = NULL, $billing_form = NULL, $return_url = NULL, $method = 'CART', $by_admin = FALSE, $update_txn = TRUE, $cancel_url = '' ) { |
|
68 | - if( $amount < 0 ) { |
|
67 | + public function process_payment(EE_Payment_Method $payment_method, EE_Transaction $transaction, $amount = NULL, $billing_form = NULL, $return_url = NULL, $method = 'CART', $by_admin = FALSE, $update_txn = TRUE, $cancel_url = '') { |
|
68 | + if ($amount < 0) { |
|
69 | 69 | throw new EE_Error( |
70 | 70 | sprintf( |
71 | - __( 'Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', 'event_espresso' ), |
|
71 | + __('Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', 'event_espresso'), |
|
72 | 72 | $amount, |
73 | 73 | $transaction->ID() ) ); |
74 | 74 | } |
75 | 75 | // verify payment method |
76 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
76 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
77 | 77 | // verify transaction |
78 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
79 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
78 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
79 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
80 | 80 | // verify payment method type |
81 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ){ |
|
81 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
82 | 82 | $payment = $payment_method->type_obj()->process_payment( |
83 | 83 | $transaction, |
84 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
84 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
85 | 85 | $billing_form, |
86 | 86 | $return_url, |
87 | - add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ), |
|
87 | + add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
88 | 88 | $method, |
89 | 89 | $by_admin |
90 | 90 | ); |
91 | 91 | // check if payment method uses an off-site gateway |
92 | - if ( $payment_method->type_obj()->payment_occurs() != EE_PMT_Base::offsite ) { |
|
92 | + if ($payment_method->type_obj()->payment_occurs() != EE_PMT_Base::offsite) { |
|
93 | 93 | // don't process payments for off-site gateways yet because no payment has occurred yet |
94 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
94 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
95 | 95 | } |
96 | 96 | return $payment; |
97 | 97 | } else { |
98 | 98 | EE_Error::add_error( |
99 | 99 | sprintf( |
100 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
100 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
101 | 101 | '<br/>', |
102 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
102 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
103 | 103 | ), __FILE__, __FUNCTION__, __LINE__ |
104 | 104 | ); |
105 | 105 | return NULL; |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * @throws EE_Error |
116 | 116 | * @return string |
117 | 117 | */ |
118 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
118 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
119 | 119 | /** @type EE_Transaction $transaction */ |
120 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
120 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
121 | 121 | $primary_reg = $transaction->primary_registration(); |
122 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
123 | - throw new EE_Error(sprintf(__("Cannot get IPN URL for transaction with ID %d because it has no primary registration", "event_espresso"),$transaction->ID())); |
|
122 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
123 | + throw new EE_Error(sprintf(__("Cannot get IPN URL for transaction with ID %d because it has no primary registration", "event_espresso"), $transaction->ID())); |
|
124 | 124 | } |
125 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
125 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
126 | 126 | $url = add_query_arg( |
127 | 127 | array( |
128 | 128 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -149,81 +149,81 @@ discard block |
||
149 | 149 | * @throws Exception |
150 | 150 | * @return EE_Payment |
151 | 151 | */ |
152 | - public function process_ipn( $_req_data, $transaction = NULL, $payment_method = NULL, $update_txn = true, $separate_IPN_request = true ){ |
|
153 | - $_req_data = $this->_remove_unusable_characters( $_req_data ); |
|
154 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
155 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
156 | - if( $transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method ){ |
|
157 | - $obj_for_log = EEM_Payment::instance()->get_one( array( array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), 'order_by' => array( 'PAY_timestamp' => 'desc' ) ) ); |
|
158 | - }elseif( $payment_method instanceof EE_Payment ){ |
|
152 | + public function process_ipn($_req_data, $transaction = NULL, $payment_method = NULL, $update_txn = true, $separate_IPN_request = true) { |
|
153 | + $_req_data = $this->_remove_unusable_characters($_req_data); |
|
154 | + EE_Registry::instance()->load_model('Change_Log'); |
|
155 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
156 | + if ($transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method) { |
|
157 | + $obj_for_log = EEM_Payment::instance()->get_one(array(array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), 'order_by' => array('PAY_timestamp' => 'desc'))); |
|
158 | + }elseif ($payment_method instanceof EE_Payment) { |
|
159 | 159 | $obj_for_log = $payment_method; |
160 | - }elseif( $transaction instanceof EE_Transaction ){ |
|
160 | + }elseif ($transaction instanceof EE_Transaction) { |
|
161 | 161 | $obj_for_log = $transaction; |
162 | - }else{ |
|
162 | + } else { |
|
163 | 163 | $obj_for_log = null; |
164 | 164 | } |
165 | 165 | $log = EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data received'=>$_req_data), $obj_for_log); |
166 | - try{ |
|
166 | + try { |
|
167 | 167 | /** |
168 | 168 | * @var EE_Payment $payment |
169 | 169 | */ |
170 | 170 | $payment = NULL; |
171 | - if($transaction && $payment_method){ |
|
171 | + if ($transaction && $payment_method) { |
|
172 | 172 | /** @type EE_Transaction $transaction */ |
173 | 173 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
174 | 174 | /** @type EE_Payment_Method $payment_method */ |
175 | 175 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
176 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
177 | - $payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction ); |
|
176 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
177 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
178 | 178 | $log->set_object($payment); |
179 | 179 | } else { |
180 | 180 | // not a payment |
181 | 181 | EE_Error::add_error( |
182 | 182 | sprintf( |
183 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ), |
|
183 | + __('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'), |
|
184 | 184 | '<br/>', |
185 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
185 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
186 | 186 | ), |
187 | 187 | __FILE__, __FUNCTION__, __LINE__ |
188 | 188 | ); |
189 | 189 | } |
190 | - }else{ |
|
190 | + } else { |
|
191 | 191 | //that's actually pretty ok. The IPN just wasn't able |
192 | 192 | //to identify which transaction or payment method this was for |
193 | 193 | // give all active payment methods a chance to claim it |
194 | 194 | $active_pms = EEM_Payment_Method::instance()->get_all_active(); |
195 | - foreach( $active_pms as $payment_method ){ |
|
196 | - try{ |
|
197 | - $payment = $payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
195 | + foreach ($active_pms as $payment_method) { |
|
196 | + try { |
|
197 | + $payment = $payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
198 | 198 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment); |
199 | 199 | break; |
200 | - } catch( EE_Error $e ) { |
|
200 | + } catch (EE_Error $e) { |
|
201 | 201 | //that's fine- it apparently couldn't handle the IPN |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | 205 | } |
206 | 206 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
207 | - if( $payment instanceof EE_Payment){ |
|
207 | + if ($payment instanceof EE_Payment) { |
|
208 | 208 | $payment->save(); |
209 | 209 | // update the TXN |
210 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
211 | - }else{ |
|
210 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
211 | + } else { |
|
212 | 212 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
213 | - if($payment_method){ |
|
213 | + if ($payment_method) { |
|
214 | 214 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
215 | - }elseif($transaction){ |
|
215 | + }elseif ($transaction) { |
|
216 | 216 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
217 | 217 | } |
218 | 218 | } |
219 | 219 | return $payment; |
220 | 220 | |
221 | - } catch( EE_Error $e ) { |
|
221 | + } catch (EE_Error $e) { |
|
222 | 222 | do_action( |
223 | 223 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
224 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
225 | - print_r( $transaction, TRUE ), |
|
226 | - print_r( $_req_data, TRUE ), |
|
224 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
225 | + print_r($transaction, TRUE), |
|
226 | + print_r($_req_data, TRUE), |
|
227 | 227 | $e->getMessage() |
228 | 228 | ) |
229 | 229 | ); |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | * @param array $request_data |
238 | 238 | * @return array|string |
239 | 239 | */ |
240 | - protected function _remove_unusable_characters( $request_data ) { |
|
241 | - if( is_array( $request_data ) ) { |
|
240 | + protected function _remove_unusable_characters($request_data) { |
|
241 | + if (is_array($request_data)) { |
|
242 | 242 | $return_data = array(); |
243 | - foreach( $request_data as $key => $value ) { |
|
244 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
243 | + foreach ($request_data as $key => $value) { |
|
244 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
245 | 245 | } |
246 | - }else{ |
|
247 | - $return_data = preg_replace('/[^[:print:]]/', '', $request_data); |
|
246 | + } else { |
|
247 | + $return_data = preg_replace('/[^[:print:]]/', '', $request_data); |
|
248 | 248 | } |
249 | 249 | return $return_data; |
250 | 250 | } |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | * @return EE_Payment |
267 | 267 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, to call handle_ipn() for offsite gateways that don't receive separate IPNs |
268 | 268 | */ |
269 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
269 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
270 | 270 | /** @var $transaction EE_Transaction */ |
271 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
271 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
272 | 272 | $last_payment_method = $transaction->payment_method(); |
273 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
274 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
275 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
273 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
274 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
275 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
276 | 276 | return $payment; |
277 | 277 | } else { |
278 | 278 | return NULL; |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * @internal param float $amount |
290 | 290 | * @return EE_Payment |
291 | 291 | */ |
292 | - public function process_refund( EE_Payment_Method $payment_method, EE_Payment $payment_to_refund, $refund_info = array() ){ |
|
293 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
294 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
295 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
292 | + public function process_refund(EE_Payment_Method $payment_method, EE_Payment $payment_to_refund, $refund_info = array()) { |
|
293 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
294 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
295 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
296 | 296 | } |
297 | 297 | return $payment_to_refund; |
298 | 298 | } |
@@ -334,12 +334,12 @@ discard block |
||
334 | 334 | * TXN is locked before updating |
335 | 335 | * @throws \EE_Error |
336 | 336 | */ |
337 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
337 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
338 | 338 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
339 | 339 | /** @type EE_Transaction $transaction */ |
340 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
340 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
341 | 341 | // can we freely update the TXN at this moment? |
342 | - if ( $IPN && $transaction->is_locked() ) { |
|
342 | + if ($IPN && $transaction->is_locked()) { |
|
343 | 343 | // don't update the transaction at this exact moment |
344 | 344 | // because the TXN is active in another request |
345 | 345 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | ); |
350 | 350 | } else { |
351 | 351 | // verify payment and that it has been saved |
352 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
352 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
353 | 353 | //$this->log( |
354 | 354 | // __CLASS__, __FUNCTION__, __LINE__, |
355 | 355 | // $payment->transaction(), |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | // 'payment' => $payment, |
359 | 359 | // ) |
360 | 360 | //); |
361 | - if( $payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->type_obj() instanceof EE_PMT_Base ){ |
|
362 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
361 | + if ($payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->type_obj() instanceof EE_PMT_Base) { |
|
362 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
363 | 363 | //$this->log( |
364 | 364 | // __CLASS__, __FUNCTION__, __LINE__, |
365 | 365 | // $payment->transaction(), |
@@ -368,36 +368,36 @@ discard block |
||
368 | 368 | // ) |
369 | 369 | //); |
370 | 370 | // update TXN registrations with payment info |
371 | - $this->process_registration_payments( $transaction, $payment ); |
|
371 | + $this->process_registration_payments($transaction, $payment); |
|
372 | 372 | } |
373 | 373 | $do_action = $payment->just_approved() ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' : $do_action; |
374 | 374 | } else { |
375 | 375 | // send out notifications |
376 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
376 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
377 | 377 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
378 | 378 | } |
379 | 379 | // if this is an IPN, then we want to know the initial TXN status prior to updating the TXN |
380 | 380 | // so that we know whether the status has changed and notifications should be triggered |
381 | - if ( $IPN ) { |
|
381 | + if ($IPN) { |
|
382 | 382 | /** @type EE_Transaction_Processor $transaction_processor */ |
383 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
384 | - $transaction_processor->set_old_txn_status( $transaction->status_ID() ); |
|
383 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
384 | + $transaction_processor->set_old_txn_status($transaction->status_ID()); |
|
385 | 385 | } |
386 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
386 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
387 | 387 | /** @type EE_Transaction_Payments $transaction_payments */ |
388 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
388 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
389 | 389 | // set new value for total paid |
390 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
390 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
391 | 391 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
392 | - if ( $update_txn ) { |
|
393 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
392 | + if ($update_txn) { |
|
393 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | // granular hook for others to use. |
397 | - do_action( $do_action, $transaction, $payment ); |
|
398 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
397 | + do_action($do_action, $transaction, $payment); |
|
398 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
399 | 399 | //global hook for others to use. |
400 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
400 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
@@ -411,25 +411,25 @@ discard block |
||
411 | 411 | * @param EE_Registration[] $registrations |
412 | 412 | * @throws \EE_Error |
413 | 413 | */ |
414 | - public function process_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $registrations = array() ) { |
|
414 | + public function process_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $registrations = array()) { |
|
415 | 415 | // only process if payment was successful |
416 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
416 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
417 | 417 | return; |
418 | 418 | } |
419 | 419 | //EEM_Registration::instance()->show_next_x_db_queries(); |
420 | - if ( empty( $registrations )) { |
|
420 | + if (empty($registrations)) { |
|
421 | 421 | // find registrations with monies owing that can receive a payment |
422 | - $registrations = $transaction->registrations( array( |
|
422 | + $registrations = $transaction->registrations(array( |
|
423 | 423 | array( |
424 | 424 | // only these reg statuses can receive payments |
425 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
426 | - 'REG_final_price' => array( '!=', 0 ), |
|
427 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
425 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
426 | + 'REG_final_price' => array('!=', 0), |
|
427 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
428 | 428 | ) |
429 | - ) ); |
|
429 | + )); |
|
430 | 430 | } |
431 | 431 | // still nothing ??!?? |
432 | - if ( empty( $registrations )) { |
|
432 | + if (empty($registrations)) { |
|
433 | 433 | return; |
434 | 434 | } |
435 | 435 | // todo: break out the following logic into a separate strategy class |
@@ -441,28 +441,28 @@ discard block |
||
441 | 441 | |
442 | 442 | $refund = $payment->is_a_refund(); |
443 | 443 | // how much is available to apply to registrations? |
444 | - $available_payment_amount = abs( $payment->amount() ); |
|
445 | - foreach ( $registrations as $registration ) { |
|
446 | - if ( $registration instanceof EE_Registration ) { |
|
444 | + $available_payment_amount = abs($payment->amount()); |
|
445 | + foreach ($registrations as $registration) { |
|
446 | + if ($registration instanceof EE_Registration) { |
|
447 | 447 | // nothing left? |
448 | - if ( $available_payment_amount <= 0 ) { |
|
448 | + if ($available_payment_amount <= 0) { |
|
449 | 449 | break; |
450 | 450 | } |
451 | - if ( $refund ) { |
|
452 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
451 | + if ($refund) { |
|
452 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
453 | 453 | } else { |
454 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
454 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | } |
458 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
458 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
459 | 459 | EE_Error::add_attention( |
460 | 460 | sprintf( |
461 | - __( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ), |
|
462 | - EEH_Template::format_currency( $available_payment_amount ), |
|
463 | - implode( ', ', array_keys( $registrations ) ), |
|
461 | + __('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'), |
|
462 | + EEH_Template::format_currency($available_payment_amount), |
|
463 | + implode(', ', array_keys($registrations)), |
|
464 | 464 | '<br/>', |
465 | - EEH_Template::format_currency( $payment->amount() ) |
|
465 | + EEH_Template::format_currency($payment->amount()) |
|
466 | 466 | ), |
467 | 467 | __FILE__, __FUNCTION__, __LINE__ |
468 | 468 | ); |
@@ -479,17 +479,17 @@ discard block |
||
479 | 479 | * @param float $available_payment_amount |
480 | 480 | * @return float |
481 | 481 | */ |
482 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
482 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
483 | 483 | $owing = $registration->final_price() - $registration->paid(); |
484 | - if ( $owing > 0 ) { |
|
484 | + if ($owing > 0) { |
|
485 | 485 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
486 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
486 | + $payment_amount = min($available_payment_amount, $owing); |
|
487 | 487 | // update $available_payment_amount |
488 | 488 | $available_payment_amount = $available_payment_amount - $payment_amount; |
489 | 489 | //calculate and set new REG_paid |
490 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
490 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
491 | 491 | // now save it |
492 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
492 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
493 | 493 | } |
494 | 494 | return $available_payment_amount; |
495 | 495 | } |
@@ -504,19 +504,19 @@ discard block |
||
504 | 504 | * @param float $payment_amount |
505 | 505 | * @return float |
506 | 506 | */ |
507 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
507 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
508 | 508 | // find any existing reg payment records for this registration and payment |
509 | 509 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
510 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
510 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
511 | 511 | ); |
512 | 512 | // if existing registration payment exists |
513 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
513 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
514 | 514 | // then update that record |
515 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
515 | + $existing_reg_payment->set_amount($payment_amount); |
|
516 | 516 | $existing_reg_payment->save(); |
517 | 517 | } else { |
518 | 518 | // or add new relation between registration and payment and set amount |
519 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
519 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
520 | 520 | // make it stick |
521 | 521 | $registration->save(); |
522 | 522 | } |
@@ -532,21 +532,21 @@ discard block |
||
532 | 532 | * @param float $available_refund_amount - IMPORTANT !!! SEND AVAILABLE REFUND AMOUNT AS A POSITIVE NUMBER |
533 | 533 | * @return float |
534 | 534 | */ |
535 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
535 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
536 | 536 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
537 | - if ( $registration->paid() > 0 ) { |
|
537 | + if ($registration->paid() > 0) { |
|
538 | 538 | // ensure $available_refund_amount is NOT negative |
539 | - $available_refund_amount = abs( $available_refund_amount ); |
|
539 | + $available_refund_amount = abs($available_refund_amount); |
|
540 | 540 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
541 | - $refund_amount = min( $available_refund_amount, $registration->paid() ); |
|
541 | + $refund_amount = min($available_refund_amount, $registration->paid()); |
|
542 | 542 | // update $available_payment_amount |
543 | 543 | $available_refund_amount = $available_refund_amount - $refund_amount; |
544 | 544 | //calculate and set new REG_paid |
545 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
545 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
546 | 546 | // convert payment amount back to a negative value for storage in the db |
547 | - $refund_amount = abs( $refund_amount ) * -1; |
|
547 | + $refund_amount = abs($refund_amount) * -1; |
|
548 | 548 | // now save it |
549 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
549 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
550 | 550 | } |
551 | 551 | return $available_refund_amount; |
552 | 552 | } |
@@ -564,12 +564,12 @@ discard block |
||
564 | 564 | * @param EE_Payment $payment |
565 | 565 | * @param bool $IPN |
566 | 566 | */ |
567 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
567 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
568 | 568 | |
569 | 569 | /** @type EE_Transaction_Processor $transaction_processor */ |
570 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
570 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
571 | 571 | // is the Payment Options Reg Step completed ? |
572 | - $payment_options_step_completed = $transaction_processor->reg_step_completed( $transaction, 'payment_options' ); |
|
572 | + $payment_options_step_completed = $transaction_processor->reg_step_completed($transaction, 'payment_options'); |
|
573 | 573 | // DEBUG LOG |
574 | 574 | //$this->log( |
575 | 575 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -582,14 +582,14 @@ discard block |
||
582 | 582 | // if the Payment Options Reg Step is completed... |
583 | 583 | $revisit = $payment_options_step_completed === true ? true : false; |
584 | 584 | // then this is kinda sorta a revisit with regards to payments at least |
585 | - $transaction_processor->set_revisit( $revisit ); |
|
585 | + $transaction_processor->set_revisit($revisit); |
|
586 | 586 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
587 | 587 | if ( |
588 | 588 | $IPN && |
589 | 589 | $payment_options_step_completed !== true && |
590 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
590 | + ($payment->is_approved() || $payment->is_pending()) |
|
591 | 591 | ) { |
592 | - $payment_options_step_completed = $transaction_processor->set_reg_step_completed( $transaction, 'payment_options' ); |
|
592 | + $payment_options_step_completed = $transaction_processor->set_reg_step_completed($transaction, 'payment_options'); |
|
593 | 593 | } |
594 | 594 | // DEBUG LOG |
595 | 595 | //$this->log( |
@@ -601,11 +601,11 @@ discard block |
||
601 | 601 | // ) |
602 | 602 | //); |
603 | 603 | /** @type EE_Transaction_Payments $transaction_payments */ |
604 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
604 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
605 | 605 | // maybe update status, but don't save transaction just yet |
606 | - $transaction_payments->update_transaction_status_based_on_total_paid( $transaction, false ); |
|
606 | + $transaction_payments->update_transaction_status_based_on_total_paid($transaction, false); |
|
607 | 607 | // check if 'finalize_registration' step has been completed... |
608 | - $finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' ); |
|
608 | + $finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration'); |
|
609 | 609 | // DEBUG LOG |
610 | 610 | //$this->log( |
611 | 611 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -616,9 +616,9 @@ discard block |
||
616 | 616 | // ) |
617 | 617 | //); |
618 | 618 | // if this is an IPN and the final step has not been initiated |
619 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
619 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
620 | 620 | // and if it hasn't already been set as being started... |
621 | - $finalized = $transaction_processor->set_reg_step_initiated( $transaction, 'finalize_registration' ); |
|
621 | + $finalized = $transaction_processor->set_reg_step_initiated($transaction, 'finalize_registration'); |
|
622 | 622 | // DEBUG LOG |
623 | 623 | //$this->log( |
624 | 624 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -631,13 +631,13 @@ discard block |
||
631 | 631 | } |
632 | 632 | $transaction->save(); |
633 | 633 | // because the above will return false if the final step was not fully completed, we need to check again... |
634 | - if ( $IPN && $finalized !== false ) { |
|
634 | + if ($IPN && $finalized !== false) { |
|
635 | 635 | // and if we are all good to go, then send out notifications |
636 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
636 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
637 | 637 | // DEBUG LOG |
638 | 638 | //$this->log( __CLASS__, __FUNCTION__, __LINE__, $transaction ); |
639 | 639 | //ok, now process the transaction according to the payment |
640 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
640 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
641 | 641 | } |
642 | 642 | // DEBUG LOG |
643 | 643 | //$this->log( |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This template will display The Loop that displays your venues |
|
4 | - * |
|
5 | - * @ package Event Espresso |
|
6 | - * @ author Seth Shoultes |
|
7 | - * @ copyright (c) 2008-2013 Event Espresso All Rights Reserved. |
|
8 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
9 | - * @ link http://www.eventespresso.com |
|
10 | - * @ version 4+ |
|
11 | - */ |
|
3 | + * This template will display The Loop that displays your venues |
|
4 | + * |
|
5 | + * @ package Event Espresso |
|
6 | + * @ author Seth Shoultes |
|
7 | + * @ copyright (c) 2008-2013 Event Espresso All Rights Reserved. |
|
8 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
9 | + * @ link http://www.eventespresso.com |
|
10 | + * @ version 4+ |
|
11 | + */ |
|
12 | 12 | |
13 | 13 | if ( have_posts() ) : ?> |
14 | 14 |
@@ -1,28 +1,28 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EEM_Base |
|
5 | - * |
|
6 | - * Multi-table model. Especially handles joins when querying. |
|
7 | - * An important note about values dealt with in models and model objects: |
|
8 | - * values used by models exist in basically 3 different domains, which the EE_Model_Fields help convert between: |
|
9 | - * 1. Client-code values (eg, controller code may refer to a date as "March 21, 2013") |
|
10 | - * 2. Model object values (eg, after the model object has called set() on the value and saves it onto the model object, it may become a unix timestamp, eg 12312412412) |
|
11 | - * 3. Database values (eg, we may later decide to store dates as mysql dates, in which case they'd be stored as '2013-03-21 00:00:00') |
|
12 | - * Sometimes these values are the same, but often they are not. When your client code is using a model's functions, you need to be aware |
|
13 | - * which domain your data exists in. If it is client-code values (ie, it hasn't had a EE_Model_Field call prepare_for_set on it) then use the |
|
14 | - * model functions as normal. However, if you are calling the model functions with values from the model object domain (ie, the code your writing is |
|
15 | - * probably within a model object, and all the values you're dealing with have had an EE_Model_Field call prepare_for_set on them), then you'll want |
|
16 | - * to set $values_already_prepared_by_model_object to FALSE within the argument-list of the functions you call (in order to avoid re-processing those values). |
|
17 | - * If your values are already in the database values domain, you'll either way to convert them into the model object domain by creating model objects |
|
18 | - * from those raw db values (ie,using EEM_Base::_create_objects), or just use $wpdb directly. |
|
19 | - * |
|
20 | - * @package Event Espresso |
|
21 | - * @subpackage core |
|
22 | - * @author Michael Nelson |
|
23 | - * @since EE4 |
|
24 | - * |
|
25 | - */ |
|
3 | + * |
|
4 | + * Class EEM_Base |
|
5 | + * |
|
6 | + * Multi-table model. Especially handles joins when querying. |
|
7 | + * An important note about values dealt with in models and model objects: |
|
8 | + * values used by models exist in basically 3 different domains, which the EE_Model_Fields help convert between: |
|
9 | + * 1. Client-code values (eg, controller code may refer to a date as "March 21, 2013") |
|
10 | + * 2. Model object values (eg, after the model object has called set() on the value and saves it onto the model object, it may become a unix timestamp, eg 12312412412) |
|
11 | + * 3. Database values (eg, we may later decide to store dates as mysql dates, in which case they'd be stored as '2013-03-21 00:00:00') |
|
12 | + * Sometimes these values are the same, but often they are not. When your client code is using a model's functions, you need to be aware |
|
13 | + * which domain your data exists in. If it is client-code values (ie, it hasn't had a EE_Model_Field call prepare_for_set on it) then use the |
|
14 | + * model functions as normal. However, if you are calling the model functions with values from the model object domain (ie, the code your writing is |
|
15 | + * probably within a model object, and all the values you're dealing with have had an EE_Model_Field call prepare_for_set on them), then you'll want |
|
16 | + * to set $values_already_prepared_by_model_object to FALSE within the argument-list of the functions you call (in order to avoid re-processing those values). |
|
17 | + * If your values are already in the database values domain, you'll either way to convert them into the model object domain by creating model objects |
|
18 | + * from those raw db values (ie,using EEM_Base::_create_objects), or just use $wpdb directly. |
|
19 | + * |
|
20 | + * @package Event Espresso |
|
21 | + * @subpackage core |
|
22 | + * @author Michael Nelson |
|
23 | + * @since EE4 |
|
24 | + * |
|
25 | + */ |
|
26 | 26 | abstract class EEM_Base extends EE_Base{ |
27 | 27 | |
28 | 28 | //admin posty |
@@ -578,10 +578,10 @@ discard block |
||
578 | 578 | $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) ); |
579 | 579 | $status_array = array(); |
580 | 580 | foreach ( $stati as $status ) { |
581 | - $status_array[ $status->ID() ] = $status->get('STS_code'); |
|
582 | - } |
|
583 | - return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array; |
|
584 | - } |
|
581 | + $status_array[ $status->ID() ] = $status->get('STS_code'); |
|
582 | + } |
|
583 | + return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array; |
|
584 | + } |
|
585 | 585 | |
586 | 586 | |
587 | 587 |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
3 | 3 | /** |
4 | - * Event Espresso |
|
5 | - * |
|
6 | - * Event Registration and Management Plugin for WordPress |
|
7 | - * |
|
8 | - * @ package Event Espresso |
|
9 | - * @ author Seth Shoultes |
|
10 | - * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
11 | - * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
12 | - * @ link {@link http://www.eventespresso.com} |
|
13 | - * @ since 4.0 |
|
14 | - * |
|
15 | - */ |
|
4 | + * Event Espresso |
|
5 | + * |
|
6 | + * Event Registration and Management Plugin for WordPress |
|
7 | + * |
|
8 | + * @ package Event Espresso |
|
9 | + * @ author Seth Shoultes |
|
10 | + * @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
|
11 | + * @ license {@link http://eventespresso.com/support/terms-conditions/} * see Plugin Licensing * |
|
12 | + * @ link {@link http://www.eventespresso.com} |
|
13 | + * @ since 4.0 |
|
14 | + * |
|
15 | + */ |
|
16 | 16 | |
17 | 17 | |
18 | 18 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | -do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | +do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
3 | 3 | /** |
4 | 4 | * Event Espresso |
5 | 5 | * |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @subpackage includes/classes/EE_Checkin.class.php |
24 | 24 | * @author Darren Ethier |
25 | 25 | */ |
26 | -class EE_Checkin extends EE_Base_Class{ |
|
26 | +class EE_Checkin extends EE_Base_Class { |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | * date_format and the second value is the time format |
35 | 35 | * @return EE_Checkin |
36 | 36 | */ |
37 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
38 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
39 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
37 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
38 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
39 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * the website will be used. |
48 | 48 | * @return EE_Checkin |
49 | 49 | */ |
50 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
51 | - return new self( $props_n_values, TRUE, $timezone ); |
|
50 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
51 | + return new self($props_n_values, TRUE, $timezone); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Espresso Template functions |
|
4 | - * |
|
5 | - * @ package Event Espresso |
|
6 | - * @ author Seth Shoultes |
|
7 | - * @ copyright (c) 2008-2014 Event Espresso All Rights Reserved. |
|
8 | - * @ license http://venueespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
9 | - * @ link http://www.eventespresso.com |
|
10 | - * @ version 4+ |
|
11 | - */ |
|
3 | + * Espresso Template functions |
|
4 | + * |
|
5 | + * @ package Event Espresso |
|
6 | + * @ author Seth Shoultes |
|
7 | + * @ copyright (c) 2008-2014 Event Espresso All Rights Reserved. |
|
8 | + * @ license http://venueespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
9 | + * @ link http://www.eventespresso.com |
|
10 | + * @ version 4+ |
|
11 | + */ |
|
12 | 12 | define( 'EE_THEME_FUNCTIONS_LOADED', TRUE ); |
13 | 13 | |
14 | 14 | /** |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | * @ link http://www.eventespresso.com |
10 | 10 | * @ version 4+ |
11 | 11 | */ |
12 | -define( 'EE_THEME_FUNCTIONS_LOADED', TRUE ); |
|
12 | +define('EE_THEME_FUNCTIONS_LOADED', TRUE); |
|
13 | 13 | |
14 | -if ( ! function_exists( 'espresso_pagination' ) ) { |
|
14 | +if ( ! function_exists('espresso_pagination')) { |
|
15 | 15 | /** |
16 | 16 | * espresso_pagination |
17 | 17 | * |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | $big = 999999999; // need an unlikely integer |
24 | 24 | $pagination = paginate_links( |
25 | 25 | array( |
26 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
26 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
27 | 27 | 'format' => '?paged=%#%', |
28 | - 'current' => max( 1, get_query_var( 'paged' ) ), |
|
28 | + 'current' => max(1, get_query_var('paged')), |
|
29 | 29 | 'total' => $wp_query->max_num_pages, |
30 | 30 | 'show_all' => true, |
31 | 31 | 'end_size' => 10, |
32 | 32 | 'mid_size' => 6, |
33 | 33 | 'prev_next' => true, |
34 | - 'prev_text' => __( '‹ PREV', 'event_espresso' ), |
|
35 | - 'next_text' => __( 'NEXT ›', 'event_espresso' ), |
|
34 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
35 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
36 | 36 | 'type' => 'plain', |
37 | 37 | 'add_args' => false, |
38 | 38 | 'add_fragment' => '' |
39 | 39 | ) |
40 | 40 | ); |
41 | - echo ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
41 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | /** |
3 | - * Single Page Checkout (SPCO) |
|
4 | - * |
|
5 | - * @package Event Espresso |
|
6 | - * @subpackage /modules/single_page_checkout/ |
|
7 | - * @author Brent Christensen |
|
8 | - * |
|
9 | - */ |
|
3 | + * Single Page Checkout (SPCO) |
|
4 | + * |
|
5 | + * @package Event Espresso |
|
6 | + * @subpackage /modules/single_page_checkout/ |
|
7 | + * @author Brent Christensen |
|
8 | + * |
|
9 | + */ |
|
10 | 10 | class EED_Single_Page_Checkout extends EED_Module { |
11 | 11 | |
12 | 12 |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @return EED_Single_Page_Checkout |
39 | 39 | */ |
40 | 40 | public static function instance() { |
41 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
42 | - return parent::get_instance( __CLASS__ ); |
|
41 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
42 | + return parent::get_instance(__CLASS__); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -84,22 +84,22 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public static function set_hooks_admin() { |
86 | 86 | EED_Single_Page_Checkout::set_definitions(); |
87 | - if ( defined( 'DOING_AJAX' )) { |
|
87 | + if (defined('DOING_AJAX')) { |
|
88 | 88 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
89 | 89 | ob_start(); |
90 | 90 | EED_Single_Page_Checkout::load_request_handler(); |
91 | 91 | EED_Single_Page_Checkout::load_reg_steps(); |
92 | 92 | } else { |
93 | 93 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
94 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
94 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
95 | 95 | } |
96 | 96 | // set ajax hooks |
97 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
98 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
99 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
100 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
101 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
102 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
97 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
98 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
99 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
100 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
101 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
102 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * process ajax request |
109 | 109 | * @param string $ajax_action |
110 | 110 | */ |
111 | - public static function process_ajax_request( $ajax_action ) { |
|
112 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
111 | + public static function process_ajax_request($ajax_action) { |
|
112 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
113 | 113 | EED_Single_Page_Checkout::instance()->_initialize(); |
114 | 114 | } |
115 | 115 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * ajax display registration step |
120 | 120 | */ |
121 | 121 | public static function display_reg_step() { |
122 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
122 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * ajax process registration step |
129 | 129 | */ |
130 | 130 | public static function process_reg_step() { |
131 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
131 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * ajax process registration step |
138 | 138 | */ |
139 | 139 | public static function update_reg_step() { |
140 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
140 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return void |
150 | 150 | */ |
151 | 151 | public static function update_checkout() { |
152 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
152 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public static function load_request_handler() { |
164 | 164 | // load core Request_Handler class |
165 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
166 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
165 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
166 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -176,21 +176,21 @@ discard block |
||
176 | 176 | * @return void |
177 | 177 | */ |
178 | 178 | public static function set_definitions() { |
179 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
180 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
181 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
182 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
183 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
184 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
185 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
186 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
187 | - EE_Registry::$i18n_js_strings[ 'registration_expiration_notice' ] = sprintf( |
|
188 | - __( '%1$sWe\'re sorry, but you\'re registration time has expired.%2$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 except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
179 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
180 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
181 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
182 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
183 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
184 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
185 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
186 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
187 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
188 | + __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$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 except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
189 | 189 | '<h4 class="important-notice">', |
190 | 190 | '</h4>', |
191 | 191 | '<br />', |
192 | 192 | '<p>', |
193 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
193 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
194 | 194 | '">', |
195 | 195 | '</a>', |
196 | 196 | '</p>' |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | public static function load_reg_steps() { |
211 | 211 | static $reg_steps_loaded = FALSE; |
212 | - if ( $reg_steps_loaded ) { |
|
212 | + if ($reg_steps_loaded) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | // filter list of reg_steps |
@@ -218,24 +218,24 @@ discard block |
||
218 | 218 | EED_Single_Page_Checkout::get_reg_steps() |
219 | 219 | ); |
220 | 220 | // sort by key (order) |
221 | - ksort( $reg_steps_to_load ); |
|
221 | + ksort($reg_steps_to_load); |
|
222 | 222 | // loop through folders |
223 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
223 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
224 | 224 | // we need a |
225 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
225 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
226 | 226 | // copy over to the reg_steps_array |
227 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
227 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
228 | 228 | // register custom key route for each reg step |
229 | 229 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
230 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
230 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
231 | 231 | // add AJAX or other hooks |
232 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
232 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
233 | 233 | // setup autoloaders if necessary |
234 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
235 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
234 | + if ( ! class_exists($reg_step['class_name'])) { |
|
235 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
236 | 236 | } |
237 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
238 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
237 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
238 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | } |
@@ -254,28 +254,28 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public static function get_reg_steps() { |
256 | 256 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
257 | - if ( empty( $reg_steps )) { |
|
257 | + if (empty($reg_steps)) { |
|
258 | 258 | $reg_steps = array( |
259 | 259 | 10 => array( |
260 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
260 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
261 | 261 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
262 | 262 | 'slug' => 'attendee_information', |
263 | 263 | 'has_hooks' => FALSE |
264 | 264 | ), |
265 | 265 | 20 => array( |
266 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
266 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
267 | 267 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
268 | 268 | 'slug' => 'registration_confirmation', |
269 | 269 | 'has_hooks' => FALSE |
270 | 270 | ), |
271 | 271 | 30 => array( |
272 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
272 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
273 | 273 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
274 | 274 | 'slug' => 'payment_options', |
275 | 275 | 'has_hooks' => TRUE |
276 | 276 | ), |
277 | 277 | 999 => array( |
278 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
278 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
279 | 279 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
280 | 280 | 'slug' => 'finalize_registration', |
281 | 281 | 'has_hooks' => FALSE |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public static function registration_checkout_for_admin() { |
297 | 297 | EED_Single_Page_Checkout::load_reg_steps(); |
298 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
299 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
300 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
298 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
299 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
300 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
301 | 301 | EED_Single_Page_Checkout::instance()->_initialize(); |
302 | 302 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
303 | 303 | return EE_Registry::instance()->REQ->get_output(); |
@@ -313,15 +313,15 @@ discard block |
||
313 | 313 | */ |
314 | 314 | public static function process_registration_from_admin() { |
315 | 315 | EED_Single_Page_Checkout::load_reg_steps(); |
316 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
317 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
318 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
316 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
317 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
318 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
319 | 319 | EED_Single_Page_Checkout::instance()->_initialize(); |
320 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
321 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
322 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
323 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step ); |
|
324 | - if ( $final_reg_step->process_reg_step() ) { |
|
320 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
321 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
322 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
323 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
324 | + if ($final_reg_step->process_reg_step()) { |
|
325 | 325 | $final_reg_step->set_completed(); |
326 | 326 | EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
327 | 327 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
@@ -340,11 +340,11 @@ discard block |
||
340 | 340 | * @param WP_Query $WP_Query |
341 | 341 | * @return void |
342 | 342 | */ |
343 | - public function run( $WP_Query ) { |
|
343 | + public function run($WP_Query) { |
|
344 | 344 | if ( |
345 | 345 | $WP_Query instanceof WP_Query |
346 | 346 | && $WP_Query->is_main_query() |
347 | - && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
|
347 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
348 | 348 | ) { |
349 | 349 | $this->_initialize(); |
350 | 350 | } |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | * @param WP_Query $WP_Query |
361 | 361 | * @return void |
362 | 362 | */ |
363 | - public static function init( $WP_Query ) { |
|
364 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
363 | + public static function init($WP_Query) { |
|
364 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | |
@@ -375,29 +375,29 @@ discard block |
||
375 | 375 | */ |
376 | 376 | private function _initialize() { |
377 | 377 | // ensure SPCO doesn't run twice |
378 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
378 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
379 | 379 | return; |
380 | 380 | } |
381 | 381 | $this->_verify_session(); |
382 | 382 | // setup the EE_Checkout object |
383 | 383 | $this->checkout = $this->_initialize_checkout(); |
384 | 384 | // filter checkout |
385 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
385 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
386 | 386 | // get the $_GET |
387 | 387 | $this->_get_request_vars(); |
388 | 388 | // filter continue_reg |
389 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
389 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
390 | 390 | // load the reg steps array |
391 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
391 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
392 | 392 | EED_Single_Page_Checkout::$_initialized = true; |
393 | 393 | return; |
394 | 394 | } |
395 | 395 | // set the current step |
396 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
396 | + $this->checkout->set_current_step($this->checkout->step); |
|
397 | 397 | // and the next step |
398 | 398 | $this->checkout->set_next_step(); |
399 | 399 | // verify that everything has been setup correctly |
400 | - if ( ! ( $this->_verify_transaction_and_get_registrations() && $this->_final_verifications() ) ) { |
|
400 | + if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
401 | 401 | EED_Single_Page_Checkout::$_initialized = true; |
402 | 402 | return; |
403 | 403 | } |
@@ -422,9 +422,9 @@ discard block |
||
422 | 422 | // set no cache headers and constants |
423 | 423 | EE_System::do_not_cache(); |
424 | 424 | // add anchor |
425 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
425 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
426 | 426 | // remove transaction lock |
427 | - add_action( 'shutdown', array( $this, 'unlock_transaction' ), 1 ); |
|
427 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | |
@@ -437,16 +437,16 @@ discard block |
||
437 | 437 | * @throws EE_Error |
438 | 438 | */ |
439 | 439 | private function _verify_session() { |
440 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
441 | - throw new EE_Error( __( 'The EE_Session class could not be loaded.', 'event_espresso' ) ); |
|
440 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
441 | + throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
442 | 442 | } |
443 | 443 | // is session still valid ? |
444 | - if ( EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ) === '' ) { |
|
444 | + if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') { |
|
445 | 445 | $this->checkout = new EE_Checkout(); |
446 | 446 | EE_Registry::instance()->SSN->reset_cart(); |
447 | 447 | EE_Registry::instance()->SSN->reset_checkout(); |
448 | 448 | EE_Registry::instance()->SSN->reset_transaction(); |
449 | - EE_Error::add_attention( EE_Registry::$i18n_js_strings[ 'registration_expiration_notice' ], __FILE__, __FUNCTION__, __LINE__ ); |
|
449 | + EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__, __FUNCTION__, __LINE__); |
|
450 | 450 | EE_Registry::instance()->SSN->reset_expired(); |
451 | 451 | } |
452 | 452 | } |
@@ -466,20 +466,20 @@ discard block |
||
466 | 466 | /** @type EE_Checkout $checkout */ |
467 | 467 | $checkout = EE_Registry::instance()->SSN->checkout(); |
468 | 468 | // verify |
469 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
469 | + if ( ! $checkout instanceof EE_Checkout) { |
|
470 | 470 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
471 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
471 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
472 | 472 | // verify again |
473 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
474 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
473 | + if ( ! $checkout instanceof EE_Checkout) { |
|
474 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
475 | 475 | } |
476 | 476 | } else { |
477 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
478 | - wp_safe_redirect( $checkout->redirect_url ); |
|
477 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
478 | + wp_safe_redirect($checkout->redirect_url); |
|
479 | 479 | exit(); |
480 | 480 | } |
481 | 481 | } |
482 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
482 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
483 | 483 | // reset anything that needs a clean slate for each request |
484 | 484 | $checkout->reset_for_current_request(); |
485 | 485 | return $checkout; |
@@ -497,24 +497,24 @@ discard block |
||
497 | 497 | // load classes |
498 | 498 | EED_Single_Page_Checkout::load_request_handler(); |
499 | 499 | //make sure this request is marked as belonging to EE |
500 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
500 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
501 | 501 | // which step is being requested ? |
502 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
502 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
503 | 503 | // which step is being edited ? |
504 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
504 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
505 | 505 | // and what we're doing on the current step |
506 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
506 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
507 | 507 | // returning to edit ? |
508 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
508 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
509 | 509 | // or some other kind of revisit ? |
510 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
510 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
511 | 511 | // and whether or not to generate a reg form for this request |
512 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
512 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
513 | 513 | // and whether or not to process a reg form submission for this request |
514 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
514 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
515 | 515 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
516 | 516 | ? $this->checkout->process_form_submission |
517 | - : FALSE; // TRUE FALSE |
|
517 | + : FALSE; // TRUE FALSE |
|
518 | 518 | //$this->_display_request_vars(); |
519 | 519 | } |
520 | 520 | |
@@ -527,17 +527,17 @@ discard block |
||
527 | 527 | * @return void |
528 | 528 | */ |
529 | 529 | protected function _display_request_vars() { |
530 | - if ( ! WP_DEBUG ) { |
|
530 | + if ( ! WP_DEBUG) { |
|
531 | 531 | return; |
532 | 532 | } |
533 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
534 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
535 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
536 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
537 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
538 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
539 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
540 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
533 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
534 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
535 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
536 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
537 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
538 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
539 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
540 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | |
@@ -551,8 +551,8 @@ discard block |
||
551 | 551 | * @return array |
552 | 552 | */ |
553 | 553 | private function _get_first_step() { |
554 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
555 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
554 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
555 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | |
@@ -568,27 +568,27 @@ discard block |
||
568 | 568 | private function _load_and_instantiate_reg_steps() { |
569 | 569 | // have reg_steps already been instantiated ? |
570 | 570 | if ( |
571 | - empty( $this->checkout->reg_steps ) || |
|
572 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
571 | + empty($this->checkout->reg_steps) || |
|
572 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
573 | 573 | ) { |
574 | 574 | // if not, then loop through raw reg steps array |
575 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
576 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
575 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
576 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
577 | 577 | return false; |
578 | 578 | } |
579 | 579 | } |
580 | 580 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
581 | 581 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
582 | 582 | // skip the registration_confirmation page ? |
583 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
583 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
584 | 584 | // just remove it from the reg steps array |
585 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
585 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
586 | 586 | } else if ( |
587 | 587 | EE_Registry::instance()->CFG->registration->reg_confirmation_last |
588 | - && isset( $this->checkout->reg_steps['registration_confirmation'] ) |
|
588 | + && isset($this->checkout->reg_steps['registration_confirmation']) |
|
589 | 589 | ) { |
590 | 590 | // set the order to something big like 100 |
591 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
591 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
592 | 592 | } |
593 | 593 | // filter the array for good luck |
594 | 594 | $this->checkout->reg_steps = apply_filters( |
@@ -598,13 +598,13 @@ discard block |
||
598 | 598 | // finally re-sort based on the reg step class order properties |
599 | 599 | $this->checkout->sort_reg_steps(); |
600 | 600 | } else { |
601 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
601 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
602 | 602 | // set all current step stati to FALSE |
603 | - $reg_step->set_is_current_step( FALSE ); |
|
603 | + $reg_step->set_is_current_step(FALSE); |
|
604 | 604 | } |
605 | 605 | } |
606 | - if ( empty( $this->checkout->reg_steps )) { |
|
607 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
606 | + if (empty($this->checkout->reg_steps)) { |
|
607 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
608 | 608 | return false; |
609 | 609 | } |
610 | 610 | // make reg step details available to JS |
@@ -622,10 +622,10 @@ discard block |
||
622 | 622 | * @param int $order |
623 | 623 | * @return bool |
624 | 624 | */ |
625 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
625 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
626 | 626 | |
627 | 627 | // we need a file_path, class_name, and slug to add a reg step |
628 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
628 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
629 | 629 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
630 | 630 | if ( |
631 | 631 | $this->checkout->reg_url_link |
@@ -643,26 +643,26 @@ discard block |
||
643 | 643 | FALSE |
644 | 644 | ); |
645 | 645 | // did we gets the goods ? |
646 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
646 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
647 | 647 | // set reg step order based on config |
648 | - $reg_step_obj->set_order( $order ); |
|
648 | + $reg_step_obj->set_order($order); |
|
649 | 649 | // add instantiated reg step object to the master reg steps array |
650 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
650 | + $this->checkout->add_reg_step($reg_step_obj); |
|
651 | 651 | } else { |
652 | 652 | EE_Error::add_error( |
653 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
653 | + __('The current step could not be set.', 'event_espresso'), |
|
654 | 654 | __FILE__, __FUNCTION__, __LINE__ |
655 | 655 | ); |
656 | 656 | return false; |
657 | 657 | } |
658 | 658 | } else { |
659 | - if ( WP_DEBUG ) { |
|
659 | + if (WP_DEBUG) { |
|
660 | 660 | EE_Error::add_error( |
661 | 661 | sprintf( |
662 | - __( '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', 'event_espresso' ), |
|
663 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
664 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
665 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
662 | + __('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', 'event_espresso'), |
|
663 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
664 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
665 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
666 | 666 | '<ul>', |
667 | 667 | '<li>', |
668 | 668 | '</li>', |
@@ -686,15 +686,15 @@ discard block |
||
686 | 686 | */ |
687 | 687 | private function _verify_transaction_and_get_registrations() { |
688 | 688 | // was there already a valid transaction in the checkout from the session ? |
689 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
689 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
690 | 690 | // get transaction from db or session |
691 | 691 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
692 | 692 | ? $this->_get_transaction_and_cart_for_previous_visit() |
693 | 693 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
694 | 694 | |
695 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
695 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
696 | 696 | EE_Error::add_error( |
697 | - __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), |
|
697 | + __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
698 | 698 | __FILE__, __FUNCTION__, __LINE__ |
699 | 699 | ); |
700 | 700 | $this->checkout->transaction = EE_Transaction::new_instance(); |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | return false; |
705 | 705 | } |
706 | 706 | // and the registrations for the transaction |
707 | - $this->_get_registrations( $this->checkout->transaction ); |
|
707 | + $this->_get_registrations($this->checkout->transaction); |
|
708 | 708 | } |
709 | 709 | return true; |
710 | 710 | } |
@@ -719,16 +719,16 @@ discard block |
||
719 | 719 | */ |
720 | 720 | private function _get_transaction_and_cart_for_previous_visit() { |
721 | 721 | /** @var $TXN_model EEM_Transaction */ |
722 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
722 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
723 | 723 | // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
724 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
724 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
725 | 725 | // verify transaction |
726 | - if ( $transaction instanceof EE_Transaction ) { |
|
726 | + if ($transaction instanceof EE_Transaction) { |
|
727 | 727 | // and get the cart that was used for that transaction |
728 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
728 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
729 | 729 | return $transaction; |
730 | 730 | } else { |
731 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
731 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
732 | 732 | return NULL; |
733 | 733 | } |
734 | 734 | } |
@@ -742,11 +742,11 @@ discard block |
||
742 | 742 | * @param EE_Transaction $transaction |
743 | 743 | * @return EE_Cart |
744 | 744 | */ |
745 | - private function _get_cart_for_transaction( $transaction ) { |
|
746 | - $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn( $transaction ) : NULL; |
|
745 | + private function _get_cart_for_transaction($transaction) { |
|
746 | + $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction) : NULL; |
|
747 | 747 | // verify cart |
748 | - if ( ! $cart instanceof EE_Cart ) { |
|
749 | - $cart = EE_Registry::instance()->load_core( 'Cart' ); |
|
748 | + if ( ! $cart instanceof EE_Cart) { |
|
749 | + $cart = EE_Registry::instance()->load_core('Cart'); |
|
750 | 750 | } |
751 | 751 | return $cart; |
752 | 752 | } |
@@ -761,8 +761,8 @@ discard block |
||
761 | 761 | * @param EE_Transaction $transaction |
762 | 762 | * @return EE_Cart |
763 | 763 | */ |
764 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
765 | - return EE_Cart::get_cart_from_txn( $transaction ); |
|
764 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
765 | + return EE_Cart::get_cart_from_txn($transaction); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | |
@@ -777,15 +777,15 @@ discard block |
||
777 | 777 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
778 | 778 | // if there's no transaction, then this is the FIRST visit to SPCO |
779 | 779 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
780 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
780 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
781 | 781 | // and then create a new transaction |
782 | 782 | $transaction = $this->_initialize_transaction(); |
783 | 783 | // verify transaction |
784 | - if ( $transaction instanceof EE_Transaction ) { |
|
784 | + if ($transaction instanceof EE_Transaction) { |
|
785 | 785 | // and save TXN data to the cart |
786 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
786 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
787 | 787 | } else { |
788 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
788 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
789 | 789 | } |
790 | 790 | return $transaction; |
791 | 791 | } |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | // grab the cart grand total |
806 | 806 | $cart_total = $this->checkout->cart->get_cart_grand_total(); |
807 | 807 | // create new TXN |
808 | - $transaction = EE_Transaction::new_instance( array( |
|
808 | + $transaction = EE_Transaction::new_instance(array( |
|
809 | 809 | 'TXN_timestamp' => time(), |
810 | 810 | 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
811 | 811 | 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
@@ -820,8 +820,8 @@ discard block |
||
820 | 820 | $transaction->ID() |
821 | 821 | ); |
822 | 822 | return $transaction; |
823 | - } catch( Exception $e ) { |
|
824 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
823 | + } catch (Exception $e) { |
|
824 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
825 | 825 | } |
826 | 826 | return NULL; |
827 | 827 | } |
@@ -835,34 +835,34 @@ discard block |
||
835 | 835 | * @param EE_Transaction $transaction |
836 | 836 | * @return EE_Cart |
837 | 837 | */ |
838 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
838 | + private function _get_registrations(EE_Transaction $transaction) { |
|
839 | 839 | // first step: grab the registrants { : o |
840 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
840 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
841 | 841 | // verify registrations have been set |
842 | - if ( empty( $registrations )) { |
|
842 | + if (empty($registrations)) { |
|
843 | 843 | // if no cached registrations, then check the db |
844 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
844 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
845 | 845 | // still nothing ? well as long as this isn't a revisit |
846 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
846 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
847 | 847 | // generate new registrations from scratch |
848 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
848 | + $registrations = $this->_initialize_registrations($transaction); |
|
849 | 849 | } |
850 | 850 | } |
851 | 851 | // sort by their original registration order |
852 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
852 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
853 | 853 | // then loop thru the array |
854 | - foreach ( $registrations as $registration ) { |
|
854 | + foreach ($registrations as $registration) { |
|
855 | 855 | // verify each registration |
856 | - if ( $registration instanceof EE_Registration ) { |
|
856 | + if ($registration instanceof EE_Registration) { |
|
857 | 857 | // we display all attendee info for the primary registrant |
858 | - if ( $this->checkout->reg_url_link == $registration->reg_url_link() && $registration->is_primary_registrant() ) { |
|
858 | + if ($this->checkout->reg_url_link == $registration->reg_url_link() && $registration->is_primary_registrant()) { |
|
859 | 859 | $this->checkout->primary_revisit = TRUE; |
860 | 860 | break; |
861 | - } else if ( $this->checkout->revisit && $this->checkout->reg_url_link != $registration->reg_url_link() ) { |
|
861 | + } else if ($this->checkout->revisit && $this->checkout->reg_url_link != $registration->reg_url_link()) { |
|
862 | 862 | // but hide info if it doesn't belong to you |
863 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
863 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
864 | 864 | } |
865 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
865 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
866 | 866 | } |
867 | 867 | } |
868 | 868 | } |
@@ -876,17 +876,17 @@ discard block |
||
876 | 876 | * @param EE_Transaction $transaction |
877 | 877 | * @return array |
878 | 878 | */ |
879 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
879 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
880 | 880 | $att_nmbr = 0; |
881 | 881 | $registrations = array(); |
882 | - if ( $transaction instanceof EE_Transaction ) { |
|
882 | + if ($transaction instanceof EE_Transaction) { |
|
883 | 883 | /** @type EE_Registration_Processor $registration_processor */ |
884 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
884 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
885 | 885 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
886 | 886 | // now let's add the cart items to the $transaction |
887 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
887 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
888 | 888 | //do the following for each ticket of this type they selected |
889 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
889 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
890 | 890 | $att_nmbr++; |
891 | 891 | $registration = $registration_processor->generate_ONE_registration_from_line_item( |
892 | 892 | $line_item, |
@@ -894,12 +894,12 @@ discard block |
||
894 | 894 | $att_nmbr, |
895 | 895 | $this->checkout->total_ticket_count |
896 | 896 | ); |
897 | - if ( $registration instanceof EE_Registration ) { |
|
898 | - $registrations[ $registration->ID() ] = $registration; |
|
897 | + if ($registration instanceof EE_Registration) { |
|
898 | + $registrations[$registration->ID()] = $registration; |
|
899 | 899 | } |
900 | 900 | } |
901 | 901 | } |
902 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
902 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
903 | 903 | } |
904 | 904 | return $registrations; |
905 | 905 | } |
@@ -914,12 +914,12 @@ discard block |
||
914 | 914 | * @param EE_Registration $reg_B |
915 | 915 | * @return array() |
916 | 916 | */ |
917 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
917 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
918 | 918 | // this shouldn't ever happen within the same TXN, but oh well |
919 | - if ( $reg_A->count() == $reg_B->count() ) { |
|
919 | + if ($reg_A->count() == $reg_B->count()) { |
|
920 | 920 | return 0; |
921 | 921 | } |
922 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
922 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | |
@@ -934,35 +934,35 @@ discard block |
||
934 | 934 | */ |
935 | 935 | private function _final_verifications() { |
936 | 936 | // filter checkout |
937 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
937 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
938 | 938 | //verify that current step is still set correctly |
939 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
940 | - EE_Error::add_error( __( '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.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
939 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
940 | + EE_Error::add_error(__('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.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
941 | 941 | return false; |
942 | 942 | } |
943 | 943 | // if returning to SPCO, then verify that primary registrant is set |
944 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
944 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
945 | 945 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
946 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
947 | - EE_Error::add_error( __( '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.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
946 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
947 | + EE_Error::add_error(__('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.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
948 | 948 | return false; |
949 | 949 | } |
950 | 950 | $valid_registrant = null; |
951 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
952 | - if ( $registration instanceof EE_Registration ) { |
|
953 | - if ( $registration->reg_url_link() == $this->checkout->reg_url_link ) { |
|
951 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
952 | + if ($registration instanceof EE_Registration) { |
|
953 | + if ($registration->reg_url_link() == $this->checkout->reg_url_link) { |
|
954 | 954 | $valid_registrant = $registration; |
955 | 955 | } |
956 | 956 | } |
957 | 957 | } |
958 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
959 | - EE_Error::add_error( __( '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.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
958 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
959 | + EE_Error::add_error(__('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.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
960 | 960 | return false; |
961 | 961 | } |
962 | 962 | } |
963 | 963 | // now that things have been kinda sufficiently verified, |
964 | 964 | // let's add the checkout to the session so that's available other systems |
965 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
965 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
966 | 966 | return true; |
967 | 967 | } |
968 | 968 | |
@@ -978,28 +978,28 @@ discard block |
||
978 | 978 | * @access private |
979 | 979 | * @param bool $reinitializing |
980 | 980 | */ |
981 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
982 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
981 | + private function _initialize_reg_steps($reinitializing = false) { |
|
982 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
983 | 983 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
984 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
985 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
984 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
985 | + if ( ! $reg_step->initialize_reg_step()) { |
|
986 | 986 | // if not initialized then maybe this step is being removed... |
987 | - if ( $reg_step->is_current_step() && ! $reinitializing ) { |
|
987 | + if ($reg_step->is_current_step() && ! $reinitializing) { |
|
988 | 988 | // if it was the current step, then we need to start over here |
989 | - $this->_initialize_reg_steps( true ); |
|
989 | + $this->_initialize_reg_steps(true); |
|
990 | 990 | return; |
991 | 991 | } |
992 | 992 | continue; |
993 | 993 | } |
994 | 994 | // i18n |
995 | 995 | $reg_step->translate_js_strings(); |
996 | - if ( $reg_step->is_current_step() ) { |
|
996 | + if ($reg_step->is_current_step()) { |
|
997 | 997 | // the text that appears on the reg step form submit button |
998 | 998 | $reg_step->set_submit_button_text(); |
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
1002 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
1002 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | |
@@ -1012,39 +1012,39 @@ discard block |
||
1012 | 1012 | */ |
1013 | 1013 | private function _check_form_submission() { |
1014 | 1014 | //does this request require the reg form to be generated ? |
1015 | - if ( $this->checkout->generate_reg_form ) { |
|
1015 | + if ($this->checkout->generate_reg_form) { |
|
1016 | 1016 | // ever heard that song by Blue Rodeo ? |
1017 | 1017 | try { |
1018 | 1018 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
1019 | 1019 | // if not displaying a form, then check for form submission |
1020 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
1020 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
1021 | 1021 | // clear out any old data in case this step is being run again |
1022 | - $this->checkout->current_step->set_valid_data( array() ); |
|
1022 | + $this->checkout->current_step->set_valid_data(array()); |
|
1023 | 1023 | // capture submitted form data |
1024 | 1024 | $this->checkout->current_step->reg_form->receive_form_submission( |
1025 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
1025 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
1026 | 1026 | ); |
1027 | 1027 | // validate submitted form data |
1028 | - if ( ! $this->checkout->current_step->reg_form->is_valid() || ! $this->checkout->continue_reg ) { |
|
1028 | + if ( ! $this->checkout->current_step->reg_form->is_valid() || ! $this->checkout->continue_reg) { |
|
1029 | 1029 | // thou shall not pass !!! |
1030 | 1030 | $this->checkout->continue_reg = FALSE; |
1031 | 1031 | // any form validation errors? |
1032 | - if ( $this->checkout->current_step->reg_form->submission_error_message() != '' ) { |
|
1032 | + if ($this->checkout->current_step->reg_form->submission_error_message() != '') { |
|
1033 | 1033 | $submission_error_messages = array(); |
1034 | 1034 | // bad, bad, bad registrant |
1035 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
1036 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1037 | - $submission_error_messages[] = sprintf( __( '%s : %s', 'event_espresso' ), $validation_error->get_form_section()->html_label_text(), $validation_error->getMessage() ); |
|
1035 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1036 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1037 | + $submission_error_messages[] = sprintf(__('%s : %s', 'event_espresso'), $validation_error->get_form_section()->html_label_text(), $validation_error->getMessage()); |
|
1038 | 1038 | } |
1039 | 1039 | } |
1040 | - EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1040 | + EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1041 | 1041 | } |
1042 | 1042 | // well not really... what will happen is we'll just get redirected back to redo the current step |
1043 | 1043 | $this->go_to_next_step(); |
1044 | 1044 | return; |
1045 | 1045 | } |
1046 | 1046 | } |
1047 | - } catch( EE_Error $e ) { |
|
1047 | + } catch (EE_Error $e) { |
|
1048 | 1048 | $e->get_error(); |
1049 | 1049 | } |
1050 | 1050 | } |
@@ -1060,38 +1060,38 @@ discard block |
||
1060 | 1060 | */ |
1061 | 1061 | private function _process_form_action() { |
1062 | 1062 | // what cha wanna do? |
1063 | - switch( $this->checkout->action ) { |
|
1063 | + switch ($this->checkout->action) { |
|
1064 | 1064 | // AJAX next step reg form |
1065 | 1065 | case 'display_spco_reg_step' : |
1066 | 1066 | $this->checkout->redirect = FALSE; |
1067 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1068 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
1067 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1068 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1069 | 1069 | } |
1070 | 1070 | break; |
1071 | 1071 | |
1072 | 1072 | default : |
1073 | 1073 | // meh... do one of those other steps first |
1074 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
1074 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1075 | 1075 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
1076 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1076 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1077 | 1077 | // call action on current step |
1078 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
1078 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1079 | 1079 | // good registrant, you get to proceed |
1080 | - if ( $this->checkout->current_step->success_message() != '' ) { |
|
1081 | - if ( apply_filters( 'FHEE__Single_Page_Checkout___process_form_action__display_success', false ) ) { |
|
1082 | - EE_Error::add_success( $this->checkout->current_step->success_message() . '<br />' . $this->checkout->next_step->_instructions() ); |
|
1080 | + if ($this->checkout->current_step->success_message() != '') { |
|
1081 | + if (apply_filters('FHEE__Single_Page_Checkout___process_form_action__display_success', false)) { |
|
1082 | + EE_Error::add_success($this->checkout->current_step->success_message().'<br />'.$this->checkout->next_step->_instructions()); |
|
1083 | 1083 | } |
1084 | 1084 | } |
1085 | 1085 | // pack it up, pack it in... |
1086 | 1086 | $this->_setup_redirect(); |
1087 | 1087 | } |
1088 | 1088 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
1089 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1089 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1090 | 1090 | |
1091 | 1091 | } else { |
1092 | 1092 | EE_Error::add_error( |
1093 | 1093 | sprintf( |
1094 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
1094 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1095 | 1095 | $this->checkout->action, |
1096 | 1096 | $this->checkout->current_step->name() |
1097 | 1097 | ), |
@@ -1117,10 +1117,10 @@ discard block |
||
1117 | 1117 | public function add_styles_and_scripts() { |
1118 | 1118 | // i18n |
1119 | 1119 | $this->translate_js_strings(); |
1120 | - if ( $this->checkout->admin_request ) { |
|
1121 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
1120 | + if ($this->checkout->admin_request) { |
|
1121 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1122 | 1122 | } else { |
1123 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
1123 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1124 | 1124 | } |
1125 | 1125 | } |
1126 | 1126 | |
@@ -1136,50 +1136,50 @@ discard block |
||
1136 | 1136 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
1137 | 1137 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
1138 | 1138 | EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
1139 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1140 | - EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
1141 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1139 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1140 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1141 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1142 | 1142 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
1143 | 1143 | EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
1144 | 1144 | EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
1145 | - __( 'Please wait while we process your registration.%1$sDo not refresh the page or navigate away while this is happening.%1$sThank you for your patience.', 'event_espresso' ), |
|
1145 | + __('Please wait while we process your registration.%1$sDo not refresh the page or navigate away while this is happening.%1$sThank you for your patience.', 'event_espresso'), |
|
1146 | 1146 | '<br/>' |
1147 | 1147 | ); |
1148 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
1148 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1149 | 1149 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
1150 | 1150 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
1151 | 1151 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
1152 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
1153 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
1154 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
1155 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
1156 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
1157 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
1158 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
1159 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
1160 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
1161 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
1162 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
1163 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
1164 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
1165 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
1152 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1153 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1154 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1155 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1156 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1157 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1158 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1159 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1160 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1161 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1162 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1163 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1164 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1165 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1166 | 1166 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
1167 | - __( '%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 except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
1167 | + __('%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 except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
1168 | 1168 | '<h4 class="important-notice">', |
1169 | 1169 | '</h4>', |
1170 | 1170 | '<br />', |
1171 | 1171 | '<p>', |
1172 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1172 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1173 | 1173 | '">', |
1174 | 1174 | '</a>', |
1175 | 1175 | '</p>' |
1176 | 1176 | ); |
1177 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
1178 | - EE_Registry::$i18n_js_strings[ 'session_extension' ] = absint( |
|
1179 | - apply_filters( 'FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS ) |
|
1177 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1178 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1179 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1180 | 1180 | ); |
1181 | - EE_Registry::$i18n_js_strings[ 'session_expiration' ] = gmdate( |
|
1182 | - 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) |
|
1181 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1182 | + 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1183 | 1183 | ); |
1184 | 1184 | |
1185 | 1185 | |
@@ -1195,31 +1195,31 @@ discard block |
||
1195 | 1195 | */ |
1196 | 1196 | public function enqueue_styles_and_scripts() { |
1197 | 1197 | // load css |
1198 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1199 | - wp_enqueue_style( 'single_page_checkout' ); |
|
1198 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1199 | + wp_enqueue_style('single_page_checkout'); |
|
1200 | 1200 | // load JS |
1201 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
1202 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
1201 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
1202 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
1203 | 1203 | wp_register_script( |
1204 | 1204 | 'single_page_checkout', |
1205 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
1206 | - array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), |
|
1205 | + SPCO_JS_URL.'single_page_checkout.js', |
|
1206 | + array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), |
|
1207 | 1207 | EVENT_ESPRESSO_VERSION, |
1208 | 1208 | TRUE |
1209 | 1209 | ); |
1210 | - wp_enqueue_script( 'single_page_checkout' ); |
|
1210 | + wp_enqueue_script('single_page_checkout'); |
|
1211 | 1211 | |
1212 | 1212 | /** |
1213 | 1213 | * global action hook for enqueueing styles and scripts with |
1214 | 1214 | * spco calls. |
1215 | 1215 | */ |
1216 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
1216 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1217 | 1217 | |
1218 | 1218 | /** |
1219 | 1219 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1220 | 1220 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1221 | 1221 | */ |
1222 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
1222 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1223 | 1223 | |
1224 | 1224 | // add css and JS for current step |
1225 | 1225 | $this->checkout->current_step->enqueue_styles_and_scripts(); |
@@ -1235,21 +1235,21 @@ discard block |
||
1235 | 1235 | */ |
1236 | 1236 | private function _display_spco_reg_form() { |
1237 | 1237 | // if registering via the admin, just display the reg form for the current step |
1238 | - if ( $this->checkout->admin_request ) { |
|
1239 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
1238 | + if ($this->checkout->admin_request) { |
|
1239 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1240 | 1240 | } else { |
1241 | 1241 | // add powered by EE msg |
1242 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
1242 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1243 | 1243 | |
1244 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
1245 | - EE_Registry::$i18n_js_strings[ 'empty_cart' ] = $empty_cart; |
|
1244 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
1245 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1246 | 1246 | $cookies_not_set_msg = ''; |
1247 | - if ( $empty_cart ) { |
|
1248 | - if ( ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
1247 | + if ($empty_cart) { |
|
1248 | + if ( ! isset($_COOKIE['ee_cookie_test'])) { |
|
1249 | 1249 | $cookies_not_set_msg = apply_filters( |
1250 | 1250 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
1251 | 1251 | sprintf( |
1252 | - __( '%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', 'event_espresso' ), |
|
1252 | + __('%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', 'event_espresso'), |
|
1253 | 1253 | '<div class="ee-attention">', |
1254 | 1254 | '</div>', |
1255 | 1255 | '<h6 class="important-notice">', |
@@ -1270,7 +1270,7 @@ discard block |
||
1270 | 1270 | 'layout_strategy' => |
1271 | 1271 | new EE_Template_Layout( |
1272 | 1272 | array( |
1273 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1273 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1274 | 1274 | 'template_args' => array( |
1275 | 1275 | 'empty_cart' => $empty_cart, |
1276 | 1276 | 'revisit' => $this->checkout->revisit, |
@@ -1279,8 +1279,8 @@ discard block |
||
1279 | 1279 | 'empty_msg' => apply_filters( |
1280 | 1280 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
1281 | 1281 | sprintf( |
1282 | - __( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ), |
|
1283 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1282 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'), |
|
1283 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1284 | 1284 | '">', |
1285 | 1285 | '</a>' |
1286 | 1286 | ) |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | ) |
1299 | 1299 | ); |
1300 | 1300 | // load template and add to output sent that gets filtered into the_content() |
1301 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
1301 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
1302 | 1302 | } |
1303 | 1303 | } |
1304 | 1304 | |
@@ -1312,8 +1312,8 @@ discard block |
||
1312 | 1312 | * @internal param string $label |
1313 | 1313 | * @return string |
1314 | 1314 | */ |
1315 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
1316 | - if ( $next_step == 'finalize_registration' ) { |
|
1315 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
1316 | + if ($next_step == 'finalize_registration') { |
|
1317 | 1317 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
1318 | 1318 | } |
1319 | 1319 | } |
@@ -1327,18 +1327,18 @@ discard block |
||
1327 | 1327 | * @return string |
1328 | 1328 | */ |
1329 | 1329 | public static function display_registration_footer() { |
1330 | - if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) { |
|
1331 | - EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1332 | - $url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' ); |
|
1333 | - $url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
1330 | + if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) { |
|
1331 | + EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1332 | + $url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/'); |
|
1333 | + $url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1334 | 1334 | echo apply_filters( |
1335 | 1335 | 'FHEE__EE_Front_Controller__display_registration_footer', |
1336 | 1336 | sprintf( |
1337 | - __( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ), |
|
1338 | - '<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="', |
|
1337 | + __('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'), |
|
1338 | + '<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="', |
|
1339 | 1339 | '" target="_blank">', |
1340 | 1340 | '</a>', |
1341 | - '<a href="' . $url . '" title="', |
|
1341 | + '<a href="'.$url.'" title="', |
|
1342 | 1342 | '" target="_blank">', |
1343 | 1343 | '</a></div>' |
1344 | 1344 | ) |
@@ -1369,12 +1369,12 @@ discard block |
||
1369 | 1369 | * @return array |
1370 | 1370 | */ |
1371 | 1371 | private function _setup_redirect() { |
1372 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
1372 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1373 | 1373 | $this->checkout->redirect = TRUE; |
1374 | - if ( empty( $this->checkout->redirect_url )) { |
|
1374 | + if (empty($this->checkout->redirect_url)) { |
|
1375 | 1375 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
1376 | 1376 | } |
1377 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
1377 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
1378 | 1378 | } |
1379 | 1379 | } |
1380 | 1380 | |
@@ -1387,12 +1387,12 @@ discard block |
||
1387 | 1387 | * @return void |
1388 | 1388 | */ |
1389 | 1389 | public function go_to_next_step() { |
1390 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1390 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1391 | 1391 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
1392 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
1392 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1393 | 1393 | } |
1394 | 1394 | // just return for these conditions |
1395 | - if ( $this->checkout->admin_request || $this->checkout->action == 'redirect_form' || $this->checkout->action == 'update_checkout' ) { |
|
1395 | + if ($this->checkout->admin_request || $this->checkout->action == 'redirect_form' || $this->checkout->action == 'update_checkout') { |
|
1396 | 1396 | return; |
1397 | 1397 | } |
1398 | 1398 | // AJAX response |
@@ -1413,7 +1413,7 @@ discard block |
||
1413 | 1413 | */ |
1414 | 1414 | protected function _handle_json_response() { |
1415 | 1415 | // if this is an ajax request |
1416 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1416 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1417 | 1417 | // DEBUG LOG |
1418 | 1418 | //$this->checkout->log( |
1419 | 1419 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1423,10 +1423,10 @@ discard block |
||
1423 | 1423 | // 'continue_reg' => $this->checkout->continue_reg, |
1424 | 1424 | // ) |
1425 | 1425 | //); |
1426 | - $this->checkout->json_response->set_registration_time_limit( $this->checkout->get_registration_time_limit() ); |
|
1427 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
1426 | + $this->checkout->json_response->set_registration_time_limit($this->checkout->get_registration_time_limit()); |
|
1427 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1428 | 1428 | // just send the ajax ( |
1429 | - $json_response = apply_filters( 'FHEE__EE_Single_Page_Checkout__JSON_response', $this->checkout->json_response ); |
|
1429 | + $json_response = apply_filters('FHEE__EE_Single_Page_Checkout__JSON_response', $this->checkout->json_response); |
|
1430 | 1430 | $this->unlock_transaction(); |
1431 | 1431 | echo $json_response; |
1432 | 1432 | exit(); |
@@ -1443,9 +1443,9 @@ discard block |
||
1443 | 1443 | */ |
1444 | 1444 | protected function _handle_html_redirects() { |
1445 | 1445 | // going somewhere ? |
1446 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
1446 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1447 | 1447 | // store notices in a transient |
1448 | - EE_Error::get_notices( false, true, true ); |
|
1448 | + EE_Error::get_notices(false, true, true); |
|
1449 | 1449 | $this->unlock_transaction(); |
1450 | 1450 | // DEBUG LOG |
1451 | 1451 | //$this->checkout->log( |
@@ -1456,7 +1456,7 @@ discard block |
||
1456 | 1456 | // 'headers_list' => headers_list(), |
1457 | 1457 | // ) |
1458 | 1458 | //); |
1459 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
1459 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1460 | 1460 | exit(); |
1461 | 1461 | } |
1462 | 1462 | } |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * This template will display The Loop that displays your events |
|
4 | - * DO NOT COPY THIS TEMPLATE TO YOUR THEMES FOLDER |
|
5 | - * |
|
6 | - * @ package Event Espresso |
|
7 | - * @ author Seth Shoultes |
|
8 | - * @ copyright (c) 2008-2013 Event Espresso All Rights Reserved. |
|
9 | - * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
10 | - * @ link http://www.eventespresso.com |
|
11 | - * @ version 4+ |
|
12 | - */ |
|
3 | + * This template will display The Loop that displays your events |
|
4 | + * DO NOT COPY THIS TEMPLATE TO YOUR THEMES FOLDER |
|
5 | + * |
|
6 | + * @ package Event Espresso |
|
7 | + * @ author Seth Shoultes |
|
8 | + * @ copyright (c) 2008-2013 Event Espresso All Rights Reserved. |
|
9 | + * @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
|
10 | + * @ link http://www.eventespresso.com |
|
11 | + * @ version 4+ |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | if ( have_posts() ) : ?> |
15 | 15 |