Completed
Branch BUG-9548-transaction-completio... (b1c41e)
by
unknown
560:12 queued 545:24
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/db_classes/EE_Base_Class.class.php 1 patch
Spacing   +484 added lines, -484 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
2
-do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2
+do_action('AHEE_log', __FILE__, ' FILE LOADED', '');
3 3
 /**
4 4
  *
5 5
  * Event Espresso
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * ------------------------------------------------------------------------
25 25
  */
26 26
 
27
-abstract class EE_Base_Class{
27
+abstract class EE_Base_Class {
28 28
 
29 29
 	/**
30 30
 	 * This is an array of the original properties and values provided during construction
@@ -117,59 +117,59 @@  discard block
 block discarded – undo
117 117
 	 * @throws EE_Error
118 118
 	 * @return \EE_Base_Class
119 119
 	 */
120
-	protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){
120
+	protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) {
121 121
 
122
-		$className=get_class($this);
122
+		$className = get_class($this);
123 123
 
124
-		do_action("AHEE__{$className}__construct",$this,$fieldValues);
125
-		$model=$this->get_model();
126
-		$model_fields = $model->field_settings( FALSE );
124
+		do_action("AHEE__{$className}__construct", $this, $fieldValues);
125
+		$model = $this->get_model();
126
+		$model_fields = $model->field_settings(FALSE);
127 127
 		// ensure $fieldValues is an array
128
-		$fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues );
128
+		$fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues);
129 129
 		// EEH_Debug_Tools::printr( $fieldValues, '$fieldValues  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
130 130
 		// verify client code has not passed any invalid field names
131
-		foreach($fieldValues as $field_name=> $field_value){
132
-			if( ! isset( $model_fields[ $field_name] ) ){
133
-				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields))));
131
+		foreach ($fieldValues as $field_name=> $field_value) {
132
+			if ( ! isset($model_fields[$field_name])) {
133
+				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields))));
134 134
 			}
135 135
 		}
136 136
 		// EEH_Debug_Tools::printr( $model_fields, '$model_fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
137
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
137
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
138 138
 
139
-		if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
139
+		if ( ! empty($date_formats) && is_array($date_formats)) {
140 140
 			$this->_dt_frmt = $date_formats[0];
141 141
 			$this->_tm_frmt = $date_formats[1];
142 142
 		} else {
143 143
 			//set default formats for date and time
144
-			$this->_dt_frmt = get_option( 'date_format' );
145
-			$this->_tm_frmt = get_option( 'time_format' );
144
+			$this->_dt_frmt = get_option('date_format');
145
+			$this->_tm_frmt = get_option('time_format');
146 146
 		}
147 147
 
148 148
 		//if db model is instantiating
149
-		if ( $bydb ){
149
+		if ($bydb) {
150 150
 			//client code has indicated these field values are from the database
151
-			foreach( $model_fields as $fieldName => $field ){
152
-				$this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null );
151
+			foreach ($model_fields as $fieldName => $field) {
152
+				$this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null);
153 153
 			}
154 154
 		} else {
155 155
 			//we're constructing a brand
156 156
 			//new instance of the model object. Generally, this means we'll need to do more field validation
157
-			foreach( $model_fields as $fieldName => $field ){
158
-				$this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true );
157
+			foreach ($model_fields as $fieldName => $field) {
158
+				$this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true);
159 159
 			}
160 160
 		}
161 161
 
162 162
 		//remember what values were passed to this constructor
163 163
 		$this->_props_n_values_provided_in_constructor = $fieldValues;
164 164
 		//remember in entity mapper
165
-		if( ! $bydb  && $model->has_primary_key_field() && $this->ID() ){
165
+		if ( ! $bydb && $model->has_primary_key_field() && $this->ID()) {
166 166
 			$model->add_to_entity_map($this);
167 167
 		}
168 168
 		//setup all the relations
169
-		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
170
-			if($relation_obj instanceof EE_Belongs_To_Relation){
169
+		foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) {
170
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
171 171
 				$this->_model_relations[$relation_name] = NULL;
172
-			}else{
172
+			} else {
173 173
 				$this->_model_relations[$relation_name] = array();
174 174
 			}
175 175
 		}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		 * Action done at the end of each model object construction
178 178
 		 * @param EE_Base_Class $this the model object just created
179 179
 		 */
180
-		do_action( 'AHEE__EE_Base_Class__construct__finished', $this );
180
+		do_action('AHEE__EE_Base_Class__construct__finished', $this);
181 181
 	}
182 182
 
183 183
 	/**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param boolean $allow_persist
198 198
 	 * @return boolean
199 199
 	 */
200
-	public function set_allow_persist( $allow_persist ) {
200
+	public function set_allow_persist($allow_persist) {
201 201
 		return $this->_allow_persist = $allow_persist;
202 202
 	}
203 203
 
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	 * @return mixed|null
212 212
 	 * @throws \EE_Error
213 213
 	 */
214
-	public function get_original( $field_name ){
215
-		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
216
-				$field_settings = $this->get_model()->field_settings_for( $field_name )){
217
-			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
218
-		}else{
214
+	public function get_original($field_name) {
215
+		if (isset($this->_props_n_values_provided_in_constructor[$field_name]) &&
216
+				$field_settings = $this->get_model()->field_settings_for($field_name)) {
217
+			return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]);
218
+		} else {
219 219
 			return NULL;
220 220
 		}
221 221
 	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 * @param EE_Base_Class $obj
226 226
 	 * @return string
227 227
 	 */
228
-	public function get_class($obj){
228
+	public function get_class($obj) {
229 229
 		return get_class($obj);
230 230
 	}
231 231
 
@@ -240,19 +240,19 @@  discard block
 block discarded – undo
240 240
 	 * @param bool      $use_default
241 241
 	 * @throws \EE_Error
242 242
 	 */
243
-	public function set( $field_name, $field_value, $use_default = FALSE ){
244
-		$field_obj = $this->get_model()->field_settings_for( $field_name );
245
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
243
+	public function set($field_name, $field_value, $use_default = FALSE) {
244
+		$field_obj = $this->get_model()->field_settings_for($field_name);
245
+		if ($field_obj instanceof EE_Model_Field_Base) {
246 246
 //			if ( method_exists( $field_obj, 'set_timezone' )) {
247
-			if ( $field_obj instanceof EE_Datetime_Field ) {
248
-				$field_obj->set_timezone( $this->_timezone );
249
-				$field_obj->set_date_format( $this->_dt_frmt );
250
-				$field_obj->set_time_format( $this->_tm_frmt );
247
+			if ($field_obj instanceof EE_Datetime_Field) {
248
+				$field_obj->set_timezone($this->_timezone);
249
+				$field_obj->set_date_format($this->_dt_frmt);
250
+				$field_obj->set_time_format($this->_tm_frmt);
251 251
 			}
252 252
 
253 253
 			$holder_of_value = $field_obj->prepare_for_set($field_value);
254 254
 			//should the value be null?
255
-			if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){
255
+			if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) {
256 256
 				$this->_fields[$field_name] = $field_obj->get_default_value();
257 257
 
258 258
 				/**
@@ -264,26 +264,26 @@  discard block
 block discarded – undo
264 264
 				 */
265 265
 				if (
266 266
 					$field_obj instanceof EE_Datetime_Field
267
-					&& $this->_fields[ $field_name ] !== null
267
+					&& $this->_fields[$field_name] !== null
268 268
 					&& ! $this->_fields[$field_name] instanceof DateTime
269 269
 				) {
270
-					empty( $this->_fields[$field_name] )
271
-						? $this->set( $field_name, time() )
272
-						: $this->set( $field_name, $this->_fields[$field_name] );
270
+					empty($this->_fields[$field_name])
271
+						? $this->set($field_name, time())
272
+						: $this->set($field_name, $this->_fields[$field_name]);
273 273
 				}
274 274
 
275
-			}else{
275
+			} else {
276 276
 				$this->_fields[$field_name] = $holder_of_value;
277 277
 			}
278 278
 
279 279
 			//if we're not in the constructor...
280 280
 			//now check if what we set was a primary key
281
-			if(
281
+			if (
282 282
 				//note: props_n_values_provided_in_constructor is only set at the END of the constructor
283 283
 				$this->_props_n_values_provided_in_constructor
284 284
 				&& $field_value
285
-				&& $field_name === self::_get_primary_key_name( get_class( $this ) )
286
-			){
285
+				&& $field_name === self::_get_primary_key_name(get_class($this))
286
+			) {
287 287
 				//if so, we want all this object's fields to be filled either with
288 288
 				//what we've explicitly set on this model
289 289
 				//or what we have in the db
@@ -291,20 +291,20 @@  discard block
 block discarded – undo
291 291
 				$fields_on_model = self::_get_model(get_class($this))->field_settings();
292 292
 
293 293
 				$obj_in_db = self::_get_model(get_class($this))->get_one_by_ID($field_value);
294
-				foreach($fields_on_model as $field_obj){
295
-					if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
296
-						&& $field_obj->get_name() !== $field_name ){
294
+				foreach ($fields_on_model as $field_obj) {
295
+					if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
296
+						&& $field_obj->get_name() !== $field_name) {
297 297
 
298
-						$this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name()));
298
+						$this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name()));
299 299
 					}
300 300
 				}
301 301
 				//oh this model object has an ID? well make sure its in the entity mapper
302 302
 				$this->get_model()->add_to_entity_map($this);
303 303
 			}
304 304
 			//let's unset any cache for this field_name from the $_cached_properties property.
305
-			$this->_clear_cached_property( $field_name );
306
-		}else{
307
-			throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name  ) );
305
+			$this->_clear_cached_property($field_name);
306
+		} else {
307
+			throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name));
308 308
 		}
309 309
 
310 310
 	}
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 	 * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs.
322 322
 	 * @throws \EE_Error
323 323
 	 */
324
-	public function set_field_or_extra_meta( $field_name, $field_value ) {
325
-		if ( $this->get_model()->has_field( $field_name ) ) {
326
-			$this->set( $field_name, $field_value );
324
+	public function set_field_or_extra_meta($field_name, $field_value) {
325
+		if ($this->get_model()->has_field($field_name)) {
326
+			$this->set($field_name, $field_value);
327 327
 			return true;
328 328
 		} else {
329 329
 			//ensure this object is saved first so that extra meta can be properly related.
330 330
 			$this->save();
331
-			return $this->update_extra_meta( $field_name, $field_value );
331
+			return $this->update_extra_meta($field_name, $field_value);
332 332
 		}
333 333
 	}
334 334
 
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 	 * @return mixed|null  value for the field if found.  null if not found.
350 350
 	 * @throws \EE_Error
351 351
 	 */
352
-	public function get_field_or_extra_meta( $field_name ) {
353
-		if ( $this->get_model()->has_field( $field_name ) ) {
354
-			$column_value = $this->get( $field_name );
352
+	public function get_field_or_extra_meta($field_name) {
353
+		if ($this->get_model()->has_field($field_name)) {
354
+			$column_value = $this->get($field_name);
355 355
 		} else {
356 356
 			//This isn't a column in the main table, let's see if it is in the extra meta.
357
-			$column_value = $this->get_extra_meta( $field_name, true, null );
357
+			$column_value = $this->get_extra_meta($field_name, true, null);
358 358
 		}
359 359
 		return $column_value;
360 360
 	}
@@ -370,18 +370,18 @@  discard block
 block discarded – undo
370 370
 	 * @return void
371 371
 	 * @throws \EE_Error
372 372
 	 */
373
-	public function set_timezone( $timezone = '' ) {
374
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
373
+	public function set_timezone($timezone = '') {
374
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
375 375
 		//make sure we clear all cached properties because they won't be relevant now
376 376
 		$this->_clear_cached_properties();
377 377
 
378 378
 		//make sure we update field settings and the date for all EE_Datetime_Fields
379
-		$model_fields = $this->get_model()->field_settings( false );
380
-		foreach ( $model_fields as $field_name => $field_obj ) {
381
-			if ( $field_obj instanceof EE_Datetime_Field ) {
382
-				$field_obj->set_timezone( $this->_timezone );
383
-				if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) {
384
-					$this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) );
379
+		$model_fields = $this->get_model()->field_settings(false);
380
+		foreach ($model_fields as $field_name => $field_obj) {
381
+			if ($field_obj instanceof EE_Datetime_Field) {
382
+				$field_obj->set_timezone($this->_timezone);
383
+				if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) {
384
+					$this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone));
385 385
 				}
386 386
 			}
387 387
 		}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 *
411 411
 	 * @param string $format   should be a format recognizable by PHP date() functions.
412 412
 	 */
413
-	public function set_date_format( $format ) {
413
+	public function set_date_format($format) {
414 414
 		$this->_dt_frmt = $format;
415 415
 		//clear cached_properties because they won't be relevant now.
416 416
 		$this->_clear_cached_properties();
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 * @since 4.6
427 427
 	 * @param string $format should be a format recognizable by PHP date() functions.
428 428
 	 */
429
-	public function set_time_format( $format ) {
429
+	public function set_time_format($format) {
430 430
 		$this->_tm_frmt = $format;
431 431
 		//clear cached_properties because they won't be relevant now.
432 432
 		$this->_clear_cached_properties();
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @return mixed string|array
445 445
 	 */
446
-	public function get_format( $full = true ) {
447
-		return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt );
446
+	public function get_format($full = true) {
447
+		return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt);
448 448
 	}
449 449
 
450 450
 
@@ -462,17 +462,17 @@  discard block
 block discarded – undo
462 462
 	 * @throws EE_Error
463 463
 	 * @return mixed    index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array)
464 464
 	 */
465
-	public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){
465
+	public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) {
466 466
 		// its entirely possible that there IS no related object yet in which case there is nothing to cache.
467
-		if ( ! $object_to_cache instanceof EE_Base_Class ) {
467
+		if ( ! $object_to_cache instanceof EE_Base_Class) {
468 468
 			return FALSE;
469 469
 		}
470 470
 		// also get "how" the object is related, or throw an error
471
-		if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) {
472
-			throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this )));
471
+		if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) {
472
+			throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this)));
473 473
 		}
474 474
 		// how many things are related ?
475
-		if( $relationship_to_model instanceof EE_Belongs_To_Relation ){
475
+		if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
476 476
 			// if it's a "belongs to" relationship, then there's only one related model object  eg, if this is a registration, there's only 1 attendee for it
477 477
 			// so for these model objects just set it to be cached
478 478
 			$this->_model_relations[$relationName] = $object_to_cache;
@@ -480,26 +480,26 @@  discard block
 block discarded – undo
480 480
 		} else {
481 481
 			// otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type.
482 482
 			// eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array
483
-			if( ! is_array( $this->_model_relations[$relationName] )) {
483
+			if ( ! is_array($this->_model_relations[$relationName])) {
484 484
 				// if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array
485
-				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array();
485
+				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array();
486 486
 			}
487 487
 			// first check for a cache_id which is normally empty
488
-			if ( ! empty( $cache_id )) {
488
+			if ( ! empty($cache_id)) {
489 489
 				// if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on
490
-				$this->_model_relations[$relationName][ $cache_id ] = $object_to_cache;
490
+				$this->_model_relations[$relationName][$cache_id] = $object_to_cache;
491 491
 				$return = $cache_id;
492
-			} elseif ( $object_to_cache->ID() ) {
492
+			} elseif ($object_to_cache->ID()) {
493 493
 				// OR the cached object originally came from the db, so let's just use it's PK for an ID
494
-				$this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache;
494
+				$this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache;
495 495
 				$return = $object_to_cache->ID();
496 496
 			} else {
497 497
 				// OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID
498 498
 				$this->_model_relations[$relationName][] = $object_to_cache;
499 499
 				  // move the internal pointer to the end of the array
500
-				end( $this->_model_relations[$relationName] );
500
+				end($this->_model_relations[$relationName]);
501 501
 				// and grab the key so that we can return it
502
-				$return = key( $this->_model_relations[$relationName] );
502
+				$return = key($this->_model_relations[$relationName]);
503 503
 			}
504 504
 
505 505
 		}
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
 	 * @return void
519 519
 	 * @throws \EE_Error
520 520
 	 */
521
-	protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) {
521
+	protected function _set_cached_property($fieldname, $value, $cache_type = NULL) {
522 522
 		//first make sure this property exists
523 523
 		$this->get_model()->field_settings_for($fieldname);
524 524
 
525
-		$cache_type = empty( $cache_type ) ? 'standard' : $cache_type;
525
+		$cache_type = empty($cache_type) ? 'standard' : $cache_type;
526 526
 		$this->_cached_properties[$fieldname][$cache_type] = $value;
527 527
 	}
528 528
 
@@ -543,36 +543,36 @@  discard block
 block discarded – undo
543 543
 	 * @return mixed                   whatever the value for the property is we're retrieving
544 544
 	 * @throws \EE_Error
545 545
 	 */
546
-	protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) {
546
+	protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) {
547 547
 		//verify the field exists
548 548
 		$this->get_model()->field_settings_for($fieldname);
549 549
 
550 550
 		$cache_type = $pretty ? 'pretty' : 'standard';
551
-		$cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : '';
551
+		$cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : '';
552 552
 
553
-		if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) {
553
+		if (isset($this->_cached_properties[$fieldname][$cache_type])) {
554 554
 			return $this->_cached_properties[$fieldname][$cache_type];
555 555
 		}
556 556
 
557 557
 		$field_obj = $this->get_model()->field_settings_for($fieldname);
558
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
558
+		if ($field_obj instanceof EE_Model_Field_Base) {
559 559
 			/**
560 560
 			 * maybe this is EE_Datetime_Field.  If so we need to make sure timezone and
561 561
 			 * formats are correct.
562 562
 			 */
563
-			if ( $field_obj instanceof EE_Datetime_Field ) {
564
-				$field_obj->set_timezone( $this->_timezone );
565
-				$field_obj->set_date_format( $this->_dt_frmt, $pretty );
566
-				$field_obj->set_time_format( $this->_tm_frmt, $pretty );
563
+			if ($field_obj instanceof EE_Datetime_Field) {
564
+				$field_obj->set_timezone($this->_timezone);
565
+				$field_obj->set_date_format($this->_dt_frmt, $pretty);
566
+				$field_obj->set_time_format($this->_tm_frmt, $pretty);
567 567
 			}
568 568
 
569
-			if( ! isset($this->_fields[$fieldname])){
569
+			if ( ! isset($this->_fields[$fieldname])) {
570 570
 				$this->_fields[$fieldname] = NULL;
571 571
 			}
572 572
 			$value = $pretty
573 573
 				? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref)
574
-				: $field_obj->prepare_for_get($this->_fields[$fieldname] );
575
-			$this->_set_cached_property( $fieldname, $value, $cache_type );
574
+				: $field_obj->prepare_for_get($this->_fields[$fieldname]);
575
+			$this->_set_cached_property($fieldname, $value, $cache_type);
576 576
 			return $value;
577 577
 		}
578 578
 		return null;
@@ -598,9 +598,9 @@  discard block
 block discarded – undo
598 598
 	 * @param  string $property_name the property to remove if it exists (from the _cached_properties array)
599 599
 	 * @return void
600 600
 	 */
601
-	protected function _clear_cached_property( $property_name ) {
602
-		if ( isset( $this->_cached_properties[ $property_name ] ) ) {
603
-			unset( $this->_cached_properties[ $property_name ] );
601
+	protected function _clear_cached_property($property_name) {
602
+		if (isset($this->_cached_properties[$property_name])) {
603
+			unset($this->_cached_properties[$property_name]);
604 604
 		}
605 605
 	}
606 606
 
@@ -614,12 +614,12 @@  discard block
 block discarded – undo
614 614
 	 * @return EE_Base_Class
615 615
 	 * @throws \EE_Error
616 616
 	 */
617
-	protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){
617
+	protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) {
618 618
 		$other_model_instance = self::_get_model_instance_with_name(
619
-			self::_get_model_classname( $model_name ),
619
+			self::_get_model_classname($model_name),
620 620
 			$this->_timezone
621 621
 		);
622
-		return $other_model_instance->ensure_is_obj( $object_or_id );
622
+		return $other_model_instance->ensure_is_obj($object_or_id);
623 623
 	}
624 624
 
625 625
 
@@ -636,32 +636,32 @@  discard block
 block discarded – undo
636 636
 	 * @throws EE_Error
637 637
 	 * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all
638 638
 	 */
639
-	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){
639
+	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) {
640 640
 		$relationship_to_model = $this->get_model()->related_settings_for($relationName);
641 641
 		$index_in_cache = '';
642
-		if( ! $relationship_to_model){
642
+		if ( ! $relationship_to_model) {
643 643
 			throw new EE_Error(
644 644
 				sprintf(
645
-					__( "There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso' ),
645
+					__("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'),
646 646
 					$relationName,
647
-					get_class( $this )
647
+					get_class($this)
648 648
 				)
649 649
 			);
650 650
 		}
651
-		if($clear_all){
651
+		if ($clear_all) {
652 652
 			$obj_removed = true;
653 653
 			$this->_model_relations[$relationName]  = null;
654
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
654
+		}elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) {
655 655
 			$obj_removed = $this->_model_relations[$relationName];
656 656
 			$this->_model_relations[$relationName]  = null;
657
-		}else{
658
-			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
657
+		} else {
658
+			if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) {
659 659
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
660
-				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
660
+				if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) {
661 661
 					$index_found_at = NULL;
662 662
 					//find this object in the array even though it has a different key
663
-					foreach($this->_model_relations[$relationName] as $index=>$obj){
664
-						if(
663
+					foreach ($this->_model_relations[$relationName] as $index=>$obj) {
664
+						if (
665 665
 							$obj instanceof EE_Base_Class
666 666
 							&& (
667 667
 								$obj == $object_to_remove_or_index_into_array
@@ -672,34 +672,34 @@  discard block
 block discarded – undo
672 672
 							break;
673 673
 						}
674 674
 					}
675
-					if($index_found_at){
675
+					if ($index_found_at) {
676 676
 						$index_in_cache = $index_found_at;
677
-					}else{
677
+					} else {
678 678
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
679 679
 						//if it wasn't in it to begin with. So we're done
680 680
 						return $object_to_remove_or_index_into_array;
681 681
 					}
682 682
 				}
683
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
683
+			}elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) {
684 684
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
685
-				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
686
-					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
685
+				foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) {
686
+					if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) {
687 687
 						$index_in_cache = $index;
688 688
 					}
689 689
 				}
690
-			}else{
690
+			} else {
691 691
 				$index_in_cache = $object_to_remove_or_index_into_array;
692 692
 			}
693 693
 			//supposedly we've found it. But it could just be that the client code
694 694
 			//provided a bad index/object
695 695
 			if (
696 696
 				isset(
697
-					$this->_model_relations[ $relationName ],
698
-					$this->_model_relations[ $relationName ][ $index_in_cache ]
697
+					$this->_model_relations[$relationName],
698
+					$this->_model_relations[$relationName][$index_in_cache]
699 699
 				)
700 700
 			) {
701
-				$obj_removed = $this->_model_relations[ $relationName ][ $index_in_cache ];
702
-				unset( $this->_model_relations[ $relationName ][ $index_in_cache ] );
701
+				$obj_removed = $this->_model_relations[$relationName][$index_in_cache];
702
+				unset($this->_model_relations[$relationName][$index_in_cache]);
703 703
 			} else {
704 704
 				//that thing was never cached anyways.
705 705
 				$obj_removed = null;
@@ -720,24 +720,24 @@  discard block
 block discarded – undo
720 720
 	 * @return boolean TRUE on success, FALSE on fail
721 721
 	 * @throws \EE_Error
722 722
 	 */
723
-	public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
723
+	public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
724 724
 		// verify that incoming object is of the correct type
725
-		$obj_class = 'EE_' . $relationName;
726
-		if ( $newly_saved_object instanceof $obj_class ) {
725
+		$obj_class = 'EE_'.$relationName;
726
+		if ($newly_saved_object instanceof $obj_class) {
727 727
 			/* @type EE_Base_Class $newly_saved_object*/
728 728
 			// now get the type of relation
729
-			$relationship_to_model = $this->get_model()->related_settings_for( $relationName );
729
+			$relationship_to_model = $this->get_model()->related_settings_for($relationName);
730 730
 			// if this is a 1:1 relationship
731
-			if( $relationship_to_model instanceof EE_Belongs_To_Relation ) {
731
+			if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
732 732
 				// then just replace the cached object with the newly saved object
733 733
 				$this->_model_relations[$relationName] = $newly_saved_object;
734 734
 				return TRUE;
735 735
 			// or if it's some kind of sordid feral polyamorous relationship...
736
-			} elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) {
736
+			} elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) {
737 737
 				// then remove the current cached item
738
-				unset( $this->_model_relations[$relationName][ $current_cache_id ] );
738
+				unset($this->_model_relations[$relationName][$current_cache_id]);
739 739
 				// and cache the newly saved object using it's new ID
740
-				$this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object;
740
+				$this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object;
741 741
 				return TRUE;
742 742
 			}
743 743
 		}
@@ -753,11 +753,11 @@  discard block
 block discarded – undo
753 753
 	 * @param string $relationName
754 754
 	 * @return EE_Base_Class
755 755
 	 */
756
-	public function get_one_from_cache($relationName){
757
-		$cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null;
758
-		if(is_array($cached_array_or_object)){
756
+	public function get_one_from_cache($relationName) {
757
+		$cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null;
758
+		if (is_array($cached_array_or_object)) {
759 759
 			return array_shift($cached_array_or_object);
760
-		}else{
760
+		} else {
761 761
 			return $cached_array_or_object;
762 762
 		}
763 763
 	}
@@ -772,23 +772,23 @@  discard block
 block discarded – undo
772 772
 	 * @throws \EE_Error
773 773
 	 * @return EE_Base_Class[] NOT necessarily indexed by primary keys
774 774
 	 */
775
-	public function get_all_from_cache($relationName){
776
-		$objects = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array();
775
+	public function get_all_from_cache($relationName) {
776
+		$objects = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array();
777 777
 		// if the result is not an array, but exists, make it an array
778
-		$objects = is_array( $objects ) ? $objects : array( $objects );
778
+		$objects = is_array($objects) ? $objects : array($objects);
779 779
 		//bugfix for https://events.codebasehq.com/projects/event-espresso/tickets/7143
780 780
 		//basically, if this model object was stored in the session, and these cached model objects
781 781
 		//already have IDs, let's make sure they're in their model's entity mapper
782 782
 		//otherwise we will have duplicates next time we call
783 783
 		// EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() );
784
-		$model = EE_Registry::instance()->load_model( $relationName );
785
-		foreach( $objects as $model_object ){
786
-			if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){
784
+		$model = EE_Registry::instance()->load_model($relationName);
785
+		foreach ($objects as $model_object) {
786
+			if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) {
787 787
 				//ensure its in the map if it has an ID; otherwise it will be added to the map when its saved
788
-				if( $model_object->ID() ){
789
-					$model->add_to_entity_map( $model_object );
788
+				if ($model_object->ID()) {
789
+					$model->add_to_entity_map($model_object);
790 790
 				}
791
-			}else{
791
+			} else {
792 792
 				throw new EE_Error(
793 793
 					sprintf(
794 794
 						__(
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 							'event_espresso'
797 797
 						),
798 798
 						$relationName,
799
-						gettype( $model_object )
799
+						gettype($model_object)
800 800
 					)
801 801
 				);
802 802
 			}
@@ -818,15 +818,15 @@  discard block
 block discarded – undo
818 818
 	 * @return array|EE_Base_Class[]
819 819
 	 * @throws \EE_Error
820 820
 	 */
821
-	public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
822
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
821
+	public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
822
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
823 823
 			? $this->get_model()->get_primary_key_field()->get_name()
824 824
 			: $field_to_order_by;
825
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
826
-		if ( empty( $field ) || empty( $current_value ) ) {
825
+		$current_value = ! empty($field) ? $this->get($field) : null;
826
+		if (empty($field) || empty($current_value)) {
827 827
 			return array();
828 828
 		}
829
-		return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select );
829
+		return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
830 830
 	}
831 831
 
832 832
 
@@ -843,15 +843,15 @@  discard block
 block discarded – undo
843 843
 	 * @return array|EE_Base_Class[]
844 844
 	 * @throws \EE_Error
845 845
 	 */
846
-	public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
847
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
846
+	public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
847
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
848 848
 			? $this->get_model()->get_primary_key_field()->get_name()
849 849
 			: $field_to_order_by;
850
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
851
-		if ( empty( $field ) || empty( $current_value ) ) {
850
+		$current_value = ! empty($field) ? $this->get($field) : null;
851
+		if (empty($field) || empty($current_value)) {
852 852
 			return array();
853 853
 		}
854
-		return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select );
854
+		return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
855 855
 	}
856 856
 
857 857
 
@@ -867,15 +867,15 @@  discard block
 block discarded – undo
867 867
 	 * @return array|EE_Base_Class
868 868
 	 * @throws \EE_Error
869 869
 	 */
870
-	public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
871
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
870
+	public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
871
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
872 872
 			? $this->get_model()->get_primary_key_field()->get_name()
873 873
 			: $field_to_order_by;
874
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
875
-		if ( empty( $field ) || empty( $current_value ) ) {
874
+		$current_value = ! empty($field) ? $this->get($field) : null;
875
+		if (empty($field) || empty($current_value)) {
876 876
 			return array();
877 877
 		}
878
-		return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select );
878
+		return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select);
879 879
 	}
880 880
 
881 881
 
@@ -891,15 +891,15 @@  discard block
 block discarded – undo
891 891
 	 * @return array|EE_Base_Class
892 892
 	 * @throws \EE_Error
893 893
 	 */
894
-	public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
895
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
894
+	public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
895
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
896 896
 			? $this->get_model()->get_primary_key_field()->get_name()
897 897
 			: $field_to_order_by;
898
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
899
-		if ( empty( $field ) || empty( $current_value ) ) {
898
+		$current_value = ! empty($field) ? $this->get($field) : null;
899
+		if (empty($field) || empty($current_value)) {
900 900
 			return array();
901 901
 		}
902
-		return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select );
902
+		return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select);
903 903
 	}
904 904
 
905 905
 
@@ -912,25 +912,25 @@  discard block
 block discarded – undo
912 912
 	 * @param mixed  $field_value_from_db
913 913
 	 * @throws \EE_Error
914 914
 	 */
915
-	public function set_from_db($field_name,$field_value_from_db){
915
+	public function set_from_db($field_name, $field_value_from_db) {
916 916
 		$field_obj = $this->get_model()->field_settings_for($field_name);
917
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
917
+		if ($field_obj instanceof EE_Model_Field_Base) {
918 918
 			//you would think the DB has no NULLs for non-null label fields right? wrong!
919 919
 			//eg, a CPT model object could have an entry in the posts table, but no
920 920
 			//entry in the meta table. Meaning that all its columns in the meta table
921 921
 			//are null! yikes! so when we find one like that, use defaults for its meta columns
922
-			if($field_value_from_db === NULL ){
923
-				if( $field_obj->is_nullable()){
922
+			if ($field_value_from_db === NULL) {
923
+				if ($field_obj->is_nullable()) {
924 924
 					//if the field allows nulls, then let it be null
925 925
 					$field_value = NULL;
926
-				}else{
926
+				} else {
927 927
 					$field_value = $field_obj->get_default_value();
928 928
 				}
929
-			}else{
930
-				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
929
+			} else {
930
+				$field_value = $field_obj->prepare_for_set_from_db($field_value_from_db);
931 931
 			}
932 932
 			$this->_fields[$field_name] = $field_value;
933
-			$this->_clear_cached_property( $field_name );
933
+			$this->_clear_cached_property($field_name);
934 934
 		}
935 935
 	}
936 936
 
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 	 * @return mixed
947 947
 	 * @throws \EE_Error
948 948
 	 */
949
-	public function get($field_name, $extra_cache_ref = NULL ){
950
-		return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref );
949
+	public function get($field_name, $extra_cache_ref = NULL) {
950
+		return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref);
951 951
 	}
952 952
 
953 953
 
@@ -980,10 +980,10 @@  discard block
 block discarded – undo
980 980
 	 *                                         just null is returned (because that indicates that likely
981 981
 	 *                                         this field is nullable).
982 982
 	 */
983
-	public function get_DateTime_object( $field_name ) {
984
-		$field_settings = $this->get_model()->field_settings_for( $field_name );
983
+	public function get_DateTime_object($field_name) {
984
+		$field_settings = $this->get_model()->field_settings_for($field_name);
985 985
 
986
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
986
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
987 987
 			EE_Error::add_error(
988 988
 				sprintf(
989 989
 					__(
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 	 * @return void
1016 1016
 	 * @throws \EE_Error
1017 1017
 	 */
1018
-	public function e($field_name, $extra_cache_ref = NULL){
1018
+	public function e($field_name, $extra_cache_ref = NULL) {
1019 1019
 		echo $this->get_pretty($field_name, $extra_cache_ref);
1020 1020
 	}
1021 1021
 
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 	 * @return void
1030 1030
 	 * @throws \EE_Error
1031 1031
 	 */
1032
-	public function f($field_name){
1033
-		$this->e($field_name,'form_input');
1032
+	public function f($field_name) {
1033
+		$this->e($field_name, 'form_input');
1034 1034
 	}
1035 1035
 
1036 1036
 
@@ -1043,8 +1043,8 @@  discard block
 block discarded – undo
1043 1043
 	 * @return mixed
1044 1044
 	 * @throws \EE_Error
1045 1045
 	 */
1046
-	public function get_pretty($field_name, $extra_cache_ref = NULL){
1047
-		return  $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref );
1046
+	public function get_pretty($field_name, $extra_cache_ref = NULL) {
1047
+		return  $this->_get_cached_property($field_name, TRUE, $extra_cache_ref);
1048 1048
 	}
1049 1049
 
1050 1050
 
@@ -1062,36 +1062,36 @@  discard block
 block discarded – undo
1062 1062
 	 * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
1063 1063
 	 * @throws \EE_Error
1064 1064
 	 */
1065
-	protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) {
1065
+	protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) {
1066 1066
 
1067
-		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt :  $dt_frmt;
1067
+		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt;
1068 1068
 		$in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt;
1069 1069
 
1070 1070
 		//validate field for datetime and returns field settings if valid.
1071
-		$field = $this->_get_dtt_field_settings( $field_name );
1071
+		$field = $this->_get_dtt_field_settings($field_name);
1072 1072
 
1073 1073
 		//clear cached property if either formats are not null.
1074
-		if( $dt_frmt !== null || $tm_frmt !== null ) {
1075
-			$this->_clear_cached_property( $field_name );
1074
+		if ($dt_frmt !== null || $tm_frmt !== null) {
1075
+			$this->_clear_cached_property($field_name);
1076 1076
 			//reset format properties because they are used in get()
1077 1077
 			$this->_dt_frmt = $in_dt_frmt;
1078 1078
 			$this->_tm_frmt = $in_tm_frmt;
1079 1079
 		}
1080
-		if ( $echo ) {
1081
-			$field->set_pretty_date_format( $in_dt_frmt );
1080
+		if ($echo) {
1081
+			$field->set_pretty_date_format($in_dt_frmt);
1082 1082
 		} else {
1083
-			$field->set_date_format( $in_dt_frmt );
1083
+			$field->set_date_format($in_dt_frmt);
1084 1084
 		}
1085
-		if ( $echo ) {
1086
-			$field->set_pretty_time_format( $in_tm_frmt );
1085
+		if ($echo) {
1086
+			$field->set_pretty_time_format($in_tm_frmt);
1087 1087
 		} else {
1088
-			$field->set_time_format( $in_tm_frmt );
1088
+			$field->set_time_format($in_tm_frmt);
1089 1089
 		}
1090 1090
 		//set timezone in field object
1091
-		$field->set_timezone( $this->_timezone );
1091
+		$field->set_timezone($this->_timezone);
1092 1092
 
1093 1093
 		//set the output returned
1094
-		switch ( $date_or_time ) {
1094
+		switch ($date_or_time) {
1095 1095
 
1096 1096
 			case 'D' :
1097 1097
 				$field->set_date_time_output('date');
@@ -1106,11 +1106,11 @@  discard block
 block discarded – undo
1106 1106
 		}
1107 1107
 
1108 1108
 
1109
-		if ( $echo ) {
1110
-			$this->e( $field_name, $date_or_time );
1109
+		if ($echo) {
1110
+			$this->e($field_name, $date_or_time);
1111 1111
 			return '';
1112 1112
 		 }
1113
-		return $this->get( $field_name, $date_or_time );
1113
+		return $this->get($field_name, $date_or_time);
1114 1114
 	}
1115 1115
 
1116 1116
 
@@ -1123,8 +1123,8 @@  discard block
 block discarded – undo
1123 1123
 	 * @return string            datetime value formatted
1124 1124
 	 * @throws \EE_Error
1125 1125
 	 */
1126
-	public function get_date( $field_name, $format = NULL ) {
1127
-		return $this->_get_datetime( $field_name, $format, NULL, 'D' );
1126
+	public function get_date($field_name, $format = NULL) {
1127
+		return $this->_get_datetime($field_name, $format, NULL, 'D');
1128 1128
 	}
1129 1129
 
1130 1130
 
@@ -1134,8 +1134,8 @@  discard block
 block discarded – undo
1134 1134
 	 * @param null $format
1135 1135
 	 * @throws \EE_Error
1136 1136
 	 */
1137
-	public function e_date( $field_name, $format = NULL ) {
1138
-		$this->_get_datetime( $field_name, $format, NULL, 'D', TRUE );
1137
+	public function e_date($field_name, $format = NULL) {
1138
+		$this->_get_datetime($field_name, $format, NULL, 'D', TRUE);
1139 1139
 	}
1140 1140
 
1141 1141
 
@@ -1148,8 +1148,8 @@  discard block
 block discarded – undo
1148 1148
 	 * @return string             datetime value formatted
1149 1149
 	 * @throws \EE_Error
1150 1150
 	 */
1151
-	public function get_time( $field_name, $format = NULL ) {
1152
-		return $this->_get_datetime( $field_name, NULL, $format, 'T' );
1151
+	public function get_time($field_name, $format = NULL) {
1152
+		return $this->_get_datetime($field_name, NULL, $format, 'T');
1153 1153
 	}
1154 1154
 
1155 1155
 
@@ -1159,8 +1159,8 @@  discard block
 block discarded – undo
1159 1159
 	 * @param null $format
1160 1160
 	 * @throws \EE_Error
1161 1161
 	 */
1162
-	public function e_time( $field_name, $format = NULL ) {
1163
-		$this->_get_datetime( $field_name, NULL, $format, 'T', TRUE );
1162
+	public function e_time($field_name, $format = NULL) {
1163
+		$this->_get_datetime($field_name, NULL, $format, 'T', TRUE);
1164 1164
 	}
1165 1165
 
1166 1166
 
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 	 * @return string             datetime value formatted
1175 1175
 	 * @throws \EE_Error
1176 1176
 	 */
1177
-	public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1178
-		return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt );
1177
+	public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1178
+		return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt);
1179 1179
 	}
1180 1180
 
1181 1181
 
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
 	 * @param null $tm_frmt
1187 1187
 	 * @throws \EE_Error
1188 1188
 	 */
1189
-	public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1190
-		$this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1189
+	public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1190
+		$this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1191 1191
 	}
1192 1192
 
1193 1193
 
@@ -1201,11 +1201,11 @@  discard block
 block discarded – undo
1201 1201
 	 * @throws \EE_Error
1202 1202
 	 *                           field name.
1203 1203
 	 */
1204
-	public function get_i18n_datetime( $field_name, $format = NULL ) {
1205
-		$format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format;
1204
+	public function get_i18n_datetime($field_name, $format = NULL) {
1205
+		$format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format;
1206 1206
 		return date_i18n(
1207 1207
 			$format,
1208
-			EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone )
1208
+			EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone)
1209 1209
 		);
1210 1210
 	}
1211 1211
 
@@ -1218,14 +1218,14 @@  discard block
 block discarded – undo
1218 1218
 	 * @throws EE_Error
1219 1219
 	 * @return EE_Datetime_Field
1220 1220
 	 */
1221
-	protected function _get_dtt_field_settings( $field_name ) {
1221
+	protected function _get_dtt_field_settings($field_name) {
1222 1222
 		$field = $this->get_model()->field_settings_for($field_name);
1223 1223
 
1224 1224
 		//check if field is dtt
1225
-		if ( $field instanceof EE_Datetime_Field ) {
1225
+		if ($field instanceof EE_Datetime_Field) {
1226 1226
 			return $field;
1227 1227
 		} else {
1228
-			throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) );
1228
+			throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this))));
1229 1229
 		}
1230 1230
 	}
1231 1231
 
@@ -1246,8 +1246,8 @@  discard block
 block discarded – undo
1246 1246
 	 * @param string          $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field)
1247 1247
 	 * @throws \EE_Error
1248 1248
 	 */
1249
-	protected function _set_time_for( $time, $fieldname ) {
1250
-		$this->_set_date_time( 'T', $time, $fieldname );
1249
+	protected function _set_time_for($time, $fieldname) {
1250
+		$this->_set_date_time('T', $time, $fieldname);
1251 1251
 	}
1252 1252
 
1253 1253
 
@@ -1260,8 +1260,8 @@  discard block
 block discarded – undo
1260 1260
 	 * @param string          $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field)
1261 1261
 	 * @throws \EE_Error
1262 1262
 	 */
1263
-	protected function _set_date_for( $date, $fieldname ) {
1264
-		$this->_set_date_time( 'D', $date, $fieldname );
1263
+	protected function _set_date_for($date, $fieldname) {
1264
+		$this->_set_date_time('D', $date, $fieldname);
1265 1265
 	}
1266 1266
 
1267 1267
 
@@ -1275,26 +1275,26 @@  discard block
 block discarded – undo
1275 1275
 	 * @param string          $fieldname      the name of the field the date OR time is being set on (must match a EE_Datetime_Field property)
1276 1276
 	 * @throws \EE_Error
1277 1277
 	 */
1278
-	protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) {
1279
-		$field = $this->_get_dtt_field_settings( $fieldname );
1280
-		$field->set_timezone( $this->_timezone );
1281
-		$field->set_date_format( $this->_dt_frmt );
1282
-		$field->set_time_format( $this->_tm_frmt );
1283
-		switch ( $what ) {
1278
+	protected function _set_date_time($what = 'T', $datetime_value, $fieldname) {
1279
+		$field = $this->_get_dtt_field_settings($fieldname);
1280
+		$field->set_timezone($this->_timezone);
1281
+		$field->set_date_format($this->_dt_frmt);
1282
+		$field->set_time_format($this->_tm_frmt);
1283
+		switch ($what) {
1284 1284
 			case 'T' :
1285
-				$this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_time(
1285
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_time(
1286 1286
 					$datetime_value,
1287
-					$this->_fields[ $fieldname ]
1287
+					$this->_fields[$fieldname]
1288 1288
 				);
1289 1289
 				break;
1290 1290
 			case 'D' :
1291
-				$this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_date(
1291
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_date(
1292 1292
 					$datetime_value,
1293
-					$this->_fields[ $fieldname ]
1293
+					$this->_fields[$fieldname]
1294 1294
 				);
1295 1295
 				break;
1296 1296
 			case 'B' :
1297
-				$this->_fields[ $fieldname ] = $field->prepare_for_set( $datetime_value );
1297
+				$this->_fields[$fieldname] = $field->prepare_for_set($datetime_value);
1298 1298
 				break;
1299 1299
 		}
1300 1300
 		$this->_clear_cached_property($fieldname);
@@ -1316,17 +1316,17 @@  discard block
 block discarded – undo
1316 1316
 	 * @throws EE_Error
1317 1317
 	 * @return string timestamp
1318 1318
 	 */
1319
-	public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) {
1319
+	public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') {
1320 1320
 		$timezone = EEH_DTT_Helper::get_timezone();
1321
-		if ( $timezone === $this->_timezone ) {
1321
+		if ($timezone === $this->_timezone) {
1322 1322
 			return '';
1323 1323
 		}
1324 1324
 		$original_timezone = $this->_timezone;
1325
-		$this->set_timezone( $timezone );
1325
+		$this->set_timezone($timezone);
1326 1326
 
1327 1327
 		$fn = (array) $field_name;
1328
-		$args = array_merge( $fn, (array) $args );
1329
-		if ( ! method_exists( $this, $callback ) ) {
1328
+		$args = array_merge($fn, (array) $args);
1329
+		if ( ! method_exists($this, $callback)) {
1330 1330
 			throw new EE_Error(
1331 1331
 				sprintf(
1332 1332
 					__(
@@ -1338,9 +1338,9 @@  discard block
 block discarded – undo
1338 1338
 			);
1339 1339
 		}
1340 1340
 		$args = (array) $args;
1341
-		$return =  $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append;
1341
+		$return = $prepend.call_user_func_array(array($this, $callback), $args).$append;
1342 1342
 
1343
-		$this->set_timezone( $original_timezone );
1343
+		$this->set_timezone($original_timezone);
1344 1344
 		return $return;
1345 1345
 	}
1346 1346
 
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
 	 * @return boolean | int
1355 1355
 	 * @throws \EE_Error
1356 1356
 	 */
1357
-	public function delete(){
1357
+	public function delete() {
1358 1358
 		/**
1359 1359
 		 * Called just before the `EE_Base_Class::_delete` method call.
1360 1360
 		 * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 		 *
1364 1364
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1365 1365
 		 */
1366
-		do_action( 'AHEE__EE_Base_Class__delete__before', $this );
1366
+		do_action('AHEE__EE_Base_Class__delete__before', $this);
1367 1367
 		$result = $this->_delete();
1368 1368
 		/**
1369 1369
 		 * Called just after the `EE_Base_Class::_delete` method call.
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1374 1374
 		 * @param boolean $result
1375 1375
 		 */
1376
-		do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result );
1376
+		do_action('AHEE__EE_Base_Class__delete__end', $this, $result);
1377 1377
 		return $result;
1378 1378
 	}
1379 1379
 
@@ -1399,22 +1399,22 @@  discard block
 block discarded – undo
1399 1399
 	 * @return bool | int
1400 1400
 	 * @throws \EE_Error
1401 1401
 	 */
1402
-	public function delete_permanently(){
1402
+	public function delete_permanently() {
1403 1403
 		/**
1404 1404
 		 * Called just before HARD deleting a model object
1405 1405
 		 *
1406 1406
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1407 1407
 		 */
1408
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this );
1409
-		$model=$this->get_model();
1410
-		$result=$model->delete_permanently_by_ID($this->ID());
1408
+		do_action('AHEE__EE_Base_Class__delete_permanently__before', $this);
1409
+		$model = $this->get_model();
1410
+		$result = $model->delete_permanently_by_ID($this->ID());
1411 1411
 		$this->refresh_cache_of_related_objects();
1412 1412
 		/**
1413 1413
 		 * Called just after HARD deleting a model object
1414 1414
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1415 1415
 		 * @param boolean $result
1416 1416
 		 */
1417
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result );
1417
+		do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result);
1418 1418
 		return $result;
1419 1419
 	}
1420 1420
 
@@ -1427,18 +1427,18 @@  discard block
 block discarded – undo
1427 1427
 	 * @throws \EE_Error
1428 1428
 	 */
1429 1429
         public function refresh_cache_of_related_objects() {
1430
-            foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1431
-                if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1432
-                    $related_objects = $this->_model_relations[ $relation_name ];
1433
-                    if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1430
+            foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1431
+                if ( ! empty($this->_model_relations[$relation_name])) {
1432
+                    $related_objects = $this->_model_relations[$relation_name];
1433
+                    if ($relation_obj instanceof EE_Belongs_To_Relation) {
1434 1434
                         //this relation only stores a single model object, not an array
1435 1435
                         //but let's make it consistent
1436
-                        $related_objects = array( $related_objects );
1436
+                        $related_objects = array($related_objects);
1437 1437
                     }
1438
-                    foreach( $related_objects as $related_object ) {
1438
+                    foreach ($related_objects as $related_object) {
1439 1439
                         //only refresh their cache if they're in memory
1440
-                        if( $related_object instanceof EE_Base_Class ) {
1441
-							$related_object->clear_cache( $this->get_model()->get_this_model_name(), $this );
1440
+                        if ($related_object instanceof EE_Base_Class) {
1441
+							$related_object->clear_cache($this->get_model()->get_this_model_name(), $this);
1442 1442
                         }
1443 1443
                     }
1444 1444
                 }
@@ -1458,17 +1458,17 @@  discard block
 block discarded – undo
1458 1458
 	 * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object
1459 1459
 	 * isn't allowed to persist (as determined by EE_Base_Class::allow_persist())
1460 1460
 	 */
1461
-	public function save($set_cols_n_values=array()) {
1461
+	public function save($set_cols_n_values = array()) {
1462 1462
 		/**
1463 1463
 		 * Filters the fields we're about to save on the model object
1464 1464
 		 *
1465 1465
 		 * @param array $set_cols_n_values
1466 1466
 		 * @param EE_Base_Class $model_object
1467 1467
 		 */
1468
-		$set_cols_n_values = (array)apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this  );
1468
+		$set_cols_n_values = (array) apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this);
1469 1469
 		//set attributes as provided in $set_cols_n_values
1470
-		foreach($set_cols_n_values as $column=>$value){
1471
-			$this->set($column,$value);
1470
+		foreach ($set_cols_n_values as $column=>$value) {
1471
+			$this->set($column, $value);
1472 1472
 		}
1473 1473
 		/**
1474 1474
 		 * Saving a model object.
@@ -1476,8 +1476,8 @@  discard block
 block discarded – undo
1476 1476
 		 * Before we perform a save, this action is fired.
1477 1477
 		 * @param EE_Base_Class $model_object the model object about to be saved.
1478 1478
 		 */
1479
-		do_action( 'AHEE__EE_Base_Class__save__begin', $this );
1480
-		if( ! $this->allow_persist() ) {
1479
+		do_action('AHEE__EE_Base_Class__save__begin', $this);
1480
+		if ( ! $this->allow_persist()) {
1481 1481
 			return 0;
1482 1482
 		}
1483 1483
 		//now get current attribute values
@@ -1487,61 +1487,61 @@  discard block
 block discarded – undo
1487 1487
 		$old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object();
1488 1488
 		$this->get_model()->assume_values_already_prepared_by_model_object(true);
1489 1489
 		//does this model have an autoincrement PK?
1490
-		if($this->get_model()->has_primary_key_field()){
1491
-			if($this->get_model()->get_primary_key_field()->is_auto_increment()){
1490
+		if ($this->get_model()->has_primary_key_field()) {
1491
+			if ($this->get_model()->get_primary_key_field()->is_auto_increment()) {
1492 1492
 				//ok check if it's set, if so: update; if not, insert
1493
-				if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){
1494
-					$results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() );
1493
+				if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) {
1494
+					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1495 1495
 				} else {
1496
-					unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]);
1497
-					$results = $this->get_model()->insert( $save_cols_n_values );
1498
-					if($results){
1496
+					unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]);
1497
+					$results = $this->get_model()->insert($save_cols_n_values);
1498
+					if ($results) {
1499 1499
 						//if successful, set the primary key
1500 1500
 						//but don't use the normal SET method, because it will check if
1501 1501
 						//an item with the same ID exists in the mapper & db, then
1502 1502
 						//will find it in the db (because we just added it) and THAT object
1503 1503
 						//will get added to the mapper before we can add this one!
1504 1504
 						//but if we just avoid using the SET method, all that headache can be avoided
1505
-						$pk_field_name =self::_get_primary_key_name( get_class($this));
1505
+						$pk_field_name = self::_get_primary_key_name(get_class($this));
1506 1506
 						$this->_fields[$pk_field_name] = $results;
1507 1507
 						$this->_clear_cached_property($pk_field_name);
1508
-						$this->get_model()->add_to_entity_map( $this );
1508
+						$this->get_model()->add_to_entity_map($this);
1509 1509
 						$this->_update_cached_related_model_objs_fks();
1510 1510
 					}
1511 1511
 				}
1512
-			}else{//PK is NOT auto-increment
1512
+			} else {//PK is NOT auto-increment
1513 1513
 				//so check if one like it already exists in the db
1514
-				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1515
-					if( WP_DEBUG && ! $this->in_entity_map() ){
1514
+				if ($this->get_model()->exists_by_ID($this->ID())) {
1515
+					if (WP_DEBUG && ! $this->in_entity_map()) {
1516 1516
 						throw new EE_Error(
1517 1517
 							sprintf(
1518
-								__( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ),
1518
+								__('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'),
1519 1519
 								get_class($this),
1520
-								get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
1521
-								get_class( $this->get_model() ) . '::instance()->get_one_by_ID()',
1520
+								get_class($this->get_model()).'::instance()->add_to_entity_map()',
1521
+								get_class($this->get_model()).'::instance()->get_one_by_ID()',
1522 1522
 								'<br />'
1523 1523
 							)
1524 1524
 						);
1525 1525
 					}
1526 1526
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1527
-				}else{
1527
+				} else {
1528 1528
 					$results = $this->get_model()->insert($save_cols_n_values);
1529 1529
 					$this->_update_cached_related_model_objs_fks();
1530 1530
 				}
1531 1531
 			}
1532
-		}else{//there is NO primary key
1532
+		} else {//there is NO primary key
1533 1533
 			$already_in_db = false;
1534
-			foreach($this->get_model()->unique_indexes() as $index){
1534
+			foreach ($this->get_model()->unique_indexes() as $index) {
1535 1535
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
1536
-				if($this->get_model()->exists(array($uniqueness_where_params))){
1536
+				if ($this->get_model()->exists(array($uniqueness_where_params))) {
1537 1537
 					$already_in_db = true;
1538 1538
 				}
1539 1539
 			}
1540
-			if( $already_in_db ){
1541
-				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1542
-				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1543
-			}else{
1544
-				$results = $this->get_model()->insert( $save_cols_n_values );
1540
+			if ($already_in_db) {
1541
+				$combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields());
1542
+				$results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values);
1543
+			} else {
1544
+				$results = $this->get_model()->insert($save_cols_n_values);
1545 1545
 			}
1546 1546
 		}
1547 1547
 		//restore the old assumption about values being prepared by the model object
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
 		 * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted
1555 1555
 		 * the new ID (or 0 if an error occurred and it wasn't updated)
1556 1556
 		 */
1557
-		do_action( 'AHEE__EE_Base_Class__save__end', $this, $results );
1557
+		do_action('AHEE__EE_Base_Class__save__end', $this, $results);
1558 1558
 		return $results;
1559 1559
 	}
1560 1560
 
@@ -1569,15 +1569,15 @@  discard block
 block discarded – undo
1569 1569
 	 * @return void
1570 1570
 	 * @throws \EE_Error
1571 1571
 	 */
1572
-	protected function _update_cached_related_model_objs_fks(){
1573
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){
1574
-			if( $relation_obj instanceof EE_Has_Many_Relation ){
1575
-				foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) {
1572
+	protected function _update_cached_related_model_objs_fks() {
1573
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1574
+			if ($relation_obj instanceof EE_Has_Many_Relation) {
1575
+				foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) {
1576 1576
 					$fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to(
1577 1577
 						$this->get_model()->get_this_model_name()
1578 1578
 					);
1579
-					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() );
1580
-					if( $related_model_obj_in_cache->ID() ){
1579
+					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID());
1580
+					if ($related_model_obj_in_cache->ID()) {
1581 1581
 						$related_model_obj_in_cache->save();
1582 1582
 					}
1583 1583
 				}
@@ -1598,21 +1598,21 @@  discard block
 block discarded – undo
1598 1598
 	 * @return int ID of new model object on save; 0 on failure+
1599 1599
 	 * @throws \EE_Error
1600 1600
 	 */
1601
-	public function save_new_cached_related_model_objs(){
1601
+	public function save_new_cached_related_model_objs() {
1602 1602
 		//make sure this has been saved
1603
-		if( ! $this->ID()){
1603
+		if ( ! $this->ID()) {
1604 1604
 			$id = $this->save();
1605
-		}else{
1605
+		} else {
1606 1606
 			$id = $this->ID();
1607 1607
 		}
1608 1608
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
1609
-		foreach($this->get_model()->relation_settings() as $relationName => $relationObj){
1609
+		foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) {
1610 1610
 
1611 1611
 
1612
-			if($this->_model_relations[$relationName]){
1612
+			if ($this->_model_relations[$relationName]) {
1613 1613
 				//is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation)
1614 1614
 				//or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)?
1615
-				if($relationObj instanceof EE_Belongs_To_Relation){
1615
+				if ($relationObj instanceof EE_Belongs_To_Relation) {
1616 1616
 					//add a relation to that relation type (which saves the appropriate thing in the process)
1617 1617
 					//but ONLY if it DOES NOT exist in the DB
1618 1618
 					/* @var $related_model_obj EE_Base_Class */
@@ -1621,8 +1621,8 @@  discard block
 block discarded – undo
1621 1621
 						$this->_add_relation_to($related_model_obj, $relationName);
1622 1622
 						$related_model_obj->save_new_cached_related_model_objs();
1623 1623
 //					}
1624
-				}else{
1625
-					foreach($this->_model_relations[$relationName] as $related_model_obj){
1624
+				} else {
1625
+					foreach ($this->_model_relations[$relationName] as $related_model_obj) {
1626 1626
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1627 1627
 						//but ONLY if it DOES NOT exist in the DB
1628 1628
 //						if( ! $related_model_obj->ID()){
@@ -1643,8 +1643,8 @@  discard block
 block discarded – undo
1643 1643
 	 * @return \EEM_Base | \EEM_CPT_Base
1644 1644
 	 */
1645 1645
 	public function get_model() {
1646
-		$modelName = self::_get_model_classname( get_class($this) );
1647
-		return self::_get_model_instance_with_name($modelName, $this->_timezone );
1646
+		$modelName = self::_get_model_classname(get_class($this));
1647
+		return self::_get_model_instance_with_name($modelName, $this->_timezone);
1648 1648
 	}
1649 1649
 
1650 1650
 
@@ -1655,10 +1655,10 @@  discard block
 block discarded – undo
1655 1655
 	 * @return mixed bool|EE_Base_Class|EEM_CPT_Base
1656 1656
 	 * @throws \EE_Error
1657 1657
 	 */
1658
-	protected static function _get_object_from_entity_mapper($props_n_values, $classname){
1658
+	protected static function _get_object_from_entity_mapper($props_n_values, $classname) {
1659 1659
 		//TODO: will not work for Term_Relationships because they have no PK!
1660
-		$primary_id_ref = self::_get_primary_key_name( $classname );
1661
-		if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1660
+		$primary_id_ref = self::_get_primary_key_name($classname);
1661
+		if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) {
1662 1662
 			$id = $props_n_values[$primary_id_ref];
1663 1663
 			return self::_get_model($classname)->get_from_entity_map($id);
1664 1664
 		}
@@ -1679,37 +1679,37 @@  discard block
 block discarded – undo
1679 1679
 	 * @return mixed (EE_Base_Class|bool)
1680 1680
 	 * @throws \EE_Error
1681 1681
 	 */
1682
-	protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) {
1682
+	protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) {
1683 1683
 		$existing = null;
1684
-		if ( self::_get_model( $classname )->has_primary_key_field() ) {
1685
-			$primary_id_ref = self::_get_primary_key_name( $classname );
1686
-			if ( array_key_exists( $primary_id_ref, $props_n_values )
1687
-			     && ! empty( $props_n_values[ $primary_id_ref ] )
1684
+		if (self::_get_model($classname)->has_primary_key_field()) {
1685
+			$primary_id_ref = self::_get_primary_key_name($classname);
1686
+			if (array_key_exists($primary_id_ref, $props_n_values)
1687
+			     && ! empty($props_n_values[$primary_id_ref])
1688 1688
 			) {
1689
-				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID(
1690
-					$props_n_values[ $primary_id_ref ]
1689
+				$existing = self::_get_model($classname, $timezone)->get_one_by_ID(
1690
+					$props_n_values[$primary_id_ref]
1691 1691
 				);
1692 1692
 			}
1693
-		} elseif ( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ) {
1693
+		} elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) {
1694 1694
 			//no primary key on this model, but there's still a matching item in the DB
1695
-			$existing = self::_get_model( $classname, $timezone )->get_one_by_ID(
1696
-				self::_get_model( $classname, $timezone )->get_index_primary_key_string( $props_n_values )
1695
+			$existing = self::_get_model($classname, $timezone)->get_one_by_ID(
1696
+				self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values)
1697 1697
 			);
1698 1698
 		}
1699
-		if ( $existing ) {
1699
+		if ($existing) {
1700 1700
 
1701 1701
 			//set date formats if present before setting values
1702
-			if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
1703
-				$existing->set_date_format( $date_formats[0] );
1704
-				$existing->set_time_format( $date_formats[1] );
1702
+			if ( ! empty($date_formats) && is_array($date_formats)) {
1703
+				$existing->set_date_format($date_formats[0]);
1704
+				$existing->set_time_format($date_formats[1]);
1705 1705
 			} else {
1706 1706
 				//set default formats for date and time
1707
-				$existing->set_date_format( get_option( 'date_format' ) );
1708
-				$existing->set_time_format( get_option( 'time_format' ) );
1707
+				$existing->set_date_format(get_option('date_format'));
1708
+				$existing->set_time_format(get_option('time_format'));
1709 1709
 			}
1710 1710
 
1711
-			foreach ( $props_n_values as $property => $field_value ) {
1712
-				$existing->set( $property, $field_value );
1711
+			foreach ($props_n_values as $property => $field_value) {
1712
+				$existing->set($property, $field_value);
1713 1713
 			}
1714 1714
 			return $existing;
1715 1715
 		} else {
@@ -1727,9 +1727,9 @@  discard block
 block discarded – undo
1727 1727
 	 * @throws EE_Error
1728 1728
 	 * @return EEM_Base
1729 1729
 	 */
1730
-	protected static function  _get_model( $classname, $timezone = NULL ){
1730
+	protected static function  _get_model($classname, $timezone = NULL) {
1731 1731
 		//find model for this class
1732
-		if( ! $classname ){
1732
+		if ( ! $classname) {
1733 1733
 			throw new EE_Error(
1734 1734
 				sprintf(
1735 1735
 					__(
@@ -1740,8 +1740,8 @@  discard block
 block discarded – undo
1740 1740
 				)
1741 1741
 			);
1742 1742
 		}
1743
-		$modelName=self::_get_model_classname($classname);
1744
-		return self::_get_model_instance_with_name($modelName, $timezone );
1743
+		$modelName = self::_get_model_classname($classname);
1744
+		return self::_get_model_instance_with_name($modelName, $timezone);
1745 1745
 	}
1746 1746
 
1747 1747
 
@@ -1752,10 +1752,10 @@  discard block
 block discarded – undo
1752 1752
 	 * @param null   $timezone
1753 1753
 	 * @return EEM_Base
1754 1754
 	 */
1755
-	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){
1756
-		$model_classname = str_replace( 'EEM_', '', $model_classname );
1757
-		$model = EE_Registry::instance()->load_model( $model_classname );
1758
-		$model->set_timezone( $timezone );
1755
+	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) {
1756
+		$model_classname = str_replace('EEM_', '', $model_classname);
1757
+		$model = EE_Registry::instance()->load_model($model_classname);
1758
+		$model->set_timezone($timezone);
1759 1759
 		return $model;
1760 1760
 	}
1761 1761
 
@@ -1767,10 +1767,10 @@  discard block
 block discarded – undo
1767 1767
 	 * @param null $model_name
1768 1768
 	 * @return string like EEM_Attendee
1769 1769
 	 */
1770
-	private static function _get_model_classname( $model_name = null){
1771
-		if(strpos($model_name,"EE_")===0){
1772
-			$model_classname=str_replace("EE_","EEM_",$model_name);
1773
-		}else{
1770
+	private static function _get_model_classname($model_name = null) {
1771
+		if (strpos($model_name, "EE_") === 0) {
1772
+			$model_classname = str_replace("EE_", "EEM_", $model_name);
1773
+		} else {
1774 1774
 			$model_classname = "EEM_".$model_name;
1775 1775
 		}
1776 1776
 		return $model_classname;
@@ -1784,16 +1784,16 @@  discard block
 block discarded – undo
1784 1784
 	 * @throws EE_Error
1785 1785
 	 * @return string
1786 1786
 	 */
1787
-	protected static function _get_primary_key_name( $classname = NULL ){
1788
-		if( ! $classname){
1787
+	protected static function _get_primary_key_name($classname = NULL) {
1788
+		if ( ! $classname) {
1789 1789
 			throw new EE_Error(
1790 1790
 				sprintf(
1791
-					__( "What were you thinking calling _get_primary_key_name(%s)", "event_espresso" ),
1791
+					__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"),
1792 1792
 					$classname
1793 1793
 				)
1794 1794
 			);
1795 1795
 		}
1796
-		return self::_get_model( $classname )->get_primary_key_field()->get_name();
1796
+		return self::_get_model($classname)->get_primary_key_field()->get_name();
1797 1797
 	}
1798 1798
 
1799 1799
 
@@ -1807,12 +1807,12 @@  discard block
 block discarded – undo
1807 1807
 	 * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string
1808 1808
 	 * @throws \EE_Error
1809 1809
 	 */
1810
-	public function ID(){
1810
+	public function ID() {
1811 1811
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1812
-		if( $this->get_model()->has_primary_key_field() ) {
1813
-			return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ];
1814
-		}else{
1815
-			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1812
+		if ($this->get_model()->has_primary_key_field()) {
1813
+			return $this->_fields[self::_get_primary_key_name(get_class($this))];
1814
+		} else {
1815
+			return $this->get_model()->get_index_primary_key_string($this->_fields);
1816 1816
 		}
1817 1817
 	}
1818 1818
 
@@ -1830,38 +1830,38 @@  discard block
 block discarded – undo
1830 1830
 	 * @throws EE_Error
1831 1831
 	 * @return EE_Base_Class the object the relation was added to
1832 1832
 	 */
1833
-	public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){
1833
+	public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) {
1834 1834
 		//if this thing exists in the DB, save the relation to the DB
1835
-		if( $this->ID() ){
1836
-			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values );
1835
+		if ($this->ID()) {
1836
+			$otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values);
1837 1837
 			//clear cache so future get_many_related and get_first_related() return new results.
1838
-			$this->clear_cache( $relationName, $otherObject, TRUE );
1839
-                        if( $otherObject instanceof EE_Base_Class ) {
1840
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1838
+			$this->clear_cache($relationName, $otherObject, TRUE);
1839
+                        if ($otherObject instanceof EE_Base_Class) {
1840
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1841 1841
                         }
1842 1842
 		} else {
1843 1843
 			//this thing doesn't exist in the DB,  so just cache it
1844
-			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
1845
-				throw new EE_Error( sprintf(
1846
-					__( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ),
1844
+			if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) {
1845
+				throw new EE_Error(sprintf(
1846
+					__('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'),
1847 1847
 					$otherObjectModelObjectOrID,
1848
-					get_class( $this )
1848
+					get_class($this)
1849 1849
 				));
1850 1850
 			} else {
1851 1851
 				$otherObject = $otherObjectModelObjectOrID;
1852 1852
 			}
1853
-			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1853
+			$this->cache($relationName, $otherObjectModelObjectOrID, $cache_id);
1854 1854
 		}
1855
-                if( $otherObject instanceof EE_Base_Class ) {
1855
+                if ($otherObject instanceof EE_Base_Class) {
1856 1856
                     //fix the reciprocal relation too
1857
-                    if( $otherObject->ID() ) {
1857
+                    if ($otherObject->ID()) {
1858 1858
                             //its saved so assumed relations exist in the DB, so we can just
1859 1859
                             //clear the cache so future queries use the updated info in the DB
1860
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1860
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true);
1861 1861
                     } else {
1862 1862
 
1863 1863
                             //it's not saved, so it caches relations like this
1864
-                            $otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1864
+                            $otherObject->cache($this->get_model()->get_this_model_name(), $this);
1865 1865
                     }
1866 1866
                 }
1867 1867
 		return $otherObject;
@@ -1885,17 +1885,17 @@  discard block
 block discarded – undo
1885 1885
 	 * @return EE_Base_Class the relation was removed from
1886 1886
 	 * @throws \EE_Error
1887 1887
 	 */
1888
-	public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){
1889
-		if ( $this->ID() ) {
1888
+	public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) {
1889
+		if ($this->ID()) {
1890 1890
 			//if this exists in the DB, save the relation change to the DB too
1891
-			$otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query );
1892
-			$this->clear_cache( $relationName, $otherObject );
1891
+			$otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query);
1892
+			$this->clear_cache($relationName, $otherObject);
1893 1893
 		} else {
1894 1894
 			//this doesn't exist in the DB, just remove it from the cache
1895
-			$otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID );
1895
+			$otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID);
1896 1896
 		}
1897
-                if( $otherObject instanceof EE_Base_Class ) {
1898
-                    $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1897
+                if ($otherObject instanceof EE_Base_Class) {
1898
+                    $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1899 1899
                 }
1900 1900
 		return $otherObject;
1901 1901
 	}
@@ -1910,18 +1910,18 @@  discard block
 block discarded – undo
1910 1910
 	 * @return EE_Base_Class
1911 1911
 	 * @throws \EE_Error
1912 1912
 	 */
1913
-	public function _remove_relations($relationName,$where_query_params = array()){
1914
-		if ( $this->ID() ) {
1913
+	public function _remove_relations($relationName, $where_query_params = array()) {
1914
+		if ($this->ID()) {
1915 1915
 			//if this exists in the DB, save the relation change to the DB too
1916
-			$otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params );
1917
-			$this->clear_cache( $relationName, null, true );
1916
+			$otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params);
1917
+			$this->clear_cache($relationName, null, true);
1918 1918
 		} else {
1919 1919
 			//this doesn't exist in the DB, just remove it from the cache
1920
-			$otherObjects = $this->clear_cache( $relationName, null, true );
1920
+			$otherObjects = $this->clear_cache($relationName, null, true);
1921 1921
 		}
1922
-                if( is_array( $otherObjects ) ) {
1923
-                    foreach ( $otherObjects as $otherObject ) {
1924
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1922
+                if (is_array($otherObjects)) {
1923
+                    foreach ($otherObjects as $otherObject) {
1924
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1925 1925
                     }
1926 1926
                 }
1927 1927
 		return $otherObjects;
@@ -1941,27 +1941,27 @@  discard block
 block discarded – undo
1941 1941
 	 * @throws \EE_Error
1942 1942
 	 *                             or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs
1943 1943
 	 */
1944
-	public function get_many_related($relationName,$query_params = array()){
1945
-		if($this->ID()){
1944
+	public function get_many_related($relationName, $query_params = array()) {
1945
+		if ($this->ID()) {
1946 1946
 			//this exists in the DB, so get the related things from either the cache or the DB
1947 1947
 			//if there are query parameters, forget about caching the related model objects.
1948
-			if( $query_params ){
1948
+			if ($query_params) {
1949 1949
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1950
-			}else{
1950
+			} else {
1951 1951
 				//did we already cache the result of this query?
1952 1952
 				$cached_results = $this->get_all_from_cache($relationName);
1953
-				if ( ! $cached_results ){
1953
+				if ( ! $cached_results) {
1954 1954
 					$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1955 1955
 					//if no query parameters were passed, then we got all the related model objects
1956 1956
 					//for that relation. We can cache them then.
1957
-					foreach($related_model_objects as $related_model_object){
1957
+					foreach ($related_model_objects as $related_model_object) {
1958 1958
 						$this->cache($relationName, $related_model_object);
1959 1959
 					}
1960
-				}else{
1960
+				} else {
1961 1961
 					$related_model_objects = $cached_results;
1962 1962
 				}
1963 1963
 			}
1964
-		}else{
1964
+		} else {
1965 1965
 			//this doesn't exist in the DB, so just get the related things from the cache
1966 1966
 			$related_model_objects = $this->get_all_from_cache($relationName);
1967 1967
 		}
@@ -1979,8 +1979,8 @@  discard block
 block discarded – undo
1979 1979
 	 * @param bool   	$distinct       if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
1980 1980
 	 * @return int
1981 1981
 	 */
1982
-	public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1983
-		return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct);
1982
+	public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1983
+		return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct);
1984 1984
 	}
1985 1985
 
1986 1986
 
@@ -1994,7 +1994,7 @@  discard block
 block discarded – undo
1994 1994
 	 * 						By default, uses primary key (which doesn't make much sense, so you should probably change it)
1995 1995
 	 * @return int
1996 1996
 	 */
1997
-	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){
1997
+	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) {
1998 1998
 		return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum);
1999 1999
 	}
2000 2000
 
@@ -2008,33 +2008,33 @@  discard block
 block discarded – undo
2008 2008
 	 * @return EE_Base_Class (not an array, a single object)
2009 2009
 	 * @throws \EE_Error
2010 2010
 	 */
2011
-	public function get_first_related($relationName,$query_params = array()){
2012
-		if($this->ID()){//this exists in the DB, get from the cache OR the DB
2011
+	public function get_first_related($relationName, $query_params = array()) {
2012
+		if ($this->ID()) {//this exists in the DB, get from the cache OR the DB
2013 2013
 
2014 2014
 			//if they've provided some query parameters, don't bother trying to cache the result
2015 2015
 			//also make sure we're not caching the result of get_first_related
2016 2016
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
2017
-			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
2018
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
2019
-			}else{
2017
+			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
2018
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2019
+			} else {
2020 2020
 				//first, check if we've already cached the result of this query
2021 2021
 				$cached_result = $this->get_one_from_cache($relationName);
2022
-				if ( ! $cached_result ){
2022
+				if ( ! $cached_result) {
2023 2023
 
2024 2024
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2025
-					$this->cache($relationName,$related_model_object);
2026
-				}else{
2025
+					$this->cache($relationName, $related_model_object);
2026
+				} else {
2027 2027
 					$related_model_object = $cached_result;
2028 2028
 				}
2029 2029
 			}
2030
-		}else{
2030
+		} else {
2031 2031
 			$related_model_object = null;
2032 2032
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
2033
-			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
2034
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
2033
+			if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
2034
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2035 2035
 			}
2036 2036
 			//this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object
2037
-			if( ! $related_model_object){
2037
+			if ( ! $related_model_object) {
2038 2038
 				$related_model_object = $this->get_one_from_cache($relationName);
2039 2039
 			}
2040 2040
 
@@ -2056,12 +2056,12 @@  discard block
 block discarded – undo
2056 2056
 	 * @return int how many deleted
2057 2057
 	 * @throws \EE_Error
2058 2058
 	 */
2059
-	public function delete_related($relationName,$query_params = array()){
2060
-		if($this->ID()){
2061
-			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
2062
-		}else{
2059
+	public function delete_related($relationName, $query_params = array()) {
2060
+		if ($this->ID()) {
2061
+			$count = $this->get_model()->delete_related($this, $relationName, $query_params);
2062
+		} else {
2063 2063
 			$count = count($this->get_all_from_cache($relationName));
2064
-			$this->clear_cache($relationName,NULL,TRUE);
2064
+			$this->clear_cache($relationName, NULL, TRUE);
2065 2065
 		}
2066 2066
 		return $count;
2067 2067
 	}
@@ -2080,13 +2080,13 @@  discard block
 block discarded – undo
2080 2080
 	 * @return int how many deleted (including those soft deleted)
2081 2081
 	 * @throws \EE_Error
2082 2082
 	 */
2083
-	public function delete_related_permanently($relationName,$query_params = array()){
2084
-		if($this->ID()){
2085
-			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
2086
-		}else{
2083
+	public function delete_related_permanently($relationName, $query_params = array()) {
2084
+		if ($this->ID()) {
2085
+			$count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
2086
+		} else {
2087 2087
 			$count = count($this->get_all_from_cache($relationName));
2088 2088
 		}
2089
-		$this->clear_cache($relationName,NULL,TRUE);
2089
+		$this->clear_cache($relationName, NULL, TRUE);
2090 2090
 		return $count;
2091 2091
 	}
2092 2092
 
@@ -2102,7 +2102,7 @@  discard block
 block discarded – undo
2102 2102
 	 * @param  string $field_name property to check
2103 2103
 	 * @return bool            				  TRUE if existing,FALSE if not.
2104 2104
 	 */
2105
-	public function is_set( $field_name ) {
2105
+	public function is_set($field_name) {
2106 2106
 		return isset($this->_fields[$field_name]);
2107 2107
 	}
2108 2108
 
@@ -2114,11 +2114,11 @@  discard block
 block discarded – undo
2114 2114
 	 * @throws EE_Error
2115 2115
 	 * @return bool                              TRUE if existing, throw EE_Error if not.
2116 2116
 	 */
2117
-	protected function _property_exists( $properties ) {
2117
+	protected function _property_exists($properties) {
2118 2118
 
2119
-		foreach ( (array) $properties as $property_name ) {
2119
+		foreach ((array) $properties as $property_name) {
2120 2120
 			//first make sure this property exists
2121
-			if ( ! $this->_fields[ $property_name ] ) {
2121
+			if ( ! $this->_fields[$property_name]) {
2122 2122
 				throw new EE_Error(
2123 2123
 					sprintf(
2124 2124
 						__(
@@ -2146,7 +2146,7 @@  discard block
 block discarded – undo
2146 2146
 		$fields = $this->get_model()->field_settings(FALSE);
2147 2147
 		$properties = array();
2148 2148
 		//remove prepended underscore
2149
-		foreach ( $fields as $field_name => $settings ) {
2149
+		foreach ($fields as $field_name => $settings) {
2150 2150
 			$properties[$field_name] = $this->get($field_name);
2151 2151
 		}
2152 2152
 		return $properties;
@@ -2176,10 +2176,10 @@  discard block
 block discarded – undo
2176 2176
 	 * @throws EE_Error
2177 2177
 	 * @return mixed whatever the plugin which calls add_filter decides
2178 2178
 	 */
2179
-	public function __call($methodName,$args){
2180
-		$className=get_class($this);
2181
-		$tagName="FHEE__{$className}__{$methodName}";
2182
-		if ( ! has_filter( $tagName ) ) {
2179
+	public function __call($methodName, $args) {
2180
+		$className = get_class($this);
2181
+		$tagName = "FHEE__{$className}__{$methodName}";
2182
+		if ( ! has_filter($tagName)) {
2183 2183
 			throw new EE_Error(
2184 2184
 				sprintf(
2185 2185
 					__(
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
 				)
2193 2193
 			);
2194 2194
 		}
2195
-		return apply_filters($tagName,null,$this,$args);
2195
+		return apply_filters($tagName, null, $this, $args);
2196 2196
 	}
2197 2197
 
2198 2198
 
@@ -2208,7 +2208,7 @@  discard block
 block discarded – undo
2208 2208
 	 * @throws \EE_Error
2209 2209
 	 * NOTE: if the values haven't changed, returns 0
2210 2210
 	 */
2211
-	public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){
2211
+	public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) {
2212 2212
 		$query_params = array(
2213 2213
 			array(
2214 2214
 				'EXM_key'  => $meta_key,
@@ -2216,17 +2216,17 @@  discard block
 block discarded – undo
2216 2216
 				'EXM_type' => $this->get_model()->get_this_model_name()
2217 2217
 			)
2218 2218
 		);
2219
-		if ( $previous_value !== null ) {
2219
+		if ($previous_value !== null) {
2220 2220
 			$query_params[0]['EXM_value'] = $meta_value;
2221 2221
 		}
2222
-		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all( $query_params );
2223
-		if ( ! $existing_rows_like_that ) {
2224
-			return $this->add_extra_meta( $meta_key, $meta_value );
2222
+		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params);
2223
+		if ( ! $existing_rows_like_that) {
2224
+			return $this->add_extra_meta($meta_key, $meta_value);
2225 2225
 		} else {
2226
-			foreach ( $existing_rows_like_that as $existing_row ) {
2227
-				$existing_row->save( array( 'EXM_value' => $meta_value ) );
2226
+			foreach ($existing_rows_like_that as $existing_row) {
2227
+				$existing_row->save(array('EXM_value' => $meta_value));
2228 2228
 			}
2229
-			return count( $existing_rows_like_that );
2229
+			return count($existing_rows_like_that);
2230 2230
 		}
2231 2231
 	}
2232 2232
 
@@ -2243,8 +2243,8 @@  discard block
 block discarded – undo
2243 2243
 	 * @return boolean
2244 2244
 	 * @throws \EE_Error
2245 2245
 	 */
2246
-	public function add_extra_meta($meta_key,$meta_value,$unique = false){
2247
-		if ( $unique ) {
2246
+	public function add_extra_meta($meta_key, $meta_value, $unique = false) {
2247
+		if ($unique) {
2248 2248
 			$existing_extra_meta = EEM_Extra_Meta::instance()->get_one(
2249 2249
 				array(
2250 2250
 					array(
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 					)
2255 2255
 				)
2256 2256
 			);
2257
-			if ( $existing_extra_meta ) {
2257
+			if ($existing_extra_meta) {
2258 2258
 				return false;
2259 2259
 			}
2260 2260
 		}
@@ -2281,7 +2281,7 @@  discard block
 block discarded – undo
2281 2281
 	 * @return int number of extra meta rows deleted
2282 2282
 	 * @throws \EE_Error
2283 2283
 	 */
2284
-	public function delete_extra_meta($meta_key,$meta_value = NULL){
2284
+	public function delete_extra_meta($meta_key, $meta_value = NULL) {
2285 2285
 		$query_params = array(
2286 2286
 			array(
2287 2287
 				'EXM_key'  => $meta_key,
@@ -2289,10 +2289,10 @@  discard block
 block discarded – undo
2289 2289
 				'EXM_type' => $this->get_model()->get_this_model_name()
2290 2290
 			)
2291 2291
 		);
2292
-		if ( $meta_value !== null ) {
2292
+		if ($meta_value !== null) {
2293 2293
 			$query_params[0]['EXM_value'] = $meta_value;
2294 2294
 		}
2295
-		return EEM_Extra_Meta::instance()->delete( $query_params );
2295
+		return EEM_Extra_Meta::instance()->delete($query_params);
2296 2296
 	}
2297 2297
 
2298 2298
 
@@ -2308,25 +2308,25 @@  discard block
 block discarded – undo
2308 2308
 	 * @return mixed single value if $single; array if ! $single
2309 2309
 	 * @throws \EE_Error
2310 2310
 	 */
2311
-	public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){
2312
-		if($single){
2313
-			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2314
-			if ( $result instanceof EE_Extra_Meta ){
2311
+	public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) {
2312
+		if ($single) {
2313
+			$result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2314
+			if ($result instanceof EE_Extra_Meta) {
2315 2315
 				return $result->value();
2316
-			}else{
2316
+			} else {
2317 2317
 				return $default;
2318 2318
 			}
2319
-		}else{
2320
-			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2321
-			if($results){
2319
+		} else {
2320
+			$results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2321
+			if ($results) {
2322 2322
 				$values = array();
2323
-				foreach($results as $result){
2324
-					if ( $result instanceof EE_Extra_Meta ){
2323
+				foreach ($results as $result) {
2324
+					if ($result instanceof EE_Extra_Meta) {
2325 2325
 						$values[$result->ID()] = $result->value();
2326 2326
 					}
2327 2327
 				}
2328 2328
 				return $values;
2329
-			}else{
2329
+			} else {
2330 2330
 				return $default;
2331 2331
 			}
2332 2332
 		}
@@ -2348,20 +2348,20 @@  discard block
 block discarded – undo
2348 2348
 	 * @return array
2349 2349
 	 * @throws \EE_Error
2350 2350
 	 */
2351
-	public function all_extra_meta_array($one_of_each_key = true){
2351
+	public function all_extra_meta_array($one_of_each_key = true) {
2352 2352
 		$return_array = array();
2353
-		if($one_of_each_key){
2353
+		if ($one_of_each_key) {
2354 2354
 			$extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key'));
2355
-			foreach($extra_meta_objs as $extra_meta_obj){
2356
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2355
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2356
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2357 2357
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2358 2358
 				}
2359 2359
 			}
2360
-		}else{
2360
+		} else {
2361 2361
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2362
-			foreach($extra_meta_objs as $extra_meta_obj){
2363
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2364
-					if( ! isset($return_array[$extra_meta_obj->key()])){
2362
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2363
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2364
+					if ( ! isset($return_array[$extra_meta_obj->key()])) {
2365 2365
 						$return_array[$extra_meta_obj->key()] = array();
2366 2366
 					}
2367 2367
 					$return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value();
@@ -2379,19 +2379,19 @@  discard block
 block discarded – undo
2379 2379
 	 * @return string
2380 2380
 	 * @throws \EE_Error
2381 2381
 	 */
2382
-	public function name(){
2382
+	public function name() {
2383 2383
 		//find a field that's not a text field
2384 2384
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2385
-		if($field_we_can_use){
2385
+		if ($field_we_can_use) {
2386 2386
 			return $this->get($field_we_can_use->get_name());
2387
-		}else{
2387
+		} else {
2388 2388
 			$first_few_properties = $this->model_field_array();
2389
-			$first_few_properties = array_slice($first_few_properties,0,3);
2389
+			$first_few_properties = array_slice($first_few_properties, 0, 3);
2390 2390
 			$name_parts = array();
2391
-			foreach( $first_few_properties as $name=> $value ){
2391
+			foreach ($first_few_properties as $name=> $value) {
2392 2392
 				$name_parts[] = "$name:$value";
2393 2393
 			}
2394
-			return implode(",",$name_parts);
2394
+			return implode(",", $name_parts);
2395 2395
 		}
2396 2396
 	}
2397 2397
 
@@ -2404,11 +2404,11 @@  discard block
 block discarded – undo
2404 2404
 	 * @return boolean
2405 2405
 	 * @throws \EE_Error
2406 2406
 	 */
2407
-	public function in_entity_map(){
2408
-		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2407
+	public function in_entity_map() {
2408
+		if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) {
2409 2409
 			//well, if we looked, did we find it in the entity map?
2410 2410
 			return TRUE;
2411
-		}else{
2411
+		} else {
2412 2412
 			return FALSE;
2413 2413
 		}
2414 2414
 	}
@@ -2419,21 +2419,21 @@  discard block
 block discarded – undo
2419 2419
 	 * @throws EE_Error if this model object isn't in the entity mapper (because then you should
2420 2420
 	 * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE
2421 2421
 	 */
2422
-	public function refresh_from_db(){
2423
-		if( $this->ID() && $this->in_entity_map() ){
2424
-			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2425
-		}else{
2422
+	public function refresh_from_db() {
2423
+		if ($this->ID() && $this->in_entity_map()) {
2424
+			$this->get_model()->refresh_entity_map_from_db($this->ID());
2425
+		} else {
2426 2426
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2427 2427
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2428 2428
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
2429 2429
 			//absolutely nothing in it for this ID
2430
-			if( WP_DEBUG ) {
2430
+			if (WP_DEBUG) {
2431 2431
 				throw new EE_Error(
2432 2432
 					sprintf(
2433
-						__( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ),
2433
+						__('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'),
2434 2434
 						$this->ID(),
2435
-						get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
2436
-						get_class( $this->get_model() ) . '::instance()->refresh_entity_map()'
2435
+						get_class($this->get_model()).'::instance()->add_to_entity_map()',
2436
+						get_class($this->get_model()).'::instance()->refresh_entity_map()'
2437 2437
 					)
2438 2438
 				);
2439 2439
 			}
@@ -2447,11 +2447,11 @@  discard block
 block discarded – undo
2447 2447
 	 * (probably a bad assumption they have made, oh well)
2448 2448
 	 * @return string
2449 2449
 	 */
2450
-	public function __toString(){
2450
+	public function __toString() {
2451 2451
 		try {
2452
-			return sprintf( '%s (%s)', $this->name(), $this->ID() );
2453
-		} catch ( Exception $e ) {
2454
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
2452
+			return sprintf('%s (%s)', $this->name(), $this->ID());
2453
+		} catch (Exception $e) {
2454
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
2455 2455
 			return '';
2456 2456
 		}
2457 2457
 	}
@@ -2487,16 +2487,16 @@  discard block
 block discarded – undo
2487 2487
 	 * @throws \EE_Error
2488 2488
 	 */
2489 2489
 	public function __sleep() {
2490
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
2491
-			if( $relation_obj instanceof EE_Belongs_To_Relation ) {
2492
-				$classname = 'EE_' . $this->get_model()->get_this_model_name();
2493
-				if( $this->get_one_from_cache( $relation_name ) instanceof $classname &&
2494
-						$this->get_one_from_cache( $relation_name )->ID() ) {
2495
-					$this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() );
2490
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
2491
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
2492
+				$classname = 'EE_'.$this->get_model()->get_this_model_name();
2493
+				if ($this->get_one_from_cache($relation_name) instanceof $classname &&
2494
+						$this->get_one_from_cache($relation_name)->ID()) {
2495
+					$this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID());
2496 2496
 				}
2497 2497
 			}
2498 2498
 		}
2499
-		return array_keys( get_object_vars( $this ) );
2499
+		return array_keys(get_object_vars($this));
2500 2500
 	}
2501 2501
 
2502 2502
 
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.