Completed
Branch BUG-9548-transaction-completio... (b1c41e)
by
unknown
519:42 queued 503:28
created
core/db_classes/EE_Transaction.class.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
  * EE_Transaction class
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 	 * @return EE_Transaction
26 26
 	 * @throws \EE_Error
27 27
 	 */
28
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
29
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
28
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
29
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
30 30
 		return $has_object
31 31
 			? $has_object
32
-			: new self( $props_n_values, false, $timezone, $date_formats );
32
+			: new self($props_n_values, false, $timezone, $date_formats);
33 33
 	}
34 34
 
35 35
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	 * @return EE_Transaction
42 42
 	 * @throws \EE_Error
43 43
 	 */
44
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
45
-		return new self( $props_n_values, TRUE, $timezone );
44
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
45
+		return new self($props_n_values, TRUE, $timezone);
46 46
 	}
47 47
 
48 48
 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function lock() {
60 60
 		// attempt to set lock, but if that fails...
61
-		if ( ! $this->add_extra_meta( 'lock', time(), true )  ) {
61
+		if ( ! $this->add_extra_meta('lock', time(), true)) {
62 62
 			// then attempt to remove the lock in case it is expired
63
-			if ( $this->_remove_expired_lock() ) {
63
+			if ($this->_remove_expired_lock()) {
64 64
 				// if removal was successful, then try setting lock again
65 65
 				$this->lock();
66 66
 			} else {
67 67
 				// but if the lock can not be removed, then throw an exception
68 68
 				throw new EE_Error(
69 69
 					sprintf(
70
-						__( 'Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso' ),
70
+						__('Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso'),
71 71
 						$this->ID()
72 72
 					)
73 73
 				);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @throws \EE_Error
87 87
 	 */
88 88
 	public function unlock() {
89
-		return $this->delete_extra_meta( 'lock' );
89
+		return $this->delete_extra_meta('lock');
90 90
 	}
91 91
 
92 92
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function is_locked() {
109 109
 		// if TXN is not locked, then return false immediately
110
-		if ( ! $this->_get_lock() ) {
110
+		if ( ! $this->_get_lock()) {
111 111
 			return false;
112 112
 		}
113 113
 		// if not, then let's try and remove the lock in case it's expired...
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @throws \EE_Error
129 129
 	 */
130 130
 	protected function _get_lock() {
131
-		return (int)$this->get_extra_meta( 'lock', true, 0 );
131
+		return (int) $this->get_extra_meta('lock', true, 0);
132 132
 	}
133 133
 
134 134
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 */
144 144
 	protected function _remove_expired_lock() {
145 145
 		$locked = $this->_get_lock();
146
-		if ( $locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked ) {
146
+		if ($locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked) {
147 147
 			return $this->unlock();
148 148
 		}
149 149
 		return 0;
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @param        float $total total value of transaction
159 159
 	 * @throws \EE_Error
160 160
 	 */
161
-	public function set_total( $total = 0.00 ) {
162
-		$this->set( 'TXN_total', (float)$total );
161
+	public function set_total($total = 0.00) {
162
+		$this->set('TXN_total', (float) $total);
163 163
 	}
164 164
 
165 165
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @param        float $total_paid total amount paid to date (sum of all payments)
172 172
 	 * @throws \EE_Error
173 173
 	 */
174
-	public function set_paid( $total_paid = 0.00 ) {
175
-		$this->set( 'TXN_paid', (float)$total_paid );
174
+	public function set_paid($total_paid = 0.00) {
175
+		$this->set('TXN_paid', (float) $total_paid);
176 176
 	}
177 177
 
178 178
 
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param        string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set
185 185
 	 * @throws \EE_Error
186 186
 	 */
187
-	public function set_status( $status = '' ) {
188
-		$this->set( 'STS_ID', $status );
187
+	public function set_status($status = '') {
188
+		$this->set('STS_ID', $status);
189 189
 	}
190 190
 
191 191
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param        string $hash_salt required for some payment gateways
198 198
 	 * @throws \EE_Error
199 199
 	 */
200
-	public function set_hash_salt( $hash_salt = '' ) {
201
-		$this->set( 'TXN_hash_salt', $hash_salt );
200
+	public function set_hash_salt($hash_salt = '') {
201
+		$this->set('TXN_hash_salt', $hash_salt);
202 202
 	}
203 203
 
204 204
 
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 	 * @param array $txn_reg_steps
210 210
 	 * @throws \EE_Error
211 211
 	 */
212
-	public function set_reg_steps( array $txn_reg_steps ) {
213
-		$this->set( 'TXN_reg_steps', $txn_reg_steps );
212
+	public function set_reg_steps(array $txn_reg_steps) {
213
+		$this->set('TXN_reg_steps', $txn_reg_steps);
214 214
 	}
215 215
 
216 216
 
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 * @throws \EE_Error
223 223
 	 */
224 224
 	public function reg_steps() {
225
-		$TXN_reg_steps = $this->get( 'TXN_reg_steps' );
226
-		return is_array( $TXN_reg_steps ) ? (array)$TXN_reg_steps : array();
225
+		$TXN_reg_steps = $this->get('TXN_reg_steps');
226
+		return is_array($TXN_reg_steps) ? (array) $TXN_reg_steps : array();
227 227
 	}
228 228
 
229 229
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @throws \EE_Error
234 234
 	 */
235 235
 	public function pretty_total() {
236
-		return $this->get_pretty( 'TXN_total' );
236
+		return $this->get_pretty('TXN_total');
237 237
 	}
238 238
 
239 239
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @throws \EE_Error
246 246
 	 */
247 247
 	public function pretty_paid() {
248
-		return $this->get_pretty( 'TXN_paid' );
248
+		return $this->get_pretty('TXN_paid');
249 249
 	}
250 250
 
251 251
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @throws \EE_Error
259 259
 	 */
260 260
 	public function remaining() {
261
-		return (float)( $this->total() - $this->paid() );
261
+		return (float) ($this->total() - $this->paid());
262 262
 	}
263 263
 
264 264
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @throws \EE_Error
272 272
 	 */
273 273
 	public function total() {
274
-		return (float)$this->get( 'TXN_total' );
274
+		return (float) $this->get('TXN_total');
275 275
 	}
276 276
 
277 277
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @throws \EE_Error
285 285
 	 */
286 286
 	public function paid() {
287
-		return (float)$this->get( 'TXN_paid' );
287
+		return (float) $this->get('TXN_paid');
288 288
 	}
289 289
 
290 290
 
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 	 * @throws \EE_Error
297 297
 	 */
298 298
 	public function get_cart_session() {
299
-		$session_data = (array)$this->get( 'TXN_session_data' );
300
-		return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart
301
-			? $session_data[ 'cart' ]
299
+		$session_data = (array) $this->get('TXN_session_data');
300
+		return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart
301
+			? $session_data['cart']
302 302
 			: null;
303 303
 	}
304 304
 
@@ -311,8 +311,8 @@  discard block
 block discarded – undo
311 311
 	 * @throws \EE_Error
312 312
 	 */
313 313
 	public function session_data() {
314
-		$session_data = $this->get( 'TXN_session_data' );
315
-		if ( empty( $session_data ) ) {
314
+		$session_data = $this->get('TXN_session_data');
315
+		if (empty($session_data)) {
316 316
 			$session_data = array(
317 317
 				'id'            => null,
318 318
 				'user_id'       => null,
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 	 * @param        EE_Session|array $session_data
336 336
 	 * @throws \EE_Error
337 337
 	 */
338
-	public function set_txn_session_data( $session_data ) {
339
-		if ( $session_data instanceof EE_Session ) {
340
-			$this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE ));
338
+	public function set_txn_session_data($session_data) {
339
+		if ($session_data instanceof EE_Session) {
340
+			$this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE));
341 341
 		} else {
342
-			$this->set( 'TXN_session_data', $session_data );
342
+			$this->set('TXN_session_data', $session_data);
343 343
 		}
344 344
 	}
345 345
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @throws \EE_Error
353 353
 	 */
354 354
 	public function hash_salt_() {
355
-		return $this->get( 'TXN_hash_salt' );
355
+		return $this->get('TXN_hash_salt');
356 356
 	}
357 357
 
358 358
 
@@ -372,13 +372,13 @@  discard block
 block discarded – undo
372 372
 	 * @return    string | int
373 373
 	 * @throws \EE_Error
374 374
 	 */
375
-	public function datetime( $format = FALSE, $gmt = FALSE ) {
376
-		if ( $format ) {
377
-			return $this->get_pretty( 'TXN_timestamp' );
378
-		} else if ( $gmt ) {
379
-			return $this->get_raw( 'TXN_timestamp' );
375
+	public function datetime($format = FALSE, $gmt = FALSE) {
376
+		if ($format) {
377
+			return $this->get_pretty('TXN_timestamp');
378
+		} else if ($gmt) {
379
+			return $this->get_raw('TXN_timestamp');
380 380
 		} else {
381
-			return $this->get( 'TXN_timestamp' );
381
+			return $this->get('TXN_timestamp');
382 382
 		}
383 383
 	}
384 384
 
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 	 * @return EE_Registration[]
393 393
 	 * @throws \EE_Error
394 394
 	 */
395
-	public function registrations( $query_params = array(), $get_cached = FALSE ) {
396
-		$query_params = ( empty( $query_params ) || ! is_array( $query_params ) )
395
+	public function registrations($query_params = array(), $get_cached = FALSE) {
396
+		$query_params = (empty($query_params) || ! is_array($query_params))
397 397
 			? array(
398 398
 				'order_by' => array(
399 399
 					'Event.EVT_name' => 'ASC',
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 			)
404 404
 			: $query_params;
405 405
 		$query_params = $get_cached ? array() : $query_params;
406
-		return $this->get_many_related( 'Registration', $query_params );
406
+		return $this->get_many_related('Registration', $query_params);
407 407
 	}
408 408
 
409 409
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	 * @throws \EE_Error
417 417
 	 */
418 418
 	public function attendees() {
419
-		return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) );
419
+		return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID())));
420 420
 	}
421 421
 
422 422
 
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 	 * @return EE_Payment[]
429 429
 	 * @throws \EE_Error
430 430
 	 */
431
-	public function payments( $query_params = array() ) {
432
-		return $this->get_many_related( 'Payment', $query_params );
431
+	public function payments($query_params = array()) {
432
+		return $this->get_many_related('Payment', $query_params);
433 433
 	}
434 434
 
435 435
 
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @throws \EE_Error
442 442
 	 */
443 443
 	public function approved_payments() {
444
-		EE_Registry::instance()->load_model( 'Payment' );
445
-		return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) );
444
+		EE_Registry::instance()->load_model('Payment');
445
+		return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC')));
446 446
 	}
447 447
 
448 448
 
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 * @return string
455 455
 	 * @throws \EE_Error
456 456
 	 */
457
-	public function e_pretty_status( $show_icons = FALSE ) {
458
-		echo $this->pretty_status( $show_icons );
457
+	public function e_pretty_status($show_icons = FALSE) {
458
+		echo $this->pretty_status($show_icons);
459 459
 	}
460 460
 
461 461
 
@@ -467,10 +467,10 @@  discard block
 block discarded – undo
467 467
 	 * @return string
468 468
 	 * @throws \EE_Error
469 469
 	 */
470
-	public function pretty_status( $show_icons = FALSE ) {
471
-		$status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' );
470
+	public function pretty_status($show_icons = FALSE) {
471
+		$status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence');
472 472
 		$icon = '';
473
-		switch ( $this->status_ID() ) {
473
+		switch ($this->status_ID()) {
474 474
 			case EEM_Transaction::complete_status_code:
475 475
 				$icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : '';
476 476
 				break;
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 				$icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : '';
488 488
 				break;
489 489
 		}
490
-		return $icon . $status[ $this->status_ID() ];
490
+		return $icon.$status[$this->status_ID()];
491 491
 	}
492 492
 
493 493
 
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 	 * @throws \EE_Error
500 500
 	 */
501 501
 	public function status_ID() {
502
-		return $this->get( 'STS_ID' );
502
+		return $this->get('STS_ID');
503 503
 	}
504 504
 
505 505
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	 * @throws \EE_Error
512 512
 	 */
513 513
 	public function is_free() {
514
-		return EEH_Money::compare_floats( $this->get( 'TXN_total' ), 0, '==' );
514
+		return EEH_Money::compare_floats($this->get('TXN_total'), 0, '==');
515 515
 	}
516 516
 
517 517
 
@@ -591,12 +591,12 @@  discard block
 block discarded – undo
591 591
 	 * @return string
592 592
 	 * @throws \EE_Error
593 593
 	 */
594
-	public function invoice_url( $type = 'html' ) {
594
+	public function invoice_url($type = 'html') {
595 595
 		$REG = $this->primary_registration();
596
-		if ( ! $REG instanceof EE_Registration ) {
596
+		if ( ! $REG instanceof EE_Registration) {
597 597
 			return '';
598 598
 		}
599
-		return $REG->invoice_url( $type );
599
+		return $REG->invoice_url($type);
600 600
 	}
601 601
 
602 602
 
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 * @throws \EE_Error
609 609
 	 */
610 610
 	public function primary_registration() {
611
-		return $this->get_first_related( 'Registration', array( array( 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT ) ) );
611
+		return $this->get_first_related('Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
612 612
 	}
613 613
 
614 614
 
@@ -620,12 +620,12 @@  discard block
 block discarded – undo
620 620
 	 * @return string
621 621
 	 * @throws \EE_Error
622 622
 	 */
623
-	public function receipt_url( $type = 'html' ) {
623
+	public function receipt_url($type = 'html') {
624 624
 		$REG = $this->primary_registration();
625
-		if ( ! $REG instanceof EE_Registration ) {
625
+		if ( ! $REG instanceof EE_Registration) {
626 626
 			return '';
627 627
 		}
628
-		return $REG->receipt_url( $type );
628
+		return $REG->receipt_url($type);
629 629
 	}
630 630
 
631 631
 
@@ -653,15 +653,15 @@  discard block
 block discarded – undo
653 653
 	 * @return boolean
654 654
 	 * @throws \EE_Error
655 655
 	 */
656
-	public function update_based_on_payments(){
656
+	public function update_based_on_payments() {
657 657
 		EE_Error::doing_it_wrong(
658
-			__CLASS__ . '::' . __FUNCTION__,
659
-			sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ),
658
+			__CLASS__.'::'.__FUNCTION__,
659
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
660 660
 			'4.6.0'
661 661
 		);
662 662
 		/** @type EE_Transaction_Processor $transaction_processor */
663
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
664
-		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this );
663
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
664
+		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this);
665 665
 	}
666 666
 
667 667
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	 * @throws \EE_Error
672 672
 	 */
673 673
 	public function gateway_response_on_transaction() {
674
-		$payment = $this->get_first_related( 'Payment' );
674
+		$payment = $this->get_first_related('Payment');
675 675
 		return $payment instanceof EE_Payment ? $payment->gateway_response() : '';
676 676
 	}
677 677
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 	 * @throws \EE_Error
685 685
 	 */
686 686
 	public function status_obj() {
687
-		return $this->get_first_related( 'Status' );
687
+		return $this->get_first_related('Status');
688 688
 	}
689 689
 
690 690
 
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 	 * @return EE_Extra_Meta
697 697
 	 * @throws \EE_Error
698 698
 	 */
699
-	public function extra_meta( $query_params = array() ) {
700
-		return $this->get_many_related( 'Extra_Meta', $query_params );
699
+	public function extra_meta($query_params = array()) {
700
+		return $this->get_many_related('Extra_Meta', $query_params);
701 701
 	}
702 702
 
703 703
 
@@ -709,8 +709,8 @@  discard block
 block discarded – undo
709 709
 	 * @return EE_Base_Class the relation was added to
710 710
 	 * @throws \EE_Error
711 711
 	 */
712
-	public function add_registration( EE_Registration $registration ) {
713
-		return $this->_add_relation_to( $registration, 'Registration' );
712
+	public function add_registration(EE_Registration $registration) {
713
+		return $this->_add_relation_to($registration, 'Registration');
714 714
 	}
715 715
 
716 716
 
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
 	 * @return EE_Base_Class that was removed from being related
724 724
 	 * @throws \EE_Error
725 725
 	 */
726
-	public function remove_registration_with_id( $registration_or_id ) {
727
-		return $this->_remove_relation_to( $registration_or_id, 'Registration' );
726
+	public function remove_registration_with_id($registration_or_id) {
727
+		return $this->_remove_relation_to($registration_or_id, 'Registration');
728 728
 	}
729 729
 
730 730
 
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 	 * @throws \EE_Error
737 737
 	 */
738 738
 	public function items_purchased() {
739
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) );
739
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item)));
740 740
 	}
741 741
 
742 742
 
@@ -748,8 +748,8 @@  discard block
 block discarded – undo
748 748
 	 * @return EE_Base_Class the relation was added to
749 749
 	 * @throws \EE_Error
750 750
 	 */
751
-	public function add_line_item( EE_Line_Item $line_item ) {
752
-		return $this->_add_relation_to( $line_item, 'Line_Item' );
751
+	public function add_line_item(EE_Line_Item $line_item) {
752
+		return $this->_add_relation_to($line_item, 'Line_Item');
753 753
 	}
754 754
 
755 755
 
@@ -761,8 +761,8 @@  discard block
 block discarded – undo
761 761
 	 * @return EE_Line_Item[]
762 762
 	 * @throws \EE_Error
763 763
 	 */
764
-	public function line_items( $query_params = array() ) {
765
-		return $this->get_many_related( 'Line_Item', $query_params );
764
+	public function line_items($query_params = array()) {
765
+		return $this->get_many_related('Line_Item', $query_params);
766 766
 	}
767 767
 
768 768
 
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 	 * @throws \EE_Error
775 775
 	 */
776 776
 	public function tax_items() {
777
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) );
777
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax)));
778 778
 	}
779 779
 
780 780
 
@@ -787,9 +787,9 @@  discard block
 block discarded – undo
787 787
 	 * @throws \EE_Error
788 788
 	 */
789 789
 	public function total_line_item() {
790
-		$item =  $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) );
791
-		if( ! $item ){
792
-			$item = EEH_Line_Item::create_total_line_item( $this );
790
+		$item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total)));
791
+		if ( ! $item) {
792
+			$item = EEH_Line_Item::create_total_line_item($this);
793 793
 		}
794 794
 		return $item;
795 795
 	}
@@ -805,10 +805,10 @@  discard block
 block discarded – undo
805 805
 	 */
806 806
 	public function tax_total() {
807 807
 		$tax_line_item = $this->tax_total_line_item();
808
-		if ( $tax_line_item ) {
809
-			return (float)$tax_line_item->total();
808
+		if ($tax_line_item) {
809
+			return (float) $tax_line_item->total();
810 810
 		} else {
811
-			return (float)0;
811
+			return (float) 0;
812 812
 		}
813 813
 	}
814 814
 
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 	 * @throws \EE_Error
822 822
 	 */
823 823
 	public function tax_total_line_item() {
824
-		return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() );
824
+		return EEH_Line_Item::get_taxes_subtotal($this->total_line_item());
825 825
 	}
826 826
 
827 827
 
@@ -832,20 +832,20 @@  discard block
 block discarded – undo
832 832
 	 * @return EE_Form_Section_Proper
833 833
 	 * @throws \EE_Error
834 834
 	 */
835
-	public function billing_info(){
835
+	public function billing_info() {
836 836
 		$payment_method = $this->payment_method();
837
-		if ( !$payment_method){
837
+		if ( ! $payment_method) {
838 838
 			EE_Error::add_error(__("Could not find billing info for transaction because no gateway has been used for it yet", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
839 839
 			return false;
840 840
 		}
841 841
 		$primary_reg = $this->primary_registration();
842
-		if ( ! $primary_reg ) {
843
-			EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
842
+		if ( ! $primary_reg) {
843
+			EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
844 844
 			return FALSE;
845 845
 		}
846 846
 		$attendee = $primary_reg->attendee();
847
-		if ( ! $attendee ) {
848
-			EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
847
+		if ( ! $attendee) {
848
+			EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
849 849
 			return FALSE;
850 850
 		}
851 851
 		return $attendee->billing_info_for_payment_method($payment_method);
@@ -886,15 +886,15 @@  discard block
 block discarded – undo
886 886
 	 * @return EE_Payment_Method
887 887
 	 * @throws \EE_Error
888 888
 	 */
889
-	public function payment_method(){
889
+	public function payment_method() {
890 890
 		$pm = $this->get_first_related('Payment_Method');
891
-		if( $pm instanceof EE_Payment_Method ){
891
+		if ($pm instanceof EE_Payment_Method) {
892 892
 			return $pm;
893
-		}else{
893
+		} else {
894 894
 			$last_payment = $this->last_payment();
895
-			if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){
895
+			if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) {
896 896
 				return $last_payment->payment_method();
897
-			}else{
897
+			} else {
898 898
 				return NULL;
899 899
 			}
900 900
 		}
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 	 * @throws \EE_Error
910 910
 	 */
911 911
 	public function last_payment() {
912
-		return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) );
912
+		return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc')));
913 913
 	}
914 914
 
915 915
 
@@ -920,8 +920,8 @@  discard block
 block discarded – undo
920 920
 	 * @return EE_Line_Item[]
921 921
 	 * @throws \EE_Error
922 922
 	 */
923
-	public function non_ticket_line_items(){
924
-		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() );
923
+	public function non_ticket_line_items() {
924
+		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID());
925 925
 	}
926 926
 
927 927
 
Please login to merge, or discard this patch.
core/db_classes/EE_Payment.class.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
core/db_classes/EE_Message_Template_Group.class.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
  * Event Espresso
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 	 * @param string $timezone
35 35
 	 * @return EE_Message_Template_Group|mixed
36 36
 	 */
37
-	public static function new_instance( $props_n_values = array(), $timezone = '' ) {
38
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone );
39
-		return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone );
37
+	public static function new_instance($props_n_values = array(), $timezone = '') {
38
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
39
+		return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone);
40 40
 	}
41 41
 
42 42
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 	 * @param string $timezone
47 47
 	 * @return EE_Message_Template_Group
48 48
 	 */
49
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = '' ) {
50
-		return new self( $props_n_values, TRUE, $timezone );
49
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '') {
50
+		return new self($props_n_values, TRUE, $timezone);
51 51
 	}
52 52
 
53 53
 
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 	 * @param bool $message_type
57 57
 	 * @throws EE_Error
58 58
 	 */
59
-	public function set_message_type( $message_type = FALSE ) {
60
-		if ( ! $message_type ) {
61
-			throw new EE_Error( __( 'Missing required value for the message_type parameter', 'event_espresso' ) );
59
+	public function set_message_type($message_type = FALSE) {
60
+		if ( ! $message_type) {
61
+			throw new EE_Error(__('Missing required value for the message_type parameter', 'event_espresso'));
62 62
 		}
63
-		$this->set( 'MTP_message_type', $message_type );
63
+		$this->set('MTP_message_type', $message_type);
64 64
 	}
65 65
 
66 66
 
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 	 * @param bool $messenger
70 70
 	 * @throws EE_Error
71 71
 	 */
72
-	public function set_messenger( $messenger = FALSE ) {
73
-		if ( ! $messenger ) {
74
-			throw new EE_Error( __( 'Missing required value for the messenger parameter', 'event_espresso' ) );
72
+	public function set_messenger($messenger = FALSE) {
73
+		if ( ! $messenger) {
74
+			throw new EE_Error(__('Missing required value for the messenger parameter', 'event_espresso'));
75 75
 		}
76
-		$this->set( 'MTP_messenger', $messenger );
76
+		$this->set('MTP_messenger', $messenger);
77 77
 	}
78 78
 
79 79
 
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 	 * @param bool $GRP_ID
83 83
 	 * @throws EE_Error
84 84
 	 */
85
-	public function set_group_template_id( $GRP_ID = FALSE ) {
86
-		if ( ! $GRP_ID ) {
87
-			throw new EE_Error( __( 'Missing required value for the message template group id', 'event_espresso' ) );
85
+	public function set_group_template_id($GRP_ID = FALSE) {
86
+		if ( ! $GRP_ID) {
87
+			throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso'));
88 88
 		}
89
-		$this->set( 'GRP_ID', $GRP_ID );
89
+		$this->set('GRP_ID', $GRP_ID);
90 90
 	}
91 91
 
92 92
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @return int
98 98
 	 */
99 99
 	public function GRP_ID() {
100
-		return $this->get( 'GRP_ID' );
100
+		return $this->get('GRP_ID');
101 101
 	}
102 102
 
103 103
 
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 * @return int
109 109
 	 */
110 110
 	public function user() {
111
-		$user_id = $this->get( 'MTP_user_id' );
112
-		return empty( $user_id ) ? get_current_user_id() : $user_id;
111
+		$user_id = $this->get('MTP_user_id');
112
+		return empty($user_id) ? get_current_user_id() : $user_id;
113 113
 	}
114 114
 
115 115
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @return int
133 133
 	 */
134 134
 	public function count_events() {
135
-		return $this->count_related( 'Event' );
135
+		return $this->count_related('Event');
136 136
 	}
137 137
 
138 138
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @return string
143 143
 	 */
144 144
 	public function name() {
145
-		return $this->get( 'MTP_name' );
145
+		return $this->get('MTP_name');
146 146
 	}
147 147
 
148 148
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @return string
153 153
 	 */
154 154
 	public function description() {
155
-		return $this->get( 'MTP_description' );
155
+		return $this->get('MTP_description');
156 156
 	}
157 157
 
158 158
 
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 	 * @param  array $query_params like EEM_Base::get_all()
163 163
 	 * @return EE_Message_Template[]
164 164
 	 */
165
-	public function message_templates( $query_params = array() ) {
166
-		return $this->get_many_related( 'Message_Template', $query_params );
165
+	public function message_templates($query_params = array()) {
166
+		return $this->get_many_related('Message_Template', $query_params);
167 167
 	}
168 168
 
169 169
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @return string
175 175
 	 */
176 176
 	public function messenger() {
177
-		return $this->get( 'MTP_messenger' );
177
+		return $this->get('MTP_messenger');
178 178
 	}
179 179
 
180 180
 
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 	public function messenger_obj() {
192 192
 		$messenger = $this->messenger();
193 193
 		try {
194
-			$messenger = EEH_MSG_Template::messenger_obj( $messenger );
195
-		} catch( EE_Error $e ) {
194
+			$messenger = EEH_MSG_Template::messenger_obj($messenger);
195
+		} catch (EE_Error $e) {
196 196
 			//if an exception was thrown then let's deactivate this message template group because it means there is no class for this messenger in this group.
197
-			$this->set( 'MTP_is_active', false );
197
+			$this->set('MTP_is_active', false);
198 198
 			$this->save();
199 199
 			return null;
200 200
 		}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @return string
211 211
 	 */
212 212
 	public function message_type() {
213
-		return $this->get( 'MTP_message_type' );
213
+		return $this->get('MTP_message_type');
214 214
 	}
215 215
 
216 216
 
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
 	public function message_type_obj() {
229 229
 		$message_type = $this->message_type();
230 230
 		try {
231
-			$message_type = EEH_MSG_Template::message_type_obj( $message_type );
232
-		} catch(EE_Error $e) {
231
+			$message_type = EEH_MSG_Template::message_type_obj($message_type);
232
+		} catch (EE_Error $e) {
233 233
 			//if an exception was thrown then let's deactivate this message template group because it means there is no class for the message type in this group.
234
-			$this->set( 'MTP_is_active', false );
234
+			$this->set('MTP_is_active', false);
235 235
 			$this->save();
236 236
 			return null;
237 237
 		}
@@ -268,13 +268,13 @@  discard block
 block discarded – undo
268 268
 	 */
269 269
 	public function context_templates() {
270 270
 		$mtps_arr = array();
271
-		$mtps = $this->get_many_related( 'Message_Template' );
272
-		if ( empty( $mtps ) ) {
271
+		$mtps = $this->get_many_related('Message_Template');
272
+		if (empty($mtps)) {
273 273
 			return array();
274 274
 		}
275 275
 		//note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field.
276
-		foreach ( $mtps as $mtp ) {
277
-			$mtps_arr[ $mtp->get( 'MTP_context' ) ][ $mtp->get( 'MTP_template_field' ) ] = $mtp;
276
+		foreach ($mtps as $mtp) {
277
+			$mtps_arr[$mtp->get('MTP_context')][$mtp->get('MTP_template_field')] = $mtp;
278 278
 		}
279 279
 		return $mtps_arr;
280 280
 	}
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * @return boolean true if it is, false if it isn't
287 287
 	 */
288 288
 	public function is_global() {
289
-		return $this->get( 'MTP_is_global' );
289
+		return $this->get('MTP_is_global');
290 290
 	}
291 291
 
292 292
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	 * @return boolean true if it is, false if it isn't
297 297
 	 */
298 298
 	public function is_active() {
299
-		return $this->get( 'MTP_is_active' );
299
+		return $this->get('MTP_is_active');
300 300
 	}
301 301
 
302 302
 
@@ -312,10 +312,10 @@  discard block
 block discarded – undo
312 312
 	 * @param bool   $merged  If TRUE then we don't return shortcodes indexed by field but instead an array of the unique shortcodes for all the given (or all) fields.
313 313
 	 * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no shortcodes found.
314 314
 	 */
315
-	public function get_shortcodes( $context, $fields = array(), $merged = FALSE ) {
315
+	public function get_shortcodes($context, $fields = array(), $merged = FALSE) {
316 316
 		$messenger = $this->messenger();
317 317
 		$message_type = $this->message_type();
318
-		return EEH_MSG_Template::get_shortcodes( $message_type, $messenger, $fields, $context, $merged );
318
+		return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged);
319 319
 	}
320 320
 
321 321
 
@@ -328,20 +328,20 @@  discard block
 block discarded – undo
328 328
 	 * @throws EE_Error
329 329
 	 * @return array    an array of EE_Shortcode objects
330 330
 	 */
331
-	private function _get_shortcode_objects( $sc_refs ) {
331
+	private function _get_shortcode_objects($sc_refs) {
332 332
 		$sc_objs = array();
333 333
 		EED_Messages::set_autoloaders();
334
-		foreach ( $sc_refs as $shortcode_ref ) {
335
-			$ref = ucwords( str_replace( '_', ' ', $shortcode_ref ) );
336
-			$ref = str_replace( ' ', '_', $ref );
337
-			$classname = 'EE_' . $ref . '_Shortcodes';
338
-			if ( ! class_exists( $classname ) ) {
339
-				$msg[ ] = __( 'Shortcode library loading fail.', 'event_espresso' );
340
-				$msg[ ] = sprintf( __( 'The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate shortcode library file name (minus the extension) in the "/library/shortcodes/" directory', 'event_espresso' ), $classname );
341
-				throw new EE_Error( implode( '||', $msg ) );
334
+		foreach ($sc_refs as $shortcode_ref) {
335
+			$ref = ucwords(str_replace('_', ' ', $shortcode_ref));
336
+			$ref = str_replace(' ', '_', $ref);
337
+			$classname = 'EE_'.$ref.'_Shortcodes';
338
+			if ( ! class_exists($classname)) {
339
+				$msg[] = __('Shortcode library loading fail.', 'event_espresso');
340
+				$msg[] = sprintf(__('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate shortcode library file name (minus the extension) in the "/library/shortcodes/" directory', 'event_espresso'), $classname);
341
+				throw new EE_Error(implode('||', $msg));
342 342
 			}
343
-			$a = new ReflectionClass( $classname );
344
-			$sc_objs[ ] = $a->newInstance();
343
+			$a = new ReflectionClass($classname);
344
+			$sc_objs[] = $a->newInstance();
345 345
 		}
346 346
 		return $sc_objs;
347 347
 	}
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 * @return string
357 357
 	 */
358 358
 	public function get_template_pack_name() {
359
-		return $this->get_extra_meta( 'MTP_template_pack', TRUE, 'default' );
359
+		return $this->get_extra_meta('MTP_template_pack', TRUE, 'default');
360 360
 	}
361 361
 
362 362
 
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 	public function get_template_pack() {
373 373
 		$pack_name = $this->get_template_pack_name();
374 374
 
375
-		return EED_Messages::get_template_pack( $pack_name );
375
+		return EED_Messages::get_template_pack($pack_name);
376 376
 	}
377 377
 
378 378
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	 * @return string
386 386
 	 */
387 387
 	public function get_template_pack_variation() {
388
-		return $this->get_extra_meta( 'MTP_variation', TRUE, 'default' );
388
+		return $this->get_extra_meta('MTP_variation', TRUE, 'default');
389 389
 	}
390 390
 
391 391
 
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 *
399 399
 	 * @param string $template_pack_name What message template pack is assigned.
400 400
 	 */
401
-	public function set_template_pack_name( $template_pack_name ) {
402
-		return $this->update_extra_meta( 'MTP_template_pack', $template_pack_name );
401
+	public function set_template_pack_name($template_pack_name) {
402
+		return $this->update_extra_meta('MTP_template_pack', $template_pack_name);
403 403
 	}
404 404
 
405 405
 
@@ -412,8 +412,8 @@  discard block
 block discarded – undo
412 412
 	 *
413 413
 	 * @param string $variation What variation is being set on the message template group.
414 414
 	 */
415
-	public function set_template_pack_variation( $variation ) {
416
-		return $this->update_extra_meta( 'MTP_variation', $variation );
415
+	public function set_template_pack_variation($variation) {
416
+		return $this->update_extra_meta('MTP_variation', $variation);
417 417
 	}
418 418
 }
419 419
 //end EE_Message_Template_Group class
Please login to merge, or discard this patch.
core/db_classes/EE_CPT_Base.class.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
  * Event Espresso
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 * @param int    $parent_term_taxonomy_id optional
48 48
 	 * @return EE_Term_Taxonomy
49 49
 	 */
50
-	function add_event_category( $category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL ) {
51
-		return $this->get_model()->add_event_category( $this, $category_name, $category_description, $parent_term_taxonomy_id );
50
+	function add_event_category($category_name, $category_description = NULL, $parent_term_taxonomy_id = NULL) {
51
+		return $this->get_model()->add_event_category($this, $category_name, $category_description, $parent_term_taxonomy_id);
52 52
 	}
53 53
 
54 54
 
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	 * @param string $category_name
59 59
 	 * @return bool
60 60
 	 */
61
-	function remove_event_category( $category_name ) {
62
-		return $this->get_model()->remove_event_category( $this, $category_name );
61
+	function remove_event_category($category_name) {
62
+		return $this->get_model()->remove_event_category($this, $category_name);
63 63
 	}
64 64
 
65 65
 
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 	 * @param EE_Term_Taxonomy $term_taxonomy
71 71
 	 * @return EE_Base_Class the relation was removed from
72 72
 	 */
73
-	function remove_relation_to_term_taxonomy( $term_taxonomy ) {
74
-		if ( !$term_taxonomy ) {
75
-			EE_Error::add_error( sprintf( __( "No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso" ), get_class( $this ), $this->ID() ), __FILE__, __FUNCTION__, __LINE__ );
73
+	function remove_relation_to_term_taxonomy($term_taxonomy) {
74
+		if ( ! $term_taxonomy) {
75
+			EE_Error::add_error(sprintf(__("No Term_Taxonomy provided which to remove from model object of type %s and id %d", "event_espresso"), get_class($this), $this->ID()), __FILE__, __FUNCTION__, __LINE__);
76 76
 			return NULL;
77 77
 		}
78
-		$term_taxonomy->set_count( $term_taxonomy->count() - 1 );
78
+		$term_taxonomy->set_count($term_taxonomy->count() - 1);
79 79
 		$term_taxonomy->save();
80
-		return $this->_remove_relation_to( $term_taxonomy, 'Term_Taxonomy' );
80
+		return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy');
81 81
 	}
82 82
 
83 83
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @return int
102 102
 	 */
103 103
 	public function parent() {
104
-		return $this->get( 'parent' );
104
+		return $this->get('parent');
105 105
 	}
106 106
 
107 107
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @return string
112 112
 	 */
113 113
 	public function status() {
114
-		return $this->get( 'status' );
114
+		return $this->get('status');
115 115
 	}
116 116
 
117 117
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	/**
120 120
 	 * @param string $status
121 121
 	 */
122
-	public function set_status( $status ) {
123
-		$this->set( 'status', $status );
122
+	public function set_status($status) {
123
+		$this->set('status', $status);
124 124
 	}
125 125
 
126 126
 
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 	 * @param string|array $attr Optional. Query string or array of attributes.
135 135
 	 * @return string HTML image element
136 136
 	 */
137
-	protected function _get_feature_image( $size, $attr ) {
137
+	protected function _get_feature_image($size, $attr) {
138 138
 		//first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size
139
-		$attr_key = is_array( $attr ) ? implode( '_', $attr ) : $attr;
140
-		$cache_key = is_array( $size ) ? implode( '_', $size ) . $attr_key : $size . $attr_key;
141
-		$this->_feature_image[ $cache_key ] = isset( $this->_feature_image[ $cache_key ] ) ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image( $this->ID(), $size, $attr );
142
-		return $this->_feature_image[ $cache_key ];
139
+		$attr_key = is_array($attr) ? implode('_', $attr) : $attr;
140
+		$cache_key = is_array($size) ? implode('_', $size).$attr_key : $size.$attr_key;
141
+		$this->_feature_image[$cache_key] = isset($this->_feature_image[$cache_key]) ? $this->_feature_image[$cache_key] : $this->get_model()->get_feature_image($this->ID(), $size, $attr);
142
+		return $this->_feature_image[$cache_key];
143 143
 	}
144 144
 
145 145
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param string|array $attr
151 151
 	 * @return string of html
152 152
 	 */
153
-	public function feature_image( $size = 'thumbnail', $attr = '' ) {
154
-		return $this->_get_feature_image( $size, $attr );
153
+	public function feature_image($size = 'thumbnail', $attr = '') {
154
+		return $this->_get_feature_image($size, $attr);
155 155
 	}
156 156
 
157 157
 
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	 * @param  string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array representing width and height in pixels eg. array(32,32).
162 162
 	 * @return string|boolean          the url of the image or false if not found
163 163
 	 */
164
-	public function feature_image_url( $size = 'thumbnail' ) {
165
-		$attachment = wp_get_attachment_image_src( get_post_thumbnail_id( $this->ID() ), $size );
166
-		return !empty( $attachment ) ? $attachment[ 0 ] : FALSE;
164
+	public function feature_image_url($size = 'thumbnail') {
165
+		$attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size);
166
+		return ! empty($attachment) ? $attachment[0] : FALSE;
167 167
 	}
168 168
 
169 169
 
@@ -185,36 +185,36 @@  discard block
 block discarded – undo
185 185
 	 *                                 This array is INDEXED by RELATED OBJ NAME (so it corresponds with the obj_names sent);
186 186
 	 * @return void
187 187
 	 */
188
-	public function restore_revision( $revision_id, $related_obj_names = array(), $where_query = array() ) {
188
+	public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array()) {
189 189
 		//get revision object
190
-		$revision_obj = $this->get_model()->get_one_by_ID( $revision_id );
191
-		if ( $revision_obj instanceof EE_CPT_Base ) {
190
+		$revision_obj = $this->get_model()->get_one_by_ID($revision_id);
191
+		if ($revision_obj instanceof EE_CPT_Base) {
192 192
 			//no related_obj_name so we assume we're saving a revision on this object.
193
-			if ( empty( $related_obj_names ) ) {
193
+			if (empty($related_obj_names)) {
194 194
 				$fields = $this->get_model()->get_meta_table_fields();
195
-				foreach ( $fields as $field ) {
196
-					$this->set( $field, $revision_obj->get( $field ) );
195
+				foreach ($fields as $field) {
196
+					$this->set($field, $revision_obj->get($field));
197 197
 				}
198 198
 				$this->save();
199 199
 			}
200
-			$related_obj_names = (array)$related_obj_names;
201
-			foreach ( $related_obj_names as $related_name ) {
200
+			$related_obj_names = (array) $related_obj_names;
201
+			foreach ($related_obj_names as $related_name) {
202 202
 				//related_obj_name so we're saving a revision on an object related to this object
203 203
 				//do we have $where_query params for this related object?  If we do then we include that.
204
-				$cols_n_values = isset( $where_query[ $related_name ] ) ? $where_query[ $related_name ] : array();
205
-				$where_params = !empty( $cols_n_values ) ? array( $cols_n_values ) : array();
206
-				$related_objs = $this->get_many_related( $related_name, $where_params );
207
-				$revision_related_objs = $revision_obj->get_many_related( $related_name, $where_params );
204
+				$cols_n_values = isset($where_query[$related_name]) ? $where_query[$related_name] : array();
205
+				$where_params = ! empty($cols_n_values) ? array($cols_n_values) : array();
206
+				$related_objs = $this->get_many_related($related_name, $where_params);
207
+				$revision_related_objs = $revision_obj->get_many_related($related_name, $where_params);
208 208
 				//load helper
209 209
 				//remove related objs from this object that are not in revision
210 210
 				//array_diff *should* work cause I think objects are indexed by ID?
211
-				$related_to_remove = EEH_Array::object_array_diff( $related_objs, $revision_related_objs );
212
-				foreach ( $related_to_remove as $rr ) {
213
-					$this->_remove_relation_to( $rr, $related_name, $cols_n_values );
211
+				$related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs);
212
+				foreach ($related_to_remove as $rr) {
213
+					$this->_remove_relation_to($rr, $related_name, $cols_n_values);
214 214
 				}
215 215
 				//add all related objs attached to revision to this object
216
-				foreach ( $revision_related_objs as $r_obj ) {
217
-					$this->_add_relation_to( $r_obj, $related_name, $cols_n_values );
216
+				foreach ($revision_related_objs as $r_obj) {
217
+					$this->_add_relation_to($r_obj, $related_name, $cols_n_values);
218 218
 				}
219 219
 			}
220 220
 		}
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 	 * <li>If $single is set to false, or left blank, the function returns an array containing all values of the specified key.</li>
231 231
 	 * <li>If $single is set to true, the function returns the first value of the specified key (not in an array</li></ul>
232 232
 	 */
233
-	public function get_post_meta( $meta_key = NULL, $single = FALSE ) {
234
-		return get_post_meta( $this->ID(), $meta_key, $single );
233
+	public function get_post_meta($meta_key = NULL, $single = FALSE) {
234
+		return get_post_meta($this->ID(), $meta_key, $single);
235 235
 	}
236 236
 
237 237
 
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
 	 * @param mixed  $prev_value
244 244
 	 * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. NOTE: If the meta_value passed to this function is the same as the value that is already in the database, this function returns false.
245 245
 	 */
246
-	public function update_post_meta( $meta_key, $meta_value, $prev_value = NULL ) {
247
-		if ( ! $this->ID() ) {
246
+	public function update_post_meta($meta_key, $meta_value, $prev_value = NULL) {
247
+		if ( ! $this->ID()) {
248 248
 			$this->save();
249 249
 		}
250
-		return update_post_meta( $this->ID(), $meta_key, $meta_value, $prev_value );
250
+		return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value);
251 251
 	}
252 252
 
253 253
 
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 	 * @param bool  $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not
260 260
 	 * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given key already exists, in which case false is returned.
261 261
 	 */
262
-	public function add_post_meta( $meta_key, $meta_value, $unique = FALSE ) {
263
-		if ( $this->ID() ) {
262
+	public function add_post_meta($meta_key, $meta_value, $unique = FALSE) {
263
+		if ($this->ID()) {
264 264
 			$this->save();
265 265
 		}
266
-		return add_post_meta( $this->ID(), $meta_key, $meta_value, $unique );
266
+		return add_post_meta($this->ID(), $meta_key, $meta_value, $unique);
267 267
 	}
268 268
 
269 269
 
@@ -275,13 +275,13 @@  discard block
 block discarded – undo
275 275
 	 * @param mixed $meta_value
276 276
 	 * @return boolean False for failure. True for success.
277 277
 	 */
278
-	public function delete_post_meta( $meta_key, $meta_value = '' ) {
279
-		if ( ! $this->ID() ) {
278
+	public function delete_post_meta($meta_key, $meta_value = '') {
279
+		if ( ! $this->ID()) {
280 280
 			//there are obviously no postmetas for this if it's not saved
281 281
 			//so let's just report this as a success
282 282
 			return true;
283 283
 		}
284
-		return delete_post_meta( $this->ID(), $meta_key, $meta_value );
284
+		return delete_post_meta($this->ID(), $meta_key, $meta_value);
285 285
 	}
286 286
 
287 287
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @return string
292 292
 	 */
293 293
 	public function get_permalink() {
294
-		return get_permalink( $this->ID() );
294
+		return get_permalink($this->ID());
295 295
 	}
296 296
 
297 297
 
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
 	 * @param array $query_params
302 302
 	 * @return EE_Term_Taxonomy
303 303
 	 */
304
-	public function term_taxonomies( $query_params = array() ) {
305
-		return $this->get_many_related( 'Term_Taxonomy', $query_params );
304
+	public function term_taxonomies($query_params = array()) {
305
+		return $this->get_many_related('Term_Taxonomy', $query_params);
306 306
 	}
307 307
 
308 308
 
Please login to merge, or discard this patch.
core/db_classes/EE_Registration.class.php 1 patch
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
  * EE_Registration class
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 	 *                             		    date_format and the second value is the time format
42 42
 	 * @return EE_Registration
43 43
 	 */
44
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
45
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
46
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
44
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
45
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
46
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
47 47
 	}
48 48
 
49 49
 
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 	 *                          		the website will be used.
55 55
 	 * @return EE_Registration
56 56
 	 */
57
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
58
-		return new self( $props_n_values, TRUE, $timezone );
57
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
58
+		return new self($props_n_values, TRUE, $timezone);
59 59
 	}
60 60
 
61 61
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	 * @access        public
67 67
 	 * @param        int $EVT_ID Event ID
68 68
 	 */
69
-	public function set_event( $EVT_ID = 0 ) {
70
-		$this->set( 'EVT_ID', $EVT_ID );
69
+	public function set_event($EVT_ID = 0) {
70
+		$this->set('EVT_ID', $EVT_ID);
71 71
 	}
72 72
 
73 73
 
@@ -78,18 +78,18 @@  discard block
 block discarded – undo
78 78
 	 * @param mixed  $field_value
79 79
 	 * @param bool   $use_default
80 80
 	 */
81
-	public function set( $field_name, $field_value, $use_default = FALSE ) {
82
-		switch( $field_name ) {
81
+	public function set($field_name, $field_value, $use_default = FALSE) {
82
+		switch ($field_name) {
83 83
 			case 'REG_code' :
84
-				if ( ! empty( $field_value ) && $this->reg_code() == '' ) {
85
-					$this->set_reg_code( $field_value, $use_default );
84
+				if ( ! empty($field_value) && $this->reg_code() == '') {
85
+					$this->set_reg_code($field_value, $use_default);
86 86
 				}
87 87
 				break;
88 88
 			case 'STS_ID' :
89
-				$this->set_status( $field_value, $use_default );
89
+				$this->set_status($field_value, $use_default);
90 90
 				break;
91 91
 			default :
92
-				parent::set( $field_name, $field_value, $use_default );
92
+				parent::set($field_name, $field_value, $use_default);
93 93
 		}
94 94
 	}
95 95
 
@@ -106,30 +106,30 @@  discard block
 block discarded – undo
106 106
 	 * @param boolean $use_default
107 107
 	 * @return bool
108 108
 	 */
109
-	public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) {
109
+	public function set_status($new_STS_ID = NULL, $use_default = FALSE) {
110 110
 		// get current REG_Status
111 111
 		$old_STS_ID = $this->status_ID();
112 112
 		// if status has changed
113
-		if ( $old_STS_ID != $new_STS_ID  ) {
113
+		if ($old_STS_ID != $new_STS_ID) {
114 114
 			// TO approved
115
-			if ( $new_STS_ID == EEM_Registration::status_id_approved ) {
115
+			if ($new_STS_ID == EEM_Registration::status_id_approved) {
116 116
 				// reserve a space by incrementing ticket and datetime sold values
117 117
 				$this->_reserve_registration_space();
118
-				do_action( 'AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID );
118
+				do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID);
119 119
 			// OR FROM  approved
120
-			} else if ( $old_STS_ID == EEM_Registration::status_id_approved ) {
120
+			} else if ($old_STS_ID == EEM_Registration::status_id_approved) {
121 121
 				// release a space by decrementing ticket and datetime sold values
122 122
 				$this->_release_registration_space();
123
-				do_action( 'AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID );
123
+				do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID);
124 124
 			}
125 125
 			// update status
126
-			parent::set( 'STS_ID', $new_STS_ID, $use_default );
127
-			do_action( 'AHEE__EE_Registration__set_status__after_update', $this );
126
+			parent::set('STS_ID', $new_STS_ID, $use_default);
127
+			do_action('AHEE__EE_Registration__set_status__after_update', $this);
128 128
 			return TRUE;
129
-		}else{
129
+		} else {
130 130
 			//even though the old value matches the new value, it's still good to
131 131
 			//allow the parent set method to have a say
132
-			parent::set( 'STS_ID', $new_STS_ID, $use_default );
132
+			parent::set('STS_ID', $new_STS_ID, $use_default);
133 133
 			return TRUE;
134 134
 		}
135 135
 	}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @access        public
142 142
 	 */
143 143
 	public function status_ID() {
144
-		return $this->get( 'STS_ID' );
144
+		return $this->get('STS_ID');
145 145
 	}
146 146
 
147 147
 
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 	 * @param boolean $include_archived whether to include archived tickets or not.
167 167
 	 * @return EE_Ticket
168 168
 	 */
169
-	public function ticket( $include_archived = TRUE ) {
169
+	public function ticket($include_archived = TRUE) {
170 170
 		$query_params = array();
171
-		if ( $include_archived ) {
172
-			$query_params[ 'default_where_conditions' ] = 'none';
171
+		if ($include_archived) {
172
+			$query_params['default_where_conditions'] = 'none';
173 173
 		}
174
-		return $this->get_first_related( 'Ticket', $query_params );
174
+		return $this->get_first_related('Ticket', $query_params);
175 175
 	}
176 176
 
177 177
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @return EE_Event
182 182
 	 */
183 183
 	public function event() {
184
-		return $this->get_first_related( 'Event' );
184
+		return $this->get_first_related('Event');
185 185
 	}
186 186
 
187 187
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 */
196 196
 	public function wp_user() {
197 197
 		$event = $this->event();
198
-		if ( $event instanceof EE_Event ) {
198
+		if ($event instanceof EE_Event) {
199 199
 			return $event->wp_user();
200 200
 		}
201 201
 		return 0;
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 * @access        public
222 222
 	 * @param        int $ATT_ID Attendee ID
223 223
 	 */
224
-	public function set_attendee_id( $ATT_ID = 0 ) {
225
-		$this->set( 'ATT_ID', $ATT_ID );
224
+	public function set_attendee_id($ATT_ID = 0) {
225
+		$this->set('ATT_ID', $ATT_ID);
226 226
 	}
227 227
 
228 228
 
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 	 * @access        public
234 234
 	 * @param        int $TXN_ID Transaction ID
235 235
 	 */
236
-	public function set_transaction_id( $TXN_ID = 0 ) {
237
-		$this->set( 'TXN_ID', $TXN_ID );
236
+	public function set_transaction_id($TXN_ID = 0) {
237
+		$this->set('TXN_ID', $TXN_ID);
238 238
 	}
239 239
 
240 240
 
@@ -245,8 +245,8 @@  discard block
 block discarded – undo
245 245
 	 * @access    public
246 246
 	 * @param    string $REG_session PHP Session ID
247 247
 	 */
248
-	public function set_session( $REG_session = '' ) {
249
-		$this->set( 'REG_session', $REG_session );
248
+	public function set_session($REG_session = '') {
249
+		$this->set('REG_session', $REG_session);
250 250
 	}
251 251
 
252 252
 
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 	 * @access    public
258 258
 	 * @param    string $REG_url_link Registration URL Link
259 259
 	 */
260
-	public function set_reg_url_link( $REG_url_link = '' ) {
261
-		$this->set( 'REG_url_link', $REG_url_link );
260
+	public function set_reg_url_link($REG_url_link = '') {
261
+		$this->set('REG_url_link', $REG_url_link);
262 262
 	}
263 263
 
264 264
 
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 	 * @access        public
270 270
 	 * @param        int $REG_count Primary Attendee
271 271
 	 */
272
-	public function set_count( $REG_count = 1 ) {
273
-		$this->set( 'REG_count', $REG_count );
272
+	public function set_count($REG_count = 1) {
273
+		$this->set('REG_count', $REG_count);
274 274
 	}
275 275
 
276 276
 
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @access        public
282 282
 	 * @param        boolean $REG_group_size Group Registration
283 283
 	 */
284
-	public function set_group_size( $REG_group_size = FALSE ) {
285
-		$this->set( 'REG_group_size', $REG_group_size );
284
+	public function set_group_size($REG_group_size = FALSE) {
285
+		$this->set('REG_group_size', $REG_group_size);
286 286
 	}
287 287
 
288 288
 
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @access        public
366 366
 	 * @param        mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date
367 367
 	 */
368
-	public function set_reg_date( $REG_date = FALSE ) {
369
-		$this->set( 'REG_date', $REG_date );
368
+	public function set_reg_date($REG_date = FALSE) {
369
+		$this->set('REG_date', $REG_date);
370 370
 	}
371 371
 
372 372
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	 * @access    public
378 378
 	 * @param    float $REG_final_price
379 379
 	 */
380
-	public function set_final_price( $REG_final_price = 0.00 ) {
381
-		$this->set( 'REG_final_price', $REG_final_price );
380
+	public function set_final_price($REG_final_price = 0.00) {
381
+		$this->set('REG_final_price', $REG_final_price);
382 382
 	}
383 383
 
384 384
 
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 	 * @access    public
390 390
 	 * @param    float $REG_paid
391 391
 	 */
392
-	public function set_paid( $REG_paid = 0.00 ) {
393
-		$this->set( 'REG_paid', $REG_paid );
392
+	public function set_paid($REG_paid = 0.00) {
393
+		$this->set('REG_paid', $REG_paid);
394 394
 	}
395 395
 
396 396
 
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
 	 * @access        public
402 402
 	 * @param        boolean $REG_att_is_going Attendee Is Going
403 403
 	 */
404
-	public function set_att_is_going( $REG_att_is_going = FALSE ) {
405
-		$this->set( 'REG_att_is_going', $REG_att_is_going );
404
+	public function set_att_is_going($REG_att_is_going = FALSE) {
405
+		$this->set('REG_att_is_going', $REG_att_is_going);
406 406
 	}
407 407
 
408 408
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * @return EE_Attendee
413 413
 	 */
414 414
 	public function attendee() {
415
-		return $this->get_first_related( 'Attendee' );
415
+		return $this->get_first_related('Attendee');
416 416
 	}
417 417
 
418 418
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * @access        public
423 423
 	 */
424 424
 	public function event_ID() {
425
-		return $this->get( 'EVT_ID' );
425
+		return $this->get('EVT_ID');
426 426
 	}
427 427
 
428 428
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	 */
434 434
 	public function event_name() {
435 435
 		$event = $this->event_obj();
436
-		if ( $event ) {
436
+		if ($event) {
437 437
 			return $event->name();
438 438
 		} else {
439 439
 			return NULL;
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
 	 * @return EE_Event
448 448
 	 */
449 449
 	public function event_obj() {
450
-		return $this->get_first_related( 'Event' );
450
+		return $this->get_first_related('Event');
451 451
 	}
452 452
 
453 453
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	 * @access        public
458 458
 	 */
459 459
 	public function attendee_ID() {
460
-		return $this->get( 'ATT_ID' );
460
+		return $this->get('ATT_ID');
461 461
 	}
462 462
 
463 463
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 	 * @access        public
468 468
 	 */
469 469
 	public function session_ID() {
470
-		return $this->get( 'REG_session' );
470
+		return $this->get('REG_session');
471 471
 	}
472 472
 
473 473
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @param string $messenger 'pdf' or 'html'.  Default 'html'.
478 478
 	 * @return string
479 479
 	 */
480
-	public function receipt_url( $messenger = 'html' ) {
480
+	public function receipt_url($messenger = 'html') {
481 481
 
482 482
 		/**
483 483
 		 * The below will be deprecated one version after this.  We check first if there is a custom receipt template already in use on old system.  If there is then we just return the standard url for it.
@@ -485,12 +485,12 @@  discard block
 block discarded – undo
485 485
 		 * @since 4.5.0
486 486
 		 */
487 487
 		$template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php';
488
-		$has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE );
488
+		$has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE);
489 489
 
490
-		if ( $has_custom ) {
491
-			return add_query_arg( array( 'receipt' => 'true' ), $this->invoice_url( 'launch' ) );
490
+		if ($has_custom) {
491
+			return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch'));
492 492
 		}
493
-		return apply_filters( 'FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt' );
493
+		return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt');
494 494
 	}
495 495
 
496 496
 
@@ -501,28 +501,28 @@  discard block
 block discarded – undo
501 501
 	 * @param string $messenger 'pdf' or 'html'.  Default 'html'.
502 502
 	 * @return string
503 503
 	 */
504
-	public function invoice_url( $messenger = 'html' ) {
504
+	public function invoice_url($messenger = 'html') {
505 505
 		/**
506 506
 		 * The below will be deprecated one version after this.  We check first if there is a custom invoice template already in use on old system.  If there is then we just return the standard url for it.
507 507
 		 *
508 508
 		 * @since 4.5.0
509 509
 		 */
510 510
 		$template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php';
511
-		$has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE );
511
+		$has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE);
512 512
 
513
-		if ( $has_custom ) {
514
-			if ( $messenger == 'html' ) {
515
-				return $this->invoice_url( 'launch' );
513
+		if ($has_custom) {
514
+			if ($messenger == 'html') {
515
+				return $this->invoice_url('launch');
516 516
 			}
517 517
 			$route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice';
518 518
 
519
-			$query_args = array( 'ee' => $route, 'id' => $this->reg_url_link() );
520
-			if ( $messenger == 'html' ) {
519
+			$query_args = array('ee' => $route, 'id' => $this->reg_url_link());
520
+			if ($messenger == 'html') {
521 521
 				$query_args['html'] = TRUE;
522 522
 			}
523
-			return add_query_arg( $query_args, get_permalink( EE_Registry::instance()->CFG->core->thank_you_page_id ) );
523
+			return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id));
524 524
 		}
525
-		return apply_filters( 'FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice' );
525
+		return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice');
526 526
 	}
527 527
 
528 528
 
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 	 * @throws \EE_Error
536 536
 	 */
537 537
 	public function reg_url_link() {
538
-		return (string)$this->get( 'REG_url_link' );
538
+		return (string) $this->get('REG_url_link');
539 539
 	}
540 540
 
541 541
 
@@ -545,8 +545,8 @@  discard block
 block discarded – undo
545 545
 	 * @param string $type 'download','launch', or 'html' (default is 'launch')
546 546
 	 * @return void
547 547
 	 */
548
-	public function e_invoice_url( $type = 'launch' ) {
549
-		echo $this->invoice_url( $type );
548
+	public function e_invoice_url($type = 'launch') {
549
+		echo $this->invoice_url($type);
550 550
 	}
551 551
 
552 552
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 * @return string
567 567
 	 */
568 568
 	public function payment_overview_url() {
569
-		return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() );
569
+		return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url());
570 570
 	}
571 571
 
572 572
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	 * @return string
578 578
 	 */
579 579
 	public function edit_attendee_information_url() {
580
-		return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() );
580
+		return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url());
581 581
 	}
582 582
 
583 583
 
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 	 * @return string
588 588
 	 */
589 589
 	public function get_admin_edit_url() {
590
-		return EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID() ), admin_url( 'admin.php' ) );
590
+		return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php'));
591 591
 	}
592 592
 
593 593
 
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	 * @access        public
598 598
 	 */
599 599
 	public function is_primary_registrant() {
600
-		return $this->get( 'REG_count' ) == 1 ? TRUE : FALSE;
600
+		return $this->get('REG_count') == 1 ? TRUE : FALSE;
601 601
 	}
602 602
 
603 603
 
@@ -606,12 +606,12 @@  discard block
 block discarded – undo
606 606
 	 * This returns the primary registration object for this registration group (which may be this object).
607 607
 	 * @return EE_Registration
608 608
 	 */
609
-	public function get_primary_registration()  {
610
-		if ( $this->is_primary_registrant() )
609
+	public function get_primary_registration() {
610
+		if ($this->is_primary_registrant())
611 611
 			return $this;
612 612
 
613 613
 		//k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1
614
-		$primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) );
614
+		$primary_registrant = EEM_Registration::instance()->get_one(array(array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1)));
615 615
 		return $primary_registrant;
616 616
 	}
617 617
 
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 	* 		@access		public
623 623
 	*/
624 624
 	public function count() {
625
-		return $this->get( 'REG_count' );
625
+		return $this->get('REG_count');
626 626
 	}
627 627
 
628 628
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	 * @access        public
633 633
 	 */
634 634
 	public function group_size() {
635
-		return $this->get( 'REG_group_size' );
635
+		return $this->get('REG_group_size');
636 636
 	}
637 637
 
638 638
 
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 	 * @access        public
643 643
 	 */
644 644
 	public function date() {
645
-		return $this->get( 'REG_date' );
645
+		return $this->get('REG_date');
646 646
 	}
647 647
 
648 648
 
@@ -653,8 +653,8 @@  discard block
 block discarded – undo
653 653
 	 * @param string $time_format
654 654
 	 * @return string
655 655
 	 */
656
-	public function pretty_date( $date_format = NULL, $time_format = NULL ) {
657
-		return $this->get_datetime( 'REG_date', $date_format, $time_format );
656
+	public function pretty_date($date_format = NULL, $time_format = NULL) {
657
+		return $this->get_datetime('REG_date', $date_format, $time_format);
658 658
 	}
659 659
 
660 660
 
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	 * @return    float
668 668
 	 */
669 669
 	public function final_price() {
670
-		return $this->get( 'REG_final_price' );
670
+		return $this->get('REG_final_price');
671 671
 	}
672 672
 
673 673
 
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 	 * @return string
679 679
 	 */
680 680
 	public function pretty_final_price() {
681
-		return $this->get_pretty( 'REG_final_price' );
681
+		return $this->get_pretty('REG_final_price');
682 682
 	}
683 683
 
684 684
 
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 	 * @return 	float
690 690
 	 */
691 691
 	public function paid() {
692
-		return $this->get( 'REG_paid' );
692
+		return $this->get('REG_paid');
693 693
 	}
694 694
 
695 695
 
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	 * @return 	float
701 701
 	 */
702 702
 	public function pretty_paid() {
703
-		return $this->get_pretty( 'REG_paid' );
703
+		return $this->get_pretty('REG_paid');
704 704
 	}
705 705
 
706 706
 
@@ -712,11 +712,11 @@  discard block
 block discarded – undo
712 712
 	 * @param array $requires_payment
713 713
 	 * @return bool
714 714
 	 */
715
-	public function owes_monies_and_can_pay( $requires_payment = array()) {
715
+	public function owes_monies_and_can_pay($requires_payment = array()) {
716 716
 		// these reg statuses require payment (if event is not free)
717
-		$requires_payment = ! empty( $requires_payment ) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment();
717
+		$requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment();
718 718
 		if (
719
-			in_array( $this->status_ID(), $requires_payment ) &&
719
+			in_array($this->status_ID(), $requires_payment) &&
720 720
 			$this->final_price() != 0 &&
721 721
 			$this->final_price() != $this->paid()
722 722
 		) {
@@ -733,8 +733,8 @@  discard block
 block discarded – undo
733 733
 	 * @param bool $show_icons
734 734
 	 * @return void
735 735
 	 */
736
-	public function e_pretty_status( $show_icons = FALSE ) {
737
-		echo $this->pretty_status( $show_icons );
736
+	public function e_pretty_status($show_icons = FALSE) {
737
+		echo $this->pretty_status($show_icons);
738 738
 	}
739 739
 
740 740
 
@@ -745,10 +745,10 @@  discard block
 block discarded – undo
745 745
 	 * @param bool $show_icons
746 746
 	 * @return string
747 747
 	 */
748
-	public function pretty_status( $show_icons = FALSE ) {
749
-		$status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' );
748
+	public function pretty_status($show_icons = FALSE) {
749
+		$status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence');
750 750
 		$icon = '';
751
-		switch ( $this->status_ID() ) {
751
+		switch ($this->status_ID()) {
752 752
 			case EEM_Registration::status_id_approved:
753 753
 				$icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : '';
754 754
 				break;
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 				$icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : '';
769 769
 				break;
770 770
 		}
771
-		return $icon . $status[ $this->status_ID() ];
771
+		return $icon.$status[$this->status_ID()];
772 772
 	}
773 773
 
774 774
 
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 	 * @access        public
779 779
 	 */
780 780
 	public function att_is_going() {
781
-		return $this->get( 'REG_att_is_going' );
781
+		return $this->get('REG_att_is_going');
782 782
 	}
783 783
 
784 784
 
@@ -788,8 +788,8 @@  discard block
 block discarded – undo
788 788
 	 * @param array $query_params like EEM_Base::get_all
789 789
 	 * @return EE_Answer[]
790 790
 	 */
791
-	public function answers( $query_params = NULL ) {
792
-		return $this->get_many_related( 'Answer', $query_params );
791
+	public function answers($query_params = NULL) {
792
+		return $this->get_many_related('Answer', $query_params);
793 793
 	}
794 794
 
795 795
 
@@ -803,9 +803,9 @@  discard block
 block discarded – undo
803 803
 	 * (because the answer might be an array of answer values, so passing pretty_value=true
804 804
 	 * will convert it into some kind of string)
805 805
 	 */
806
-	public function answer_value_to_question( $question, $pretty_value=true ) {
806
+	public function answer_value_to_question($question, $pretty_value = true) {
807 807
 		$question_id = EEM_Question::instance()->ensure_is_ID($question);
808
-		return EEM_Answer::instance()->get_answer_value_to_question($this,$question_id,$pretty_value);
808
+		return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value);
809 809
 	}
810 810
 
811 811
 
@@ -818,13 +818,13 @@  discard block
 block discarded – undo
818 818
 	 */
819 819
 	public function question_groups() {
820 820
 		$question_groups = array();
821
-		if ( $this->event() instanceof EE_Event ) {
821
+		if ($this->event() instanceof EE_Event) {
822 822
 			$question_groups = $this->event()->question_groups(
823 823
 				array(
824 824
 					array(
825 825
 						'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false
826 826
 					),
827
-					'order_by' => array( 'QSG_order' => 'ASC' )
827
+					'order_by' => array('QSG_order' => 'ASC')
828 828
 				)
829 829
 			);
830 830
 		}
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	 */
842 842
 	public function count_question_groups() {
843 843
 		$qg_count = 0;
844
-		if ( $this->event() instanceof EE_Event ) {
844
+		if ($this->event() instanceof EE_Event) {
845 845
 			$qg_count = $this->event()->count_related(
846 846
 				'Question_Group',
847 847
 				array(
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 	 * @return string
863 863
 	 */
864 864
 	public function reg_date() {
865
-		return $this->get_datetime( 'REG_date' );
865
+		return $this->get_datetime('REG_date');
866 866
 	}
867 867
 
868 868
 
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 	 * @return EE_Datetime_Ticket
875 875
 	 */
876 876
 	public function datetime_ticket() {
877
-		return $this->get_first_related( 'Datetime_Ticket' );
877
+		return $this->get_first_related('Datetime_Ticket');
878 878
 	}
879 879
 
880 880
 
@@ -884,15 +884,15 @@  discard block
 block discarded – undo
884 884
 	 * @param EE_Datetime_Ticket $datetime_ticket
885 885
 	 * @return EE_Datetime_Ticket
886 886
 	 */
887
-	public function set_datetime_ticket( $datetime_ticket ) {
888
-		return $this->_add_relation_to( $datetime_ticket, 'Datetime_Ticket' );
887
+	public function set_datetime_ticket($datetime_ticket) {
888
+		return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket');
889 889
 	}
890 890
 	/**
891 891
 	 * Gets deleted
892 892
 	 * @return boolean
893 893
 	 */
894 894
 	public function deleted() {
895
-		return $this->get( 'REG_deleted' );
895
+		return $this->get('REG_deleted');
896 896
 	}
897 897
 
898 898
 	/**
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 	 * @return boolean
902 902
 	 */
903 903
 	public function set_deleted($deleted) {
904
-		$this->set( 'REG_deleted', $deleted );
904
+		$this->set('REG_deleted', $deleted);
905 905
 	}
906 906
 
907 907
 
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 	 * @return EE_Status
912 912
 	 */
913 913
 	public function status_obj() {
914
-		return $this->get_first_related( 'Status' );
914
+		return $this->get_first_related('Status');
915 915
 	}
916 916
 
917 917
 
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 	 * @return int
923 923
 	 */
924 924
 	public function count_checkins() {
925
-		return $this->get_model()->count_related( $this, 'Checkin' );
925
+		return $this->get_model()->count_related($this, 'Checkin');
926 926
 	}
927 927
 
928 928
 
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 	 * @return int
933 933
 	 */
934 934
 	public function count_checkins_not_checkedout() {
935
-		return $this->get_model()->count_related( $this, 'Checkin', array( array( 'CHK_in' => 1 ) ) );
935
+		return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1)));
936 936
 	}
937 937
 
938 938
 
@@ -945,20 +945,20 @@  discard block
 block discarded – undo
945 945
 	 *
946 946
 	 * @return bool
947 947
 	 */
948
-	public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) {
949
-		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID );
948
+	public function can_checkin($DTT_OR_ID, $check_approved = TRUE) {
949
+		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
950 950
 
951 951
 		//first check registration status
952
-		if (  ( $check_approved && ! $this->is_approved() ) || ! $DTT_ID ) {
952
+		if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) {
953 953
 			return false;
954 954
 		}
955 955
 		//is there a datetime ticket that matches this dtt_ID?
956
-		if ( ! ( EEM_Datetime_Ticket::instance()->exists( array( array( 'TKT_ID' => $this->get('TKT_ID' ), 'DTT_ID' => $DTT_ID ) ) ) ) ) {
956
+		if ( ! (EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID))))) {
957 957
 			return false;
958 958
 		}
959 959
 
960 960
 		//final check is against TKT_uses
961
-		return $this->verify_can_checkin_against_TKT_uses( $DTT_ID );
961
+		return $this->verify_can_checkin_against_TKT_uses($DTT_ID);
962 962
 	}
963 963
 
964 964
 
@@ -971,10 +971,10 @@  discard block
 block discarded – undo
971 971
 	 * @param int | EE_Datetime  $DTT_OR_ID  The datetime the registration is being checked against
972 972
 	 * @return bool   true means can checkin.  false means cannot checkin.
973 973
 	 */
974
-	public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) {
975
-		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID );
974
+	public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) {
975
+		$DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
976 976
 
977
-		if ( ! $DTT_ID ) {
977
+		if ( ! $DTT_ID) {
978 978
 			return false;
979 979
 		}
980 980
 
@@ -982,23 +982,23 @@  discard block
 block discarded – undo
982 982
 
983 983
 		// if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in
984 984
 		// or not.
985
-		if ( ! $max_uses || $max_uses === EE_INF ) {
985
+		if ( ! $max_uses || $max_uses === EE_INF) {
986 986
 			return true;
987 987
 		}
988 988
 
989 989
 		//does this datetime have a checkin record?  If so, then the dtt count has already been verified so we can just
990 990
 		//go ahead and toggle.
991
-		if ( EEM_Checkin::instance()->exists( array( array( 'REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID ) ) ) ) {
991
+		if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) {
992 992
 			return true;
993 993
 		}
994 994
 
995 995
 		//made it here so the last check is whether the number of checkins per unique datetime on this registration
996 996
 		//disallows further check-ins.
997
-		$count_unique_dtt_checkins = EEM_Checkin::instance()->count( array( array( 'REG_ID' => $this->ID(), 'CHK_in' => true ) ), 'DTT_ID', true );
997
+		$count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(array('REG_ID' => $this->ID(), 'CHK_in' => true)), 'DTT_ID', true);
998 998
 		// checkins have already reached their max number of uses
999 999
 		// so registrant can NOT checkin
1000
-		if ( $count_unique_dtt_checkins >= $max_uses ) {
1001
-			EE_Error::add_error( __( 'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1000
+		if ($count_unique_dtt_checkins >= $max_uses) {
1001
+			EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1002 1002
 			return false;
1003 1003
 		}
1004 1004
 		return true;
@@ -1019,15 +1019,15 @@  discard block
 block discarded – undo
1019 1019
 	 * @param  bool $verify  If true then can_checkin() is used to verify whether the person can be checked in or not.  Otherwise this forces change in checkin status.
1020 1020
 	 * @return int|BOOL            the chk_in status toggled to OR false if nothing got changed.
1021 1021
 	 */
1022
-	public function toggle_checkin_status( $DTT_ID = null, $verify = false ) {
1023
-		if ( empty( $DTT_ID ) ) {
1022
+	public function toggle_checkin_status($DTT_ID = null, $verify = false) {
1023
+		if (empty($DTT_ID)) {
1024 1024
 			$datetime = $this->get_related_primary_datetime();
1025 1025
 			$DTT_ID = $datetime->ID();
1026 1026
 		// verify the registration can checkin for the given DTT_ID
1027
-		} elseif ( ! $this->can_checkin( $DTT_ID, $verify ) ) {
1027
+		} elseif ( ! $this->can_checkin($DTT_ID, $verify)) {
1028 1028
 			EE_Error::add_error(
1029 1029
 					sprintf(
1030
-						__( 'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'),
1030
+						__('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'),
1031 1031
 						$this->ID(),
1032 1032
 						$DTT_ID
1033 1033
 					),
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
 			EE_Registration::checkin_status_out => EE_Registration::checkin_status_in
1042 1042
 		);
1043 1043
 		//start by getting the current status so we know what status we'll be changing to.
1044
-		$cur_status = $this->check_in_status_for_datetime( $DTT_ID, NULL );
1045
-		$status_to = $status_paths[ $cur_status ];
1044
+		$cur_status = $this->check_in_status_for_datetime($DTT_ID, NULL);
1045
+		$status_to = $status_paths[$cur_status];
1046 1046
 		// database only records true for checked IN or false for checked OUT
1047 1047
 		// no record ( null ) means checked in NEVER, but we obviously don't save that
1048 1048
 		$new_status = $status_to == EE_Registration::checkin_status_in ? true : false;
@@ -1050,24 +1050,24 @@  discard block
 block discarded – undo
1050 1050
 		// because we are keeping track of Check-ins over time.
1051 1051
 		// Eventually we'll probably want to show a list table
1052 1052
 		// for the individual Check-ins so that they can be managed.
1053
-		$checkin = EE_Checkin::new_instance( array(
1053
+		$checkin = EE_Checkin::new_instance(array(
1054 1054
 				'REG_ID' => $this->ID(),
1055 1055
 				'DTT_ID' => $DTT_ID,
1056 1056
 				'CHK_in' => $new_status
1057
-		) );
1057
+		));
1058 1058
 		// if the record could not be saved then return false
1059
-		if ( $checkin->save() === 0 ) {
1060
-			if ( WP_DEBUG ) {
1059
+		if ($checkin->save() === 0) {
1060
+			if (WP_DEBUG) {
1061 1061
 				global $wpdb;
1062 1062
 				$error = sprintf(
1063
-					__( 'Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso' ),
1063
+					__('Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso'),
1064 1064
 					'<br />',
1065 1065
 					$wpdb->last_error
1066 1066
 				);
1067 1067
 			} else {
1068
-				$error = __( 'Registration check in update failed because of an unknown database error', 'event_espresso' );
1068
+				$error = __('Registration check in update failed because of an unknown database error', 'event_espresso');
1069 1069
 			}
1070
-			EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ );
1070
+			EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
1071 1071
 			return false;
1072 1072
 		}
1073 1073
 		return $status_to;
@@ -1091,19 +1091,19 @@  discard block
 block discarded – undo
1091 1091
 	 * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id.
1092 1092
 	 * @return int            Integer representing Check-in status.
1093 1093
 	 */
1094
-	public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = NULL ) {
1095
-		if ( empty( $DTT_ID ) && ! $checkin instanceof EE_Checkin ) {
1094
+	public function check_in_status_for_datetime($DTT_ID = 0, $checkin = NULL) {
1095
+		if (empty($DTT_ID) && ! $checkin instanceof EE_Checkin) {
1096 1096
 			$datetime = $this->get_related_primary_datetime();
1097
-			if ( ! $datetime instanceof EE_Datetime ) {
1097
+			if ( ! $datetime instanceof EE_Datetime) {
1098 1098
 				return 0;
1099 1099
 			}
1100 1100
 			$DTT_ID = $datetime->ID();
1101 1101
 		//verify the registration can checkin for the given DTT_ID
1102 1102
 		}
1103 1103
 		//get checkin object (if exists)
1104
-		$checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ), 'order_by' => array( 'CHK_timestamp' => 'DESC' ) ) );
1105
-		if ( $checkin instanceof EE_Checkin ) {
1106
-			if ( $checkin->get( 'CHK_in' ) ) {
1104
+		$checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related('Checkin', array(array('DTT_ID' => $DTT_ID), 'order_by' => array('CHK_timestamp' => 'DESC')));
1105
+		if ($checkin instanceof EE_Checkin) {
1106
+			if ($checkin->get('CHK_in')) {
1107 1107
 				return EE_Registration::checkin_status_in; //checked in
1108 1108
 			} else {
1109 1109
 				return EE_Registration::checkin_status_out; //had checked in but is now checked out.
@@ -1121,28 +1121,28 @@  discard block
 block discarded – undo
1121 1121
 	 * @param bool $error  This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name.
1122 1122
 	 * @return string         internationalized message
1123 1123
 	 */
1124
-	public function get_checkin_msg( $DTT_ID, $error = FALSE ) {
1124
+	public function get_checkin_msg($DTT_ID, $error = FALSE) {
1125 1125
 		//let's get the attendee first so we can include the name of the attendee
1126
-		$attendee = $this->get_first_related( 'Attendee' );
1127
-		if ( $attendee instanceof EE_Attendee ) {
1128
-			if ( $error ) {
1129
-				return sprintf( __( "%s's check-in status was not changed.", "event_espresso" ), $attendee->full_name() );
1126
+		$attendee = $this->get_first_related('Attendee');
1127
+		if ($attendee instanceof EE_Attendee) {
1128
+			if ($error) {
1129
+				return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name());
1130 1130
 			}
1131
-			$cur_status = $this->check_in_status_for_datetime( $DTT_ID );
1131
+			$cur_status = $this->check_in_status_for_datetime($DTT_ID);
1132 1132
 			//what is the status message going to be?
1133
-			switch ( $cur_status ) {
1133
+			switch ($cur_status) {
1134 1134
 				case EE_Registration::checkin_status_never :
1135
-					return sprintf( __( "%s has been removed from Check-in records", "event_espresso" ), $attendee->full_name() );
1135
+					return sprintf(__("%s has been removed from Check-in records", "event_espresso"), $attendee->full_name());
1136 1136
 					break;
1137 1137
 				case EE_Registration::checkin_status_in :
1138
-					return sprintf( __( '%s has been checked in', 'event_espresso' ), $attendee->full_name() );
1138
+					return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name());
1139 1139
 					break;
1140 1140
 				case EE_Registration::checkin_status_out :
1141
-					return sprintf( __( '%s has been checked out', 'event_espresso' ), $attendee->full_name() );
1141
+					return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name());
1142 1142
 					break;
1143 1143
 			}
1144 1144
 		}
1145
-		return __( "The check-in status could not be determined.", "event_espresso" );
1145
+		return __("The check-in status could not be determined.", "event_espresso");
1146 1146
 	}
1147 1147
 
1148 1148
 
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 	 * @return EE_Transaction
1153 1153
 	 */
1154 1154
 	public function transaction() {
1155
-		return $this->get_first_related( 'Transaction' );
1155
+		return $this->get_first_related('Transaction');
1156 1156
 	}
1157 1157
 
1158 1158
 
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 	 * @access        public
1164 1164
 	 */
1165 1165
 	public function reg_code() {
1166
-		return $this->get( 'REG_code' );
1166
+		return $this->get('REG_code');
1167 1167
 	}
1168 1168
 
1169 1169
 
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
 	 * @access        public
1174 1174
 	 */
1175 1175
 	public function transaction_ID() {
1176
-		return $this->get( 'TXN_ID' );
1176
+		return $this->get('TXN_ID');
1177 1177
 	}
1178 1178
 
1179 1179
 
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 	 * @return int
1183 1183
 	 */
1184 1184
 	public function ticket_ID() {
1185
-		return $this->get( 'TKT_ID' );
1185
+		return $this->get('TKT_ID');
1186 1186
 	}
1187 1187
 
1188 1188
 
@@ -1194,17 +1194,17 @@  discard block
 block discarded – undo
1194 1194
 	 * @param    string $REG_code Registration Code
1195 1195
 	 * @param	boolean $use_default
1196 1196
 	 */
1197
-	public function set_reg_code( $REG_code, $use_default = FALSE ) {
1198
-		if ( empty( $REG_code )) {
1199
-			EE_Error::add_error( __( 'REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1197
+	public function set_reg_code($REG_code, $use_default = FALSE) {
1198
+		if (empty($REG_code)) {
1199
+			EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1200 1200
 			return;
1201 1201
 		}
1202
-		if ( ! $this->reg_code() ) {
1203
-			parent::set( 'REG_code', $REG_code, $use_default );
1202
+		if ( ! $this->reg_code()) {
1203
+			parent::set('REG_code', $REG_code, $use_default);
1204 1204
 		} else {
1205 1205
 			EE_Error::doing_it_wrong(
1206
-				__CLASS__ . '::' . __FUNCTION__,
1207
-				__( 'Can not change a registration REG_code once it has been set.', 'event_espresso' ),
1206
+				__CLASS__.'::'.__FUNCTION__,
1207
+				__('Can not change a registration REG_code once it has been set.', 'event_espresso'),
1208 1208
 				'4.6.0'
1209 1209
 			);
1210 1210
 		}
@@ -1224,17 +1224,17 @@  discard block
 block discarded – undo
1224 1224
 	 * @return EE_Registration[]  or empty array if this isn't a group registration.
1225 1225
 	 */
1226 1226
 	public function get_all_other_registrations_in_group() {
1227
-		if ( $this->group_size() < 2 ) {
1227
+		if ($this->group_size() < 2) {
1228 1228
 			return array();
1229 1229
 		}
1230 1230
 
1231 1231
 		$query[0] = array(
1232 1232
 			'TXN_ID' => $this->transaction_ID(),
1233
-			'REG_ID' => array( '!=', $this->ID() ),
1233
+			'REG_ID' => array('!=', $this->ID()),
1234 1234
 			'TKT_ID' => $this->ticket_ID()
1235 1235
 			);
1236 1236
 
1237
-		$registrations = $this->get_model()->get_all( $query );
1237
+		$registrations = $this->get_model()->get_all($query);
1238 1238
 		return $registrations;
1239 1239
 	}
1240 1240
 
@@ -1244,8 +1244,8 @@  discard block
 block discarded – undo
1244 1244
 	 * @param array $query_params
1245 1245
 	 * @return \EE_Registration[]
1246 1246
 	 */
1247
-	public function payments( $query_params = array() ) {
1248
-		return $this->get_many_related( 'Payment', $query_params );
1247
+	public function payments($query_params = array()) {
1248
+		return $this->get_many_related('Payment', $query_params);
1249 1249
 	}
1250 1250
 
1251 1251
 
@@ -1254,8 +1254,8 @@  discard block
 block discarded – undo
1254 1254
 	 * @param array $query_params
1255 1255
 	 * @return \EE_Registration[]
1256 1256
 	 */
1257
-	public function registration_payments( $query_params = array() ) {
1258
-		return $this->get_many_related( 'Registration_Payment', $query_params );
1257
+	public function registration_payments($query_params = array()) {
1258
+		return $this->get_many_related('Registration_Payment', $query_params);
1259 1259
 	}
1260 1260
 
1261 1261
 
@@ -1266,7 +1266,7 @@  discard block
 block discarded – undo
1266 1266
 	 * @access 	public
1267 1267
 	 */
1268 1268
 	public function price_paid() {
1269
-		EE_Error::doing_it_wrong( 'EE_Registration::price_paid()', __( 'This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso' ), '4.7.0' );
1269
+		EE_Error::doing_it_wrong('EE_Registration::price_paid()', __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), '4.7.0');
1270 1270
 		return $this->final_price();
1271 1271
 	}
1272 1272
 
@@ -1278,9 +1278,9 @@  discard block
 block discarded – undo
1278 1278
 	 * @access    public
1279 1279
 	 * @param    float $REG_final_price
1280 1280
 	 */
1281
-	public function set_price_paid( $REG_final_price = 0.00 ) {
1282
-		EE_Error::doing_it_wrong( 'EE_Registration::set_price_paid()', __( 'This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso' ), '4.7.0' );
1283
-		$this->set_final_price( $REG_final_price );
1281
+	public function set_price_paid($REG_final_price = 0.00) {
1282
+		EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), '4.7.0');
1283
+		$this->set_final_price($REG_final_price);
1284 1284
 	}
1285 1285
 
1286 1286
 
@@ -1291,7 +1291,7 @@  discard block
 block discarded – undo
1291 1291
 	 * @return string
1292 1292
 	 */
1293 1293
 	public function pretty_price_paid() {
1294
-		EE_Error::doing_it_wrong( 'EE_Registration::pretty_price_paid()', __( 'This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso' ), '4.7.0' );
1294
+		EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso'), '4.7.0');
1295 1295
 		return $this->pretty_final_price();
1296 1296
 	}
1297 1297
 
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 	 * @return EE_Payment_Method|null
1306 1306
 	 */
1307 1307
 	public function payment_method() {
1308
-		return EEM_Payment_Method::instance()->get_last_used_for_registration( $this );
1308
+		return EEM_Payment_Method::instance()->get_last_used_for_registration($this);
1309 1309
 	}
1310 1310
 
1311 1311
 
Please login to merge, or discard this patch.
core/db_classes/EE_Line_Item.class.php 1 patch
Spacing   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
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
  * Event Espresso
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	 *                             		    date_format and the second value is the time format
51 51
 	 * @return EE_Line_Item
52 52
 	 */
53
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
54
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
55
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
53
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
54
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
55
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
56 56
 	}
57 57
 
58 58
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 *                          		the website will be used.
64 64
 	 * @return EE_Line_Item
65 65
 	 */
66
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
67
-		return new self( $props_n_values, TRUE, $timezone );
66
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
67
+		return new self($props_n_values, TRUE, $timezone);
68 68
 	}
69 69
 
70 70
 
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	 * @param bool   $bydb
76 76
 	 * @param string $timezone
77 77
 	 */
78
-	protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '' ) {
79
-		parent::__construct( $fieldValues, $bydb, $timezone );
80
-		if ( ! $this->get( 'LIN_code' ) ) {
81
-			$this->set_code( $this->generate_code() );
78
+	protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '') {
79
+		parent::__construct($fieldValues, $bydb, $timezone);
80
+		if ( ! $this->get('LIN_code')) {
81
+			$this->set_code($this->generate_code());
82 82
 		}
83 83
 	}
84 84
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return int
90 90
 	 */
91 91
 	function ID() {
92
-		return $this->get( 'LIN_ID' );
92
+		return $this->get('LIN_ID');
93 93
 	}
94 94
 
95 95
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @return int
100 100
 	 */
101 101
 	function TXN_ID() {
102
-		return $this->get( 'TXN_ID' );
102
+		return $this->get('TXN_ID');
103 103
 	}
104 104
 
105 105
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param int $TXN_ID
110 110
 	 * @return boolean
111 111
 	 */
112
-	function set_TXN_ID( $TXN_ID ) {
113
-		$this->set( 'TXN_ID', $TXN_ID );
112
+	function set_TXN_ID($TXN_ID) {
113
+		$this->set('TXN_ID', $TXN_ID);
114 114
 	}
115 115
 
116 116
 
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	 * @return string
121 121
 	 */
122 122
 	function name() {
123
-		$name =  $this->get( 'LIN_name' );
124
-		if( ! $name ){
125
-			$name = ucwords( str_replace( '-', ' ', $this->type() ) );
123
+		$name = $this->get('LIN_name');
124
+		if ( ! $name) {
125
+			$name = ucwords(str_replace('-', ' ', $this->type()));
126 126
 		}
127 127
 		return $name;
128 128
 	}
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 * @param string $name
135 135
 	 * @return boolean
136 136
 	 */
137
-	function set_name( $name ) {
138
-		$this->set( 'LIN_name', $name );
137
+	function set_name($name) {
138
+		$this->set('LIN_name', $name);
139 139
 	}
140 140
 
141 141
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return string
146 146
 	 */
147 147
 	function desc() {
148
-		return $this->get( 'LIN_desc' );
148
+		return $this->get('LIN_desc');
149 149
 	}
150 150
 
151 151
 
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	 * @param string $desc
156 156
 	 * @return boolean
157 157
 	 */
158
-	function set_desc( $desc ) {
159
-		$this->set( 'LIN_desc', $desc );
158
+	function set_desc($desc) {
159
+		$this->set('LIN_desc', $desc);
160 160
 	}
161 161
 
162 162
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 * @return int
167 167
 	 */
168 168
 	function quantity() {
169
-		return $this->get( 'LIN_quantity' );
169
+		return $this->get('LIN_quantity');
170 170
 	}
171 171
 
172 172
 
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	 * @param int $quantity
177 177
 	 * @return boolean
178 178
 	 */
179
-	function set_quantity( $quantity ) {
180
-		$this->set( 'LIN_quantity', $quantity );
179
+	function set_quantity($quantity) {
180
+		$this->set('LIN_quantity', $quantity);
181 181
 	}
182 182
 
183 183
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @return string
188 188
 	 */
189 189
 	function OBJ_ID() {
190
-		return $this->get( 'OBJ_ID' );
190
+		return $this->get('OBJ_ID');
191 191
 	}
192 192
 
193 193
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param string $item_id
198 198
 	 * @return boolean
199 199
 	 */
200
-	function set_OBJ_ID( $item_id ) {
201
-		$this->set( 'OBJ_ID', $item_id );
200
+	function set_OBJ_ID($item_id) {
201
+		$this->set('OBJ_ID', $item_id);
202 202
 	}
203 203
 
204 204
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @return string
209 209
 	 */
210 210
 	function OBJ_type() {
211
-		return $this->get( 'OBJ_type' );
211
+		return $this->get('OBJ_type');
212 212
 	}
213 213
 
214 214
 
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 	 * @param string $OBJ_type
219 219
 	 * @return boolean
220 220
 	 */
221
-	function set_OBJ_type( $OBJ_type ) {
222
-		$this->set( 'OBJ_type', $OBJ_type );
221
+	function set_OBJ_type($OBJ_type) {
222
+		$this->set('OBJ_type', $OBJ_type);
223 223
 	}
224 224
 
225 225
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 * @return float
230 230
 	 */
231 231
 	function unit_price() {
232
-		return $this->get( 'LIN_unit_price' );
232
+		return $this->get('LIN_unit_price');
233 233
 	}
234 234
 
235 235
 
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 	 * @param float $unit_price
240 240
 	 * @return boolean
241 241
 	 */
242
-	function set_unit_price( $unit_price ) {
243
-		$this->set( 'LIN_unit_price', $unit_price );
242
+	function set_unit_price($unit_price) {
243
+		$this->set('LIN_unit_price', $unit_price);
244 244
 	}
245 245
 
246 246
 
@@ -251,19 +251,19 @@  discard block
 block discarded – undo
251 251
 	 * @return boolean
252 252
 	 */
253 253
 	function is_percent() {
254
-		if( $this->is_tax_sub_total() ) {
254
+		if ($this->is_tax_sub_total()) {
255 255
 			//tax subtotals HAVE a percent on them, that percentage only applies
256 256
 			//to taxable items, so its' an exception. Treat it like a flat line item
257 257
 			return false;
258 258
 		}
259
-		$unit_price = abs( $this->get( 'LIN_unit_price' ) );
260
-		$percent = abs( $this->get( 'LIN_percent' ) );
261
-		if ( $unit_price < .001 && $percent ) {
259
+		$unit_price = abs($this->get('LIN_unit_price'));
260
+		$percent = abs($this->get('LIN_percent'));
261
+		if ($unit_price < .001 && $percent) {
262 262
 			return TRUE;
263
-		} elseif ( $unit_price >= .001 && !$percent ) {
263
+		} elseif ($unit_price >= .001 && ! $percent) {
264 264
 			return FALSE;
265
-		} elseif ( $unit_price >= .001 && $percent ) {
266
-			throw new EE_Error( sprintf( __( "A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso" ), $unit_price, $percent ) );
265
+		} elseif ($unit_price >= .001 && $percent) {
266
+			throw new EE_Error(sprintf(__("A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso"), $unit_price, $percent));
267 267
 		} else {
268 268
 			// if they're both 0, assume its not a percent item
269 269
 			return FALSE;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 * @return float
278 278
 	 */
279 279
 	function percent() {
280
-		return $this->get( 'LIN_percent' );
280
+		return $this->get('LIN_percent');
281 281
 	}
282 282
 
283 283
 
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 	 * @param float $percent
288 288
 	 * @return boolean
289 289
 	 */
290
-	function set_percent( $percent ) {
291
-		$this->set( 'LIN_percent', $percent );
290
+	function set_percent($percent) {
291
+		$this->set('LIN_percent', $percent);
292 292
 	}
293 293
 
294 294
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 * @return float
299 299
 	 */
300 300
 	function total() {
301
-		return $this->get( 'LIN_total' );
301
+		return $this->get('LIN_total');
302 302
 	}
303 303
 
304 304
 
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 	 * @param float $total
309 309
 	 * @return boolean
310 310
 	 */
311
-	function set_total( $total ) {
312
-		$this->set( 'LIN_total', $total );
311
+	function set_total($total) {
312
+		$this->set('LIN_total', $total);
313 313
 	}
314 314
 
315 315
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @return int
320 320
 	 */
321 321
 	function order() {
322
-		return $this->get( 'LIN_order' );
322
+		return $this->get('LIN_order');
323 323
 	}
324 324
 
325 325
 
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 	 * Sets order
329 329
 	 * @param int $order
330 330
 	 */
331
-	function set_order( $order ) {
332
-		$this->set( 'LIN_order', $order );
331
+	function set_order($order) {
332
+		$this->set('LIN_order', $order);
333 333
 	}
334 334
 
335 335
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	 * @return int
340 340
 	 */
341 341
 	function parent_ID() {
342
-		return $this->get( 'LIN_parent' );
342
+		return $this->get('LIN_parent');
343 343
 	}
344 344
 
345 345
 
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
 	 * @param int $parent
350 350
 	 * @return boolean
351 351
 	 */
352
-	function set_parent_ID( $parent ) {
353
-		$this->set( 'LIN_parent', $parent );
352
+	function set_parent_ID($parent) {
353
+		$this->set('LIN_parent', $parent);
354 354
 	}
355 355
 
356 356
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * @return string
361 361
 	 */
362 362
 	function type() {
363
-		return $this->get( 'LIN_type' );
363
+		return $this->get('LIN_type');
364 364
 	}
365 365
 
366 366
 
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 	 * @param string $type
371 371
 	 * @return boolean
372 372
 	 */
373
-	function set_type( $type ) {
374
-		$this->set( 'LIN_type', $type );
373
+	function set_type($type) {
374
+		$this->set('LIN_type', $type);
375 375
 	}
376 376
 
377 377
 
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
 	 * @return EE_Line_Item
385 385
 	 */
386 386
 	public function parent() {
387
-		if( $this->ID() ) {
388
-			return $this->get_model()->get_one_by_ID( $this->parent_ID() );
387
+		if ($this->ID()) {
388
+			return $this->get_model()->get_one_by_ID($this->parent_ID());
389 389
 		} else {
390 390
 			return $this->_parent;
391 391
 		}
@@ -398,13 +398,13 @@  discard block
 block discarded – undo
398 398
 	 * @return EE_Line_Item[]
399 399
 	 */
400 400
 	public function children() {
401
-		if ( $this->ID() ) {
401
+		if ($this->ID()) {
402 402
 			return $this->get_model()->get_all(
403 403
 					array(
404
-						array( 'LIN_parent' => $this->ID() ),
405
-						'order_by' => array( 'LIN_order' => 'ASC' ) ) );
404
+						array('LIN_parent' => $this->ID()),
405
+						'order_by' => array('LIN_order' => 'ASC') ) );
406 406
 		} else {
407
-			if ( ! is_array( $this->_children ) ) {
407
+			if ( ! is_array($this->_children)) {
408 408
 				$this->_children = array();
409 409
 			}
410 410
 			return $this->_children;
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	 * @return string
419 419
 	 */
420 420
 	function code() {
421
-		return $this->get( 'LIN_code' );
421
+		return $this->get('LIN_code');
422 422
 	}
423 423
 
424 424
 
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 	 * @param string $code
429 429
 	 * @return boolean
430 430
 	 */
431
-	function set_code( $code ) {
432
-		$this->set( 'LIN_code', $code );
431
+	function set_code($code) {
432
+		$this->set('LIN_code', $code);
433 433
 	}
434 434
 
435 435
 
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	 * @return boolean
440 440
 	 */
441 441
 	function is_taxable() {
442
-		return $this->get( 'LIN_is_taxable' );
442
+		return $this->get('LIN_is_taxable');
443 443
 	}
444 444
 
445 445
 
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 	 * @param boolean $is_taxable
450 450
 	 * @return boolean
451 451
 	 */
452
-	function set_is_taxable( $is_taxable ) {
453
-		$this->set( 'LIN_is_taxable', $is_taxable );
452
+	function set_is_taxable($is_taxable) {
453
+		$this->set('LIN_is_taxable', $is_taxable);
454 454
 	}
455 455
 
456 456
 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 	 */
466 466
 	function get_object() {
467 467
 		$model_name_of_related_obj = $this->OBJ_type();
468
-		return $this->get_model()->has_relation(  $model_name_of_related_obj ) ? $this->get_first_related( $model_name_of_related_obj ) : NULL;
468
+		return $this->get_model()->has_relation($model_name_of_related_obj) ? $this->get_first_related($model_name_of_related_obj) : NULL;
469 469
 	}
470 470
 
471 471
 
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 	 * @param array $query_params
477 477
 	 * @return EE_Ticket
478 478
 	 */
479
-	function ticket( $query_params = array() ) {
479
+	function ticket($query_params = array()) {
480 480
 		//we're going to assume that when this method is called we always want to receive the attached ticket EVEN if that ticket is archived.  This can be overridden via the incoming $query_params argument
481
-		$remove_defaults = array( 'default_where_conditions' => 'none' );
482
-		$query_params = array_merge( $remove_defaults, $query_params );
483
-		return $this->get_first_related( 'Ticket', $query_params );
481
+		$remove_defaults = array('default_where_conditions' => 'none');
482
+		$query_params = array_merge($remove_defaults, $query_params);
483
+		return $this->get_first_related('Ticket', $query_params);
484 484
 	}
485 485
 
486 486
 
@@ -490,11 +490,11 @@  discard block
 block discarded – undo
490 490
 	 * @return EE_Datetime | NULL
491 491
 	 */
492 492
 	function get_ticket_datetime() {
493
-		if ( $this->OBJ_type() === 'Ticket' ) {
493
+		if ($this->OBJ_type() === 'Ticket') {
494 494
 			$ticket = $this->ticket();
495
-			if ( $ticket instanceof EE_Ticket ) {
495
+			if ($ticket instanceof EE_Ticket) {
496 496
 				$datetime = $ticket->first_datetime();
497
-				if ( $datetime instanceof EE_Datetime ) {
497
+				if ($datetime instanceof EE_Datetime) {
498 498
 					return $datetime;
499 499
 				}
500 500
 			}
@@ -510,9 +510,9 @@  discard block
 block discarded – undo
510 510
 	 * @return string
511 511
 	 */
512 512
 	function ticket_event_name() {
513
-		$event_name = __( "Unknown", "event_espresso" );
513
+		$event_name = __("Unknown", "event_espresso");
514 514
 		$event = $this->ticket_event();
515
-		if ( $event instanceof EE_Event ) {
515
+		if ($event instanceof EE_Event) {
516 516
 			$event_name = $event->name();
517 517
 		}
518 518
 		return $event_name;
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 	function ticket_event() {
527 527
 		$event = null;
528 528
 		$ticket = $this->ticket();
529
-		if ( $ticket instanceof EE_Ticket ) {
529
+		if ($ticket instanceof EE_Ticket) {
530 530
 			$datetime = $ticket->first_datetime();
531
-			if ( $datetime instanceof EE_Datetime ) {
531
+			if ($datetime instanceof EE_Datetime) {
532 532
 				$event = $datetime->event();
533 533
 			}
534 534
 		}
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
 	 * @param string $time_format
544 544
 	 * @return string
545 545
 	 */
546
-	function ticket_datetime_start( $date_format = '', $time_format = '' ) {
547
-		$first_datetime_string = __( "Unknown", "event_espresso" );
546
+	function ticket_datetime_start($date_format = '', $time_format = '') {
547
+		$first_datetime_string = __("Unknown", "event_espresso");
548 548
 		$datetime = $this->get_ticket_datetime();
549
-		if ( $datetime ) {
550
-			$first_datetime_string = $datetime->start_date_and_time( $date_format, $time_format );
549
+		if ($datetime) {
550
+			$first_datetime_string = $datetime->start_date_and_time($date_format, $time_format);
551 551
 		}
552 552
 		return $first_datetime_string;
553 553
 	}
@@ -562,26 +562,26 @@  discard block
 block discarded – undo
562 562
 	 * @return bool success
563 563
 	 * @throws \EE_Error
564 564
 	 */
565
-	function add_child_line_item( EEI_Line_Item $line_item, $set_order = true ) {
565
+	function add_child_line_item(EEI_Line_Item $line_item, $set_order = true) {
566 566
 		// should we calculate the LIN_order for this line item ?
567
-		if ( $set_order || $line_item->order() === null ) {
568
-			$line_item->set_order( count( $this->children() ) );
567
+		if ($set_order || $line_item->order() === null) {
568
+			$line_item->set_order(count($this->children()));
569 569
 		}
570
-		if ( $this->ID() ) {
570
+		if ($this->ID()) {
571 571
 			//check for any duplicate line items (with the same code), if so, this replaces it
572
-			$line_item_with_same_code = $this->get_child_line_item(  $line_item->code() );
573
-			if( $line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item ) {
574
-				$this->delete_child_line_item( $line_item_with_same_code->code() );
572
+			$line_item_with_same_code = $this->get_child_line_item($line_item->code());
573
+			if ($line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item) {
574
+				$this->delete_child_line_item($line_item_with_same_code->code());
575 575
 			}
576
-			$line_item->set_parent_ID( $this->ID() );
577
-			if( $this->TXN_ID() ){
578
-				$line_item->set_TXN_ID( $this->TXN_ID() );
576
+			$line_item->set_parent_ID($this->ID());
577
+			if ($this->TXN_ID()) {
578
+				$line_item->set_TXN_ID($this->TXN_ID());
579 579
 			}
580 580
 			return $line_item->save();
581 581
 		} else {
582
-			$this->_children[ $line_item->code() ] = $line_item;
583
-			if( $line_item->parent() != $this ) {
584
-				$line_item->set_parent( $this );
582
+			$this->_children[$line_item->code()] = $line_item;
583
+			if ($line_item->parent() != $this) {
584
+				$line_item->set_parent($this);
585 585
 			}
586 586
 			return TRUE;
587 587
 		}
@@ -595,16 +595,16 @@  discard block
 block discarded – undo
595 595
 	 * @param EE_Line_Item $line_item
596 596
 	 *
597 597
 	 */
598
-	public function set_parent( $line_item ) {
599
-		if ( $this->ID() ) {
600
-			if( ! $line_item->ID() ) {
598
+	public function set_parent($line_item) {
599
+		if ($this->ID()) {
600
+			if ( ! $line_item->ID()) {
601 601
 				$line_item->save();
602 602
 			}
603
-			$this->set_parent_ID( $line_item->ID() );
603
+			$this->set_parent_ID($line_item->ID());
604 604
 			$this->save();
605 605
 		} else {
606 606
 			$this->_parent = $line_item;
607
-			$this->set_parent_ID( $line_item->ID() );
607
+			$this->set_parent_ID($line_item->ID());
608 608
 		}
609 609
 	}
610 610
 
@@ -617,11 +617,11 @@  discard block
 block discarded – undo
617 617
 	 * @param string $code
618 618
 	 * @return EE_Line_Item
619 619
 	 */
620
-	function get_child_line_item( $code ) {
621
-		if ( $this->ID() ) {
622
-			return $this->get_model()->get_one( array( array( 'LIN_parent' => $this->ID(), 'LIN_code' => $code ) ) );
620
+	function get_child_line_item($code) {
621
+		if ($this->ID()) {
622
+			return $this->get_model()->get_one(array(array('LIN_parent' => $this->ID(), 'LIN_code' => $code)));
623 623
 		} else {
624
-			return isset( $this->_children[ $code ] ) ? $this->_children[ $code ] : null;
624
+			return isset($this->_children[$code]) ? $this->_children[$code] : null;
625 625
 		}
626 626
 	}
627 627
 
@@ -632,10 +632,10 @@  discard block
 block discarded – undo
632 632
 	 * @return int
633 633
 	 */
634 634
 	function delete_children_line_items() {
635
-		if ( $this->ID() ) {
636
-			return $this->get_model()->delete( array( array( 'LIN_parent' => $this->ID() ) ) );
635
+		if ($this->ID()) {
636
+			return $this->get_model()->delete(array(array('LIN_parent' => $this->ID())));
637 637
 		} else {
638
-			$count = count( $this->_children );
638
+			$count = count($this->_children);
639 639
 			$this->_children = array();
640 640
 			return $count;
641 641
 		}
@@ -652,25 +652,25 @@  discard block
 block discarded – undo
652 652
 	 * @param bool $stop_search_once_found
653 653
 	 * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet)
654 654
 	 */
655
-	function delete_child_line_item( $code, $stop_search_once_found = true ) {
656
-		if ( $this->ID() ) {
655
+	function delete_child_line_item($code, $stop_search_once_found = true) {
656
+		if ($this->ID()) {
657 657
 			$items_deleted = 0;
658
-			if( $this->code() == $code ) {
659
-				$items_deleted += EEH_Line_Item::delete_all_child_items( $this );
660
-				$items_deleted += intval( $this->delete() );
661
-				if( $stop_search_once_found ){
658
+			if ($this->code() == $code) {
659
+				$items_deleted += EEH_Line_Item::delete_all_child_items($this);
660
+				$items_deleted += intval($this->delete());
661
+				if ($stop_search_once_found) {
662 662
 					return $items_deleted;
663 663
 				}
664 664
 			}
665
-			foreach( $this->children() as $child_line_item ) {
666
-				$items_deleted += $child_line_item->delete_child_line_item( $code, $stop_search_once_found );
665
+			foreach ($this->children() as $child_line_item) {
666
+				$items_deleted += $child_line_item->delete_child_line_item($code, $stop_search_once_found);
667 667
 			}
668 668
 			return $items_deleted;
669 669
 		} else {
670
-			if( isset( $this->_children[ $code ] ) ) {
671
-				unset( $this->_children[ $code ] );
670
+			if (isset($this->_children[$code])) {
671
+				unset($this->_children[$code]);
672 672
 				return 1;
673
-			}else{
673
+			} else {
674 674
 				return 0;
675 675
 			}
676 676
 		}
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 	 * @return boolean
684 684
 	 */
685 685
 	public function delete_if_childless_subtotal() {
686
-		if( $this->ID() &&
686
+		if ($this->ID() &&
687 687
 				$this->type() == EEM_Line_Item::type_sub_total &&
688
-				! $this->children() ) {
688
+				! $this->children()) {
689 689
 			return $this->delete();
690 690
 		} else {
691 691
 			return false;
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 	 */
701 701
 	function generate_code() {
702 702
 		// each line item in the cart requires a unique identifier
703
-		return md5( $this->get( 'OBJ_type' ) . $this->get( 'OBJ_ID' ) . microtime() );
703
+		return md5($this->get('OBJ_type').$this->get('OBJ_ID').microtime());
704 704
 	}
705 705
 
706 706
 
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 	 * @return string like '2, 004.00', formatted according to the localized currency
765 765
 	 */
766 766
 	function unit_price_no_code() {
767
-		return $this->get_pretty( 'LIN_unit_price', 'no_currency_code' );
767
+		return $this->get_pretty('LIN_unit_price', 'no_currency_code');
768 768
 	}
769 769
 
770 770
 
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 	 * @return string like '2, 004.00', formatted according to the localized currency
775 775
 	 */
776 776
 	function total_no_code() {
777
-		return $this->get_pretty( 'LIN_total', 'no_currency_code' );
777
+		return $this->get_pretty('LIN_total', 'no_currency_code');
778 778
 	}
779 779
 
780 780
 
@@ -793,17 +793,17 @@  discard block
 block discarded – undo
793 793
 
794 794
 		$total = $pre_tax_total + $tax_total;
795 795
 		// no negative totals plz
796
-		$total = max( $total, 0 );
797
-		$this->set_total( $total );
796
+		$total = max($total, 0);
797
+		$this->set_total($total);
798 798
 		//only update the related transaction's total
799 799
 		//if we intend to save this line item and its a grand total
800
-		if(
800
+		if (
801 801
 			$this->allow_persist() &&
802 802
 			$this->type() == EEM_Line_Item::type_total &&
803 803
 			$this->transaction() instanceof EE_Transaction
804
-		){
805
-			$this->transaction()->set_total( $total );
806
-			if ( $this->transaction()->ID() ) {
804
+		) {
805
+			$this->transaction()->set_total($total);
806
+			if ($this->transaction()->ID()) {
807 807
 				$this->transaction()->save();
808 808
 			}
809 809
 		}
@@ -824,42 +824,42 @@  discard block
 block discarded – undo
824 824
 		$total = 0;
825 825
 		$my_children = $this->children();
826 826
 		//completely ignore tax and tax sub-totals when calculating the pre-tax-total
827
-		if ( $this->is_tax_sub_total() || $this->is_tax() ) {
827
+		if ($this->is_tax_sub_total() || $this->is_tax()) {
828 828
 			return 0;
829 829
 		} elseif (
830
-			( $this->is_sub_line_item() || $this->is_line_item() )
831
-			&& empty( $my_children )
830
+			($this->is_sub_line_item() || $this->is_line_item())
831
+			&& empty($my_children)
832 832
 		) {
833 833
 			$total = $this->unit_price() * $this->quantity();
834
-		} elseif( $this->is_sub_total() || $this->is_total() ) {
835
-			$total = $this->_recalculate_pretax_total_for_subtotal( $total, $my_children );
836
-		} elseif (  $this->is_line_item() && ! empty( $my_children ) ) {
837
-			$total = $this->_recalculate_pretax_total_for_line_item( $total, $my_children );
834
+		} elseif ($this->is_sub_total() || $this->is_total()) {
835
+			$total = $this->_recalculate_pretax_total_for_subtotal($total, $my_children);
836
+		} elseif ($this->is_line_item() && ! empty($my_children)) {
837
+			$total = $this->_recalculate_pretax_total_for_line_item($total, $my_children);
838 838
 		}
839 839
 		//ensure all non-line items and non-sub-line-items have a quantity of 1
840
-		if( ! $this->is_line_item() && ! $this->is_sub_line_item() ) {
841
-			$this->set_quantity( 1 );
842
-			if( ! $this->is_percent() ) {
843
-				$this->set_unit_price( $this->total() );
840
+		if ( ! $this->is_line_item() && ! $this->is_sub_line_item()) {
841
+			$this->set_quantity(1);
842
+			if ( ! $this->is_percent()) {
843
+				$this->set_unit_price($this->total());
844 844
 			}
845 845
 		}
846 846
 
847 847
 		//we don't want to bother saving grand totals, because that needs to factor in taxes anyways
848 848
 		//so it ought to be
849
-		if( ! $this->is_total() ) {
850
-			$this->set_total( $total );
849
+		if ( ! $this->is_total()) {
850
+			$this->set_total($total);
851 851
 			//if not a percent line item, make sure we keep the unit price in sync
852
-			if(
852
+			if (
853 853
 				$this->is_line_item() &&
854
-				! empty( $my_children ) &&
854
+				! empty($my_children) &&
855 855
 				! $this->is_percent()
856 856
 			) {
857
-				if( $this->quantity() === 0 ){
857
+				if ($this->quantity() === 0) {
858 858
 					$new_unit_price = 0;
859 859
 				} else {
860 860
 					$new_unit_price = $this->total() / $this->quantity();
861 861
 				}
862
-				$this->set_unit_price( $new_unit_price );
862
+				$this->set_unit_price($new_unit_price);
863 863
 			}
864 864
 			$this->maybe_save();
865 865
 		}
@@ -875,14 +875,14 @@  discard block
 block discarded – undo
875 875
 	 * @param EE_Line_Item[] $my_children
876 876
 	 * @return float
877 877
 	 */
878
-	protected function _recalculate_pretax_total_for_subtotal( $calculated_total_so_far, $my_children = null ) {
879
-		if( $my_children === null ) {
878
+	protected function _recalculate_pretax_total_for_subtotal($calculated_total_so_far, $my_children = null) {
879
+		if ($my_children === null) {
880 880
 			$my_children = $this->children();
881 881
 		}
882 882
 		//get the total of all its children
883
-		foreach ( $my_children as $child_line_item ) {
884
-			if ( $child_line_item instanceof EE_Line_Item ) {
885
-				if ( $child_line_item->is_percent() ) {
883
+		foreach ($my_children as $child_line_item) {
884
+			if ($child_line_item instanceof EE_Line_Item) {
885
+				if ($child_line_item->is_percent()) {
886 886
 					
887 887
 					//round as we go so that the line items add up ok
888 888
 					$percent_total = round(
@@ -890,25 +890,25 @@  discard block
 block discarded – undo
890 890
 						EE_Registry::instance()->CFG->currency->dec_plc
891 891
 					);
892 892
 					
893
-					$child_line_item->set_total( $percent_total );
893
+					$child_line_item->set_total($percent_total);
894 894
 					//so far all percent line items should have a quantity of 1
895 895
 					//(ie, no double percent discounts. Although that might be requested someday)
896
-					$child_line_item->set_quantity( 1 );
896
+					$child_line_item->set_quantity(1);
897 897
 					$child_line_item->maybe_save();
898 898
 					$calculated_total_so_far += $percent_total;
899 899
 				} else {
900 900
 					//verify flat sub-line-item quantities match their parent
901
-					if( $child_line_item->is_sub_line_item() ) {
902
-						$child_line_item->set_quantity( $this->quantity() );
901
+					if ($child_line_item->is_sub_line_item()) {
902
+						$child_line_item->set_quantity($this->quantity());
903 903
 					}
904 904
 					$calculated_total_so_far += $child_line_item->recalculate_pre_tax_total();
905 905
 				}
906 906
 			}
907 907
 		}
908 908
 
909
-		if( $this->is_sub_total() ){
909
+		if ($this->is_sub_total()) {
910 910
 			// no negative totals plz
911
-			$calculated_total_so_far = max( $calculated_total_so_far, 0 );
911
+			$calculated_total_so_far = max($calculated_total_so_far, 0);
912 912
 		}
913 913
 		return $calculated_total_so_far;
914 914
 	}
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
 	 * @param EE_Line_Item[] $my_children
923 923
 	 * @return float
924 924
 	 */
925
-	protected function _recalculate_pretax_total_for_line_item( $calculated_total_so_far, $my_children = null ) {
926
-		if( $my_children === null ) {
925
+	protected function _recalculate_pretax_total_for_line_item($calculated_total_so_far, $my_children = null) {
926
+		if ($my_children === null) {
927 927
 			$my_children = $this->children();
928 928
 		}
929 929
 		//we need to keep track of the running total for a single item,
@@ -931,9 +931,9 @@  discard block
 block discarded – undo
931 931
 		$unit_price_for_total = 0;
932 932
 		$quantity_for_total = 1;
933 933
 		//get the total of all its children
934
-		foreach ( $my_children as $child_line_item ) {
935
-			if ( $child_line_item instanceof EE_Line_Item ) {
936
-				if ( $child_line_item->is_percent() ) {
934
+		foreach ($my_children as $child_line_item) {
935
+			if ($child_line_item instanceof EE_Line_Item) {
936
+				if ($child_line_item->is_percent()) {
937 937
 					//it should be the unit-price-so-far multiplied by teh percent multiplied by the quantity
938 938
 					//not total multiplied by percent, because that ignores rounding along-the-way
939 939
 					$percent_unit_price = round(
@@ -941,17 +941,17 @@  discard block
 block discarded – undo
941 941
 						EE_Registry::instance()->CFG->currency->dec_plc
942 942
 					);
943 943
 					$percent_total = $percent_unit_price * $quantity_for_total;
944
-					$child_line_item->set_total( $percent_total );
944
+					$child_line_item->set_total($percent_total);
945 945
 					//so far all percent line items should have a quantity of 1
946 946
 					//(ie, no double percent discounts. Although that might be requested someday)
947
-					$child_line_item->set_quantity( 1 );
947
+					$child_line_item->set_quantity(1);
948 948
 					$child_line_item->maybe_save();
949 949
 					$calculated_total_so_far += $percent_total;
950 950
 					$unit_price_for_total += $percent_unit_price;
951 951
 				} else {
952 952
 					//verify flat sub-line-item quantities match their parent
953
-					if( $child_line_item->is_sub_line_item() ) {
954
-						$child_line_item->set_quantity( $this->quantity() );
953
+					if ($child_line_item->is_sub_line_item()) {
954
+						$child_line_item->set_quantity($this->quantity());
955 955
 					}
956 956
 					$quantity_for_total = $child_line_item->quantity();
957 957
 					$calculated_total_so_far += $child_line_item->recalculate_pre_tax_total();
@@ -975,10 +975,10 @@  discard block
 block discarded – undo
975 975
 		//calculate the pretax total
976 976
 		$taxable_total = $this->taxable_total();
977 977
 		$tax_total = 0;
978
-		foreach ( $taxes as $tax ) {
978
+		foreach ($taxes as $tax) {
979 979
 			$total_on_this_tax = $taxable_total * $tax->percent() / 100;
980 980
 			//remember the total on this line item
981
-			$tax->set_total( $total_on_this_tax );
981
+			$tax->set_total($total_on_this_tax);
982 982
 			$tax_total += $tax->total();
983 983
 		}
984 984
 		$this->_recalculate_tax_sub_total();
@@ -992,21 +992,21 @@  discard block
 block discarded – undo
992 992
 	 * @return void
993 993
 	 */
994 994
 	private function _recalculate_tax_sub_total() {
995
-		if ( $this->is_tax_sub_total() ) {
995
+		if ($this->is_tax_sub_total()) {
996 996
 			$total = 0;
997 997
 			$total_percent = 0;
998 998
 			//simply loop through all its children (which should be taxes) and sum their total
999
-			foreach ( $this->children() as $child_tax ) {
1000
-				if ( $child_tax instanceof EE_Line_Item ) {
999
+			foreach ($this->children() as $child_tax) {
1000
+				if ($child_tax instanceof EE_Line_Item) {
1001 1001
 					$total += $child_tax->total();
1002 1002
 					$total_percent += $child_tax->percent();
1003 1003
 				}
1004 1004
 			}
1005
-			$this->set_total( $total );
1006
-			$this->set_percent( $total_percent );
1007
-		} elseif ( $this->is_total() ) {
1008
-			foreach ( $this->children() as $maybe_tax_subtotal ) {
1009
-				if ( $maybe_tax_subtotal instanceof EE_Line_Item ) {
1005
+			$this->set_total($total);
1006
+			$this->set_percent($total_percent);
1007
+		} elseif ($this->is_total()) {
1008
+			foreach ($this->children() as $maybe_tax_subtotal) {
1009
+				if ($maybe_tax_subtotal instanceof EE_Line_Item) {
1010 1010
 					$maybe_tax_subtotal->_recalculate_tax_sub_total();
1011 1011
 				}
1012 1012
 			}
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
 	public function get_total_tax() {
1023 1023
 		$this->_recalculate_tax_sub_total();
1024 1024
 		$total = 0;
1025
-		foreach ( $this->tax_descendants() as $tax_line_item ) {
1026
-			if ( $tax_line_item instanceof EE_Line_Item ) {
1025
+		foreach ($this->tax_descendants() as $tax_line_item) {
1026
+			if ($tax_line_item instanceof EE_Line_Item) {
1027 1027
 				$total += $tax_line_item->total();
1028 1028
 			}
1029 1029
 		}
@@ -1037,15 +1037,15 @@  discard block
 block discarded – undo
1037 1037
 	 */
1038 1038
 	public function get_items_total() {
1039 1039
 		//by default, let's make sure we're consistent with the existing line item
1040
-		if( $this->is_total() ) {
1041
-			$pretax_subtotal_li = EEH_Line_Item::get_pre_tax_subtotal( $this );
1042
-			if( $pretax_subtotal_li instanceof EE_Line_Item ) {
1040
+		if ($this->is_total()) {
1041
+			$pretax_subtotal_li = EEH_Line_Item::get_pre_tax_subtotal($this);
1042
+			if ($pretax_subtotal_li instanceof EE_Line_Item) {
1043 1043
 				return $pretax_subtotal_li->total();
1044 1044
 			}
1045 1045
 		}
1046 1046
 		$total = 0;
1047
-		foreach ( $this->get_items() as $item ) {
1048
-			if ( $item instanceof EE_Line_Item ) {
1047
+		foreach ($this->get_items() as $item) {
1048
+			if ($item instanceof EE_Line_Item) {
1049 1049
 				$total += $item->total();
1050 1050
 			}
1051 1051
 		}
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 	 * @return EE_Line_Item[]
1061 1061
 	 */
1062 1062
 	function tax_descendants() {
1063
-		return EEH_Line_Item::get_tax_descendants( $this );
1063
+		return EEH_Line_Item::get_tax_descendants($this);
1064 1064
 	}
1065 1065
 
1066 1066
 
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 	 * @return EE_Line_Item[]
1071 1071
 	 */
1072 1072
 	function get_items() {
1073
-		return EEH_Line_Item::get_line_item_descendants( $this );
1073
+		return EEH_Line_Item::get_line_item_descendants($this);
1074 1074
 	}
1075 1075
 
1076 1076
 
@@ -1084,22 +1084,22 @@  discard block
 block discarded – undo
1084 1084
 	 */
1085 1085
 	function taxable_total() {
1086 1086
 		$total = 0;
1087
-		if ( $this->children() ) {
1088
-			foreach ( $this->children() as $child_line_item ) {
1089
-				if ( $child_line_item->type() == EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) {
1087
+		if ($this->children()) {
1088
+			foreach ($this->children() as $child_line_item) {
1089
+				if ($child_line_item->type() == EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) {
1090 1090
 					//if it's a percent item, only take into account the percent
1091 1091
 					//that's taxable too (the taxable total so far)
1092
-					if( $child_line_item->is_percent() ) {
1093
-						$total = $total + ( $total * $child_line_item->percent() / 100 );
1094
-					}else{
1092
+					if ($child_line_item->is_percent()) {
1093
+						$total = $total + ($total * $child_line_item->percent() / 100);
1094
+					} else {
1095 1095
 						$total += $child_line_item->total();
1096 1096
 					}
1097
-				}elseif( $child_line_item->type() == EEM_Line_Item::type_sub_total ){
1097
+				}elseif ($child_line_item->type() == EEM_Line_Item::type_sub_total) {
1098 1098
 					$total += $child_line_item->taxable_total();
1099 1099
 				}
1100 1100
 			}
1101 1101
 		}
1102
-		return max( $total, 0 );
1102
+		return max($total, 0);
1103 1103
 	}
1104 1104
 
1105 1105
 
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
 	 * @return EE_Transaction
1110 1110
 	 */
1111 1111
 	public function transaction() {
1112
-		return $this->get_first_related( 'Transaction' );
1112
+		return $this->get_first_related('Transaction');
1113 1113
 	}
1114 1114
 
1115 1115
 
@@ -1122,17 +1122,17 @@  discard block
 block discarded – undo
1122 1122
 	 * @param int $txn_id if none is provided, assumes $this->TXN_ID()
1123 1123
 	 * @return int count of items saved
1124 1124
 	 */
1125
-	public function save_this_and_descendants_to_txn( $txn_id = NULL ) {
1126
-		if ( ! $txn_id ) {
1125
+	public function save_this_and_descendants_to_txn($txn_id = NULL) {
1126
+		if ( ! $txn_id) {
1127 1127
 			$txn_id = $this->TXN_ID();
1128 1128
 		}
1129
-		$this->set_TXN_ID( $txn_id );
1129
+		$this->set_TXN_ID($txn_id);
1130 1130
 		$children = $this->children();
1131 1131
 		$this->save();
1132
-		foreach ( $children as $child_line_item ) {
1133
-			if ( $child_line_item instanceof EE_Line_Item ) {
1134
-				$child_line_item->set_parent_ID( $this->ID() );
1135
-				$child_line_item->save_this_and_descendants_to_txn( $txn_id );
1132
+		foreach ($children as $child_line_item) {
1133
+			if ($child_line_item instanceof EE_Line_Item) {
1134
+				$child_line_item->set_parent_ID($this->ID());
1135
+				$child_line_item->save_this_and_descendants_to_txn($txn_id);
1136 1136
 			}
1137 1137
 		}
1138 1138
 	}
@@ -1144,9 +1144,9 @@  discard block
 block discarded – undo
1144 1144
 	 * @param string $type one of the constants on EEM_Line_Item
1145 1145
 	 * @return EE_Line_Item[]
1146 1146
 	 */
1147
-	protected function _get_descendants_of_type( $type ) {
1148
-		EE_Error::doing_it_wrong( 'EE_Line_Item::_get_descendants_of_type()', __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0' );
1149
-		return EEH_Line_Item::get_descendants_of_type( $this, $type );
1147
+	protected function _get_descendants_of_type($type) {
1148
+		EE_Error::doing_it_wrong('EE_Line_Item::_get_descendants_of_type()', __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0');
1149
+		return EEH_Line_Item::get_descendants_of_type($this, $type);
1150 1150
 	}
1151 1151
 
1152 1152
 
@@ -1156,9 +1156,9 @@  discard block
 block discarded – undo
1156 1156
 	 * @param string $type like one of the EEM_Line_Item::type_*
1157 1157
 	 * @return EE_Line_Item
1158 1158
 	 */
1159
-	public function get_nearest_descendant_of_type( $type ) {
1160
-		EE_Error::doing_it_wrong( 'EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0' );
1161
-		return EEH_Line_Item::get_nearest_descendant_of_type( $this, $type );
1159
+	public function get_nearest_descendant_of_type($type) {
1160
+		EE_Error::doing_it_wrong('EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0');
1161
+		return EEH_Line_Item::get_nearest_descendant_of_type($this, $type);
1162 1162
 	}
1163 1163
 
1164 1164
 
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 	 * @return int count of items saved
1170 1170
 	 */
1171 1171
 	public function maybe_save() {
1172
-		if ( $this->ID() ) {
1172
+		if ($this->ID()) {
1173 1173
 			return $this->save();
1174 1174
 		}
1175 1175
 		return false;
Please login to merge, or discard this patch.
core/db_classes/EE_CSV.class.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
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
  * CSV Import Export class
4 4
  *
@@ -45,31 +45,31 @@  discard block
 block discarded – undo
45 45
 		global $wpdb;
46 46
 
47 47
 		$this->_primary_keys = array(
48
-				$wpdb->prefix . 'esp_answer' => array( 'ANS_ID' ),
49
-				$wpdb->prefix . 'esp_attendee' => array( 'ATT_ID' ),
50
-				$wpdb->prefix . 'esp_datetime'	=> array( 'DTT_ID' ),
51
-				$wpdb->prefix . 'esp_event_question_group'	=> array( 'EQG_ID' ),
52
-				$wpdb->prefix . 'esp_message_template'	=> array( 'MTP_ID' ),
53
-				$wpdb->prefix . 'esp_payment'	=> array( 'PAY_ID' ),
54
-				$wpdb->prefix . 'esp_price'	=> array( 'PRC_ID' ),
55
-				$wpdb->prefix . 'esp_price_type'	=> array( 'PRT_ID' ),
56
-				$wpdb->prefix . 'esp_question'	=> array( 'QST_ID' ),
57
-				$wpdb->prefix . 'esp_question_group'	=> array( 'QSG_ID' ),
58
-				$wpdb->prefix . 'esp_question_group_question'	=> array( 'QGQ_ID' ),
59
-				$wpdb->prefix . 'esp_question_option'	=> array( 'QSO_ID' ),
60
-				$wpdb->prefix . 'esp_registration'	=> array( 'REG_ID' ),
61
-				$wpdb->prefix . 'esp_status'	=> array( 'STS_ID' ),
62
-				$wpdb->prefix . 'esp_transaction'	=> array( 'TXN_ID' ),
63
-				$wpdb->prefix . 'esp_transaction'	=> array( 'TXN_ID' ),
64
-				$wpdb->prefix . 'events_detail'	=> array( 'id' ),
65
-				$wpdb->prefix . 'events_category_detail'	=> array( 'id' ),
66
-				$wpdb->prefix . 'events_category_rel'	=> array( 'id' ),
67
-				$wpdb->prefix . 'events_venue'	=> array( 'id' ),
68
-				$wpdb->prefix . 'events_venue_rel' =>  array( 'emeta_id' ),
69
-				$wpdb->prefix . 'events_locale'	=> array( 'id' ),
70
-				$wpdb->prefix . 'events_locale_rel'	=> array( 'id' ),
71
-				$wpdb->prefix . 'events_personnel' =>  array( 'id' ),
72
-				$wpdb->prefix . 'events_personnel_rel' =>  array( 'id' ),
48
+				$wpdb->prefix.'esp_answer' => array('ANS_ID'),
49
+				$wpdb->prefix.'esp_attendee' => array('ATT_ID'),
50
+				$wpdb->prefix.'esp_datetime'	=> array('DTT_ID'),
51
+				$wpdb->prefix.'esp_event_question_group'	=> array('EQG_ID'),
52
+				$wpdb->prefix.'esp_message_template'	=> array('MTP_ID'),
53
+				$wpdb->prefix.'esp_payment'	=> array('PAY_ID'),
54
+				$wpdb->prefix.'esp_price'	=> array('PRC_ID'),
55
+				$wpdb->prefix.'esp_price_type'	=> array('PRT_ID'),
56
+				$wpdb->prefix.'esp_question'	=> array('QST_ID'),
57
+				$wpdb->prefix.'esp_question_group'	=> array('QSG_ID'),
58
+				$wpdb->prefix.'esp_question_group_question'	=> array('QGQ_ID'),
59
+				$wpdb->prefix.'esp_question_option'	=> array('QSO_ID'),
60
+				$wpdb->prefix.'esp_registration'	=> array('REG_ID'),
61
+				$wpdb->prefix.'esp_status'	=> array('STS_ID'),
62
+				$wpdb->prefix.'esp_transaction'	=> array('TXN_ID'),
63
+				$wpdb->prefix.'esp_transaction'	=> array('TXN_ID'),
64
+				$wpdb->prefix.'events_detail'	=> array('id'),
65
+				$wpdb->prefix.'events_category_detail'	=> array('id'),
66
+				$wpdb->prefix.'events_category_rel'	=> array('id'),
67
+				$wpdb->prefix.'events_venue'	=> array('id'),
68
+				$wpdb->prefix.'events_venue_rel' =>  array('emeta_id'),
69
+				$wpdb->prefix.'events_locale'	=> array('id'),
70
+				$wpdb->prefix.'events_locale_rel'	=> array('id'),
71
+				$wpdb->prefix.'events_personnel' =>  array('id'),
72
+				$wpdb->prefix.'events_personnel_rel' =>  array('id'),
73 73
 			);
74 74
 
75 75
 	}
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 	 *		@ access public
82 82
 	 *		@return EE_CSV
83 83
 	 */
84
-	public static function instance ( ) {
84
+	public static function instance( ) {
85 85
 		// check if class object is instantiated
86
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_CSV )) {
86
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_CSV)) {
87 87
 			self::$_instance = new self();
88 88
 		}
89 89
 		return self::$_instance;
@@ -95,22 +95,22 @@  discard block
 block discarded – undo
95 95
 	 * @return string
96 96
 	 * @throws EE_Error
97 97
 	 */
98
-	private function read_unicode_file($file_path){
98
+	private function read_unicode_file($file_path) {
99 99
 		$fc = "";
100
-		$fh = fopen($file_path,"rb");
101
-		if( ! $fh ){
102
-			throw new EE_Error( sprintf( __("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path ) );
100
+		$fh = fopen($file_path, "rb");
101
+		if ( ! $fh) {
102
+			throw new EE_Error(sprintf(__("Cannot open file for read: %s<br>\n", 'event_espresso'), $file_path));
103 103
 		}
104 104
 		$flen = filesize($file_path);
105 105
 		$bc = fread($fh, $flen);
106
-		for ($i=0; $i<$flen; $i++){
107
-			$c = substr($bc,$i,1);
108
-			if ((ord($c) != 0) && (ord($c) != 13)){
109
-			  $fc = $fc . $c;
106
+		for ($i = 0; $i < $flen; $i++) {
107
+			$c = substr($bc, $i, 1);
108
+			if ((ord($c) != 0) && (ord($c) != 13)) {
109
+			  $fc = $fc.$c;
110 110
 			}
111 111
 		}
112
-		if ((ord(substr($fc,0,1)) == 255) && (ord(substr($fc,1,1)) == 254))
113
-		$fc = substr($fc,2);
112
+		if ((ord(substr($fc, 0, 1)) == 255) && (ord(substr($fc, 1, 1)) == 254))
113
+		$fc = substr($fc, 2);
114 114
 		return ($fc);
115 115
 }
116 116
 
@@ -122,15 +122,15 @@  discard block
 block discarded – undo
122 122
 	 * @param string $path_to_file
123 123
 	 * @return array of arrays. Top-level array has rows, second-level array has each item
124 124
 	 */
125
-	public function import_csv_to_multi_dimensional_array($path_to_file){
125
+	public function import_csv_to_multi_dimensional_array($path_to_file) {
126 126
 		// needed to deal with Mac line endings
127
-		ini_set('auto_detect_line_endings',TRUE);
127
+		ini_set('auto_detect_line_endings', TRUE);
128 128
 
129 129
 		// because fgetcsv does not correctly deal with backslashed quotes such as \"
130 130
 		// we'll read the file into a string
131
-		$file_contents = $this->read_unicode_file( $path_to_file );
131
+		$file_contents = $this->read_unicode_file($path_to_file);
132 132
 		// replace backslashed quotes with CSV enclosures
133
-		$file_contents = str_replace ( '\\"', '"""', $file_contents );
133
+		$file_contents = str_replace('\\"', '"""', $file_contents);
134 134
 		// HEY YOU! PUT THAT FILE BACK!!!
135 135
 		file_put_contents($path_to_file, $file_contents);
136 136
 
@@ -140,25 +140,25 @@  discard block
 block discarded – undo
140 140
 			$csvarray = array();
141 141
 
142 142
 			// in PHP 5.3 fgetcsv accepts a 5th parameter, but the pre 5.3 versions of fgetcsv choke if passed more than 4 - is that crazy or what?
143
-			if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) {
143
+			if (version_compare(PHP_VERSION, '5.3.0') < 0) {
144 144
 
145 145
 				//  PHP 5.2- version
146 146
 
147 147
 				// loop through each row of the file
148
-				while(($data = fgetcsv($file_handle, 0, ',', '"' )) !== FALSE){
149
-					$csvarray[]= $data;
148
+				while (($data = fgetcsv($file_handle, 0, ',', '"')) !== FALSE) {
149
+					$csvarray[] = $data;
150 150
 				}
151
-			}else{
151
+			} else {
152 152
 				// loop through each row of the file
153
-				while (( $data = fgetcsv( $file_handle, 0, ',', '"', '\\' )) !== FALSE ) {
154
-					$csvarray[]=$data;
153
+				while (($data = fgetcsv($file_handle, 0, ',', '"', '\\')) !== FALSE) {
154
+					$csvarray[] = $data;
155 155
 				}
156 156
 			}
157 157
 			# Close the File.
158 158
 			fclose($file_handle);
159 159
 			return $csvarray;
160
-		}else{
161
-			EE_Error::add_error( sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"),$path_to_file), __FILE__, __FUNCTION__, __LINE__ );
160
+		} else {
161
+			EE_Error::add_error(sprintf(__("An error occurred - the file: %s could not opened.", "event_espresso"), $path_to_file), __FILE__, __FUNCTION__, __LINE__);
162 162
 			return false;
163 163
 		}
164 164
 	}
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 *						...
189 189
 	 *						)
190 190
 	 */
191
-	public function import_csv_to_model_data_array( $path_to_file, $model_name = FALSE, $first_row_is_headers = TRUE ) {
191
+	public function import_csv_to_model_data_array($path_to_file, $model_name = FALSE, $first_row_is_headers = TRUE) {
192 192
 		$multi_dimensional_array = $this->import_csv_to_multi_dimensional_array($path_to_file);
193
-		if( ! $multi_dimensional_array ){
193
+		if ( ! $multi_dimensional_array) {
194 194
 			return false;
195 195
 		}
196 196
 		// gotta start somewhere
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 		$ee_formatted_data = array();
200 200
 		// array to store headers (column names)
201 201
 		$headers = array();
202
-		foreach($multi_dimensional_array as $data){
202
+		foreach ($multi_dimensional_array as $data) {
203 203
 			// if first cell is MODEL, then second cell is the MODEL name
204
-			if ( $data[0]	== 'MODEL' ) {
204
+			if ($data[0] == 'MODEL') {
205 205
 				$model_name = $data[1];
206 206
 				//don't bother looking for model data in this row. The rest of this
207 207
 				//row should be blank
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 				$headers = array();
212 212
 				continue;
213 213
 			}
214
-			if( strpos( $data[0], EE_CSV::metadata_header ) !==FALSE ){
214
+			if (strpos($data[0], EE_CSV::metadata_header) !== FALSE) {
215 215
 				$model_name = EE_CSV::metadata_header;
216 216
 				//store like model data, we just won't try importing it etc.
217 217
 				$row = 1;
@@ -224,31 +224,31 @@  discard block
 block discarded – undo
224 224
 
225 225
 			$model_entry = array();
226 226
 			// loop through each column
227
-			for ( $i=0; $i < $columns; $i++ ) {
227
+			for ($i = 0; $i < $columns; $i++) {
228 228
 
229 229
 				//replace csv_enclosures with backslashed quotes
230
-				$data[$i] = str_replace ( '"""', '\\"', $data[$i] );
230
+				$data[$i] = str_replace('"""', '\\"', $data[$i]);
231 231
 				// do we need to grab the column names?
232
-				if ( $row === 1){
233
-					if( $first_row_is_headers ) {
232
+				if ($row === 1) {
233
+					if ($first_row_is_headers) {
234 234
 						// store the column names to use for keys
235 235
 						$column_name = $data[$i];
236 236
 						//check it's not blank... sometimes CSV editign programs adda bunch of empty columns onto the end...
237
-						if(!$column_name){continue;}
237
+						if ( ! $column_name) {continue; }
238 238
 						$matches = array();
239
-						if($model_name == EE_CSV::metadata_header){
239
+						if ($model_name == EE_CSV::metadata_header) {
240 240
 							$headers[$i] = $column_name;
241
-						}else{
241
+						} else {
242 242
 							//now get the db table name from it (the part between square brackets)
243
-							$success = preg_match('~(.*)\[(.*)\]~', $column_name,$matches);
244
-							if (!$success){
245
-								EE_Error::add_error( sprintf(__("The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", "event_espresso"),$column_name,implode(",",$data)), __FILE__, __FUNCTION__, __LINE__ );
243
+							$success = preg_match('~(.*)\[(.*)\]~', $column_name, $matches);
244
+							if ( ! $success) {
245
+								EE_Error::add_error(sprintf(__("The column titled %s is invalid for importing. It must be be in the format of 'Nice Name[model_field_name]' in row %s", "event_espresso"), $column_name, implode(",", $data)), __FILE__, __FUNCTION__, __LINE__);
246 246
 								return false;
247 247
 							}
248 248
 							$headers[$i] = $matches[2];
249 249
 						}
250 250
 
251
-					}else{
251
+					} else {
252 252
 						// no column names means our final array will just use counters for keys
253 253
 						$model_entry[$headers[$i]] = $data[$i];
254 254
 						$headers[$i] = $i;
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
 					// and we need to store csv data
257 257
 				} else {
258 258
 					// this column isn' ta header, store it if there is a header for it
259
-					if(isset($headers[$i])){
259
+					if (isset($headers[$i])) {
260 260
 						$model_entry[$headers[$i]] = $data[$i];
261 261
 					}
262 262
 				}
263 263
 
264 264
 			}
265 265
 			//save the row's data IF it's a non-header-row
266
-			if( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)){
266
+			if ( ! $first_row_is_headers || ($first_row_is_headers && $row > 1)) {
267 267
 				$ee_formatted_data[$model_name][] = $model_entry;
268 268
 			}
269 269
 			// advance to next row
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 	}
283 283
 
284 284
 
285
-	public function save_csv_to_db( $csv_data_array, $model_name = FALSE ) {
286
-		EE_Error::doing_it_wrong('save_csv_to_db', __( 'Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso' ), '4.6.7' );
287
-		return EE_Import::instance()->save_csv_data_array_to_db( $csv_data_array, $model_name );
285
+	public function save_csv_to_db($csv_data_array, $model_name = FALSE) {
286
+		EE_Error::doing_it_wrong('save_csv_to_db', __('Function moved to EE_Import and renamed to save_csv_data_array_to_db', 'event_espresso'), '4.6.7');
287
+		return EE_Import::instance()->save_csv_data_array_to_db($csv_data_array, $model_name);
288 288
 	}
289 289
 
290 290
 	/**
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 	 * @param string $new_filename the name of the file that the user will download
295 295
 	 * @return resource, like the results of fopen(), which can be used for fwrite, fputcsv2, etc.
296 296
 	 */
297
-	public function begin_sending_csv($filename){
297
+	public function begin_sending_csv($filename) {
298 298
 		// grab file extension
299 299
 		$ext = substr(strrchr($filename, '.'), 1);
300
-		if ( $ext == '.csv' or  $ext == '.xls' ) {
301
-			str_replace( $ext, '', $filename );
300
+		if ($ext == '.csv' or $ext == '.xls') {
301
+			str_replace($ext, '', $filename);
302 302
 		}
303 303
 		$filename .= '.csv';
304 304
 
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 //		header("Content-Type: application/download");
320 320
 		header('Content-disposition: attachment; filename='.$filename);
321 321
 		header("Content-Type: text/csv; charset=utf-8");
322
-                do_action( 'AHEE__EE_CSV__begin_sending_csv__headers' );
323
-		echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF" ); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835
322
+                do_action('AHEE__EE_CSV__begin_sending_csv__headers');
323
+		echo apply_filters('FHEE__EE_CSV__begin_sending_csv__start_writing', "\xEF\xBB\xBF"); // makes excel open it as UTF-8. UTF-8 BOM, see http://stackoverflow.com/a/4440143/2773835
324 324
 		$fh = fopen('php://output', 'w');
325 325
 		return $fh;
326 326
 	}
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 	 * mentioning the version and timezone
331 331
 	 * @param resource $filehandle
332 332
 	 */
333
-	public function write_metadata_to_csv($filehandle){
334
-		$data_row = array(EE_CSV::metadata_header);//do NOT translate because this exact string is used when importing
333
+	public function write_metadata_to_csv($filehandle) {
334
+		$data_row = array(EE_CSV::metadata_header); //do NOT translate because this exact string is used when importing
335 335
 		$this->fputcsv2($filehandle, $data_row);
336
-		$meta_data = array( 0=> array(
336
+		$meta_data = array(0=> array(
337 337
 			'version'=>espresso_version(),
338 338
 			'timezone'=>  EEH_DTT_Helper::get_timezone(),
339 339
 			'time_of_export'=>current_time('mysql'),
@@ -351,29 +351,29 @@  discard block
 block discarded – undo
351 351
 	 * then the first row we'd write to the CSV would be "EVT_ID,EVT_name,..."
352 352
 	 * @return boolean if we successfully wrote to the CSV or not. If there's no $data, we consider that a success (because we wrote everything there was...nothing)
353 353
 	 */
354
-	public function write_data_array_to_csv($filehandle, $data){
354
+	public function write_data_array_to_csv($filehandle, $data) {
355 355
 
356 356
 
357 357
 		//determine if $data is actually a 2d array
358
-		if ( $data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))){
358
+		if ($data && is_array($data) && is_array(EEH_Array::get_one_item_from_array($data))) {
359 359
 			//make sure top level is numerically indexed,
360 360
 
361
-			if( EEH_Array::is_associative_array($data)){
362
-				throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s","event_espresso"),implode(",",array_keys($data))));
361
+			if (EEH_Array::is_associative_array($data)) {
362
+				throw new EE_Error(sprintf(__("top-level array must be numerically indexed. Does these look like numbers to you? %s", "event_espresso"), implode(",", array_keys($data))));
363 363
 			}
364 364
 			$item_in_top_level_array = EEH_Array::get_one_item_from_array($data);
365 365
 			//now, is the last item in the top-level array of $data an associative or numeric array?
366
-			if(EEH_Array::is_associative_array($item_in_top_level_array)){
366
+			if (EEH_Array::is_associative_array($item_in_top_level_array)) {
367 367
 				//its associative, so we want to output its keys as column headers
368 368
 				$keys = array_keys($item_in_top_level_array);
369 369
 				echo $this->fputcsv2($filehandle, $keys);
370 370
 			}
371 371
 			//start writing data
372
-			foreach($data as $data_row){
372
+			foreach ($data as $data_row) {
373 373
 				echo $this->fputcsv2($filehandle, $data_row);
374 374
 			}
375 375
 			return true;
376
-		}else{
376
+		} else {
377 377
 			//no data TO write... so we can assume that's a success
378 378
 			return true;
379 379
 		}
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	 * Calls exit to prevent polluting the CSV file with other junk
419 419
 	 * @param resource $fh filehandle where we're writing the CSV to
420 420
 	 */
421
-	public function end_sending_csv($fh){
421
+	public function end_sending_csv($fh) {
422 422
 		fclose($fh);
423 423
 		exit(0);
424 424
 	}
@@ -431,23 +431,23 @@  discard block
 block discarded – undo
431 431
 	 * has all the attributes o fthat model object (eg, the event's id, name, etc)
432 432
 	 * @return boolean success
433 433
 	 */
434
-	public function write_model_data_to_csv($filehandle,$model_data_array){
434
+	public function write_model_data_to_csv($filehandle, $model_data_array) {
435 435
 		$this->write_metadata_to_csv($filehandle);
436
-		foreach($model_data_array as $model_name => $model_instance_arrays){
436
+		foreach ($model_data_array as $model_name => $model_instance_arrays) {
437 437
 			//first: output a special row stating the model
438
-			echo $this->fputcsv2($filehandle,array('MODEL',$model_name));
438
+			echo $this->fputcsv2($filehandle, array('MODEL', $model_name));
439 439
 			//if we have items to put in the CSV, do it normally
440 440
 
441
-			if( ! empty($model_instance_arrays) ){
441
+			if ( ! empty($model_instance_arrays)) {
442 442
 				$this->write_data_array_to_csv($filehandle, $model_instance_arrays);
443
-			}else{
443
+			} else {
444 444
 //				echo "no data to write... so just write the headers";
445 445
 				//so there's actually NO model objects for that model.
446 446
 				//probably still want to show the columns
447 447
 				$model = EE_Registry::instance()->load_model($model_name);
448 448
 				$column_names = array();
449
-				foreach($model->field_settings() as $field){
450
-					$column_names[$field->get_nicename()."[".$field->get_name()."]"] = null ;
449
+				foreach ($model->field_settings() as $field) {
450
+					$column_names[$field->get_nicename()."[".$field->get_name()."]"] = null;
451 451
 				}
452 452
 				$this->write_data_array_to_csv($filehandle, array($column_names));
453 453
 			}
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	 * @param array $model_data_array 3d array, as described in EE_CSV::write_model_data_to_csv()
462 462
 	 * @return bool | void writes CSV file to output and dies
463 463
 	 */
464
-	public function export_multiple_model_data_to_csv($filename,$model_data_array){
464
+	public function export_multiple_model_data_to_csv($filename, $model_data_array) {
465 465
 		$filehandle = $this->begin_sending_csv($filename);
466 466
 		$this->write_model_data_to_csv($filehandle, $model_data_array);
467 467
 		$this->end_sending_csv($filehandle);
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
 	 *			@param string $filename - name for newly created csv file
474 474
 	 *			@return TRUE on success, FALSE on fail
475 475
 	 */
476
-	public function export_array_to_csv( $data = FALSE, $filename = FALSE  ) {
476
+	public function export_array_to_csv($data = FALSE, $filename = FALSE) {
477 477
 
478 478
 		// no data file?? get outta here
479
-		if ( ! $data or ! is_array( $data ) or empty( $data ) ) {
479
+		if ( ! $data or ! is_array($data) or empty($data)) {
480 480
 			return FALSE;
481 481
 		}
482 482
 
483 483
 		// no filename?? get outta here
484
-		if ( ! $filename ) {
484
+		if ( ! $filename) {
485 485
 			return FALSE;
486 486
 		}
487 487
 
@@ -507,11 +507,11 @@  discard block
 block discarded – undo
507 507
 	 *			@param int $percent_of_max - desired percentage of the max upload_mb
508 508
 	 *			@return int KB
509 509
 	 */
510
-	public function get_max_upload_size ( $percent_of_max = FALSE ) {
510
+	public function get_max_upload_size($percent_of_max = FALSE) {
511 511
 
512
-		$max_upload = (int)(ini_get('upload_max_filesize'));
513
-		$max_post = (int)(ini_get('post_max_size'));
514
-		$memory_limit = (int)(ini_get('memory_limit'));
512
+		$max_upload = (int) (ini_get('upload_max_filesize'));
513
+		$max_post = (int) (ini_get('post_max_size'));
514
+		$memory_limit = (int) (ini_get('memory_limit'));
515 515
 
516 516
 		// determine the smallest of the three values from above
517 517
 		$upload_mb = min($max_upload, $max_post, $memory_limit);
@@ -520,9 +520,9 @@  discard block
 block discarded – undo
520 520
 		$upload_mb = $upload_mb * 1024;
521 521
 
522 522
 		// don't want the full monty? then reduce the max uplaod size
523
-		if ( $percent_of_max ) {
523
+		if ($percent_of_max) {
524 524
 			// is percent_of_max like this -> 50 or like this -> 0.50 ?
525
-			if ( $percent_of_max > 1 ) {
525
+			if ($percent_of_max > 1) {
526 526
 				// chnages 50 to 0.50
527 527
 				$percent_of_max = $percent_of_max / 100;
528 528
 			}
@@ -544,17 +544,17 @@  discard block
 block discarded – undo
544 544
 	 *			@param string $mysql_null - allows php NULL to be overridden with MySQl's insertable NULL value
545 545
 	 *			@return void
546 546
 	 */
547
-	private function fputcsv2 ($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = FALSE) {
547
+	private function fputcsv2($fh, array $row, $delimiter = ',', $enclosure = '"', $mysql_null = FALSE) {
548 548
 		//Allow user to filter the csv delimiter and enclosure for other countries csv standards
549
-		$delimiter = apply_filters( 'FHEE__EE_CSV__fputcsv2__delimiter', $delimiter );
550
-		$enclosure = apply_filters( 'FHEE__EE_CSV__fputcsv2__enclosure', $enclosure );
549
+		$delimiter = apply_filters('FHEE__EE_CSV__fputcsv2__delimiter', $delimiter);
550
+		$enclosure = apply_filters('FHEE__EE_CSV__fputcsv2__enclosure', $enclosure);
551 551
 
552 552
 		$delimiter_esc = preg_quote($delimiter, '/');
553 553
 		$enclosure_esc = preg_quote($enclosure, '/');
554 554
 
555 555
 		$output = array();
556 556
 		foreach ($row as $field_value) {
557
-			if(is_object($field_value) || is_array($field_value)){
557
+			if (is_object($field_value) || is_array($field_value)) {
558 558
 				$field_value = serialize($field_value);
559 559
 			}
560 560
 			if ($field_value === null && $mysql_null) {
@@ -563,10 +563,10 @@  discard block
 block discarded – undo
563 563
 			}
564 564
 
565 565
 			$output[] = preg_match("/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field_value) ?
566
-				( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field_value) . $enclosure ) : $field_value;
566
+				($enclosure.str_replace($enclosure, $enclosure.$enclosure, $field_value).$enclosure) : $field_value;
567 567
 		}
568 568
 
569
-		fwrite($fh, join($delimiter, $output) . PHP_EOL);
569
+		fwrite($fh, join($delimiter, $output).PHP_EOL);
570 570
 	}
571 571
 
572 572
 
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
 	 * @param string $current_format
605 605
 	 * @return string
606 606
 	 */
607
-	public function get_date_format_for_csv( $current_format = null ) {
608
-		return apply_filters( 'FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format );
607
+	public function get_date_format_for_csv($current_format = null) {
608
+		return apply_filters('FHEE__EE_CSV__get_date_format_for_csv__format', 'Y-m-d', $current_format);
609 609
 	}
610 610
 
611 611
 	/**
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
 	 * @param string $current_format
614 614
 	 * @return string
615 615
 	 */
616
-	public function get_time_format_for_csv( $current_format = null ) {
617
-		return apply_filters( 'FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format );
616
+	public function get_time_format_for_csv($current_format = null) {
617
+		return apply_filters('FHEE__EE_CSV__get_time_format_for_csv__format', 'H:i:s', $current_format);
618 618
 	}
619 619
 
620 620
 
Please login to merge, or discard this patch.
core/EE_System.core.php 1 patch
Spacing   +261 added lines, -261 removed lines patch added patch discarded remove patch
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public static function instance() {
104 104
 		// check if class object is instantiated
105
-		if ( ! self::$_instance instanceof EE_System ) {
105
+		if ( ! self::$_instance instanceof EE_System) {
106 106
 			self::$_instance = new self();
107 107
 		}
108 108
 		return self::$_instance;
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 	 * resets the instance and returns it
114 114
 	 * @return EE_System
115 115
 	 */
116
-	public static function reset(){
116
+	public static function reset() {
117 117
 		self::$_instance->_req_type = NULL;
118 118
 		//we need to reset the migration manager in order for it to detect DMSs properly
119 119
 		EE_Data_Migration_Manager::reset();
120 120
 		//make sure none of the old hooks are left hanging around
121
-		remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations');
121
+		remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
122 122
 		self::instance()->detect_activations_or_upgrades();
123 123
 		self::instance()->perform_activations_upgrades_and_migrations();
124 124
 		return self::instance();
@@ -134,26 +134,26 @@  discard block
 block discarded – undo
134 134
 	 * @access    private
135 135
 	 */
136 136
 	private function __construct() {
137
-		do_action( 'AHEE__EE_System__construct__begin', $this );
137
+		do_action('AHEE__EE_System__construct__begin', $this);
138 138
 		// allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
139
-		add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) );
139
+		add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons'));
140 140
 		// when an ee addon is activated, we want to call the core hook(s) again
141 141
 		// because the newly-activated addon didn't get a chance to run at all
142
-		add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 );
142
+		add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
143 143
 		// detect whether install or upgrade
144
-		add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 );
144
+		add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3);
145 145
 		// load EE_Config, EE_Textdomain, etc
146
-		add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 );
146
+		add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5);
147 147
 		// load EE_Config, EE_Textdomain, etc
148
-		add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 );
148
+		add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7);
149 149
 		// you wanna get going? I wanna get going... let's get going!
150
-		add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 );
150
+		add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9);
151 151
 		//other housekeeping
152 152
 		//exclude EE critical pages from wp_list_pages
153
-		add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 );
153
+		add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10);
154 154
 		// ALL EE Addons should use the following hook point to attach their initial setup too
155 155
 		// it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
156
-		do_action( 'AHEE__EE_System__construct__complete', $this );
156
+		do_action('AHEE__EE_System__construct__complete', $this);
157 157
 	}
158 158
 
159 159
 
@@ -173,30 +173,30 @@  discard block
 block discarded – undo
173 173
 	public function load_espresso_addons() {
174 174
 		// set autoloaders for all of the classes implementing EEI_Plugin_API
175 175
 		// which provide helpers for EE plugin authors to more easily register certain components with EE.
176
-		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' );
176
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api');
177 177
 		//load and setup EE_Capabilities
178
-		EE_Registry::instance()->load_core( 'Capabilities' );
178
+		EE_Registry::instance()->load_core('Capabilities');
179 179
 		//caps need to be initialized on every request so that capability maps are set.
180 180
 		//@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
181 181
 		EE_Registry::instance()->CAP->init_caps();
182
-		do_action( 'AHEE__EE_System__load_espresso_addons' );
182
+		do_action('AHEE__EE_System__load_espresso_addons');
183 183
 		//if the WP API basic auth plugin isn't already loaded, load it now.
184 184
 		//We want it for mobile apps. Just include the entire plugin
185 185
 		//also, don't load the basic auth when a plugin is getting activated, because
186 186
 		//it could be the basic auth plugin, and it doesn't check if its methods are already defined
187 187
 		//and causes a fatal error
188
-		if( !function_exists( 'json_basic_auth_handler' )
189
-			&& ! function_exists( 'json_basic_auth_error' )
188
+		if ( ! function_exists('json_basic_auth_handler')
189
+			&& ! function_exists('json_basic_auth_error')
190 190
 			&& ! (
191
-				isset( $_GET[ 'action'] )
192
-				&& in_array( $_GET[ 'action' ], array( 'activate', 'activate-selected' ) )
191
+				isset($_GET['action'])
192
+				&& in_array($_GET['action'], array('activate', 'activate-selected'))
193 193
 			)
194 194
 			&& ! (
195
-				isset( $_GET['activate' ] )
196
-				&& $_GET['activate' ] === 'true'
195
+				isset($_GET['activate'])
196
+				&& $_GET['activate'] === 'true'
197 197
 			)
198 198
 		) {
199
-			include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
199
+			include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php';
200 200
 		}
201 201
 	}
202 202
 
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	 * @access public
213 213
 	 * @return void
214 214
 	 */
215
-	public function detect_activations_or_upgrades(){
215
+	public function detect_activations_or_upgrades() {
216 216
 		//first off: let's make sure to handle core
217 217
 		$this->detect_if_activation_or_upgrade();
218
-		foreach(EE_Registry::instance()->addons as $addon){
218
+		foreach (EE_Registry::instance()->addons as $addon) {
219 219
 			//detect teh request type for that addon
220 220
 			$addon->detect_activation_or_upgrade();
221 221
 		}
@@ -236,41 +236,41 @@  discard block
 block discarded – undo
236 236
 		do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
237 237
 
238 238
 		// load M-Mode class
239
-		EE_Registry::instance()->load_core( 'Maintenance_Mode' );
239
+		EE_Registry::instance()->load_core('Maintenance_Mode');
240 240
 		// check if db has been updated, or if its a brand-new installation
241 241
 
242 242
 		$espresso_db_update = $this->fix_espresso_db_upgrade_option();
243
-		$request_type =  $this->detect_req_type($espresso_db_update);
243
+		$request_type = $this->detect_req_type($espresso_db_update);
244 244
 		//EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
245 245
 
246
-		switch($request_type){
246
+		switch ($request_type) {
247 247
 			case EE_System::req_type_new_activation:
248
-				do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' );
249
-				$this->_handle_core_version_change( $espresso_db_update );
248
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
249
+				$this->_handle_core_version_change($espresso_db_update);
250 250
 				break;
251 251
 			case EE_System::req_type_reactivation:
252
-				do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' );
253
-				$this->_handle_core_version_change( $espresso_db_update );
252
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
253
+				$this->_handle_core_version_change($espresso_db_update);
254 254
 				break;
255 255
 			case EE_System::req_type_upgrade:
256
-				do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' );
256
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
257 257
 				//migrations may be required now that we've upgraded
258 258
 				EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
259
-				$this->_handle_core_version_change( $espresso_db_update );
259
+				$this->_handle_core_version_change($espresso_db_update);
260 260
 //				echo "done upgrade";die;
261 261
 				break;
262 262
 			case EE_System::req_type_downgrade:
263
-				do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' );
263
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
264 264
 				//its possible migrations are no longer required
265 265
 				EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
266
-				$this->_handle_core_version_change( $espresso_db_update );
266
+				$this->_handle_core_version_change($espresso_db_update);
267 267
 				break;
268 268
 			case EE_System::req_type_normal:
269 269
 			default:
270 270
 //				$this->_maybe_redirect_to_ee_about();
271 271
 				break;
272 272
 		}
273
-		do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' );
273
+		do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
274 274
 	}
275 275
 
276 276
 	/**
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 	 * initializing the database later during the request
279 279
 	 * @param array $espresso_db_update
280 280
 	 */
281
-	protected function _handle_core_version_change( $espresso_db_update ){
282
-		$this->update_list_of_installed_versions( $espresso_db_update );
281
+	protected function _handle_core_version_change($espresso_db_update) {
282
+		$this->update_list_of_installed_versions($espresso_db_update);
283 283
 		//get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
284
-		add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ));
284
+		add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required'));
285 285
 	}
286 286
 
287 287
 
@@ -296,44 +296,44 @@  discard block
 block discarded – undo
296 296
 	 * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table
297 297
 	 * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
298 298
 	 */
299
-	private function fix_espresso_db_upgrade_option($espresso_db_update = null){
300
-		do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update );
301
-		if( ! $espresso_db_update){
302
-			$espresso_db_update = get_option( 'espresso_db_update' );
299
+	private function fix_espresso_db_upgrade_option($espresso_db_update = null) {
300
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
301
+		if ( ! $espresso_db_update) {
302
+			$espresso_db_update = get_option('espresso_db_update');
303 303
 		}
304 304
 		// check that option is an array
305
-		if( ! is_array( $espresso_db_update )) {
305
+		if ( ! is_array($espresso_db_update)) {
306 306
 			// if option is FALSE, then it never existed
307
-			if ( $espresso_db_update === FALSE ) {
307
+			if ($espresso_db_update === FALSE) {
308 308
 				// make $espresso_db_update an array and save option with autoload OFF
309
-				$espresso_db_update =  array();
310
-				add_option( 'espresso_db_update', $espresso_db_update, '', 'no' );
309
+				$espresso_db_update = array();
310
+				add_option('espresso_db_update', $espresso_db_update, '', 'no');
311 311
 			} else {
312 312
 				// option is NOT FALSE but also is NOT an array, so make it an array and save it
313
-				$espresso_db_update =  array( $espresso_db_update=>array() );
314
-				update_option( 'espresso_db_update', $espresso_db_update );
313
+				$espresso_db_update = array($espresso_db_update=>array());
314
+				update_option('espresso_db_update', $espresso_db_update);
315 315
 			}
316
-		}else{
316
+		} else {
317 317
 			$corrected_db_update = array();
318 318
 			//if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
319
-			foreach($espresso_db_update as $should_be_version_string => $should_be_array){
320
-				if(is_int($should_be_version_string) && ! is_array($should_be_array)){
319
+			foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
320
+				if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
321 321
 					//the key is an int, and the value IS NOT an array
322 322
 					//so it must be numerically-indexed, where values are versions installed...
323 323
 					//fix it!
324 324
 					$version_string = $should_be_array;
325 325
 					$corrected_db_update[$version_string] = array('unknown-date');
326
-				}else{
326
+				} else {
327 327
 					//ok it checks out
328 328
 					$corrected_db_update[$should_be_version_string] = $should_be_array;
329 329
 				}
330 330
 			}
331 331
 			$espresso_db_update = $corrected_db_update;
332
-			update_option( 'espresso_db_update', $espresso_db_update );
332
+			update_option('espresso_db_update', $espresso_db_update);
333 333
 
334 334
 		}
335 335
 
336
-		do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update );
336
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
337 337
 		return $espresso_db_update;
338 338
 	}
339 339
 
@@ -352,34 +352,34 @@  discard block
 block discarded – undo
352 352
 	 * so we prefer to only do it when necessary
353 353
 	 * @return void
354 354
 	 */
355
-	public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){
355
+	public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) {
356 356
 		$request_type = $this->detect_req_type();
357 357
 		//only initialize system if we're not in maintenance mode.
358
-		if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){
359
-			update_option( 'ee_flush_rewrite_rules', TRUE );
358
+		if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
359
+			update_option('ee_flush_rewrite_rules', TRUE);
360 360
 
361
-			if( $verify_schema ) {
361
+			if ($verify_schema) {
362 362
 				EEH_Activation::initialize_db_and_folders();
363 363
 			}
364 364
 			EEH_Activation::initialize_db_content();
365 365
 			EEH_Activation::system_initialization();
366
-			if( $initialize_addons_too ) {
366
+			if ($initialize_addons_too) {
367 367
 				$this->initialize_addons();
368 368
 			}
369
-		}else{
370
-			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' );
369
+		} else {
370
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
371 371
 		}
372
-		if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) {
373
-			add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 );
372
+		if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) {
373
+			add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9);
374 374
 		}
375 375
 	}
376 376
 
377 377
 	/**
378 378
 	 * Initializes the db for all registered addons
379 379
 	 */
380
-	public function initialize_addons(){
380
+	public function initialize_addons() {
381 381
 		//foreach registered addon, make sure its db is up-to-date too
382
-		foreach(EE_Registry::instance()->addons as $addon){
382
+		foreach (EE_Registry::instance()->addons as $addon) {
383 383
 			$addon->initialize_db_if_no_migrations_required();
384 384
 		}
385 385
 	}
@@ -391,16 +391,16 @@  discard block
 block discarded – undo
391 391
 	 * @param 	string 	$current_version_to_add 	version to be added to the version history
392 392
 	 * @return 	boolean success as to whether or not this option was changed
393 393
 	 */
394
-	public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) {
395
-		if( ! $version_history ) {
394
+	public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) {
395
+		if ( ! $version_history) {
396 396
 			$version_history = $this->fix_espresso_db_upgrade_option($version_history);
397 397
 		}
398
-		if( $current_version_to_add == NULL){
398
+		if ($current_version_to_add == NULL) {
399 399
 			$current_version_to_add = espresso_version();
400 400
 		}
401
-		$version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() );
401
+		$version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
402 402
 		// re-save
403
-		return update_option( 'espresso_db_update', $version_history );
403
+		return update_option('espresso_db_update', $version_history);
404 404
 	}
405 405
 
406 406
 
@@ -417,10 +417,10 @@  discard block
 block discarded – undo
417 417
 	 *                            but still know if this is a new install or not
418 418
 	 * @return int one of the constants on EE_System::req_type_
419 419
 	 */
420
-	public function detect_req_type( $espresso_db_update = NULL ){
421
-		if ( $this->_req_type === NULL ){
422
-			$espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option();
423
-			$this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() );
420
+	public function detect_req_type($espresso_db_update = NULL) {
421
+		if ($this->_req_type === NULL) {
422
+			$espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option();
423
+			$this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version());
424 424
 		}
425 425
 		return $this->_req_type;
426 426
 	}
@@ -436,39 +436,39 @@  discard block
 block discarded – undo
436 436
 	 * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version())
437 437
 	 * @return int one of the constants on EE_System::req_type_*
438 438
 	 */
439
-	public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){
440
-		$version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to );
441
-		if( $activation_history_for_addon ){
439
+	public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) {
440
+		$version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
441
+		if ($activation_history_for_addon) {
442 442
 			//it exists, so this isn't a completely new install
443 443
 			//check if this version already in that list of previously installed versions
444
-			if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) {
444
+			if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) {
445 445
 				//it a version we haven't seen before
446
-				if( $version_is_higher === 1 ){
446
+				if ($version_is_higher === 1) {
447 447
 					$req_type = EE_System::req_type_upgrade;
448
-				}else{
448
+				} else {
449 449
 					$req_type = EE_System::req_type_downgrade;
450 450
 				}
451
-				delete_option( $activation_indicator_option_name );
451
+				delete_option($activation_indicator_option_name);
452 452
 			} else {
453 453
 				// its not an update. maybe a reactivation?
454
-				if( get_option( $activation_indicator_option_name, FALSE ) ){
455
-					if ( $version_is_higher === -1 ){
454
+				if (get_option($activation_indicator_option_name, FALSE)) {
455
+					if ($version_is_higher === -1) {
456 456
 						$req_type = EE_System::req_type_downgrade;
457
-					}elseif( $version_is_higher === 0 ){
457
+					}elseif ($version_is_higher === 0) {
458 458
 						//we've seen this version before, but it's an activation. must be a reactivation
459 459
 						$req_type = EE_System::req_type_reactivation;
460
-					}else{//$version_is_higher === 1
460
+					} else {//$version_is_higher === 1
461 461
 						$req_type = EE_System::req_type_upgrade;
462 462
 					}
463
-					delete_option( $activation_indicator_option_name );
463
+					delete_option($activation_indicator_option_name);
464 464
 				} else {
465 465
 					//we've seen this version before and the activation indicate doesn't show it was just activated
466
-					if ( $version_is_higher === -1 ){
466
+					if ($version_is_higher === -1) {
467 467
 						$req_type = EE_System::req_type_downgrade;
468
-					}elseif( $version_is_higher === 0 ){
468
+					}elseif ($version_is_higher === 0) {
469 469
 						//we've seen this version before and it's not an activation. its normal request
470 470
 						$req_type = EE_System::req_type_normal;
471
-					}else{//$version_is_higher === 1
471
+					} else {//$version_is_higher === 1
472 472
 						$req_type = EE_System::req_type_upgrade;
473 473
 					}
474 474
 				}
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		} else {
477 477
 			//brand new install
478 478
 			$req_type = EE_System::req_type_new_activation;
479
-			delete_option( $activation_indicator_option_name );
479
+			delete_option($activation_indicator_option_name);
480 480
 		}
481 481
 		return $req_type;
482 482
 	}
@@ -494,30 +494,30 @@  discard block
 block discarded – undo
494 494
 	 *		0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
495 495
 	 *		1 if $version_to_upgrade_to is HIGHER (upgrade) ;
496 496
 	 */
497
-	protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){
497
+	protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) {
498 498
 		//find the most recently-activated version
499 499
 		$most_recently_active_version_activation = '1970-01-01 00:00:00';
500 500
 		$most_recently_active_version = '0.0.0.dev.000';
501
-		if( is_array( $activation_history_for_addon ) ){
502
-			foreach( $activation_history_for_addon as $version => $times_activated ){
501
+		if (is_array($activation_history_for_addon)) {
502
+			foreach ($activation_history_for_addon as $version => $times_activated) {
503 503
 				//check there is a record of when this version was activated. Otherwise,
504 504
 				//mark it as unknown
505
-				if( ! $times_activated ){
506
-					$times_activated = array( 'unknown-date');
505
+				if ( ! $times_activated) {
506
+					$times_activated = array('unknown-date');
507 507
 				}
508
-				if( is_string( $times_activated ) ){
509
-					$times_activated = array( $times_activated );
508
+				if (is_string($times_activated)) {
509
+					$times_activated = array($times_activated);
510 510
 				}
511
-				foreach( $times_activated as $an_activation ){
512
-					if( $an_activation != 'unknown-date' &&
513
-							$an_activation > $most_recently_active_version_activation  ){
511
+				foreach ($times_activated as $an_activation) {
512
+					if ($an_activation != 'unknown-date' &&
513
+							$an_activation > $most_recently_active_version_activation) {
514 514
 						$most_recently_active_version = $version;
515 515
 						$most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation;
516 516
 					}
517 517
 				}
518 518
 			}
519 519
 		}
520
-		return version_compare( $version_to_upgrade_to, $most_recently_active_version );
520
+		return version_compare($version_to_upgrade_to, $most_recently_active_version);
521 521
 	}
522 522
 
523 523
 
@@ -527,20 +527,20 @@  discard block
 block discarded – undo
527 527
 	 * @return void
528 528
 	 */
529 529
 	public function redirect_to_about_ee() {
530
-		$notices = EE_Error::get_notices( FALSE );
530
+		$notices = EE_Error::get_notices(FALSE);
531 531
 		//if current user is an admin and it's not an ajax request
532
-		if(EE_Registry::instance()->CAP->current_user_can( 'manage_options', 'espresso_about_default' ) && ! ( defined('DOING_AJAX') && DOING_AJAX  ) && ! isset( $notices[ 'errors' ] ) ){
533
-			$query_params =  array( 'page' => 'espresso_about' );
532
+		if (EE_Registry::instance()->CAP->current_user_can('manage_options', 'espresso_about_default') && ! (defined('DOING_AJAX') && DOING_AJAX) && ! isset($notices['errors'])) {
533
+			$query_params = array('page' => 'espresso_about');
534 534
 
535
-			if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) {
535
+			if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) {
536 536
 			    $query_params['new_activation'] = TRUE;
537 537
 			}
538 538
 
539
-			if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) {
539
+			if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) {
540 540
 			    $query_params['reactivation'] = TRUE;
541 541
 			}
542
-			$url = add_query_arg( $query_params, admin_url( 'admin.php' ) );
543
-			wp_safe_redirect( $url );
542
+			$url = add_query_arg($query_params, admin_url('admin.php'));
543
+			wp_safe_redirect($url);
544 544
 			exit();
545 545
 		}
546 546
 	}
@@ -554,31 +554,31 @@  discard block
 block discarded – undo
554 554
 	 *
555 555
 	 * @return void
556 556
 	 */
557
-	public function load_core_configuration(){
558
-		do_action( 'AHEE__EE_System__load_core_configuration__begin', $this );
559
-		EE_Registry::instance()->load_core( 'EE_Load_Textdomain' );
557
+	public function load_core_configuration() {
558
+		do_action('AHEE__EE_System__load_core_configuration__begin', $this);
559
+		EE_Registry::instance()->load_core('EE_Load_Textdomain');
560 560
 		//load textdomain
561 561
 		EE_Load_Textdomain::load_textdomain();
562 562
 		// load and setup EE_Config and EE_Network_Config
563
-		EE_Registry::instance()->load_core( 'Config' );
564
-		EE_Registry::instance()->load_core( 'Network_Config' );
563
+		EE_Registry::instance()->load_core('Config');
564
+		EE_Registry::instance()->load_core('Network_Config');
565 565
 		// setup autoloaders
566 566
 		// enable logging?
567
-		if ( EE_Registry::instance()->CFG->admin->use_full_logging ) {
568
-			EE_Registry::instance()->load_core( 'Log' );
567
+		if (EE_Registry::instance()->CFG->admin->use_full_logging) {
568
+			EE_Registry::instance()->load_core('Log');
569 569
 		}
570 570
 		// check for activation errors
571
-		$activation_errors = get_option( 'ee_plugin_activation_errors', FALSE );
572
-		if ( $activation_errors ) {
573
-			EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ );
574
-			update_option( 'ee_plugin_activation_errors', FALSE );
571
+		$activation_errors = get_option('ee_plugin_activation_errors', FALSE);
572
+		if ($activation_errors) {
573
+			EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
574
+			update_option('ee_plugin_activation_errors', FALSE);
575 575
 		}
576 576
 		// get model names
577 577
 		$this->_parse_model_names();
578 578
 
579 579
 		//load caf stuff a chance to play during the activation process too.
580 580
 		$this->_maybe_brew_regular();
581
-		do_action( 'AHEE__EE_System__load_core_configuration__complete', $this );
581
+		do_action('AHEE__EE_System__load_core_configuration__complete', $this);
582 582
 	}
583 583
 
584 584
 
@@ -587,23 +587,23 @@  discard block
 block discarded – undo
587 587
 	 *
588 588
 	 * @return void
589 589
 	 */
590
-	private function _parse_model_names(){
590
+	private function _parse_model_names() {
591 591
 		//get all the files in the EE_MODELS folder that end in .model.php
592
-		$models = glob( EE_MODELS.'*.model.php');
592
+		$models = glob(EE_MODELS.'*.model.php');
593 593
 		$model_names = array();
594 594
 		$non_abstract_db_models = array();
595
-		foreach( $models as $model ){
595
+		foreach ($models as $model) {
596 596
 			// get model classname
597
-			$classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model );
598
-			$shortname = str_replace( 'EEM_', '', $classname );
597
+			$classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
598
+			$shortname = str_replace('EEM_', '', $classname);
599 599
 			$reflectionClass = new ReflectionClass($classname);
600
-			if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){
600
+			if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
601 601
 				$non_abstract_db_models[$shortname] = $classname;
602 602
 			}
603
-			$model_names[ $shortname ] = $classname;
603
+			$model_names[$shortname] = $classname;
604 604
 		}
605
-		EE_Registry::instance()->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names );
606
-		EE_Registry::instance()->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models );
605
+		EE_Registry::instance()->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
606
+		EE_Registry::instance()->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models);
607 607
 	}
608 608
 
609 609
 
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
 	 * @return void
614 614
 	 */
615 615
 	private function _maybe_brew_regular() {
616
-		if (( ! defined( 'EE_DECAF' ) ||  EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) {
617
-			require_once EE_CAFF_PATH . 'brewing_regular.php';
616
+		if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) {
617
+			require_once EE_CAFF_PATH.'brewing_regular.php';
618 618
 		}
619 619
 	}
620 620
 
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 	 * @return void
632 632
 	 */
633 633
 	public function register_shortcodes_modules_and_widgets() {
634
-		do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' );
634
+		do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
635 635
 		// check for addons using old hookpoint
636
-		if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) {
636
+		if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
637 637
 			$this->_incompatible_addon_error();
638 638
 		}
639 639
 	}
@@ -647,19 +647,19 @@  discard block
 block discarded – undo
647 647
 	*/
648 648
 	private function _incompatible_addon_error() {
649 649
 		// get array of classes hooking into here
650
-		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' );
651
-		if ( ! empty( $class_names )) {
652
-			$msg = __( 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso' );
650
+		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons');
651
+		if ( ! empty($class_names)) {
652
+			$msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso');
653 653
 			$msg .= '<ul>';
654
-			foreach ( $class_names as $class_name ) {
655
-				$msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>';
654
+			foreach ($class_names as $class_name) {
655
+				$msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>';
656 656
 			}
657 657
 			$msg .= '</ul>';
658
-			$msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' );
658
+			$msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso');
659 659
 			// save list of incompatible addons to wp-options for later use
660
-			add_option( 'ee_incompatible_addons', $class_names, '', 'no' );
661
-			if ( is_admin() ) {
662
-				EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
660
+			add_option('ee_incompatible_addons', $class_names, '', 'no');
661
+			if (is_admin()) {
662
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
663 663
 			}
664 664
 		}
665 665
 	}
@@ -676,25 +676,25 @@  discard block
 block discarded – undo
676 676
 	 *
677 677
 	 * @return void
678 678
 	 */
679
-	public function brew_espresso(){
680
-		do_action( 'AHEE__EE_System__brew_espresso__begin', $this );
679
+	public function brew_espresso() {
680
+		do_action('AHEE__EE_System__brew_espresso__begin', $this);
681 681
 		// load some final core systems
682
-		add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 );
683
-		add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 );
684
-		add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 );
685
-		add_action( 'init', array( $this, 'load_controllers' ), 7 );
686
-		add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 );
687
-		add_action( 'init', array( $this, 'initialize' ), 10 );
688
-		add_action( 'init', array( $this, 'initialize_last' ), 100 );
689
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 );
690
-		add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 );
691
-
692
-		if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE )  ) {
682
+		add_action('init', array($this, 'set_hooks_for_core'), 1);
683
+		add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
684
+		add_action('init', array($this, 'load_CPTs_and_session'), 5);
685
+		add_action('init', array($this, 'load_controllers'), 7);
686
+		add_action('init', array($this, 'core_loaded_and_ready'), 9);
687
+		add_action('init', array($this, 'initialize'), 10);
688
+		add_action('init', array($this, 'initialize_last'), 100);
689
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25);
690
+		add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100);
691
+
692
+		if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) {
693 693
 			// pew pew pew
694
-			EE_Registry::instance()->load_core( 'PUE' );
695
-			do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' );
694
+			EE_Registry::instance()->load_core('PUE');
695
+			do_action('AHEE__EE_System__brew_espresso__after_pue_init');
696 696
 		}
697
-		do_action( 'AHEE__EE_System__brew_espresso__complete', $this );
697
+		do_action('AHEE__EE_System__brew_espresso__complete', $this);
698 698
 	}
699 699
 
700 700
 
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 	 */
709 709
 	public function set_hooks_for_core() {
710 710
 		$this->_deactivate_incompatible_addons();
711
-		do_action( 'AHEE__EE_System__set_hooks_for_core' );
711
+		do_action('AHEE__EE_System__set_hooks_for_core');
712 712
 	}
713 713
 
714 714
 
@@ -717,15 +717,15 @@  discard block
 block discarded – undo
717 717
 	 * Using the information gathered in EE_System::_incompatible_addon_error,
718 718
 	 * deactivates any addons considered incompatible with the current version of EE
719 719
 	 */
720
-	private function _deactivate_incompatible_addons(){
721
-		$incompatible_addons = get_option( 'ee_incompatible_addons', array() );
722
-		if ( ! empty( $incompatible_addons )) {
723
-			$active_plugins = get_option( 'active_plugins', array() );
724
-			foreach ( $active_plugins as $active_plugin ) {
725
-				foreach ( $incompatible_addons as $incompatible_addon ) {
726
-					if ( strpos( $active_plugin,  $incompatible_addon ) !== FALSE ) {
727
-						unset( $_GET['activate'] );
728
-						espresso_deactivate_plugin( $active_plugin );
720
+	private function _deactivate_incompatible_addons() {
721
+		$incompatible_addons = get_option('ee_incompatible_addons', array());
722
+		if ( ! empty($incompatible_addons)) {
723
+			$active_plugins = get_option('active_plugins', array());
724
+			foreach ($active_plugins as $active_plugin) {
725
+				foreach ($incompatible_addons as $incompatible_addon) {
726
+					if (strpos($active_plugin, $incompatible_addon) !== FALSE) {
727
+						unset($_GET['activate']);
728
+						espresso_deactivate_plugin($active_plugin);
729 729
 					}
730 730
 				}
731 731
 			}
@@ -742,10 +742,10 @@  discard block
 block discarded – undo
742 742
 	 */
743 743
 	public function perform_activations_upgrades_and_migrations() {
744 744
 		//first check if we had previously attempted to setup EE's directories but failed
745
-		if( EEH_Activation::upload_directories_incomplete() ) {
745
+		if (EEH_Activation::upload_directories_incomplete()) {
746 746
 			EEH_Activation::create_upload_directories();
747 747
 		}
748
-		do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' );
748
+		do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
749 749
 	}
750 750
 
751 751
 
@@ -757,10 +757,10 @@  discard block
 block discarded – undo
757 757
 	 *  	@return 	void
758 758
 	 */
759 759
 	public function load_CPTs_and_session() {
760
-		do_action( 'AHEE__EE_System__load_CPTs_and_session__start' );
760
+		do_action('AHEE__EE_System__load_CPTs_and_session__start');
761 761
 		// register Custom Post Types
762
-		EE_Registry::instance()->load_core( 'Register_CPTs' );
763
-		do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' );
762
+		EE_Registry::instance()->load_core('Register_CPTs');
763
+		do_action('AHEE__EE_System__load_CPTs_and_session__complete');
764 764
 	}
765 765
 
766 766
 
@@ -775,16 +775,16 @@  discard block
 block discarded – undo
775 775
 	* @return void
776 776
 	*/
777 777
 	public function load_controllers() {
778
-		do_action( 'AHEE__EE_System__load_controllers__start' );
778
+		do_action('AHEE__EE_System__load_controllers__start');
779 779
 		// let's get it started
780
-		if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) {
781
-			do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' );
782
-			EE_Registry::instance()->load_core( 'Front_Controller' );
783
-		} else if ( ! EE_FRONT_AJAX ) {
784
-			do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' );
785
-			EE_Registry::instance()->load_core( 'Admin' );
780
+		if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
781
+			do_action('AHEE__EE_System__load_controllers__load_front_controllers');
782
+			EE_Registry::instance()->load_core('Front_Controller');
783
+		} else if ( ! EE_FRONT_AJAX) {
784
+			do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
785
+			EE_Registry::instance()->load_core('Admin');
786 786
 		}
787
-		do_action( 'AHEE__EE_System__load_controllers__complete' );
787
+		do_action('AHEE__EE_System__load_controllers__complete');
788 788
 	}
789 789
 
790 790
 
@@ -798,10 +798,10 @@  discard block
 block discarded – undo
798 798
 	* @return void
799 799
 	*/
800 800
 	public function core_loaded_and_ready() {
801
-		do_action( 'AHEE__EE_System__core_loaded_and_ready' );
802
-		do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' );
801
+		do_action('AHEE__EE_System__core_loaded_and_ready');
802
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
803 803
 //		add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 );
804
-		EE_Registry::instance()->load_core( 'Session' );
804
+		EE_Registry::instance()->load_core('Session');
805 805
 	}
806 806
 
807 807
 
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
 	* @return void
816 816
 	*/
817 817
 	public function initialize() {
818
-		do_action( 'AHEE__EE_System__initialize' );
818
+		do_action('AHEE__EE_System__initialize');
819 819
 	}
820 820
 
821 821
 
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 	* @return void
830 830
 	*/
831 831
 	public function initialize_last() {
832
-		do_action( 'AHEE__EE_System__initialize_last' );
832
+		do_action('AHEE__EE_System__initialize_last');
833 833
 	}
834 834
 
835 835
 
@@ -861,21 +861,21 @@  discard block
 block discarded – undo
861 861
 	*/
862 862
 	public static function do_not_cache() {
863 863
 		// set no cache constants
864
-		if ( ! defined( 'DONOTCACHEPAGE' ) ) {
865
-			define( 'DONOTCACHEPAGE', true );
864
+		if ( ! defined('DONOTCACHEPAGE')) {
865
+			define('DONOTCACHEPAGE', true);
866 866
 		}
867
-		if ( ! defined( 'DONOTCACHCEOBJECT' ) ) {
868
-			define( 'DONOTCACHCEOBJECT', true );
867
+		if ( ! defined('DONOTCACHCEOBJECT')) {
868
+			define('DONOTCACHCEOBJECT', true);
869 869
 		}
870
-		if ( ! defined( 'DONOTCACHEDB' ) ) {
871
-			define( 'DONOTCACHEDB', true );
870
+		if ( ! defined('DONOTCACHEDB')) {
871
+			define('DONOTCACHEDB', true);
872 872
 		}
873 873
 		// add no cache headers
874
-		add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 );
874
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
875 875
 		// plus a little extra for nginx and Google Chrome
876
-		add_filter( 'nocache_headers', array( 'EE_System', 'extra_nocache_headers' ), 10, 1 );
876
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
877 877
 		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
878
-		remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );
878
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
879 879
 	}
880 880
 
881 881
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 * @param $headers
888 888
 	 * @return    array
889 889
 	 */
890
-	public static function extra_nocache_headers ( $headers ) {
890
+	public static function extra_nocache_headers($headers) {
891 891
 		// for NGINX
892 892
 		$headers['X-Accel-Expires'] = 0;
893 893
 		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
@@ -916,14 +916,14 @@  discard block
 block discarded – undo
916 916
 	 * @param $admin_bar
917 917
 	 * @return    void
918 918
 	 */
919
-	public function espresso_toolbar_items( $admin_bar ) {
919
+	public function espresso_toolbar_items($admin_bar) {
920 920
 
921 921
 		// if in full M-Mode, or its an AJAX request, or user is NOT an admin
922
-		if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) {
922
+		if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) {
923 923
 			return;
924 924
 		}
925 925
 
926
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
926
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
927 927
 		$menu_class = 'espresso_menu_item_class';
928 928
 		//we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL
929 929
 		//because they're only defined in each of their respective constructors
@@ -935,20 +935,20 @@  discard block
 block discarded – undo
935 935
 		//Top Level
936 936
 		$admin_bar->add_menu(array(
937 937
 				'id' => 'espresso-toolbar',
938
-				'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>',
938
+				'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'._x('Event Espresso', 'admin bar menu group label', 'event_espresso').'</span>',
939 939
 				'href' => $events_admin_url,
940 940
 				'meta' => array(
941 941
 						'title' => __('Event Espresso', 'event_espresso'),
942
-						'class' => $menu_class . 'first'
942
+						'class' => $menu_class.'first'
943 943
 				),
944 944
 		));
945 945
 
946 946
 		//Events
947
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) {
947
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) {
948 948
 			$admin_bar->add_menu(array(
949 949
 					'id' => 'espresso-toolbar-events',
950 950
 					'parent' => 'espresso-toolbar',
951
-					'title' => __( 'Events', 'event_espresso' ),
951
+					'title' => __('Events', 'event_espresso'),
952 952
 					'href' => $events_admin_url,
953 953
 					'meta' => array(
954 954
 							'title' => __('Events', 'event_espresso'),
@@ -959,13 +959,13 @@  discard block
 block discarded – undo
959 959
 		}
960 960
 
961 961
 
962
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) {
962
+		if (EE_Registry::instance()->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) {
963 963
 			//Events Add New
964 964
 			$admin_bar->add_menu(array(
965 965
 					'id' => 'espresso-toolbar-events-new',
966 966
 					'parent' => 'espresso-toolbar-events',
967 967
 					'title' => __('Add New', 'event_espresso'),
968
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ),
968
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url),
969 969
 					'meta' => array(
970 970
 							'title' => __('Add New', 'event_espresso'),
971 971
 							'target' => '',
@@ -974,18 +974,18 @@  discard block
 block discarded – undo
974 974
 			));
975 975
 		}
976 976
 
977
-		if ( is_single() && ( get_post_type() == 'espresso_events' ) ) {
977
+		if (is_single() && (get_post_type() == 'espresso_events')) {
978 978
 
979 979
 			//Current post
980 980
 			global $post;
981 981
 
982
-	    	if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) {
982
+	    	if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) {
983 983
 				//Events Edit Current Event
984 984
 				$admin_bar->add_menu(array(
985 985
 						'id' => 'espresso-toolbar-events-edit',
986 986
 						'parent' => 'espresso-toolbar-events',
987 987
 						'title' => __('Edit Event', 'event_espresso'),
988
-						'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ),
988
+						'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url),
989 989
 						'meta' => array(
990 990
 								'title' => __('Edit Event', 'event_espresso'),
991 991
 								'target' => '',
@@ -997,11 +997,11 @@  discard block
 block discarded – undo
997 997
 		}
998 998
 
999 999
 		//Events View
1000
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) {
1000
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) {
1001 1001
 			$admin_bar->add_menu(array(
1002 1002
 					'id' => 'espresso-toolbar-events-view',
1003 1003
 					'parent' => 'espresso-toolbar-events',
1004
-					'title' => __( 'View', 'event_espresso' ),
1004
+					'title' => __('View', 'event_espresso'),
1005 1005
 					'href' => $events_admin_url,
1006 1006
 					'meta' => array(
1007 1007
 							'title' => __('View', 'event_espresso'),
@@ -1011,12 +1011,12 @@  discard block
 block discarded – undo
1011 1011
 			));
1012 1012
 		}
1013 1013
 
1014
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) {
1014
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) {
1015 1015
 			//Events View All
1016 1016
 			$admin_bar->add_menu(array(
1017 1017
 					'id' => 'espresso-toolbar-events-all',
1018 1018
 					'parent' => 'espresso-toolbar-events-view',
1019
-					'title' => __( 'All', 'event_espresso' ),
1019
+					'title' => __('All', 'event_espresso'),
1020 1020
 					'href' => $events_admin_url,
1021 1021
 					'meta' => array(
1022 1022
 							'title' => __('All', 'event_espresso'),
@@ -1027,13 +1027,13 @@  discard block
 block discarded – undo
1027 1027
 		}
1028 1028
 
1029 1029
 
1030
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) {
1030
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) {
1031 1031
 			//Events View Today
1032 1032
 			$admin_bar->add_menu(array(
1033 1033
 					'id' => 'espresso-toolbar-events-today',
1034 1034
 					'parent' => 'espresso-toolbar-events-view',
1035 1035
 					'title' => __('Today', 'event_espresso'),
1036
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ),
1036
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url),
1037 1037
 					'meta' => array(
1038 1038
 							'title' => __('Today', 'event_espresso'),
1039 1039
 							'target' => '',
@@ -1043,13 +1043,13 @@  discard block
 block discarded – undo
1043 1043
 		}
1044 1044
 
1045 1045
 
1046
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) {
1046
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) {
1047 1047
 			//Events View This Month
1048 1048
 			$admin_bar->add_menu(array(
1049 1049
 					'id' => 'espresso-toolbar-events-month',
1050 1050
 					'parent' => 'espresso-toolbar-events-view',
1051
-					'title' => __( 'This Month', 'event_espresso'),
1052
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ),
1051
+					'title' => __('This Month', 'event_espresso'),
1052
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url),
1053 1053
 					'meta' => array(
1054 1054
 							'title' => __('This Month', 'event_espresso'),
1055 1055
 							'target' => '',
@@ -1059,11 +1059,11 @@  discard block
 block discarded – undo
1059 1059
 		}
1060 1060
 
1061 1061
 		//Registration Overview
1062
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) {
1062
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) {
1063 1063
 			$admin_bar->add_menu(array(
1064 1064
 					'id' => 'espresso-toolbar-registrations',
1065 1065
 					'parent' => 'espresso-toolbar',
1066
-					'title' => __( 'Registrations', 'event_espresso' ),
1066
+					'title' => __('Registrations', 'event_espresso'),
1067 1067
 					'href' => $reg_admin_url,
1068 1068
 					'meta' => array(
1069 1069
 							'title' => __('Registrations', 'event_espresso'),
@@ -1074,12 +1074,12 @@  discard block
 block discarded – undo
1074 1074
 		}
1075 1075
 
1076 1076
 		//Registration Overview Today
1077
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) {
1077
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) {
1078 1078
 			$admin_bar->add_menu(array(
1079 1079
 					'id' => 'espresso-toolbar-registrations-today',
1080 1080
 					'parent' => 'espresso-toolbar-registrations',
1081
-					'title' => __( 'Today', 'event_espresso'),
1082
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ),
1081
+					'title' => __('Today', 'event_espresso'),
1082
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url),
1083 1083
 					'meta' => array(
1084 1084
 							'title' => __('Today', 'event_espresso'),
1085 1085
 							'target' => '',
@@ -1089,14 +1089,14 @@  discard block
 block discarded – undo
1089 1089
 		}
1090 1090
 
1091 1091
 		//Registration Overview Today Completed
1092
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) {
1092
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) {
1093 1093
 			$admin_bar->add_menu(array(
1094 1094
 					'id' => 'espresso-toolbar-registrations-today-approved',
1095 1095
 					'parent' => 'espresso-toolbar-registrations-today',
1096
-					'title' => __( 'Approved', 'event_espresso' ),
1097
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ),
1096
+					'title' => __('Approved', 'event_espresso'),
1097
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url),
1098 1098
 					'meta' => array(
1099
-							'title' => __('Approved', 'event_espresso' ),
1099
+							'title' => __('Approved', 'event_espresso'),
1100 1100
 							'target' => '',
1101 1101
 							'class' => $menu_class
1102 1102
 					),
@@ -1104,14 +1104,14 @@  discard block
 block discarded – undo
1104 1104
 		}
1105 1105
 
1106 1106
 		//Registration Overview Today Pending\
1107
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) {
1107
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) {
1108 1108
 			$admin_bar->add_menu(array(
1109 1109
 					'id' => 'espresso-toolbar-registrations-today-pending',
1110 1110
 					'parent' => 'espresso-toolbar-registrations-today',
1111
-					'title' => __( 'Pending', 'event_espresso' ),
1112
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ),
1111
+					'title' => __('Pending', 'event_espresso'),
1112
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url),
1113 1113
 					'meta' => array(
1114
-							'title' => __('Pending Payment', 'event_espresso' ),
1114
+							'title' => __('Pending Payment', 'event_espresso'),
1115 1115
 							'target' => '',
1116 1116
 							'class' => $menu_class
1117 1117
 					),
@@ -1119,14 +1119,14 @@  discard block
 block discarded – undo
1119 1119
 		}
1120 1120
 
1121 1121
 		//Registration Overview Today Incomplete
1122
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) {
1122
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) {
1123 1123
 			$admin_bar->add_menu(array(
1124 1124
 					'id' => 'espresso-toolbar-registrations-today-not-approved',
1125 1125
 					'parent' => 'espresso-toolbar-registrations-today',
1126
-					'title' => __( 'Not Approved', 'event_espresso' ),
1127
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ),
1126
+					'title' => __('Not Approved', 'event_espresso'),
1127
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url),
1128 1128
 					'meta' => array(
1129
-							'title' => __('Not Approved', 'event_espresso' ),
1129
+							'title' => __('Not Approved', 'event_espresso'),
1130 1130
 							'target' => '',
1131 1131
 							'class' => $menu_class
1132 1132
 					),
@@ -1134,12 +1134,12 @@  discard block
 block discarded – undo
1134 1134
 		}
1135 1135
 
1136 1136
 		//Registration Overview Today Incomplete
1137
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) {
1137
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) {
1138 1138
 			$admin_bar->add_menu(array(
1139 1139
 					'id' => 'espresso-toolbar-registrations-today-cancelled',
1140 1140
 					'parent' => 'espresso-toolbar-registrations-today',
1141
-					'title' => __( 'Cancelled', 'event_espresso'),
1142
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ),
1141
+					'title' => __('Cancelled', 'event_espresso'),
1142
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url),
1143 1143
 					'meta' => array(
1144 1144
 							'title' => __('Cancelled', 'event_espresso'),
1145 1145
 							'target' => '',
@@ -1149,12 +1149,12 @@  discard block
 block discarded – undo
1149 1149
 		}
1150 1150
 
1151 1151
 		//Registration Overview This Month
1152
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) {
1152
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) {
1153 1153
 			$admin_bar->add_menu(array(
1154 1154
 					'id' => 'espresso-toolbar-registrations-month',
1155 1155
 					'parent' => 'espresso-toolbar-registrations',
1156
-					'title' => __( 'This Month', 'event_espresso' ),
1157
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ),
1156
+					'title' => __('This Month', 'event_espresso'),
1157
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url),
1158 1158
 					'meta' => array(
1159 1159
 							'title' => __('This Month', 'event_espresso'),
1160 1160
 							'target' => '',
@@ -1164,12 +1164,12 @@  discard block
 block discarded – undo
1164 1164
 		}
1165 1165
 
1166 1166
 		//Registration Overview This Month Approved
1167
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) {
1167
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) {
1168 1168
 			$admin_bar->add_menu(array(
1169 1169
 					'id' => 'espresso-toolbar-registrations-month-approved',
1170 1170
 					'parent' => 'espresso-toolbar-registrations-month',
1171
-					'title' => __( 'Approved', 'event_espresso' ),
1172
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ),
1171
+					'title' => __('Approved', 'event_espresso'),
1172
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url),
1173 1173
 					'meta' => array(
1174 1174
 							'title' => __('Approved', 'event_espresso'),
1175 1175
 							'target' => '',
@@ -1179,12 +1179,12 @@  discard block
 block discarded – undo
1179 1179
 		}
1180 1180
 
1181 1181
 		//Registration Overview This Month Pending
1182
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) {
1182
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) {
1183 1183
 			$admin_bar->add_menu(array(
1184 1184
 					'id' => 'espresso-toolbar-registrations-month-pending',
1185 1185
 					'parent' => 'espresso-toolbar-registrations-month',
1186
-					'title' => __( 'Pending', 'event_espresso'),
1187
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ),
1186
+					'title' => __('Pending', 'event_espresso'),
1187
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url),
1188 1188
 					'meta' => array(
1189 1189
 							'title' => __('Pending', 'event_espresso'),
1190 1190
 							'target' => '',
@@ -1194,14 +1194,14 @@  discard block
 block discarded – undo
1194 1194
 		}
1195 1195
 
1196 1196
 		//Registration Overview This Month Not Approved
1197
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) {
1197
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) {
1198 1198
 			$admin_bar->add_menu(array(
1199 1199
 					'id' => 'espresso-toolbar-registrations-month-not-approved',
1200 1200
 					'parent' => 'espresso-toolbar-registrations-month',
1201
-					'title' => __( 'Not Approved', 'event_espresso'),
1202
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ),
1201
+					'title' => __('Not Approved', 'event_espresso'),
1202
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url),
1203 1203
 					'meta' => array(
1204
-							'title' => __('Not Approved', 'event_espresso' ),
1204
+							'title' => __('Not Approved', 'event_espresso'),
1205 1205
 							'target' => '',
1206 1206
 							'class' => $menu_class
1207 1207
 					),
@@ -1210,12 +1210,12 @@  discard block
 block discarded – undo
1210 1210
 
1211 1211
 
1212 1212
 		//Registration Overview This Month Cancelled
1213
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) {
1213
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) {
1214 1214
 			$admin_bar->add_menu(array(
1215 1215
 					'id' => 'espresso-toolbar-registrations-month-cancelled',
1216 1216
 					'parent' => 'espresso-toolbar-registrations-month',
1217 1217
 					'title' => __('Cancelled', 'event_espresso'),
1218
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ),
1218
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url),
1219 1219
 					'meta' => array(
1220 1220
 							'title' => __('Cancelled', 'event_espresso'),
1221 1221
 							'target' => '',
@@ -1225,11 +1225,11 @@  discard block
 block discarded – undo
1225 1225
 		}
1226 1226
 
1227 1227
 		//Extensions & Services
1228
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) {
1228
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) {
1229 1229
 			$admin_bar->add_menu(array(
1230 1230
 					'id' => 'espresso-toolbar-extensions-and-services',
1231 1231
 					'parent' => 'espresso-toolbar',
1232
-					'title' => __( 'Extensions & Services', 'event_espresso' ),
1232
+					'title' => __('Extensions & Services', 'event_espresso'),
1233 1233
 					'href' => $extensions_admin_url,
1234 1234
 					'meta' => array(
1235 1235
 							'title' => __('Extensions & Services', 'event_espresso'),
@@ -1251,8 +1251,8 @@  discard block
 block discarded – undo
1251 1251
 	 * @param  array  $exclude_array any existing pages being excluded are in this array.
1252 1252
 	 * @return array
1253 1253
 	 */
1254
-	public function remove_pages_from_wp_list_pages( $exclude_array ) {
1255
-		return  array_merge( $exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array() );
1254
+	public function remove_pages_from_wp_list_pages($exclude_array) {
1255
+		return  array_merge($exclude_array, EE_Registry::instance()->CFG->core->get_critical_pages_array());
1256 1256
 	}
1257 1257
 
1258 1258
 
@@ -1272,12 +1272,12 @@  discard block
 block discarded – undo
1272 1272
 	 */
1273 1273
 	public function wp_enqueue_scripts() {
1274 1274
 		// unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' );
1275
-		if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) {
1275
+		if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) {
1276 1276
 			// jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via:  add_filter( 'FHEE_load_jquery_validate', '__return_true' );
1277
-			if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) {
1277
+			if (apply_filters('FHEE_load_jquery_validate', FALSE)) {
1278 1278
 				// register jQuery Validate and additional methods
1279
-				wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery' ), '1.15.0', TRUE );
1280
-				wp_register_script( 'jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', array( 'jquery', 'jquery-validate' ), '1.15.0', TRUE );
1279
+				wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE);
1280
+				wp_register_script('jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', array('jquery', 'jquery-validate'), '1.15.0', TRUE);
1281 1281
 			}
1282 1282
 		}
1283 1283
 	}
Please login to merge, or discard this patch.
core/CPTs/EE_CPT_Event_Strategy.core.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 	 * @param 	array 	$arguments
40 40
 	 * @return 	\EE_CPT_Event_Strategy
41 41
 	 */
42
-	public function __construct( $arguments = array() ) {
43
-		$this->CPT = isset( $arguments['CPT'] ) ? $arguments['CPT'] : NULL;
44
-		$WP_Query = isset( $arguments['WP_Query'] ) ? $arguments['WP_Query'] : NULL;
42
+	public function __construct($arguments = array()) {
43
+		$this->CPT = isset($arguments['CPT']) ? $arguments['CPT'] : NULL;
44
+		$WP_Query = isset($arguments['WP_Query']) ? $arguments['WP_Query'] : NULL;
45 45
 
46 46
 		// !!!!!!!!!!  IMPORTANT !!!!!!!!!!!!
47 47
 		// here's the list of available filters in the WP_Query object
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 		// 'posts_fields'
56 56
 		// 'posts_join'
57 57
 		$this->_add_filters();
58
-		if ( $WP_Query instanceof WP_Query ) {
59
-			$WP_Query->is_espresso_event_single = is_singular() && isset( $WP_Query->query->post_type ) && $WP_Query->query->post_type == 'espresso_events' ? TRUE : FALSE;
58
+		if ($WP_Query instanceof WP_Query) {
59
+			$WP_Query->is_espresso_event_single = is_singular() && isset($WP_Query->query->post_type) && $WP_Query->query->post_type == 'espresso_events' ? TRUE : FALSE;
60 60
 			$WP_Query->is_espresso_event_archive = is_post_type_archive('espresso_events') ? TRUE : FALSE;
61
-			$WP_Query->is_espresso_event_taxonomy = is_tax( 'espresso_event_categories' ) ? TRUE : FALSE;
61
+			$WP_Query->is_espresso_event_taxonomy = is_tax('espresso_event_categories') ? TRUE : FALSE;
62 62
 		}
63 63
 
64 64
 	}
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 	 * (which will get removed in case the next call to get_posts ISN'T
71 71
 	 * for event CPTs)
72 72
 	 */
73
-	protected function _add_filters(){
74
-		add_filter( 'posts_fields', array( $this, 'posts_fields' ), 1, 2 );
75
-		add_filter( 'posts_join', array( $this, 'posts_join' ), 1, 2 );
76
-		add_filter( 'posts_where', array( $this, 'posts_where' ), 10, 2 );
73
+	protected function _add_filters() {
74
+		add_filter('posts_fields', array($this, 'posts_fields'), 1, 2);
75
+		add_filter('posts_join', array($this, 'posts_join'), 1, 2);
76
+		add_filter('posts_where', array($this, 'posts_where'), 10, 2);
77 77
 		// add_filter( 'the_posts', array( $this, 'the_posts' ), 1, 2 );
78
-		add_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1, 2 );
79
-		add_filter( 'posts_groupby', array( $this, 'posts_groupby' ), 1, 2 );
78
+		add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2);
79
+		add_filter('posts_groupby', array($this, 'posts_groupby'), 1, 2);
80 80
 	}
81 81
 
82 82
 
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 	 * This is to avoid applying this CPT strategy for other posts or CPTs (eg,
87 87
 	 * we don't want to join to the datetime table when querying for venues, do we!?)
88 88
 	 */
89
-	protected function _remove_filters(){
90
-		remove_filter( 'posts_fields', array( $this, 'posts_fields' ), 1 );
91
-		remove_filter( 'posts_join', array( $this, 'posts_join' ), 1 );
92
-		remove_filter( 'posts_where', array( $this, 'posts_where' ), 10 );
89
+	protected function _remove_filters() {
90
+		remove_filter('posts_fields', array($this, 'posts_fields'), 1);
91
+		remove_filter('posts_join', array($this, 'posts_join'), 1);
92
+		remove_filter('posts_where', array($this, 'posts_where'), 10);
93 93
 		// remove_filter( 'the_posts', array( $this, 'the_posts' ), 1 );
94
-		remove_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1 );
95
-		remove_filter( 'posts_groupby', array( $this, 'posts_groupby' ), 1 );
94
+		remove_filter('posts_orderby', array($this, 'posts_orderby'), 1);
95
+		remove_filter('posts_groupby', array($this, 'posts_groupby'), 1);
96 96
 	}
97 97
 
98 98
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @param WP_Query $wp_query
106 106
 	 * @return    string
107 107
 	 */
108
-	public function posts_fields( $SQL, WP_Query $wp_query ) {
108
+	public function posts_fields($SQL, WP_Query $wp_query) {
109 109
 		if (
110 110
 			$wp_query instanceof WP_Query
111 111
 			&&
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 			)
117 117
 		) {
118 118
 			// adds something like ", wp_esp_datetime.* " to WP Query SELECT statement
119
-			$SQL .= ', ' . EEM_Datetime::instance()->table() . '.* ' ;
120
-			if ( $wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy ) {
119
+			$SQL .= ', '.EEM_Datetime::instance()->table().'.* ';
120
+			if ($wp_query->is_espresso_event_archive || $wp_query->is_espresso_event_taxonomy) {
121 121
 				// because we only want to retrieve the next upcoming datetime for each event:
122 122
 				// add something like ", MIN( wp_esp_datetime.DTT_EVT_start ) as event_start_date " to WP Query SELECT statement
123
-				$SQL .= ', MIN( ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start ) as event_start_date ' ;
123
+				$SQL .= ', MIN( '.EEM_Datetime::instance()->table().'.DTT_EVT_start ) as event_start_date ';
124 124
 			}
125 125
 		}
126 126
 		return $SQL;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @internal  param \WP_Query $WP_Query
138 138
 	 * @return    string
139 139
 	 */
140
-	public function posts_join( $SQL, WP_Query $wp_query ) {
140
+	public function posts_join($SQL, WP_Query $wp_query) {
141 141
 		if (
142 142
 			$wp_query instanceof WP_Query
143 143
 			&&
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 			)
149 149
 		) {
150 150
 			// adds something like " LEFT JOIN wp_esp_datetime ON ( wp_esp_datetime.EVT_ID = wp_posts.ID ) " to WP Query JOIN statement
151
-			$SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name() . ' ) ';
151
+			$SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name().' ) ';
152 152
 		}
153 153
 		return $SQL;
154 154
 	}
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param WP_Query $wp_query
164 164
 	 * @return    string
165 165
 	 */
166
-	public function posts_where( $SQL, WP_Query $wp_query ) {
166
+	public function posts_where($SQL, WP_Query $wp_query) {
167 167
 //		global $wpdb;
168 168
 		if (
169 169
 			$wp_query instanceof WP_Query
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 				|| $wp_query->is_espresso_event_taxonomy
174 174
 			)
175 175
 		) {
176
-			if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive ) || ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events ) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events ) {
177
-				$SQL .=  ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . current_time( 'mysql', true ) . '" ';
176
+			if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive) || ! isset(EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->display_expired_events) {
177
+				$SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.current_time('mysql', true).'" ';
178 178
 			}
179 179
 		}
180 180
 		return $SQL;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @param 	WP_Query $wp_query
191 191
 	 * @return 	string
192 192
 	 */
193
-	public function posts_orderby( $SQL, WP_Query $wp_query ) {
193
+	public function posts_orderby($SQL, WP_Query $wp_query) {
194 194
 		if (
195 195
 			$wp_query instanceof WP_Query
196 196
 			&&
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @param WP_Query $wp_query
215 215
 	 * @return    string
216 216
 	 */
217
-	public function posts_groupby( $SQL, WP_Query $wp_query ) {
217
+	public function posts_groupby($SQL, WP_Query $wp_query) {
218 218
 		if (
219 219
 			$wp_query instanceof WP_Query
220 220
 			&&
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 			// we're joining to the datetimes table, where there can be MANY datetimes for a single event, but we want to only show each event only once
228 228
 			// (whereas if we didn't group them by the post's ID, then we would end up with many repeats)
229 229
 			global $wpdb;
230
-			$SQL = $wpdb->posts . '.ID ';
230
+			$SQL = $wpdb->posts.'.ID ';
231 231
 		}
232 232
 		return $SQL;
233 233
 	}
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * @param WP_Query $wp_query
243 243
 	 * @return    array
244 244
 	 */
245
-	public function the_posts( $posts, WP_Query $wp_query ) {
245
+	public function the_posts($posts, WP_Query $wp_query) {
246 246
 		return $posts;
247 247
 	}
248 248
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @param      $single
259 259
 	 * @return    string
260 260
 	 */
261
-	public function get_EE_post_type_metadata( $meta_value = NULL, $post_id, $meta_key, $single ) {
261
+	public function get_EE_post_type_metadata($meta_value = NULL, $post_id, $meta_key, $single) {
262 262
 		return $meta_value;
263 263
 	}
264 264
 
Please login to merge, or discard this patch.