@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param array $props_n_values incoming values |
16 | 16 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
17 | 17 | * used.) |
18 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
18 | + * @param string[] $date_formats incoming date_formats in an array where the first value is the |
|
19 | 19 | * date_format and the second value is the time format |
20 | 20 | * @return EE_Payment |
21 | 21 | * @throws \EE_Error |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * Gets all the extra meta info on this payment |
591 | 591 | * |
592 | 592 | * @param array $query_params like EEM_Base::get_all |
593 | - * @return EE_Extra_Meta |
|
593 | + * @return EE_Base_Class[] |
|
594 | 594 | * @throws \EE_Error |
595 | 595 | */ |
596 | 596 | public function extra_meta( $query_params = array() ) { |
@@ -662,11 +662,11 @@ discard block |
||
662 | 662 | $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
663 | 663 | } |
664 | 664 | $form = EEH_HTML::nl( 1 ) |
665 | - . '<form method="' |
|
666 | - . $method |
|
667 | - . '" name="gateway_form" action="' |
|
668 | - . $redirect_url |
|
669 | - . '">'; |
|
665 | + . '<form method="' |
|
666 | + . $method |
|
667 | + . '" name="gateway_form" action="' |
|
668 | + . $redirect_url |
|
669 | + . '">'; |
|
670 | 670 | $form .= EEH_HTML::nl( 1 ) . $this->redirect_args_as_inputs(); |
671 | 671 | $form .= $inside_form_html; |
672 | 672 | $form .= EEH_HTML::nl( -1 ) . '</form>' . EEH_HTML::nl( -1 ); |
@@ -704,11 +704,11 @@ discard block |
||
704 | 704 | EE_Registry::instance()->load_helper( 'HTML' ); |
705 | 705 | foreach ( $args as $name => $value ) { |
706 | 706 | $html .= EEH_HTML::nl( 0 ) |
707 | - . '<input type="hidden" name="' |
|
708 | - . $name |
|
709 | - . '" value="' |
|
710 | - . esc_attr( $value ) |
|
711 | - . '"/>'; |
|
707 | + . '<input type="hidden" name="' |
|
708 | + . $name |
|
709 | + . '" value="' |
|
710 | + . esc_attr( $value ) |
|
711 | + . '"/>'; |
|
712 | 712 | } |
713 | 713 | } |
714 | 714 | return $html; |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | * @return EE_Payment |
21 | 21 | * @throws \EE_Error |
22 | 22 | */ |
23 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
24 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
25 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
23 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
24 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @return EE_Payment |
35 | 35 | * @throws \EE_Error |
36 | 36 | */ |
37 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
38 | - return new self( $props_n_values, true, $timezone ); |
|
37 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
38 | + return new self($props_n_values, true, $timezone); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param int $TXN_ID |
48 | 48 | * @throws \EE_Error |
49 | 49 | */ |
50 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
51 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
50 | + public function set_transaction_id($TXN_ID = 0) { |
|
51 | + $this->set('TXN_ID', $TXN_ID); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @throws \EE_Error |
61 | 61 | */ |
62 | 62 | public function transaction() { |
63 | - return $this->get_first_related( 'Transaction' ); |
|
63 | + return $this->get_first_related('Transaction'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @param string $STS_ID |
73 | 73 | * @throws \EE_Error |
74 | 74 | */ |
75 | - public function set_status( $STS_ID = '' ) { |
|
76 | - $this->set( 'STS_ID', $STS_ID ); |
|
75 | + public function set_status($STS_ID = '') { |
|
76 | + $this->set('STS_ID', $STS_ID); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @param int $timestamp |
86 | 86 | * @throws \EE_Error |
87 | 87 | */ |
88 | - public function set_timestamp( $timestamp = 0 ) { |
|
89 | - $this->set( 'PAY_timestamp', $timestamp ); |
|
88 | + public function set_timestamp($timestamp = 0) { |
|
89 | + $this->set('PAY_timestamp', $timestamp); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @param string $PAY_source |
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | - public function set_source( $PAY_source = '' ) { |
|
102 | - $this->set( 'PAY_source', $PAY_source ); |
|
101 | + public function set_source($PAY_source = '') { |
|
102 | + $this->set('PAY_source', $PAY_source); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @param float $amount |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function set_amount( $amount = 0.00 ) { |
|
115 | - $this->set( 'PAY_amount', (float)$amount ); |
|
114 | + public function set_amount($amount = 0.00) { |
|
115 | + $this->set('PAY_amount', (float) $amount); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @param string $gateway_response |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - public function set_gateway_response( $gateway_response = '' ) { |
|
128 | - $this->set( 'PAY_gateway_response', $gateway_response ); |
|
127 | + public function set_gateway_response($gateway_response = '') { |
|
128 | + $this->set('PAY_gateway_response', $gateway_response); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | ), |
149 | 149 | '4.6.0' |
150 | 150 | ); |
151 | - return $this->payment_method() ? $this->payment_method()->name() : __( 'Unknown', 'event_espresso' ); |
|
151 | + return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @param string $txn_id_chq_nmbr |
161 | 161 | * @throws \EE_Error |
162 | 162 | */ |
163 | - public function set_txn_id_chq_nmbr( $txn_id_chq_nmbr = '' ) { |
|
164 | - $this->set( 'PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr ); |
|
163 | + public function set_txn_id_chq_nmbr($txn_id_chq_nmbr = '') { |
|
164 | + $this->set('PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param string $po_number |
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | - public function set_po_number( $po_number = '' ) { |
|
177 | - $this->set( 'PAY_po_number', $po_number ); |
|
176 | + public function set_po_number($po_number = '') { |
|
177 | + $this->set('PAY_po_number', $po_number); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param string $extra_accntng |
187 | 187 | * @throws \EE_Error |
188 | 188 | */ |
189 | - public function set_extra_accntng( $extra_accntng = '' ) { |
|
190 | - $this->set( 'PAY_extra_accntng', $extra_accntng ); |
|
189 | + public function set_extra_accntng($extra_accntng = '') { |
|
190 | + $this->set('PAY_extra_accntng', $extra_accntng); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @param bool $via_admin |
200 | 200 | * @throws \EE_Error |
201 | 201 | */ |
202 | - public function set_payment_made_via_admin( $via_admin = false ) { |
|
203 | - if ( $via_admin ) { |
|
204 | - $this->set( 'PAY_source', EEM_Payment_Method::scope_admin ); |
|
202 | + public function set_payment_made_via_admin($via_admin = false) { |
|
203 | + if ($via_admin) { |
|
204 | + $this->set('PAY_source', EEM_Payment_Method::scope_admin); |
|
205 | 205 | } else { |
206 | - $this->set( 'PAY_source', EEM_Payment_Method::scope_cart ); |
|
206 | + $this->set('PAY_source', EEM_Payment_Method::scope_cart); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * @param string|array $details |
217 | 217 | * @throws \EE_Error |
218 | 218 | */ |
219 | - public function set_details( $details = '' ) { |
|
220 | - if ( is_array( $details ) ) { |
|
221 | - array_walk_recursive( $details, array( $this, '_strip_all_tags_within_array' ) ); |
|
219 | + public function set_details($details = '') { |
|
220 | + if (is_array($details)) { |
|
221 | + array_walk_recursive($details, array($this, '_strip_all_tags_within_array')); |
|
222 | 222 | } else { |
223 | - $details = wp_strip_all_tags( $details ); |
|
223 | + $details = wp_strip_all_tags($details); |
|
224 | 224 | } |
225 | - $this->set( 'PAY_details', $details ); |
|
225 | + $this->set('PAY_details', $details); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @param string $redirect_url |
234 | 234 | * @throws \EE_Error |
235 | 235 | */ |
236 | - public function set_redirect_url( $redirect_url ) { |
|
237 | - $this->set( 'PAY_redirect_url', $redirect_url ); |
|
236 | + public function set_redirect_url($redirect_url) { |
|
237 | + $this->set('PAY_redirect_url', $redirect_url); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @param array $redirect_args |
246 | 246 | * @throws \EE_Error |
247 | 247 | */ |
248 | - public function set_redirect_args( $redirect_args ) { |
|
249 | - $this->set( 'PAY_redirect_args', $redirect_args ); |
|
248 | + public function set_redirect_args($redirect_args) { |
|
249 | + $this->set('PAY_redirect_args', $redirect_args); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @throws \EE_Error |
259 | 259 | */ |
260 | 260 | public function TXN_ID() { |
261 | - return $this->get( 'TXN_ID' ); |
|
261 | + return $this->get('TXN_ID'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @throws \EE_Error |
271 | 271 | */ |
272 | 272 | public function status() { |
273 | - return $this->get( 'STS_ID' ); |
|
273 | + return $this->get('STS_ID'); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @throws \EE_Error |
283 | 283 | */ |
284 | 284 | public function STS_ID() { |
285 | - return $this->get( 'STS_ID' ); |
|
285 | + return $this->get('STS_ID'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @return string |
297 | 297 | * @throws \EE_Error |
298 | 298 | */ |
299 | - public function timestamp( $dt_frmt = '', $tm_frmt = '' ) { |
|
300 | - return $this->get_datetime( 'PAY_timestamp', $dt_frmt, $tm_frmt ); |
|
299 | + public function timestamp($dt_frmt = '', $tm_frmt = '') { |
|
300 | + return $this->get_datetime('PAY_timestamp', $dt_frmt, $tm_frmt); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @throws \EE_Error |
310 | 310 | */ |
311 | 311 | public function source() { |
312 | - return $this->get( 'PAY_source' ); |
|
312 | + return $this->get('PAY_source'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @throws \EE_Error |
323 | 323 | */ |
324 | 324 | public function amount() { |
325 | - return (float)$this->get( 'PAY_amount' ); |
|
325 | + return (float) $this->get('PAY_amount'); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @throws \EE_Error |
333 | 333 | */ |
334 | 334 | public function amount_no_code() { |
335 | - return $this->get_pretty( 'PAY_amount', 'no_currency_code' ); |
|
335 | + return $this->get_pretty('PAY_amount', 'no_currency_code'); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @throws \EE_Error |
345 | 345 | */ |
346 | 346 | public function gateway_response() { |
347 | - return $this->get( 'PAY_gateway_response' ); |
|
347 | + return $this->get('PAY_gateway_response'); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @throws \EE_Error |
357 | 357 | */ |
358 | 358 | public function txn_id_chq_nmbr() { |
359 | - return $this->get( 'PAY_txn_id_chq_nmbr' ); |
|
359 | + return $this->get('PAY_txn_id_chq_nmbr'); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @throws \EE_Error |
369 | 369 | */ |
370 | 370 | public function po_number() { |
371 | - return $this->get( 'PAY_po_number' ); |
|
371 | + return $this->get('PAY_po_number'); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @throws \EE_Error |
381 | 381 | */ |
382 | 382 | public function extra_accntng() { |
383 | - return $this->get( 'PAY_extra_accntng' ); |
|
383 | + return $this->get('PAY_extra_accntng'); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @throws \EE_Error |
393 | 393 | */ |
394 | 394 | public function payment_made_via_admin() { |
395 | - return ( $this->get( 'PAY_source' ) === EEM_Payment_Method::scope_admin ); |
|
395 | + return ($this->get('PAY_source') === EEM_Payment_Method::scope_admin); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @throws \EE_Error |
405 | 405 | */ |
406 | 406 | public function details() { |
407 | - return $this->get( 'PAY_details' ); |
|
407 | + return $this->get('PAY_details'); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | 418 | public function redirect_url() { |
419 | - return $this->get( 'PAY_redirect_url' ); |
|
419 | + return $this->get('PAY_redirect_url'); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @throws \EE_Error |
429 | 429 | */ |
430 | 430 | public function redirect_args() { |
431 | - return $this->get( 'PAY_redirect_args' ); |
|
431 | + return $this->get('PAY_redirect_args'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @return void |
441 | 441 | * @throws \EE_Error |
442 | 442 | */ |
443 | - public function e_pretty_status( $show_icons = false ) { |
|
444 | - echo $this->pretty_status( $show_icons ); |
|
443 | + public function e_pretty_status($show_icons = false) { |
|
444 | + echo $this->pretty_status($show_icons); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -453,14 +453,14 @@ discard block |
||
453 | 453 | * @return string |
454 | 454 | * @throws \EE_Error |
455 | 455 | */ |
456 | - public function pretty_status( $show_icons = false ) { |
|
456 | + public function pretty_status($show_icons = false) { |
|
457 | 457 | $status = EEM_Status::instance()->localized_status( |
458 | - array( $this->STS_ID() => __( 'unknown', 'event_espresso' ) ), |
|
458 | + array($this->STS_ID() => __('unknown', 'event_espresso')), |
|
459 | 459 | false, |
460 | 460 | 'sentence' |
461 | 461 | ); |
462 | 462 | $icon = ''; |
463 | - switch ( $this->STS_ID() ) { |
|
463 | + switch ($this->STS_ID()) { |
|
464 | 464 | case EEM_Payment::status_id_approved: |
465 | 465 | $icon = $show_icons |
466 | 466 | ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | : ''; |
483 | 483 | break; |
484 | 484 | } |
485 | - return $icon . $status[ $this->STS_ID() ]; |
|
485 | + return $icon.$status[$this->STS_ID()]; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | 496 | public function is_approved() { |
497 | - return $this->status_is( EEM_Payment::status_id_approved ); |
|
497 | + return $this->status_is(EEM_Payment::status_id_approved); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @return boolean whether the status of this payment equals the status id |
509 | 509 | * @throws \EE_Error |
510 | 510 | */ |
511 | - protected function status_is( $STS_ID ) { |
|
511 | + protected function status_is($STS_ID) { |
|
512 | 512 | return $STS_ID === $this->STS_ID() ? true : false; |
513 | 513 | } |
514 | 514 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @throws \EE_Error |
522 | 522 | */ |
523 | 523 | public function is_pending() { |
524 | - return $this->status_is( EEM_Payment::status_id_pending ); |
|
524 | + return $this->status_is(EEM_Payment::status_id_pending); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * @throws \EE_Error |
534 | 534 | */ |
535 | 535 | public function is_cancelled() { |
536 | - return $this->status_is( EEM_Payment::status_id_cancelled ); |
|
536 | + return $this->status_is(EEM_Payment::status_id_cancelled); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @throws \EE_Error |
546 | 546 | */ |
547 | 547 | public function is_declined() { |
548 | - return $this->status_is( EEM_Payment::status_id_declined ); |
|
548 | + return $this->status_is(EEM_Payment::status_id_declined); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * @throws \EE_Error |
558 | 558 | */ |
559 | 559 | public function is_failed() { |
560 | - return $this->status_is( EEM_Payment::status_id_failed ); |
|
560 | + return $this->status_is(EEM_Payment::status_id_failed); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @throws \EE_Error |
582 | 582 | */ |
583 | 583 | public function status_obj() { |
584 | - return $this->get_first_related( 'Status' ); |
|
584 | + return $this->get_first_related('Status'); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | * @return EE_Extra_Meta |
594 | 594 | * @throws \EE_Error |
595 | 595 | */ |
596 | - public function extra_meta( $query_params = array() ) { |
|
597 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
596 | + public function extra_meta($query_params = array()) { |
|
597 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @throws \EE_Error |
609 | 609 | */ |
610 | 610 | public function payment_method() { |
611 | - return $this->get_first_related( 'Payment_Method' ); |
|
611 | + return $this->get_first_related('Payment_Method'); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -626,18 +626,18 @@ discard block |
||
626 | 626 | * @return string html |
627 | 627 | * @throws \EE_Error |
628 | 628 | */ |
629 | - public function redirect_form( $inside_form_html = null ) { |
|
629 | + public function redirect_form($inside_form_html = null) { |
|
630 | 630 | $redirect_url = $this->redirect_url(); |
631 | - if ( ! empty( $redirect_url ) ) { |
|
631 | + if ( ! empty($redirect_url)) { |
|
632 | 632 | // what ? no inner form content? |
633 | - if ( $inside_form_html === null ) { |
|
633 | + if ($inside_form_html === null) { |
|
634 | 634 | $inside_form_html = EEH_HTML::p( |
635 | 635 | sprintf( |
636 | 636 | __( |
637 | 637 | 'If you are not automatically redirected to the payment website within 10 seconds... %1$s %2$s Click Here %3$s', |
638 | 638 | 'event_espresso' |
639 | 639 | ), |
640 | - EEH_HTML::br( 2 ), |
|
640 | + EEH_HTML::br(2), |
|
641 | 641 | '<input type="submit" value="', |
642 | 642 | '">' |
643 | 643 | ), |
@@ -653,22 +653,22 @@ discard block |
||
653 | 653 | ); |
654 | 654 | //if it's a GET request, we need to remove all the GET params in the querystring |
655 | 655 | //and put them into the form instead |
656 | - if ( $method === 'GET' ) { |
|
657 | - $querystring = parse_url( $redirect_url, PHP_URL_QUERY ); |
|
656 | + if ($method === 'GET') { |
|
657 | + $querystring = parse_url($redirect_url, PHP_URL_QUERY); |
|
658 | 658 | $get_params = null; |
659 | - parse_str( $querystring, $get_params ); |
|
660 | - $inside_form_html .= $this->_args_as_inputs( $get_params ); |
|
661 | - $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
|
659 | + parse_str($querystring, $get_params); |
|
660 | + $inside_form_html .= $this->_args_as_inputs($get_params); |
|
661 | + $redirect_url = str_replace('?'.$querystring, '', $redirect_url); |
|
662 | 662 | } |
663 | - $form = EEH_HTML::nl( 1 ) |
|
663 | + $form = EEH_HTML::nl(1) |
|
664 | 664 | . '<form method="' |
665 | 665 | . $method |
666 | 666 | . '" name="gateway_form" action="' |
667 | 667 | . $redirect_url |
668 | 668 | . '">'; |
669 | - $form .= EEH_HTML::nl( 1 ) . $this->redirect_args_as_inputs(); |
|
669 | + $form .= EEH_HTML::nl(1).$this->redirect_args_as_inputs(); |
|
670 | 670 | $form .= $inside_form_html; |
671 | - $form .= EEH_HTML::nl( -1 ) . '</form>' . EEH_HTML::nl( -1 ); |
|
671 | + $form .= EEH_HTML::nl( -1 ).'</form>'.EEH_HTML::nl( -1 ); |
|
672 | 672 | return $form; |
673 | 673 | } else { |
674 | 674 | return null; |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * @throws \EE_Error |
686 | 686 | */ |
687 | 687 | public function redirect_args_as_inputs() { |
688 | - return $this->_args_as_inputs( $this->redirect_args() ); |
|
688 | + return $this->_args_as_inputs($this->redirect_args()); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -697,15 +697,15 @@ discard block |
||
697 | 697 | * @param array $args key-value pairs |
698 | 698 | * @return string |
699 | 699 | */ |
700 | - protected function _args_as_inputs( $args ) { |
|
700 | + protected function _args_as_inputs($args) { |
|
701 | 701 | $html = ''; |
702 | - if ( $args !== null && is_array( $args ) ) { |
|
703 | - foreach ( $args as $name => $value ) { |
|
704 | - $html .= EEH_HTML::nl( 0 ) |
|
702 | + if ($args !== null && is_array($args)) { |
|
703 | + foreach ($args as $name => $value) { |
|
704 | + $html .= EEH_HTML::nl(0) |
|
705 | 705 | . '<input type="hidden" name="' |
706 | 706 | . $name |
707 | 707 | . '" value="' |
708 | - . esc_attr( $value ) |
|
708 | + . esc_attr($value) |
|
709 | 709 | . '"/>'; |
710 | 710 | } |
711 | 711 | } |
@@ -734,14 +734,14 @@ discard block |
||
734 | 734 | * @access private |
735 | 735 | * @param mixed $item |
736 | 736 | */ |
737 | - private function _strip_all_tags_within_array( &$item ) { |
|
738 | - if ( is_object( $item ) ) { |
|
739 | - $item = (array)$item; |
|
737 | + private function _strip_all_tags_within_array(&$item) { |
|
738 | + if (is_object($item)) { |
|
739 | + $item = (array) $item; |
|
740 | 740 | } |
741 | - if ( is_array( $item ) ) { |
|
742 | - array_walk_recursive( $item, array( $this, '_strip_all_tags_within_array' ) ); |
|
741 | + if (is_array($item)) { |
|
742 | + array_walk_recursive($item, array($this, '_strip_all_tags_within_array')); |
|
743 | 743 | } else { |
744 | - $item = wp_strip_all_tags( $item ); |
|
744 | + $item = wp_strip_all_tags($item); |
|
745 | 745 | } |
746 | 746 | } |
747 | 747 | |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | $original_status = EEH_Array::is_set( |
759 | 759 | $this->_props_n_values_provided_in_constructor, |
760 | 760 | 'STS_ID', |
761 | - $this->get_model()->field_settings_for( 'STS_ID' )->get_default_value() |
|
761 | + $this->get_model()->field_settings_for('STS_ID')->get_default_value() |
|
762 | 762 | ); |
763 | 763 | $current_status = $this->status(); |
764 | 764 | if ( |
@@ -784,11 +784,11 @@ discard block |
||
784 | 784 | * @return mixed |
785 | 785 | * @throws \EE_Error |
786 | 786 | */ |
787 | - public function get_pretty( $field_name, $extra_cache_ref = null ) { |
|
788 | - if ( $field_name === 'PAY_gateway' ) { |
|
789 | - return $this->payment_method() ? $this->payment_method()->name() : __( 'Unknown', 'event_espresso' ); |
|
787 | + public function get_pretty($field_name, $extra_cache_ref = null) { |
|
788 | + if ($field_name === 'PAY_gateway') { |
|
789 | + return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso'); |
|
790 | 790 | } |
791 | - return $this->_get_cached_property( $field_name, true, $extra_cache_ref ); |
|
791 | + return $this->_get_cached_property($field_name, true, $extra_cache_ref); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | |
@@ -800,8 +800,8 @@ discard block |
||
800 | 800 | * @return EE_Registration_Payment[] |
801 | 801 | * @throws \EE_Error |
802 | 802 | */ |
803 | - public function registration_payments( $query_params = array() ) { |
|
804 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
803 | + public function registration_payments($query_params = array()) { |
|
804 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | * @since 4.6.0 |
557 | 557 | * @global WPDB $wpdb |
558 | 558 | * |
559 | - * @return mixed null|int WP_user ID or NULL |
|
559 | + * @return integer|null null|int WP_user ID or NULL |
|
560 | 560 | */ |
561 | 561 | public static function get_default_creator_id() { |
562 | 562 | global $wpdb; |
@@ -701,6 +701,7 @@ discard block |
||
701 | 701 | * @access public |
702 | 702 | * @static |
703 | 703 | * @param string $table_name, without prefixed $wpdb->prefix |
704 | + * @param string $table_name |
|
704 | 705 | * @return array of database column names |
705 | 706 | */ |
706 | 707 | public static function get_fields_on_table( $table_name = NULL ) { |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | if ( is_array( $hooks_to_fire_at_time ) ) { |
208 | 208 | foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
209 | 209 | if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
210 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
210 | + && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
211 | 211 | ) { |
212 | 212 | unset( $crons[ $timestamp ][ $hook_name ] ); |
213 | 213 | } |
@@ -1124,14 +1124,14 @@ discard block |
||
1124 | 1124 | $QSG_ID = reset( $id_col ); |
1125 | 1125 | } else { |
1126 | 1126 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1127 | - EE_Log::instance()->log( |
|
1128 | - __FILE__, |
|
1129 | - __FUNCTION__, |
|
1130 | - sprintf( |
|
1131 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1132 | - $QST_ID ), |
|
1133 | - 'error' ); |
|
1134 | - continue; |
|
1127 | + EE_Log::instance()->log( |
|
1128 | + __FILE__, |
|
1129 | + __FUNCTION__, |
|
1130 | + sprintf( |
|
1131 | + __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1132 | + $QST_ID ), |
|
1133 | + 'error' ); |
|
1134 | + continue; |
|
1135 | 1135 | } |
1136 | 1136 | } |
1137 | 1137 | |
@@ -1139,8 +1139,8 @@ discard block |
||
1139 | 1139 | $wpdb->insert( |
1140 | 1140 | EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
1141 | 1141 | array( 'QSG_ID' => $QSG_ID, |
1142 | - 'QST_ID' => $QST_ID, |
|
1143 | - 'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++ |
|
1142 | + 'QST_ID' => $QST_ID, |
|
1143 | + 'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++ |
|
1144 | 1144 | ), |
1145 | 1145 | array( '%d', '%d', '%d' ) |
1146 | 1146 | ); |
@@ -1678,8 +1678,8 @@ discard block |
||
1678 | 1678 | } |
1679 | 1679 | } |
1680 | 1680 | } |
1681 | - //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1682 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1681 | + //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
|
1682 | + remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1683 | 1683 | |
1684 | 1684 | if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
1685 | 1685 | $db_update_sans_ee4 = array(); |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
465 | 465 | if($post_id){ |
466 | 466 | return get_post($post_id); |
467 | - }else{ |
|
467 | + } else{ |
|
468 | 468 | return NULL; |
469 | 469 | } |
470 | 470 | |
@@ -836,13 +836,13 @@ discard block |
||
836 | 836 | foreach( $current_data_migration_script->get_errors() as $error ){ |
837 | 837 | EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
838 | 838 | } |
839 | - }else{ |
|
839 | + } else{ |
|
840 | 840 | EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
841 | 841 | } |
842 | 842 | return false; |
843 | 843 | } |
844 | 844 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
845 | - }else{ |
|
845 | + } else{ |
|
846 | 846 | EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
847 | 847 | return false; |
848 | 848 | } |
@@ -1172,7 +1172,7 @@ discard block |
||
1172 | 1172 | if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
1173 | 1173 | EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
1174 | 1174 | EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
1175 | - }else{ |
|
1175 | + } else{ |
|
1176 | 1176 | EEM_Payment_Method::instance()->verify_button_urls(); |
1177 | 1177 | } |
1178 | 1178 | } |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | if( ! delete_option( $option_name ) ){ |
1680 | 1680 | $undeleted_options[] = $option_name; |
1681 | 1681 | } |
1682 | - }else{ |
|
1682 | + } else{ |
|
1683 | 1683 | $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
1684 | 1684 | foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
1685 | 1685 | if( ! delete_option( $option_name_from_wildcard ) ){ |
@@ -1745,7 +1745,7 @@ discard block |
||
1745 | 1745 | $EZSQL_ERROR = $ezsql_error_cache; |
1746 | 1746 | if( empty( $new_error ) ){ |
1747 | 1747 | return TRUE; |
1748 | - }else{ |
|
1748 | + } else{ |
|
1749 | 1749 | return FALSE; |
1750 | 1750 | } |
1751 | 1751 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * EEH_Activation Helper |
4 | 4 | * |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * @param $table_name |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - public static function ensure_table_name_has_prefix( $table_name ) { |
|
51 | + public static function ensure_table_name_has_prefix($table_name) { |
|
52 | 52 | global $wpdb; |
53 | - return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name; |
|
53 | + return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return boolean success, whether the database and folders are setup properly |
79 | 79 | * @throws \EE_Error |
80 | 80 | */ |
81 | - public static function initialize_db_and_folders(){ |
|
81 | + public static function initialize_db_and_folders() { |
|
82 | 82 | $good_filesystem = EEH_Activation::create_upload_directories(); |
83 | 83 | $good_db = EEH_Activation::create_database_tables(); |
84 | 84 | return $good_filesystem && $good_db; |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @throws \EE_Error |
96 | 96 | */ |
97 | - public static function initialize_db_content(){ |
|
97 | + public static function initialize_db_content() { |
|
98 | 98 | //let's avoid doing all this logic repeatedly, especially when addons are requesting it |
99 | - if( EEH_Activation::$_initialized_db_content_already_in_this_request ) { |
|
99 | + if (EEH_Activation::$_initialized_db_content_already_in_this_request) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | EEH_Activation::$_initialized_db_content_already_in_this_request = true; |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | EEH_Activation::remove_cron_tasks(); |
114 | 114 | EEH_Activation::create_cron_tasks(); |
115 | 115 | // remove all TXN locks since that is being done via extra meta now |
116 | - delete_option( 'ee_locked_transactions' ); |
|
116 | + delete_option('ee_locked_transactions'); |
|
117 | 117 | //also, check for CAF default db content |
118 | - do_action( 'AHEE__EEH_Activation__initialize_db_content' ); |
|
118 | + do_action('AHEE__EEH_Activation__initialize_db_content'); |
|
119 | 119 | //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages |
120 | 120 | //which users really won't care about on initial activation |
121 | 121 | EE_Error::overwrite_success(); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return array |
136 | 136 | * @throws \EE_Error |
137 | 137 | */ |
138 | - public static function get_cron_tasks( $which_to_include ) { |
|
138 | + public static function get_cron_tasks($which_to_include) { |
|
139 | 139 | $cron_tasks = apply_filters( |
140 | 140 | 'FHEE__EEH_Activation__get_cron_tasks', |
141 | 141 | array( |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | 'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates |
145 | 145 | ) |
146 | 146 | ); |
147 | - if ( $which_to_include === 'old' ) { |
|
147 | + if ($which_to_include === 'old') { |
|
148 | 148 | $cron_tasks = array_filter( |
149 | 149 | $cron_tasks, |
150 | - function ( $value ) { |
|
150 | + function($value) { |
|
151 | 151 | return $value === EEH_Activation::cron_task_no_longer_in_use; |
152 | 152 | } |
153 | 153 | ); |
154 | - } elseif ( $which_to_include === 'current' ) { |
|
155 | - $cron_tasks = array_filter( $cron_tasks ); |
|
156 | - } elseif ( WP_DEBUG && $which_to_include !== 'all' ) { |
|
154 | + } elseif ($which_to_include === 'current') { |
|
155 | + $cron_tasks = array_filter($cron_tasks); |
|
156 | + } elseif (WP_DEBUG && $which_to_include !== 'all') { |
|
157 | 157 | throw new EE_Error( |
158 | 158 | sprintf( |
159 | 159 | __( |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | */ |
177 | 177 | public static function create_cron_tasks() { |
178 | 178 | |
179 | - foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) { |
|
180 | - if( ! wp_next_scheduled( $hook_name ) ) { |
|
181 | - wp_schedule_event( time(), $frequency, $hook_name ); |
|
179 | + foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) { |
|
180 | + if ( ! wp_next_scheduled($hook_name)) { |
|
181 | + wp_schedule_event(time(), $frequency, $hook_name); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones |
193 | 193 | * @throws \EE_Error |
194 | 194 | */ |
195 | - public static function remove_cron_tasks( $remove_all = true ) { |
|
195 | + public static function remove_cron_tasks($remove_all = true) { |
|
196 | 196 | $cron_tasks_to_remove = $remove_all ? 'all' : 'old'; |
197 | 197 | $crons = _get_cron_array(); |
198 | - $crons = is_array( $crons ) ? $crons : array(); |
|
198 | + $crons = is_array($crons) ? $crons : array(); |
|
199 | 199 | /* reminder of what $crons look like: |
200 | 200 | * Top-level keys are timestamps, and their values are arrays. |
201 | 201 | * The 2nd level arrays have keys with each of the cron task hook names to run at that time |
@@ -213,23 +213,23 @@ discard block |
||
213 | 213 | * ... |
214 | 214 | * ... |
215 | 215 | */ |
216 | - $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove ); |
|
217 | - foreach ( $crons as $timestamp => $hooks_to_fire_at_time ) { |
|
218 | - if ( is_array( $hooks_to_fire_at_time ) ) { |
|
219 | - foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) { |
|
220 | - if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
221 | - && is_array( $ee_cron_tasks_to_remove[ $hook_name ] ) |
|
216 | + $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove); |
|
217 | + foreach ($crons as $timestamp => $hooks_to_fire_at_time) { |
|
218 | + if (is_array($hooks_to_fire_at_time)) { |
|
219 | + foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) { |
|
220 | + if (isset($ee_cron_tasks_to_remove[$hook_name]) |
|
221 | + && is_array($ee_cron_tasks_to_remove[$hook_name]) |
|
222 | 222 | ) { |
223 | - unset( $crons[ $timestamp ][ $hook_name ] ); |
|
223 | + unset($crons[$timestamp][$hook_name]); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | //also take care of any empty cron timestamps. |
227 | - if ( empty( $hooks_to_fire_at_time ) ) { |
|
228 | - unset( $crons[ $timestamp ] ); |
|
227 | + if (empty($hooks_to_fire_at_time)) { |
|
228 | + unset($crons[$timestamp]); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | - _set_cron_array( $crons ); |
|
232 | + _set_cron_array($crons); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public static function CPT_initialization() { |
246 | 246 | // register Custom Post Types |
247 | - EE_Registry::instance()->load_core( 'Register_CPTs' ); |
|
247 | + EE_Registry::instance()->load_core('Register_CPTs'); |
|
248 | 248 | flush_rewrite_rules(); |
249 | 249 | } |
250 | 250 | |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @return void |
263 | 263 | */ |
264 | 264 | public static function reset_and_update_config() { |
265 | - do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) ); |
|
266 | - add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 ); |
|
265 | + do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config')); |
|
266 | + add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3); |
|
267 | 267 | //EE_Config::reset(); |
268 | 268 | } |
269 | 269 | |
@@ -276,28 +276,28 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public static function load_calendar_config() { |
278 | 278 | // grab array of all plugin folders and loop thru it |
279 | - $plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR ); |
|
280 | - if ( empty( $plugins ) ) { |
|
279 | + $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR); |
|
280 | + if (empty($plugins)) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | - foreach ( $plugins as $plugin_path ) { |
|
283 | + foreach ($plugins as $plugin_path) { |
|
284 | 284 | // grab plugin folder name from path |
285 | - $plugin = basename( $plugin_path ); |
|
285 | + $plugin = basename($plugin_path); |
|
286 | 286 | // drill down to Espresso plugins |
287 | 287 | // then to calendar related plugins |
288 | 288 | if ( |
289 | - strpos( $plugin, 'espresso' ) !== FALSE |
|
290 | - || strpos( $plugin, 'Espresso' ) !== FALSE |
|
291 | - || strpos( $plugin, 'ee4' ) !== FALSE |
|
292 | - || strpos( $plugin, 'EE4' ) !== FALSE |
|
293 | - || strpos( $plugin, 'calendar' ) !== false |
|
289 | + strpos($plugin, 'espresso') !== FALSE |
|
290 | + || strpos($plugin, 'Espresso') !== FALSE |
|
291 | + || strpos($plugin, 'ee4') !== FALSE |
|
292 | + || strpos($plugin, 'EE4') !== FALSE |
|
293 | + || strpos($plugin, 'calendar') !== false |
|
294 | 294 | ) { |
295 | 295 | // this is what we are looking for |
296 | - $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php'; |
|
296 | + $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php'; |
|
297 | 297 | // does it exist in this folder ? |
298 | - if ( is_readable( $calendar_config )) { |
|
298 | + if (is_readable($calendar_config)) { |
|
299 | 299 | // YEAH! let's load it |
300 | - require_once( $calendar_config ); |
|
300 | + require_once($calendar_config); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | } |
@@ -313,21 +313,21 @@ discard block |
||
313 | 313 | * @param \EE_Config $EE_Config |
314 | 314 | * @return \stdClass |
315 | 315 | */ |
316 | - public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) { |
|
317 | - $convert_from_array = array( 'addons' ); |
|
316 | + public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) { |
|
317 | + $convert_from_array = array('addons'); |
|
318 | 318 | // in case old settings were saved as an array |
319 | - if ( is_array( $settings ) && in_array( $config, $convert_from_array )) { |
|
319 | + if (is_array($settings) && in_array($config, $convert_from_array)) { |
|
320 | 320 | // convert existing settings to an object |
321 | 321 | $config_array = $settings; |
322 | 322 | $settings = new stdClass(); |
323 | - foreach ( $config_array as $key => $value ){ |
|
324 | - if ( $key === 'calendar' && class_exists( 'EE_Calendar_Config' )) { |
|
325 | - $EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value ); |
|
323 | + foreach ($config_array as $key => $value) { |
|
324 | + if ($key === 'calendar' && class_exists('EE_Calendar_Config')) { |
|
325 | + $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value); |
|
326 | 326 | } else { |
327 | 327 | $settings->{$key} = $value; |
328 | 328 | } |
329 | 329 | } |
330 | - add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' ); |
|
330 | + add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true'); |
|
331 | 331 | } |
332 | 332 | return $settings; |
333 | 333 | } |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | */ |
344 | 344 | public static function deactivate_event_espresso() { |
345 | 345 | // check permissions |
346 | - if ( current_user_can( 'activate_plugins' )) { |
|
347 | - deactivate_plugins( EE_PLUGIN_BASENAME, TRUE ); |
|
346 | + if (current_user_can('activate_plugins')) { |
|
347 | + deactivate_plugins(EE_PLUGIN_BASENAME, TRUE); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
@@ -366,25 +366,25 @@ discard block |
||
366 | 366 | $critical_pages = array( |
367 | 367 | array( |
368 | 368 | 'id' =>'reg_page_id', |
369 | - 'name' => __( 'Registration Checkout', 'event_espresso' ), |
|
369 | + 'name' => __('Registration Checkout', 'event_espresso'), |
|
370 | 370 | 'post' => NULL, |
371 | 371 | 'code' => 'ESPRESSO_CHECKOUT' |
372 | 372 | ), |
373 | 373 | array( |
374 | 374 | 'id' => 'txn_page_id', |
375 | - 'name' => __( 'Transactions', 'event_espresso' ), |
|
375 | + 'name' => __('Transactions', 'event_espresso'), |
|
376 | 376 | 'post' => NULL, |
377 | 377 | 'code' => 'ESPRESSO_TXN_PAGE' |
378 | 378 | ), |
379 | 379 | array( |
380 | 380 | 'id' => 'thank_you_page_id', |
381 | - 'name' => __( 'Thank You', 'event_espresso' ), |
|
381 | + 'name' => __('Thank You', 'event_espresso'), |
|
382 | 382 | 'post' => NULL, |
383 | 383 | 'code' => 'ESPRESSO_THANK_YOU' |
384 | 384 | ), |
385 | 385 | array( |
386 | 386 | 'id' => 'cancel_page_id', |
387 | - 'name' => __( 'Registration Cancelled', 'event_espresso' ), |
|
387 | + 'name' => __('Registration Cancelled', 'event_espresso'), |
|
388 | 388 | 'post' => NULL, |
389 | 389 | 'code' => 'ESPRESSO_CANCELLED' |
390 | 390 | ), |
@@ -392,62 +392,62 @@ discard block |
||
392 | 392 | |
393 | 393 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
394 | 394 | |
395 | - foreach ( $critical_pages as $critical_page ) { |
|
395 | + foreach ($critical_pages as $critical_page) { |
|
396 | 396 | // is critical page ID set in config ? |
397 | - if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) { |
|
397 | + if ($EE_Core_Config->{$critical_page['id']} !== FALSE) { |
|
398 | 398 | // attempt to find post by ID |
399 | - $critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} ); |
|
399 | + $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} ); |
|
400 | 400 | } |
401 | 401 | // no dice? |
402 | - if ( $critical_page['post'] === null ) { |
|
402 | + if ($critical_page['post'] === null) { |
|
403 | 403 | // attempt to find post by title |
404 | - $critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] ); |
|
404 | + $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']); |
|
405 | 405 | // still nothing? |
406 | - if ( $critical_page['post'] === null ) { |
|
407 | - $critical_page = EEH_Activation::create_critical_page( $critical_page ); |
|
406 | + if ($critical_page['post'] === null) { |
|
407 | + $critical_page = EEH_Activation::create_critical_page($critical_page); |
|
408 | 408 | // REALLY? Still nothing ??!?!? |
409 | - if ( $critical_page['post'] === null ) { |
|
410 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
411 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
409 | + if ($critical_page['post'] === null) { |
|
410 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
411 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
412 | 412 | break; |
413 | 413 | } |
414 | 414 | } |
415 | 415 | } |
416 | 416 | // track post_shortcodes |
417 | - if ( $critical_page['post'] ) { |
|
418 | - EEH_Activation::_track_critical_page_post_shortcodes( $critical_page ); |
|
417 | + if ($critical_page['post']) { |
|
418 | + EEH_Activation::_track_critical_page_post_shortcodes($critical_page); |
|
419 | 419 | } |
420 | 420 | // check that Post ID matches critical page ID in config |
421 | 421 | if ( |
422 | - isset( $critical_page['post']->ID ) |
|
423 | - && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page[ 'id' ]} |
|
422 | + isset($critical_page['post']->ID) |
|
423 | + && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']} |
|
424 | 424 | ) { |
425 | 425 | //update Config with post ID |
426 | - $EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID; |
|
427 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) { |
|
428 | - $msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' ); |
|
429 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
426 | + $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID; |
|
427 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
428 | + $msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso'); |
|
429 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | |
433 | 433 | $critical_page_problem = |
434 | - ! isset( $critical_page['post']->post_status ) |
|
434 | + ! isset($critical_page['post']->post_status) |
|
435 | 435 | || $critical_page['post']->post_status !== 'publish' |
436 | - || strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE |
|
436 | + || strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE |
|
437 | 437 | ? TRUE |
438 | 438 | : $critical_page_problem; |
439 | 439 | |
440 | 440 | } |
441 | 441 | |
442 | - if ( $critical_page_problem ) { |
|
442 | + if ($critical_page_problem) { |
|
443 | 443 | $msg = sprintf( |
444 | - __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ), |
|
445 | - '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>' |
|
444 | + __('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'), |
|
445 | + '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>' |
|
446 | 446 | ); |
447 | - EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg ); |
|
447 | + EE_Error::add_persistent_admin_notice('critical_page_problem', $msg); |
|
448 | 448 | } |
449 | - if ( EE_Error::has_notices() ) { |
|
450 | - EE_Error::get_notices( FALSE, TRUE, TRUE ); |
|
449 | + if (EE_Error::has_notices()) { |
|
450 | + EE_Error::get_notices(FALSE, TRUE, TRUE); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
@@ -459,13 +459,13 @@ discard block |
||
459 | 459 | * parameter to the shortcode |
460 | 460 | * @return WP_Post or NULl |
461 | 461 | */ |
462 | - public static function get_page_by_ee_shortcode($ee_shortcode){ |
|
462 | + public static function get_page_by_ee_shortcode($ee_shortcode) { |
|
463 | 463 | global $wpdb; |
464 | 464 | $shortcode_and_opening_bracket = '['.$ee_shortcode; |
465 | 465 | $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1"); |
466 | - if($post_id){ |
|
466 | + if ($post_id) { |
|
467 | 467 | return get_post($post_id); |
468 | - }else{ |
|
468 | + } else { |
|
469 | 469 | return NULL; |
470 | 470 | } |
471 | 471 | |
@@ -482,32 +482,32 @@ discard block |
||
482 | 482 | * @param array $critical_page |
483 | 483 | * @return array |
484 | 484 | */ |
485 | - public static function create_critical_page( $critical_page ) { |
|
485 | + public static function create_critical_page($critical_page) { |
|
486 | 486 | |
487 | 487 | $post_args = array( |
488 | 488 | 'post_title' => $critical_page['name'], |
489 | 489 | 'post_status' => 'publish', |
490 | 490 | 'post_type' => 'page', |
491 | 491 | 'comment_status' => 'closed', |
492 | - 'post_content' => '[' . $critical_page['code'] . ']' |
|
492 | + 'post_content' => '['.$critical_page['code'].']' |
|
493 | 493 | ); |
494 | 494 | |
495 | - $post_id = wp_insert_post( $post_args ); |
|
496 | - if ( ! $post_id ) { |
|
495 | + $post_id = wp_insert_post($post_args); |
|
496 | + if ( ! $post_id) { |
|
497 | 497 | $msg = sprintf( |
498 | - __( 'The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso' ), |
|
498 | + __('The Event Espresso critical page entitled "%s" could not be created.', 'event_espresso'), |
|
499 | 499 | $critical_page['name'] |
500 | 500 | ); |
501 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
501 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
502 | 502 | return $critical_page; |
503 | 503 | } |
504 | 504 | // get newly created post's details |
505 | - if ( ! $critical_page['post'] = get_post( $post_id )) { |
|
505 | + if ( ! $critical_page['post'] = get_post($post_id)) { |
|
506 | 506 | $msg = sprintf( |
507 | - __( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ), |
|
507 | + __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'), |
|
508 | 508 | $critical_page['name'] |
509 | 509 | ); |
510 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
510 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | return $critical_page; |
@@ -526,35 +526,35 @@ discard block |
||
526 | 526 | * @param array $critical_page |
527 | 527 | * @return void |
528 | 528 | */ |
529 | - private static function _track_critical_page_post_shortcodes( $critical_page = array() ) { |
|
529 | + private static function _track_critical_page_post_shortcodes($critical_page = array()) { |
|
530 | 530 | // check the goods |
531 | - if ( ! $critical_page['post'] instanceof WP_Post ) { |
|
531 | + if ( ! $critical_page['post'] instanceof WP_Post) { |
|
532 | 532 | $msg = sprintf( |
533 | - __( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ), |
|
533 | + __('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'), |
|
534 | 534 | $critical_page['name'] |
535 | 535 | ); |
536 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
536 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
537 | 537 | return; |
538 | 538 | } |
539 | 539 | $EE_Core_Config = EE_Registry::instance()->CFG->core; |
540 | 540 | // map shortcode to post |
541 | - $EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID; |
|
541 | + $EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID; |
|
542 | 542 | // and make sure it's NOT added to the WP "Posts Page" |
543 | 543 | // name of the WP Posts Page |
544 | 544 | $posts_page = EE_Config::get_page_for_posts(); |
545 | - if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) { |
|
546 | - unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] ); |
|
545 | + if (isset($EE_Core_Config->post_shortcodes[$posts_page])) { |
|
546 | + unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]); |
|
547 | 547 | } |
548 | - if ( $posts_page !== 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) { |
|
549 | - unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] ); |
|
548 | + if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) { |
|
549 | + unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]); |
|
550 | 550 | } |
551 | 551 | // update post_shortcode CFG |
552 | - if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) { |
|
552 | + if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) { |
|
553 | 553 | $msg = sprintf( |
554 | - __( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ), |
|
554 | + __('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'), |
|
555 | 555 | $critical_page['name'] |
556 | 556 | ); |
557 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
557 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
@@ -572,24 +572,24 @@ discard block |
||
572 | 572 | public static function get_default_creator_id() { |
573 | 573 | global $wpdb; |
574 | 574 | |
575 | - if ( ! empty( self::$_default_creator_id ) ) { |
|
575 | + if ( ! empty(self::$_default_creator_id)) { |
|
576 | 576 | return self::$_default_creator_id; |
577 | 577 | }/**/ |
578 | 578 | |
579 | - $role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' ); |
|
579 | + $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator'); |
|
580 | 580 | |
581 | 581 | //let's allow pre_filtering for early exits by alternative methods for getting id. We check for truthy result and if so then exit early. |
582 | - $pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check ); |
|
583 | - if ( $pre_filtered_id !== false ) { |
|
582 | + $pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check); |
|
583 | + if ($pre_filtered_id !== false) { |
|
584 | 584 | return (int) $pre_filtered_id; |
585 | 585 | } |
586 | 586 | |
587 | - $capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' ); |
|
588 | - $query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' ); |
|
589 | - $user_id = $wpdb->get_var( $query ); |
|
590 | - $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id ); |
|
591 | - if ( $user_id && (int)$user_id ) { |
|
592 | - self::$_default_creator_id = (int)$user_id; |
|
587 | + $capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities'); |
|
588 | + $query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%'); |
|
589 | + $user_id = $wpdb->get_var($query); |
|
590 | + $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id); |
|
591 | + if ($user_id && (int) $user_id) { |
|
592 | + self::$_default_creator_id = (int) $user_id; |
|
593 | 593 | return self::$_default_creator_id; |
594 | 594 | } else { |
595 | 595 | return NULL; |
@@ -616,29 +616,29 @@ discard block |
||
616 | 616 | * @return void |
617 | 617 | * @throws EE_Error if there are database errors |
618 | 618 | */ |
619 | - public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) { |
|
620 | - if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){ |
|
619 | + public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) { |
|
620 | + if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) { |
|
621 | 621 | return; |
622 | 622 | } |
623 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
624 | - if ( ! function_exists( 'dbDelta' )) { |
|
625 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
623 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
624 | + if ( ! function_exists('dbDelta')) { |
|
625 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
626 | 626 | } |
627 | 627 | /** @var WPDB $wpdb */ |
628 | 628 | global $wpdb; |
629 | - $wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
629 | + $wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
630 | 630 | // do we need to first delete an existing version of this table ? |
631 | - if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){ |
|
631 | + if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) { |
|
632 | 632 | // ok, delete the table... but ONLY if it's empty |
633 | - $deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name ); |
|
633 | + $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name); |
|
634 | 634 | // table is NOT empty, are you SURE you want to delete this table ??? |
635 | - if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){ |
|
636 | - EEH_Activation::delete_unused_db_table( $wp_table_name ); |
|
637 | - } else if ( ! $deleted_safely ) { |
|
635 | + if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) { |
|
636 | + EEH_Activation::delete_unused_db_table($wp_table_name); |
|
637 | + } else if ( ! $deleted_safely) { |
|
638 | 638 | // so we should be more cautious rather than just dropping tables so easily |
639 | 639 | EE_Error::add_persistent_admin_notice( |
640 | - 'bad_table_' . $wp_table_name . '_detected', |
|
641 | - sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ), |
|
640 | + 'bad_table_'.$wp_table_name.'_detected', |
|
641 | + sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'), |
|
642 | 642 | $wp_table_name, |
643 | 643 | "<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>", |
644 | 644 | '<b>wp-config.php</b>', |
@@ -647,25 +647,25 @@ discard block |
||
647 | 647 | } |
648 | 648 | } |
649 | 649 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
650 | - if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) { |
|
650 | + if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) { |
|
651 | 651 | $SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
652 | 652 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
653 | 653 | //happened. And then we can choose to tell the end user |
654 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
655 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
654 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
655 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
656 | 656 | ob_start(); |
657 | - dbDelta( $SQL ); |
|
657 | + dbDelta($SQL); |
|
658 | 658 | $output = ob_get_contents(); |
659 | 659 | ob_end_clean(); |
660 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
661 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
662 | - if( ! empty( $output ) ){ |
|
663 | - throw new EE_Error( $output ); |
|
660 | + $wpdb->show_errors($old_show_errors_policy); |
|
661 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
662 | + if ( ! empty($output)) { |
|
663 | + throw new EE_Error($output); |
|
664 | 664 | } |
665 | 665 | } else { |
666 | 666 | throw new EE_Error( |
667 | 667 | sprintf( |
668 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
668 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
669 | 669 | '<br />', |
670 | 670 | $sql |
671 | 671 | ) |
@@ -688,15 +688,15 @@ discard block |
||
688 | 688 | * 'VARCHAR(10)' |
689 | 689 | * @return bool|int |
690 | 690 | */ |
691 | - public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){ |
|
692 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
691 | + public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') { |
|
692 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
693 | 693 | return FALSE; |
694 | 694 | } |
695 | 695 | global $wpdb; |
696 | - $full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
696 | + $full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
697 | 697 | $fields = self::get_fields_on_table($table_name); |
698 | - if (!in_array($column_name, $fields)){ |
|
699 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
698 | + if ( ! in_array($column_name, $fields)) { |
|
699 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
700 | 700 | //echo "alter query:$alter_query"; |
701 | 701 | return $wpdb->query($alter_query); |
702 | 702 | } |
@@ -715,14 +715,14 @@ discard block |
||
715 | 715 | * @param string $table_name, without prefixed $wpdb->prefix |
716 | 716 | * @return array of database column names |
717 | 717 | */ |
718 | - public static function get_fields_on_table( $table_name = NULL ) { |
|
718 | + public static function get_fields_on_table($table_name = NULL) { |
|
719 | 719 | global $wpdb; |
720 | - $table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
721 | - if ( ! empty( $table_name )) { |
|
720 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
721 | + if ( ! empty($table_name)) { |
|
722 | 722 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
723 | 723 | if ($columns !== FALSE) { |
724 | 724 | $field_array = array(); |
725 | - foreach($columns as $column ){ |
|
725 | + foreach ($columns as $column) { |
|
726 | 726 | $field_array[] = $column->Field; |
727 | 727 | } |
728 | 728 | return $field_array; |
@@ -741,12 +741,12 @@ discard block |
||
741 | 741 | * @param string $table_name |
742 | 742 | * @return bool |
743 | 743 | */ |
744 | - public static function db_table_is_empty( $table_name ) { |
|
744 | + public static function db_table_is_empty($table_name) { |
|
745 | 745 | global $wpdb; |
746 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
747 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
748 | - $count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" ); |
|
749 | - return absint( $count ) === 0 ? true : false; |
|
746 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
747 | + if (EEH_Activation::table_exists($table_name)) { |
|
748 | + $count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name"); |
|
749 | + return absint($count) === 0 ? true : false; |
|
750 | 750 | } |
751 | 751 | return false; |
752 | 752 | } |
@@ -761,9 +761,9 @@ discard block |
||
761 | 761 | * @param string $table_name |
762 | 762 | * @return bool | int |
763 | 763 | */ |
764 | - public static function delete_db_table_if_empty( $table_name ) { |
|
765 | - if ( EEH_Activation::db_table_is_empty( $table_name ) ) { |
|
766 | - return EEH_Activation::delete_unused_db_table( $table_name ); |
|
764 | + public static function delete_db_table_if_empty($table_name) { |
|
765 | + if (EEH_Activation::db_table_is_empty($table_name)) { |
|
766 | + return EEH_Activation::delete_unused_db_table($table_name); |
|
767 | 767 | } |
768 | 768 | return false; |
769 | 769 | } |
@@ -778,11 +778,11 @@ discard block |
||
778 | 778 | * @param string $table_name |
779 | 779 | * @return bool | int |
780 | 780 | */ |
781 | - public static function delete_unused_db_table( $table_name ) { |
|
781 | + public static function delete_unused_db_table($table_name) { |
|
782 | 782 | global $wpdb; |
783 | - if ( EEH_Activation::table_exists( $table_name ) ) { |
|
784 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
785 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
783 | + if (EEH_Activation::table_exists($table_name)) { |
|
784 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
785 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
786 | 786 | } |
787 | 787 | return false; |
788 | 788 | } |
@@ -798,18 +798,18 @@ discard block |
||
798 | 798 | * @param string $index_name |
799 | 799 | * @return bool | int |
800 | 800 | */ |
801 | - public static function drop_index( $table_name, $index_name ) { |
|
802 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
801 | + public static function drop_index($table_name, $index_name) { |
|
802 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
803 | 803 | return FALSE; |
804 | 804 | } |
805 | 805 | global $wpdb; |
806 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
806 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
807 | 807 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'"; |
808 | 808 | if ( |
809 | - $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) === $table_name |
|
810 | - && $wpdb->get_var( $index_exists_query ) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
809 | + $wpdb->get_var("SHOW TABLES LIKE '$table_name'") === $table_name |
|
810 | + && $wpdb->get_var($index_exists_query) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
811 | 811 | ) { |
812 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" ); |
|
812 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name"); |
|
813 | 813 | } |
814 | 814 | return TRUE; |
815 | 815 | } |
@@ -825,27 +825,27 @@ discard block |
||
825 | 825 | * @return boolean success (whether database is setup properly or not) |
826 | 826 | */ |
827 | 827 | public static function create_database_tables() { |
828 | - EE_Registry::instance()->load_core( 'Data_Migration_Manager' ); |
|
828 | + EE_Registry::instance()->load_core('Data_Migration_Manager'); |
|
829 | 829 | //find the migration script that sets the database to be compatible with the code |
830 | 830 | $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms(); |
831 | - if( $dms_name ){ |
|
832 | - $current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name ); |
|
833 | - $current_data_migration_script->set_migrating( false ); |
|
831 | + if ($dms_name) { |
|
832 | + $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name); |
|
833 | + $current_data_migration_script->set_migrating(false); |
|
834 | 834 | $current_data_migration_script->schema_changes_before_migration(); |
835 | 835 | $current_data_migration_script->schema_changes_after_migration(); |
836 | - if( $current_data_migration_script->get_errors() ){ |
|
837 | - if( WP_DEBUG ){ |
|
838 | - foreach( $current_data_migration_script->get_errors() as $error ){ |
|
839 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ ); |
|
836 | + if ($current_data_migration_script->get_errors()) { |
|
837 | + if (WP_DEBUG) { |
|
838 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
839 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
840 | 840 | } |
841 | - }else{ |
|
842 | - EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) ); |
|
841 | + } else { |
|
842 | + EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso')); |
|
843 | 843 | } |
844 | 844 | return false; |
845 | 845 | } |
846 | 846 | EE_Data_Migration_Manager::instance()->update_current_database_state_to(); |
847 | - }else{ |
|
848 | - EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
847 | + } else { |
|
848 | + EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
849 | 849 | return false; |
850 | 850 | } |
851 | 851 | return true; |
@@ -865,27 +865,27 @@ discard block |
||
865 | 865 | public static function initialize_system_questions() { |
866 | 866 | // QUESTION GROUPS |
867 | 867 | global $wpdb; |
868 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' ); |
|
868 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group'); |
|
869 | 869 | $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0"; |
870 | 870 | // what we have |
871 | - $question_groups = $wpdb->get_col( $SQL ); |
|
871 | + $question_groups = $wpdb->get_col($SQL); |
|
872 | 872 | // check the response |
873 | - $question_groups = is_array( $question_groups ) ? $question_groups : array(); |
|
873 | + $question_groups = is_array($question_groups) ? $question_groups : array(); |
|
874 | 874 | // what we should have |
875 | - $QSG_systems = array( 1, 2 ); |
|
875 | + $QSG_systems = array(1, 2); |
|
876 | 876 | // loop thru what we should have and compare to what we have |
877 | - foreach ( $QSG_systems as $QSG_system ) { |
|
877 | + foreach ($QSG_systems as $QSG_system) { |
|
878 | 878 | // reset values array |
879 | 879 | $QSG_values = array(); |
880 | 880 | // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db) |
881 | - if ( ! in_array( "$QSG_system", $question_groups )) { |
|
881 | + if ( ! in_array("$QSG_system", $question_groups)) { |
|
882 | 882 | // add it |
883 | - switch ( $QSG_system ) { |
|
883 | + switch ($QSG_system) { |
|
884 | 884 | |
885 | 885 | case 1: |
886 | 886 | $QSG_values = array( |
887 | - 'QSG_name' => __( 'Personal Information', 'event_espresso' ), |
|
888 | - 'QSG_identifier' => 'personal-information-' . time(), |
|
887 | + 'QSG_name' => __('Personal Information', 'event_espresso'), |
|
888 | + 'QSG_identifier' => 'personal-information-'.time(), |
|
889 | 889 | 'QSG_desc' => '', |
890 | 890 | 'QSG_order' => 1, |
891 | 891 | 'QSG_show_group_name' => 1, |
@@ -897,8 +897,8 @@ discard block |
||
897 | 897 | |
898 | 898 | case 2: |
899 | 899 | $QSG_values = array( |
900 | - 'QSG_name' => __( 'Address Information','event_espresso' ), |
|
901 | - 'QSG_identifier' => 'address-information-' . time(), |
|
900 | + 'QSG_name' => __('Address Information', 'event_espresso'), |
|
901 | + 'QSG_identifier' => 'address-information-'.time(), |
|
902 | 902 | 'QSG_desc' => '', |
903 | 903 | 'QSG_order' => 2, |
904 | 904 | 'QSG_show_group_name' => 1, |
@@ -910,14 +910,14 @@ discard block |
||
910 | 910 | |
911 | 911 | } |
912 | 912 | // make sure we have some values before inserting them |
913 | - if ( ! empty( $QSG_values )) { |
|
913 | + if ( ! empty($QSG_values)) { |
|
914 | 914 | // insert system question |
915 | 915 | $wpdb->insert( |
916 | 916 | $table_name, |
917 | 917 | $QSG_values, |
918 | - array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' ) |
|
918 | + array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d') |
|
919 | 919 | ); |
920 | - $QSG_IDs[ $QSG_system ] = $wpdb->insert_id; |
|
920 | + $QSG_IDs[$QSG_system] = $wpdb->insert_id; |
|
921 | 921 | } |
922 | 922 | } |
923 | 923 | } |
@@ -926,10 +926,10 @@ discard block |
||
926 | 926 | |
927 | 927 | // QUESTIONS |
928 | 928 | global $wpdb; |
929 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' ); |
|
929 | + $table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question'); |
|
930 | 930 | $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''"; |
931 | 931 | // what we have |
932 | - $questions = $wpdb->get_col( $SQL ); |
|
932 | + $questions = $wpdb->get_col($SQL); |
|
933 | 933 | // what we should have |
934 | 934 | $QST_systems = array( |
935 | 935 | 'fname', |
@@ -946,25 +946,25 @@ discard block |
||
946 | 946 | $order_for_group_1 = 1; |
947 | 947 | $order_for_group_2 = 1; |
948 | 948 | // loop thru what we should have and compare to what we have |
949 | - foreach ( $QST_systems as $QST_system ) { |
|
949 | + foreach ($QST_systems as $QST_system) { |
|
950 | 950 | // reset values array |
951 | 951 | $QST_values = array(); |
952 | 952 | // if we don't have what we should have |
953 | - if ( ! in_array( $QST_system, $questions )) { |
|
953 | + if ( ! in_array($QST_system, $questions)) { |
|
954 | 954 | // add it |
955 | - switch ( $QST_system ) { |
|
955 | + switch ($QST_system) { |
|
956 | 956 | |
957 | 957 | case 'fname': |
958 | 958 | $QST_values = array( |
959 | - 'QST_display_text' => __( 'First Name', 'event_espresso' ), |
|
960 | - 'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ), |
|
959 | + 'QST_display_text' => __('First Name', 'event_espresso'), |
|
960 | + 'QST_admin_label' => __('First Name - System Question', 'event_espresso'), |
|
961 | 961 | 'QST_system' => 'fname', |
962 | 962 | 'QST_type' => 'TEXT', |
963 | 963 | 'QST_required' => 1, |
964 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
964 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
965 | 965 | 'QST_order' => 1, |
966 | 966 | 'QST_admin_only' => 0, |
967 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
967 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
968 | 968 | 'QST_wp_user' => self::get_default_creator_id(), |
969 | 969 | 'QST_deleted' => 0 |
970 | 970 | ); |
@@ -972,15 +972,15 @@ discard block |
||
972 | 972 | |
973 | 973 | case 'lname': |
974 | 974 | $QST_values = array( |
975 | - 'QST_display_text' => __( 'Last Name', 'event_espresso' ), |
|
976 | - 'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ), |
|
975 | + 'QST_display_text' => __('Last Name', 'event_espresso'), |
|
976 | + 'QST_admin_label' => __('Last Name - System Question', 'event_espresso'), |
|
977 | 977 | 'QST_system' => 'lname', |
978 | 978 | 'QST_type' => 'TEXT', |
979 | 979 | 'QST_required' => 1, |
980 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
980 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
981 | 981 | 'QST_order' => 2, |
982 | 982 | 'QST_admin_only' => 0, |
983 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
983 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
984 | 984 | 'QST_wp_user' => self::get_default_creator_id(), |
985 | 985 | 'QST_deleted' => 0 |
986 | 986 | ); |
@@ -988,15 +988,15 @@ discard block |
||
988 | 988 | |
989 | 989 | case 'email': |
990 | 990 | $QST_values = array( |
991 | - 'QST_display_text' => __( 'Email Address', 'event_espresso' ), |
|
992 | - 'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ), |
|
991 | + 'QST_display_text' => __('Email Address', 'event_espresso'), |
|
992 | + 'QST_admin_label' => __('Email Address - System Question', 'event_espresso'), |
|
993 | 993 | 'QST_system' => 'email', |
994 | 994 | 'QST_type' => 'EMAIL', |
995 | 995 | 'QST_required' => 1, |
996 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
996 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
997 | 997 | 'QST_order' => 3, |
998 | 998 | 'QST_admin_only' => 0, |
999 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
999 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1000 | 1000 | 'QST_wp_user' => self::get_default_creator_id(), |
1001 | 1001 | 'QST_deleted' => 0 |
1002 | 1002 | ); |
@@ -1004,15 +1004,15 @@ discard block |
||
1004 | 1004 | |
1005 | 1005 | case 'address': |
1006 | 1006 | $QST_values = array( |
1007 | - 'QST_display_text' => __( 'Address', 'event_espresso' ), |
|
1008 | - 'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ), |
|
1007 | + 'QST_display_text' => __('Address', 'event_espresso'), |
|
1008 | + 'QST_admin_label' => __('Address - System Question', 'event_espresso'), |
|
1009 | 1009 | 'QST_system' => 'address', |
1010 | 1010 | 'QST_type' => 'TEXT', |
1011 | 1011 | 'QST_required' => 0, |
1012 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1012 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1013 | 1013 | 'QST_order' => 4, |
1014 | 1014 | 'QST_admin_only' => 0, |
1015 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1015 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1016 | 1016 | 'QST_wp_user' => self::get_default_creator_id(), |
1017 | 1017 | 'QST_deleted' => 0 |
1018 | 1018 | ); |
@@ -1020,15 +1020,15 @@ discard block |
||
1020 | 1020 | |
1021 | 1021 | case 'address2': |
1022 | 1022 | $QST_values = array( |
1023 | - 'QST_display_text' => __( 'Address2', 'event_espresso' ), |
|
1024 | - 'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ), |
|
1023 | + 'QST_display_text' => __('Address2', 'event_espresso'), |
|
1024 | + 'QST_admin_label' => __('Address2 - System Question', 'event_espresso'), |
|
1025 | 1025 | 'QST_system' => 'address2', |
1026 | 1026 | 'QST_type' => 'TEXT', |
1027 | 1027 | 'QST_required' => 0, |
1028 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1028 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1029 | 1029 | 'QST_order' => 5, |
1030 | 1030 | 'QST_admin_only' => 0, |
1031 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1031 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1032 | 1032 | 'QST_wp_user' => self::get_default_creator_id(), |
1033 | 1033 | 'QST_deleted' => 0 |
1034 | 1034 | ); |
@@ -1036,15 +1036,15 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | case 'city': |
1038 | 1038 | $QST_values = array( |
1039 | - 'QST_display_text' => __( 'City', 'event_espresso' ), |
|
1040 | - 'QST_admin_label' => __( 'City - System Question', 'event_espresso' ), |
|
1039 | + 'QST_display_text' => __('City', 'event_espresso'), |
|
1040 | + 'QST_admin_label' => __('City - System Question', 'event_espresso'), |
|
1041 | 1041 | 'QST_system' => 'city', |
1042 | 1042 | 'QST_type' => 'TEXT', |
1043 | 1043 | 'QST_required' => 0, |
1044 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1044 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1045 | 1045 | 'QST_order' => 6, |
1046 | 1046 | 'QST_admin_only' => 0, |
1047 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1047 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1048 | 1048 | 'QST_wp_user' => self::get_default_creator_id(), |
1049 | 1049 | 'QST_deleted' => 0 |
1050 | 1050 | ); |
@@ -1052,12 +1052,12 @@ discard block |
||
1052 | 1052 | |
1053 | 1053 | case 'state': |
1054 | 1054 | $QST_values = array( |
1055 | - 'QST_display_text' => __( 'State/Province', 'event_espresso' ), |
|
1056 | - 'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ), |
|
1055 | + 'QST_display_text' => __('State/Province', 'event_espresso'), |
|
1056 | + 'QST_admin_label' => __('State/Province - System Question', 'event_espresso'), |
|
1057 | 1057 | 'QST_system' => 'state', |
1058 | 1058 | 'QST_type' => 'STATE', |
1059 | 1059 | 'QST_required' => 0, |
1060 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1060 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1061 | 1061 | 'QST_order' => 7, |
1062 | 1062 | 'QST_admin_only' => 0, |
1063 | 1063 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1067,12 +1067,12 @@ discard block |
||
1067 | 1067 | |
1068 | 1068 | case 'country' : |
1069 | 1069 | $QST_values = array( |
1070 | - 'QST_display_text' => __( 'Country', 'event_espresso' ), |
|
1071 | - 'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ), |
|
1070 | + 'QST_display_text' => __('Country', 'event_espresso'), |
|
1071 | + 'QST_admin_label' => __('Country - System Question', 'event_espresso'), |
|
1072 | 1072 | 'QST_system' => 'country', |
1073 | 1073 | 'QST_type' => 'COUNTRY', |
1074 | 1074 | 'QST_required' => 0, |
1075 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1075 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1076 | 1076 | 'QST_order' => 8, |
1077 | 1077 | 'QST_admin_only' => 0, |
1078 | 1078 | 'QST_wp_user' => self::get_default_creator_id(), |
@@ -1082,15 +1082,15 @@ discard block |
||
1082 | 1082 | |
1083 | 1083 | case 'zip': |
1084 | 1084 | $QST_values = array( |
1085 | - 'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ), |
|
1086 | - 'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ), |
|
1085 | + 'QST_display_text' => __('Zip/Postal Code', 'event_espresso'), |
|
1086 | + 'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'), |
|
1087 | 1087 | 'QST_system' => 'zip', |
1088 | 1088 | 'QST_type' => 'TEXT', |
1089 | 1089 | 'QST_required' => 0, |
1090 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1090 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1091 | 1091 | 'QST_order' => 9, |
1092 | 1092 | 'QST_admin_only' => 0, |
1093 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1093 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1094 | 1094 | 'QST_wp_user' => self::get_default_creator_id(), |
1095 | 1095 | 'QST_deleted' => 0 |
1096 | 1096 | ); |
@@ -1098,49 +1098,49 @@ discard block |
||
1098 | 1098 | |
1099 | 1099 | case 'phone': |
1100 | 1100 | $QST_values = array( |
1101 | - 'QST_display_text' => __( 'Phone Number', 'event_espresso' ), |
|
1102 | - 'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ), |
|
1101 | + 'QST_display_text' => __('Phone Number', 'event_espresso'), |
|
1102 | + 'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'), |
|
1103 | 1103 | 'QST_system' => 'phone', |
1104 | 1104 | 'QST_type' => 'TEXT', |
1105 | 1105 | 'QST_required' => 0, |
1106 | - 'QST_required_text' => __( 'This field is required', 'event_espresso' ), |
|
1106 | + 'QST_required_text' => __('This field is required', 'event_espresso'), |
|
1107 | 1107 | 'QST_order' => 10, |
1108 | 1108 | 'QST_admin_only' => 0, |
1109 | - 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ), |
|
1109 | + 'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system), |
|
1110 | 1110 | 'QST_wp_user' => self::get_default_creator_id(), |
1111 | 1111 | 'QST_deleted' => 0 |
1112 | 1112 | ); |
1113 | 1113 | break; |
1114 | 1114 | |
1115 | 1115 | } |
1116 | - if ( ! empty( $QST_values )) { |
|
1116 | + if ( ! empty($QST_values)) { |
|
1117 | 1117 | // insert system question |
1118 | 1118 | $wpdb->insert( |
1119 | 1119 | $table_name, |
1120 | 1120 | $QST_values, |
1121 | - array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' ) |
|
1121 | + array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d') |
|
1122 | 1122 | ); |
1123 | 1123 | $QST_ID = $wpdb->insert_id; |
1124 | 1124 | |
1125 | 1125 | // QUESTION GROUP QUESTIONS |
1126 | - if( in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) { |
|
1126 | + if (in_array($QST_system, array('fname', 'lname', 'email'))) { |
|
1127 | 1127 | $system_question_we_want = EEM_Question_Group::system_personal; |
1128 | 1128 | } else { |
1129 | 1129 | $system_question_we_want = EEM_Question_Group::system_address; |
1130 | 1130 | } |
1131 | - if( isset( $QSG_IDs[ $system_question_we_want ] ) ) { |
|
1132 | - $QSG_ID = $QSG_IDs[ $system_question_we_want ]; |
|
1131 | + if (isset($QSG_IDs[$system_question_we_want])) { |
|
1132 | + $QSG_ID = $QSG_IDs[$system_question_we_want]; |
|
1133 | 1133 | } else { |
1134 | - $id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) ); |
|
1135 | - if( is_array( $id_col ) ) { |
|
1136 | - $QSG_ID = reset( $id_col ); |
|
1134 | + $id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want))); |
|
1135 | + if (is_array($id_col)) { |
|
1136 | + $QSG_ID = reset($id_col); |
|
1137 | 1137 | } else { |
1138 | 1138 | //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method |
1139 | 1139 | EE_Log::instance()->log( |
1140 | 1140 | __FILE__, |
1141 | 1141 | __FUNCTION__, |
1142 | 1142 | sprintf( |
1143 | - __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1143 | + __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'), |
|
1144 | 1144 | $QST_ID ), |
1145 | 1145 | 'error' ); |
1146 | 1146 | continue; |
@@ -1149,12 +1149,12 @@ discard block |
||
1149 | 1149 | |
1150 | 1150 | // add system questions to groups |
1151 | 1151 | $wpdb->insert( |
1152 | - EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ), |
|
1153 | - array( 'QSG_ID' => $QSG_ID, |
|
1152 | + EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'), |
|
1153 | + array('QSG_ID' => $QSG_ID, |
|
1154 | 1154 | 'QST_ID' => $QST_ID, |
1155 | - 'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++ |
|
1155 | + 'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++ |
|
1156 | 1156 | ), |
1157 | - array( '%d', '%d', '%d' ) |
|
1157 | + array('%d', '%d', '%d') |
|
1158 | 1158 | ); |
1159 | 1159 | } |
1160 | 1160 | } |
@@ -1170,11 +1170,11 @@ discard block |
||
1170 | 1170 | * |
1171 | 1171 | * @throws \EE_Error |
1172 | 1172 | */ |
1173 | - public static function insert_default_payment_methods(){ |
|
1174 | - if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){ |
|
1175 | - EE_Registry::instance()->load_lib( 'Payment_Method_Manager' ); |
|
1176 | - EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' ); |
|
1177 | - }else{ |
|
1173 | + public static function insert_default_payment_methods() { |
|
1174 | + if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) { |
|
1175 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
1176 | + EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice'); |
|
1177 | + } else { |
|
1178 | 1178 | EEM_Payment_Method::instance()->verify_button_urls(); |
1179 | 1179 | } |
1180 | 1180 | } |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | |
1191 | 1191 | global $wpdb; |
1192 | 1192 | |
1193 | - if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) { |
|
1193 | + if (EEH_Activation::table_exists(EEM_Status::instance()->table())) { |
|
1194 | 1194 | |
1195 | 1195 | $table_name = EEM_Status::instance()->table(); |
1196 | 1196 | |
@@ -1265,33 +1265,33 @@ discard block |
||
1265 | 1265 | $folders = array( |
1266 | 1266 | EVENT_ESPRESSO_TEMPLATE_DIR, |
1267 | 1267 | EVENT_ESPRESSO_GATEWAY_DIR, |
1268 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs/', |
|
1269 | - EVENT_ESPRESSO_UPLOAD_DIR . 'css/', |
|
1270 | - EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/' |
|
1268 | + EVENT_ESPRESSO_UPLOAD_DIR.'logs/', |
|
1269 | + EVENT_ESPRESSO_UPLOAD_DIR.'css/', |
|
1270 | + EVENT_ESPRESSO_UPLOAD_DIR.'tickets/' |
|
1271 | 1271 | ); |
1272 | - foreach ( $folders as $folder ) { |
|
1272 | + foreach ($folders as $folder) { |
|
1273 | 1273 | try { |
1274 | - EEH_File::ensure_folder_exists_and_is_writable( $folder ); |
|
1275 | - @ chmod( $folder, 0755 ); |
|
1276 | - } catch( EE_Error $e ){ |
|
1274 | + EEH_File::ensure_folder_exists_and_is_writable($folder); |
|
1275 | + @ chmod($folder, 0755); |
|
1276 | + } catch (EE_Error $e) { |
|
1277 | 1277 | EE_Error::add_error( |
1278 | 1278 | sprintf( |
1279 | - __( 'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ), |
|
1279 | + __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'), |
|
1280 | 1280 | $folder, |
1281 | - '<br />' . $e->getMessage() |
|
1281 | + '<br />'.$e->getMessage() |
|
1282 | 1282 | ), |
1283 | 1283 | __FILE__, __FUNCTION__, __LINE__ |
1284 | 1284 | ); |
1285 | 1285 | //indicate we'll need to fix this later |
1286 | - update_option( EEH_Activation::upload_directories_incomplete_option_name, true ); |
|
1286 | + update_option(EEH_Activation::upload_directories_incomplete_option_name, true); |
|
1287 | 1287 | return FALSE; |
1288 | 1288 | } |
1289 | 1289 | } |
1290 | 1290 | //just add the .htaccess file to the logs directory to begin with. Even if logging |
1291 | 1291 | //is disabled, there might be activation errors recorded in there |
1292 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' ); |
|
1292 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/'); |
|
1293 | 1293 | //remember EE's folders are all good |
1294 | - delete_option( EEH_Activation::upload_directories_incomplete_option_name ); |
|
1294 | + delete_option(EEH_Activation::upload_directories_incomplete_option_name); |
|
1295 | 1295 | return TRUE; |
1296 | 1296 | } |
1297 | 1297 | |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | * @return boolean |
1305 | 1305 | */ |
1306 | 1306 | public static function upload_directories_incomplete() { |
1307 | - return get_option( EEH_Activation::upload_directories_incomplete_option_name, false ); |
|
1307 | + return get_option(EEH_Activation::upload_directories_incomplete_option_name, false); |
|
1308 | 1308 | } |
1309 | 1309 | |
1310 | 1310 | |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | */ |
1322 | 1322 | public static function generate_default_message_templates() { |
1323 | 1323 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1324 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1324 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1325 | 1325 | /* |
1326 | 1326 | * This first method is taking care of ensuring any default messengers |
1327 | 1327 | * that should be made active and have templates generated are done. |
@@ -1357,28 +1357,28 @@ discard block |
||
1357 | 1357 | $active_messengers = $message_resource_manager->active_messengers(); |
1358 | 1358 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1359 | 1359 | $templates_created = false; |
1360 | - foreach ( $active_messengers as $active_messenger ) { |
|
1360 | + foreach ($active_messengers as $active_messenger) { |
|
1361 | 1361 | $default_message_type_names_for_messenger = $active_messenger->get_default_message_types(); |
1362 | 1362 | $default_message_type_names_to_activate = array(); |
1363 | 1363 | // looping through each default message type reported by the messenger |
1364 | 1364 | // and setup the actual message types to activate. |
1365 | - foreach ( $default_message_type_names_for_messenger as $default_message_type_name_for_messenger ) { |
|
1365 | + foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) { |
|
1366 | 1366 | // if already active or has already been activated before we skip |
1367 | 1367 | // (otherwise we might reactivate something user's intentionally deactivated.) |
1368 | 1368 | // we also skip if the message type is not installed. |
1369 | 1369 | if ( |
1370 | 1370 | ( |
1371 | - isset( $has_activated[ $active_messenger->name ] ) |
|
1371 | + isset($has_activated[$active_messenger->name]) |
|
1372 | 1372 | && in_array( |
1373 | 1373 | $default_message_type_name_for_messenger, |
1374 | - $has_activated[ $active_messenger->name ] |
|
1374 | + $has_activated[$active_messenger->name] |
|
1375 | 1375 | ) |
1376 | 1376 | ) |
1377 | 1377 | || $message_resource_manager->is_message_type_active_for_messenger( |
1378 | 1378 | $active_messenger->name, |
1379 | 1379 | $default_message_type_name_for_messenger |
1380 | 1380 | ) |
1381 | - || ! isset( $installed_message_types[ $default_message_type_name_for_messenger ] ) |
|
1381 | + || ! isset($installed_message_types[$default_message_type_name_for_messenger]) |
|
1382 | 1382 | ) { |
1383 | 1383 | continue; |
1384 | 1384 | } |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | false |
1392 | 1392 | ); |
1393 | 1393 | //activate the templates for these message types |
1394 | - if ( ! empty( $default_message_type_names_to_activate ) ) { |
|
1394 | + if ( ! empty($default_message_type_names_to_activate)) { |
|
1395 | 1395 | $templates_created = EEH_MSG_Template::generate_new_templates( |
1396 | 1396 | $active_messenger->name, |
1397 | 1397 | $default_message_type_names_for_messenger, |
@@ -1418,15 +1418,15 @@ discard block |
||
1418 | 1418 | EE_message_Resource_Manager $message_resource_manager |
1419 | 1419 | ) { |
1420 | 1420 | /** @type EE_messenger[] $messengers_to_generate */ |
1421 | - $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation( $message_resource_manager ); |
|
1421 | + $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager); |
|
1422 | 1422 | $installed_message_types = $message_resource_manager->installed_message_types(); |
1423 | 1423 | $templates_generated = false; |
1424 | - foreach ( $messengers_to_generate as $messenger_to_generate ) { |
|
1424 | + foreach ($messengers_to_generate as $messenger_to_generate) { |
|
1425 | 1425 | $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types(); |
1426 | 1426 | //verify the default message types match an installed message type. |
1427 | - foreach ( $default_message_type_names_for_messenger as $key => $name ) { |
|
1428 | - if ( ! isset( $installed_message_types[ $name ] ) ) { |
|
1429 | - unset( $default_message_type_names_for_messenger[ $key ] ); |
|
1427 | + foreach ($default_message_type_names_for_messenger as $key => $name) { |
|
1428 | + if ( ! isset($installed_message_types[$name])) { |
|
1429 | + unset($default_message_type_names_for_messenger[$key]); |
|
1430 | 1430 | } |
1431 | 1431 | } |
1432 | 1432 | // in previous iterations, the active_messengers option in the db |
@@ -1440,7 +1440,7 @@ discard block |
||
1440 | 1440 | false |
1441 | 1441 | ); |
1442 | 1442 | //create any templates needing created (or will reactivate templates already generated as necessary). |
1443 | - if ( ! empty( $default_message_type_names_for_messenger ) ) { |
|
1443 | + if ( ! empty($default_message_type_names_for_messenger)) { |
|
1444 | 1444 | $templates_generated = EEH_MSG_Template::generate_new_templates( |
1445 | 1445 | $messenger_to_generate->name, |
1446 | 1446 | $default_message_type_names_for_messenger, |
@@ -1471,18 +1471,18 @@ discard block |
||
1471 | 1471 | $installed_messengers = $message_resource_manager->installed_messengers(); |
1472 | 1472 | $has_activated = $message_resource_manager->get_has_activated_messengers_option(); |
1473 | 1473 | $messengers_to_generate = array(); |
1474 | - foreach ( $installed_messengers as $installed_messenger ) { |
|
1474 | + foreach ($installed_messengers as $installed_messenger) { |
|
1475 | 1475 | //if installed messenger is a messenger that should be activated on install |
1476 | 1476 | //and is not already active |
1477 | 1477 | //and has never been activated |
1478 | 1478 | if ( |
1479 | 1479 | ! $installed_messenger->activate_on_install |
1480 | - || isset( $active_messengers[ $installed_messenger->name ] ) |
|
1481 | - || isset( $has_activated[ $installed_messenger->name ] ) |
|
1480 | + || isset($active_messengers[$installed_messenger->name]) |
|
1481 | + || isset($has_activated[$installed_messenger->name]) |
|
1482 | 1482 | ) { |
1483 | 1483 | continue; |
1484 | 1484 | } |
1485 | - $messengers_to_generate[ $installed_messenger->name ] = $installed_messenger; |
|
1485 | + $messengers_to_generate[$installed_messenger->name] = $installed_messenger; |
|
1486 | 1486 | } |
1487 | 1487 | return $messengers_to_generate; |
1488 | 1488 | } |
@@ -1507,9 +1507,9 @@ discard block |
||
1507 | 1507 | */ |
1508 | 1508 | public static function validate_messages_system() { |
1509 | 1509 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
1510 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
1510 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
1511 | 1511 | $message_resource_manager->validate_active_message_types_are_installed(); |
1512 | - do_action( 'AHEE__EEH_Activation__validate_messages_system' ); |
|
1512 | + do_action('AHEE__EEH_Activation__validate_messages_system'); |
|
1513 | 1513 | } |
1514 | 1514 | |
1515 | 1515 | |
@@ -1522,12 +1522,12 @@ discard block |
||
1522 | 1522 | * @static |
1523 | 1523 | * @return void |
1524 | 1524 | */ |
1525 | - public static function create_no_ticket_prices_array(){ |
|
1525 | + public static function create_no_ticket_prices_array() { |
|
1526 | 1526 | // this creates an array for tracking events that have no active ticket prices created |
1527 | 1527 | // this allows us to warn admins of the situation so that it can be corrected |
1528 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE ); |
|
1529 | - if ( ! $espresso_no_ticket_prices ) { |
|
1530 | - add_option( 'ee_no_ticket_prices', array(), '', FALSE ); |
|
1528 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE); |
|
1529 | + if ( ! $espresso_no_ticket_prices) { |
|
1530 | + add_option('ee_no_ticket_prices', array(), '', FALSE); |
|
1531 | 1531 | } |
1532 | 1532 | } |
1533 | 1533 | |
@@ -1552,24 +1552,24 @@ discard block |
||
1552 | 1552 | * @global wpdb $wpdb |
1553 | 1553 | * @throws \EE_Error |
1554 | 1554 | */ |
1555 | - public static function delete_all_espresso_cpt_data(){ |
|
1555 | + public static function delete_all_espresso_cpt_data() { |
|
1556 | 1556 | global $wpdb; |
1557 | 1557 | //get all the CPT post_types |
1558 | 1558 | $ee_post_types = array(); |
1559 | - foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){ |
|
1560 | - if ( method_exists( $model_name, 'instance' )) { |
|
1561 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1562 | - if ( $model_obj instanceof EEM_CPT_Base ) { |
|
1563 | - $ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type()); |
|
1559 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1560 | + if (method_exists($model_name, 'instance')) { |
|
1561 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1562 | + if ($model_obj instanceof EEM_CPT_Base) { |
|
1563 | + $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type()); |
|
1564 | 1564 | } |
1565 | 1565 | } |
1566 | 1566 | } |
1567 | 1567 | //get all our CPTs |
1568 | - $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")"; |
|
1568 | + $query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")"; |
|
1569 | 1569 | $cpt_ids = $wpdb->get_col($query); |
1570 | 1570 | //delete each post meta and term relations too |
1571 | - foreach($cpt_ids as $post_id){ |
|
1572 | - wp_delete_post($post_id,true); |
|
1571 | + foreach ($cpt_ids as $post_id) { |
|
1572 | + wp_delete_post($post_id, true); |
|
1573 | 1573 | } |
1574 | 1574 | } |
1575 | 1575 | |
@@ -1583,18 +1583,18 @@ discard block |
||
1583 | 1583 | * @param bool $remove_all |
1584 | 1584 | * @return void |
1585 | 1585 | */ |
1586 | - public static function delete_all_espresso_tables_and_data( $remove_all = true ) { |
|
1586 | + public static function delete_all_espresso_tables_and_data($remove_all = true) { |
|
1587 | 1587 | global $wpdb; |
1588 | 1588 | $undeleted_tables = array(); |
1589 | 1589 | |
1590 | 1590 | // load registry |
1591 | - foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){ |
|
1592 | - if ( method_exists( $model_name, 'instance' )) { |
|
1593 | - $model_obj = call_user_func( array( $model_name, 'instance' )); |
|
1594 | - if ( $model_obj instanceof EEM_Base ) { |
|
1595 | - foreach ( $model_obj->get_tables() as $table ) { |
|
1596 | - if ( strpos( $table->get_table_name(), 'esp_' )) { |
|
1597 | - switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) { |
|
1591 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
1592 | + if (method_exists($model_name, 'instance')) { |
|
1593 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
1594 | + if ($model_obj instanceof EEM_Base) { |
|
1595 | + foreach ($model_obj->get_tables() as $table) { |
|
1596 | + if (strpos($table->get_table_name(), 'esp_')) { |
|
1597 | + switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) { |
|
1598 | 1598 | case false : |
1599 | 1599 | $undeleted_tables[] = $table->get_table_name(); |
1600 | 1600 | break; |
@@ -1619,8 +1619,8 @@ discard block |
||
1619 | 1619 | 'esp_promotion_rule', |
1620 | 1620 | 'esp_rule' |
1621 | 1621 | ); |
1622 | - foreach( $tables_without_models as $table ){ |
|
1623 | - EEH_Activation::delete_db_table_if_empty( $table ); |
|
1622 | + foreach ($tables_without_models as $table) { |
|
1623 | + EEH_Activation::delete_db_table_if_empty($table); |
|
1624 | 1624 | } |
1625 | 1625 | |
1626 | 1626 | |
@@ -1658,58 +1658,58 @@ discard block |
||
1658 | 1658 | 'ee_job_parameters_' => false, |
1659 | 1659 | 'ee_upload_directories_incomplete' => true, |
1660 | 1660 | ); |
1661 | - if( is_main_site() ) { |
|
1662 | - $wp_options_to_delete[ 'ee_network_config' ] = true; |
|
1661 | + if (is_main_site()) { |
|
1662 | + $wp_options_to_delete['ee_network_config'] = true; |
|
1663 | 1663 | } |
1664 | 1664 | |
1665 | 1665 | $undeleted_options = array(); |
1666 | - foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) { |
|
1666 | + foreach ($wp_options_to_delete as $option_name => $no_wildcard) { |
|
1667 | 1667 | |
1668 | - if( $no_wildcard ){ |
|
1669 | - if( ! delete_option( $option_name ) ){ |
|
1668 | + if ($no_wildcard) { |
|
1669 | + if ( ! delete_option($option_name)) { |
|
1670 | 1670 | $undeleted_options[] = $option_name; |
1671 | 1671 | } |
1672 | - }else{ |
|
1673 | - $option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" ); |
|
1674 | - foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){ |
|
1675 | - if( ! delete_option( $option_name_from_wildcard ) ){ |
|
1672 | + } else { |
|
1673 | + $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'"); |
|
1674 | + foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) { |
|
1675 | + if ( ! delete_option($option_name_from_wildcard)) { |
|
1676 | 1676 | $undeleted_options[] = $option_name_from_wildcard; |
1677 | 1677 | } |
1678 | 1678 | } |
1679 | 1679 | } |
1680 | 1680 | } |
1681 | 1681 | //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it |
1682 | - remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 ); |
|
1682 | + remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10); |
|
1683 | 1683 | |
1684 | - if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) { |
|
1684 | + if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) { |
|
1685 | 1685 | $db_update_sans_ee4 = array(); |
1686 | - foreach($espresso_db_update as $version => $times_activated){ |
|
1687 | - if( (string)$version[0] === '3'){//if its NON EE4 |
|
1686 | + foreach ($espresso_db_update as $version => $times_activated) { |
|
1687 | + if ((string) $version[0] === '3') {//if its NON EE4 |
|
1688 | 1688 | $db_update_sans_ee4[$version] = $times_activated; |
1689 | 1689 | } |
1690 | 1690 | } |
1691 | - update_option( 'espresso_db_update', $db_update_sans_ee4 ); |
|
1691 | + update_option('espresso_db_update', $db_update_sans_ee4); |
|
1692 | 1692 | } |
1693 | 1693 | |
1694 | 1694 | $errors = ''; |
1695 | - if ( ! empty( $undeleted_tables )) { |
|
1695 | + if ( ! empty($undeleted_tables)) { |
|
1696 | 1696 | $errors .= sprintf( |
1697 | - __( 'The following tables could not be deleted: %s%s', 'event_espresso' ), |
|
1697 | + __('The following tables could not be deleted: %s%s', 'event_espresso'), |
|
1698 | 1698 | '<br/>', |
1699 | - implode( ',<br/>', $undeleted_tables ) |
|
1699 | + implode(',<br/>', $undeleted_tables) |
|
1700 | 1700 | ); |
1701 | 1701 | } |
1702 | - if ( ! empty( $undeleted_options )) { |
|
1703 | - $errors .= ! empty( $undeleted_tables ) ? '<br/>' : ''; |
|
1702 | + if ( ! empty($undeleted_options)) { |
|
1703 | + $errors .= ! empty($undeleted_tables) ? '<br/>' : ''; |
|
1704 | 1704 | $errors .= sprintf( |
1705 | - __( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ), |
|
1705 | + __('The following wp-options could not be deleted: %s%s', 'event_espresso'), |
|
1706 | 1706 | '<br/>', |
1707 | - implode( ',<br/>', $undeleted_options ) |
|
1707 | + implode(',<br/>', $undeleted_options) |
|
1708 | 1708 | ); |
1709 | 1709 | |
1710 | 1710 | } |
1711 | - if ( ! empty( $errors ) ) { |
|
1712 | - EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ ); |
|
1711 | + if ( ! empty($errors)) { |
|
1712 | + EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__); |
|
1713 | 1713 | } |
1714 | 1714 | } |
1715 | 1715 | |
@@ -1719,23 +1719,23 @@ discard block |
||
1719 | 1719 | * @param string $table_name with or without $wpdb->prefix |
1720 | 1720 | * @return boolean |
1721 | 1721 | */ |
1722 | - public static function table_exists( $table_name ){ |
|
1722 | + public static function table_exists($table_name) { |
|
1723 | 1723 | global $wpdb, $EZSQL_ERROR; |
1724 | - $table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name ); |
|
1724 | + $table_name = EEH_Activation::ensure_table_name_has_prefix($table_name); |
|
1725 | 1725 | //ignore if this causes an sql error |
1726 | 1726 | $old_error = $wpdb->last_error; |
1727 | 1727 | $old_suppress_errors = $wpdb->suppress_errors(); |
1728 | - $old_show_errors_value = $wpdb->show_errors( FALSE ); |
|
1728 | + $old_show_errors_value = $wpdb->show_errors(FALSE); |
|
1729 | 1729 | $ezsql_error_cache = $EZSQL_ERROR; |
1730 | - $wpdb->get_results( "SELECT * from $table_name LIMIT 1"); |
|
1731 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1732 | - $wpdb->suppress_errors( $old_suppress_errors ); |
|
1730 | + $wpdb->get_results("SELECT * from $table_name LIMIT 1"); |
|
1731 | + $wpdb->show_errors($old_show_errors_value); |
|
1732 | + $wpdb->suppress_errors($old_suppress_errors); |
|
1733 | 1733 | $new_error = $wpdb->last_error; |
1734 | 1734 | $wpdb->last_error = $old_error; |
1735 | 1735 | $EZSQL_ERROR = $ezsql_error_cache; |
1736 | - if( empty( $new_error ) ){ |
|
1736 | + if (empty($new_error)) { |
|
1737 | 1737 | return TRUE; |
1738 | - }else{ |
|
1738 | + } else { |
|
1739 | 1739 | return FALSE; |
1740 | 1740 | } |
1741 | 1741 | } |
@@ -1743,7 +1743,7 @@ discard block |
||
1743 | 1743 | /** |
1744 | 1744 | * Resets the cache on EEH_Activation |
1745 | 1745 | */ |
1746 | - public static function reset(){ |
|
1746 | + public static function reset() { |
|
1747 | 1747 | self::$_default_creator_id = NULL; |
1748 | 1748 | self::$_initialized_db_content_already_in_this_request = false; |
1749 | 1749 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
141 | - * @return null |
|
141 | + * @return EE_Line_Item_Display |
|
142 | 142 | */ |
143 | 143 | public function line_item_display() { |
144 | 144 | return $this->line_item_display; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | |
149 | 149 | /** |
150 | - * @param null $line_item_display |
|
150 | + * @param EE_Line_Item_Display $line_item_display |
|
151 | 151 | */ |
152 | 152 | public function set_line_item_display( $line_item_display ) { |
153 | 153 | $this->line_item_display = $line_item_display; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | |
230 | 230 | /** |
231 | - * @return bool |
|
231 | + * @return EE_Form_Section_Proper |
|
232 | 232 | * @throws \EE_Error |
233 | 233 | */ |
234 | 234 | public function generate_reg_form() { |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * _apply_registration_payments_to_amount_owing |
625 | 625 | * |
626 | 626 | * @access protected |
627 | - * @param array $registrations |
|
627 | + * @param EE_Base_Class[] $registrations |
|
628 | 628 | */ |
629 | 629 | protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
630 | 630 | $payments = array(); |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | * get_billing_form_html_for_payment_method |
898 | 898 | * |
899 | 899 | * @access public |
900 | - * @return string |
|
900 | + * @return boolean |
|
901 | 901 | * @throws \EE_Error |
902 | 902 | */ |
903 | 903 | public function get_billing_form_html_for_payment_method() { |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | * switch_payment_method |
1066 | 1066 | * |
1067 | 1067 | * @access public |
1068 | - * @return string |
|
1068 | + * @return boolean |
|
1069 | 1069 | * @throws \EE_Error |
1070 | 1070 | */ |
1071 | 1071 | public function switch_payment_method() { |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | /** |
1272 | 1272 | * process_reg_step |
1273 | 1273 | * |
1274 | - * @return boolean |
|
1274 | + * @return null|boolean |
|
1275 | 1275 | * @throws \EE_Error |
1276 | 1276 | */ |
1277 | 1277 | public function process_reg_step() { |
@@ -1366,7 +1366,7 @@ discard block |
||
1366 | 1366 | * update_reg_step |
1367 | 1367 | * this is the final step after a user revisits the site to retry a payment |
1368 | 1368 | * |
1369 | - * @return boolean |
|
1369 | + * @return null|boolean |
|
1370 | 1370 | * @throws \EE_Error |
1371 | 1371 | */ |
1372 | 1372 | public function update_reg_step() { |
@@ -1730,7 +1730,7 @@ discard block |
||
1730 | 1730 | * |
1731 | 1731 | * @access private |
1732 | 1732 | * @type EE_Payment_Method $payment_method |
1733 | - * @return mixed EE_Payment | boolean |
|
1733 | + * @return EE_Payment|null EE_Payment | boolean |
|
1734 | 1734 | * @throws \EE_Error |
1735 | 1735 | */ |
1736 | 1736 | private function _attempt_payment( EE_Payment_Method $payment_method ) { |
@@ -1940,6 +1940,7 @@ discard block |
||
1940 | 1940 | * @access private |
1941 | 1941 | * @type EE_Payment $payment |
1942 | 1942 | * @param string $payment_occurs |
1943 | + * @param EE_Payment|null $payment |
|
1943 | 1944 | * @return bool |
1944 | 1945 | * @throws \EE_Error |
1945 | 1946 | */ |
@@ -2050,7 +2051,7 @@ discard block |
||
2050 | 2051 | * or present the payment options again |
2051 | 2052 | * |
2052 | 2053 | * @access private |
2053 | - * @return EE_Payment | FALSE |
|
2054 | + * @return boolean | FALSE |
|
2054 | 2055 | * @throws \EE_Error |
2055 | 2056 | */ |
2056 | 2057 | public function process_gateway_response() { |
@@ -2112,7 +2113,7 @@ discard block |
||
2112 | 2113 | * _validate_return |
2113 | 2114 | * |
2114 | 2115 | * @access private |
2115 | - * @return bool |
|
2116 | + * @return boolean|null |
|
2116 | 2117 | * @throws \EE_Error |
2117 | 2118 | */ |
2118 | 2119 | private function _validate_offsite_return() { |
@@ -2183,8 +2184,8 @@ discard block |
||
2183 | 2184 | * _redirect_wayward_request |
2184 | 2185 | * |
2185 | 2186 | * @access private |
2186 | - * @param \EE_Registration|null $primary_registrant |
|
2187 | - * @return bool |
|
2187 | + * @param EE_Registration $primary_registrant |
|
2188 | + * @return false|null |
|
2188 | 2189 | * @throws \EE_Error |
2189 | 2190 | */ |
2190 | 2191 | private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
@@ -411,9 +411,9 @@ discard block |
||
411 | 411 | 'layout_strategy' => new EE_Template_Layout( |
412 | 412 | array( |
413 | 413 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
414 | - . $this->_slug |
|
415 | - . DS |
|
416 | - . 'sold_out_events.template.php', |
|
414 | + . $this->_slug |
|
415 | + . DS |
|
416 | + . 'sold_out_events.template.php', |
|
417 | 417 | 'template_args' => apply_filters( |
418 | 418 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
419 | 419 | array( |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | 'layout_strategy' => new EE_Template_Layout( |
466 | 466 | array( |
467 | 467 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
468 | - . $this->_slug |
|
469 | - . DS |
|
470 | - . 'events_requiring_pre_approval.template.php', // layout_template |
|
468 | + . $this->_slug |
|
469 | + . DS |
|
470 | + . 'events_requiring_pre_approval.template.php', // layout_template |
|
471 | 471 | 'template_args' => apply_filters( |
472 | 472 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
473 | 473 | array( |
@@ -509,9 +509,9 @@ discard block |
||
509 | 509 | 'layout_strategy' => new EE_Template_Layout( |
510 | 510 | array( |
511 | 511 | 'layout_template_file' => SPCO_REG_STEPS_PATH |
512 | - . $this->_slug |
|
513 | - . DS |
|
514 | - . 'no_payment_required.template.php', // layout_template |
|
512 | + . $this->_slug |
|
513 | + . DS |
|
514 | + . 'no_payment_required.template.php', // layout_template |
|
515 | 515 | 'template_args' => apply_filters( |
516 | 516 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
517 | 517 | array( |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
742 | 742 | } |
743 | 743 | $payment_methods_billing_info[ $payment_method->slug() |
744 | - . '-info' ] = $this->_payment_method_billing_info( |
|
744 | + . '-info' ] = $this->_payment_method_billing_info( |
|
745 | 745 | $payment_method |
746 | 746 | ); |
747 | 747 | } |
@@ -929,7 +929,7 @@ discard block |
||
929 | 929 | // fill form with attendee info if applicable |
930 | 930 | if ( |
931 | 931 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
932 | - && $this->checkout->transaction_has_primary_registrant() |
|
932 | + && $this->checkout->transaction_has_primary_registrant() |
|
933 | 933 | ) { |
934 | 934 | $payment_method_billing_form->populate_from_attendee( |
935 | 935 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -938,7 +938,7 @@ discard block |
||
938 | 938 | // and debug content |
939 | 939 | if ( |
940 | 940 | $payment_method_billing_form instanceof EE_Billing_Info_Form |
941 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
941 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
942 | 942 | ) { |
943 | 943 | $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
944 | 944 | $payment_method_billing_form |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | } |
1098 | 1098 | // fill form with attendee info if applicable |
1099 | 1099 | if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
1100 | - && $this->checkout->transaction_has_primary_registrant() |
|
1100 | + && $this->checkout->transaction_has_primary_registrant() |
|
1101 | 1101 | ) { |
1102 | 1102 | $this->checkout->billing_form->populate_from_attendee( |
1103 | 1103 | $this->checkout->transaction->primary_registration()->attendee() |
@@ -1105,7 +1105,7 @@ discard block |
||
1105 | 1105 | } |
1106 | 1106 | // and debug content |
1107 | 1107 | if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
1108 | - && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1108 | + && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
|
1109 | 1109 | ) { |
1110 | 1110 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
1111 | 1111 | $this->checkout->billing_form |
@@ -1238,8 +1238,8 @@ discard block |
||
1238 | 1238 | } |
1239 | 1239 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1240 | 1240 | if ( ! empty( $attendee_data['ATT_fname'] ) |
1241 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1242 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1241 | + && ! empty( $attendee_data['ATT_lname'] ) |
|
1242 | + && ! empty( $attendee_data['ATT_email'] ) |
|
1243 | 1243 | ) { |
1244 | 1244 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1245 | 1245 | array( |
@@ -1450,7 +1450,7 @@ discard block |
||
1450 | 1450 | $payment_status = $payment->status(); |
1451 | 1451 | if ( |
1452 | 1452 | $payment_status === EEM_Payment::status_id_approved |
1453 | - || $payment_status === EEM_Payment::status_id_pending |
|
1453 | + || $payment_status === EEM_Payment::status_id_pending |
|
1454 | 1454 | ) { |
1455 | 1455 | return true; |
1456 | 1456 | } else { |
@@ -1638,8 +1638,8 @@ discard block |
||
1638 | 1638 | return false; |
1639 | 1639 | } |
1640 | 1640 | if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
1641 | - instanceof |
|
1642 | - EE_Attendee |
|
1641 | + instanceof |
|
1642 | + EE_Attendee |
|
1643 | 1643 | ) { |
1644 | 1644 | EE_Error::add_error( |
1645 | 1645 | sprintf( |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -38,32 +38,32 @@ discard block |
||
38 | 38 | public static function set_hooks() { |
39 | 39 | add_filter( |
40 | 40 | 'FHEE__SPCO__EE_Line_Item_Filter_Collection', |
41 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) |
|
41 | + array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters') |
|
42 | 42 | ); |
43 | 43 | add_action( |
44 | 44 | 'wp_ajax_switch_spco_billing_form', |
45 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
45 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
46 | 46 | ); |
47 | 47 | add_action( |
48 | 48 | 'wp_ajax_nopriv_switch_spco_billing_form', |
49 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ) |
|
49 | + array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form') |
|
50 | 50 | ); |
51 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) ); |
|
51 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
52 | 52 | add_action( |
53 | 53 | 'wp_ajax_nopriv_save_payer_details', |
54 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) |
|
54 | + array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details') |
|
55 | 55 | ); |
56 | 56 | add_action( |
57 | 57 | 'wp_ajax_get_transaction_details_for_gateways', |
58 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
58 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
59 | 59 | ); |
60 | 60 | add_action( |
61 | 61 | 'wp_ajax_nopriv_get_transaction_details_for_gateways', |
62 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
62 | + array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
63 | 63 | ); |
64 | 64 | add_filter( |
65 | 65 | 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
66 | - array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), |
|
66 | + array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), |
|
67 | 67 | 10, |
68 | 68 | 1 |
69 | 69 | ); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @throws \EE_Error |
78 | 78 | */ |
79 | 79 | public static function switch_spco_billing_form() { |
80 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
80 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @throws \EE_Error |
89 | 89 | */ |
90 | 90 | public static function save_payer_details() { |
91 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
91 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | 101 | public static function get_transaction_details() { |
102 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
102 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | * @param EE_Checkout $checkout |
128 | 128 | * @return \EE_SPCO_Reg_Step_Payment_Options |
129 | 129 | */ |
130 | - public function __construct( EE_Checkout $checkout ) { |
|
130 | + public function __construct(EE_Checkout $checkout) { |
|
131 | 131 | $this->_slug = 'payment_options'; |
132 | - $this->_name = __( 'Payment Options', 'event_espresso' ); |
|
133 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
132 | + $this->_name = __('Payment Options', 'event_espresso'); |
|
133 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
134 | 134 | $this->checkout = $checkout; |
135 | 135 | $this->_reset_success_message(); |
136 | 136 | $this->set_instructions( |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * @param null $line_item_display |
157 | 157 | */ |
158 | - public function set_line_item_display( $line_item_display ) { |
|
158 | + public function set_line_item_display($line_item_display) { |
|
159 | 159 | $this->line_item_display = $line_item_display; |
160 | 160 | } |
161 | 161 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * @param boolean $handle_IPN_in_this_request |
175 | 175 | */ |
176 | - public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) { |
|
177 | - $this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN ); |
|
176 | + public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) { |
|
177 | + $this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -227,20 +227,20 @@ discard block |
||
227 | 227 | // $ 0.00 transactions (no payment required) |
228 | 228 | ! $this->checkout->payment_required() |
229 | 229 | // but do NOT remove if current action being called belongs to this reg step |
230 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
230 | + && ! is_callable(array($this, $this->checkout->action)) |
|
231 | 231 | && ! $this->completed() |
232 | 232 | ) { |
233 | 233 | // and if so, then we no longer need the Payment Options step |
234 | - if ( $this->is_current_step() ) { |
|
234 | + if ($this->is_current_step()) { |
|
235 | 235 | $this->checkout->generate_reg_form = false; |
236 | 236 | } |
237 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
237 | + $this->checkout->remove_reg_step($this->_slug); |
|
238 | 238 | // DEBUG LOG |
239 | 239 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
240 | 240 | return false; |
241 | 241 | } |
242 | 242 | // load EEM_Payment_Method |
243 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
243 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
244 | 244 | // get all active payment methods |
245 | 245 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
246 | 246 | $this->checkout->transaction, |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | $sold_out_events = array(); |
267 | 267 | $reg_count = 0; |
268 | 268 | // loop thru registrations to gather info |
269 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
270 | - foreach ( $registrations as $registration ) { |
|
269 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
270 | + foreach ($registrations as $registration) { |
|
271 | 271 | /** @var $registration EE_Registration */ |
272 | 272 | $reg_count++; |
273 | 273 | // if returning registrant is Approved then do NOT do this |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | && $registration->status_ID() === EEM_Registration::status_id_approved |
278 | 278 | ) |
279 | 279 | ) { |
280 | - if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true ) ) { |
|
280 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
281 | 281 | // add event to list of events that are sold out |
282 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
282 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
283 | 283 | do_action( |
284 | 284 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
285 | 285 | $registration->event(), |
@@ -287,9 +287,9 @@ discard block |
||
287 | 287 | ); |
288 | 288 | } |
289 | 289 | // event requires admin approval |
290 | - if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) { |
|
290 | + if ($registration->status_ID() === EEM_Registration::status_id_not_approved) { |
|
291 | 291 | // add event to list of events with pre-approval reg status |
292 | - $registrations_requiring_pre_approval[ $registration->ID() ] = $registration; |
|
292 | + $registrations_requiring_pre_approval[$registration->ID()] = $registration; |
|
293 | 293 | do_action( |
294 | 294 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
295 | 295 | $registration->event(), |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | } |
299 | 299 | } |
300 | 300 | // are they allowed to pay now and is there monies owing? |
301 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
302 | - $registrations_requiring_payment[ $registration->ID() ] = $registration; |
|
301 | + if ($registration->owes_monies_and_can_pay()) { |
|
302 | + $registrations_requiring_payment[$registration->ID()] = $registration; |
|
303 | 303 | do_action( |
304 | 304 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
305 | 305 | $registration->event(), |
@@ -310,23 +310,23 @@ discard block |
||
310 | 310 | && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
311 | 311 | && $registration->ticket()->is_free() |
312 | 312 | ) { |
313 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
313 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | $subsections = array(); |
317 | 317 | // now decide which template to load |
318 | - if ( ! empty( $sold_out_events ) ) { |
|
319 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
318 | + if ( ! empty($sold_out_events)) { |
|
319 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
320 | 320 | } |
321 | - if ( ! empty( $registrations_requiring_pre_approval ) ) { |
|
321 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
322 | 322 | $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( |
323 | 323 | $registrations_requiring_pre_approval |
324 | 324 | ); |
325 | 325 | } |
326 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
327 | - $subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events ); |
|
326 | + if ( ! empty($registrations_for_free_events)) { |
|
327 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
328 | 328 | } |
329 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
329 | + if ( ! empty($registrations_requiring_payment)) { |
|
330 | 330 | // autoload Line_Item_Display classes |
331 | 331 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
332 | 332 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -338,17 +338,17 @@ discard block |
||
338 | 338 | ); |
339 | 339 | /** @var EE_Line_Item $filtered_line_item_tree */ |
340 | 340 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
341 | - if ( $this->checkout->amount_owing > 0 ) { |
|
341 | + if ($this->checkout->amount_owing > 0) { |
|
342 | 342 | EEH_Autoloader::register_line_item_display_autoloaders(); |
343 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
343 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
344 | 344 | $subsections['payment_options'] = $this->_display_payment_options( |
345 | 345 | $this->line_item_display->display_line_item( |
346 | 346 | $filtered_line_item_tree, |
347 | - array( 'registrations' => $registrations ) |
|
347 | + array('registrations' => $registrations) |
|
348 | 348 | ) |
349 | 349 | ); |
350 | 350 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
351 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
351 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
352 | 352 | } |
353 | 353 | } else { |
354 | 354 | $this->_hide_reg_step_submit_button_if_revisit(); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
379 | 379 | * @return \EE_Line_Item_Filter_Collection |
380 | 380 | */ |
381 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
381 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
382 | 382 | $line_item_filter_collection->add( |
383 | 383 | new EE_Billable_Line_Item_Filter( |
384 | 384 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | ) |
387 | 387 | ) |
388 | 388 | ); |
389 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
389 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
390 | 390 | return $line_item_filter_collection; |
391 | 391 | } |
392 | 392 | |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | * @return void |
401 | 401 | */ |
402 | 402 | protected function _hide_reg_step_submit_button_if_revisit() { |
403 | - if ( $this->checkout->revisit ) { |
|
404 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
403 | + if ($this->checkout->revisit) { |
|
404 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
@@ -414,13 +414,13 @@ discard block |
||
414 | 414 | * @return \EE_Form_Section_Proper |
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
417 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
418 | 418 | // set some defaults |
419 | 419 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
420 | 420 | $sold_out_events = ''; |
421 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
421 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
422 | 422 | $sold_out_events .= EEH_HTML::li( |
423 | - EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ) |
|
423 | + EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text') |
|
424 | 424 | ); |
425 | 425 | } |
426 | 426 | return new EE_Form_Section_Proper( |
@@ -465,17 +465,17 @@ discard block |
||
465 | 465 | * @return \EE_Form_Section_Proper |
466 | 466 | * @throws \EE_Error |
467 | 467 | */ |
468 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) { |
|
468 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
469 | 469 | $events_requiring_pre_approval = ''; |
470 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
471 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
472 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
470 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
471 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
472 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
473 | 473 | EEH_HTML::span( |
474 | 474 | '', |
475 | 475 | '', |
476 | 476 | 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
477 | 477 | ) |
478 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
478 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
479 | 479 | ); |
480 | 480 | } |
481 | 481 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | 'template_args' => apply_filters( |
495 | 495 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
496 | 496 | array( |
497 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
497 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
498 | 498 | 'events_requiring_pre_approval_msg' => apply_filters( |
499 | 499 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
500 | 500 | __( |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | * @return \EE_Form_Section_Proper |
520 | 520 | * @throws \EE_Error |
521 | 521 | */ |
522 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
522 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
523 | 523 | // set some defaults |
524 | 524 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
525 | 525 | // generate no_payment_required form |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | 'ticket_count' => array(), |
544 | 544 | 'registrations_for_free_events' => $registrations_for_free_events, |
545 | 545 | 'no_payment_required_msg' => EEH_HTML::p( |
546 | - __( 'This is a free event, so no billing will occur.', 'event_espresso' ) |
|
546 | + __('This is a free event, so no billing will occur.', 'event_espresso') |
|
547 | 547 | ) |
548 | 548 | ) |
549 | 549 | ), |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | * @return \EE_Form_Section_Proper |
563 | 563 | * @throws \EE_Error |
564 | 564 | */ |
565 | - private function _display_payment_options( $transaction_details = '' ) { |
|
565 | + private function _display_payment_options($transaction_details = '') { |
|
566 | 566 | // has method_of_payment been set by no-js user? |
567 | 567 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
568 | 568 | // build payment options form |
@@ -574,18 +574,18 @@ discard block |
||
574 | 574 | 'before_payment_options' => apply_filters( |
575 | 575 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
576 | 576 | new EE_Form_Section_Proper( |
577 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
577 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
578 | 578 | ) |
579 | 579 | ), |
580 | 580 | 'payment_options' => $this->_setup_payment_options(), |
581 | 581 | 'after_payment_options' => apply_filters( |
582 | 582 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
583 | 583 | new EE_Form_Section_Proper( |
584 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
584 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
585 | 585 | ) |
586 | 586 | ), |
587 | 587 | 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
588 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs( false ) |
|
588 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(false) |
|
589 | 589 | ), |
590 | 590 | 'layout_strategy' => new EE_Template_Layout( |
591 | 591 | array( |
@@ -614,10 +614,10 @@ discard block |
||
614 | 614 | * @return \EE_Form_Section_Proper |
615 | 615 | * @throws \EE_Error |
616 | 616 | */ |
617 | - private function _extra_hidden_inputs( $no_payment_required = true ) { |
|
617 | + private function _extra_hidden_inputs($no_payment_required = true) { |
|
618 | 618 | return new EE_Form_Section_Proper( |
619 | 619 | array( |
620 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
620 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
621 | 621 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
622 | 622 | 'subsections' => array( |
623 | 623 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -649,16 +649,16 @@ discard block |
||
649 | 649 | * @access protected |
650 | 650 | * @param array $registrations |
651 | 651 | */ |
652 | - protected function _apply_registration_payments_to_amount_owing( array $registrations ) { |
|
652 | + protected function _apply_registration_payments_to_amount_owing(array $registrations) { |
|
653 | 653 | $payments = array(); |
654 | - foreach ( $registrations as $registration ) { |
|
655 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
654 | + foreach ($registrations as $registration) { |
|
655 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
656 | 656 | $payments += $registration->registration_payments(); |
657 | 657 | } |
658 | 658 | } |
659 | - if ( ! empty( $payments ) ) { |
|
660 | - foreach ( $payments as $payment ) { |
|
661 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
659 | + if ( ! empty($payments)) { |
|
660 | + foreach ($payments as $payment) { |
|
661 | + if ($payment instanceof EE_Registration_Payment) { |
|
662 | 662 | $this->checkout->amount_owing -= $payment->amount(); |
663 | 663 | } |
664 | 664 | } |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | * @param bool $force_reset |
675 | 675 | * @return void |
676 | 676 | */ |
677 | - private function _reset_selected_method_of_payment( $force_reset = false ) { |
|
677 | + private function _reset_selected_method_of_payment($force_reset = false) { |
|
678 | 678 | $reset_payment_method = $force_reset |
679 | 679 | ? true |
680 | - : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) ); |
|
681 | - if ( $reset_payment_method ) { |
|
680 | + : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false)); |
|
681 | + if ($reset_payment_method) { |
|
682 | 682 | $this->checkout->selected_method_of_payment = null; |
683 | 683 | $this->checkout->payment_method = null; |
684 | 684 | $this->checkout->billing_form = null; |
@@ -697,12 +697,12 @@ discard block |
||
697 | 697 | * @param string $selected_method_of_payment |
698 | 698 | * @return EE_Billing_Info_Form |
699 | 699 | */ |
700 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
701 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) |
|
700 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
701 | + $selected_method_of_payment = ! empty($selected_method_of_payment) |
|
702 | 702 | ? $selected_method_of_payment |
703 | 703 | : $this->checkout->selected_method_of_payment; |
704 | 704 | EE_Registry::instance()->SSN->set_session_data( |
705 | - array( 'selected_method_of_payment' => $selected_method_of_payment ) |
|
705 | + array('selected_method_of_payment' => $selected_method_of_payment) |
|
706 | 706 | ); |
707 | 707 | } |
708 | 708 | |
@@ -718,19 +718,19 @@ discard block |
||
718 | 718 | // load payment method classes |
719 | 719 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
720 | 720 | // switch up header depending on number of available payment methods |
721 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
721 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
722 | 722 | ? apply_filters( |
723 | 723 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
724 | - __( 'Please Select Your Method of Payment', 'event_espresso' ) |
|
724 | + __('Please Select Your Method of Payment', 'event_espresso') |
|
725 | 725 | ) |
726 | 726 | : apply_filters( |
727 | 727 | 'FHEE__registration_page_payment_options__method_of_payment_hdr', |
728 | - __( 'Method of Payment', 'event_espresso' ) |
|
728 | + __('Method of Payment', 'event_espresso') |
|
729 | 729 | ); |
730 | 730 | $available_payment_methods = array( |
731 | 731 | // display the "Payment Method" header |
732 | 732 | 'payment_method_header' => new EE_Form_Section_HTML( |
733 | - EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' ) |
|
733 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
734 | 734 | ) |
735 | 735 | ); |
736 | 736 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
@@ -739,32 +739,32 @@ discard block |
||
739 | 739 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
740 | 740 | $payment_methods_billing_info = array( |
741 | 741 | new EE_Form_Section_HTML( |
742 | - EEH_HTML::div( '<br />', '', '', 'clear:both;' ) |
|
742 | + EEH_HTML::div('<br />', '', '', 'clear:both;') |
|
743 | 743 | ) |
744 | 744 | ); |
745 | 745 | // loop through payment methods |
746 | - foreach ( $this->checkout->available_payment_methods as $payment_method ) { |
|
747 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
746 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
747 | + if ($payment_method instanceof EE_Payment_Method) { |
|
748 | 748 | $payment_method_button = EEH_HTML::img( |
749 | 749 | $payment_method->button_url(), |
750 | 750 | $payment_method->name(), |
751 | - 'spco-payment-method-' . $payment_method->slug() . '-btn-img', |
|
751 | + 'spco-payment-method-'.$payment_method->slug().'-btn-img', |
|
752 | 752 | 'spco-payment-method-btn-img' |
753 | 753 | ); |
754 | 754 | // check if any payment methods are set as default |
755 | 755 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
756 | 756 | if ( |
757 | - ( $this->checkout->selected_method_of_payment === $payment_method->slug() ) |
|
758 | - || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() ) |
|
757 | + ($this->checkout->selected_method_of_payment === $payment_method->slug()) |
|
758 | + || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default()) |
|
759 | 759 | ) { |
760 | 760 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
761 | 761 | $this->_save_selected_method_of_payment(); |
762 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
762 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
763 | 763 | } else { |
764 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
764 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
765 | 765 | } |
766 | - $payment_methods_billing_info[ $payment_method->slug() |
|
767 | - . '-info' ] = $this->_payment_method_billing_info( |
|
766 | + $payment_methods_billing_info[$payment_method->slug() |
|
767 | + . '-info'] = $this->_payment_method_billing_info( |
|
768 | 768 | $payment_method |
769 | 769 | ); |
770 | 770 | } |
@@ -794,12 +794,12 @@ discard block |
||
794 | 794 | * @return EE_Payment_Method[] |
795 | 795 | */ |
796 | 796 | protected function _get_available_payment_methods() { |
797 | - if ( ! empty( $this->checkout->available_payment_methods ) ) { |
|
797 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
798 | 798 | return $this->checkout->available_payment_methods; |
799 | 799 | } |
800 | 800 | $available_payment_methods = array(); |
801 | 801 | // load EEM_Payment_Method |
802 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
802 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
803 | 803 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
804 | 804 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
805 | 805 | // get all active payment methods |
@@ -807,9 +807,9 @@ discard block |
||
807 | 807 | $this->checkout->transaction, |
808 | 808 | EEM_Payment_Method::scope_cart |
809 | 809 | ); |
810 | - foreach ( $payment_methods as $payment_method ) { |
|
811 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
812 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
810 | + foreach ($payment_methods as $payment_method) { |
|
811 | + if ($payment_method instanceof EE_Payment_Method) { |
|
812 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | return $available_payment_methods; |
@@ -824,14 +824,14 @@ discard block |
||
824 | 824 | * @param array $available_payment_method_options |
825 | 825 | * @return \EE_Form_Section_Proper |
826 | 826 | */ |
827 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
827 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
828 | 828 | // generate inputs |
829 | 829 | return new EE_Form_Section_Proper( |
830 | 830 | array( |
831 | 831 | 'html_id' => 'ee-available-payment-method-inputs', |
832 | 832 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
833 | 833 | 'subsections' => array( |
834 | - '' => new EE_Radio_Button_Input ( |
|
834 | + '' => new EE_Radio_Button_Input( |
|
835 | 835 | $available_payment_method_options, |
836 | 836 | array( |
837 | 837 | 'html_name' => 'selected_method_of_payment', |
@@ -856,28 +856,28 @@ discard block |
||
856 | 856 | * @return \EE_Form_Section_Proper |
857 | 857 | * @throws \EE_Error |
858 | 858 | */ |
859 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
859 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
860 | 860 | $currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug() |
861 | 861 | ? true |
862 | 862 | : false; |
863 | 863 | // generate the billing form for payment method |
864 | 864 | $billing_form = $currently_selected |
865 | - ? $this->_get_billing_form_for_payment_method( $payment_method ) |
|
865 | + ? $this->_get_billing_form_for_payment_method($payment_method) |
|
866 | 866 | : new EE_Form_Section_HTML(); |
867 | 867 | $this->checkout->billing_form = $currently_selected |
868 | 868 | ? $billing_form |
869 | 869 | : $this->checkout->billing_form; |
870 | 870 | // it's all in the details |
871 | 871 | $info_html = EEH_HTML::h3( |
872 | - __( 'Important information regarding your payment', 'event_espresso' ), |
|
872 | + __('Important information regarding your payment', 'event_espresso'), |
|
873 | 873 | '', |
874 | 874 | 'spco-payment-method-hdr' |
875 | 875 | ); |
876 | 876 | // add some info regarding the step, either from what's saved in the admin, |
877 | 877 | // or a default string depending on whether the PM has a billing form or not |
878 | - if ( $payment_method->description() ) { |
|
878 | + if ($payment_method->description()) { |
|
879 | 879 | $payment_method_info = $payment_method->description(); |
880 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
880 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
881 | 881 | $payment_method_info = sprintf( |
882 | 882 | __( |
883 | 883 | 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | ); |
888 | 888 | } else { |
889 | 889 | $payment_method_info = sprintf( |
890 | - __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), |
|
890 | + __('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), |
|
891 | 891 | $this->submit_button_text() |
892 | 892 | ); |
893 | 893 | } |
@@ -901,13 +901,13 @@ discard block |
||
901 | 901 | ); |
902 | 902 | return new EE_Form_Section_Proper( |
903 | 903 | array( |
904 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
904 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
905 | 905 | 'html_class' => 'spco-payment-method-info-dv', |
906 | 906 | // only display the selected or default PM |
907 | 907 | 'html_style' => $currently_selected ? '' : 'display:none;', |
908 | 908 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
909 | 909 | 'subsections' => array( |
910 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
910 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
911 | 911 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
912 | 912 | ) |
913 | 913 | ) |
@@ -925,15 +925,15 @@ discard block |
||
925 | 925 | */ |
926 | 926 | public function get_billing_form_html_for_payment_method() { |
927 | 927 | // how have they chosen to pay? |
928 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
928 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
929 | 929 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
930 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
930 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
931 | 931 | return false; |
932 | 932 | } |
933 | - if ( apply_filters( |
|
933 | + if (apply_filters( |
|
934 | 934 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
935 | 935 | false |
936 | - ) ) { |
|
936 | + )) { |
|
937 | 937 | EE_Error::add_success( |
938 | 938 | apply_filters( |
939 | 939 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | ); |
949 | 949 | } |
950 | 950 | // now generate billing form for selected method of payment |
951 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
951 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
952 | 952 | // fill form with attendee info if applicable |
953 | 953 | if ( |
954 | 954 | $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form |
@@ -970,10 +970,10 @@ discard block |
||
970 | 970 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper |
971 | 971 | ? $payment_method_billing_form->get_html() |
972 | 972 | : ''; |
973 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) ); |
|
973 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
974 | 974 | // localize validation rules for main form |
975 | 975 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
976 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
976 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
977 | 977 | return true; |
978 | 978 | } |
979 | 979 | |
@@ -987,18 +987,18 @@ discard block |
||
987 | 987 | * @return \EE_Billing_Info_Form |
988 | 988 | * @throws \EE_Error |
989 | 989 | */ |
990 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
990 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
991 | 991 | $billing_form = $payment_method->type_obj()->billing_form( |
992 | 992 | $this->checkout->transaction, |
993 | - array( 'amount_owing' => $this->checkout->amount_owing ) |
|
993 | + array('amount_owing' => $this->checkout->amount_owing) |
|
994 | 994 | ); |
995 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
995 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
996 | 996 | if ( |
997 | 997 | apply_filters( |
998 | 998 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
999 | 999 | false |
1000 | 1000 | ) |
1001 | - && EE_Registry::instance()->REQ->is_set( 'payment_method' ) |
|
1001 | + && EE_Registry::instance()->REQ->is_set('payment_method') |
|
1002 | 1002 | ) { |
1003 | 1003 | EE_Error::add_success( |
1004 | 1004 | apply_filters( |
@@ -1040,15 +1040,15 @@ discard block |
||
1040 | 1040 | $request_param = 'selected_method_of_payment' |
1041 | 1041 | ) { |
1042 | 1042 | // is selected_method_of_payment set in the request ? |
1043 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false ); |
|
1044 | - if ( $selected_method_of_payment ) { |
|
1043 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false); |
|
1044 | + if ($selected_method_of_payment) { |
|
1045 | 1045 | // sanitize it |
1046 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) |
|
1047 | - ? array_shift( $selected_method_of_payment ) |
|
1046 | + $selected_method_of_payment = is_array($selected_method_of_payment) |
|
1047 | + ? array_shift($selected_method_of_payment) |
|
1048 | 1048 | : $selected_method_of_payment; |
1049 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
1049 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
1050 | 1050 | // store it in the session so that it's available for all subsequent requests including AJAX |
1051 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
1051 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
1052 | 1052 | } else { |
1053 | 1053 | // or is is set in the session ? |
1054 | 1054 | $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | ); |
1057 | 1057 | } |
1058 | 1058 | // do ya really really gotta have it? |
1059 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
1059 | + if (empty($selected_method_of_payment) && $required) { |
|
1060 | 1060 | EE_Error::add_error( |
1061 | 1061 | sprintf( |
1062 | 1062 | __( |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | ), |
1066 | 1066 | '<br/>', |
1067 | 1067 | '<br/>', |
1068 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1068 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1069 | 1069 | ), |
1070 | 1070 | __FILE__, |
1071 | 1071 | __FUNCTION__, |
@@ -1092,13 +1092,13 @@ discard block |
||
1092 | 1092 | * @throws \EE_Error |
1093 | 1093 | */ |
1094 | 1094 | public function switch_payment_method() { |
1095 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1095 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1096 | 1096 | return false; |
1097 | 1097 | } |
1098 | - if ( apply_filters( |
|
1098 | + if (apply_filters( |
|
1099 | 1099 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', |
1100 | 1100 | false |
1101 | - ) ) { |
|
1101 | + )) { |
|
1102 | 1102 | EE_Error::add_success( |
1103 | 1103 | apply_filters( |
1104 | 1104 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -1113,13 +1113,13 @@ discard block |
||
1113 | 1113 | ); |
1114 | 1114 | } |
1115 | 1115 | // generate billing form for selected method of payment if it hasn't been done already |
1116 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1116 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1117 | 1117 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1118 | 1118 | $this->checkout->payment_method |
1119 | 1119 | ); |
1120 | 1120 | } |
1121 | 1121 | // fill form with attendee info if applicable |
1122 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
1122 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form |
|
1123 | 1123 | && $this->checkout->transaction_has_primary_registrant() |
1124 | 1124 | ) { |
1125 | 1125 | $this->checkout->billing_form->populate_from_attendee( |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | ); |
1128 | 1128 | } |
1129 | 1129 | // and debug content |
1130 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1130 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form |
|
1131 | 1131 | && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base |
1132 | 1132 | ) { |
1133 | 1133 | $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( |
@@ -1135,15 +1135,15 @@ discard block |
||
1135 | 1135 | ); |
1136 | 1136 | } |
1137 | 1137 | // get html and validation rules for form |
1138 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
1138 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
1139 | 1139 | $this->checkout->json_response->set_return_data( |
1140 | - array( 'payment_method_info' => $this->checkout->billing_form->get_html() ) |
|
1140 | + array('payment_method_info' => $this->checkout->billing_form->get_html()) |
|
1141 | 1141 | ); |
1142 | 1142 | // localize validation rules for main form |
1143 | - $this->checkout->billing_form->localize_validation_rules( true ); |
|
1144 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
1143 | + $this->checkout->billing_form->localize_validation_rules(true); |
|
1144 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
1145 | 1145 | } else { |
1146 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) ); |
|
1146 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
1147 | 1147 | } |
1148 | 1148 | //prevents advancement to next step |
1149 | 1149 | $this->checkout->continue_reg = false; |
@@ -1160,12 +1160,12 @@ discard block |
||
1160 | 1160 | */ |
1161 | 1161 | protected function _verify_payment_method_is_set() { |
1162 | 1162 | // generate billing form for selected method of payment if it hasn't been done already |
1163 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1163 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1164 | 1164 | // how have they chosen to pay? |
1165 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1165 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1166 | 1166 | } |
1167 | 1167 | // verify payment method |
1168 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
1168 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
1169 | 1169 | // get payment method for selected method of payment |
1170 | 1170 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
1171 | 1171 | } |
@@ -1184,25 +1184,25 @@ discard block |
||
1184 | 1184 | * @throws \EE_Error |
1185 | 1185 | */ |
1186 | 1186 | public function save_payer_details_via_ajax() { |
1187 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
1187 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
1188 | 1188 | return; |
1189 | 1189 | } |
1190 | 1190 | // generate billing form for selected method of payment if it hasn't been done already |
1191 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1191 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1192 | 1192 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1193 | 1193 | $this->checkout->payment_method |
1194 | 1194 | ); |
1195 | 1195 | } |
1196 | 1196 | // generate primary attendee from payer info if applicable |
1197 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1197 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1198 | 1198 | $attendee = $this->_create_attendee_from_request_data(); |
1199 | - if ( $attendee instanceof EE_Attendee ) { |
|
1200 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
1201 | - if ( $registration->is_primary_registrant() ) { |
|
1199 | + if ($attendee instanceof EE_Attendee) { |
|
1200 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
1201 | + if ($registration->is_primary_registrant()) { |
|
1202 | 1202 | $this->checkout->primary_attendee_obj = $attendee; |
1203 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1204 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1205 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1203 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1204 | + $registration->set_attendee_id($attendee->ID()); |
|
1205 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1206 | 1206 | } |
1207 | 1207 | } |
1208 | 1208 | } |
@@ -1219,50 +1219,50 @@ discard block |
||
1219 | 1219 | */ |
1220 | 1220 | protected function _create_attendee_from_request_data() { |
1221 | 1221 | // get State ID |
1222 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
1223 | - if ( ! empty( $STA_ID ) ) { |
|
1222 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
1223 | + if ( ! empty($STA_ID)) { |
|
1224 | 1224 | // can we get state object from name ? |
1225 | - EE_Registry::instance()->load_model( 'State' ); |
|
1226 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' ); |
|
1227 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
1225 | + EE_Registry::instance()->load_model('State'); |
|
1226 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
1227 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
1228 | 1228 | } |
1229 | 1229 | // get Country ISO |
1230 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
1231 | - if ( ! empty( $CNT_ISO ) ) { |
|
1230 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
1231 | + if ( ! empty($CNT_ISO)) { |
|
1232 | 1232 | // can we get country object from name ? |
1233 | - EE_Registry::instance()->load_model( 'Country' ); |
|
1233 | + EE_Registry::instance()->load_model('Country'); |
|
1234 | 1234 | $country = EEM_Country::instance()->get_col( |
1235 | - array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ), |
|
1235 | + array(array('CNT_name' => $CNT_ISO), 'limit' => 1), |
|
1236 | 1236 | 'CNT_ISO' |
1237 | 1237 | ); |
1238 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
1238 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
1239 | 1239 | } |
1240 | 1240 | // grab attendee data |
1241 | 1241 | $attendee_data = array( |
1242 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
1243 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1244 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1245 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1246 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1247 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
1242 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
1243 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1244 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1245 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1246 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1247 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1248 | 1248 | 'STA_ID' => $STA_ID, |
1249 | 1249 | 'CNT_ISO' => $CNT_ISO, |
1250 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1251 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1250 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1251 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1252 | 1252 | ); |
1253 | 1253 | // validate the email address since it is the most important piece of info |
1254 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) { |
|
1254 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) { |
|
1255 | 1255 | EE_Error::add_error( |
1256 | - __( 'An invalid email address was submitted.', 'event_espresso' ), |
|
1256 | + __('An invalid email address was submitted.', 'event_espresso'), |
|
1257 | 1257 | __FILE__, |
1258 | 1258 | __FUNCTION__, |
1259 | 1259 | __LINE__ |
1260 | 1260 | ); |
1261 | 1261 | } |
1262 | 1262 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1263 | - if ( ! empty( $attendee_data['ATT_fname'] ) |
|
1264 | - && ! empty( $attendee_data['ATT_lname'] ) |
|
1265 | - && ! empty( $attendee_data['ATT_email'] ) |
|
1263 | + if ( ! empty($attendee_data['ATT_fname']) |
|
1264 | + && ! empty($attendee_data['ATT_lname']) |
|
1265 | + && ! empty($attendee_data['ATT_email']) |
|
1266 | 1266 | ) { |
1267 | 1267 | $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( |
1268 | 1268 | array( |
@@ -1271,19 +1271,19 @@ discard block |
||
1271 | 1271 | 'ATT_email' => $attendee_data['ATT_email'] |
1272 | 1272 | ) |
1273 | 1273 | ); |
1274 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1274 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1275 | 1275 | return $existing_attendee; |
1276 | 1276 | } |
1277 | 1277 | } |
1278 | 1278 | // no existing attendee? kk let's create a new one |
1279 | 1279 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1280 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) |
|
1280 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) |
|
1281 | 1281 | ? $attendee_data['ATT_fname'] |
1282 | 1282 | : $attendee_data['ATT_email']; |
1283 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) |
|
1283 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) |
|
1284 | 1284 | ? $attendee_data['ATT_lname'] |
1285 | 1285 | : $attendee_data['ATT_email']; |
1286 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1286 | + return EE_Attendee::new_instance($attendee_data); |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | |
@@ -1301,26 +1301,26 @@ discard block |
||
1301 | 1301 | // how have they chosen to pay? |
1302 | 1302 | $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() |
1303 | 1303 | ? 'no_payment_required' |
1304 | - : $this->_get_selected_method_of_payment( true ); |
|
1304 | + : $this->_get_selected_method_of_payment(true); |
|
1305 | 1305 | // choose your own adventure based on method_of_payment |
1306 | - switch ( $this->checkout->selected_method_of_payment ) { |
|
1306 | + switch ($this->checkout->selected_method_of_payment) { |
|
1307 | 1307 | |
1308 | 1308 | case 'events_sold_out' : |
1309 | 1309 | $this->checkout->redirect = true; |
1310 | 1310 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1311 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1311 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1312 | 1312 | // mark this reg step as completed |
1313 | 1313 | $this->set_completed(); |
1314 | 1314 | return false; |
1315 | 1315 | break; |
1316 | 1316 | |
1317 | 1317 | case 'payments_closed' : |
1318 | - if ( apply_filters( |
|
1318 | + if (apply_filters( |
|
1319 | 1319 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', |
1320 | 1320 | false |
1321 | - ) ) { |
|
1321 | + )) { |
|
1322 | 1322 | EE_Error::add_success( |
1323 | - __( 'no payment required at this time.', 'event_espresso' ), |
|
1323 | + __('no payment required at this time.', 'event_espresso'), |
|
1324 | 1324 | __FILE__, |
1325 | 1325 | __FUNCTION__, |
1326 | 1326 | __LINE__ |
@@ -1332,12 +1332,12 @@ discard block |
||
1332 | 1332 | break; |
1333 | 1333 | |
1334 | 1334 | case 'no_payment_required' : |
1335 | - if ( apply_filters( |
|
1335 | + if (apply_filters( |
|
1336 | 1336 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', |
1337 | 1337 | false |
1338 | - ) ) { |
|
1338 | + )) { |
|
1339 | 1339 | EE_Error::add_success( |
1340 | - __( 'no payment required.', 'event_espresso' ), |
|
1340 | + __('no payment required.', 'event_espresso'), |
|
1341 | 1341 | __FILE__, |
1342 | 1342 | __FUNCTION__, |
1343 | 1343 | __LINE__ |
@@ -1350,9 +1350,9 @@ discard block |
||
1350 | 1350 | |
1351 | 1351 | default: |
1352 | 1352 | $payment_successful = $this->_process_payment(); |
1353 | - if ( $payment_successful ) { |
|
1353 | + if ($payment_successful) { |
|
1354 | 1354 | $this->checkout->continue_reg = true; |
1355 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1355 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1356 | 1356 | } else { |
1357 | 1357 | $this->checkout->continue_reg = false; |
1358 | 1358 | } |
@@ -1371,8 +1371,8 @@ discard block |
||
1371 | 1371 | * @return void |
1372 | 1372 | * @throws \EE_Error |
1373 | 1373 | */ |
1374 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1375 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1374 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1375 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1376 | 1376 | case EE_PMT_Base::offsite : |
1377 | 1377 | break; |
1378 | 1378 | case EE_PMT_Base::onsite : |
@@ -1395,7 +1395,7 @@ discard block |
||
1395 | 1395 | public function update_reg_step() { |
1396 | 1396 | $success = true; |
1397 | 1397 | // if payment required |
1398 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1398 | + if ($this->checkout->transaction->total() > 0) { |
|
1399 | 1399 | do_action( |
1400 | 1400 | 'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', |
1401 | 1401 | $this->checkout->transaction |
@@ -1403,13 +1403,13 @@ discard block |
||
1403 | 1403 | // attempt payment via payment method |
1404 | 1404 | $success = $this->process_reg_step(); |
1405 | 1405 | } |
1406 | - if ( $success && ! $this->checkout->redirect ) { |
|
1406 | + if ($success && ! $this->checkout->redirect) { |
|
1407 | 1407 | $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( |
1408 | 1408 | $this->checkout->transaction->ID() |
1409 | 1409 | ); |
1410 | 1410 | // set return URL |
1411 | 1411 | $this->checkout->redirect_url = add_query_arg( |
1412 | - array( 'e_reg_url_link' => $this->checkout->reg_url_link ), |
|
1412 | + array('e_reg_url_link' => $this->checkout->reg_url_link), |
|
1413 | 1413 | $this->checkout->thank_you_page_url |
1414 | 1414 | ); |
1415 | 1415 | } |
@@ -1429,28 +1429,28 @@ discard block |
||
1429 | 1429 | // clear any previous errors related to not selecting a payment method |
1430 | 1430 | // EE_Error::overwrite_errors(); |
1431 | 1431 | // ya gotta make a choice man |
1432 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1432 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1433 | 1433 | $this->checkout->json_response->set_plz_select_method_of_payment( |
1434 | - __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1434 | + __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1435 | 1435 | ); |
1436 | 1436 | return false; |
1437 | 1437 | } |
1438 | 1438 | // get EE_Payment_Method object |
1439 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1439 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1440 | 1440 | return false; |
1441 | 1441 | } |
1442 | 1442 | // setup billing form |
1443 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1443 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1444 | 1444 | $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( |
1445 | 1445 | $this->checkout->payment_method |
1446 | 1446 | ); |
1447 | 1447 | // bad billing form ? |
1448 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1448 | + if ( ! $this->_billing_form_is_valid()) { |
|
1449 | 1449 | return false; |
1450 | 1450 | } |
1451 | 1451 | } |
1452 | 1452 | // ensure primary registrant has been fully processed |
1453 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1453 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1454 | 1454 | return false; |
1455 | 1455 | } |
1456 | 1456 | /** @type EE_Transaction_Processor $transaction_processor */ |
@@ -1458,18 +1458,18 @@ discard block |
||
1458 | 1458 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1459 | 1459 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1460 | 1460 | // attempt payment |
1461 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1461 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1462 | 1462 | // process results |
1463 | - $payment = $this->_validate_payment( $payment ); |
|
1464 | - $payment = $this->_post_payment_processing( $payment ); |
|
1463 | + $payment = $this->_validate_payment($payment); |
|
1464 | + $payment = $this->_post_payment_processing($payment); |
|
1465 | 1465 | // verify payment |
1466 | - if ( $payment instanceof EE_Payment ) { |
|
1466 | + if ($payment instanceof EE_Payment) { |
|
1467 | 1467 | // store that for later |
1468 | 1468 | $this->checkout->payment = $payment; |
1469 | 1469 | /** @type EE_Transaction_Processor $transaction_processor */ |
1470 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1470 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1471 | 1471 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1472 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1472 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1473 | 1473 | $payment_status = $payment->status(); |
1474 | 1474 | if ( |
1475 | 1475 | $payment_status === EEM_Payment::status_id_approved |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | } else { |
1480 | 1480 | return false; |
1481 | 1481 | } |
1482 | - } else if ( $payment === true ) { |
|
1482 | + } else if ($payment === true) { |
|
1483 | 1483 | // please note that offline payment methods will NOT make a payment, |
1484 | 1484 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1485 | 1485 | $this->checkout->payment = $payment; |
@@ -1504,7 +1504,7 @@ discard block |
||
1504 | 1504 | ); |
1505 | 1505 | $html = $payment_method_billing_info->get_html_and_js(); |
1506 | 1506 | $html .= $this->checkout->redirect_form; |
1507 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1507 | + EE_Registry::instance()->REQ->add_output($html); |
|
1508 | 1508 | return true; |
1509 | 1509 | } |
1510 | 1510 | |
@@ -1518,28 +1518,28 @@ discard block |
||
1518 | 1518 | * @throws \EE_Error |
1519 | 1519 | */ |
1520 | 1520 | private function _billing_form_is_valid() { |
1521 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1521 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1522 | 1522 | return true; |
1523 | 1523 | } |
1524 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1525 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1524 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1525 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1526 | 1526 | $this->checkout->billing_form->receive_form_submission(); |
1527 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1527 | + if ($this->checkout->billing_form->is_valid()) { |
|
1528 | 1528 | return true; |
1529 | 1529 | } |
1530 | 1530 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1531 | 1531 | $error_strings = array(); |
1532 | - foreach ( $validation_errors as $validation_error ) { |
|
1533 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1532 | + foreach ($validation_errors as $validation_error) { |
|
1533 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1534 | 1534 | $form_section = $validation_error->get_form_section(); |
1535 | - if ( $form_section instanceof EE_Form_Input_Base ) { |
|
1535 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1536 | 1536 | $label = $form_section->html_label_text(); |
1537 | - } elseif ( $form_section instanceof EE_Form_Section_Base ) { |
|
1537 | + } elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1538 | 1538 | $label = $form_section->name(); |
1539 | 1539 | } else { |
1540 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1540 | + $label = __('Validation Error', 'event_espresso'); |
|
1541 | 1541 | } |
1542 | - $error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1542 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1543 | 1543 | } |
1544 | 1544 | } |
1545 | 1545 | EE_Error::add_error( |
@@ -1549,7 +1549,7 @@ discard block |
||
1549 | 1549 | 'event_espresso' |
1550 | 1550 | ), |
1551 | 1551 | '<br/>', |
1552 | - implode( '<br/>', $error_strings ) |
|
1552 | + implode('<br/>', $error_strings) |
|
1553 | 1553 | ), |
1554 | 1554 | __FILE__, |
1555 | 1555 | __FUNCTION__, |
@@ -1568,7 +1568,7 @@ discard block |
||
1568 | 1568 | } |
1569 | 1569 | } else { |
1570 | 1570 | EE_Error::add_error( |
1571 | - __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), |
|
1571 | + __('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), |
|
1572 | 1572 | __FILE__, |
1573 | 1573 | __FUNCTION__, |
1574 | 1574 | __LINE__ |
@@ -1603,13 +1603,13 @@ discard block |
||
1603 | 1603 | // grab the primary_registration object |
1604 | 1604 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1605 | 1605 | /** @type EE_Transaction_Processor $transaction_processor */ |
1606 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1606 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1607 | 1607 | // at this point we'll consider a TXN to not have been failed |
1608 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1608 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1609 | 1609 | // save the TXN ( which clears cached copy of primary_registration) |
1610 | 1610 | $this->checkout->transaction->save(); |
1611 | 1611 | // grab TXN ID and save it to the primary_registration |
1612 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1612 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1613 | 1613 | // save what we have so far |
1614 | 1614 | $primary_registration->save(); |
1615 | 1615 | return true; |
@@ -1627,7 +1627,7 @@ discard block |
||
1627 | 1627 | private function _capture_primary_registration_data_from_billing_form() { |
1628 | 1628 | // convert billing form data into an attendee |
1629 | 1629 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1630 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1630 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1631 | 1631 | EE_Error::add_error( |
1632 | 1632 | sprintf( |
1633 | 1633 | __( |
@@ -1635,7 +1635,7 @@ discard block |
||
1635 | 1635 | 'event_espresso' |
1636 | 1636 | ), |
1637 | 1637 | '<br/>', |
1638 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1638 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1639 | 1639 | ), |
1640 | 1640 | __FILE__, |
1641 | 1641 | __FUNCTION__, |
@@ -1644,7 +1644,7 @@ discard block |
||
1644 | 1644 | return false; |
1645 | 1645 | } |
1646 | 1646 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1647 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1647 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1648 | 1648 | EE_Error::add_error( |
1649 | 1649 | sprintf( |
1650 | 1650 | __( |
@@ -1652,7 +1652,7 @@ discard block |
||
1652 | 1652 | 'event_espresso' |
1653 | 1653 | ), |
1654 | 1654 | '<br/>', |
1655 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1655 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1656 | 1656 | ), |
1657 | 1657 | __FILE__, |
1658 | 1658 | __FUNCTION__, |
@@ -1660,7 +1660,7 @@ discard block |
||
1660 | 1660 | ); |
1661 | 1661 | return false; |
1662 | 1662 | } |
1663 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) |
|
1663 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') |
|
1664 | 1664 | instanceof |
1665 | 1665 | EE_Attendee |
1666 | 1666 | ) { |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | 'event_espresso' |
1672 | 1672 | ), |
1673 | 1673 | '<br/>', |
1674 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1674 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1675 | 1675 | ), |
1676 | 1676 | __FILE__, |
1677 | 1677 | __FUNCTION__, |
@@ -1680,9 +1680,9 @@ discard block |
||
1680 | 1680 | return false; |
1681 | 1681 | } |
1682 | 1682 | /** @type EE_Registration_Processor $registration_processor */ |
1683 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1683 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1684 | 1684 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1685 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1685 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1686 | 1686 | return true; |
1687 | 1687 | } |
1688 | 1688 | |
@@ -1698,17 +1698,17 @@ discard block |
||
1698 | 1698 | */ |
1699 | 1699 | private function _get_payment_method_for_selected_method_of_payment() { |
1700 | 1700 | // get EE_Payment_Method object |
1701 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) { |
|
1702 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
1701 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
1702 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
1703 | 1703 | } else { |
1704 | 1704 | // load EEM_Payment_Method |
1705 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1705 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1706 | 1706 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1707 | 1707 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1708 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
1708 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
1709 | 1709 | } |
1710 | 1710 | // verify $payment_method |
1711 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
1711 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
1712 | 1712 | // not a payment |
1713 | 1713 | EE_Error::add_error( |
1714 | 1714 | sprintf( |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | 'event_espresso' |
1718 | 1718 | ), |
1719 | 1719 | '<br/>', |
1720 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1720 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1721 | 1721 | ), |
1722 | 1722 | __FILE__, |
1723 | 1723 | __FUNCTION__, |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | return null; |
1727 | 1727 | } |
1728 | 1728 | // and verify it has a valid Payment_Method Type object |
1729 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
1729 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
1730 | 1730 | // not a payment |
1731 | 1731 | EE_Error::add_error( |
1732 | 1732 | sprintf( |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | 'event_espresso' |
1736 | 1736 | ), |
1737 | 1737 | '<br/>', |
1738 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1738 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1739 | 1739 | ), |
1740 | 1740 | __FILE__, |
1741 | 1741 | __FUNCTION__, |
@@ -1756,29 +1756,29 @@ discard block |
||
1756 | 1756 | * @return mixed EE_Payment | boolean |
1757 | 1757 | * @throws \EE_Error |
1758 | 1758 | */ |
1759 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
1759 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
1760 | 1760 | $payment = null; |
1761 | 1761 | $this->checkout->transaction->save(); |
1762 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1763 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
1762 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1763 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
1764 | 1764 | return false; |
1765 | 1765 | } |
1766 | 1766 | try { |
1767 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
1767 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
1768 | 1768 | // generate payment object |
1769 | 1769 | $payment = $payment_processor->process_payment( |
1770 | 1770 | $payment_method, |
1771 | 1771 | $this->checkout->transaction, |
1772 | 1772 | $this->checkout->amount_owing, |
1773 | 1773 | $this->checkout->billing_form, |
1774 | - $this->_get_return_url( $payment_method ), |
|
1774 | + $this->_get_return_url($payment_method), |
|
1775 | 1775 | 'CART', |
1776 | 1776 | $this->checkout->admin_request, |
1777 | 1777 | true, |
1778 | 1778 | $this->reg_step_url() |
1779 | 1779 | ); |
1780 | - } catch ( Exception $e ) { |
|
1781 | - $this->_handle_payment_processor_exception( $e ); |
|
1780 | + } catch (Exception $e) { |
|
1781 | + $this->_handle_payment_processor_exception($e); |
|
1782 | 1782 | } |
1783 | 1783 | return $payment; |
1784 | 1784 | } |
@@ -1793,7 +1793,7 @@ discard block |
||
1793 | 1793 | * @return void |
1794 | 1794 | * @throws \EE_Error |
1795 | 1795 | */ |
1796 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
1796 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
1797 | 1797 | EE_Error::add_error( |
1798 | 1798 | sprintf( |
1799 | 1799 | __( |
@@ -1801,7 +1801,7 @@ discard block |
||
1801 | 1801 | 'event_espresso' |
1802 | 1802 | ), |
1803 | 1803 | '<br/>', |
1804 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
1804 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
1805 | 1805 | $e->getMessage(), |
1806 | 1806 | $e->getFile(), |
1807 | 1807 | $e->getLine() |
@@ -1822,9 +1822,9 @@ discard block |
||
1822 | 1822 | * @return string |
1823 | 1823 | * @throws \EE_Error |
1824 | 1824 | */ |
1825 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
1825 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
1826 | 1826 | $return_url = ''; |
1827 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1827 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1828 | 1828 | case EE_PMT_Base::offsite : |
1829 | 1829 | $return_url = add_query_arg( |
1830 | 1830 | array( |
@@ -1853,12 +1853,12 @@ discard block |
||
1853 | 1853 | * @return EE_Payment | FALSE |
1854 | 1854 | * @throws \EE_Error |
1855 | 1855 | */ |
1856 | - private function _validate_payment( $payment = null ) { |
|
1857 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
1856 | + private function _validate_payment($payment = null) { |
|
1857 | + if ($this->checkout->payment_method->is_off_line()) { |
|
1858 | 1858 | return true; |
1859 | 1859 | } |
1860 | 1860 | // verify payment object |
1861 | - if ( ! $payment instanceof EE_Payment ) { |
|
1861 | + if ( ! $payment instanceof EE_Payment) { |
|
1862 | 1862 | // not a payment |
1863 | 1863 | EE_Error::add_error( |
1864 | 1864 | sprintf( |
@@ -1867,7 +1867,7 @@ discard block |
||
1867 | 1867 | 'event_espresso' |
1868 | 1868 | ), |
1869 | 1869 | '<br/>', |
1870 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1870 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1871 | 1871 | ), |
1872 | 1872 | __FILE__, |
1873 | 1873 | __FUNCTION__, |
@@ -1888,27 +1888,27 @@ discard block |
||
1888 | 1888 | * @return bool |
1889 | 1889 | * @throws \EE_Error |
1890 | 1890 | */ |
1891 | - private function _post_payment_processing( $payment = null ) { |
|
1891 | + private function _post_payment_processing($payment = null) { |
|
1892 | 1892 | // Off-Line payment? |
1893 | - if ( $payment === true ) { |
|
1893 | + if ($payment === true) { |
|
1894 | 1894 | //$this->_setup_redirect_for_next_step(); |
1895 | 1895 | return true; |
1896 | 1896 | // On-Site payment? |
1897 | - } else if ( $this->checkout->payment_method->is_on_site() ) { |
|
1898 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) { |
|
1897 | + } else if ($this->checkout->payment_method->is_on_site()) { |
|
1898 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
1899 | 1899 | //$this->_setup_redirect_for_next_step(); |
1900 | 1900 | $this->checkout->continue_reg = false; |
1901 | 1901 | } |
1902 | 1902 | // Off-Site payment? |
1903 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
1903 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
1904 | 1904 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
1905 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ) { |
|
1906 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
1905 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
1906 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
1907 | 1907 | $this->checkout->redirect = true; |
1908 | 1908 | $this->checkout->redirect_form = $payment->redirect_form(); |
1909 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
1909 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
1910 | 1910 | // set JSON response |
1911 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
1911 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
1912 | 1912 | // set cron job for finalizing the TXN |
1913 | 1913 | // in case the user does not return from the off-site gateway |
1914 | 1914 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -1916,7 +1916,7 @@ discard block |
||
1916 | 1916 | $this->checkout->transaction->ID() |
1917 | 1917 | ); |
1918 | 1918 | // and lastly, let's bump the payment status to pending |
1919 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
1919 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
1920 | 1920 | $payment->save(); |
1921 | 1921 | } else { |
1922 | 1922 | // not a payment |
@@ -1928,7 +1928,7 @@ discard block |
||
1928 | 1928 | 'event_espresso' |
1929 | 1929 | ), |
1930 | 1930 | '<br/>', |
1931 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1931 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1932 | 1932 | ), |
1933 | 1933 | __FILE__, |
1934 | 1934 | __FUNCTION__, |
@@ -1966,21 +1966,21 @@ discard block |
||
1966 | 1966 | * @return bool |
1967 | 1967 | * @throws \EE_Error |
1968 | 1968 | */ |
1969 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
1969 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
1970 | 1970 | // off-line payment? carry on |
1971 | - if ( $payment_occurs === EE_PMT_Base::offline ) { |
|
1971 | + if ($payment_occurs === EE_PMT_Base::offline) { |
|
1972 | 1972 | return true; |
1973 | 1973 | } |
1974 | 1974 | // verify payment validity |
1975 | - if ( $payment instanceof EE_Payment ) { |
|
1976 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
1975 | + if ($payment instanceof EE_Payment) { |
|
1976 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
1977 | 1977 | $msg = $payment->gateway_response(); |
1978 | 1978 | // check results |
1979 | - switch ( $payment->status() ) { |
|
1979 | + switch ($payment->status()) { |
|
1980 | 1980 | // good payment |
1981 | 1981 | case EEM_Payment::status_id_approved : |
1982 | 1982 | EE_Error::add_success( |
1983 | - __( 'Your payment was processed successfully.', 'event_espresso' ), |
|
1983 | + __('Your payment was processed successfully.', 'event_espresso'), |
|
1984 | 1984 | __FILE__, |
1985 | 1985 | __FUNCTION__, |
1986 | 1986 | __LINE__ |
@@ -1989,45 +1989,45 @@ discard block |
||
1989 | 1989 | break; |
1990 | 1990 | // slow payment |
1991 | 1991 | case EEM_Payment::status_id_pending : |
1992 | - if ( empty( $msg ) ) { |
|
1992 | + if (empty($msg)) { |
|
1993 | 1993 | $msg = __( |
1994 | 1994 | 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', |
1995 | 1995 | 'event_espresso' |
1996 | 1996 | ); |
1997 | 1997 | } |
1998 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1998 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1999 | 1999 | return true; |
2000 | 2000 | break; |
2001 | 2001 | // don't wanna payment |
2002 | 2002 | case EEM_Payment::status_id_cancelled : |
2003 | - if ( empty( $msg ) ) { |
|
2003 | + if (empty($msg)) { |
|
2004 | 2004 | $msg = _n( |
2005 | 2005 | 'Payment cancelled. Please try again.', |
2006 | 2006 | 'Payment cancelled. Please try again or select another method of payment.', |
2007 | - count( $this->checkout->available_payment_methods ), |
|
2007 | + count($this->checkout->available_payment_methods), |
|
2008 | 2008 | 'event_espresso' |
2009 | 2009 | ); |
2010 | 2010 | } |
2011 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2011 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2012 | 2012 | return false; |
2013 | 2013 | break; |
2014 | 2014 | // not enough payment |
2015 | 2015 | case EEM_Payment::status_id_declined : |
2016 | - if ( empty( $msg ) ) { |
|
2016 | + if (empty($msg)) { |
|
2017 | 2017 | $msg = _n( |
2018 | 2018 | 'We\'re sorry but your payment was declined. Please try again.', |
2019 | 2019 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
2020 | - count( $this->checkout->available_payment_methods ), |
|
2020 | + count($this->checkout->available_payment_methods), |
|
2021 | 2021 | 'event_espresso' |
2022 | 2022 | ); |
2023 | 2023 | } |
2024 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2024 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2025 | 2025 | return false; |
2026 | 2026 | break; |
2027 | 2027 | // bad payment |
2028 | 2028 | case EEM_Payment::status_id_failed : |
2029 | - if ( ! empty( $msg ) ) { |
|
2030 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2029 | + if ( ! empty($msg)) { |
|
2030 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2031 | 2031 | return false; |
2032 | 2032 | } |
2033 | 2033 | // default to error below |
@@ -2036,7 +2036,7 @@ discard block |
||
2036 | 2036 | } |
2037 | 2037 | // off-site payment gateway responses are too unreliable, so let's just assume that |
2038 | 2038 | // the payment processing is just running slower than the registrant's request |
2039 | - if ( $payment_occurs === EE_PMT_Base::offsite ) { |
|
2039 | + if ($payment_occurs === EE_PMT_Base::offsite) { |
|
2040 | 2040 | return true; |
2041 | 2041 | } |
2042 | 2042 | EE_Error::add_error( |
@@ -2046,7 +2046,7 @@ discard block |
||
2046 | 2046 | 'event_espresso' |
2047 | 2047 | ), |
2048 | 2048 | '<br/>', |
2049 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2049 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2050 | 2050 | ), |
2051 | 2051 | __FILE__, |
2052 | 2052 | __FUNCTION__, |
@@ -2079,13 +2079,13 @@ discard block |
||
2079 | 2079 | public function process_gateway_response() { |
2080 | 2080 | $payment = null; |
2081 | 2081 | // how have they chosen to pay? |
2082 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
2082 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
2083 | 2083 | // get EE_Payment_Method object |
2084 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
2084 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
2085 | 2085 | $this->checkout->continue_reg = false; |
2086 | 2086 | return false; |
2087 | 2087 | } |
2088 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
2088 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
2089 | 2089 | return false; |
2090 | 2090 | } |
2091 | 2091 | $this->_validate_offsite_return(); |
@@ -2099,23 +2099,23 @@ discard block |
||
2099 | 2099 | // true |
2100 | 2100 | //); |
2101 | 2101 | // verify TXN |
2102 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
2102 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
2103 | 2103 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
2104 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
2104 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
2105 | 2105 | $this->checkout->continue_reg = false; |
2106 | 2106 | return false; |
2107 | 2107 | } |
2108 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
2109 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
2110 | - $payment = $this->_validate_payment( $payment ); |
|
2108 | + $payment = $this->_process_off_site_payment($gateway); |
|
2109 | + $payment = $this->_process_cancelled_payments($payment); |
|
2110 | + $payment = $this->_validate_payment($payment); |
|
2111 | 2111 | // if payment was not declined by the payment gateway or cancelled by the registrant |
2112 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
2112 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
2113 | 2113 | //$this->_setup_redirect_for_next_step(); |
2114 | 2114 | // store that for later |
2115 | 2115 | $this->checkout->payment = $payment; |
2116 | 2116 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
2117 | 2117 | // because we will complete this step during the IPN processing then |
2118 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) { |
|
2118 | + if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) { |
|
2119 | 2119 | $this->set_completed(); |
2120 | 2120 | } |
2121 | 2121 | return true; |
@@ -2139,21 +2139,21 @@ discard block |
||
2139 | 2139 | * @throws \EE_Error |
2140 | 2140 | */ |
2141 | 2141 | private function _validate_offsite_return() { |
2142 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
2143 | - if ( $TXN_ID !== $this->checkout->transaction->ID() ) { |
|
2142 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
2143 | + if ($TXN_ID !== $this->checkout->transaction->ID()) { |
|
2144 | 2144 | // Houston... we might have a problem |
2145 | 2145 | $invalid_TXN = false; |
2146 | 2146 | // first gather some info |
2147 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
2147 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
2148 | 2148 | $primary_registrant = $valid_TXN instanceof EE_Transaction |
2149 | 2149 | ? $valid_TXN->primary_registration() |
2150 | 2150 | : null; |
2151 | 2151 | // let's start by retrieving the cart for this TXN |
2152 | - $cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction ); |
|
2153 | - if ( $cart instanceof EE_Cart ) { |
|
2152 | + $cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction); |
|
2153 | + if ($cart instanceof EE_Cart) { |
|
2154 | 2154 | // verify that the current cart has tickets |
2155 | 2155 | $tickets = $cart->get_tickets(); |
2156 | - if ( empty( $tickets ) ) { |
|
2156 | + if (empty($tickets)) { |
|
2157 | 2157 | $invalid_TXN = true; |
2158 | 2158 | } |
2159 | 2159 | } else { |
@@ -2163,39 +2163,39 @@ discard block |
||
2163 | 2163 | ? $primary_registrant->session_ID() |
2164 | 2164 | : null; |
2165 | 2165 | // validate current Session ID and compare against valid TXN session ID |
2166 | - if ( EE_Session::instance()->id() === null ) { |
|
2166 | + if (EE_Session::instance()->id() === null) { |
|
2167 | 2167 | $invalid_TXN = true; |
2168 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
2168 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
2169 | 2169 | // WARNING !!! |
2170 | 2170 | // this could be PayPal sending back duplicate requests (ya they do that) |
2171 | 2171 | // or it **could** mean someone is simply registering AGAIN after having just done so |
2172 | 2172 | // so now we need to determine if this current TXN looks valid or not |
2173 | 2173 | /** @type EE_Transaction_Processor $transaction_processor */ |
2174 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
2174 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
2175 | 2175 | // has this step even been started ? |
2176 | - if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false ) |
|
2176 | + if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false) |
|
2177 | 2177 | ) { |
2178 | 2178 | // really? you're half way through this reg step, but you never started it ? |
2179 | 2179 | $invalid_TXN = true; |
2180 | 2180 | } |
2181 | 2181 | } |
2182 | - if ( $invalid_TXN ) { |
|
2182 | + if ($invalid_TXN) { |
|
2183 | 2183 | // is the valid TXN completed ? |
2184 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
2184 | + if ($valid_TXN instanceof EE_Transaction) { |
|
2185 | 2185 | /** @type EE_Transaction_Processor $transaction_processor */ |
2186 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
2186 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
2187 | 2187 | // has this step even been started ? |
2188 | - $reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() ); |
|
2189 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
2188 | + $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug()); |
|
2189 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
2190 | 2190 | // so it **looks** like this is a double request from PayPal |
2191 | 2191 | // so let's try to pick up where we left off |
2192 | 2192 | $this->checkout->transaction = $valid_TXN; |
2193 | - $this->checkout->refresh_all_entities( true ); |
|
2193 | + $this->checkout->refresh_all_entities(true); |
|
2194 | 2194 | return; |
2195 | 2195 | } |
2196 | 2196 | } |
2197 | 2197 | // you appear to be lost? |
2198 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
2198 | + $this->_redirect_wayward_request($primary_registrant); |
|
2199 | 2199 | } |
2200 | 2200 | } |
2201 | 2201 | } |
@@ -2210,14 +2210,14 @@ discard block |
||
2210 | 2210 | * @return bool |
2211 | 2211 | * @throws \EE_Error |
2212 | 2212 | */ |
2213 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
2214 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2213 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
2214 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2215 | 2215 | // try redirecting based on the current TXN |
2216 | 2216 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction |
2217 | 2217 | ? $this->checkout->transaction->primary_registration() |
2218 | 2218 | : null; |
2219 | 2219 | } |
2220 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
2220 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
2221 | 2221 | EE_Error::add_error( |
2222 | 2222 | sprintf( |
2223 | 2223 | __( |
@@ -2225,7 +2225,7 @@ discard block |
||
2225 | 2225 | 'event_espresso' |
2226 | 2226 | ), |
2227 | 2227 | '<br/>', |
2228 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
2228 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
2229 | 2229 | ), |
2230 | 2230 | __FILE__, |
2231 | 2231 | __FUNCTION__, |
@@ -2256,17 +2256,17 @@ discard block |
||
2256 | 2256 | * @return \EE_Payment |
2257 | 2257 | * @throws \EE_Error |
2258 | 2258 | */ |
2259 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
2259 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
2260 | 2260 | try { |
2261 | 2261 | $request_data = \EE_Registry::instance()->REQ->params(); |
2262 | 2262 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
2263 | 2263 | $this->set_handle_IPN_in_this_request( |
2264 | - $gateway->handle_IPN_in_this_request( $request_data, false ) |
|
2264 | + $gateway->handle_IPN_in_this_request($request_data, false) |
|
2265 | 2265 | ); |
2266 | - if ( $this->handle_IPN_in_this_request() ) { |
|
2266 | + if ($this->handle_IPN_in_this_request()) { |
|
2267 | 2267 | // get payment details and process results |
2268 | 2268 | /** @type EE_Payment_Processor $payment_processor */ |
2269 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
2269 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
2270 | 2270 | $payment = $payment_processor->process_ipn( |
2271 | 2271 | $request_data, |
2272 | 2272 | $this->checkout->transaction, |
@@ -2279,14 +2279,14 @@ discard block |
||
2279 | 2279 | $payment = $this->checkout->transaction->last_payment(); |
2280 | 2280 | //$payment_source = 'last_payment'; |
2281 | 2281 | } |
2282 | - } catch ( Exception $e ) { |
|
2282 | + } catch (Exception $e) { |
|
2283 | 2283 | // let's just eat the exception and try to move on using any previously set payment info |
2284 | 2284 | $payment = $this->checkout->transaction->last_payment(); |
2285 | 2285 | //$payment_source = 'last_payment after Exception'; |
2286 | 2286 | // but if we STILL don't have a payment object |
2287 | - if ( ! $payment instanceof EE_Payment ) { |
|
2287 | + if ( ! $payment instanceof EE_Payment) { |
|
2288 | 2288 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
2289 | - $this->_handle_payment_processor_exception( $e ); |
|
2289 | + $this->_handle_payment_processor_exception($e); |
|
2290 | 2290 | } |
2291 | 2291 | } |
2292 | 2292 | // DEBUG LOG |
@@ -2311,13 +2311,13 @@ discard block |
||
2311 | 2311 | * @return EE_Payment | FALSE |
2312 | 2312 | * @throws \EE_Error |
2313 | 2313 | */ |
2314 | - private function _process_cancelled_payments( $payment = null ) { |
|
2314 | + private function _process_cancelled_payments($payment = null) { |
|
2315 | 2315 | if ( |
2316 | 2316 | $payment instanceof EE_Payment |
2317 | - && isset( $_REQUEST['ee_cancel_payment'] ) |
|
2317 | + && isset($_REQUEST['ee_cancel_payment']) |
|
2318 | 2318 | && $payment->status() === EEM_Payment::status_id_failed |
2319 | 2319 | ) { |
2320 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
2320 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
2321 | 2321 | } |
2322 | 2322 | return $payment; |
2323 | 2323 | } |
@@ -2334,14 +2334,14 @@ discard block |
||
2334 | 2334 | public function get_transaction_details_for_gateways() { |
2335 | 2335 | $txn_details = array(); |
2336 | 2336 | // ya gotta make a choice man |
2337 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
2337 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
2338 | 2338 | $txn_details = array( |
2339 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
2339 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
2340 | 2340 | ); |
2341 | 2341 | } |
2342 | 2342 | // get EE_Payment_Method object |
2343 | 2343 | if ( |
2344 | - empty( $txn_details ) |
|
2344 | + empty($txn_details) |
|
2345 | 2345 | && |
2346 | 2346 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
2347 | 2347 | ) { |
@@ -2353,8 +2353,8 @@ discard block |
||
2353 | 2353 | ) |
2354 | 2354 | ); |
2355 | 2355 | } |
2356 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
2357 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
2356 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
2357 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
2358 | 2358 | $txn_details = array( |
2359 | 2359 | 'TXN_ID' => $this->checkout->transaction->ID(), |
2360 | 2360 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -2365,7 +2365,7 @@ discard block |
||
2365 | 2365 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
2366 | 2366 | 'payment_amount' => $this->checkout->amount_owing, |
2367 | 2367 | 'return_url' => $return_url, |
2368 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
2368 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
2369 | 2369 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
2370 | 2370 | array( |
2371 | 2371 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -2374,7 +2374,7 @@ discard block |
||
2374 | 2374 | ) |
2375 | 2375 | ); |
2376 | 2376 | } |
2377 | - echo json_encode( $txn_details ); |
|
2377 | + echo json_encode($txn_details); |
|
2378 | 2378 | exit(); |
2379 | 2379 | } |
2380 | 2380 |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Checkout |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * @since 4.5.0 |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_Checkout |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * @since 4.5.0 |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_Checkout { |
15 | 15 | |
16 | 16 | /** |
@@ -792,10 +792,10 @@ discard block |
||
792 | 792 | */ |
793 | 793 | public function visit_allows_processing_of_this_registration( EE_Registration $registration ) { |
794 | 794 | return ! $this->revisit |
795 | - || $this->primary_revisit |
|
796 | - || ( |
|
797 | - $this->revisit && $this->reg_url_link === $registration->reg_url_link() |
|
798 | - ) |
|
795 | + || $this->primary_revisit |
|
796 | + || ( |
|
797 | + $this->revisit && $this->reg_url_link === $registration->reg_url_link() |
|
798 | + ) |
|
799 | 799 | ? true |
800 | 800 | : false; |
801 | 801 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | /** |
253 | 253 | * returns true if ANY reg status was updated during checkout |
254 | - * @return array |
|
254 | + * @return boolean |
|
255 | 255 | */ |
256 | 256 | public function any_reg_status_updated() { |
257 | 257 | foreach ( $this->reg_status_updated as $reg_status ) { |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | /** |
278 | 278 | * @param $REG_ID |
279 | - * @param $reg_status |
|
279 | + * @param boolean $reg_status |
|
280 | 280 | */ |
281 | 281 | public function set_reg_status_updated( $REG_ID, $reg_status ) { |
282 | 282 | $this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN ); |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | * reset_reg_steps |
634 | 634 | * |
635 | 635 | * @access public |
636 | - * @return bool |
|
636 | + * @return boolean|null |
|
637 | 637 | */ |
638 | 638 | public function reset_reg_steps() { |
639 | 639 | $this->sort_reg_steps(); |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | * stores whether any updates were made to the TXN or it's related registrations |
749 | 749 | * |
750 | 750 | * @access public |
751 | - * @return bool |
|
751 | + * @return boolean|null |
|
752 | 752 | * @throws \EE_Error |
753 | 753 | */ |
754 | 754 | public function track_transaction_and_registration_status_updates() { |
@@ -1110,6 +1110,7 @@ discard block |
||
1110 | 1110 | * |
1111 | 1111 | * @param string | int $reg_cache_ID |
1112 | 1112 | * @param EE_Registration $registration |
1113 | + * @param integer $reg_cache_ID |
|
1113 | 1114 | * @return void |
1114 | 1115 | * @throws \EE_Error |
1115 | 1116 | */ |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | $this->reg_page_base_url = EE_Registry::instance()->CFG->core->reg_page_url(); |
243 | 243 | $this->thank_you_page_url = EE_Registry::instance()->CFG->core->thank_you_page_url(); |
244 | 244 | $this->cancel_page_url = EE_Registry::instance()->CFG->core->cancel_page_url(); |
245 | - $this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', TRUE ); |
|
245 | + $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', TRUE); |
|
246 | 246 | $this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->ajax; |
247 | - $this->reg_cache_where_params = array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
247 | + $this->reg_cache_where_params = array('order_by' => array('REG_count' => 'ASC')); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | * @return array |
255 | 255 | */ |
256 | 256 | public function any_reg_status_updated() { |
257 | - foreach ( $this->reg_status_updated as $reg_status ) { |
|
258 | - if ( $reg_status ) { |
|
257 | + foreach ($this->reg_status_updated as $reg_status) { |
|
258 | + if ($reg_status) { |
|
259 | 259 | return true; |
260 | 260 | } |
261 | 261 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @param $REG_ID |
269 | 269 | * @return array |
270 | 270 | */ |
271 | - public function reg_status_updated( $REG_ID ) { |
|
272 | - return isset( $this->reg_status_updated[ $REG_ID ] ) ? $this->reg_status_updated[ $REG_ID ] : false; |
|
271 | + public function reg_status_updated($REG_ID) { |
|
272 | + return isset($this->reg_status_updated[$REG_ID]) ? $this->reg_status_updated[$REG_ID] : false; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @param $REG_ID |
279 | 279 | * @param $reg_status |
280 | 280 | */ |
281 | - public function set_reg_status_updated( $REG_ID, $reg_status ) { |
|
282 | - $this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN ); |
|
281 | + public function set_reg_status_updated($REG_ID, $reg_status) { |
|
282 | + $this->reg_status_updated[$REG_ID] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * can ONLY be set by the Finalize_Registration reg step |
301 | 301 | */ |
302 | 302 | public function set_exit_spco() { |
303 | - if ( $this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
303 | + if ($this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
304 | 304 | $this->exit_spco = true; |
305 | 305 | } |
306 | 306 | } |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function reset_for_current_request() { |
319 | 319 | $this->process_form_submission = FALSE; |
320 | - $this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', true ); |
|
320 | + $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true); |
|
321 | 321 | $this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->front_ajax; |
322 | 322 | $this->continue_reg = true; |
323 | 323 | $this->redirect = false; |
324 | 324 | // don't reset the cached redirect form if we're about to be asked to display it !!! |
325 | - if ( EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ) !== 'redirect_form' ) { |
|
325 | + if (EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step') !== 'redirect_form') { |
|
326 | 326 | $this->redirect_form = ''; |
327 | 327 | } |
328 | 328 | $this->redirect_url = ''; |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_SPCO_Reg_Step $reg_step_obj |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_reg_step( EE_SPCO_Reg_Step $reg_step_obj ) { |
|
343 | - $this->reg_steps[ $reg_step_obj->slug() ] = $reg_step_obj; |
|
342 | + public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj) { |
|
343 | + $this->reg_steps[$reg_step_obj->slug()] = $reg_step_obj; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -356,22 +356,22 @@ discard block |
||
356 | 356 | * @return void |
357 | 357 | * @throws \EE_Error |
358 | 358 | */ |
359 | - public function skip_reg_step( $reg_step_slug = '' ) { |
|
360 | - $step_to_skip = $this->find_reg_step( $reg_step_slug ); |
|
361 | - if ( $step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step() ) { |
|
362 | - $step_to_skip->set_is_current_step( false ); |
|
359 | + public function skip_reg_step($reg_step_slug = '') { |
|
360 | + $step_to_skip = $this->find_reg_step($reg_step_slug); |
|
361 | + if ($step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step()) { |
|
362 | + $step_to_skip->set_is_current_step(false); |
|
363 | 363 | $step_to_skip->set_completed(); |
364 | 364 | // advance to the next step |
365 | - $this->set_current_step( $this->next_step->slug() ); |
|
365 | + $this->set_current_step($this->next_step->slug()); |
|
366 | 366 | // also reset the step param in the request in case any other code references that directly |
367 | - EE_Registry::instance()->REQ->set( 'step', $this->current_step->slug() ); |
|
367 | + EE_Registry::instance()->REQ->set('step', $this->current_step->slug()); |
|
368 | 368 | // since we are skipping a step and setting the current step to be what was previously the next step, |
369 | 369 | // we need to check that the next step is now correct, and not still set to the current step. |
370 | - if ( $this->current_step->slug() === $this->next_step->slug() ) { |
|
370 | + if ($this->current_step->slug() === $this->next_step->slug()) { |
|
371 | 371 | // correctly setup the next step |
372 | 372 | $this->set_next_step(); |
373 | 373 | } |
374 | - $this->set_reg_step_initiated( $this->current_step ); |
|
374 | + $this->set_reg_step_initiated($this->current_step); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * @param bool $reset whether to reset reg steps after removal |
386 | 386 | * @throws EE_Error |
387 | 387 | */ |
388 | - public function remove_reg_step( $reg_step_slug = '', $reset = true ) { |
|
389 | - unset( $this->reg_steps[ $reg_step_slug ] ); |
|
390 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
388 | + public function remove_reg_step($reg_step_slug = '', $reset = true) { |
|
389 | + unset($this->reg_steps[$reg_step_slug]); |
|
390 | + if ($this->transaction instanceof EE_Transaction) { |
|
391 | 391 | /** @type EE_Transaction_Processor $transaction_processor */ |
392 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
392 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
393 | 393 | // now remove reg step from TXN and save |
394 | - $transaction_processor->remove_reg_step( $this->transaction, $reg_step_slug ); |
|
394 | + $transaction_processor->remove_reg_step($this->transaction, $reg_step_slug); |
|
395 | 395 | $this->transaction->save(); |
396 | 396 | } |
397 | - if ( $reset ) { |
|
397 | + if ($reset) { |
|
398 | 398 | $this->reset_reg_steps(); |
399 | 399 | } |
400 | 400 | } |
@@ -409,9 +409,9 @@ discard block |
||
409 | 409 | * @param int $order |
410 | 410 | * @return void |
411 | 411 | */ |
412 | - public function set_reg_step_order( $reg_step_slug = '', $order = 100 ) { |
|
413 | - if ( isset( $this->reg_steps[ $reg_step_slug ] )) { |
|
414 | - $this->reg_steps[ $reg_step_slug ]->set_order( $order ); |
|
412 | + public function set_reg_step_order($reg_step_slug = '', $order = 100) { |
|
413 | + if (isset($this->reg_steps[$reg_step_slug])) { |
|
414 | + $this->reg_steps[$reg_step_slug]->set_order($order); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
@@ -424,25 +424,25 @@ discard block |
||
424 | 424 | * @param string $current_step |
425 | 425 | * @return void |
426 | 426 | */ |
427 | - public function set_current_step( $current_step ) { |
|
427 | + public function set_current_step($current_step) { |
|
428 | 428 | // grab what step we're on |
429 | - $this->current_step = isset( $this->reg_steps[ $current_step ] ) ? $this->reg_steps[ $current_step ] : reset( $this->reg_steps ); |
|
429 | + $this->current_step = isset($this->reg_steps[$current_step]) ? $this->reg_steps[$current_step] : reset($this->reg_steps); |
|
430 | 430 | // verify instance |
431 | - if ( $this->current_step instanceof EE_SPCO_Reg_Step ) { |
|
431 | + if ($this->current_step instanceof EE_SPCO_Reg_Step) { |
|
432 | 432 | // we don't want to repeat completed steps if this is the first time through SPCO |
433 | - if ( $this->continue_reg && ! $this->revisit && $this->current_step->completed() ) { |
|
433 | + if ($this->continue_reg && ! $this->revisit && $this->current_step->completed()) { |
|
434 | 434 | // so advance to the next step |
435 | 435 | $this->set_next_step(); |
436 | - if ( $this->next_step instanceof EE_SPCO_Reg_Step ) { |
|
436 | + if ($this->next_step instanceof EE_SPCO_Reg_Step) { |
|
437 | 437 | // and attempt to set it as the current step |
438 | - $this->set_current_step( $this->next_step->slug() ); |
|
438 | + $this->set_current_step($this->next_step->slug()); |
|
439 | 439 | } |
440 | 440 | return; |
441 | 441 | } |
442 | - $this->current_step->set_is_current_step( TRUE ); |
|
442 | + $this->current_step->set_is_current_step(TRUE); |
|
443 | 443 | } else { |
444 | 444 | EE_Error::add_error( |
445 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
445 | + __('The current step could not be set.', 'event_espresso'), |
|
446 | 446 | __FILE__, __FUNCTION__, __LINE__ |
447 | 447 | ); |
448 | 448 | } |
@@ -459,20 +459,20 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function set_next_step() { |
461 | 461 | // set pointer to start of array |
462 | - reset( $this->reg_steps ); |
|
462 | + reset($this->reg_steps); |
|
463 | 463 | // if there is more than one step |
464 | - if ( count( $this->reg_steps ) > 1 ) { |
|
464 | + if (count($this->reg_steps) > 1) { |
|
465 | 465 | // advance to the current step and set pointer |
466 | - while ( key( $this->reg_steps ) !== $this->current_step->slug() && key( $this->reg_steps ) !== '' ) { |
|
467 | - next( $this->reg_steps ); |
|
466 | + while (key($this->reg_steps) !== $this->current_step->slug() && key($this->reg_steps) !== '') { |
|
467 | + next($this->reg_steps); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | // advance one more spot ( if it exists ) |
471 | - $this->next_step = next( $this->reg_steps ); |
|
471 | + $this->next_step = next($this->reg_steps); |
|
472 | 472 | // verify instance |
473 | - $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL; |
|
473 | + $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL; |
|
474 | 474 | // then back to current step to reset |
475 | - prev( $this->reg_steps ); |
|
475 | + prev($this->reg_steps); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -486,8 +486,8 @@ discard block |
||
486 | 486 | * @return EE_SPCO_Reg_Step | null |
487 | 487 | */ |
488 | 488 | public function get_next_reg_step() { |
489 | - $next = next( $this->reg_steps ); |
|
490 | - prev( $this->reg_steps ); |
|
489 | + $next = next($this->reg_steps); |
|
490 | + prev($this->reg_steps); |
|
491 | 491 | return $next instanceof EE_SPCO_Reg_Step ? $next : null; |
492 | 492 | } |
493 | 493 | |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | * @return EE_SPCO_Reg_Step | null |
503 | 503 | */ |
504 | 504 | public function get_prev_reg_step() { |
505 | - $prev = prev( $this->reg_steps ); |
|
506 | - next( $this->reg_steps ); |
|
505 | + $prev = prev($this->reg_steps); |
|
506 | + next($this->reg_steps); |
|
507 | 507 | return $prev instanceof EE_SPCO_Reg_Step ? $prev : null; |
508 | 508 | } |
509 | 509 | |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | * @return void |
517 | 517 | */ |
518 | 518 | public function sort_reg_steps() { |
519 | - $reg_step_sorting_callback = apply_filters( 'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback' ); |
|
520 | - uasort( $this->reg_steps, array( $this, $reg_step_sorting_callback )); |
|
519 | + $reg_step_sorting_callback = apply_filters('FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback'); |
|
520 | + uasort($this->reg_steps, array($this, $reg_step_sorting_callback)); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -530,19 +530,19 @@ discard block |
||
530 | 530 | * @param string $reg_step_slug |
531 | 531 | * @return EE_SPCO_Reg_Step|null |
532 | 532 | */ |
533 | - public function find_reg_step( $reg_step_slug = '' ) { |
|
534 | - if ( ! empty( $reg_step_slug ) ) { |
|
533 | + public function find_reg_step($reg_step_slug = '') { |
|
534 | + if ( ! empty($reg_step_slug)) { |
|
535 | 535 | // copy reg step array |
536 | 536 | $reg_steps = $this->reg_steps; |
537 | 537 | // set pointer to start of array |
538 | - reset( $reg_steps ); |
|
538 | + reset($reg_steps); |
|
539 | 539 | // if there is more than one step |
540 | - if ( count( $reg_steps ) > 1 ) { |
|
540 | + if (count($reg_steps) > 1) { |
|
541 | 541 | // advance to the current step and set pointer |
542 | - while ( key( $reg_steps ) !== $reg_step_slug && key( $reg_steps ) !== '' ) { |
|
543 | - next( $reg_steps ); |
|
542 | + while (key($reg_steps) !== $reg_step_slug && key($reg_steps) !== '') { |
|
543 | + next($reg_steps); |
|
544 | 544 | } |
545 | - return current( $reg_steps ); |
|
545 | + return current($reg_steps); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | return null; |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | * @param EE_SPCO_Reg_Step $reg_step_B |
559 | 559 | * @return array() |
560 | 560 | */ |
561 | - public function reg_step_sorting_callback( EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B ) { |
|
561 | + public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B) { |
|
562 | 562 | // send finalize_registration step to the end of the array |
563 | - if ( $reg_step_A->slug() === 'finalize_registration' ) { |
|
563 | + if ($reg_step_A->slug() === 'finalize_registration') { |
|
564 | 564 | return 1; |
565 | - } else if ( $reg_step_B->slug() === 'finalize_registration' ) { |
|
565 | + } else if ($reg_step_B->slug() === 'finalize_registration') { |
|
566 | 566 | return -1; |
567 | 567 | } |
568 | - if ( $reg_step_A->order() === $reg_step_B->order() ) { |
|
568 | + if ($reg_step_A->order() === $reg_step_B->order()) { |
|
569 | 569 | return 0; |
570 | 570 | } |
571 | - return ( $reg_step_A->order() > $reg_step_B->order() ) ? 1 : -1; |
|
571 | + return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1; |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * @param EE_SPCO_Reg_Step $reg_step |
581 | 581 | * @throws \EE_Error |
582 | 582 | */ |
583 | - public function set_reg_step_initiated( EE_SPCO_Reg_Step $reg_step ) { |
|
583 | + public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step) { |
|
584 | 584 | // call set_reg_step_initiated ??? |
585 | 585 | if ( |
586 | 586 | // first time visiting SPCO ? |
@@ -593,13 +593,13 @@ discard block |
||
593 | 593 | ) |
594 | 594 | ) { |
595 | 595 | /** @type EE_Transaction_Processor $transaction_processor */ |
596 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
596 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
597 | 597 | // set the start time for this reg step |
598 | - if ( ! $transaction_processor->set_reg_step_initiated( $this->transaction, $reg_step->slug() ) ) { |
|
599 | - if ( WP_DEBUG ) { |
|
598 | + if ( ! $transaction_processor->set_reg_step_initiated($this->transaction, $reg_step->slug())) { |
|
599 | + if (WP_DEBUG) { |
|
600 | 600 | EE_Error::add_error( |
601 | 601 | sprintf( |
602 | - __( 'The "%1$s" registration step was not initialized properly.', 'event_espresso' ), |
|
602 | + __('The "%1$s" registration step was not initialized properly.', 'event_espresso'), |
|
603 | 603 | $reg_step->name() |
604 | 604 | ), |
605 | 605 | __FILE__, __FUNCTION__, __LINE__ |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | * @return void |
619 | 619 | */ |
620 | 620 | public function set_reg_step_JSON_info() { |
621 | - EE_Registry::$i18n_js_strings[ 'reg_steps' ] = array(); |
|
621 | + EE_Registry::$i18n_js_strings['reg_steps'] = array(); |
|
622 | 622 | // pass basic reg step data to JS |
623 | - foreach ( $this->reg_steps as $reg_step ) { |
|
624 | - EE_Registry::$i18n_js_strings[ 'reg_steps' ][] = $reg_step->slug(); |
|
623 | + foreach ($this->reg_steps as $reg_step) { |
|
624 | + EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug(); |
|
625 | 625 | } |
626 | 626 | // reset reg step html |
627 | 627 | // $this->json_response->set_reg_step_html( '' ); |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | */ |
638 | 638 | public function reset_reg_steps() { |
639 | 639 | $this->sort_reg_steps(); |
640 | - $this->set_current_step( EE_Registry::instance()->REQ->get( 'step' )); |
|
640 | + $this->set_current_step(EE_Registry::instance()->REQ->get('step')); |
|
641 | 641 | $this->set_next_step(); |
642 | 642 | // the text that appears on the reg step form submit button |
643 | 643 | $this->current_step->set_submit_button_text(); |
@@ -654,9 +654,9 @@ discard block |
||
654 | 654 | */ |
655 | 655 | public function get_registration_time_limit() { |
656 | 656 | |
657 | - $registration_time_limit = (float)( EE_Registry::instance() ->SSN->expiration() - time() ); |
|
657 | + $registration_time_limit = (float) (EE_Registry::instance() ->SSN->expiration() - time()); |
|
658 | 658 | $time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s'; |
659 | - $registration_time_limit = gmdate( $time_limit_format, $registration_time_limit ); |
|
659 | + $registration_time_limit = gmdate($time_limit_format, $registration_time_limit); |
|
660 | 660 | return apply_filters( |
661 | 661 | 'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit', |
662 | 662 | $registration_time_limit |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | // overpaid TXN |
677 | 677 | // free TXN ( total = 0.00 ) |
678 | 678 | // then payment required is TRUE |
679 | - return ! ( $this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free() ) ? TRUE : FALSE; |
|
679 | + return ! ($this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free()) ? TRUE : FALSE; |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | |
@@ -688,12 +688,12 @@ discard block |
||
688 | 688 | * @param EE_Transaction $transaction |
689 | 689 | * @return EE_Cart |
690 | 690 | */ |
691 | - public function get_cart_for_transaction( $transaction ) { |
|
692 | - $session = EE_Registry::instance()->load_core( 'Session' ); |
|
693 | - $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn( $transaction, $session ) : null; |
|
691 | + public function get_cart_for_transaction($transaction) { |
|
692 | + $session = EE_Registry::instance()->load_core('Session'); |
|
693 | + $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null; |
|
694 | 694 | // verify cart |
695 | - if ( ! $cart instanceof EE_Cart ) { |
|
696 | - $cart = EE_Registry::instance()->load_core( 'Cart' ); |
|
695 | + if ( ! $cart instanceof EE_Cart) { |
|
696 | + $cart = EE_Registry::instance()->load_core('Cart'); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | return $cart; |
@@ -709,8 +709,8 @@ discard block |
||
709 | 709 | */ |
710 | 710 | public function initialize_txn_reg_steps_array() { |
711 | 711 | $txn_reg_steps_array = array(); |
712 | - foreach ( $this->reg_steps as $reg_step ) { |
|
713 | - $txn_reg_steps_array[ $reg_step->slug() ] = FALSE; |
|
712 | + foreach ($this->reg_steps as $reg_step) { |
|
713 | + $txn_reg_steps_array[$reg_step->slug()] = FALSE; |
|
714 | 714 | } |
715 | 715 | return $txn_reg_steps_array; |
716 | 716 | } |
@@ -727,15 +727,15 @@ discard block |
||
727 | 727 | public function update_txn_reg_steps_array() { |
728 | 728 | $updated = false; |
729 | 729 | /** @type EE_Transaction_Processor $transaction_processor */ |
730 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
731 | - foreach ( $this->reg_steps as $reg_step ) { |
|
732 | - if ( $reg_step->completed() ) { |
|
733 | - $updated = $transaction_processor->set_reg_step_completed( $this->transaction, $reg_step->slug() ) |
|
730 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
731 | + foreach ($this->reg_steps as $reg_step) { |
|
732 | + if ($reg_step->completed()) { |
|
733 | + $updated = $transaction_processor->set_reg_step_completed($this->transaction, $reg_step->slug()) |
|
734 | 734 | ? true |
735 | 735 | : $updated; |
736 | 736 | } |
737 | 737 | } |
738 | - if ( $updated ) { |
|
738 | + if ($updated) { |
|
739 | 739 | $this->transaction->save(); |
740 | 740 | } |
741 | 741 | return $updated; |
@@ -751,14 +751,14 @@ discard block |
||
751 | 751 | * @throws \EE_Error |
752 | 752 | */ |
753 | 753 | public function stash_transaction_and_checkout() { |
754 | - if ( ! $this->revisit ) { |
|
754 | + if ( ! $this->revisit) { |
|
755 | 755 | $this->update_txn_reg_steps_array(); |
756 | 756 | } |
757 | 757 | $this->track_transaction_and_registration_status_updates(); |
758 | 758 | // save all data to the db, but suppress errors |
759 | 759 | //$this->save_all_data( FALSE ); |
760 | 760 | // cache the checkout in the session |
761 | - EE_Registry::instance()->SSN->set_checkout( $this ); |
|
761 | + EE_Registry::instance()->SSN->set_checkout($this); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | |
@@ -773,21 +773,21 @@ discard block |
||
773 | 773 | */ |
774 | 774 | public function track_transaction_and_registration_status_updates() { |
775 | 775 | // verify the transaction |
776 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
776 | + if ($this->transaction instanceof EE_Transaction) { |
|
777 | 777 | /** @type EE_Transaction_Payments $transaction_payments */ |
778 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
778 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
779 | 779 | /** @type EE_Transaction_Processor $transaction_processor */ |
780 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
780 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
781 | 781 | // has there been a TXN status change during this checkout? |
782 | - if ( $transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated() ) { |
|
782 | + if ($transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated()) { |
|
783 | 783 | $this->txn_status_updated = true; |
784 | 784 | } |
785 | 785 | /** @type EE_Registration_Processor $registration_processor */ |
786 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
786 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
787 | 787 | // grab the saved registrations from the transaction |
788 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) { |
|
789 | - if ( $registration_processor->reg_status_updated( $registration->ID() ) ) { |
|
790 | - $this->set_reg_status_updated( $registration->ID(), true ); |
|
788 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) { |
|
789 | + if ($registration_processor->reg_status_updated($registration->ID())) { |
|
790 | + $this->set_reg_status_updated($registration->ID(), true); |
|
791 | 791 | } |
792 | 792 | } |
793 | 793 | } |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | * @return bool |
809 | 809 | * @throws \EE_Error |
810 | 810 | */ |
811 | - public function visit_allows_processing_of_this_registration( EE_Registration $registration ) { |
|
811 | + public function visit_allows_processing_of_this_registration(EE_Registration $registration) { |
|
812 | 812 | return ! $this->revisit |
813 | 813 | || $this->primary_revisit |
814 | 814 | || ( |
@@ -841,18 +841,18 @@ discard block |
||
841 | 841 | * @return bool |
842 | 842 | * @throws \EE_Error |
843 | 843 | */ |
844 | - public function save_all_data( $show_errors = TRUE ) { |
|
844 | + public function save_all_data($show_errors = TRUE) { |
|
845 | 845 | // verify the transaction |
846 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
846 | + if ($this->transaction instanceof EE_Transaction) { |
|
847 | 847 | // save to ensure that TXN has ID |
848 | 848 | $this->transaction->save(); |
849 | 849 | // grab the saved registrations from the transaction |
850 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) { |
|
851 | - $this->_save_registration( $registration, $show_errors ); |
|
850 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) { |
|
851 | + $this->_save_registration($registration, $show_errors); |
|
852 | 852 | } |
853 | 853 | } else { |
854 | - if ( $show_errors ) { |
|
855 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to save your registration information.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
854 | + if ($show_errors) { |
|
855 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
856 | 856 | } |
857 | 857 | return FALSE; |
858 | 858 | } |
@@ -869,32 +869,32 @@ discard block |
||
869 | 869 | * @return void |
870 | 870 | * @throws \EE_Error |
871 | 871 | */ |
872 | - private function _save_registration( $registration, $show_errors = TRUE ) { |
|
872 | + private function _save_registration($registration, $show_errors = TRUE) { |
|
873 | 873 | // verify object |
874 | - if ( $registration instanceof EE_Registration ) { |
|
874 | + if ($registration instanceof EE_Registration) { |
|
875 | 875 | // should this registration be processed during this visit ? |
876 | - if ( $this->visit_allows_processing_of_this_registration( $registration ) ) { |
|
876 | + if ($this->visit_allows_processing_of_this_registration($registration)) { |
|
877 | 877 | //set TXN ID |
878 | - if ( ! $registration->transaction_ID() ) { |
|
879 | - $registration->set_transaction_id( $this->transaction->ID() ); |
|
878 | + if ( ! $registration->transaction_ID()) { |
|
879 | + $registration->set_transaction_id($this->transaction->ID()); |
|
880 | 880 | } |
881 | 881 | // verify and save the attendee |
882 | - $this->_save_registration_attendee( $registration, $show_errors ); |
|
882 | + $this->_save_registration_attendee($registration, $show_errors); |
|
883 | 883 | // save answers to reg form questions |
884 | - $this->_save_registration_answers( $registration, $show_errors ); |
|
884 | + $this->_save_registration_answers($registration, $show_errors); |
|
885 | 885 | // save changes |
886 | 886 | $registration->save(); |
887 | 887 | // update txn cache |
888 | - if ( ! $this->transaction->update_cache_after_object_save( 'Registration', $registration )) { |
|
889 | - if ( $show_errors ) { |
|
890 | - EE_Error::add_error( __( 'The newly saved Registration object could not be cached on the Transaction.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
888 | + if ( ! $this->transaction->update_cache_after_object_save('Registration', $registration)) { |
|
889 | + if ($show_errors) { |
|
890 | + EE_Error::add_error(__('The newly saved Registration object could not be cached on the Transaction.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
891 | 891 | } |
892 | 892 | } |
893 | 893 | } |
894 | 894 | } else { |
895 | - if ( $show_errors ) { |
|
895 | + if ($show_errors) { |
|
896 | 896 | EE_Error::add_error( |
897 | - __( 'An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
897 | + __('An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
898 | 898 | __FILE__, __FUNCTION__, __LINE__ |
899 | 899 | ); |
900 | 900 | } |
@@ -911,25 +911,25 @@ discard block |
||
911 | 911 | * @return void |
912 | 912 | * @throws \EE_Error |
913 | 913 | */ |
914 | - private function _save_registration_attendee( $registration, $show_errors = TRUE ) { |
|
915 | - if ( $registration->attendee() instanceof EE_Attendee ) { |
|
914 | + private function _save_registration_attendee($registration, $show_errors = TRUE) { |
|
915 | + if ($registration->attendee() instanceof EE_Attendee) { |
|
916 | 916 | // save so that ATT has ID |
917 | 917 | $registration->attendee()->save(); |
918 | - if ( ! $registration->update_cache_after_object_save( 'Attendee', $registration->attendee() ) ) { |
|
919 | - if ( $show_errors ) { |
|
918 | + if ( ! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) { |
|
919 | + if ($show_errors) { |
|
920 | 920 | EE_Error::add_error( |
921 | - __( 'The newly saved Attendee object could not be cached on the registration.', 'event_espresso' ), |
|
921 | + __('The newly saved Attendee object could not be cached on the registration.', 'event_espresso'), |
|
922 | 922 | __FILE__, __FUNCTION__, __LINE__ |
923 | 923 | ); |
924 | 924 | } |
925 | 925 | } |
926 | 926 | } else { |
927 | - if ( $show_errors ) { |
|
927 | + if ($show_errors) { |
|
928 | 928 | EE_Error::add_error( |
929 | 929 | sprintf( |
930 | 930 | '%1$s||%1$s $attendee = %2$s', |
931 | - __( 'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
932 | - var_export( $registration->attendee(), true ) |
|
931 | + __('Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
932 | + var_export($registration->attendee(), true) |
|
933 | 933 | ), |
934 | 934 | __FILE__, __FUNCTION__, __LINE__ |
935 | 935 | ); |
@@ -947,25 +947,25 @@ discard block |
||
947 | 947 | * @return void |
948 | 948 | * @throws \EE_Error |
949 | 949 | */ |
950 | - private function _save_registration_answers( $registration, $show_errors = TRUE ) { |
|
950 | + private function _save_registration_answers($registration, $show_errors = TRUE) { |
|
951 | 951 | // now save the answers |
952 | - foreach ( $registration->answers() as $cache_key => $answer ) { |
|
952 | + foreach ($registration->answers() as $cache_key => $answer) { |
|
953 | 953 | // verify object |
954 | - if ( $answer instanceof EE_Answer ) { |
|
955 | - $answer->set_registration( $registration->ID() ); |
|
954 | + if ($answer instanceof EE_Answer) { |
|
955 | + $answer->set_registration($registration->ID()); |
|
956 | 956 | $answer->save(); |
957 | - if ( ! $registration->update_cache_after_object_save( 'Answer', $answer, $cache_key )) { |
|
958 | - if ( $show_errors ) { |
|
957 | + if ( ! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) { |
|
958 | + if ($show_errors) { |
|
959 | 959 | EE_Error::add_error( |
960 | - __( 'The newly saved Answer object could not be cached on the registration.', 'event_espresso' ), |
|
960 | + __('The newly saved Answer object could not be cached on the registration.', 'event_espresso'), |
|
961 | 961 | __FILE__, __FUNCTION__, __LINE__ |
962 | 962 | ); |
963 | 963 | } |
964 | 964 | } |
965 | 965 | } else { |
966 | - if ( $show_errors ) { |
|
966 | + if ($show_errors) { |
|
967 | 967 | EE_Error::add_error( |
968 | - __( 'An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
968 | + __('An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
969 | 969 | __FILE__, __FUNCTION__, __LINE__ |
970 | 970 | ); |
971 | 971 | } |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | * @return bool |
985 | 985 | * @throws \EE_Error |
986 | 986 | */ |
987 | - public function refresh_all_entities( $from_db = false ) { |
|
987 | + public function refresh_all_entities($from_db = false) { |
|
988 | 988 | $from_db = $this->current_step->is_final_step() || $this->action === 'process_gateway_response' |
989 | 989 | ? true |
990 | 990 | : $from_db; |
@@ -1008,11 +1008,11 @@ discard block |
||
1008 | 1008 | */ |
1009 | 1009 | protected function refresh_from_db() { |
1010 | 1010 | // verify the transaction |
1011 | - if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) { |
|
1011 | + if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { |
|
1012 | 1012 | // pull fresh TXN data from the db |
1013 | - $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db( $this->transaction->ID() ); |
|
1013 | + $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID()); |
|
1014 | 1014 | // update EE_Checkout's cached primary_attendee object |
1015 | - $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db( $this->transaction ); |
|
1015 | + $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction); |
|
1016 | 1016 | // update EE_Checkout's cached payment object |
1017 | 1017 | $payment = $this->transaction->last_payment(); |
1018 | 1018 | $this->payment = $payment instanceof EE_Payment ? $payment : $this->payment; |
@@ -1020,9 +1020,9 @@ discard block |
||
1020 | 1020 | $payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null; |
1021 | 1021 | $this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method : $this->payment_method; |
1022 | 1022 | //now refresh the cart, based on the TXN |
1023 | - $this->cart = $this->get_cart_for_transaction( $this->transaction ); |
|
1023 | + $this->cart = $this->get_cart_for_transaction($this->transaction); |
|
1024 | 1024 | } else { |
1025 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
1025 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1026 | 1026 | return FALSE; |
1027 | 1027 | } |
1028 | 1028 | return TRUE; |
@@ -1037,21 +1037,21 @@ discard block |
||
1037 | 1037 | * @return EE_Attendee | null |
1038 | 1038 | * @throws \EE_Error |
1039 | 1039 | */ |
1040 | - protected function _refresh_primary_attendee_obj_from_db( EE_Transaction $transaction ) { |
|
1040 | + protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction) { |
|
1041 | 1041 | |
1042 | 1042 | $primary_attendee_obj = null; |
1043 | 1043 | // grab the saved registrations from the transaction |
1044 | - foreach ( $transaction->registrations( $this->reg_cache_where_params, true ) as $registration ) { |
|
1044 | + foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) { |
|
1045 | 1045 | // verify object |
1046 | - if ( $registration instanceof EE_Registration ) { |
|
1046 | + if ($registration instanceof EE_Registration) { |
|
1047 | 1047 | $attendee = $registration->attendee(); |
1048 | 1048 | // verify object && maybe cache primary_attendee_obj ? |
1049 | - if ( $attendee instanceof EE_Attendee&& $registration->is_primary_registrant() ) { |
|
1049 | + if ($attendee instanceof EE_Attendee && $registration->is_primary_registrant()) { |
|
1050 | 1050 | $primary_attendee_obj = $attendee; |
1051 | 1051 | } |
1052 | 1052 | } else { |
1053 | 1053 | EE_Error::add_error( |
1054 | - __( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1054 | + __('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1055 | 1055 | __FILE__, __FUNCTION__, __LINE__ |
1056 | 1056 | ); |
1057 | 1057 | } |
@@ -1072,45 +1072,45 @@ discard block |
||
1072 | 1072 | */ |
1073 | 1073 | protected function refresh_entity_map() { |
1074 | 1074 | // verify the transaction |
1075 | - if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) { |
|
1075 | + if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { |
|
1076 | 1076 | // never cache payment info |
1077 | - $this->transaction->clear_cache( 'Payment' ); |
|
1077 | + $this->transaction->clear_cache('Payment'); |
|
1078 | 1078 | /** @type EE_Transaction_Processor $transaction_processor */ |
1079 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1079 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1080 | 1080 | // is the Payment Options Reg Step completed ? |
1081 | - if ( $transaction_processor->reg_step_completed( $this->transaction, 'payment_options' ) ) { |
|
1081 | + if ($transaction_processor->reg_step_completed($this->transaction, 'payment_options')) { |
|
1082 | 1082 | // then check for payments and update TXN accordingly |
1083 | 1083 | /** @type EE_Transaction_Payments $transaction_payments */ |
1084 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1085 | - $transaction_payments->calculate_total_payments_and_update_status( $this->transaction ); |
|
1084 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1085 | + $transaction_payments->calculate_total_payments_and_update_status($this->transaction); |
|
1086 | 1086 | } |
1087 | 1087 | // grab the saved registrations from the transaction |
1088 | 1088 | foreach ( |
1089 | - $this->transaction->registrations( $this->reg_cache_where_params ) as $reg_cache_ID => $registration |
|
1089 | + $this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration |
|
1090 | 1090 | ) { |
1091 | - $this->_refresh_registration( $reg_cache_ID, $registration ); |
|
1091 | + $this->_refresh_registration($reg_cache_ID, $registration); |
|
1092 | 1092 | } |
1093 | 1093 | // make sure our cached TXN is added to the model entity mapper |
1094 | - $this->transaction = $this->transaction->get_model()->refresh_entity_map_with( $this->transaction->ID(), $this->transaction ); |
|
1094 | + $this->transaction = $this->transaction->get_model()->refresh_entity_map_with($this->transaction->ID(), $this->transaction); |
|
1095 | 1095 | |
1096 | 1096 | } else { |
1097 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
1097 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1098 | 1098 | return FALSE; |
1099 | 1099 | } |
1100 | 1100 | // verify and update the cart because inaccurate totals are not so much fun |
1101 | - if ( $this->cart instanceof EE_Cart ) { |
|
1101 | + if ($this->cart instanceof EE_Cart) { |
|
1102 | 1102 | $grand_total = $this->cart->get_grand_total(); |
1103 | - if ( $grand_total instanceof EE_Line_Item && $grand_total->ID() ) { |
|
1103 | + if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) { |
|
1104 | 1104 | $grand_total->recalculate_total_including_taxes(); |
1105 | 1105 | $grand_total = $grand_total->get_model()->refresh_entity_map_with( |
1106 | 1106 | $this->cart->get_grand_total()->ID(), |
1107 | 1107 | $this->cart->get_grand_total() |
1108 | 1108 | ); |
1109 | 1109 | } |
1110 | - if ( $grand_total instanceof EE_Line_Item ) { |
|
1111 | - $this->cart = EE_Cart::instance( $grand_total ); |
|
1110 | + if ($grand_total instanceof EE_Line_Item) { |
|
1111 | + $this->cart = EE_Cart::instance($grand_total); |
|
1112 | 1112 | } else { |
1113 | - EE_Error::add_error( __( 'A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1113 | + EE_Error::add_error(__('A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1114 | 1114 | return false; |
1115 | 1115 | } |
1116 | 1116 | } |
@@ -1127,19 +1127,19 @@ discard block |
||
1127 | 1127 | * @return void |
1128 | 1128 | * @throws \EE_Error |
1129 | 1129 | */ |
1130 | - protected function _refresh_registration( $reg_cache_ID, $registration ) { |
|
1130 | + protected function _refresh_registration($reg_cache_ID, $registration) { |
|
1131 | 1131 | |
1132 | 1132 | // verify object |
1133 | - if ( $registration instanceof EE_Registration ) { |
|
1133 | + if ($registration instanceof EE_Registration) { |
|
1134 | 1134 | // update the entity mapper attendee |
1135 | - $this->_refresh_registration_attendee( $registration ); |
|
1135 | + $this->_refresh_registration_attendee($registration); |
|
1136 | 1136 | // update the entity mapper answers for reg form questions |
1137 | - $this->_refresh_registration_answers( $registration ); |
|
1137 | + $this->_refresh_registration_answers($registration); |
|
1138 | 1138 | // make sure the cached registration is added to the model entity mapper |
1139 | - $registration->get_model()->refresh_entity_map_with( $reg_cache_ID, $registration ); |
|
1139 | + $registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration); |
|
1140 | 1140 | } else { |
1141 | 1141 | EE_Error::add_error( |
1142 | - __( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1142 | + __('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1143 | 1143 | __FILE__, __FUNCTION__, __LINE__ |
1144 | 1144 | ); |
1145 | 1145 | } |
@@ -1154,15 +1154,15 @@ discard block |
||
1154 | 1154 | * @return void |
1155 | 1155 | * @throws \EE_Error |
1156 | 1156 | */ |
1157 | - protected function _refresh_registration_attendee( $registration ) { |
|
1157 | + protected function _refresh_registration_attendee($registration) { |
|
1158 | 1158 | |
1159 | 1159 | $attendee = $registration->attendee(); |
1160 | 1160 | // verify object |
1161 | - if ( $attendee instanceof EE_Attendee && $attendee->ID() ) { |
|
1161 | + if ($attendee instanceof EE_Attendee && $attendee->ID()) { |
|
1162 | 1162 | // make sure the cached attendee is added to the model entity mapper |
1163 | - $registration->attendee()->get_model()->refresh_entity_map_with( $attendee->ID(), $attendee ); |
|
1163 | + $registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee); |
|
1164 | 1164 | // maybe cache primary_attendee_obj ? |
1165 | - if ( $registration->is_primary_registrant() ) { |
|
1165 | + if ($registration->is_primary_registrant()) { |
|
1166 | 1166 | $this->primary_attendee_obj = $attendee; |
1167 | 1167 | } |
1168 | 1168 | } |
@@ -1177,19 +1177,19 @@ discard block |
||
1177 | 1177 | * @return void |
1178 | 1178 | * @throws \EE_Error |
1179 | 1179 | */ |
1180 | - protected function _refresh_registration_answers( $registration ) { |
|
1180 | + protected function _refresh_registration_answers($registration) { |
|
1181 | 1181 | |
1182 | 1182 | // now update the answers |
1183 | - foreach ( $registration->answers() as $cache_key => $answer ) { |
|
1183 | + foreach ($registration->answers() as $cache_key => $answer) { |
|
1184 | 1184 | // verify object |
1185 | - if ( $answer instanceof EE_Answer ) { |
|
1186 | - if ( $answer->ID() ) { |
|
1185 | + if ($answer instanceof EE_Answer) { |
|
1186 | + if ($answer->ID()) { |
|
1187 | 1187 | // make sure the cached answer is added to the model entity mapper |
1188 | - $answer->get_model()->refresh_entity_map_with( $answer->ID(), $answer ); |
|
1188 | + $answer->get_model()->refresh_entity_map_with($answer->ID(), $answer); |
|
1189 | 1189 | } |
1190 | 1190 | } else { |
1191 | 1191 | EE_Error::add_error( |
1192 | - __( 'An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1192 | + __('An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1193 | 1193 | __FILE__, __FUNCTION__, __LINE__ |
1194 | 1194 | ); |
1195 | 1195 | } |
@@ -1204,7 +1204,7 @@ discard block |
||
1204 | 1204 | * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object |
1205 | 1205 | */ |
1206 | 1206 | public function __wakeup() { |
1207 | - foreach ( $this->reg_steps as $reg_step ) { |
|
1207 | + foreach ($this->reg_steps as $reg_step) { |
|
1208 | 1208 | $reg_step->checkout = $this; |
1209 | 1209 | } |
1210 | 1210 | } |
@@ -1221,12 +1221,12 @@ discard block |
||
1221 | 1221 | * @param bool $display_request |
1222 | 1222 | * @throws \EE_Error |
1223 | 1223 | */ |
1224 | - public function log( $class = '', $func = '', $line = '', $info = array(), $display_request = false ) { |
|
1224 | + public function log($class = '', $func = '', $line = '', $info = array(), $display_request = false) { |
|
1225 | 1225 | $disabled = true; |
1226 | - if ( WP_DEBUG && ! $disabled ) { |
|
1227 | - $debug_data = get_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array() ); |
|
1226 | + if (WP_DEBUG && ! $disabled) { |
|
1227 | + $debug_data = get_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), array()); |
|
1228 | 1228 | $default_data = array( |
1229 | - $class => $func . '() : ' . $line, |
|
1229 | + $class => $func.'() : '.$line, |
|
1230 | 1230 | 'request->step' => $this->step, |
1231 | 1231 | 'request->action' => $this->action, |
1232 | 1232 | 'current_step->slug' => $this->current_step instanceof EE_SPCO_Reg_Step ? |
@@ -1238,24 +1238,24 @@ discard block |
||
1238 | 1238 | 'reg_url_link' => $this->reg_url_link, |
1239 | 1239 | 'REQ' => $display_request ? $_REQUEST : '', |
1240 | 1240 | ); |
1241 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
1242 | - $default_data[ 'TXN_status' ] = $this->transaction->status_ID(); |
|
1243 | - $default_data[ 'TXN_reg_steps' ] = $this->transaction->reg_steps(); |
|
1244 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $REG_ID => $registration ) { |
|
1245 | - $default_data[ 'registrations' ][ $REG_ID ] = $registration->status_ID(); |
|
1241 | + if ($this->transaction instanceof EE_Transaction) { |
|
1242 | + $default_data['TXN_status'] = $this->transaction->status_ID(); |
|
1243 | + $default_data['TXN_reg_steps'] = $this->transaction->reg_steps(); |
|
1244 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) { |
|
1245 | + $default_data['registrations'][$REG_ID] = $registration->status_ID(); |
|
1246 | 1246 | } |
1247 | - if ( $this->transaction->ID() ) { |
|
1248 | - $TXN_ID = 'EE_Transaction: ' . $this->transaction->ID(); |
|
1247 | + if ($this->transaction->ID()) { |
|
1248 | + $TXN_ID = 'EE_Transaction: '.$this->transaction->ID(); |
|
1249 | 1249 | // don't serialize objects |
1250 | - $info = $this->_strip_objects( $info ); |
|
1251 | - if ( ! isset( $debug_data[ $TXN_ID ] ) ) { |
|
1252 | - $debug_data[ $TXN_ID ] = array(); |
|
1250 | + $info = $this->_strip_objects($info); |
|
1251 | + if ( ! isset($debug_data[$TXN_ID])) { |
|
1252 | + $debug_data[$TXN_ID] = array(); |
|
1253 | 1253 | } |
1254 | - $debug_data[ $TXN_ID ][ microtime() ] = array_merge( |
|
1254 | + $debug_data[$TXN_ID][microtime()] = array_merge( |
|
1255 | 1255 | $default_data, |
1256 | 1256 | $info |
1257 | 1257 | ); |
1258 | - update_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data ); |
|
1258 | + update_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), $debug_data); |
|
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | } |
@@ -1268,23 +1268,23 @@ discard block |
||
1268 | 1268 | * @param array $info |
1269 | 1269 | * @return array |
1270 | 1270 | */ |
1271 | - public function _strip_objects( $info = array() ) { |
|
1272 | - foreach ( (array)$info as $key => $value ) { |
|
1273 | - if ( is_array( $value )) { |
|
1274 | - $info[ $key ] = $this->_strip_objects( $value ); |
|
1275 | - } else if ( is_object( $value ) ) { |
|
1276 | - $object_class = get_class( $value ); |
|
1277 | - $info[ $object_class ] = array(); |
|
1278 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : 0; |
|
1279 | - if ( method_exists( $value, 'status' ) ) { |
|
1280 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
1281 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
1282 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
1271 | + public function _strip_objects($info = array()) { |
|
1272 | + foreach ((array) $info as $key => $value) { |
|
1273 | + if (is_array($value)) { |
|
1274 | + $info[$key] = $this->_strip_objects($value); |
|
1275 | + } else if (is_object($value)) { |
|
1276 | + $object_class = get_class($value); |
|
1277 | + $info[$object_class] = array(); |
|
1278 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0; |
|
1279 | + if (method_exists($value, 'status')) { |
|
1280 | + $info[$object_class]['status'] = $value->status(); |
|
1281 | + } else if (method_exists($value, 'status_ID')) { |
|
1282 | + $info[$object_class]['status'] = $value->status_ID(); |
|
1283 | 1283 | } |
1284 | - unset( $info[ $key ] ); |
|
1284 | + unset($info[$key]); |
|
1285 | 1285 | } |
1286 | 1286 | } |
1287 | - return (array)$info; |
|
1287 | + return (array) $info; |
|
1288 | 1288 | } |
1289 | 1289 | |
1290 | 1290 |
@@ -310,23 +310,23 @@ discard block |
||
310 | 310 | * @param float $amount |
311 | 311 | * @param string $name |
312 | 312 | * @param string $description |
313 | - * @param string $code |
|
314 | - * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
315 | - * the same code is found, $amount will be added onto it; otherwise will simply |
|
316 | - * set the taxes to match $amount |
|
313 | + * @param string $code |
|
314 | + * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
315 | + * the same code is found, $amount will be added onto it; otherwise will simply |
|
316 | + * set the taxes to match $amount |
|
317 | 317 | * @return EE_Line_Item the new tax created |
318 | 318 | */ |
319 | 319 | public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
320 | 320 | |
321 | - /** |
|
322 | - * Makes all the line items which are children of $line_item taxable (or not). |
|
323 | - * Does NOT save the line items |
|
324 | - * @param EE_Line_Item $line_item |
|
325 | - * @param boolean $taxable |
|
326 | - * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
327 | - * it will be whitelisted (ie, except from becoming taxable) |
|
328 | - */ |
|
329 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
321 | + /** |
|
322 | + * Makes all the line items which are children of $line_item taxable (or not). |
|
323 | + * Does NOT save the line items |
|
324 | + * @param EE_Line_Item $line_item |
|
325 | + * @param boolean $taxable |
|
326 | + * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
327 | + * it will be whitelisted (ie, except from becoming taxable) |
|
328 | + */ |
|
329 | + public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -356,15 +356,15 @@ discard block |
||
356 | 356 | */ |
357 | 357 | interface EEHI_Money{ |
358 | 358 | /** |
359 | - * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
360 | - * This should be used to compare floats instead of normal '==' because floats |
|
361 | - * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
362 | - * but actually differ by 0.00000001. |
|
363 | - * @param float $float1 |
|
364 | - * @param float $float2 |
|
365 | - * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
366 | - * @return boolean whether the equation is true or false |
|
367 | - */ |
|
359 | + * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
360 | + * This should be used to compare floats instead of normal '==' because floats |
|
361 | + * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
362 | + * but actually differ by 0.00000001. |
|
363 | + * @param float $float1 |
|
364 | + * @param float $float2 |
|
365 | + * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
366 | + * @return boolean whether the equation is true or false |
|
367 | + */ |
|
368 | 368 | public function compare_floats( $float1, $float2, $operator='=' ); |
369 | 369 | } |
370 | 370 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | /** |
6 | 6 | * Interface EEI_Base |
7 | 7 | */ |
8 | -interface EEI_Base{ |
|
8 | +interface EEI_Base { |
|
9 | 9 | /** |
10 | 10 | * gets the unique ID of the model object. If it hasn't been saved yet |
11 | 11 | * to the database, this should be 0 or NULL |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row) |
33 | 33 | * NOTE: if the values haven't changed, returns 0 |
34 | 34 | */ |
35 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL); |
|
35 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Adds a new extra meta record. If $unique is set to TRUE, we'll first double-check |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param boolean $unique |
44 | 44 | * @return boolean |
45 | 45 | */ |
46 | - public function add_extra_meta($meta_key,$meta_value,$unique = false); |
|
46 | + public function add_extra_meta($meta_key, $meta_value, $unique = false); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Deletes all the extra meta rows for this record as specified by key. If $meta_value |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $meta_value |
53 | 53 | * @return int number of extra meta rows deleted |
54 | 54 | */ |
55 | - public function delete_extra_meta($meta_key,$meta_value = NULL); |
|
55 | + public function delete_extra_meta($meta_key, $meta_value = NULL); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Gets the extra meta with the given meta key. If you specify "single" we just return 1, otherwise |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param mixed $default if we don't find anything, what should we return? |
64 | 64 | * @return mixed single value if $single; array if ! $single |
65 | 65 | */ |
66 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL); |
|
66 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param EE_Response $response |
91 | 91 | * @return EE_Response |
92 | 92 | */ |
93 | - public function handle_request( EE_Request $request, EE_Response $response ); |
|
93 | + public function handle_request(EE_Request $request, EE_Response $response); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param EE_Request $request |
107 | 107 | * @param EE_Response $response |
108 | 108 | */ |
109 | - public function handle_response( EE_Request $request, EE_Response $response ); |
|
109 | + public function handle_response(EE_Request $request, EE_Response $response); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | * @param string $country |
287 | 287 | * @param string $CNT_ISO |
288 | 288 | */ |
289 | - public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ); |
|
289 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -296,13 +296,13 @@ discard block |
||
296 | 296 | /** |
297 | 297 | * Interface EEHI_Line_Item |
298 | 298 | */ |
299 | -interface EEHI_Line_Item{ |
|
299 | +interface EEHI_Line_Item { |
|
300 | 300 | /** |
301 | 301 | * Adds an item to the purchase in the right spot |
302 | 302 | * @param EE_Line_Item $total_line_item |
303 | 303 | * @param EE_Line_Item $line_item |
304 | 304 | */ |
305 | - public function add_item( EE_Line_Item $total_line_item, EE_Line_Item $line_item ); |
|
305 | + public function add_item(EE_Line_Item $total_line_item, EE_Line_Item $line_item); |
|
306 | 306 | /** |
307 | 307 | * Overwrites the previous tax by clearing out the old taxes, and creates a new |
308 | 308 | * tax and updates the total line item accordingly |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * set the taxes to match $amount |
317 | 317 | * @return EE_Line_Item the new tax created |
318 | 318 | */ |
319 | - public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
|
319 | + public function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false); |
|
320 | 320 | |
321 | 321 | /** |
322 | 322 | * Makes all the line items which are children of $line_item taxable (or not). |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @param string $code_substring_for_whitelist if this string is part of the line item's code |
327 | 327 | * it will be whitelisted (ie, except from becoming taxable) |
328 | 328 | */ |
329 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
329 | + public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -340,21 +340,21 @@ discard block |
||
340 | 340 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
341 | 341 | * @return boolean success |
342 | 342 | */ |
343 | - public function add_unrelated_item( EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null ); |
|
343 | + public function add_unrelated_item(EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null); |
|
344 | 344 | |
345 | 345 | /** |
346 | 346 | * Gets the line item for the taxes subtotal |
347 | 347 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
348 | 348 | * @return \EE_Line_Item |
349 | 349 | */ |
350 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ); |
|
350 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Money-related helper |
356 | 356 | */ |
357 | -interface EEHI_Money{ |
|
357 | +interface EEHI_Money { |
|
358 | 358 | /** |
359 | 359 | * For comparing floats. Default operator is '=', but see the $operator below for all options. |
360 | 360 | * This should be used to compare floats instead of normal '==' because floats |
@@ -365,13 +365,13 @@ discard block |
||
365 | 365 | * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
366 | 366 | * @return boolean whether the equation is true or false |
367 | 367 | */ |
368 | - public function compare_floats( $float1, $float2, $operator='=' ); |
|
368 | + public function compare_floats($float1, $float2, $operator = '='); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
372 | 372 | * Interface EEHI_Template |
373 | 373 | */ |
374 | -interface EEHI_Template{ |
|
374 | +interface EEHI_Template { |
|
375 | 375 | |
376 | 376 | /** |
377 | 377 | * EEH_Template::format_currency |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param string $cur_code_span_class |
385 | 385 | * @return string the html output for the formatted money value |
386 | 386 | */ |
387 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ); |
|
387 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code'); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * @param array $options |
400 | 400 | * @return mixed |
401 | 401 | */ |
402 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ); |
|
402 | + public function display_line_item(EE_Line_Item $line_item, $options = array()); |
|
403 | 403 | |
404 | 404 | } |
405 | 405 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws EE_Error |
417 | 417 | * @return bool |
418 | 418 | */ |
419 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ); |
|
419 | + public static function ensure_file_exists_and_is_writable($full_file_path = ''); |
|
420 | 420 | |
421 | 421 | /** |
422 | 422 | * ensure_folder_exists_and_is_writable |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | * @throws EE_Error |
426 | 426 | * @return bool |
427 | 427 | */ |
428 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ); |
|
428 | + public static function ensure_folder_exists_and_is_writable($folder = ''); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | // End of file EEI_Interfaces.php |
@@ -13,9 +13,9 @@ discard block |
||
13 | 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; |
20 | 20 | |
21 | 21 | |
@@ -50,7 +50,6 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Using the selected gateway, processes the payment for that transaction, and updates the transaction appropriately. |
52 | 52 | * Saves the payment that is generated |
53 | - |
|
54 | 53 | * |
55 | 54 | *@param EE_Payment_Method $payment_method |
56 | 55 | * @param EE_Transaction $transaction |
@@ -130,7 +129,6 @@ discard block |
||
130 | 129 | |
131 | 130 | |
132 | 131 | /** |
133 | - |
|
134 | 132 | * @param EE_Base_Class|int $transaction |
135 | 133 | * @param EE_Payment_Method $payment_method |
136 | 134 | * @throws EE_Error |
@@ -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 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $update_txn = true, |
82 | 82 | $cancel_url = '' |
83 | 83 | ) { |
84 | - if( (float)$amount < 0 ) { |
|
84 | + if ((float) $amount < 0) { |
|
85 | 85 | throw new EE_Error( |
86 | 86 | sprintf( |
87 | 87 | __( |
@@ -94,33 +94,33 @@ discard block |
||
94 | 94 | ); |
95 | 95 | } |
96 | 96 | // verify payment method |
97 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE ); |
|
97 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE); |
|
98 | 98 | // verify transaction |
99 | - EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
100 | - $transaction->set_payment_method_ID( $payment_method->ID() ); |
|
99 | + EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
100 | + $transaction->set_payment_method_ID($payment_method->ID()); |
|
101 | 101 | // verify payment method type |
102 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
102 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
103 | 103 | $payment = $payment_method->type_obj()->process_payment( |
104 | 104 | $transaction, |
105 | - min( $amount, $transaction->remaining() ),//make sure we don't overcharge |
|
105 | + min($amount, $transaction->remaining()), //make sure we don't overcharge |
|
106 | 106 | $billing_form, |
107 | 107 | $return_url, |
108 | - add_query_arg( array( 'ee_cancel_payment' => true ), $cancel_url ), |
|
108 | + add_query_arg(array('ee_cancel_payment' => true), $cancel_url), |
|
109 | 109 | $method, |
110 | 110 | $by_admin |
111 | 111 | ); |
112 | 112 | // check if payment method uses an off-site gateway |
113 | - if ( $payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite ) { |
|
113 | + if ($payment_method->type_obj()->payment_occurs() !== EE_PMT_Base::offsite) { |
|
114 | 114 | // don't process payments for off-site gateways yet because no payment has occurred yet |
115 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
115 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
116 | 116 | } |
117 | 117 | return $payment; |
118 | 118 | } else { |
119 | 119 | EE_Error::add_error( |
120 | 120 | sprintf( |
121 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
121 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
122 | 122 | '<br/>', |
123 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
123 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
124 | 124 | ), __FILE__, __FUNCTION__, __LINE__ |
125 | 125 | ); |
126 | 126 | return NULL; |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * @throws EE_Error |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - public function get_ipn_url_for_payment_method( $transaction, $payment_method ){ |
|
139 | + public function get_ipn_url_for_payment_method($transaction, $payment_method) { |
|
140 | 140 | /** @type \EE_Transaction $transaction */ |
141 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
141 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
142 | 142 | $primary_reg = $transaction->primary_registration(); |
143 | - if( ! $primary_reg instanceof EE_Registration ){ |
|
143 | + if ( ! $primary_reg instanceof EE_Registration) { |
|
144 | 144 | throw new EE_Error( |
145 | 145 | sprintf( |
146 | 146 | __( |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | ) |
152 | 152 | ); |
153 | 153 | } |
154 | - $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true); |
|
154 | + $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true); |
|
155 | 155 | $url = add_query_arg( |
156 | 156 | array( |
157 | 157 | 'e_reg_url_link'=>$primary_reg->reg_url_link(), |
@@ -188,92 +188,92 @@ discard block |
||
188 | 188 | $update_txn = true, |
189 | 189 | $separate_IPN_request = true |
190 | 190 | ) { |
191 | - EE_Registry::instance()->load_model( 'Change_Log' ); |
|
192 | - $_req_data = $this->_remove_unusable_characters_from_array( $_req_data ); |
|
193 | - EE_Processor_Base::set_IPN( $separate_IPN_request ); |
|
191 | + EE_Registry::instance()->load_model('Change_Log'); |
|
192 | + $_req_data = $this->_remove_unusable_characters_from_array($_req_data); |
|
193 | + EE_Processor_Base::set_IPN($separate_IPN_request); |
|
194 | 194 | $obj_for_log = null; |
195 | - if( $transaction instanceof EE_Transaction ){ |
|
195 | + if ($transaction instanceof EE_Transaction) { |
|
196 | 196 | $obj_for_log = $transaction; |
197 | - if( $payment_method instanceof EE_Payment_Method ) { |
|
197 | + if ($payment_method instanceof EE_Payment_Method) { |
|
198 | 198 | $obj_for_log = EEM_Payment::instance()->get_one( |
199 | 199 | array( |
200 | - array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), |
|
201 | - 'order_by' => array( 'PAY_timestamp' => 'desc' ) |
|
200 | + array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), |
|
201 | + 'order_by' => array('PAY_timestamp' => 'desc') |
|
202 | 202 | ) |
203 | 203 | ); |
204 | 204 | } |
205 | - } else if( $payment_method instanceof EE_Payment ) { |
|
205 | + } else if ($payment_method instanceof EE_Payment) { |
|
206 | 206 | $obj_for_log = $payment_method; |
207 | 207 | } |
208 | 208 | $log = EEM_Change_Log::instance()->log( |
209 | 209 | EEM_Change_Log::type_gateway, |
210 | - array( 'IPN data received' => $_req_data ), |
|
210 | + array('IPN data received' => $_req_data), |
|
211 | 211 | $obj_for_log |
212 | 212 | ); |
213 | - try{ |
|
213 | + try { |
|
214 | 214 | /** |
215 | 215 | * @var EE_Payment $payment |
216 | 216 | */ |
217 | 217 | $payment = NULL; |
218 | - if($transaction && $payment_method){ |
|
218 | + if ($transaction && $payment_method) { |
|
219 | 219 | /** @type EE_Transaction $transaction */ |
220 | 220 | $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
221 | 221 | /** @type EE_Payment_Method $payment_method */ |
222 | 222 | $payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method); |
223 | - if ( $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
224 | - $payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction ); |
|
223 | + if ($payment_method->type_obj() instanceof EE_PMT_Base) { |
|
224 | + $payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction); |
|
225 | 225 | $log->set_object($payment); |
226 | 226 | } else { |
227 | 227 | // not a payment |
228 | 228 | EE_Error::add_error( |
229 | 229 | sprintf( |
230 | - __( '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' ), |
|
230 | + __('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'), |
|
231 | 231 | '<br/>', |
232 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
232 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
233 | 233 | ), |
234 | 234 | __FILE__, __FUNCTION__, __LINE__ |
235 | 235 | ); |
236 | 236 | } |
237 | - }else{ |
|
237 | + } else { |
|
238 | 238 | //that's actually pretty ok. The IPN just wasn't able |
239 | 239 | //to identify which transaction or payment method this was for |
240 | 240 | // give all active payment methods a chance to claim it |
241 | 241 | $active_payment_methods = EEM_Payment_Method::instance()->get_all_active(); |
242 | - foreach( $active_payment_methods as $active_payment_method ){ |
|
243 | - try{ |
|
244 | - $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn( $_req_data ); |
|
242 | + foreach ($active_payment_methods as $active_payment_method) { |
|
243 | + try { |
|
244 | + $payment = $active_payment_method->type_obj()->handle_unclaimed_ipn($_req_data); |
|
245 | 245 | $payment_method = $active_payment_method; |
246 | 246 | EEM_Change_Log::instance()->log( |
247 | 247 | EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment |
248 | 248 | ); |
249 | 249 | break; |
250 | - } catch( EE_Error $e ) { |
|
250 | + } catch (EE_Error $e) { |
|
251 | 251 | //that's fine- it apparently couldn't handle the IPN |
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
255 | 255 | } |
256 | 256 | // EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method); |
257 | - if( $payment instanceof EE_Payment){ |
|
257 | + if ($payment instanceof EE_Payment) { |
|
258 | 258 | $payment->save(); |
259 | 259 | // update the TXN |
260 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
|
261 | - }else{ |
|
260 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request); |
|
261 | + } else { |
|
262 | 262 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
263 | - if($payment_method){ |
|
263 | + if ($payment_method) { |
|
264 | 264 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
265 | - }elseif($transaction){ |
|
265 | + }elseif ($transaction) { |
|
266 | 266 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
267 | 267 | } |
268 | 268 | } |
269 | 269 | return $payment; |
270 | 270 | |
271 | - } catch( EE_Error $e ) { |
|
271 | + } catch (EE_Error $e) { |
|
272 | 272 | do_action( |
273 | 273 | 'AHEE__log', __FILE__, __FUNCTION__, sprintf( |
274 | - __( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ), |
|
275 | - print_r( $transaction, TRUE ), |
|
276 | - print_r( $_req_data, TRUE ), |
|
274 | + __('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'), |
|
275 | + print_r($transaction, TRUE), |
|
276 | + print_r($_req_data, TRUE), |
|
277 | 277 | $e->getMessage() |
278 | 278 | ) |
279 | 279 | ); |
@@ -288,10 +288,10 @@ discard block |
||
288 | 288 | * @param array $request_data |
289 | 289 | * @return array |
290 | 290 | */ |
291 | - protected function _remove_unusable_characters_from_array( array $request_data ) { |
|
291 | + protected function _remove_unusable_characters_from_array(array $request_data) { |
|
292 | 292 | $return_data = array(); |
293 | - foreach( $request_data as $key => $value ) { |
|
294 | - $return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value ); |
|
293 | + foreach ($request_data as $key => $value) { |
|
294 | + $return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value); |
|
295 | 295 | } |
296 | 296 | return $return_data; |
297 | 297 | } |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | * @param string $request_data |
304 | 304 | * @return string |
305 | 305 | */ |
306 | - protected function _remove_unusable_characters( $request_data ) { |
|
307 | - return preg_replace( '/[^[:print:]]/', '', $request_data ); |
|
306 | + protected function _remove_unusable_characters($request_data) { |
|
307 | + return preg_replace('/[^[:print:]]/', '', $request_data); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, |
327 | 327 | * to call handle_ipn() for offsite gateways that don't receive separate IPNs |
328 | 328 | */ |
329 | - public function finalize_payment_for( $transaction, $update_txn = TRUE ){ |
|
329 | + public function finalize_payment_for($transaction, $update_txn = TRUE) { |
|
330 | 330 | /** @var $transaction EE_Transaction */ |
331 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
331 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
332 | 332 | $last_payment_method = $transaction->payment_method(); |
333 | - if ( $last_payment_method instanceof EE_Payment_Method ) { |
|
334 | - $payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction ); |
|
335 | - $this->update_txn_based_on_payment( $transaction, $payment, $update_txn ); |
|
333 | + if ($last_payment_method instanceof EE_Payment_Method) { |
|
334 | + $payment = $last_payment_method->type_obj()->finalize_payment_for($transaction); |
|
335 | + $this->update_txn_based_on_payment($transaction, $payment, $update_txn); |
|
336 | 336 | return $payment; |
337 | 337 | } else { |
338 | 338 | return NULL; |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | EE_Payment $payment_to_refund, |
356 | 356 | $refund_info = array() |
357 | 357 | ) { |
358 | - if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) { |
|
359 | - $payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info ); |
|
360 | - $this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund ); |
|
358 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) { |
|
359 | + $payment_method->type_obj()->process_refund($payment_to_refund, $refund_info); |
|
360 | + $this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund); |
|
361 | 361 | } |
362 | 362 | return $payment_to_refund; |
363 | 363 | } |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | * TXN is locked before updating |
399 | 399 | * @throws \EE_Error |
400 | 400 | */ |
401 | - public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){ |
|
401 | + public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) { |
|
402 | 402 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful'; |
403 | 403 | /** @type EE_Transaction $transaction */ |
404 | - $transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction ); |
|
404 | + $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction); |
|
405 | 405 | // can we freely update the TXN at this moment? |
406 | - if ( $IPN && $transaction->is_locked() ) { |
|
406 | + if ($IPN && $transaction->is_locked()) { |
|
407 | 407 | // don't update the transaction at this exact moment |
408 | 408 | // because the TXN is active in another request |
409 | 409 | EE_Cron_Tasks::schedule_update_transaction_with_payment( |
@@ -413,45 +413,45 @@ discard block |
||
413 | 413 | ); |
414 | 414 | } else { |
415 | 415 | // verify payment and that it has been saved |
416 | - if ( $payment instanceof EE_Payment && $payment->ID() ) { |
|
417 | - if( |
|
416 | + if ($payment instanceof EE_Payment && $payment->ID()) { |
|
417 | + if ( |
|
418 | 418 | $payment->payment_method() instanceof EE_Payment_Method |
419 | 419 | && $payment->payment_method()->type_obj() instanceof EE_PMT_Base |
420 | - ){ |
|
421 | - $payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment ); |
|
420 | + ) { |
|
421 | + $payment->payment_method()->type_obj()->update_txn_based_on_payment($payment); |
|
422 | 422 | // update TXN registrations with payment info |
423 | - $this->process_registration_payments( $transaction, $payment ); |
|
423 | + $this->process_registration_payments($transaction, $payment); |
|
424 | 424 | } |
425 | 425 | $do_action = $payment->just_approved() |
426 | 426 | ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' |
427 | 427 | : $do_action; |
428 | 428 | } else { |
429 | 429 | // send out notifications |
430 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
430 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
431 | 431 | $do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made'; |
432 | 432 | } |
433 | 433 | // if this is an IPN, then we want to know the initial TXN status prior to updating the TXN |
434 | 434 | // so that we know whether the status has changed and notifications should be triggered |
435 | - if ( $IPN ) { |
|
435 | + if ($IPN) { |
|
436 | 436 | /** @type EE_Transaction_Processor $transaction_processor */ |
437 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
438 | - $transaction_processor->set_old_txn_status( $transaction->status_ID() ); |
|
437 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
438 | + $transaction_processor->set_old_txn_status($transaction->status_ID()); |
|
439 | 439 | } |
440 | - if ( $payment->status() !== EEM_Payment::status_id_failed ) { |
|
440 | + if ($payment->status() !== EEM_Payment::status_id_failed) { |
|
441 | 441 | /** @type EE_Transaction_Payments $transaction_payments */ |
442 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
442 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
443 | 443 | // set new value for total paid |
444 | - $transaction_payments->calculate_total_payments_and_update_status( $transaction ); |
|
444 | + $transaction_payments->calculate_total_payments_and_update_status($transaction); |
|
445 | 445 | // call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ??? |
446 | - if ( $update_txn ) { |
|
447 | - $this->_post_payment_processing( $transaction, $payment, $IPN ); |
|
446 | + if ($update_txn) { |
|
447 | + $this->_post_payment_processing($transaction, $payment, $IPN); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | // granular hook for others to use. |
451 | - do_action( $do_action, $transaction, $payment ); |
|
452 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' ); |
|
451 | + do_action($do_action, $transaction, $payment); |
|
452 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action'); |
|
453 | 453 | //global hook for others to use. |
454 | - do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment ); |
|
454 | + do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
@@ -471,25 +471,25 @@ discard block |
||
471 | 471 | $registrations = array() |
472 | 472 | ) { |
473 | 473 | // only process if payment was successful |
474 | - if ( $payment->status() !== EEM_Payment::status_id_approved ) { |
|
474 | + if ($payment->status() !== EEM_Payment::status_id_approved) { |
|
475 | 475 | return; |
476 | 476 | } |
477 | 477 | //EEM_Registration::instance()->show_next_x_db_queries(); |
478 | - if ( empty( $registrations )) { |
|
478 | + if (empty($registrations)) { |
|
479 | 479 | // find registrations with monies owing that can receive a payment |
480 | 480 | $registrations = $transaction->registrations( |
481 | 481 | array( |
482 | 482 | array( |
483 | 483 | // only these reg statuses can receive payments |
484 | - 'STS_ID' => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ), |
|
485 | - 'REG_final_price' => array( '!=', 0 ), |
|
486 | - 'REG_final_price*' => array( '!=', 'REG_paid', true ), |
|
484 | + 'STS_ID' => array('IN', EEM_Registration::reg_statuses_that_allow_payment()), |
|
485 | + 'REG_final_price' => array('!=', 0), |
|
486 | + 'REG_final_price*' => array('!=', 'REG_paid', true), |
|
487 | 487 | ) |
488 | 488 | ) |
489 | 489 | ); |
490 | 490 | } |
491 | 491 | // still nothing ??!?? |
492 | - if ( empty( $registrations )) { |
|
492 | + if (empty($registrations)) { |
|
493 | 493 | return; |
494 | 494 | } |
495 | 495 | // todo: break out the following logic into a separate strategy class |
@@ -501,28 +501,28 @@ discard block |
||
501 | 501 | |
502 | 502 | $refund = $payment->is_a_refund(); |
503 | 503 | // how much is available to apply to registrations? |
504 | - $available_payment_amount = abs( $payment->amount() ); |
|
505 | - foreach ( $registrations as $registration ) { |
|
506 | - if ( $registration instanceof EE_Registration ) { |
|
504 | + $available_payment_amount = abs($payment->amount()); |
|
505 | + foreach ($registrations as $registration) { |
|
506 | + if ($registration instanceof EE_Registration) { |
|
507 | 507 | // nothing left? |
508 | - if ( $available_payment_amount <= 0 ) { |
|
508 | + if ($available_payment_amount <= 0) { |
|
509 | 509 | break; |
510 | 510 | } |
511 | - if ( $refund ) { |
|
512 | - $available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount ); |
|
511 | + if ($refund) { |
|
512 | + $available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount); |
|
513 | 513 | } else { |
514 | - $available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount ); |
|
514 | + $available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount); |
|
515 | 515 | } |
516 | 516 | } |
517 | 517 | } |
518 | - if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) { |
|
518 | + if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) { |
|
519 | 519 | EE_Error::add_attention( |
520 | 520 | sprintf( |
521 | - __( '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' ), |
|
522 | - EEH_Template::format_currency( $available_payment_amount ), |
|
523 | - implode( ', ', array_keys( $registrations ) ), |
|
521 | + __('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'), |
|
522 | + EEH_Template::format_currency($available_payment_amount), |
|
523 | + implode(', ', array_keys($registrations)), |
|
524 | 524 | '<br/>', |
525 | - EEH_Template::format_currency( $payment->amount() ) |
|
525 | + EEH_Template::format_currency($payment->amount()) |
|
526 | 526 | ), |
527 | 527 | __FILE__, __FUNCTION__, __LINE__ |
528 | 528 | ); |
@@ -540,17 +540,17 @@ discard block |
||
540 | 540 | * @return float |
541 | 541 | * @throws \EE_Error |
542 | 542 | */ |
543 | - public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) { |
|
543 | + public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) { |
|
544 | 544 | $owing = $registration->final_price() - $registration->paid(); |
545 | - if ( $owing > 0 ) { |
|
545 | + if ($owing > 0) { |
|
546 | 546 | // don't allow payment amount to exceed the available payment amount, OR the amount owing |
547 | - $payment_amount = min( $available_payment_amount, $owing ); |
|
547 | + $payment_amount = min($available_payment_amount, $owing); |
|
548 | 548 | // update $available_payment_amount |
549 | 549 | $available_payment_amount -= $payment_amount; |
550 | 550 | //calculate and set new REG_paid |
551 | - $registration->set_paid( $registration->paid() + $payment_amount ); |
|
551 | + $registration->set_paid($registration->paid() + $payment_amount); |
|
552 | 552 | // now save it |
553 | - $this->_apply_registration_payment( $registration, $payment, $payment_amount ); |
|
553 | + $this->_apply_registration_payment($registration, $payment, $payment_amount); |
|
554 | 554 | } |
555 | 555 | return $available_payment_amount; |
556 | 556 | } |
@@ -566,19 +566,19 @@ discard block |
||
566 | 566 | * @return float |
567 | 567 | * @throws \EE_Error |
568 | 568 | */ |
569 | - protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) { |
|
569 | + protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) { |
|
570 | 570 | // find any existing reg payment records for this registration and payment |
571 | 571 | $existing_reg_payment = EEM_Registration_Payment::instance()->get_one( |
572 | - array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) ) |
|
572 | + array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID())) |
|
573 | 573 | ); |
574 | 574 | // if existing registration payment exists |
575 | - if ( $existing_reg_payment instanceof EE_Registration_Payment ) { |
|
575 | + if ($existing_reg_payment instanceof EE_Registration_Payment) { |
|
576 | 576 | // then update that record |
577 | - $existing_reg_payment->set_amount( $payment_amount ); |
|
577 | + $existing_reg_payment->set_amount($payment_amount); |
|
578 | 578 | $existing_reg_payment->save(); |
579 | 579 | } else { |
580 | 580 | // or add new relation between registration and payment and set amount |
581 | - $registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) ); |
|
581 | + $registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount)); |
|
582 | 582 | // make it stick |
583 | 583 | $registration->save(); |
584 | 584 | } |
@@ -595,21 +595,21 @@ discard block |
||
595 | 595 | * @return float |
596 | 596 | * @throws \EE_Error |
597 | 597 | */ |
598 | - public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) { |
|
598 | + public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) { |
|
599 | 599 | //EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ ); |
600 | - if ( $registration->paid() > 0 ) { |
|
600 | + if ($registration->paid() > 0) { |
|
601 | 601 | // ensure $available_refund_amount is NOT negative |
602 | - $available_refund_amount = (float)abs( $available_refund_amount ); |
|
602 | + $available_refund_amount = (float) abs($available_refund_amount); |
|
603 | 603 | // don't allow refund amount to exceed the available payment amount, OR the amount paid |
604 | - $refund_amount = min( $available_refund_amount, (float)$registration->paid() ); |
|
604 | + $refund_amount = min($available_refund_amount, (float) $registration->paid()); |
|
605 | 605 | // update $available_payment_amount |
606 | 606 | $available_refund_amount -= $refund_amount; |
607 | 607 | //calculate and set new REG_paid |
608 | - $registration->set_paid( $registration->paid() - $refund_amount ); |
|
608 | + $registration->set_paid($registration->paid() - $refund_amount); |
|
609 | 609 | // convert payment amount back to a negative value for storage in the db |
610 | - $refund_amount = (float)abs( $refund_amount ) * -1; |
|
610 | + $refund_amount = (float) abs($refund_amount) * -1; |
|
611 | 611 | // now save it |
612 | - $this->_apply_registration_payment( $registration, $payment, $refund_amount ); |
|
612 | + $this->_apply_registration_payment($registration, $payment, $refund_amount); |
|
613 | 613 | } |
614 | 614 | return $available_refund_amount; |
615 | 615 | } |
@@ -628,21 +628,21 @@ discard block |
||
628 | 628 | * @param bool $IPN |
629 | 629 | * @throws \EE_Error |
630 | 630 | */ |
631 | - protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) { |
|
631 | + protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) { |
|
632 | 632 | |
633 | 633 | /** @type EE_Transaction_Processor $transaction_processor */ |
634 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
634 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
635 | 635 | // is the Payment Options Reg Step completed ? |
636 | - $payment_options_step_completed = $transaction_processor->reg_step_completed( $transaction, 'payment_options' ); |
|
636 | + $payment_options_step_completed = $transaction_processor->reg_step_completed($transaction, 'payment_options'); |
|
637 | 637 | // if the Payment Options Reg Step is completed... |
638 | 638 | $revisit = $payment_options_step_completed === true ? true : false; |
639 | 639 | // then this is kinda sorta a revisit with regards to payments at least |
640 | - $transaction_processor->set_revisit( $revisit ); |
|
640 | + $transaction_processor->set_revisit($revisit); |
|
641 | 641 | // if this is an IPN, let's consider the Payment Options Reg Step completed if not already |
642 | 642 | if ( |
643 | 643 | $IPN && |
644 | 644 | $payment_options_step_completed !== true && |
645 | - ( $payment->is_approved() || $payment->is_pending() ) |
|
645 | + ($payment->is_approved() || $payment->is_pending()) |
|
646 | 646 | ) { |
647 | 647 | $payment_options_step_completed = $transaction_processor->set_reg_step_completed( |
648 | 648 | $transaction, |
@@ -650,34 +650,34 @@ discard block |
||
650 | 650 | ); |
651 | 651 | } |
652 | 652 | /** @type EE_Transaction_Payments $transaction_payments */ |
653 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
653 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
654 | 654 | // maybe update status, but don't save transaction just yet |
655 | - $transaction_payments->update_transaction_status_based_on_total_paid( $transaction, false ); |
|
655 | + $transaction_payments->update_transaction_status_based_on_total_paid($transaction, false); |
|
656 | 656 | // check if 'finalize_registration' step has been completed... |
657 | - $finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' ); |
|
657 | + $finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration'); |
|
658 | 658 | // if this is an IPN and the final step has not been initiated |
659 | - if ( $IPN && $payment_options_step_completed && $finalized === false ) { |
|
659 | + if ($IPN && $payment_options_step_completed && $finalized === false) { |
|
660 | 660 | // and if it hasn't already been set as being started... |
661 | - $finalized = $transaction_processor->set_reg_step_initiated( $transaction, 'finalize_registration' ); |
|
661 | + $finalized = $transaction_processor->set_reg_step_initiated($transaction, 'finalize_registration'); |
|
662 | 662 | } |
663 | 663 | $transaction->save(); |
664 | 664 | // because the above will return false if the final step was not fully completed, we need to check again... |
665 | - if ( $IPN && $finalized !== false ) { |
|
665 | + if ($IPN && $finalized !== false) { |
|
666 | 666 | // and if we are all good to go, then send out notifications |
667 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' ); |
|
667 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true'); |
|
668 | 668 | //ok, now process the transaction according to the payment |
669 | - $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment ); |
|
669 | + $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment); |
|
670 | 670 | } |
671 | 671 | // DEBUG LOG |
672 | 672 | $payment_method = $payment->payment_method(); |
673 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
673 | + if ($payment_method instanceof EE_Payment_Method) { |
|
674 | 674 | $payment_method_type_obj = $payment_method->type_obj(); |
675 | - if ( $payment_method_type_obj instanceof EE_PMT_Base ) { |
|
675 | + if ($payment_method_type_obj instanceof EE_PMT_Base) { |
|
676 | 676 | $gateway = $payment_method_type_obj->get_gateway(); |
677 | - if ( $gateway instanceof EE_Gateway ){ |
|
677 | + if ($gateway instanceof EE_Gateway) { |
|
678 | 678 | $gateway->log( |
679 | 679 | array( |
680 | - 'message' => __( 'Post Payment Transaction Details', 'event_espresso' ), |
|
680 | + 'message' => __('Post Payment Transaction Details', 'event_espresso'), |
|
681 | 681 | 'transaction' => $transaction->model_field_array(), |
682 | 682 | 'finalized' => $finalized, |
683 | 683 | 'IPN' => $IPN, |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | __FILE__, __FUNCTION__, __LINE__ |
235 | 235 | ); |
236 | 236 | } |
237 | - }else{ |
|
237 | + } else{ |
|
238 | 238 | //that's actually pretty ok. The IPN just wasn't able |
239 | 239 | //to identify which transaction or payment method this was for |
240 | 240 | // give all active payment methods a chance to claim it |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | $payment->save(); |
259 | 259 | // update the TXN |
260 | 260 | $this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request ); |
261 | - }else{ |
|
261 | + } else{ |
|
262 | 262 | //we couldn't find the payment for this IPN... let's try and log at least SOMETHING |
263 | 263 | if($payment_method){ |
264 | 264 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method); |
265 | - }elseif($transaction){ |
|
265 | + } elseif($transaction){ |
|
266 | 266 | EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction); |
267 | 267 | } |
268 | 268 | } |
@@ -47,25 +47,25 @@ discard block |
||
47 | 47 | |
48 | 48 | |
49 | 49 | /** |
50 | - * date format |
|
51 | - * |
|
52 | - * pattern or format for displaying dates |
|
53 | - * |
|
54 | - * @access protected |
|
55 | - * @var string |
|
56 | - */ |
|
50 | + * date format |
|
51 | + * |
|
52 | + * pattern or format for displaying dates |
|
53 | + * |
|
54 | + * @access protected |
|
55 | + * @var string |
|
56 | + */ |
|
57 | 57 | protected $_dt_frmt; |
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * time format |
|
63 | - * |
|
64 | - * pattern or format for displaying time |
|
65 | - * |
|
66 | - * @access protected |
|
67 | - * @var string |
|
68 | - */ |
|
61 | + /** |
|
62 | + * time format |
|
63 | + * |
|
64 | + * pattern or format for displaying time |
|
65 | + * |
|
66 | + * @access protected |
|
67 | + * @var string |
|
68 | + */ |
|
69 | 69 | protected $_tm_frmt; |
70 | 70 | |
71 | 71 | |
@@ -1420,24 +1420,24 @@ discard block |
||
1420 | 1420 | * |
1421 | 1421 | * @throws \EE_Error |
1422 | 1422 | */ |
1423 | - public function refresh_cache_of_related_objects() { |
|
1424 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1425 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1426 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1427 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1428 | - //this relation only stores a single model object, not an array |
|
1429 | - //but let's make it consistent |
|
1430 | - $related_objects = array( $related_objects ); |
|
1431 | - } |
|
1432 | - foreach( $related_objects as $related_object ) { |
|
1433 | - //only refresh their cache if they're in memory |
|
1434 | - if( $related_object instanceof EE_Base_Class ) { |
|
1423 | + public function refresh_cache_of_related_objects() { |
|
1424 | + foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1425 | + if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1426 | + $related_objects = $this->_model_relations[ $relation_name ]; |
|
1427 | + if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1428 | + //this relation only stores a single model object, not an array |
|
1429 | + //but let's make it consistent |
|
1430 | + $related_objects = array( $related_objects ); |
|
1431 | + } |
|
1432 | + foreach( $related_objects as $related_object ) { |
|
1433 | + //only refresh their cache if they're in memory |
|
1434 | + if( $related_object instanceof EE_Base_Class ) { |
|
1435 | 1435 | $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
1436 | - } |
|
1437 | - } |
|
1438 | - } |
|
1439 | - } |
|
1440 | - } |
|
1436 | + } |
|
1437 | + } |
|
1438 | + } |
|
1439 | + } |
|
1440 | + } |
|
1441 | 1441 | |
1442 | 1442 | |
1443 | 1443 | |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | if ( self::_get_model( $classname )->has_primary_key_field() ) { |
1679 | 1679 | $primary_id_ref = self::_get_primary_key_name( $classname ); |
1680 | 1680 | if ( array_key_exists( $primary_id_ref, $props_n_values ) |
1681 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1681 | + && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1682 | 1682 | ) { |
1683 | 1683 | $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
1684 | 1684 | $props_n_values[ $primary_id_ref ] |
@@ -1830,9 +1830,9 @@ discard block |
||
1830 | 1830 | $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
1831 | 1831 | //clear cache so future get_many_related and get_first_related() return new results. |
1832 | 1832 | $this->clear_cache( $relationName, $otherObject, TRUE ); |
1833 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1834 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1835 | - } |
|
1833 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1834 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1835 | + } |
|
1836 | 1836 | } else { |
1837 | 1837 | //this thing doesn't exist in the DB, so just cache it |
1838 | 1838 | if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
@@ -1846,18 +1846,18 @@ discard block |
||
1846 | 1846 | } |
1847 | 1847 | $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
1848 | 1848 | } |
1849 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1850 | - //fix the reciprocal relation too |
|
1851 | - if( $otherObject->ID() ) { |
|
1852 | - //its saved so assumed relations exist in the DB, so we can just |
|
1853 | - //clear the cache so future queries use the updated info in the DB |
|
1854 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1855 | - } else { |
|
1856 | - |
|
1857 | - //it's not saved, so it caches relations like this |
|
1858 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1859 | - } |
|
1860 | - } |
|
1849 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1850 | + //fix the reciprocal relation too |
|
1851 | + if( $otherObject->ID() ) { |
|
1852 | + //its saved so assumed relations exist in the DB, so we can just |
|
1853 | + //clear the cache so future queries use the updated info in the DB |
|
1854 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1855 | + } else { |
|
1856 | + |
|
1857 | + //it's not saved, so it caches relations like this |
|
1858 | + $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1859 | + } |
|
1860 | + } |
|
1861 | 1861 | return $otherObject; |
1862 | 1862 | } |
1863 | 1863 | |
@@ -1888,9 +1888,9 @@ discard block |
||
1888 | 1888 | //this doesn't exist in the DB, just remove it from the cache |
1889 | 1889 | $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
1890 | 1890 | } |
1891 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1892 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1893 | - } |
|
1891 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1892 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1893 | + } |
|
1894 | 1894 | return $otherObject; |
1895 | 1895 | } |
1896 | 1896 | |
@@ -1913,11 +1913,11 @@ discard block |
||
1913 | 1913 | //this doesn't exist in the DB, just remove it from the cache |
1914 | 1914 | $otherObjects = $this->clear_cache( $relationName, null, true ); |
1915 | 1915 | } |
1916 | - if( is_array( $otherObjects ) ) { |
|
1917 | - foreach ( $otherObjects as $otherObject ) { |
|
1918 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1919 | - } |
|
1920 | - } |
|
1916 | + if( is_array( $otherObjects ) ) { |
|
1917 | + foreach ( $otherObjects as $otherObject ) { |
|
1918 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1919 | + } |
|
1920 | + } |
|
1921 | 1921 | return $otherObjects; |
1922 | 1922 | } |
1923 | 1923 |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
171 | 171 | if($relation_obj instanceof EE_Belongs_To_Relation){ |
172 | 172 | $this->_model_relations[$relation_name] = NULL; |
173 | - }else{ |
|
173 | + } else{ |
|
174 | 174 | $this->_model_relations[$relation_name] = array(); |
175 | 175 | } |
176 | 176 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
217 | 217 | $field_settings = $this->get_model()->field_settings_for( $field_name )){ |
218 | 218 | return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
219 | - }else{ |
|
219 | + } else{ |
|
220 | 220 | return NULL; |
221 | 221 | } |
222 | 222 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | : $this->set( $field_name, $this->_fields[$field_name] ); |
274 | 274 | } |
275 | 275 | |
276 | - }else{ |
|
276 | + } else{ |
|
277 | 277 | $this->_fields[$field_name] = $holder_of_value; |
278 | 278 | } |
279 | 279 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | //let's unset any cache for this field_name from the $_cached_properties property. |
306 | 306 | $this->_clear_cached_property( $field_name ); |
307 | - }else{ |
|
307 | + } else{ |
|
308 | 308 | throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
309 | 309 | } |
310 | 310 | |
@@ -653,10 +653,10 @@ discard block |
||
653 | 653 | if($clear_all){ |
654 | 654 | $obj_removed = true; |
655 | 655 | $this->_model_relations[$relationName] = null; |
656 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
656 | + } elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
657 | 657 | $obj_removed = $this->_model_relations[$relationName]; |
658 | 658 | $this->_model_relations[$relationName] = null; |
659 | - }else{ |
|
659 | + } else{ |
|
660 | 660 | if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
661 | 661 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
662 | 662 | if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
@@ -676,20 +676,20 @@ discard block |
||
676 | 676 | } |
677 | 677 | if($index_found_at){ |
678 | 678 | $index_in_cache = $index_found_at; |
679 | - }else{ |
|
679 | + } else{ |
|
680 | 680 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
681 | 681 | //if it wasn't in it to begin with. So we're done |
682 | 682 | return $object_to_remove_or_index_into_array; |
683 | 683 | } |
684 | 684 | } |
685 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
685 | + } elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
686 | 686 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
687 | 687 | foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
688 | 688 | if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
689 | 689 | $index_in_cache = $index; |
690 | 690 | } |
691 | 691 | } |
692 | - }else{ |
|
692 | + } else{ |
|
693 | 693 | $index_in_cache = $object_to_remove_or_index_into_array; |
694 | 694 | } |
695 | 695 | //supposedly we've found it. But it could just be that the client code |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
760 | 760 | if(is_array($cached_array_or_object)){ |
761 | 761 | return array_shift($cached_array_or_object); |
762 | - }else{ |
|
762 | + } else{ |
|
763 | 763 | return $cached_array_or_object; |
764 | 764 | } |
765 | 765 | } |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | if( $model_object->ID() ){ |
791 | 791 | $model->add_to_entity_map( $model_object ); |
792 | 792 | } |
793 | - }else{ |
|
793 | + } else{ |
|
794 | 794 | throw new EE_Error( |
795 | 795 | sprintf( |
796 | 796 | __( |
@@ -925,10 +925,10 @@ discard block |
||
925 | 925 | if( $field_obj->is_nullable()){ |
926 | 926 | //if the field allows nulls, then let it be null |
927 | 927 | $field_value = NULL; |
928 | - }else{ |
|
928 | + } else{ |
|
929 | 929 | $field_value = $field_obj->get_default_value(); |
930 | 930 | } |
931 | - }else{ |
|
931 | + } else{ |
|
932 | 932 | $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
933 | 933 | } |
934 | 934 | $this->_fields[$field_name] = $field_value; |
@@ -1513,7 +1513,7 @@ discard block |
||
1513 | 1513 | $this->_update_cached_related_model_objs_fks(); |
1514 | 1514 | } |
1515 | 1515 | } |
1516 | - }else{//PK is NOT auto-increment |
|
1516 | + } else{//PK is NOT auto-increment |
|
1517 | 1517 | //so check if one like it already exists in the db |
1518 | 1518 | if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
1519 | 1519 | if( WP_DEBUG && ! $this->in_entity_map() ){ |
@@ -1528,12 +1528,12 @@ discard block |
||
1528 | 1528 | ); |
1529 | 1529 | } |
1530 | 1530 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1531 | - }else{ |
|
1531 | + } else{ |
|
1532 | 1532 | $results = $this->get_model()->insert($save_cols_n_values); |
1533 | 1533 | $this->_update_cached_related_model_objs_fks(); |
1534 | 1534 | } |
1535 | 1535 | } |
1536 | - }else{//there is NO primary key |
|
1536 | + } else{//there is NO primary key |
|
1537 | 1537 | $already_in_db = false; |
1538 | 1538 | foreach($this->get_model()->unique_indexes() as $index){ |
1539 | 1539 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | if( $already_in_db ){ |
1545 | 1545 | $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
1546 | 1546 | $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
1547 | - }else{ |
|
1547 | + } else{ |
|
1548 | 1548 | $results = $this->get_model()->insert( $save_cols_n_values ); |
1549 | 1549 | } |
1550 | 1550 | } |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | //make sure this has been saved |
1607 | 1607 | if( ! $this->ID()){ |
1608 | 1608 | $id = $this->save(); |
1609 | - }else{ |
|
1609 | + } else{ |
|
1610 | 1610 | $id = $this->ID(); |
1611 | 1611 | } |
1612 | 1612 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
@@ -1625,7 +1625,7 @@ discard block |
||
1625 | 1625 | $this->_add_relation_to($related_model_obj, $relationName); |
1626 | 1626 | $related_model_obj->save_new_cached_related_model_objs(); |
1627 | 1627 | // } |
1628 | - }else{ |
|
1628 | + } else{ |
|
1629 | 1629 | foreach($this->_model_relations[$relationName] as $related_model_obj){ |
1630 | 1630 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1631 | 1631 | //but ONLY if it DOES NOT exist in the DB |
@@ -1774,7 +1774,7 @@ discard block |
||
1774 | 1774 | private static function _get_model_classname( $model_name = null){ |
1775 | 1775 | if(strpos($model_name,"EE_")===0){ |
1776 | 1776 | $model_classname=str_replace("EE_","EEM_",$model_name); |
1777 | - }else{ |
|
1777 | + } else{ |
|
1778 | 1778 | $model_classname = "EEM_".$model_name; |
1779 | 1779 | } |
1780 | 1780 | return $model_classname; |
@@ -1815,7 +1815,7 @@ discard block |
||
1815 | 1815 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1816 | 1816 | if( $this->get_model()->has_primary_key_field() ) { |
1817 | 1817 | return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ]; |
1818 | - }else{ |
|
1818 | + } else{ |
|
1819 | 1819 | return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
1820 | 1820 | } |
1821 | 1821 | } |
@@ -1951,7 +1951,7 @@ discard block |
||
1951 | 1951 | //if there are query parameters, forget about caching the related model objects. |
1952 | 1952 | if( $query_params ){ |
1953 | 1953 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1954 | - }else{ |
|
1954 | + } else{ |
|
1955 | 1955 | //did we already cache the result of this query? |
1956 | 1956 | $cached_results = $this->get_all_from_cache($relationName); |
1957 | 1957 | if ( ! $cached_results ){ |
@@ -1961,11 +1961,11 @@ discard block |
||
1961 | 1961 | foreach($related_model_objects as $related_model_object){ |
1962 | 1962 | $this->cache($relationName, $related_model_object); |
1963 | 1963 | } |
1964 | - }else{ |
|
1964 | + } else{ |
|
1965 | 1965 | $related_model_objects = $cached_results; |
1966 | 1966 | } |
1967 | 1967 | } |
1968 | - }else{ |
|
1968 | + } else{ |
|
1969 | 1969 | //this doesn't exist in the DB, so just get the related things from the cache |
1970 | 1970 | $related_model_objects = $this->get_all_from_cache($relationName); |
1971 | 1971 | } |
@@ -2020,18 +2020,18 @@ discard block |
||
2020 | 2020 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
2021 | 2021 | if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
2022 | 2022 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2023 | - }else{ |
|
2023 | + } else{ |
|
2024 | 2024 | //first, check if we've already cached the result of this query |
2025 | 2025 | $cached_result = $this->get_one_from_cache($relationName); |
2026 | 2026 | if ( ! $cached_result ){ |
2027 | 2027 | |
2028 | 2028 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2029 | 2029 | $this->cache($relationName,$related_model_object); |
2030 | - }else{ |
|
2030 | + } else{ |
|
2031 | 2031 | $related_model_object = $cached_result; |
2032 | 2032 | } |
2033 | 2033 | } |
2034 | - }else{ |
|
2034 | + } else{ |
|
2035 | 2035 | $related_model_object = null; |
2036 | 2036 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
2037 | 2037 | if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
@@ -2063,7 +2063,7 @@ discard block |
||
2063 | 2063 | public function delete_related($relationName,$query_params = array()){ |
2064 | 2064 | if($this->ID()){ |
2065 | 2065 | $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
2066 | - }else{ |
|
2066 | + } else{ |
|
2067 | 2067 | $count = count($this->get_all_from_cache($relationName)); |
2068 | 2068 | $this->clear_cache($relationName,NULL,TRUE); |
2069 | 2069 | } |
@@ -2087,7 +2087,7 @@ discard block |
||
2087 | 2087 | public function delete_related_permanently($relationName,$query_params = array()){ |
2088 | 2088 | if($this->ID()){ |
2089 | 2089 | $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
2090 | - }else{ |
|
2090 | + } else{ |
|
2091 | 2091 | $count = count($this->get_all_from_cache($relationName)); |
2092 | 2092 | } |
2093 | 2093 | $this->clear_cache($relationName,NULL,TRUE); |
@@ -2317,10 +2317,10 @@ discard block |
||
2317 | 2317 | $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
2318 | 2318 | if ( $result instanceof EE_Extra_Meta ){ |
2319 | 2319 | return $result->value(); |
2320 | - }else{ |
|
2320 | + } else{ |
|
2321 | 2321 | return $default; |
2322 | 2322 | } |
2323 | - }else{ |
|
2323 | + } else{ |
|
2324 | 2324 | $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
2325 | 2325 | if($results){ |
2326 | 2326 | $values = array(); |
@@ -2330,7 +2330,7 @@ discard block |
||
2330 | 2330 | } |
2331 | 2331 | } |
2332 | 2332 | return $values; |
2333 | - }else{ |
|
2333 | + } else{ |
|
2334 | 2334 | return $default; |
2335 | 2335 | } |
2336 | 2336 | } |
@@ -2361,7 +2361,7 @@ discard block |
||
2361 | 2361 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2362 | 2362 | } |
2363 | 2363 | } |
2364 | - }else{ |
|
2364 | + } else{ |
|
2365 | 2365 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2366 | 2366 | foreach($extra_meta_objs as $extra_meta_obj){ |
2367 | 2367 | if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
@@ -2388,7 +2388,7 @@ discard block |
||
2388 | 2388 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2389 | 2389 | if($field_we_can_use){ |
2390 | 2390 | return $this->get($field_we_can_use->get_name()); |
2391 | - }else{ |
|
2391 | + } else{ |
|
2392 | 2392 | $first_few_properties = $this->model_field_array(); |
2393 | 2393 | $first_few_properties = array_slice($first_few_properties,0,3); |
2394 | 2394 | $name_parts = array(); |
@@ -2412,7 +2412,7 @@ discard block |
||
2412 | 2412 | if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
2413 | 2413 | //well, if we looked, did we find it in the entity map? |
2414 | 2414 | return TRUE; |
2415 | - }else{ |
|
2415 | + } else{ |
|
2416 | 2416 | return FALSE; |
2417 | 2417 | } |
2418 | 2418 | } |
@@ -2426,7 +2426,7 @@ discard block |
||
2426 | 2426 | public function refresh_from_db(){ |
2427 | 2427 | if( $this->ID() && $this->in_entity_map() ){ |
2428 | 2428 | $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
2429 | - }else{ |
|
2429 | + } else{ |
|
2430 | 2430 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2431 | 2431 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2432 | 2432 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
@@ -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__, ' FILE LOADED', '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | +do_action('AHEE_log', __FILE__, ' FILE LOADED', ''); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Event Espresso |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * ------------------------------------------------------------------------ |
25 | 25 | */ |
26 | 26 | |
27 | -abstract class EE_Base_Class{ |
|
27 | +abstract class EE_Base_Class { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * This is an array of the original properties and values provided during construction |
@@ -117,59 +117,59 @@ discard block |
||
117 | 117 | * @throws EE_Error |
118 | 118 | * @return \EE_Base_Class |
119 | 119 | */ |
120 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){ |
|
120 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) { |
|
121 | 121 | |
122 | - $className=get_class($this); |
|
122 | + $className = get_class($this); |
|
123 | 123 | |
124 | - do_action("AHEE__{$className}__construct",$this,$fieldValues); |
|
125 | - $model=$this->get_model(); |
|
126 | - $model_fields = $model->field_settings( FALSE ); |
|
124 | + do_action("AHEE__{$className}__construct", $this, $fieldValues); |
|
125 | + $model = $this->get_model(); |
|
126 | + $model_fields = $model->field_settings(FALSE); |
|
127 | 127 | // ensure $fieldValues is an array |
128 | - $fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues ); |
|
128 | + $fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues); |
|
129 | 129 | // EEH_Debug_Tools::printr( $fieldValues, '$fieldValues <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
130 | 130 | // verify client code has not passed any invalid field names |
131 | - foreach($fieldValues as $field_name=> $field_value){ |
|
132 | - if( ! isset( $model_fields[ $field_name] ) ){ |
|
133 | - throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields)))); |
|
131 | + foreach ($fieldValues as $field_name=> $field_value) { |
|
132 | + if ( ! isset($model_fields[$field_name])) { |
|
133 | + throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields)))); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | // EEH_Debug_Tools::printr( $model_fields, '$model_fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
137 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
137 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
138 | 138 | |
139 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
139 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
140 | 140 | $this->_dt_frmt = $date_formats[0]; |
141 | 141 | $this->_tm_frmt = $date_formats[1]; |
142 | 142 | } else { |
143 | 143 | //set default formats for date and time |
144 | - $this->_dt_frmt = get_option( 'date_format' ); |
|
145 | - $this->_tm_frmt = get_option( 'time_format' ); |
|
144 | + $this->_dt_frmt = get_option('date_format'); |
|
145 | + $this->_tm_frmt = get_option('time_format'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | //if db model is instantiating |
149 | - if ( $bydb ){ |
|
149 | + if ($bydb) { |
|
150 | 150 | //client code has indicated these field values are from the database |
151 | - foreach( $model_fields as $fieldName => $field ){ |
|
152 | - $this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null ); |
|
151 | + foreach ($model_fields as $fieldName => $field) { |
|
152 | + $this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null); |
|
153 | 153 | } |
154 | 154 | } else { |
155 | 155 | //we're constructing a brand |
156 | 156 | //new instance of the model object. Generally, this means we'll need to do more field validation |
157 | - foreach( $model_fields as $fieldName => $field ){ |
|
158 | - $this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true ); |
|
157 | + foreach ($model_fields as $fieldName => $field) { |
|
158 | + $this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | 162 | //remember what values were passed to this constructor |
163 | 163 | $this->_props_n_values_provided_in_constructor = $fieldValues; |
164 | 164 | //remember in entity mapper |
165 | - if( ! $bydb && $model->has_primary_key_field() && $this->ID() ){ |
|
165 | + if ( ! $bydb && $model->has_primary_key_field() && $this->ID()) { |
|
166 | 166 | $model->add_to_entity_map($this); |
167 | 167 | } |
168 | 168 | //setup all the relations |
169 | - foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
|
170 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
169 | + foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) { |
|
170 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
171 | 171 | $this->_model_relations[$relation_name] = NULL; |
172 | - }else{ |
|
172 | + } else { |
|
173 | 173 | $this->_model_relations[$relation_name] = array(); |
174 | 174 | } |
175 | 175 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * Action done at the end of each model object construction |
178 | 178 | * @param EE_Base_Class $this the model object just created |
179 | 179 | */ |
180 | - do_action( 'AHEE__EE_Base_Class__construct__finished', $this ); |
|
180 | + do_action('AHEE__EE_Base_Class__construct__finished', $this); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param boolean $allow_persist |
198 | 198 | * @return boolean |
199 | 199 | */ |
200 | - public function set_allow_persist( $allow_persist ) { |
|
200 | + public function set_allow_persist($allow_persist) { |
|
201 | 201 | return $this->_allow_persist = $allow_persist; |
202 | 202 | } |
203 | 203 | |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | * @return mixed|null |
212 | 212 | * @throws \EE_Error |
213 | 213 | */ |
214 | - public function get_original( $field_name ){ |
|
215 | - if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
|
216 | - $field_settings = $this->get_model()->field_settings_for( $field_name )){ |
|
217 | - return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
|
218 | - }else{ |
|
214 | + public function get_original($field_name) { |
|
215 | + if (isset($this->_props_n_values_provided_in_constructor[$field_name]) && |
|
216 | + $field_settings = $this->get_model()->field_settings_for($field_name)) { |
|
217 | + return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]); |
|
218 | + } else { |
|
219 | 219 | return NULL; |
220 | 220 | } |
221 | 221 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param EE_Base_Class $obj |
226 | 226 | * @return string |
227 | 227 | */ |
228 | - public function get_class($obj){ |
|
228 | + public function get_class($obj) { |
|
229 | 229 | return get_class($obj); |
230 | 230 | } |
231 | 231 | |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | * @param bool $use_default |
241 | 241 | * @throws \EE_Error |
242 | 242 | */ |
243 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
244 | - $field_obj = $this->get_model()->field_settings_for( $field_name ); |
|
245 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
243 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
244 | + $field_obj = $this->get_model()->field_settings_for($field_name); |
|
245 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
246 | 246 | // if ( method_exists( $field_obj, 'set_timezone' )) { |
247 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
248 | - $field_obj->set_timezone( $this->_timezone ); |
|
249 | - $field_obj->set_date_format( $this->_dt_frmt ); |
|
250 | - $field_obj->set_time_format( $this->_tm_frmt ); |
|
247 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
248 | + $field_obj->set_timezone($this->_timezone); |
|
249 | + $field_obj->set_date_format($this->_dt_frmt); |
|
250 | + $field_obj->set_time_format($this->_tm_frmt); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | $holder_of_value = $field_obj->prepare_for_set($field_value); |
254 | 254 | //should the value be null? |
255 | - if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){ |
|
255 | + if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) { |
|
256 | 256 | $this->_fields[$field_name] = $field_obj->get_default_value(); |
257 | 257 | |
258 | 258 | /** |
@@ -264,26 +264,26 @@ discard block |
||
264 | 264 | */ |
265 | 265 | if ( |
266 | 266 | $field_obj instanceof EE_Datetime_Field |
267 | - && $this->_fields[ $field_name ] !== null |
|
267 | + && $this->_fields[$field_name] !== null |
|
268 | 268 | && ! $this->_fields[$field_name] instanceof DateTime |
269 | 269 | ) { |
270 | - empty( $this->_fields[$field_name] ) |
|
271 | - ? $this->set( $field_name, time() ) |
|
272 | - : $this->set( $field_name, $this->_fields[$field_name] ); |
|
270 | + empty($this->_fields[$field_name]) |
|
271 | + ? $this->set($field_name, time()) |
|
272 | + : $this->set($field_name, $this->_fields[$field_name]); |
|
273 | 273 | } |
274 | 274 | |
275 | - }else{ |
|
275 | + } else { |
|
276 | 276 | $this->_fields[$field_name] = $holder_of_value; |
277 | 277 | } |
278 | 278 | |
279 | 279 | //if we're not in the constructor... |
280 | 280 | //now check if what we set was a primary key |
281 | - if( |
|
281 | + if ( |
|
282 | 282 | //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
283 | 283 | $this->_props_n_values_provided_in_constructor |
284 | 284 | && $field_value |
285 | - && $field_name === self::_get_primary_key_name( get_class( $this ) ) |
|
286 | - ){ |
|
285 | + && $field_name === self::_get_primary_key_name(get_class($this)) |
|
286 | + ) { |
|
287 | 287 | //if so, we want all this object's fields to be filled either with |
288 | 288 | //what we've explicitly set on this model |
289 | 289 | //or what we have in the db |
@@ -291,20 +291,20 @@ discard block |
||
291 | 291 | $fields_on_model = self::_get_model(get_class($this))->field_settings(); |
292 | 292 | |
293 | 293 | $obj_in_db = self::_get_model(get_class($this))->get_one_by_ID($field_value); |
294 | - foreach($fields_on_model as $field_obj){ |
|
295 | - if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
296 | - && $field_obj->get_name() !== $field_name ){ |
|
294 | + foreach ($fields_on_model as $field_obj) { |
|
295 | + if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
296 | + && $field_obj->get_name() !== $field_name) { |
|
297 | 297 | |
298 | - $this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name())); |
|
298 | + $this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name())); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | //oh this model object has an ID? well make sure its in the entity mapper |
302 | 302 | $this->get_model()->add_to_entity_map($this); |
303 | 303 | } |
304 | 304 | //let's unset any cache for this field_name from the $_cached_properties property. |
305 | - $this->_clear_cached_property( $field_name ); |
|
306 | - }else{ |
|
307 | - throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
|
305 | + $this->_clear_cached_property($field_name); |
|
306 | + } else { |
|
307 | + throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name)); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | } |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs. |
322 | 322 | * @throws \EE_Error |
323 | 323 | */ |
324 | - public function set_field_or_extra_meta( $field_name, $field_value ) { |
|
325 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
326 | - $this->set( $field_name, $field_value ); |
|
324 | + public function set_field_or_extra_meta($field_name, $field_value) { |
|
325 | + if ($this->get_model()->has_field($field_name)) { |
|
326 | + $this->set($field_name, $field_value); |
|
327 | 327 | return true; |
328 | 328 | } else { |
329 | 329 | //ensure this object is saved first so that extra meta can be properly related. |
330 | 330 | $this->save(); |
331 | - return $this->update_extra_meta( $field_name, $field_value ); |
|
331 | + return $this->update_extra_meta($field_name, $field_value); |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | * @return mixed|null value for the field if found. null if not found. |
350 | 350 | * @throws \EE_Error |
351 | 351 | */ |
352 | - public function get_field_or_extra_meta( $field_name ) { |
|
353 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
354 | - $column_value = $this->get( $field_name ); |
|
352 | + public function get_field_or_extra_meta($field_name) { |
|
353 | + if ($this->get_model()->has_field($field_name)) { |
|
354 | + $column_value = $this->get($field_name); |
|
355 | 355 | } else { |
356 | 356 | //This isn't a column in the main table, let's see if it is in the extra meta. |
357 | - $column_value = $this->get_extra_meta( $field_name, true, null ); |
|
357 | + $column_value = $this->get_extra_meta($field_name, true, null); |
|
358 | 358 | } |
359 | 359 | return $column_value; |
360 | 360 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | * @return void |
371 | 371 | * @throws \EE_Error |
372 | 372 | */ |
373 | - public function set_timezone( $timezone = '' ) { |
|
374 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
373 | + public function set_timezone($timezone = '') { |
|
374 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
375 | 375 | //make sure we clear all cached properties because they won't be relevant now |
376 | 376 | $this->_clear_cached_properties(); |
377 | 377 | |
378 | 378 | //make sure we update field settings and the date for all EE_Datetime_Fields |
379 | - $model_fields = $this->get_model()->field_settings( false ); |
|
380 | - foreach ( $model_fields as $field_name => $field_obj ) { |
|
381 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
382 | - $field_obj->set_timezone( $this->_timezone ); |
|
383 | - if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) { |
|
384 | - $this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) ); |
|
379 | + $model_fields = $this->get_model()->field_settings(false); |
|
380 | + foreach ($model_fields as $field_name => $field_obj) { |
|
381 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
382 | + $field_obj->set_timezone($this->_timezone); |
|
383 | + if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) { |
|
384 | + $this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone)); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @param string $format should be a format recognizable by PHP date() functions. |
412 | 412 | */ |
413 | - public function set_date_format( $format ) { |
|
413 | + public function set_date_format($format) { |
|
414 | 414 | $this->_dt_frmt = $format; |
415 | 415 | //clear cached_properties because they won't be relevant now. |
416 | 416 | $this->_clear_cached_properties(); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @since 4.6 |
427 | 427 | * @param string $format should be a format recognizable by PHP date() functions. |
428 | 428 | */ |
429 | - public function set_time_format( $format ) { |
|
429 | + public function set_time_format($format) { |
|
430 | 430 | $this->_tm_frmt = $format; |
431 | 431 | //clear cached_properties because they won't be relevant now. |
432 | 432 | $this->_clear_cached_properties(); |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return mixed string|array |
445 | 445 | */ |
446 | - public function get_format( $full = true ) { |
|
447 | - return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt ); |
|
446 | + public function get_format($full = true) { |
|
447 | + return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | |
@@ -462,17 +462,17 @@ discard block |
||
462 | 462 | * @throws EE_Error |
463 | 463 | * @return mixed index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array) |
464 | 464 | */ |
465 | - public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){ |
|
465 | + public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) { |
|
466 | 466 | // its entirely possible that there IS no related object yet in which case there is nothing to cache. |
467 | - if ( ! $object_to_cache instanceof EE_Base_Class ) { |
|
467 | + if ( ! $object_to_cache instanceof EE_Base_Class) { |
|
468 | 468 | return FALSE; |
469 | 469 | } |
470 | 470 | // also get "how" the object is related, or throw an error |
471 | - if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) { |
|
472 | - throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this ))); |
|
471 | + if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) { |
|
472 | + throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this))); |
|
473 | 473 | } |
474 | 474 | // how many things are related ? |
475 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ){ |
|
475 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
476 | 476 | // if it's a "belongs to" relationship, then there's only one related model object eg, if this is a registration, there's only 1 attendee for it |
477 | 477 | // so for these model objects just set it to be cached |
478 | 478 | $this->_model_relations[$relationName] = $object_to_cache; |
@@ -480,26 +480,26 @@ discard block |
||
480 | 480 | } else { |
481 | 481 | // otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type. |
482 | 482 | // eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array |
483 | - if( ! is_array( $this->_model_relations[$relationName] )) { |
|
483 | + if ( ! is_array($this->_model_relations[$relationName])) { |
|
484 | 484 | // if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array |
485 | - $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array(); |
|
485 | + $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array(); |
|
486 | 486 | } |
487 | 487 | // first check for a cache_id which is normally empty |
488 | - if ( ! empty( $cache_id )) { |
|
488 | + if ( ! empty($cache_id)) { |
|
489 | 489 | // if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on |
490 | - $this->_model_relations[$relationName][ $cache_id ] = $object_to_cache; |
|
490 | + $this->_model_relations[$relationName][$cache_id] = $object_to_cache; |
|
491 | 491 | $return = $cache_id; |
492 | - } elseif ( $object_to_cache->ID() ) { |
|
492 | + } elseif ($object_to_cache->ID()) { |
|
493 | 493 | // OR the cached object originally came from the db, so let's just use it's PK for an ID |
494 | - $this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache; |
|
494 | + $this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache; |
|
495 | 495 | $return = $object_to_cache->ID(); |
496 | 496 | } else { |
497 | 497 | // OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID |
498 | 498 | $this->_model_relations[$relationName][] = $object_to_cache; |
499 | 499 | // move the internal pointer to the end of the array |
500 | - end( $this->_model_relations[$relationName] ); |
|
500 | + end($this->_model_relations[$relationName]); |
|
501 | 501 | // and grab the key so that we can return it |
502 | - $return = key( $this->_model_relations[$relationName] ); |
|
502 | + $return = key($this->_model_relations[$relationName]); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | } |
@@ -518,11 +518,11 @@ discard block |
||
518 | 518 | * @return void |
519 | 519 | * @throws \EE_Error |
520 | 520 | */ |
521 | - protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
|
521 | + protected function _set_cached_property($fieldname, $value, $cache_type = NULL) { |
|
522 | 522 | //first make sure this property exists |
523 | 523 | $this->get_model()->field_settings_for($fieldname); |
524 | 524 | |
525 | - $cache_type = empty( $cache_type ) ? 'standard' : $cache_type; |
|
525 | + $cache_type = empty($cache_type) ? 'standard' : $cache_type; |
|
526 | 526 | $this->_cached_properties[$fieldname][$cache_type] = $value; |
527 | 527 | } |
528 | 528 | |
@@ -543,36 +543,36 @@ discard block |
||
543 | 543 | * @return mixed whatever the value for the property is we're retrieving |
544 | 544 | * @throws \EE_Error |
545 | 545 | */ |
546 | - protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) { |
|
546 | + protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) { |
|
547 | 547 | //verify the field exists |
548 | 548 | $this->get_model()->field_settings_for($fieldname); |
549 | 549 | |
550 | 550 | $cache_type = $pretty ? 'pretty' : 'standard'; |
551 | - $cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : ''; |
|
551 | + $cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : ''; |
|
552 | 552 | |
553 | - if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) { |
|
553 | + if (isset($this->_cached_properties[$fieldname][$cache_type])) { |
|
554 | 554 | return $this->_cached_properties[$fieldname][$cache_type]; |
555 | 555 | } |
556 | 556 | |
557 | 557 | $field_obj = $this->get_model()->field_settings_for($fieldname); |
558 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
558 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
559 | 559 | /** |
560 | 560 | * maybe this is EE_Datetime_Field. If so we need to make sure timezone and |
561 | 561 | * formats are correct. |
562 | 562 | */ |
563 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
564 | - $field_obj->set_timezone( $this->_timezone ); |
|
565 | - $field_obj->set_date_format( $this->_dt_frmt, $pretty ); |
|
566 | - $field_obj->set_time_format( $this->_tm_frmt, $pretty ); |
|
563 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
564 | + $field_obj->set_timezone($this->_timezone); |
|
565 | + $field_obj->set_date_format($this->_dt_frmt, $pretty); |
|
566 | + $field_obj->set_time_format($this->_tm_frmt, $pretty); |
|
567 | 567 | } |
568 | 568 | |
569 | - if( ! isset($this->_fields[$fieldname])){ |
|
569 | + if ( ! isset($this->_fields[$fieldname])) { |
|
570 | 570 | $this->_fields[$fieldname] = NULL; |
571 | 571 | } |
572 | 572 | $value = $pretty |
573 | 573 | ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) |
574 | - : $field_obj->prepare_for_get($this->_fields[$fieldname] ); |
|
575 | - $this->_set_cached_property( $fieldname, $value, $cache_type ); |
|
574 | + : $field_obj->prepare_for_get($this->_fields[$fieldname]); |
|
575 | + $this->_set_cached_property($fieldname, $value, $cache_type); |
|
576 | 576 | return $value; |
577 | 577 | } |
578 | 578 | return null; |
@@ -598,9 +598,9 @@ discard block |
||
598 | 598 | * @param string $property_name the property to remove if it exists (from the _cached_properties array) |
599 | 599 | * @return void |
600 | 600 | */ |
601 | - protected function _clear_cached_property( $property_name ) { |
|
602 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) { |
|
603 | - unset( $this->_cached_properties[ $property_name ] ); |
|
601 | + protected function _clear_cached_property($property_name) { |
|
602 | + if (isset($this->_cached_properties[$property_name])) { |
|
603 | + unset($this->_cached_properties[$property_name]); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | |
@@ -614,12 +614,12 @@ discard block |
||
614 | 614 | * @return EE_Base_Class |
615 | 615 | * @throws \EE_Error |
616 | 616 | */ |
617 | - protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){ |
|
617 | + protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) { |
|
618 | 618 | $other_model_instance = self::_get_model_instance_with_name( |
619 | - self::_get_model_classname( $model_name ), |
|
619 | + self::_get_model_classname($model_name), |
|
620 | 620 | $this->_timezone |
621 | 621 | ); |
622 | - return $other_model_instance->ensure_is_obj( $object_or_id ); |
|
622 | + return $other_model_instance->ensure_is_obj($object_or_id); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | |
@@ -636,32 +636,32 @@ discard block |
||
636 | 636 | * @throws EE_Error |
637 | 637 | * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all |
638 | 638 | */ |
639 | - public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){ |
|
639 | + public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) { |
|
640 | 640 | $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
641 | 641 | $index_in_cache = ''; |
642 | - if( ! $relationship_to_model){ |
|
642 | + if ( ! $relationship_to_model) { |
|
643 | 643 | throw new EE_Error( |
644 | 644 | sprintf( |
645 | - __( "There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso' ), |
|
645 | + __("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), |
|
646 | 646 | $relationName, |
647 | - get_class( $this ) |
|
647 | + get_class($this) |
|
648 | 648 | ) |
649 | 649 | ); |
650 | 650 | } |
651 | - if($clear_all){ |
|
651 | + if ($clear_all) { |
|
652 | 652 | $obj_removed = true; |
653 | 653 | $this->_model_relations[$relationName] = null; |
654 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
654 | + }elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
655 | 655 | $obj_removed = $this->_model_relations[$relationName]; |
656 | 656 | $this->_model_relations[$relationName] = null; |
657 | - }else{ |
|
658 | - if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
|
657 | + } else { |
|
658 | + if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) { |
|
659 | 659 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
660 | - if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
|
660 | + if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
661 | 661 | $index_found_at = NULL; |
662 | 662 | //find this object in the array even though it has a different key |
663 | - foreach($this->_model_relations[$relationName] as $index=>$obj){ |
|
664 | - if( |
|
663 | + foreach ($this->_model_relations[$relationName] as $index=>$obj) { |
|
664 | + if ( |
|
665 | 665 | $obj instanceof EE_Base_Class |
666 | 666 | && ( |
667 | 667 | $obj == $object_to_remove_or_index_into_array |
@@ -672,34 +672,34 @@ discard block |
||
672 | 672 | break; |
673 | 673 | } |
674 | 674 | } |
675 | - if($index_found_at){ |
|
675 | + if ($index_found_at) { |
|
676 | 676 | $index_in_cache = $index_found_at; |
677 | - }else{ |
|
677 | + } else { |
|
678 | 678 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
679 | 679 | //if it wasn't in it to begin with. So we're done |
680 | 680 | return $object_to_remove_or_index_into_array; |
681 | 681 | } |
682 | 682 | } |
683 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
683 | + }elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) { |
|
684 | 684 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
685 | - foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
|
686 | - if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
|
685 | + foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) { |
|
686 | + if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) { |
|
687 | 687 | $index_in_cache = $index; |
688 | 688 | } |
689 | 689 | } |
690 | - }else{ |
|
690 | + } else { |
|
691 | 691 | $index_in_cache = $object_to_remove_or_index_into_array; |
692 | 692 | } |
693 | 693 | //supposedly we've found it. But it could just be that the client code |
694 | 694 | //provided a bad index/object |
695 | 695 | if ( |
696 | 696 | isset( |
697 | - $this->_model_relations[ $relationName ], |
|
698 | - $this->_model_relations[ $relationName ][ $index_in_cache ] |
|
697 | + $this->_model_relations[$relationName], |
|
698 | + $this->_model_relations[$relationName][$index_in_cache] |
|
699 | 699 | ) |
700 | 700 | ) { |
701 | - $obj_removed = $this->_model_relations[ $relationName ][ $index_in_cache ]; |
|
702 | - unset( $this->_model_relations[ $relationName ][ $index_in_cache ] ); |
|
701 | + $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
|
702 | + unset($this->_model_relations[$relationName][$index_in_cache]); |
|
703 | 703 | } else { |
704 | 704 | //that thing was never cached anyways. |
705 | 705 | $obj_removed = null; |
@@ -720,24 +720,24 @@ discard block |
||
720 | 720 | * @return boolean TRUE on success, FALSE on fail |
721 | 721 | * @throws \EE_Error |
722 | 722 | */ |
723 | - public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
723 | + public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
724 | 724 | // verify that incoming object is of the correct type |
725 | - $obj_class = 'EE_' . $relationName; |
|
726 | - if ( $newly_saved_object instanceof $obj_class ) { |
|
725 | + $obj_class = 'EE_'.$relationName; |
|
726 | + if ($newly_saved_object instanceof $obj_class) { |
|
727 | 727 | /* @type EE_Base_Class $newly_saved_object*/ |
728 | 728 | // now get the type of relation |
729 | - $relationship_to_model = $this->get_model()->related_settings_for( $relationName ); |
|
729 | + $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
|
730 | 730 | // if this is a 1:1 relationship |
731 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ) { |
|
731 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
732 | 732 | // then just replace the cached object with the newly saved object |
733 | 733 | $this->_model_relations[$relationName] = $newly_saved_object; |
734 | 734 | return TRUE; |
735 | 735 | // or if it's some kind of sordid feral polyamorous relationship... |
736 | - } elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) { |
|
736 | + } elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) { |
|
737 | 737 | // then remove the current cached item |
738 | - unset( $this->_model_relations[$relationName][ $current_cache_id ] ); |
|
738 | + unset($this->_model_relations[$relationName][$current_cache_id]); |
|
739 | 739 | // and cache the newly saved object using it's new ID |
740 | - $this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object; |
|
740 | + $this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object; |
|
741 | 741 | return TRUE; |
742 | 742 | } |
743 | 743 | } |
@@ -753,11 +753,11 @@ discard block |
||
753 | 753 | * @param string $relationName |
754 | 754 | * @return EE_Base_Class |
755 | 755 | */ |
756 | - public function get_one_from_cache($relationName){ |
|
757 | - $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
|
758 | - if(is_array($cached_array_or_object)){ |
|
756 | + public function get_one_from_cache($relationName) { |
|
757 | + $cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null; |
|
758 | + if (is_array($cached_array_or_object)) { |
|
759 | 759 | return array_shift($cached_array_or_object); |
760 | - }else{ |
|
760 | + } else { |
|
761 | 761 | return $cached_array_or_object; |
762 | 762 | } |
763 | 763 | } |
@@ -772,23 +772,23 @@ discard block |
||
772 | 772 | * @throws \EE_Error |
773 | 773 | * @return EE_Base_Class[] NOT necessarily indexed by primary keys |
774 | 774 | */ |
775 | - public function get_all_from_cache($relationName){ |
|
776 | - $objects = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array(); |
|
775 | + public function get_all_from_cache($relationName) { |
|
776 | + $objects = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array(); |
|
777 | 777 | // if the result is not an array, but exists, make it an array |
778 | - $objects = is_array( $objects ) ? $objects : array( $objects ); |
|
778 | + $objects = is_array($objects) ? $objects : array($objects); |
|
779 | 779 | //bugfix for https://events.codebasehq.com/projects/event-espresso/tickets/7143 |
780 | 780 | //basically, if this model object was stored in the session, and these cached model objects |
781 | 781 | //already have IDs, let's make sure they're in their model's entity mapper |
782 | 782 | //otherwise we will have duplicates next time we call |
783 | 783 | // EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() ); |
784 | - $model = EE_Registry::instance()->load_model( $relationName ); |
|
785 | - foreach( $objects as $model_object ){ |
|
786 | - if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){ |
|
784 | + $model = EE_Registry::instance()->load_model($relationName); |
|
785 | + foreach ($objects as $model_object) { |
|
786 | + if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) { |
|
787 | 787 | //ensure its in the map if it has an ID; otherwise it will be added to the map when its saved |
788 | - if( $model_object->ID() ){ |
|
789 | - $model->add_to_entity_map( $model_object ); |
|
788 | + if ($model_object->ID()) { |
|
789 | + $model->add_to_entity_map($model_object); |
|
790 | 790 | } |
791 | - }else{ |
|
791 | + } else { |
|
792 | 792 | throw new EE_Error( |
793 | 793 | sprintf( |
794 | 794 | __( |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | 'event_espresso' |
797 | 797 | ), |
798 | 798 | $relationName, |
799 | - gettype( $model_object ) |
|
799 | + gettype($model_object) |
|
800 | 800 | ) |
801 | 801 | ); |
802 | 802 | } |
@@ -818,15 +818,15 @@ discard block |
||
818 | 818 | * @return array|EE_Base_Class[] |
819 | 819 | * @throws \EE_Error |
820 | 820 | */ |
821 | - public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
822 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
821 | + public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
822 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
823 | 823 | ? $this->get_model()->get_primary_key_field()->get_name() |
824 | 824 | : $field_to_order_by; |
825 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
826 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
825 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
826 | + if (empty($field) || empty($current_value)) { |
|
827 | 827 | return array(); |
828 | 828 | } |
829 | - return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
829 | + return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | |
@@ -843,15 +843,15 @@ discard block |
||
843 | 843 | * @return array|EE_Base_Class[] |
844 | 844 | * @throws \EE_Error |
845 | 845 | */ |
846 | - public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
847 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
846 | + public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
847 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
848 | 848 | ? $this->get_model()->get_primary_key_field()->get_name() |
849 | 849 | : $field_to_order_by; |
850 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
851 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
850 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
851 | + if (empty($field) || empty($current_value)) { |
|
852 | 852 | return array(); |
853 | 853 | } |
854 | - return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
854 | + return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | |
@@ -867,15 +867,15 @@ discard block |
||
867 | 867 | * @return array|EE_Base_Class |
868 | 868 | * @throws \EE_Error |
869 | 869 | */ |
870 | - public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
871 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
870 | + public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
871 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
872 | 872 | ? $this->get_model()->get_primary_key_field()->get_name() |
873 | 873 | : $field_to_order_by; |
874 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
875 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
874 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
875 | + if (empty($field) || empty($current_value)) { |
|
876 | 876 | return array(); |
877 | 877 | } |
878 | - return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select ); |
|
878 | + return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select); |
|
879 | 879 | } |
880 | 880 | |
881 | 881 | |
@@ -891,15 +891,15 @@ discard block |
||
891 | 891 | * @return array|EE_Base_Class |
892 | 892 | * @throws \EE_Error |
893 | 893 | */ |
894 | - public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
895 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() |
|
894 | + public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
895 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() |
|
896 | 896 | ? $this->get_model()->get_primary_key_field()->get_name() |
897 | 897 | : $field_to_order_by; |
898 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
899 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
898 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
899 | + if (empty($field) || empty($current_value)) { |
|
900 | 900 | return array(); |
901 | 901 | } |
902 | - return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select ); |
|
902 | + return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | |
@@ -912,25 +912,25 @@ discard block |
||
912 | 912 | * @param mixed $field_value_from_db |
913 | 913 | * @throws \EE_Error |
914 | 914 | */ |
915 | - public function set_from_db($field_name,$field_value_from_db){ |
|
915 | + public function set_from_db($field_name, $field_value_from_db) { |
|
916 | 916 | $field_obj = $this->get_model()->field_settings_for($field_name); |
917 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
917 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
918 | 918 | //you would think the DB has no NULLs for non-null label fields right? wrong! |
919 | 919 | //eg, a CPT model object could have an entry in the posts table, but no |
920 | 920 | //entry in the meta table. Meaning that all its columns in the meta table |
921 | 921 | //are null! yikes! so when we find one like that, use defaults for its meta columns |
922 | - if($field_value_from_db === NULL ){ |
|
923 | - if( $field_obj->is_nullable()){ |
|
922 | + if ($field_value_from_db === NULL) { |
|
923 | + if ($field_obj->is_nullable()) { |
|
924 | 924 | //if the field allows nulls, then let it be null |
925 | 925 | $field_value = NULL; |
926 | - }else{ |
|
926 | + } else { |
|
927 | 927 | $field_value = $field_obj->get_default_value(); |
928 | 928 | } |
929 | - }else{ |
|
930 | - $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
|
929 | + } else { |
|
930 | + $field_value = $field_obj->prepare_for_set_from_db($field_value_from_db); |
|
931 | 931 | } |
932 | 932 | $this->_fields[$field_name] = $field_value; |
933 | - $this->_clear_cached_property( $field_name ); |
|
933 | + $this->_clear_cached_property($field_name); |
|
934 | 934 | } |
935 | 935 | } |
936 | 936 | |
@@ -946,8 +946,8 @@ discard block |
||
946 | 946 | * @return mixed |
947 | 947 | * @throws \EE_Error |
948 | 948 | */ |
949 | - public function get($field_name, $extra_cache_ref = NULL ){ |
|
950 | - return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref ); |
|
949 | + public function get($field_name, $extra_cache_ref = NULL) { |
|
950 | + return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | |
@@ -980,10 +980,10 @@ discard block |
||
980 | 980 | * just null is returned (because that indicates that likely |
981 | 981 | * this field is nullable). |
982 | 982 | */ |
983 | - public function get_DateTime_object( $field_name ) { |
|
984 | - $field_settings = $this->get_model()->field_settings_for( $field_name ); |
|
983 | + public function get_DateTime_object($field_name) { |
|
984 | + $field_settings = $this->get_model()->field_settings_for($field_name); |
|
985 | 985 | |
986 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
986 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
987 | 987 | EE_Error::add_error( |
988 | 988 | sprintf( |
989 | 989 | __( |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | * @return void |
1016 | 1016 | * @throws \EE_Error |
1017 | 1017 | */ |
1018 | - public function e($field_name, $extra_cache_ref = NULL){ |
|
1018 | + public function e($field_name, $extra_cache_ref = NULL) { |
|
1019 | 1019 | echo $this->get_pretty($field_name, $extra_cache_ref); |
1020 | 1020 | } |
1021 | 1021 | |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | * @return void |
1030 | 1030 | * @throws \EE_Error |
1031 | 1031 | */ |
1032 | - public function f($field_name){ |
|
1033 | - $this->e($field_name,'form_input'); |
|
1032 | + public function f($field_name) { |
|
1033 | + $this->e($field_name, 'form_input'); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | |
@@ -1043,8 +1043,8 @@ discard block |
||
1043 | 1043 | * @return mixed |
1044 | 1044 | * @throws \EE_Error |
1045 | 1045 | */ |
1046 | - public function get_pretty($field_name, $extra_cache_ref = NULL){ |
|
1047 | - return $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref ); |
|
1046 | + public function get_pretty($field_name, $extra_cache_ref = NULL) { |
|
1047 | + return $this->_get_cached_property($field_name, TRUE, $extra_cache_ref); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | |
@@ -1062,36 +1062,36 @@ discard block |
||
1062 | 1062 | * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
1063 | 1063 | * @throws \EE_Error |
1064 | 1064 | */ |
1065 | - protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) { |
|
1065 | + protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) { |
|
1066 | 1066 | |
1067 | - $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1067 | + $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
1068 | 1068 | $in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt; |
1069 | 1069 | |
1070 | 1070 | //validate field for datetime and returns field settings if valid. |
1071 | - $field = $this->_get_dtt_field_settings( $field_name ); |
|
1071 | + $field = $this->_get_dtt_field_settings($field_name); |
|
1072 | 1072 | |
1073 | 1073 | //clear cached property if either formats are not null. |
1074 | - if( $dt_frmt !== null || $tm_frmt !== null ) { |
|
1075 | - $this->_clear_cached_property( $field_name ); |
|
1074 | + if ($dt_frmt !== null || $tm_frmt !== null) { |
|
1075 | + $this->_clear_cached_property($field_name); |
|
1076 | 1076 | //reset format properties because they are used in get() |
1077 | 1077 | $this->_dt_frmt = $in_dt_frmt; |
1078 | 1078 | $this->_tm_frmt = $in_tm_frmt; |
1079 | 1079 | } |
1080 | - if ( $echo ) { |
|
1081 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
1080 | + if ($echo) { |
|
1081 | + $field->set_pretty_date_format($in_dt_frmt); |
|
1082 | 1082 | } else { |
1083 | - $field->set_date_format( $in_dt_frmt ); |
|
1083 | + $field->set_date_format($in_dt_frmt); |
|
1084 | 1084 | } |
1085 | - if ( $echo ) { |
|
1086 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
1085 | + if ($echo) { |
|
1086 | + $field->set_pretty_time_format($in_tm_frmt); |
|
1087 | 1087 | } else { |
1088 | - $field->set_time_format( $in_tm_frmt ); |
|
1088 | + $field->set_time_format($in_tm_frmt); |
|
1089 | 1089 | } |
1090 | 1090 | //set timezone in field object |
1091 | - $field->set_timezone( $this->_timezone ); |
|
1091 | + $field->set_timezone($this->_timezone); |
|
1092 | 1092 | |
1093 | 1093 | //set the output returned |
1094 | - switch ( $date_or_time ) { |
|
1094 | + switch ($date_or_time) { |
|
1095 | 1095 | |
1096 | 1096 | case 'D' : |
1097 | 1097 | $field->set_date_time_output('date'); |
@@ -1106,11 +1106,11 @@ discard block |
||
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | |
1109 | - if ( $echo ) { |
|
1110 | - $this->e( $field_name, $date_or_time ); |
|
1109 | + if ($echo) { |
|
1110 | + $this->e($field_name, $date_or_time); |
|
1111 | 1111 | return ''; |
1112 | 1112 | } |
1113 | - return $this->get( $field_name, $date_or_time ); |
|
1113 | + return $this->get($field_name, $date_or_time); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | * @return string datetime value formatted |
1124 | 1124 | * @throws \EE_Error |
1125 | 1125 | */ |
1126 | - public function get_date( $field_name, $format = NULL ) { |
|
1127 | - return $this->_get_datetime( $field_name, $format, NULL, 'D' ); |
|
1126 | + public function get_date($field_name, $format = NULL) { |
|
1127 | + return $this->_get_datetime($field_name, $format, NULL, 'D'); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | |
@@ -1134,8 +1134,8 @@ discard block |
||
1134 | 1134 | * @param null $format |
1135 | 1135 | * @throws \EE_Error |
1136 | 1136 | */ |
1137 | - public function e_date( $field_name, $format = NULL ) { |
|
1138 | - $this->_get_datetime( $field_name, $format, NULL, 'D', TRUE ); |
|
1137 | + public function e_date($field_name, $format = NULL) { |
|
1138 | + $this->_get_datetime($field_name, $format, NULL, 'D', TRUE); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | |
@@ -1148,8 +1148,8 @@ discard block |
||
1148 | 1148 | * @return string datetime value formatted |
1149 | 1149 | * @throws \EE_Error |
1150 | 1150 | */ |
1151 | - public function get_time( $field_name, $format = NULL ) { |
|
1152 | - return $this->_get_datetime( $field_name, NULL, $format, 'T' ); |
|
1151 | + public function get_time($field_name, $format = NULL) { |
|
1152 | + return $this->_get_datetime($field_name, NULL, $format, 'T'); |
|
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | |
@@ -1159,8 +1159,8 @@ discard block |
||
1159 | 1159 | * @param null $format |
1160 | 1160 | * @throws \EE_Error |
1161 | 1161 | */ |
1162 | - public function e_time( $field_name, $format = NULL ) { |
|
1163 | - $this->_get_datetime( $field_name, NULL, $format, 'T', TRUE ); |
|
1162 | + public function e_time($field_name, $format = NULL) { |
|
1163 | + $this->_get_datetime($field_name, NULL, $format, 'T', TRUE); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | |
@@ -1174,8 +1174,8 @@ discard block |
||
1174 | 1174 | * @return string datetime value formatted |
1175 | 1175 | * @throws \EE_Error |
1176 | 1176 | */ |
1177 | - public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1178 | - return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt ); |
|
1177 | + public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1178 | + return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | 1181 | |
@@ -1186,8 +1186,8 @@ discard block |
||
1186 | 1186 | * @param null $tm_frmt |
1187 | 1187 | * @throws \EE_Error |
1188 | 1188 | */ |
1189 | - public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1190 | - $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1189 | + public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1190 | + $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1191 | 1191 | } |
1192 | 1192 | |
1193 | 1193 | |
@@ -1201,11 +1201,11 @@ discard block |
||
1201 | 1201 | * @throws \EE_Error |
1202 | 1202 | * field name. |
1203 | 1203 | */ |
1204 | - public function get_i18n_datetime( $field_name, $format = NULL ) { |
|
1205 | - $format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format; |
|
1204 | + public function get_i18n_datetime($field_name, $format = NULL) { |
|
1205 | + $format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format; |
|
1206 | 1206 | return date_i18n( |
1207 | 1207 | $format, |
1208 | - EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) |
|
1208 | + EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone) |
|
1209 | 1209 | ); |
1210 | 1210 | } |
1211 | 1211 | |
@@ -1218,14 +1218,14 @@ discard block |
||
1218 | 1218 | * @throws EE_Error |
1219 | 1219 | * @return EE_Datetime_Field |
1220 | 1220 | */ |
1221 | - protected function _get_dtt_field_settings( $field_name ) { |
|
1221 | + protected function _get_dtt_field_settings($field_name) { |
|
1222 | 1222 | $field = $this->get_model()->field_settings_for($field_name); |
1223 | 1223 | |
1224 | 1224 | //check if field is dtt |
1225 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1225 | + if ($field instanceof EE_Datetime_Field) { |
|
1226 | 1226 | return $field; |
1227 | 1227 | } else { |
1228 | - throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) ); |
|
1228 | + throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this)))); |
|
1229 | 1229 | } |
1230 | 1230 | } |
1231 | 1231 | |
@@ -1246,8 +1246,8 @@ discard block |
||
1246 | 1246 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1247 | 1247 | * @throws \EE_Error |
1248 | 1248 | */ |
1249 | - protected function _set_time_for( $time, $fieldname ) { |
|
1250 | - $this->_set_date_time( 'T', $time, $fieldname ); |
|
1249 | + protected function _set_time_for($time, $fieldname) { |
|
1250 | + $this->_set_date_time('T', $time, $fieldname); |
|
1251 | 1251 | } |
1252 | 1252 | |
1253 | 1253 | |
@@ -1260,8 +1260,8 @@ discard block |
||
1260 | 1260 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1261 | 1261 | * @throws \EE_Error |
1262 | 1262 | */ |
1263 | - protected function _set_date_for( $date, $fieldname ) { |
|
1264 | - $this->_set_date_time( 'D', $date, $fieldname ); |
|
1263 | + protected function _set_date_for($date, $fieldname) { |
|
1264 | + $this->_set_date_time('D', $date, $fieldname); |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | |
@@ -1275,26 +1275,26 @@ discard block |
||
1275 | 1275 | * @param string $fieldname the name of the field the date OR time is being set on (must match a EE_Datetime_Field property) |
1276 | 1276 | * @throws \EE_Error |
1277 | 1277 | */ |
1278 | - protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) { |
|
1279 | - $field = $this->_get_dtt_field_settings( $fieldname ); |
|
1280 | - $field->set_timezone( $this->_timezone ); |
|
1281 | - $field->set_date_format( $this->_dt_frmt ); |
|
1282 | - $field->set_time_format( $this->_tm_frmt ); |
|
1283 | - switch ( $what ) { |
|
1278 | + protected function _set_date_time($what = 'T', $datetime_value, $fieldname) { |
|
1279 | + $field = $this->_get_dtt_field_settings($fieldname); |
|
1280 | + $field->set_timezone($this->_timezone); |
|
1281 | + $field->set_date_format($this->_dt_frmt); |
|
1282 | + $field->set_time_format($this->_tm_frmt); |
|
1283 | + switch ($what) { |
|
1284 | 1284 | case 'T' : |
1285 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_time( |
|
1285 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( |
|
1286 | 1286 | $datetime_value, |
1287 | - $this->_fields[ $fieldname ] |
|
1287 | + $this->_fields[$fieldname] |
|
1288 | 1288 | ); |
1289 | 1289 | break; |
1290 | 1290 | case 'D' : |
1291 | - $this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_date( |
|
1291 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( |
|
1292 | 1292 | $datetime_value, |
1293 | - $this->_fields[ $fieldname ] |
|
1293 | + $this->_fields[$fieldname] |
|
1294 | 1294 | ); |
1295 | 1295 | break; |
1296 | 1296 | case 'B' : |
1297 | - $this->_fields[ $fieldname ] = $field->prepare_for_set( $datetime_value ); |
|
1297 | + $this->_fields[$fieldname] = $field->prepare_for_set($datetime_value); |
|
1298 | 1298 | break; |
1299 | 1299 | } |
1300 | 1300 | $this->_clear_cached_property($fieldname); |
@@ -1316,17 +1316,17 @@ discard block |
||
1316 | 1316 | * @throws EE_Error |
1317 | 1317 | * @return string timestamp |
1318 | 1318 | */ |
1319 | - public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) { |
|
1319 | + public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') { |
|
1320 | 1320 | $timezone = EEH_DTT_Helper::get_timezone(); |
1321 | - if ( $timezone === $this->_timezone ) { |
|
1321 | + if ($timezone === $this->_timezone) { |
|
1322 | 1322 | return ''; |
1323 | 1323 | } |
1324 | 1324 | $original_timezone = $this->_timezone; |
1325 | - $this->set_timezone( $timezone ); |
|
1325 | + $this->set_timezone($timezone); |
|
1326 | 1326 | |
1327 | 1327 | $fn = (array) $field_name; |
1328 | - $args = array_merge( $fn, (array) $args ); |
|
1329 | - if ( ! method_exists( $this, $callback ) ) { |
|
1328 | + $args = array_merge($fn, (array) $args); |
|
1329 | + if ( ! method_exists($this, $callback)) { |
|
1330 | 1330 | throw new EE_Error( |
1331 | 1331 | sprintf( |
1332 | 1332 | __( |
@@ -1338,9 +1338,9 @@ discard block |
||
1338 | 1338 | ); |
1339 | 1339 | } |
1340 | 1340 | $args = (array) $args; |
1341 | - $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
|
1341 | + $return = $prepend.call_user_func_array(array($this, $callback), $args).$append; |
|
1342 | 1342 | |
1343 | - $this->set_timezone( $original_timezone ); |
|
1343 | + $this->set_timezone($original_timezone); |
|
1344 | 1344 | return $return; |
1345 | 1345 | } |
1346 | 1346 | |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | * @return boolean | int |
1355 | 1355 | * @throws \EE_Error |
1356 | 1356 | */ |
1357 | - public function delete(){ |
|
1357 | + public function delete() { |
|
1358 | 1358 | /** |
1359 | 1359 | * Called just before the `EE_Base_Class::_delete` method call. |
1360 | 1360 | * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions |
@@ -1363,7 +1363,7 @@ discard block |
||
1363 | 1363 | * |
1364 | 1364 | * @param EE_Base_Class $model_object about to be 'deleted' |
1365 | 1365 | */ |
1366 | - do_action( 'AHEE__EE_Base_Class__delete__before', $this ); |
|
1366 | + do_action('AHEE__EE_Base_Class__delete__before', $this); |
|
1367 | 1367 | $result = $this->_delete(); |
1368 | 1368 | /** |
1369 | 1369 | * Called just after the `EE_Base_Class::_delete` method call. |
@@ -1373,7 +1373,7 @@ discard block |
||
1373 | 1373 | * @param EE_Base_Class $model_object that was just 'deleted' |
1374 | 1374 | * @param boolean $result |
1375 | 1375 | */ |
1376 | - do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result ); |
|
1376 | + do_action('AHEE__EE_Base_Class__delete__end', $this, $result); |
|
1377 | 1377 | return $result; |
1378 | 1378 | } |
1379 | 1379 | |
@@ -1399,22 +1399,22 @@ discard block |
||
1399 | 1399 | * @return bool | int |
1400 | 1400 | * @throws \EE_Error |
1401 | 1401 | */ |
1402 | - public function delete_permanently(){ |
|
1402 | + public function delete_permanently() { |
|
1403 | 1403 | /** |
1404 | 1404 | * Called just before HARD deleting a model object |
1405 | 1405 | * |
1406 | 1406 | * @param EE_Base_Class $model_object about to be 'deleted' |
1407 | 1407 | */ |
1408 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this ); |
|
1409 | - $model=$this->get_model(); |
|
1410 | - $result=$model->delete_permanently_by_ID($this->ID()); |
|
1408 | + do_action('AHEE__EE_Base_Class__delete_permanently__before', $this); |
|
1409 | + $model = $this->get_model(); |
|
1410 | + $result = $model->delete_permanently_by_ID($this->ID()); |
|
1411 | 1411 | $this->refresh_cache_of_related_objects(); |
1412 | 1412 | /** |
1413 | 1413 | * Called just after HARD deleting a model object |
1414 | 1414 | * @param EE_Base_Class $model_object that was just 'deleted' |
1415 | 1415 | * @param boolean $result |
1416 | 1416 | */ |
1417 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result ); |
|
1417 | + do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result); |
|
1418 | 1418 | return $result; |
1419 | 1419 | } |
1420 | 1420 | |
@@ -1427,18 +1427,18 @@ discard block |
||
1427 | 1427 | * @throws \EE_Error |
1428 | 1428 | */ |
1429 | 1429 | public function refresh_cache_of_related_objects() { |
1430 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1431 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1432 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1433 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1430 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1431 | + if ( ! empty($this->_model_relations[$relation_name])) { |
|
1432 | + $related_objects = $this->_model_relations[$relation_name]; |
|
1433 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
1434 | 1434 | //this relation only stores a single model object, not an array |
1435 | 1435 | //but let's make it consistent |
1436 | - $related_objects = array( $related_objects ); |
|
1436 | + $related_objects = array($related_objects); |
|
1437 | 1437 | } |
1438 | - foreach( $related_objects as $related_object ) { |
|
1438 | + foreach ($related_objects as $related_object) { |
|
1439 | 1439 | //only refresh their cache if they're in memory |
1440 | - if( $related_object instanceof EE_Base_Class ) { |
|
1441 | - $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1440 | + if ($related_object instanceof EE_Base_Class) { |
|
1441 | + $related_object->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1442 | 1442 | } |
1443 | 1443 | } |
1444 | 1444 | } |
@@ -1458,17 +1458,17 @@ discard block |
||
1458 | 1458 | * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object |
1459 | 1459 | * isn't allowed to persist (as determined by EE_Base_Class::allow_persist()) |
1460 | 1460 | */ |
1461 | - public function save($set_cols_n_values=array()) { |
|
1461 | + public function save($set_cols_n_values = array()) { |
|
1462 | 1462 | /** |
1463 | 1463 | * Filters the fields we're about to save on the model object |
1464 | 1464 | * |
1465 | 1465 | * @param array $set_cols_n_values |
1466 | 1466 | * @param EE_Base_Class $model_object |
1467 | 1467 | */ |
1468 | - $set_cols_n_values = (array)apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this ); |
|
1468 | + $set_cols_n_values = (array) apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this); |
|
1469 | 1469 | //set attributes as provided in $set_cols_n_values |
1470 | - foreach($set_cols_n_values as $column=>$value){ |
|
1471 | - $this->set($column,$value); |
|
1470 | + foreach ($set_cols_n_values as $column=>$value) { |
|
1471 | + $this->set($column, $value); |
|
1472 | 1472 | } |
1473 | 1473 | /** |
1474 | 1474 | * Saving a model object. |
@@ -1476,8 +1476,8 @@ discard block |
||
1476 | 1476 | * Before we perform a save, this action is fired. |
1477 | 1477 | * @param EE_Base_Class $model_object the model object about to be saved. |
1478 | 1478 | */ |
1479 | - do_action( 'AHEE__EE_Base_Class__save__begin', $this ); |
|
1480 | - if( ! $this->allow_persist() ) { |
|
1479 | + do_action('AHEE__EE_Base_Class__save__begin', $this); |
|
1480 | + if ( ! $this->allow_persist()) { |
|
1481 | 1481 | return 0; |
1482 | 1482 | } |
1483 | 1483 | //now get current attribute values |
@@ -1487,61 +1487,61 @@ discard block |
||
1487 | 1487 | $old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object(); |
1488 | 1488 | $this->get_model()->assume_values_already_prepared_by_model_object(true); |
1489 | 1489 | //does this model have an autoincrement PK? |
1490 | - if($this->get_model()->has_primary_key_field()){ |
|
1491 | - if($this->get_model()->get_primary_key_field()->is_auto_increment()){ |
|
1490 | + if ($this->get_model()->has_primary_key_field()) { |
|
1491 | + if ($this->get_model()->get_primary_key_field()->is_auto_increment()) { |
|
1492 | 1492 | //ok check if it's set, if so: update; if not, insert |
1493 | - if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){ |
|
1494 | - $results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() ); |
|
1493 | + if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) { |
|
1494 | + $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
|
1495 | 1495 | } else { |
1496 | - unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]); |
|
1497 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1498 | - if($results){ |
|
1496 | + unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]); |
|
1497 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1498 | + if ($results) { |
|
1499 | 1499 | //if successful, set the primary key |
1500 | 1500 | //but don't use the normal SET method, because it will check if |
1501 | 1501 | //an item with the same ID exists in the mapper & db, then |
1502 | 1502 | //will find it in the db (because we just added it) and THAT object |
1503 | 1503 | //will get added to the mapper before we can add this one! |
1504 | 1504 | //but if we just avoid using the SET method, all that headache can be avoided |
1505 | - $pk_field_name =self::_get_primary_key_name( get_class($this)); |
|
1505 | + $pk_field_name = self::_get_primary_key_name(get_class($this)); |
|
1506 | 1506 | $this->_fields[$pk_field_name] = $results; |
1507 | 1507 | $this->_clear_cached_property($pk_field_name); |
1508 | - $this->get_model()->add_to_entity_map( $this ); |
|
1508 | + $this->get_model()->add_to_entity_map($this); |
|
1509 | 1509 | $this->_update_cached_related_model_objs_fks(); |
1510 | 1510 | } |
1511 | 1511 | } |
1512 | - }else{//PK is NOT auto-increment |
|
1512 | + } else {//PK is NOT auto-increment |
|
1513 | 1513 | //so check if one like it already exists in the db |
1514 | - if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
|
1515 | - if( WP_DEBUG && ! $this->in_entity_map() ){ |
|
1514 | + if ($this->get_model()->exists_by_ID($this->ID())) { |
|
1515 | + if (WP_DEBUG && ! $this->in_entity_map()) { |
|
1516 | 1516 | throw new EE_Error( |
1517 | 1517 | sprintf( |
1518 | - __( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ), |
|
1518 | + __('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'), |
|
1519 | 1519 | get_class($this), |
1520 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
1521 | - get_class( $this->get_model() ) . '::instance()->get_one_by_ID()', |
|
1520 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
1521 | + get_class($this->get_model()).'::instance()->get_one_by_ID()', |
|
1522 | 1522 | '<br />' |
1523 | 1523 | ) |
1524 | 1524 | ); |
1525 | 1525 | } |
1526 | 1526 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1527 | - }else{ |
|
1527 | + } else { |
|
1528 | 1528 | $results = $this->get_model()->insert($save_cols_n_values); |
1529 | 1529 | $this->_update_cached_related_model_objs_fks(); |
1530 | 1530 | } |
1531 | 1531 | } |
1532 | - }else{//there is NO primary key |
|
1532 | + } else {//there is NO primary key |
|
1533 | 1533 | $already_in_db = false; |
1534 | - foreach($this->get_model()->unique_indexes() as $index){ |
|
1534 | + foreach ($this->get_model()->unique_indexes() as $index) { |
|
1535 | 1535 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
1536 | - if($this->get_model()->exists(array($uniqueness_where_params))){ |
|
1536 | + if ($this->get_model()->exists(array($uniqueness_where_params))) { |
|
1537 | 1537 | $already_in_db = true; |
1538 | 1538 | } |
1539 | 1539 | } |
1540 | - if( $already_in_db ){ |
|
1541 | - $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
|
1542 | - $results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values ); |
|
1543 | - }else{ |
|
1544 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1540 | + if ($already_in_db) { |
|
1541 | + $combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields()); |
|
1542 | + $results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values); |
|
1543 | + } else { |
|
1544 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1545 | 1545 | } |
1546 | 1546 | } |
1547 | 1547 | //restore the old assumption about values being prepared by the model object |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted |
1555 | 1555 | * the new ID (or 0 if an error occurred and it wasn't updated) |
1556 | 1556 | */ |
1557 | - do_action( 'AHEE__EE_Base_Class__save__end', $this, $results ); |
|
1557 | + do_action('AHEE__EE_Base_Class__save__end', $this, $results); |
|
1558 | 1558 | return $results; |
1559 | 1559 | } |
1560 | 1560 | |
@@ -1569,15 +1569,15 @@ discard block |
||
1569 | 1569 | * @return void |
1570 | 1570 | * @throws \EE_Error |
1571 | 1571 | */ |
1572 | - protected function _update_cached_related_model_objs_fks(){ |
|
1573 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){ |
|
1574 | - if( $relation_obj instanceof EE_Has_Many_Relation ){ |
|
1575 | - foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) { |
|
1572 | + protected function _update_cached_related_model_objs_fks() { |
|
1573 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1574 | + if ($relation_obj instanceof EE_Has_Many_Relation) { |
|
1575 | + foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) { |
|
1576 | 1576 | $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( |
1577 | 1577 | $this->get_model()->get_this_model_name() |
1578 | 1578 | ); |
1579 | - $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() ); |
|
1580 | - if( $related_model_obj_in_cache->ID() ){ |
|
1579 | + $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID()); |
|
1580 | + if ($related_model_obj_in_cache->ID()) { |
|
1581 | 1581 | $related_model_obj_in_cache->save(); |
1582 | 1582 | } |
1583 | 1583 | } |
@@ -1598,21 +1598,21 @@ discard block |
||
1598 | 1598 | * @return int ID of new model object on save; 0 on failure+ |
1599 | 1599 | * @throws \EE_Error |
1600 | 1600 | */ |
1601 | - public function save_new_cached_related_model_objs(){ |
|
1601 | + public function save_new_cached_related_model_objs() { |
|
1602 | 1602 | //make sure this has been saved |
1603 | - if( ! $this->ID()){ |
|
1603 | + if ( ! $this->ID()) { |
|
1604 | 1604 | $id = $this->save(); |
1605 | - }else{ |
|
1605 | + } else { |
|
1606 | 1606 | $id = $this->ID(); |
1607 | 1607 | } |
1608 | 1608 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
1609 | - foreach($this->get_model()->relation_settings() as $relationName => $relationObj){ |
|
1609 | + foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) { |
|
1610 | 1610 | |
1611 | 1611 | |
1612 | - if($this->_model_relations[$relationName]){ |
|
1612 | + if ($this->_model_relations[$relationName]) { |
|
1613 | 1613 | //is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation) |
1614 | 1614 | //or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)? |
1615 | - if($relationObj instanceof EE_Belongs_To_Relation){ |
|
1615 | + if ($relationObj instanceof EE_Belongs_To_Relation) { |
|
1616 | 1616 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1617 | 1617 | //but ONLY if it DOES NOT exist in the DB |
1618 | 1618 | /* @var $related_model_obj EE_Base_Class */ |
@@ -1621,8 +1621,8 @@ discard block |
||
1621 | 1621 | $this->_add_relation_to($related_model_obj, $relationName); |
1622 | 1622 | $related_model_obj->save_new_cached_related_model_objs(); |
1623 | 1623 | // } |
1624 | - }else{ |
|
1625 | - foreach($this->_model_relations[$relationName] as $related_model_obj){ |
|
1624 | + } else { |
|
1625 | + foreach ($this->_model_relations[$relationName] as $related_model_obj) { |
|
1626 | 1626 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1627 | 1627 | //but ONLY if it DOES NOT exist in the DB |
1628 | 1628 | // if( ! $related_model_obj->ID()){ |
@@ -1643,8 +1643,8 @@ discard block |
||
1643 | 1643 | * @return \EEM_Base | \EEM_CPT_Base |
1644 | 1644 | */ |
1645 | 1645 | public function get_model() { |
1646 | - $modelName = self::_get_model_classname( get_class($this) ); |
|
1647 | - return self::_get_model_instance_with_name($modelName, $this->_timezone ); |
|
1646 | + $modelName = self::_get_model_classname(get_class($this)); |
|
1647 | + return self::_get_model_instance_with_name($modelName, $this->_timezone); |
|
1648 | 1648 | } |
1649 | 1649 | |
1650 | 1650 | |
@@ -1655,10 +1655,10 @@ discard block |
||
1655 | 1655 | * @return mixed bool|EE_Base_Class|EEM_CPT_Base |
1656 | 1656 | * @throws \EE_Error |
1657 | 1657 | */ |
1658 | - protected static function _get_object_from_entity_mapper($props_n_values, $classname){ |
|
1658 | + protected static function _get_object_from_entity_mapper($props_n_values, $classname) { |
|
1659 | 1659 | //TODO: will not work for Term_Relationships because they have no PK! |
1660 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1661 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
1660 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1661 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
1662 | 1662 | $id = $props_n_values[$primary_id_ref]; |
1663 | 1663 | return self::_get_model($classname)->get_from_entity_map($id); |
1664 | 1664 | } |
@@ -1679,37 +1679,37 @@ discard block |
||
1679 | 1679 | * @return mixed (EE_Base_Class|bool) |
1680 | 1680 | * @throws \EE_Error |
1681 | 1681 | */ |
1682 | - protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) { |
|
1682 | + protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) { |
|
1683 | 1683 | $existing = null; |
1684 | - if ( self::_get_model( $classname )->has_primary_key_field() ) { |
|
1685 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1686 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) |
|
1687 | - && ! empty( $props_n_values[ $primary_id_ref ] ) |
|
1684 | + if (self::_get_model($classname)->has_primary_key_field()) { |
|
1685 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1686 | + if (array_key_exists($primary_id_ref, $props_n_values) |
|
1687 | + && ! empty($props_n_values[$primary_id_ref]) |
|
1688 | 1688 | ) { |
1689 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1690 | - $props_n_values[ $primary_id_ref ] |
|
1689 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1690 | + $props_n_values[$primary_id_ref] |
|
1691 | 1691 | ); |
1692 | 1692 | } |
1693 | - } elseif ( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ) { |
|
1693 | + } elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) { |
|
1694 | 1694 | //no primary key on this model, but there's still a matching item in the DB |
1695 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( |
|
1696 | - self::_get_model( $classname, $timezone )->get_index_primary_key_string( $props_n_values ) |
|
1695 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID( |
|
1696 | + self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values) |
|
1697 | 1697 | ); |
1698 | 1698 | } |
1699 | - if ( $existing ) { |
|
1699 | + if ($existing) { |
|
1700 | 1700 | |
1701 | 1701 | //set date formats if present before setting values |
1702 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
1703 | - $existing->set_date_format( $date_formats[0] ); |
|
1704 | - $existing->set_time_format( $date_formats[1] ); |
|
1702 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
1703 | + $existing->set_date_format($date_formats[0]); |
|
1704 | + $existing->set_time_format($date_formats[1]); |
|
1705 | 1705 | } else { |
1706 | 1706 | //set default formats for date and time |
1707 | - $existing->set_date_format( get_option( 'date_format' ) ); |
|
1708 | - $existing->set_time_format( get_option( 'time_format' ) ); |
|
1707 | + $existing->set_date_format(get_option('date_format')); |
|
1708 | + $existing->set_time_format(get_option('time_format')); |
|
1709 | 1709 | } |
1710 | 1710 | |
1711 | - foreach ( $props_n_values as $property => $field_value ) { |
|
1712 | - $existing->set( $property, $field_value ); |
|
1711 | + foreach ($props_n_values as $property => $field_value) { |
|
1712 | + $existing->set($property, $field_value); |
|
1713 | 1713 | } |
1714 | 1714 | return $existing; |
1715 | 1715 | } else { |
@@ -1727,9 +1727,9 @@ discard block |
||
1727 | 1727 | * @throws EE_Error |
1728 | 1728 | * @return EEM_Base |
1729 | 1729 | */ |
1730 | - protected static function _get_model( $classname, $timezone = NULL ){ |
|
1730 | + protected static function _get_model($classname, $timezone = NULL) { |
|
1731 | 1731 | //find model for this class |
1732 | - if( ! $classname ){ |
|
1732 | + if ( ! $classname) { |
|
1733 | 1733 | throw new EE_Error( |
1734 | 1734 | sprintf( |
1735 | 1735 | __( |
@@ -1740,8 +1740,8 @@ discard block |
||
1740 | 1740 | ) |
1741 | 1741 | ); |
1742 | 1742 | } |
1743 | - $modelName=self::_get_model_classname($classname); |
|
1744 | - return self::_get_model_instance_with_name($modelName, $timezone ); |
|
1743 | + $modelName = self::_get_model_classname($classname); |
|
1744 | + return self::_get_model_instance_with_name($modelName, $timezone); |
|
1745 | 1745 | } |
1746 | 1746 | |
1747 | 1747 | |
@@ -1752,10 +1752,10 @@ discard block |
||
1752 | 1752 | * @param null $timezone |
1753 | 1753 | * @return EEM_Base |
1754 | 1754 | */ |
1755 | - protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
|
1756 | - $model_classname = str_replace( 'EEM_', '', $model_classname ); |
|
1757 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
1758 | - $model->set_timezone( $timezone ); |
|
1755 | + protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) { |
|
1756 | + $model_classname = str_replace('EEM_', '', $model_classname); |
|
1757 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
1758 | + $model->set_timezone($timezone); |
|
1759 | 1759 | return $model; |
1760 | 1760 | } |
1761 | 1761 | |
@@ -1767,10 +1767,10 @@ discard block |
||
1767 | 1767 | * @param null $model_name |
1768 | 1768 | * @return string like EEM_Attendee |
1769 | 1769 | */ |
1770 | - private static function _get_model_classname( $model_name = null){ |
|
1771 | - if(strpos($model_name,"EE_")===0){ |
|
1772 | - $model_classname=str_replace("EE_","EEM_",$model_name); |
|
1773 | - }else{ |
|
1770 | + private static function _get_model_classname($model_name = null) { |
|
1771 | + if (strpos($model_name, "EE_") === 0) { |
|
1772 | + $model_classname = str_replace("EE_", "EEM_", $model_name); |
|
1773 | + } else { |
|
1774 | 1774 | $model_classname = "EEM_".$model_name; |
1775 | 1775 | } |
1776 | 1776 | return $model_classname; |
@@ -1784,16 +1784,16 @@ discard block |
||
1784 | 1784 | * @throws EE_Error |
1785 | 1785 | * @return string |
1786 | 1786 | */ |
1787 | - protected static function _get_primary_key_name( $classname = NULL ){ |
|
1788 | - if( ! $classname){ |
|
1787 | + protected static function _get_primary_key_name($classname = NULL) { |
|
1788 | + if ( ! $classname) { |
|
1789 | 1789 | throw new EE_Error( |
1790 | 1790 | sprintf( |
1791 | - __( "What were you thinking calling _get_primary_key_name(%s)", "event_espresso" ), |
|
1791 | + __("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), |
|
1792 | 1792 | $classname |
1793 | 1793 | ) |
1794 | 1794 | ); |
1795 | 1795 | } |
1796 | - return self::_get_model( $classname )->get_primary_key_field()->get_name(); |
|
1796 | + return self::_get_model($classname)->get_primary_key_field()->get_name(); |
|
1797 | 1797 | } |
1798 | 1798 | |
1799 | 1799 | |
@@ -1807,12 +1807,12 @@ discard block |
||
1807 | 1807 | * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string |
1808 | 1808 | * @throws \EE_Error |
1809 | 1809 | */ |
1810 | - public function ID(){ |
|
1810 | + public function ID() { |
|
1811 | 1811 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1812 | - if( $this->get_model()->has_primary_key_field() ) { |
|
1813 | - return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ]; |
|
1814 | - }else{ |
|
1815 | - return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
|
1812 | + if ($this->get_model()->has_primary_key_field()) { |
|
1813 | + return $this->_fields[self::_get_primary_key_name(get_class($this))]; |
|
1814 | + } else { |
|
1815 | + return $this->get_model()->get_index_primary_key_string($this->_fields); |
|
1816 | 1816 | } |
1817 | 1817 | } |
1818 | 1818 | |
@@ -1830,38 +1830,38 @@ discard block |
||
1830 | 1830 | * @throws EE_Error |
1831 | 1831 | * @return EE_Base_Class the object the relation was added to |
1832 | 1832 | */ |
1833 | - public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){ |
|
1833 | + public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) { |
|
1834 | 1834 | //if this thing exists in the DB, save the relation to the DB |
1835 | - if( $this->ID() ){ |
|
1836 | - $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
|
1835 | + if ($this->ID()) { |
|
1836 | + $otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values); |
|
1837 | 1837 | //clear cache so future get_many_related and get_first_related() return new results. |
1838 | - $this->clear_cache( $relationName, $otherObject, TRUE ); |
|
1839 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1840 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1838 | + $this->clear_cache($relationName, $otherObject, TRUE); |
|
1839 | + if ($otherObject instanceof EE_Base_Class) { |
|
1840 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1841 | 1841 | } |
1842 | 1842 | } else { |
1843 | 1843 | //this thing doesn't exist in the DB, so just cache it |
1844 | - if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
|
1845 | - throw new EE_Error( sprintf( |
|
1846 | - __( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ), |
|
1844 | + if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) { |
|
1845 | + throw new EE_Error(sprintf( |
|
1846 | + __('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'), |
|
1847 | 1847 | $otherObjectModelObjectOrID, |
1848 | - get_class( $this ) |
|
1848 | + get_class($this) |
|
1849 | 1849 | )); |
1850 | 1850 | } else { |
1851 | 1851 | $otherObject = $otherObjectModelObjectOrID; |
1852 | 1852 | } |
1853 | - $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
|
1853 | + $this->cache($relationName, $otherObjectModelObjectOrID, $cache_id); |
|
1854 | 1854 | } |
1855 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1855 | + if ($otherObject instanceof EE_Base_Class) { |
|
1856 | 1856 | //fix the reciprocal relation too |
1857 | - if( $otherObject->ID() ) { |
|
1857 | + if ($otherObject->ID()) { |
|
1858 | 1858 | //its saved so assumed relations exist in the DB, so we can just |
1859 | 1859 | //clear the cache so future queries use the updated info in the DB |
1860 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1860 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true); |
|
1861 | 1861 | } else { |
1862 | 1862 | |
1863 | 1863 | //it's not saved, so it caches relations like this |
1864 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1864 | + $otherObject->cache($this->get_model()->get_this_model_name(), $this); |
|
1865 | 1865 | } |
1866 | 1866 | } |
1867 | 1867 | return $otherObject; |
@@ -1885,17 +1885,17 @@ discard block |
||
1885 | 1885 | * @return EE_Base_Class the relation was removed from |
1886 | 1886 | * @throws \EE_Error |
1887 | 1887 | */ |
1888 | - public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){ |
|
1889 | - if ( $this->ID() ) { |
|
1888 | + public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) { |
|
1889 | + if ($this->ID()) { |
|
1890 | 1890 | //if this exists in the DB, save the relation change to the DB too |
1891 | - $otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
|
1892 | - $this->clear_cache( $relationName, $otherObject ); |
|
1891 | + $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query); |
|
1892 | + $this->clear_cache($relationName, $otherObject); |
|
1893 | 1893 | } else { |
1894 | 1894 | //this doesn't exist in the DB, just remove it from the cache |
1895 | - $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
|
1895 | + $otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID); |
|
1896 | 1896 | } |
1897 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1898 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1897 | + if ($otherObject instanceof EE_Base_Class) { |
|
1898 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1899 | 1899 | } |
1900 | 1900 | return $otherObject; |
1901 | 1901 | } |
@@ -1910,18 +1910,18 @@ discard block |
||
1910 | 1910 | * @return EE_Base_Class |
1911 | 1911 | * @throws \EE_Error |
1912 | 1912 | */ |
1913 | - public function _remove_relations($relationName,$where_query_params = array()){ |
|
1914 | - if ( $this->ID() ) { |
|
1913 | + public function _remove_relations($relationName, $where_query_params = array()) { |
|
1914 | + if ($this->ID()) { |
|
1915 | 1915 | //if this exists in the DB, save the relation change to the DB too |
1916 | - $otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params ); |
|
1917 | - $this->clear_cache( $relationName, null, true ); |
|
1916 | + $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params); |
|
1917 | + $this->clear_cache($relationName, null, true); |
|
1918 | 1918 | } else { |
1919 | 1919 | //this doesn't exist in the DB, just remove it from the cache |
1920 | - $otherObjects = $this->clear_cache( $relationName, null, true ); |
|
1920 | + $otherObjects = $this->clear_cache($relationName, null, true); |
|
1921 | 1921 | } |
1922 | - if( is_array( $otherObjects ) ) { |
|
1923 | - foreach ( $otherObjects as $otherObject ) { |
|
1924 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1922 | + if (is_array($otherObjects)) { |
|
1923 | + foreach ($otherObjects as $otherObject) { |
|
1924 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1925 | 1925 | } |
1926 | 1926 | } |
1927 | 1927 | return $otherObjects; |
@@ -1941,27 +1941,27 @@ discard block |
||
1941 | 1941 | * @throws \EE_Error |
1942 | 1942 | * or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs |
1943 | 1943 | */ |
1944 | - public function get_many_related($relationName,$query_params = array()){ |
|
1945 | - if($this->ID()){ |
|
1944 | + public function get_many_related($relationName, $query_params = array()) { |
|
1945 | + if ($this->ID()) { |
|
1946 | 1946 | //this exists in the DB, so get the related things from either the cache or the DB |
1947 | 1947 | //if there are query parameters, forget about caching the related model objects. |
1948 | - if( $query_params ){ |
|
1948 | + if ($query_params) { |
|
1949 | 1949 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1950 | - }else{ |
|
1950 | + } else { |
|
1951 | 1951 | //did we already cache the result of this query? |
1952 | 1952 | $cached_results = $this->get_all_from_cache($relationName); |
1953 | - if ( ! $cached_results ){ |
|
1953 | + if ( ! $cached_results) { |
|
1954 | 1954 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1955 | 1955 | //if no query parameters were passed, then we got all the related model objects |
1956 | 1956 | //for that relation. We can cache them then. |
1957 | - foreach($related_model_objects as $related_model_object){ |
|
1957 | + foreach ($related_model_objects as $related_model_object) { |
|
1958 | 1958 | $this->cache($relationName, $related_model_object); |
1959 | 1959 | } |
1960 | - }else{ |
|
1960 | + } else { |
|
1961 | 1961 | $related_model_objects = $cached_results; |
1962 | 1962 | } |
1963 | 1963 | } |
1964 | - }else{ |
|
1964 | + } else { |
|
1965 | 1965 | //this doesn't exist in the DB, so just get the related things from the cache |
1966 | 1966 | $related_model_objects = $this->get_all_from_cache($relationName); |
1967 | 1967 | } |
@@ -1979,8 +1979,8 @@ discard block |
||
1979 | 1979 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
1980 | 1980 | * @return int |
1981 | 1981 | */ |
1982 | - public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
1983 | - return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct); |
|
1982 | + public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
1983 | + return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct); |
|
1984 | 1984 | } |
1985 | 1985 | |
1986 | 1986 | |
@@ -1994,7 +1994,7 @@ discard block |
||
1994 | 1994 | * By default, uses primary key (which doesn't make much sense, so you should probably change it) |
1995 | 1995 | * @return int |
1996 | 1996 | */ |
1997 | - public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){ |
|
1997 | + public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) { |
|
1998 | 1998 | return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum); |
1999 | 1999 | } |
2000 | 2000 | |
@@ -2008,33 +2008,33 @@ discard block |
||
2008 | 2008 | * @return EE_Base_Class (not an array, a single object) |
2009 | 2009 | * @throws \EE_Error |
2010 | 2010 | */ |
2011 | - public function get_first_related($relationName,$query_params = array()){ |
|
2012 | - if($this->ID()){//this exists in the DB, get from the cache OR the DB |
|
2011 | + public function get_first_related($relationName, $query_params = array()) { |
|
2012 | + if ($this->ID()) {//this exists in the DB, get from the cache OR the DB |
|
2013 | 2013 | |
2014 | 2014 | //if they've provided some query parameters, don't bother trying to cache the result |
2015 | 2015 | //also make sure we're not caching the result of get_first_related |
2016 | 2016 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
2017 | - if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2018 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2019 | - }else{ |
|
2017 | + if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2018 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2019 | + } else { |
|
2020 | 2020 | //first, check if we've already cached the result of this query |
2021 | 2021 | $cached_result = $this->get_one_from_cache($relationName); |
2022 | - if ( ! $cached_result ){ |
|
2022 | + if ( ! $cached_result) { |
|
2023 | 2023 | |
2024 | 2024 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
2025 | - $this->cache($relationName,$related_model_object); |
|
2026 | - }else{ |
|
2025 | + $this->cache($relationName, $related_model_object); |
|
2026 | + } else { |
|
2027 | 2027 | $related_model_object = $cached_result; |
2028 | 2028 | } |
2029 | 2029 | } |
2030 | - }else{ |
|
2030 | + } else { |
|
2031 | 2031 | $related_model_object = null; |
2032 | 2032 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
2033 | - if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2034 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2033 | + if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
2034 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2035 | 2035 | } |
2036 | 2036 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
2037 | - if( ! $related_model_object){ |
|
2037 | + if ( ! $related_model_object) { |
|
2038 | 2038 | $related_model_object = $this->get_one_from_cache($relationName); |
2039 | 2039 | } |
2040 | 2040 | |
@@ -2056,12 +2056,12 @@ discard block |
||
2056 | 2056 | * @return int how many deleted |
2057 | 2057 | * @throws \EE_Error |
2058 | 2058 | */ |
2059 | - public function delete_related($relationName,$query_params = array()){ |
|
2060 | - if($this->ID()){ |
|
2061 | - $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2062 | - }else{ |
|
2059 | + public function delete_related($relationName, $query_params = array()) { |
|
2060 | + if ($this->ID()) { |
|
2061 | + $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
2062 | + } else { |
|
2063 | 2063 | $count = count($this->get_all_from_cache($relationName)); |
2064 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2064 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2065 | 2065 | } |
2066 | 2066 | return $count; |
2067 | 2067 | } |
@@ -2080,13 +2080,13 @@ discard block |
||
2080 | 2080 | * @return int how many deleted (including those soft deleted) |
2081 | 2081 | * @throws \EE_Error |
2082 | 2082 | */ |
2083 | - public function delete_related_permanently($relationName,$query_params = array()){ |
|
2084 | - if($this->ID()){ |
|
2085 | - $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2086 | - }else{ |
|
2083 | + public function delete_related_permanently($relationName, $query_params = array()) { |
|
2084 | + if ($this->ID()) { |
|
2085 | + $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
2086 | + } else { |
|
2087 | 2087 | $count = count($this->get_all_from_cache($relationName)); |
2088 | 2088 | } |
2089 | - $this->clear_cache($relationName,NULL,TRUE); |
|
2089 | + $this->clear_cache($relationName, NULL, TRUE); |
|
2090 | 2090 | return $count; |
2091 | 2091 | } |
2092 | 2092 | |
@@ -2102,7 +2102,7 @@ discard block |
||
2102 | 2102 | * @param string $field_name property to check |
2103 | 2103 | * @return bool TRUE if existing,FALSE if not. |
2104 | 2104 | */ |
2105 | - public function is_set( $field_name ) { |
|
2105 | + public function is_set($field_name) { |
|
2106 | 2106 | return isset($this->_fields[$field_name]); |
2107 | 2107 | } |
2108 | 2108 | |
@@ -2114,11 +2114,11 @@ discard block |
||
2114 | 2114 | * @throws EE_Error |
2115 | 2115 | * @return bool TRUE if existing, throw EE_Error if not. |
2116 | 2116 | */ |
2117 | - protected function _property_exists( $properties ) { |
|
2117 | + protected function _property_exists($properties) { |
|
2118 | 2118 | |
2119 | - foreach ( (array) $properties as $property_name ) { |
|
2119 | + foreach ((array) $properties as $property_name) { |
|
2120 | 2120 | //first make sure this property exists |
2121 | - if ( ! $this->_fields[ $property_name ] ) { |
|
2121 | + if ( ! $this->_fields[$property_name]) { |
|
2122 | 2122 | throw new EE_Error( |
2123 | 2123 | sprintf( |
2124 | 2124 | __( |
@@ -2146,7 +2146,7 @@ discard block |
||
2146 | 2146 | $fields = $this->get_model()->field_settings(FALSE); |
2147 | 2147 | $properties = array(); |
2148 | 2148 | //remove prepended underscore |
2149 | - foreach ( $fields as $field_name => $settings ) { |
|
2149 | + foreach ($fields as $field_name => $settings) { |
|
2150 | 2150 | $properties[$field_name] = $this->get($field_name); |
2151 | 2151 | } |
2152 | 2152 | return $properties; |
@@ -2176,10 +2176,10 @@ discard block |
||
2176 | 2176 | * @throws EE_Error |
2177 | 2177 | * @return mixed whatever the plugin which calls add_filter decides |
2178 | 2178 | */ |
2179 | - public function __call($methodName,$args){ |
|
2180 | - $className=get_class($this); |
|
2181 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
2182 | - if ( ! has_filter( $tagName ) ) { |
|
2179 | + public function __call($methodName, $args) { |
|
2180 | + $className = get_class($this); |
|
2181 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
2182 | + if ( ! has_filter($tagName)) { |
|
2183 | 2183 | throw new EE_Error( |
2184 | 2184 | sprintf( |
2185 | 2185 | __( |
@@ -2192,7 +2192,7 @@ discard block |
||
2192 | 2192 | ) |
2193 | 2193 | ); |
2194 | 2194 | } |
2195 | - return apply_filters($tagName,null,$this,$args); |
|
2195 | + return apply_filters($tagName, null, $this, $args); |
|
2196 | 2196 | } |
2197 | 2197 | |
2198 | 2198 | |
@@ -2208,7 +2208,7 @@ discard block |
||
2208 | 2208 | * @throws \EE_Error |
2209 | 2209 | * NOTE: if the values haven't changed, returns 0 |
2210 | 2210 | */ |
2211 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){ |
|
2211 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) { |
|
2212 | 2212 | $query_params = array( |
2213 | 2213 | array( |
2214 | 2214 | 'EXM_key' => $meta_key, |
@@ -2216,17 +2216,17 @@ discard block |
||
2216 | 2216 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2217 | 2217 | ) |
2218 | 2218 | ); |
2219 | - if ( $previous_value !== null ) { |
|
2219 | + if ($previous_value !== null) { |
|
2220 | 2220 | $query_params[0]['EXM_value'] = $meta_value; |
2221 | 2221 | } |
2222 | - $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all( $query_params ); |
|
2223 | - if ( ! $existing_rows_like_that ) { |
|
2224 | - return $this->add_extra_meta( $meta_key, $meta_value ); |
|
2222 | + $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
|
2223 | + if ( ! $existing_rows_like_that) { |
|
2224 | + return $this->add_extra_meta($meta_key, $meta_value); |
|
2225 | 2225 | } else { |
2226 | - foreach ( $existing_rows_like_that as $existing_row ) { |
|
2227 | - $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
|
2226 | + foreach ($existing_rows_like_that as $existing_row) { |
|
2227 | + $existing_row->save(array('EXM_value' => $meta_value)); |
|
2228 | 2228 | } |
2229 | - return count( $existing_rows_like_that ); |
|
2229 | + return count($existing_rows_like_that); |
|
2230 | 2230 | } |
2231 | 2231 | } |
2232 | 2232 | |
@@ -2243,8 +2243,8 @@ discard block |
||
2243 | 2243 | * @return boolean |
2244 | 2244 | * @throws \EE_Error |
2245 | 2245 | */ |
2246 | - public function add_extra_meta($meta_key,$meta_value,$unique = false){ |
|
2247 | - if ( $unique ) { |
|
2246 | + public function add_extra_meta($meta_key, $meta_value, $unique = false) { |
|
2247 | + if ($unique) { |
|
2248 | 2248 | $existing_extra_meta = EEM_Extra_Meta::instance()->get_one( |
2249 | 2249 | array( |
2250 | 2250 | array( |
@@ -2254,7 +2254,7 @@ discard block |
||
2254 | 2254 | ) |
2255 | 2255 | ) |
2256 | 2256 | ); |
2257 | - if ( $existing_extra_meta ) { |
|
2257 | + if ($existing_extra_meta) { |
|
2258 | 2258 | return false; |
2259 | 2259 | } |
2260 | 2260 | } |
@@ -2281,7 +2281,7 @@ discard block |
||
2281 | 2281 | * @return int number of extra meta rows deleted |
2282 | 2282 | * @throws \EE_Error |
2283 | 2283 | */ |
2284 | - public function delete_extra_meta($meta_key,$meta_value = NULL){ |
|
2284 | + public function delete_extra_meta($meta_key, $meta_value = NULL) { |
|
2285 | 2285 | $query_params = array( |
2286 | 2286 | array( |
2287 | 2287 | 'EXM_key' => $meta_key, |
@@ -2289,10 +2289,10 @@ discard block |
||
2289 | 2289 | 'EXM_type' => $this->get_model()->get_this_model_name() |
2290 | 2290 | ) |
2291 | 2291 | ); |
2292 | - if ( $meta_value !== null ) { |
|
2292 | + if ($meta_value !== null) { |
|
2293 | 2293 | $query_params[0]['EXM_value'] = $meta_value; |
2294 | 2294 | } |
2295 | - return EEM_Extra_Meta::instance()->delete( $query_params ); |
|
2295 | + return EEM_Extra_Meta::instance()->delete($query_params); |
|
2296 | 2296 | } |
2297 | 2297 | |
2298 | 2298 | |
@@ -2308,25 +2308,25 @@ discard block |
||
2308 | 2308 | * @return mixed single value if $single; array if ! $single |
2309 | 2309 | * @throws \EE_Error |
2310 | 2310 | */ |
2311 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){ |
|
2312 | - if($single){ |
|
2313 | - $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2314 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2311 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) { |
|
2312 | + if ($single) { |
|
2313 | + $result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2314 | + if ($result instanceof EE_Extra_Meta) { |
|
2315 | 2315 | return $result->value(); |
2316 | - }else{ |
|
2316 | + } else { |
|
2317 | 2317 | return $default; |
2318 | 2318 | } |
2319 | - }else{ |
|
2320 | - $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2321 | - if($results){ |
|
2319 | + } else { |
|
2320 | + $results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2321 | + if ($results) { |
|
2322 | 2322 | $values = array(); |
2323 | - foreach($results as $result){ |
|
2324 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2323 | + foreach ($results as $result) { |
|
2324 | + if ($result instanceof EE_Extra_Meta) { |
|
2325 | 2325 | $values[$result->ID()] = $result->value(); |
2326 | 2326 | } |
2327 | 2327 | } |
2328 | 2328 | return $values; |
2329 | - }else{ |
|
2329 | + } else { |
|
2330 | 2330 | return $default; |
2331 | 2331 | } |
2332 | 2332 | } |
@@ -2348,20 +2348,20 @@ discard block |
||
2348 | 2348 | * @return array |
2349 | 2349 | * @throws \EE_Error |
2350 | 2350 | */ |
2351 | - public function all_extra_meta_array($one_of_each_key = true){ |
|
2351 | + public function all_extra_meta_array($one_of_each_key = true) { |
|
2352 | 2352 | $return_array = array(); |
2353 | - if($one_of_each_key){ |
|
2353 | + if ($one_of_each_key) { |
|
2354 | 2354 | $extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key')); |
2355 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2356 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2355 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2356 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2357 | 2357 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2358 | 2358 | } |
2359 | 2359 | } |
2360 | - }else{ |
|
2360 | + } else { |
|
2361 | 2361 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2362 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2363 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2364 | - if( ! isset($return_array[$extra_meta_obj->key()])){ |
|
2362 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2363 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2364 | + if ( ! isset($return_array[$extra_meta_obj->key()])) { |
|
2365 | 2365 | $return_array[$extra_meta_obj->key()] = array(); |
2366 | 2366 | } |
2367 | 2367 | $return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value(); |
@@ -2379,19 +2379,19 @@ discard block |
||
2379 | 2379 | * @return string |
2380 | 2380 | * @throws \EE_Error |
2381 | 2381 | */ |
2382 | - public function name(){ |
|
2382 | + public function name() { |
|
2383 | 2383 | //find a field that's not a text field |
2384 | 2384 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2385 | - if($field_we_can_use){ |
|
2385 | + if ($field_we_can_use) { |
|
2386 | 2386 | return $this->get($field_we_can_use->get_name()); |
2387 | - }else{ |
|
2387 | + } else { |
|
2388 | 2388 | $first_few_properties = $this->model_field_array(); |
2389 | - $first_few_properties = array_slice($first_few_properties,0,3); |
|
2389 | + $first_few_properties = array_slice($first_few_properties, 0, 3); |
|
2390 | 2390 | $name_parts = array(); |
2391 | - foreach( $first_few_properties as $name=> $value ){ |
|
2391 | + foreach ($first_few_properties as $name=> $value) { |
|
2392 | 2392 | $name_parts[] = "$name:$value"; |
2393 | 2393 | } |
2394 | - return implode(",",$name_parts); |
|
2394 | + return implode(",", $name_parts); |
|
2395 | 2395 | } |
2396 | 2396 | } |
2397 | 2397 | |
@@ -2404,11 +2404,11 @@ discard block |
||
2404 | 2404 | * @return boolean |
2405 | 2405 | * @throws \EE_Error |
2406 | 2406 | */ |
2407 | - public function in_entity_map(){ |
|
2408 | - if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
|
2407 | + public function in_entity_map() { |
|
2408 | + if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) { |
|
2409 | 2409 | //well, if we looked, did we find it in the entity map? |
2410 | 2410 | return TRUE; |
2411 | - }else{ |
|
2411 | + } else { |
|
2412 | 2412 | return FALSE; |
2413 | 2413 | } |
2414 | 2414 | } |
@@ -2419,21 +2419,21 @@ discard block |
||
2419 | 2419 | * @throws EE_Error if this model object isn't in the entity mapper (because then you should |
2420 | 2420 | * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE |
2421 | 2421 | */ |
2422 | - public function refresh_from_db(){ |
|
2423 | - if( $this->ID() && $this->in_entity_map() ){ |
|
2424 | - $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
|
2425 | - }else{ |
|
2422 | + public function refresh_from_db() { |
|
2423 | + if ($this->ID() && $this->in_entity_map()) { |
|
2424 | + $this->get_model()->refresh_entity_map_from_db($this->ID()); |
|
2425 | + } else { |
|
2426 | 2426 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2427 | 2427 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2428 | 2428 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
2429 | 2429 | //absolutely nothing in it for this ID |
2430 | - if( WP_DEBUG ) { |
|
2430 | + if (WP_DEBUG) { |
|
2431 | 2431 | throw new EE_Error( |
2432 | 2432 | sprintf( |
2433 | - __( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ), |
|
2433 | + __('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'), |
|
2434 | 2434 | $this->ID(), |
2435 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
2436 | - get_class( $this->get_model() ) . '::instance()->refresh_entity_map()' |
|
2435 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
2436 | + get_class($this->get_model()).'::instance()->refresh_entity_map()' |
|
2437 | 2437 | ) |
2438 | 2438 | ); |
2439 | 2439 | } |
@@ -2447,11 +2447,11 @@ discard block |
||
2447 | 2447 | * (probably a bad assumption they have made, oh well) |
2448 | 2448 | * @return string |
2449 | 2449 | */ |
2450 | - public function __toString(){ |
|
2450 | + public function __toString() { |
|
2451 | 2451 | try { |
2452 | - return sprintf( '%s (%s)', $this->name(), $this->ID() ); |
|
2453 | - } catch ( Exception $e ) { |
|
2454 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
2452 | + return sprintf('%s (%s)', $this->name(), $this->ID()); |
|
2453 | + } catch (Exception $e) { |
|
2454 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
2455 | 2455 | return ''; |
2456 | 2456 | } |
2457 | 2457 | } |
@@ -2487,16 +2487,16 @@ discard block |
||
2487 | 2487 | * @throws \EE_Error |
2488 | 2488 | */ |
2489 | 2489 | public function __sleep() { |
2490 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
2491 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
2492 | - $classname = 'EE_' . $this->get_model()->get_this_model_name(); |
|
2493 | - if( $this->get_one_from_cache( $relation_name ) instanceof $classname && |
|
2494 | - $this->get_one_from_cache( $relation_name )->ID() ) { |
|
2495 | - $this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() ); |
|
2490 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
2491 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
2492 | + $classname = 'EE_'.$this->get_model()->get_this_model_name(); |
|
2493 | + if ($this->get_one_from_cache($relation_name) instanceof $classname && |
|
2494 | + $this->get_one_from_cache($relation_name)->ID()) { |
|
2495 | + $this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID()); |
|
2496 | 2496 | } |
2497 | 2497 | } |
2498 | 2498 | } |
2499 | - return array_keys( get_object_vars( $this ) ); |
|
2499 | + return array_keys(get_object_vars($this)); |
|
2500 | 2500 | } |
2501 | 2501 | |
2502 | 2502 |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * |
863 | 863 | * @param null $field_to_order_by What field is being used as the reference point. |
864 | 864 | * @param array $query_params Any additional conditions on the query. |
865 | - * @param null $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
865 | + * @param string $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
866 | 866 | * you can indicate just the columns you want returned |
867 | 867 | * @return array|EE_Base_Class |
868 | 868 | * @throws \EE_Error |
@@ -886,7 +886,7 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @param null $field_to_order_by What field is being used as the reference point. |
888 | 888 | * @param array $query_params Any additional conditions on the query. |
889 | - * @param null $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
889 | + * @param string $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
890 | 890 | * you can indicate just the column you want returned |
891 | 891 | * @return array|EE_Base_Class |
892 | 892 | * @throws \EE_Error |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | * This method simply returns the RAW unprocessed value for the given property in this class |
956 | 956 | * |
957 | 957 | * @param string $field_name A valid fieldname |
958 | - * @return mixed Whatever the raw value stored on the property is. |
|
958 | + * @return integer|null Whatever the raw value stored on the property is. |
|
959 | 959 | * @throws EE_Error if fieldSettings is misconfigured or the field doesn't exist. |
960 | 960 | */ |
961 | 961 | public function get_raw($field_name) { |
@@ -1055,8 +1055,8 @@ discard block |
||
1055 | 1055 | * |
1056 | 1056 | * @access protected |
1057 | 1057 | * @param string $field_name Field on the instantiated EE_Base_Class child object |
1058 | - * @param null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
1059 | - * @param null $tm_frmt Same as above except this is for time format |
|
1058 | + * @param string|null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
1059 | + * @param null|string $tm_frmt Same as above except this is for time format |
|
1060 | 1060 | * @param string $date_or_time if NULL then both are returned, otherwise "D" = only date and "T" = only time. |
1061 | 1061 | * @param boolean $echo Whether the dtt is echoing using pretty echoing or just returned using vanilla get |
1062 | 1062 | * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
@@ -1242,7 +1242,7 @@ discard block |
||
1242 | 1242 | * sets the time on a datetime property |
1243 | 1243 | * |
1244 | 1244 | * @access protected |
1245 | - * @param string|Datetime $time a valid time string for php datetime functions (or DateTime object) |
|
1245 | + * @param string $time a valid time string for php datetime functions (or DateTime object) |
|
1246 | 1246 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1247 | 1247 | * @throws \EE_Error |
1248 | 1248 | */ |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | * sets the date on a datetime property |
1257 | 1257 | * |
1258 | 1258 | * @access protected |
1259 | - * @param string|DateTime $date a valid date string for php datetime functions ( or DateTime object) |
|
1259 | + * @param string $date a valid date string for php datetime functions ( or DateTime object) |
|
1260 | 1260 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1261 | 1261 | * @throws \EE_Error |
1262 | 1262 | */ |
@@ -1313,6 +1313,7 @@ discard block |
||
1313 | 1313 | * @param mixed (array|string) $args This is the arguments that will be passed to the callback. |
1314 | 1314 | * @param string $prepend You can include something to prepend on the timestamp |
1315 | 1315 | * @param string $append You can include something to append on the timestamp |
1316 | + * @param string $args |
|
1316 | 1317 | * @throws EE_Error |
1317 | 1318 | * @return string timestamp |
1318 | 1319 | */ |
@@ -1351,7 +1352,7 @@ discard block |
||
1351 | 1352 | * This calls the `EE_Base_Class::_delete` method. Child classes wishing to change default behaviour should override |
1352 | 1353 | * `EE_Base_Class::_delete` NOT this class. |
1353 | 1354 | * |
1354 | - * @return boolean | int |
|
1355 | + * @return integer | int |
|
1355 | 1356 | * @throws \EE_Error |
1356 | 1357 | */ |
1357 | 1358 | public function delete(){ |
@@ -1384,7 +1385,7 @@ discard block |
||
1384 | 1385 | * This method is called by the public `EE_Base_Class::delete` method. Any child classes desiring to override default |
1385 | 1386 | * functionality for "delete" (which is to call `permanently_delete`) should override this method NOT `EE_Base_Class::delete` |
1386 | 1387 | * |
1387 | - * @return bool|int |
|
1388 | + * @return boolean |
|
1388 | 1389 | * @throws \EE_Error |
1389 | 1390 | */ |
1390 | 1391 | protected function _delete() { |
@@ -1673,7 +1674,7 @@ discard block |
||
1673 | 1674 | * |
1674 | 1675 | * @param array $props_n_values incoming array of properties and their values |
1675 | 1676 | * @param string $classname the classname of the child class |
1676 | - * @param null $timezone |
|
1677 | + * @param string|null $timezone |
|
1677 | 1678 | * @param array $date_formats incoming date_formats in an array where the first value is the |
1678 | 1679 | * date_format and the second value is the time format |
1679 | 1680 | * @return mixed (EE_Base_Class|bool) |
@@ -1749,7 +1750,7 @@ discard block |
||
1749 | 1750 | /** |
1750 | 1751 | * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee) |
1751 | 1752 | * @param string $model_classname |
1752 | - * @param null $timezone |
|
1753 | + * @param string|null $timezone |
|
1753 | 1754 | * @return EEM_Base |
1754 | 1755 | */ |
1755 | 1756 | protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
@@ -519,17 +519,17 @@ |
||
519 | 519 | |
520 | 520 | //might paypal have changed the taxes? |
521 | 521 | if( $this->_paypal_taxes && $payment_was_itemized ) { |
522 | - // note that we're doing this BEFORE adding shipping; |
|
522 | + // note that we're doing this BEFORE adding shipping; |
|
523 | 523 | // we actually want PayPal's shipping to remain non-taxable |
524 | - $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' ); |
|
525 | - $this->_line_item->set_total_tax_to( |
|
526 | - $transaction_total_line_item, |
|
527 | - (float)$update_info['tax'], |
|
528 | - __( 'Taxes', 'event_espresso' ), |
|
529 | - __( 'Calculated by Paypal', 'event_espresso' ), |
|
530 | - 'paypal_tax' |
|
531 | - ); |
|
532 | - $grand_total_needs_resaving = TRUE; |
|
524 | + $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' ); |
|
525 | + $this->_line_item->set_total_tax_to( |
|
526 | + $transaction_total_line_item, |
|
527 | + (float)$update_info['tax'], |
|
528 | + __( 'Taxes', 'event_espresso' ), |
|
529 | + __( 'Calculated by Paypal', 'event_espresso' ), |
|
530 | + 'paypal_tax' |
|
531 | + ); |
|
532 | + $grand_total_needs_resaving = TRUE; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | $shipping_amount = (float)$update_info[ 'mc_shipping' ]; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return EEG_Paypal_Standard |
69 | 69 | */ |
70 | 70 | public function __construct() { |
71 | - $this->set_uses_separate_IPN_request( true ) ; |
|
71 | + $this->set_uses_separate_IPN_request(true); |
|
72 | 72 | parent::__construct(); |
73 | 73 | } |
74 | 74 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * Also sets the gateway url class variable based on whether debug mode is enabled or not |
79 | 79 | * @param array $settings_array |
80 | 80 | */ |
81 | - public function set_settings($settings_array){ |
|
81 | + public function set_settings($settings_array) { |
|
82 | 82 | parent::set_settings($settings_array); |
83 | 83 | $this->_gateway_url = $this->_debug_mode |
84 | 84 | ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' |
@@ -114,42 +114,42 @@ discard block |
||
114 | 114 | |
115 | 115 | $total_discounts_to_cart_total = $transaction->paid(); |
116 | 116 | //only itemize the order if we're paying for the rest of the order's amount |
117 | - if( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) { |
|
118 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true ); |
|
117 | + if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) { |
|
118 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true); |
|
119 | 119 | //this payment is for the remaining transaction amount, |
120 | 120 | //keep track of exactly how much the itemized order amount equals |
121 | 121 | $itemized_sum = 0; |
122 | 122 | $shipping_previously_added = 0; |
123 | 123 | //so let's show all the line items |
124 | - foreach($total_line_item->get_items() as $line_item){ |
|
125 | - if ( $line_item instanceof EE_Line_Item ) { |
|
124 | + foreach ($total_line_item->get_items() as $line_item) { |
|
125 | + if ($line_item instanceof EE_Line_Item) { |
|
126 | 126 | //it's some kind of discount |
127 | - if( $line_item->total() < 0 ) { |
|
128 | - $total_discounts_to_cart_total += abs( $line_item->total() ); |
|
127 | + if ($line_item->total() < 0) { |
|
128 | + $total_discounts_to_cart_total += abs($line_item->total()); |
|
129 | 129 | $itemized_sum += $line_item->total(); |
130 | 130 | continue; |
131 | 131 | } |
132 | 132 | //dont include shipping again. |
133 | - if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) { |
|
133 | + if (strpos($line_item->code(), 'paypal_shipping_') === 0) { |
|
134 | 134 | $shipping_previously_added = $line_item->total(); |
135 | 135 | continue; |
136 | 136 | } |
137 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
138 | - sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ), |
|
137 | + $redirect_args['item_name_'.$item_num] = substr( |
|
138 | + sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()), |
|
139 | 139 | 0, 127 |
140 | 140 | ); |
141 | - $redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price(); |
|
142 | - $redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity(); |
|
141 | + $redirect_args['amount_'.$item_num] = $line_item->unit_price(); |
|
142 | + $redirect_args['quantity_'.$item_num] = $line_item->quantity(); |
|
143 | 143 | //if we're not letting PayPal calculate shipping, tell them its 0 |
144 | - if ( ! $this->_paypal_shipping ) { |
|
145 | - $redirect_args[ 'shipping_' . $item_num ] = '0'; |
|
146 | - $redirect_args[ 'shipping2_' . $item_num ] = '0'; |
|
144 | + if ( ! $this->_paypal_shipping) { |
|
145 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
146 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
147 | 147 | } |
148 | 148 | $item_num++; |
149 | 149 | $itemized_sum += $line_item->total(); |
150 | 150 | } |
151 | 151 | } |
152 | - $taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item ); |
|
152 | + $taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item); |
|
153 | 153 | //ideally itemized sum equals the transaction total. but if not (which is weird) |
154 | 154 | //and the itemized sum is LESS than the transaction total |
155 | 155 | //add another line item |
@@ -159,47 +159,47 @@ discard block |
||
159 | 159 | $transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added, |
160 | 160 | 2 |
161 | 161 | ); |
162 | - if( $itemized_sum_diff_from_txn_total < 0 ) { |
|
162 | + if ($itemized_sum_diff_from_txn_total < 0) { |
|
163 | 163 | //itemized sum is too big |
164 | - $total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total ); |
|
165 | - } elseif( $itemized_sum_diff_from_txn_total > 0 ) { |
|
166 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
167 | - __( 'Other charges', 'event_espresso' ), 0, 127 ); |
|
168 | - $redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
169 | - $redirect_args[ 'quantity_' . $item_num ] = 1; |
|
164 | + $total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total); |
|
165 | + } elseif ($itemized_sum_diff_from_txn_total > 0) { |
|
166 | + $redirect_args['item_name_'.$item_num] = substr( |
|
167 | + __('Other charges', 'event_espresso'), 0, 127 ); |
|
168 | + $redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
169 | + $redirect_args['quantity_'.$item_num] = 1; |
|
170 | 170 | $item_num++; |
171 | 171 | } |
172 | - if( $total_discounts_to_cart_total > 0 ) { |
|
173 | - $redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total ); |
|
172 | + if ($total_discounts_to_cart_total > 0) { |
|
173 | + $redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total); |
|
174 | 174 | } |
175 | 175 | //add our taxes to the order if we're NOT using PayPal's |
176 | - if( ! $this->_paypal_taxes ){ |
|
176 | + if ( ! $this->_paypal_taxes) { |
|
177 | 177 | $redirect_args['tax_cart'] = $total_line_item->get_total_tax(); |
178 | 178 | } |
179 | 179 | } else { |
180 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false ); |
|
180 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false); |
|
181 | 181 | //partial payment that's not for the remaining amount, so we can't send an itemized list |
182 | - $redirect_args['item_name_' . $item_num] = substr( |
|
183 | - sprintf( __('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code() ), |
|
182 | + $redirect_args['item_name_'.$item_num] = substr( |
|
183 | + sprintf(__('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code()), |
|
184 | 184 | 0, 127 |
185 | 185 | ); |
186 | - $redirect_args['amount_' . $item_num] = $payment->amount(); |
|
187 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
188 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
186 | + $redirect_args['amount_'.$item_num] = $payment->amount(); |
|
187 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
188 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
189 | 189 | $redirect_args['tax_cart'] = '0'; |
190 | 190 | $item_num++; |
191 | 191 | } |
192 | 192 | |
193 | - if($this->_debug_mode){ |
|
194 | - $redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
195 | - $redirect_args['amount_' . $item_num] = 0; |
|
193 | + if ($this->_debug_mode) { |
|
194 | + $redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
195 | + $redirect_args['amount_'.$item_num] = 0; |
|
196 | 196 | $redirect_args['on0_'.$item_num] = 'NOTIFY URL'; |
197 | - $redirect_args['os0_' . $item_num] = $notify_url; |
|
197 | + $redirect_args['os0_'.$item_num] = $notify_url; |
|
198 | 198 | $redirect_args['on1_'.$item_num] = 'RETURN URL'; |
199 | - $redirect_args['os1_' . $item_num] = $return_url; |
|
199 | + $redirect_args['os1_'.$item_num] = $return_url; |
|
200 | 200 | // $redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ? |
201 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
202 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
201 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
202 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | $redirect_args['business'] = $this->_paypal_id; |
@@ -209,14 +209,14 @@ discard block |
||
209 | 209 | $redirect_args['cmd'] = '_cart'; |
210 | 210 | $redirect_args['upload'] = 1; |
211 | 211 | $redirect_args['currency_code'] = $payment->currency_code(); |
212 | - $redirect_args['rm'] = 2;//makes the user return with method=POST |
|
213 | - if($this->_image_url){ |
|
212 | + $redirect_args['rm'] = 2; //makes the user return with method=POST |
|
213 | + if ($this->_image_url) { |
|
214 | 214 | $redirect_args['image_url'] = $this->_image_url; |
215 | 215 | } |
216 | 216 | $redirect_args['no_shipping'] = $this->_shipping_details; |
217 | - $redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this |
|
217 | + $redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this |
|
218 | 218 | |
219 | - $redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this ); |
|
219 | + $redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this); |
|
220 | 220 | |
221 | 221 | $payment->set_redirect_url($this->_gateway_url); |
222 | 222 | $payment->set_redirect_args($redirect_args); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $this->log( |
225 | 225 | array( |
226 | 226 | 'message' => sprintf( |
227 | - __( 'PayPal payment request initiated.', 'event_espresso' ) |
|
227 | + __('PayPal payment request initiated.', 'event_espresso') |
|
228 | 228 | ), |
229 | 229 | 'transaction' => $transaction->model_field_array(), |
230 | 230 | ), |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | * @return \EEI_Payment updated |
245 | 245 | * @throws \EE_Error |
246 | 246 | */ |
247 | - public function handle_payment_update( $update_info, $transaction ){ |
|
247 | + public function handle_payment_update($update_info, $transaction) { |
|
248 | 248 | // verify there's payment data that's been sent |
249 | - if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) { |
|
249 | + if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) { |
|
250 | 250 | // log the results |
251 | 251 | $this->log( |
252 | 252 | array( |
253 | 253 | 'message' => sprintf( |
254 | - __( 'PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso' ) |
|
254 | + __('PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso') |
|
255 | 255 | ), |
256 | 256 | 'update_info' => $update_info, |
257 | 257 | ), |
@@ -259,50 +259,50 @@ discard block |
||
259 | 259 | ); |
260 | 260 | // waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/) |
261 | 261 | // indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes |
262 | - if ( isset( $update_info[ 'tx' ] ) ) { |
|
262 | + if (isset($update_info['tx'])) { |
|
263 | 263 | return $transaction->last_payment(); |
264 | 264 | } else { |
265 | 265 | return null; |
266 | 266 | } |
267 | 267 | } |
268 | - $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
269 | - if ( ! $payment instanceof EEI_Payment ) { |
|
268 | + $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']); |
|
269 | + if ( ! $payment instanceof EEI_Payment) { |
|
270 | 270 | $payment = $transaction->last_payment(); |
271 | 271 | } |
272 | 272 | // ok, then validate the IPN. Even if we've already processed this payment, |
273 | 273 | // let PayPal know we don't want to hear from them anymore! |
274 | - if ( ! $this->validate_ipn( $update_info, $payment ) ) { |
|
274 | + if ( ! $this->validate_ipn($update_info, $payment)) { |
|
275 | 275 | return $payment; |
276 | 276 | } |
277 | 277 | //ok, well let's process this payment then! |
278 | - switch ( $update_info[ 'payment_status' ] ) { |
|
278 | + switch ($update_info['payment_status']) { |
|
279 | 279 | |
280 | 280 | case 'Completed' : |
281 | 281 | $status = $this->_pay_model->approved_status(); |
282 | - $gateway_response = __( 'The payment is approved.', 'event_espresso' ); |
|
282 | + $gateway_response = __('The payment is approved.', 'event_espresso'); |
|
283 | 283 | break; |
284 | 284 | |
285 | 285 | case 'Pending' : |
286 | 286 | $status = $this->_pay_model->pending_status(); |
287 | - $gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' ); |
|
287 | + $gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso'); |
|
288 | 288 | break; |
289 | 289 | |
290 | 290 | case 'Denied' : |
291 | 291 | $status = $this->_pay_model->declined_status(); |
292 | - $gateway_response = __( 'The payment has been declined.', 'event_espresso' ); |
|
292 | + $gateway_response = __('The payment has been declined.', 'event_espresso'); |
|
293 | 293 | break; |
294 | 294 | |
295 | 295 | case 'Expired' : |
296 | 296 | case 'Failed' : |
297 | 297 | $status = $this->_pay_model->failed_status(); |
298 | - $gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' ); |
|
298 | + $gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso'); |
|
299 | 299 | break; |
300 | 300 | |
301 | 301 | case 'Refunded' : |
302 | 302 | case 'Partially_Refunded' : |
303 | 303 | // even though it's a refund, we consider the payment as approved, it just has a negative value |
304 | 304 | $status = $this->_pay_model->approved_status(); |
305 | - $gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' ); |
|
305 | + $gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso'); |
|
306 | 306 | break; |
307 | 307 | |
308 | 308 | case 'Voided' : |
@@ -310,28 +310,28 @@ discard block |
||
310 | 310 | case 'Canceled_Reversal' : |
311 | 311 | default : |
312 | 312 | $status = $this->_pay_model->cancelled_status(); |
313 | - $gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' ); |
|
313 | + $gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso'); |
|
314 | 314 | break; |
315 | 315 | |
316 | 316 | } |
317 | 317 | |
318 | 318 | //check if we've already processed this payment |
319 | - if ( $payment instanceof EEI_Payment ) { |
|
319 | + if ($payment instanceof EEI_Payment) { |
|
320 | 320 | //payment exists. if this has the exact same status and amount, don't bother updating. just return |
321 | - if ( $payment->status() === $status && (float)$payment->amount() === (float)$update_info[ 'mc_gross' ] ) { |
|
321 | + if ($payment->status() === $status && (float) $payment->amount() === (float) $update_info['mc_gross']) { |
|
322 | 322 | // DUPLICATED IPN! dont bother updating transaction foo!; |
323 | 323 | $message_log = sprintf( |
324 | - __( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ), |
|
324 | + __('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'), |
|
325 | 325 | $payment->ID() |
326 | 326 | ); |
327 | 327 | } else { |
328 | 328 | // new payment yippee !!! |
329 | - $payment->set_status( $status ); |
|
330 | - $payment->set_amount( (float)$update_info[ 'mc_gross' ] ); |
|
331 | - $payment->set_gateway_response( $gateway_response ); |
|
332 | - $payment->set_details( $update_info ); |
|
333 | - $payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
334 | - $message_log = __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ); |
|
329 | + $payment->set_status($status); |
|
330 | + $payment->set_amount((float) $update_info['mc_gross']); |
|
331 | + $payment->set_gateway_response($gateway_response); |
|
332 | + $payment->set_details($update_info); |
|
333 | + $payment->set_txn_id_chq_nmbr($update_info['txn_id']); |
|
334 | + $message_log = __('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso'); |
|
335 | 335 | } |
336 | 336 | $this->log( |
337 | 337 | array( |
@@ -343,16 +343,16 @@ discard block |
||
343 | 343 | $payment |
344 | 344 | ); |
345 | 345 | } |
346 | - do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this ); |
|
346 | + do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this); |
|
347 | 347 | // kill request here if this is a refund |
348 | 348 | if ( |
349 | 349 | ( |
350 | - $update_info[ 'payment_status' ] === 'Refunded' |
|
351 | - || $update_info[ 'payment_status' ] === 'Partially_Refunded' |
|
350 | + $update_info['payment_status'] === 'Refunded' |
|
351 | + || $update_info['payment_status'] === 'Partially_Refunded' |
|
352 | 352 | ) |
353 | - && apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) |
|
353 | + && apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true) |
|
354 | 354 | ) { |
355 | - status_header( 200 ); |
|
355 | + status_header(200); |
|
356 | 356 | exit(); |
357 | 357 | } |
358 | 358 | return $payment; |
@@ -369,9 +369,9 @@ discard block |
||
369 | 369 | * @return boolean |
370 | 370 | * @throws \EE_Error |
371 | 371 | */ |
372 | - public function validate_ipn( $update_info, $payment ) { |
|
372 | + public function validate_ipn($update_info, $payment) { |
|
373 | 373 | //allow us to skip validating IPNs with PayPal (useful for testing) |
374 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) { |
|
374 | + if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) { |
|
375 | 375 | return true; |
376 | 376 | } |
377 | 377 | //...otherwise, we actually don't care what the $update_info is, we need to look |
@@ -379,22 +379,22 @@ discard block |
||
379 | 379 | // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. |
380 | 380 | // Instead, read raw POST data from the input stream. |
381 | 381 | // @see https://gist.github.com/xcommerce-gists/3440401 |
382 | - $raw_post_data = file_get_contents( 'php://input' ); |
|
383 | - $raw_post_array = explode( '&', $raw_post_data ); |
|
382 | + $raw_post_data = file_get_contents('php://input'); |
|
383 | + $raw_post_array = explode('&', $raw_post_data); |
|
384 | 384 | $update_info = array(); |
385 | - foreach ( $raw_post_array as $keyval ) { |
|
386 | - $keyval = explode( '=', $keyval ); |
|
387 | - if ( count( $keyval ) === 2 ) { |
|
388 | - $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
385 | + foreach ($raw_post_array as $keyval) { |
|
386 | + $keyval = explode('=', $keyval); |
|
387 | + if (count($keyval) === 2) { |
|
388 | + $update_info[$keyval[0]] = urldecode($keyval[1]); |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' |
392 | 392 | $req = 'cmd=_notify-validate'; |
393 | - $uses_get_magic_quotes = function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() === 1 |
|
393 | + $uses_get_magic_quotes = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() === 1 |
|
394 | 394 | ? true |
395 | 395 | : false; |
396 | - foreach ( $update_info as $key => $value ) { |
|
397 | - $value = $uses_get_magic_quotes ? urlencode( stripslashes( $value ) ) : urlencode( $value ); |
|
396 | + foreach ($update_info as $key => $value) { |
|
397 | + $value = $uses_get_magic_quotes ? urlencode(stripslashes($value)) : urlencode($value); |
|
398 | 398 | $req .= "&$key=$value"; |
399 | 399 | } |
400 | 400 | // HTTP POST the complete, unaltered IPN back to PayPal |
@@ -403,38 +403,38 @@ discard block |
||
403 | 403 | array( |
404 | 404 | 'body' => $req, |
405 | 405 | 'sslverify' => false, |
406 | - 'timeout' => 60 , |
|
406 | + 'timeout' => 60, |
|
407 | 407 | // make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal |
408 | 408 | // plz see: https://github.com/websharks/s2member/issues/610 |
409 | - 'user-agent' => 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(), |
|
409 | + 'user-agent' => 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(), |
|
410 | 410 | 'httpversion' => '1.1' |
411 | 411 | ) |
412 | 412 | ); |
413 | 413 | // then check the response |
414 | 414 | if ( |
415 | - array_key_exists( 'body', $response ) |
|
416 | - && ! is_wp_error( $response ) |
|
417 | - && strcmp( $response[ 'body' ], "VERIFIED" ) === 0 |
|
415 | + array_key_exists('body', $response) |
|
416 | + && ! is_wp_error($response) |
|
417 | + && strcmp($response['body'], "VERIFIED") === 0 |
|
418 | 418 | ) { |
419 | 419 | return true; |
420 | 420 | } |
421 | 421 | // huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly, |
422 | 422 | // or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html |
423 | - if( $response instanceof WP_Error ) { |
|
423 | + if ($response instanceof WP_Error) { |
|
424 | 424 | $error_msg = sprintf( |
425 | - __( 'WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso' ), |
|
425 | + __('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'), |
|
426 | 426 | $response->get_error_code(), |
427 | 427 | $response->get_error_message(), |
428 | - print_r( $response->get_error_data(), true ) |
|
428 | + print_r($response->get_error_data(), true) |
|
429 | 429 | ); |
430 | - } elseif( is_array( $response ) && isset( $response[ 'body' ] ) ) { |
|
431 | - $error_msg = $response[ 'body' ]; |
|
430 | + } elseif (is_array($response) && isset($response['body'])) { |
|
431 | + $error_msg = $response['body']; |
|
432 | 432 | } else { |
433 | - $error_msg = print_r( $response, true ); |
|
433 | + $error_msg = print_r($response, true); |
|
434 | 434 | } |
435 | - $payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $error_msg ) ); |
|
436 | - $payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) ); |
|
437 | - $payment->set_status( EEM_Payment::status_id_failed ); |
|
435 | + $payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $error_msg)); |
|
436 | + $payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response)); |
|
437 | + $payment->set_status(EEM_Payment::status_id_failed); |
|
438 | 438 | // log the results |
439 | 439 | $this->log( |
440 | 440 | array( |
@@ -455,9 +455,9 @@ discard block |
||
455 | 455 | */ |
456 | 456 | protected function _process_response_url() { |
457 | 457 | EE_Registry::instance()->load_helper('URL'); |
458 | - if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) { |
|
458 | + if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { |
|
459 | 459 | $url = is_ssl() ? 'https://' : 'http://'; |
460 | - $url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' ); |
|
460 | + $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
461 | 461 | $url .= EEH_URL::filter_input_server_url(); |
462 | 462 | } else { |
463 | 463 | $url = 'unknown'; |
@@ -474,12 +474,12 @@ discard block |
||
474 | 474 | * @param EEI_Payment $payment |
475 | 475 | * @throws \EE_Error |
476 | 476 | */ |
477 | - public function update_txn_based_on_payment( $payment ) { |
|
477 | + public function update_txn_based_on_payment($payment) { |
|
478 | 478 | $update_info = $payment->details(); |
479 | 479 | /** @var EE_Transaction $transaction */ |
480 | 480 | $transaction = $payment->transaction(); |
481 | - $payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false ); |
|
482 | - if( ! $transaction ){ |
|
481 | + $payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false); |
|
482 | + if ( ! $transaction) { |
|
483 | 483 | $this->log( |
484 | 484 | __( |
485 | 485 | 'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', |
@@ -489,10 +489,10 @@ discard block |
||
489 | 489 | ); |
490 | 490 | return; |
491 | 491 | } |
492 | - if( |
|
493 | - ! is_array( $update_info ) |
|
494 | - || ! isset( $update_info[ 'mc_shipping' ] ) |
|
495 | - || ! isset( $update_info[ 'tax' ] ) |
|
492 | + if ( |
|
493 | + ! is_array($update_info) |
|
494 | + || ! isset($update_info['mc_shipping']) |
|
495 | + || ! isset($update_info['tax']) |
|
496 | 496 | ) { |
497 | 497 | $this->log( |
498 | 498 | array( |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | ); |
508 | 508 | return; |
509 | 509 | } |
510 | - if( $payment->status() !== $this->_pay_model->approved_status() ) { |
|
510 | + if ($payment->status() !== $this->_pay_model->approved_status()) { |
|
511 | 511 | $this->log( |
512 | 512 | array( |
513 | 513 | 'message' => __( |
@@ -526,44 +526,44 @@ discard block |
||
526 | 526 | $transaction_total_line_item = $transaction->total_line_item(); |
527 | 527 | |
528 | 528 | //might paypal have changed the taxes? |
529 | - if( $this->_paypal_taxes && $payment_was_itemized ) { |
|
529 | + if ($this->_paypal_taxes && $payment_was_itemized) { |
|
530 | 530 | // note that we're doing this BEFORE adding shipping; |
531 | 531 | // we actually want PayPal's shipping to remain non-taxable |
532 | - $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' ); |
|
532 | + $this->_line_item->set_line_items_taxable($transaction_total_line_item, true, 'paypal_shipping'); |
|
533 | 533 | $this->_line_item->set_total_tax_to( |
534 | 534 | $transaction_total_line_item, |
535 | - (float)$update_info['tax'], |
|
536 | - __( 'Taxes', 'event_espresso' ), |
|
537 | - __( 'Calculated by Paypal', 'event_espresso' ), |
|
535 | + (float) $update_info['tax'], |
|
536 | + __('Taxes', 'event_espresso'), |
|
537 | + __('Calculated by Paypal', 'event_espresso'), |
|
538 | 538 | 'paypal_tax' |
539 | 539 | ); |
540 | 540 | $grand_total_needs_resaving = TRUE; |
541 | 541 | } |
542 | 542 | |
543 | - $shipping_amount = (float)$update_info[ 'mc_shipping' ]; |
|
543 | + $shipping_amount = (float) $update_info['mc_shipping']; |
|
544 | 544 | //might paypal have added shipping? |
545 | - if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){ |
|
545 | + if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) { |
|
546 | 546 | $this->_line_item->add_unrelated_item( |
547 | 547 | $transaction_total_line_item, |
548 | - sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ), |
|
548 | + sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()), |
|
549 | 549 | $shipping_amount, |
550 | 550 | __('Shipping charges calculated by Paypal', 'event_espresso'), |
551 | 551 | 1, |
552 | 552 | false, |
553 | - 'paypal_shipping_' . $transaction->ID() |
|
553 | + 'paypal_shipping_'.$transaction->ID() |
|
554 | 554 | ); |
555 | 555 | $grand_total_needs_resaving = true; |
556 | 556 | } |
557 | 557 | |
558 | - if( $grand_total_needs_resaving ){ |
|
559 | - $transaction_total_line_item->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
558 | + if ($grand_total_needs_resaving) { |
|
559 | + $transaction_total_line_item->save_this_and_descendants_to_txn($transaction->ID()); |
|
560 | 560 | /** @var EE_Registration_Processor $registration_processor */ |
561 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
562 | - $registration_processor->update_registration_final_prices( $transaction ); |
|
561 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
562 | + $registration_processor->update_registration_final_prices($transaction); |
|
563 | 563 | } |
564 | 564 | $this->log( |
565 | 565 | array( |
566 | - 'message' => __( 'Updated transaction related to payment', 'event_espresso' ), |
|
566 | + 'message' => __('Updated transaction related to payment', 'event_espresso'), |
|
567 | 567 | 'url' => $this->_process_response_url(), |
568 | 568 | 'transaction (updated)' => $transaction->model_field_array(), |
569 | 569 | 'payment (updated)' => $payment->model_field_array(), |
@@ -151,8 +151,8 @@ |
||
151 | 151 | } |
152 | 152 | $query_params = $this->_disable_default_where_conditions_on_query_param($query_params); |
153 | 153 | $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name() |
154 | - . "." |
|
155 | - . $this->get_this_model()->get_primary_key_field()->get_name(); |
|
154 | + . "." |
|
155 | + . $this->get_this_model()->get_primary_key_field()->get_name(); |
|
156 | 156 | $model_object_id = $this->_get_model_object_id( $model_object_or_id ); |
157 | 157 | $query_params[0][$query_param_where_this_model_pk] = $model_object_id; |
158 | 158 | return $this->get_other_model()->get_all($query_params); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @subpackage core |
14 | 14 | * @author Michael Nelson |
15 | 15 | */ |
16 | -abstract class EE_Model_Relation_Base{ |
|
16 | +abstract class EE_Model_Relation_Base { |
|
17 | 17 | /** |
18 | 18 | * The model name of which this relation is a component (ie, the model that called new EE_Model_Relation_Base) |
19 | 19 | * @var string eg Event, Question_Group, Registration |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * @param boolean $block_deletes if there are related models across this relation, block (prevent and add an error) the deletion of this model |
49 | 49 | * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
50 | 50 | */ |
51 | - public function __construct($block_deletes, $blocking_delete_error_message){ |
|
51 | + public function __construct($block_deletes, $blocking_delete_error_message) { |
|
52 | 52 | $this->_blocking_delete = $block_deletes; |
53 | - $this->_blocking_delete_error_message=$blocking_delete_error_message; |
|
53 | + $this->_blocking_delete_error_message = $blocking_delete_error_message; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | * @param $other_model_name |
61 | 61 | * @throws EE_Error |
62 | 62 | */ |
63 | - public function _construct_finalize_set_models($this_model_name, $other_model_name){ |
|
63 | + public function _construct_finalize_set_models($this_model_name, $other_model_name) { |
|
64 | 64 | $this->_this_model_name = $this_model_name; |
65 | 65 | $this->_other_model_name = $other_model_name; |
66 | - if(is_string($this->_blocking_delete)){ |
|
66 | + if (is_string($this->_blocking_delete)) { |
|
67 | 67 | throw new EE_Error(sprintf(__("When instantiating the relation of type %s from %s to %s, the \$block_deletes argument should be a boolean, not a string (%s)", "event_espresso"), |
68 | - get_class($this),$this_model_name,$other_model_name,$this->_blocking_delete)); |
|
68 | + get_class($this), $this_model_name, $other_model_name, $this->_blocking_delete)); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * Gets the model where this relation is defined. |
76 | 76 | * @return EEM_Base |
77 | 77 | */ |
78 | - public function get_this_model(){ |
|
78 | + public function get_this_model() { |
|
79 | 79 | return $this->_get_model($this->_this_model_name); |
80 | 80 | } |
81 | 81 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * this relation object was defined on get_this_model(), get_other_model() is the other one) |
87 | 87 | * @return EEM_Base |
88 | 88 | */ |
89 | - public function get_other_model(){ |
|
89 | + public function get_other_model() { |
|
90 | 90 | return $this->_get_model($this->_other_model_name); |
91 | 91 | } |
92 | 92 | |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | * @param string $model_name like Event, Question_Group, etc. omit the EEM_ |
98 | 98 | * @return EEM_Base |
99 | 99 | */ |
100 | - protected function _get_model($model_name){ |
|
101 | - $modelInstance = EE_Registry::instance()->load_model( $model_name ); |
|
102 | - $modelInstance->set_timezone( $this->_timezone ); |
|
100 | + protected function _get_model($model_name) { |
|
101 | + $modelInstance = EE_Registry::instance()->load_model($model_name); |
|
102 | + $modelInstance->set_timezone($this->_timezone); |
|
103 | 103 | return $modelInstance; |
104 | 104 | } |
105 | 105 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * entirely possible that relations may be called from a model and we need to make sure those relations have their timezone set correctly. |
110 | 110 | * @param string $timezone timezone to set. |
111 | 111 | */ |
112 | - public function set_timezone( $timezone ) { |
|
113 | - if($timezone !== NULL){ |
|
112 | + public function set_timezone($timezone) { |
|
113 | + if ($timezone !== NULL) { |
|
114 | 114 | $this->_timezone = $timezone; |
115 | 115 | } |
116 | 116 | } |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @param string $extra_join_sql |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - protected function _left_join($other_table,$other_table_alias,$other_table_column,$this_table_alias,$this_table_join_column, $extra_join_sql = ''){ |
|
130 | - return " LEFT JOIN ".$other_table." AS ".$other_table_alias. " ON ".$other_table_alias.".".$other_table_column."=".$this_table_alias.".".$this_table_join_column. ($extra_join_sql ? " AND $extra_join_sql" : ''); |
|
129 | + protected function _left_join($other_table, $other_table_alias, $other_table_column, $this_table_alias, $this_table_join_column, $extra_join_sql = '') { |
|
130 | + return " LEFT JOIN ".$other_table." AS ".$other_table_alias." ON ".$other_table_alias.".".$other_table_column."=".$this_table_alias.".".$this_table_join_column.($extra_join_sql ? " AND $extra_join_sql" : ''); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -145,15 +145,15 @@ discard block |
||
145 | 145 | * @return EE_Base_Class[] |
146 | 146 | * @throws \EE_Error |
147 | 147 | */ |
148 | - public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false ){ |
|
149 | - if( $values_already_prepared_by_model_object !== false ) { |
|
150 | - EE_Error::doing_it_wrong( 'EE_Model_Relation_Base::get_all_related', __( 'The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso' ), '4.8.1' ); |
|
148 | + public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) { |
|
149 | + if ($values_already_prepared_by_model_object !== false) { |
|
150 | + EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related', __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), '4.8.1'); |
|
151 | 151 | } |
152 | 152 | $query_params = $this->_disable_default_where_conditions_on_query_param($query_params); |
153 | 153 | $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name() |
154 | 154 | . "." |
155 | 155 | . $this->get_this_model()->get_primary_key_field()->get_name(); |
156 | - $model_object_id = $this->_get_model_object_id( $model_object_or_id ); |
|
156 | + $model_object_id = $this->_get_model_object_id($model_object_or_id); |
|
157 | 157 | $query_params[0][$query_param_where_this_model_pk] = $model_object_id; |
158 | 158 | return $this->get_other_model()->get_all($query_params); |
159 | 159 | } |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | * @param string $query_params |
166 | 166 | * @return array |
167 | 167 | */ |
168 | - protected function _disable_default_where_conditions_on_query_param($query_params){ |
|
169 | - if( ! isset($query_params['default_where_conditions'])){ |
|
170 | - $query_params['default_where_conditions']='none'; |
|
168 | + protected function _disable_default_where_conditions_on_query_param($query_params) { |
|
169 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
170 | + $query_params['default_where_conditions'] = 'none'; |
|
171 | 171 | } |
172 | 172 | return $query_params; |
173 | 173 | } |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | * @return int of how many related models got deleted |
186 | 186 | * @throws \EE_Error |
187 | 187 | */ |
188 | - public function delete_all_related($model_object_or_id,$query_params = array()){ |
|
188 | + public function delete_all_related($model_object_or_id, $query_params = array()) { |
|
189 | 189 | //for each thing we would delete, |
190 | - $related_model_objects = $this->get_all_related($model_object_or_id,$query_params); |
|
190 | + $related_model_objects = $this->get_all_related($model_object_or_id, $query_params); |
|
191 | 191 | //determine if it's blocked by anything else before it can be deleted |
192 | 192 | $deleted_count = 0; |
193 | - foreach($related_model_objects as $related_model_object){ |
|
193 | + foreach ($related_model_objects as $related_model_object) { |
|
194 | 194 | $delete_is_blocked = $this->get_other_model()->delete_is_blocked_by_related_models($related_model_object, $model_object_or_id); |
195 | 195 | /* @var $model_object_or_id EE_Base_Class */ |
196 | - if( ! $delete_is_blocked ){ |
|
196 | + if ( ! $delete_is_blocked) { |
|
197 | 197 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
198 | 198 | $related_model_object->delete(); |
199 | 199 | $deleted_count++; |
@@ -215,27 +215,27 @@ discard block |
||
215 | 215 | * @return int of how many related models got deleted |
216 | 216 | * @throws \EE_Error |
217 | 217 | */ |
218 | - public function delete_related_permanently($model_object_or_id,$query_params = array()){ |
|
218 | + public function delete_related_permanently($model_object_or_id, $query_params = array()) { |
|
219 | 219 | //for each thing we would delete, |
220 | - $related_model_objects = $this->get_all_related($model_object_or_id,$query_params); |
|
220 | + $related_model_objects = $this->get_all_related($model_object_or_id, $query_params); |
|
221 | 221 | //determine if it's blocked by anything else before it can be deleted |
222 | 222 | $deleted_count = 0; |
223 | - foreach($related_model_objects as $related_model_object){ |
|
223 | + foreach ($related_model_objects as $related_model_object) { |
|
224 | 224 | $delete_is_blocked = $this->get_other_model()->delete_is_blocked_by_related_models($related_model_object, $model_object_or_id); |
225 | 225 | /* @var $model_object_or_id EE_Base_Class */ |
226 | - if( $related_model_object instanceof EE_Soft_Delete_Base_Class ){ |
|
226 | + if ($related_model_object instanceof EE_Soft_Delete_Base_Class) { |
|
227 | 227 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
228 | 228 | $deleted_count++; |
229 | - if( ! $delete_is_blocked ){ |
|
229 | + if ( ! $delete_is_blocked) { |
|
230 | 230 | $related_model_object->delete_permanently(); |
231 | - }else{ |
|
231 | + } else { |
|
232 | 232 | //delete is blocked |
233 | 233 | //brent and darren, in this case, wanted to just soft delete it then |
234 | 234 | $related_model_object->delete(); |
235 | 235 | } |
236 | - }else{ |
|
236 | + } else { |
|
237 | 237 | //its not a soft-deletable thing anyways. do the normal logic. |
238 | - if( ! $delete_is_blocked ){ |
|
238 | + if ( ! $delete_is_blocked) { |
|
239 | 239 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
240 | 240 | $related_model_object->delete(); |
241 | 241 | $deleted_count++; |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | */ |
256 | 256 | protected function _get_model_object_id($model_object_or_id) { |
257 | 257 | $model_object_id = $model_object_or_id; |
258 | - if($model_object_or_id instanceof EE_Base_Class){ |
|
258 | + if ($model_object_or_id instanceof EE_Base_Class) { |
|
259 | 259 | $model_object_id = $model_object_or_id->ID(); |
260 | 260 | } |
261 | - if( ! $model_object_id){ |
|
262 | - throw new EE_Error(sprintf(__("Sorry, we cant get the related %s model objects to %s model object before it has an ID. You can solve that by just saving it before trying to get its related model objects", "event_espresso"),$this->get_other_model()->get_this_model_name(),$this->get_this_model()->get_this_model_name())); |
|
261 | + if ( ! $model_object_id) { |
|
262 | + throw new EE_Error(sprintf(__("Sorry, we cant get the related %s model objects to %s model object before it has an ID. You can solve that by just saving it before trying to get its related model objects", "event_espresso"), $this->get_other_model()->get_this_model_name(), $this->get_this_model()->get_this_model_name())); |
|
263 | 263 | } |
264 | 264 | return $model_object_id; |
265 | 265 | } |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | * @return EE_Base_Class[] |
314 | 314 | * @throws \EE_Error |
315 | 315 | */ |
316 | - public function remove_relations($this_obj_or_id,$where_query_param = array()){ |
|
317 | - $related_things = $this->get_all_related($this_obj_or_id,array($where_query_param)); |
|
316 | + public function remove_relations($this_obj_or_id, $where_query_param = array()) { |
|
317 | + $related_things = $this->get_all_related($this_obj_or_id, array($where_query_param)); |
|
318 | 318 | $objs_removed = array(); |
319 | - foreach($related_things as $related_thing){ |
|
319 | + foreach ($related_things as $related_thing) { |
|
320 | 320 | $objs_removed[] = $this->remove_relation_to($this_obj_or_id, $related_thing); |
321 | 321 | } |
322 | 322 | return $objs_removed; |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * related objects exist, returns false. |
330 | 330 | * @return boolean |
331 | 331 | */ |
332 | - public function block_delete_if_related_models_exist(){ |
|
332 | + public function block_delete_if_related_models_exist() { |
|
333 | 333 | return $this->_blocking_delete; |
334 | 334 | } |
335 | 335 | |
@@ -338,13 +338,13 @@ discard block |
||
338 | 338 | * Gets the error message to show |
339 | 339 | * @return string |
340 | 340 | */ |
341 | - public function get_deletion_error_message(){ |
|
342 | - if($this->_blocking_delete_error_message){ |
|
341 | + public function get_deletion_error_message() { |
|
342 | + if ($this->_blocking_delete_error_message) { |
|
343 | 343 | return $this->_blocking_delete_error_message; |
344 | - }else{ |
|
344 | + } else { |
|
345 | 345 | // return sprintf(__('Cannot delete %1$s when there are related %2$s', "event_espresso"),$this->get_this_model()->item_name(2),$this->get_other_model()->item_name(2)); |
346 | 346 | return sprintf( |
347 | - __( 'This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"), |
|
347 | + __('This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"), |
|
348 | 348 | $this->get_this_model()->item_name(1), |
349 | 349 | $this->get_other_model()->item_name(1), |
350 | 350 | $this->get_other_model()->item_name(2) |
@@ -228,12 +228,12 @@ discard block |
||
228 | 228 | $deleted_count++; |
229 | 229 | if( ! $delete_is_blocked ){ |
230 | 230 | $related_model_object->delete_permanently(); |
231 | - }else{ |
|
231 | + } else{ |
|
232 | 232 | //delete is blocked |
233 | 233 | //brent and darren, in this case, wanted to just soft delete it then |
234 | 234 | $related_model_object->delete(); |
235 | 235 | } |
236 | - }else{ |
|
236 | + } else{ |
|
237 | 237 | //its not a soft-deletable thing anyways. do the normal logic. |
238 | 238 | if( ! $delete_is_blocked ){ |
239 | 239 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | public function get_deletion_error_message(){ |
342 | 342 | if($this->_blocking_delete_error_message){ |
343 | 343 | return $this->_blocking_delete_error_message; |
344 | - }else{ |
|
344 | + } else{ |
|
345 | 345 | // return sprintf(__('Cannot delete %1$s when there are related %2$s', "event_espresso"),$this->get_this_model()->item_name(2),$this->get_other_model()->item_name(2)); |
346 | 346 | return sprintf( |
347 | 347 | __( 'This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"), |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | |
120 | 120 | /** |
121 | 121 | * @param $other_table |
122 | - * @param $other_table_alias |
|
122 | + * @param string $other_table_alias |
|
123 | 123 | * @param $other_table_column |
124 | - * @param $this_table_alias |
|
124 | + * @param string $this_table_alias |
|
125 | 125 | * @param $this_table_join_column |
126 | 126 | * @param string $extra_join_sql |
127 | 127 | * @return string |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * Alters the $query_params to disable default where conditions, unless otherwise specified |
165 | 165 | * @param string $query_params |
166 | - * @return array |
|
166 | + * @return string |
|
167 | 167 | */ |
168 | 168 | protected function _disable_default_where_conditions_on_query_param($query_params){ |
169 | 169 | if( ! isset($query_params['default_where_conditions'])){ |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * Note: If the related model is extends EEM_Soft_Delete_Base, then the related |
181 | 181 | * model objects will only be soft-deleted. |
182 | 182 | * |
183 | - * @param EE_Base_Class|int|string $model_object_or_id |
|
183 | + * @param EE_Base_Class|null $model_object_or_id |
|
184 | 184 | * @param array $query_params |
185 | 185 | * @return int of how many related models got deleted |
186 | 186 | * @throws \EE_Error |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * Note: If the related model is extends EEM_Soft_Delete_Base, then the related |
211 | 211 | * model objects will only be soft-deleted. |
212 | 212 | * |
213 | - * @param EE_Base_Class|int|string $model_object_or_id |
|
213 | + * @param EE_Base_Class|null $model_object_or_id |
|
214 | 214 | * @param array $query_params |
215 | 215 | * @return int of how many related models got deleted |
216 | 216 | * @throws \EE_Error |