Completed
Branch BUG-8866-category-permalink (0af2d2)
by
unknown
22:53 queued 19s
created
core/EE_Session.core.php 3 patches
Spacing   +148 added lines, -148 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
  *
4 4
  * Event Espresso
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	  * array for defining default session vars
105 105
 	  * @var array
106 106
 	  */
107
-	 private $_default_session_vars = array (
107
+	 private $_default_session_vars = array(
108 108
 		'id' => NULL,
109 109
 		'user_id' => NULL,
110 110
 		'ip_address' => NULL,
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 	 *		@access public
127 127
 	 *		@return EE_Session
128 128
 	 */
129
-	public static function instance ( ) {
129
+	public static function instance( ) {
130 130
 		// check if class object is instantiated
131
-		if ( ! self::$_instance instanceof EE_Session ) {
131
+		if ( ! self::$_instance instanceof EE_Session) {
132 132
 			self::$_instance = new self();
133 133
 		}
134 134
 		return self::$_instance;
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
 	private function __construct() {
146 146
 
147 147
 		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' );
148
-		if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) {
148
+		if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) {
149 149
 			return NULL;
150 150
 		}
151
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
152
-		define( 'ESPRESSO_SESSION', TRUE );
151
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
152
+		define('ESPRESSO_SESSION', TRUE);
153 153
 		// default session lifespan in seconds
154 154
 		$this->_lifespan = apply_filters(
155 155
 			'FHEE__EE_Session__construct___lifespan',
@@ -162,35 +162,35 @@  discard block
 block discarded – undo
162 162
 		 * 		}
163 163
 		 */
164 164
 		// retrieve session options from db
165
-		$session_settings = get_option( 'ee_session_settings' );
166
-		if ( $session_settings !== FALSE ) {
165
+		$session_settings = get_option('ee_session_settings');
166
+		if ($session_settings !== FALSE) {
167 167
 			// cycle though existing session options
168
-			foreach ( $session_settings as $var_name => $session_setting ) {
168
+			foreach ($session_settings as $var_name => $session_setting) {
169 169
 				// set values for class properties
170
-				$var_name = '_' . $var_name;
170
+				$var_name = '_'.$var_name;
171 171
 				$this->{$var_name} = $session_setting;
172 172
 			}
173 173
 		}
174 174
 		// are we using encryption?
175
-		if ( $this->_use_encryption ) {
175
+		if ($this->_use_encryption) {
176 176
 			// instantiate the class object making all properties and methods accessible via $this->encryption ex: $this->encryption->encrypt();
177
-			$this->encryption = EE_Registry::instance()->load_core( 'Encryption' );
177
+			$this->encryption = EE_Registry::instance()->load_core('Encryption');
178 178
 		}
179 179
 		// filter hook allows outside functions/classes/plugins to change default empty cart
180
-		$extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() );
181
-		array_merge( $this->_default_session_vars, $extra_default_session_vars );
180
+		$extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array());
181
+		array_merge($this->_default_session_vars, $extra_default_session_vars);
182 182
 		// apply default session vars
183 183
 		$this->_set_defaults();
184 184
 		// check for existing session and retrieve it from db
185
-		if ( ! $this->_espresso_session() ) {
185
+		if ( ! $this->_espresso_session()) {
186 186
 			// or just start a new one
187 187
 			$this->_create_espresso_session();
188 188
 		}
189 189
 		// check request for 'clear_session' param
190
-		add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' ));
190
+		add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded'));
191 191
 		// once everything is all said and done,
192
-		add_action( 'shutdown', array( $this, 'update' ), 100 );
193
-		add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 );
192
+		add_action('shutdown', array($this, 'update'), 100);
193
+		add_action('shutdown', array($this, 'garbage_collection'), 999);
194 194
 
195 195
 	}
196 196
 
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	private function _set_defaults() {
224 224
 		// set some defaults
225
-		foreach ( $this->_default_session_vars as $key => $default_var ) {
226
-			if ( is_array( $default_var )) {
227
-				$this->_session_data[ $key ] = array();
225
+		foreach ($this->_default_session_vars as $key => $default_var) {
226
+			if (is_array($default_var)) {
227
+				$this->_session_data[$key] = array();
228 228
 			} else {
229
-				$this->_session_data[ $key ] = '';
229
+				$this->_session_data[$key] = '';
230 230
 			}
231 231
 		}
232 232
 	}
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	  * @param \EE_Cart $cart
249 249
 	  * @return bool
250 250
 	  */
251
-	 public function set_cart( EE_Cart $cart ) {
251
+	 public function set_cart(EE_Cart $cart) {
252 252
 		 $this->_session_data['cart'] = $cart;
253 253
 		 return TRUE;
254 254
 	 }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	  * @return \EE_Cart
269 269
 	  */
270 270
 	 public function cart() {
271
-		 return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL;
271
+		 return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL;
272 272
 	 }
273 273
 
274 274
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	  * @param \EE_Checkout $checkout
278 278
 	  * @return bool
279 279
 	  */
280
-	 public function set_checkout( EE_Checkout $checkout ) {
280
+	 public function set_checkout(EE_Checkout $checkout) {
281 281
 		 $this->_session_data['checkout'] = $checkout;
282 282
 		 return TRUE;
283 283
 	 }
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	  * @return \EE_Checkout
298 298
 	  */
299 299
 	 public function checkout() {
300
-		 return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL;
300
+		 return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL;
301 301
 	 }
302 302
 
303 303
 
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
 	  * @param \EE_Transaction $transaction
307 307
 	  * @return bool
308 308
 	  */
309
-	 public function set_transaction( EE_Transaction $transaction ) {
309
+	 public function set_transaction(EE_Transaction $transaction) {
310 310
 		 // first remove the session from the transaction before we save the transaction in the session
311
-		 $transaction->set_txn_session_data( NULL );
311
+		 $transaction->set_txn_session_data(NULL);
312 312
 		 $this->_session_data['transaction'] = $transaction;
313 313
 		 return TRUE;
314 314
 	 }
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	  * @return \EE_Transaction
329 329
 	  */
330 330
 	 public function transaction() {
331
-		 return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL;
331
+		 return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL;
332 332
 	 }
333 333
 
334 334
 
@@ -340,15 +340,15 @@  discard block
 block discarded – undo
340 340
 	  * @param bool $reset_cache
341 341
 	  * @return    array
342 342
 	  */
343
-	public function get_session_data( $key = NULL, $reset_cache = FALSE ) {
344
-		if ( $reset_cache ) {
343
+	public function get_session_data($key = NULL, $reset_cache = FALSE) {
344
+		if ($reset_cache) {
345 345
 			$this->reset_cart();
346 346
 			$this->reset_checkout();
347 347
 			$this->reset_transaction();
348 348
 		}
349
-		 if ( ! empty( $key ))  {
350
-			return  isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL;
351
-		}  else  {
349
+		 if ( ! empty($key)) {
350
+			return  isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL;
351
+		} else {
352 352
 			return $this->_session_data;
353 353
 		}
354 354
 	}
@@ -361,20 +361,20 @@  discard block
 block discarded – undo
361 361
 	  * @param 	array $data
362 362
 	  * @return 	TRUE on success, FALSE on fail
363 363
 	  */
364
-	public function set_session_data( $data ) {
364
+	public function set_session_data($data) {
365 365
 
366 366
 		// nothing ??? bad data ??? go home!
367
-		if ( empty( $data ) || ! is_array( $data )) {
368
-			EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
367
+		if (empty($data) || ! is_array($data)) {
368
+			EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
369 369
 			return FALSE;
370 370
 		}
371 371
 
372
-		foreach ( $data as $key =>$value ) {
373
-			if ( isset( $this->_default_session_vars[ $key ] )) {
374
-				EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ );
372
+		foreach ($data as $key =>$value) {
373
+			if (isset($this->_default_session_vars[$key])) {
374
+				EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__);
375 375
 				return FALSE;
376 376
 			} else {
377
-				$this->_session_data[ $key ] = $value;
377
+				$this->_session_data[$key] = $value;
378 378
 			}
379 379
 		}
380 380
 
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
 	  * @throws \EE_Error
392 392
 	  */
393 393
 	private function _espresso_session() {
394
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
394
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
395 395
 		// check that session has started
396
-		if ( session_id() === '' ) {
396
+		if (session_id() === '') {
397 397
 			//starts a new session if one doesn't already exist, or re-initiates an existing one
398 398
 			session_start();
399 399
 		}
@@ -402,57 +402,57 @@  discard block
 block discarded – undo
402 402
 		// and the visitors IP
403 403
 		$this->_ip_address = $this->_visitor_ip();
404 404
 		// set the "user agent"
405
-		$this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE;
405
+		$this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE;
406 406
 		// now let's retrieve what's in the db
407 407
 		// we're using WP's Transient API to store session data using the PHP session ID as the option name
408
-		$session_data = get_transient( EE_Session::session_id_prefix . $this->_sid );
409
-		if ( $session_data ) {
410
-			if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
411
-				$hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid );
412
-				if ( $hash_check && $hash_check !== md5( $session_data ) ) {
408
+		$session_data = get_transient(EE_Session::session_id_prefix.$this->_sid);
409
+		if ($session_data) {
410
+			if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
411
+				$hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid);
412
+				if ($hash_check && $hash_check !== md5($session_data)) {
413 413
 					EE_Error::add_error(
414 414
 						sprintf(
415
-							__( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ),
416
-							EE_Session::session_id_prefix . $this->_sid
415
+							__('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'),
416
+							EE_Session::session_id_prefix.$this->_sid
417 417
 						),
418 418
 						__FILE__, __FUNCTION__, __LINE__
419 419
 					);
420 420
 				}
421 421
 			}
422 422
 			// un-encrypt the data
423
-			$session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data;
423
+			$session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data;
424 424
 			// unserialize
425
-			$session_data = maybe_unserialize( $session_data );
425
+			$session_data = maybe_unserialize($session_data);
426 426
 			// just a check to make sure the session array is indeed an array
427
-			if ( ! is_array( $session_data ) ) {
427
+			if ( ! is_array($session_data)) {
428 428
 				// no?!?! then something is wrong
429 429
 				return FALSE;
430 430
 			}
431 431
 			// get the current time in UTC
432
-			$this->_time = isset( $this->_time ) ? $this->_time : time();
432
+			$this->_time = isset($this->_time) ? $this->_time : time();
433 433
 			// and reset the session expiration
434
-			$this->_expiration = isset( $session_data['expiration'] ) ? $session_data['expiration'] : $this->_time + $this->_lifespan;
434
+			$this->_expiration = isset($session_data['expiration']) ? $session_data['expiration'] : $this->_time + $this->_lifespan;
435 435
 
436 436
 		} else {
437 437
 			// set initial site access time and the session expiration
438 438
 			$this->_set_init_access_and_expiration();
439 439
 			// set referer
440
-			$this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : '';
440
+			$this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) ? esc_attr($_SERVER['HTTP_REFERER']) : '';
441 441
 			// no previous session = go back and create one (on top of the data above)
442 442
 			return FALSE;
443 443
 		}
444 444
 		// now the user agent
445
-		if ( $session_data['user_agent'] != $this->_user_agent ) {
445
+		if ($session_data['user_agent'] != $this->_user_agent) {
446 446
 			return FALSE;
447 447
 		}
448 448
 		// wait a minute... how old are you?
449
-		if ( $this->_time > $this->_expiration ) {
449
+		if ($this->_time > $this->_expiration) {
450 450
 			// yer too old fer me!
451 451
 			// wipe out everything that isn't a default session datum
452
-			$this->clear_session( __CLASS__, __FUNCTION__ );
452
+			$this->clear_session(__CLASS__, __FUNCTION__);
453 453
 		}
454 454
 		// make event espresso session data available to plugin
455
-		$this->_session_data = array_merge( $this->_session_data, $session_data );
455
+		$this->_session_data = array_merge($this->_session_data, $session_data);
456 456
 		return TRUE;
457 457
 
458 458
 	}
@@ -470,12 +470,12 @@  discard block
 block discarded – undo
470 470
 	  */
471 471
 	protected function _generate_session_id() {
472 472
 		// check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
473
-		if ( isset( $_REQUEST[ 'EESID' ] ) ) {
474
-			$session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] );
473
+		if (isset($_REQUEST['EESID'])) {
474
+			$session_id = sanitize_text_field($_REQUEST['EESID']);
475 475
 		} else {
476
-			$session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() );
476
+			$session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt());
477 477
 		}
478
-		return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id );
478
+		return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
479 479
 	}
480 480
 
481 481
 
@@ -487,20 +487,20 @@  discard block
 block discarded – undo
487 487
 	  */
488 488
 	protected function _get_sid_salt() {
489 489
 		// was session id salt already saved to db ?
490
-		if ( empty( $this->_sid_salt ) ) {
490
+		if (empty($this->_sid_salt)) {
491 491
 			// no?  then maybe use WP defined constant
492
-			if ( defined( 'AUTH_SALT' ) ) {
492
+			if (defined('AUTH_SALT')) {
493 493
 				$this->_sid_salt = AUTH_SALT;
494 494
 			}
495 495
 			// if salt doesn't exist or is too short
496
-			if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) {
496
+			if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) {
497 497
 				// create a new one
498
-				$this->_sid_salt = wp_generate_password( 64 );
498
+				$this->_sid_salt = wp_generate_password(64);
499 499
 			}
500 500
 			// and save it as a permanent session setting
501
-			$session_settings = get_option( 'ee_session_settings' );
502
-			$session_settings[ 'sid_salt' ] = $this->_sid_salt;
503
-			update_option( 'ee_session_settings', $session_settings );
501
+			$session_settings = get_option('ee_session_settings');
502
+			$session_settings['sid_salt'] = $this->_sid_salt;
503
+			update_option('ee_session_settings', $session_settings);
504 504
 		}
505 505
 		return $this->_sid_salt;
506 506
 	}
@@ -528,19 +528,19 @@  discard block
 block discarded – undo
528 528
 	  * @param bool $new_session
529 529
 	  * @return TRUE on success, FALSE on fail
530 530
 	  */
531
-	public function update( $new_session = FALSE ) {
532
-		$this->_session_data = isset( $this->_session_data )
533
-			&& is_array( $this->_session_data )
534
-			&& isset( $this->_session_data['id'])
531
+	public function update($new_session = FALSE) {
532
+		$this->_session_data = isset($this->_session_data)
533
+			&& is_array($this->_session_data)
534
+			&& isset($this->_session_data['id'])
535 535
 			? $this->_session_data
536 536
 			: NULL;
537
-		if ( empty( $this->_session_data )) {
537
+		if (empty($this->_session_data)) {
538 538
 			$this->_set_defaults();
539 539
 		}
540 540
 		$session_data = array();
541
-		foreach ( $this->_session_data as $key => $value ) {
541
+		foreach ($this->_session_data as $key => $value) {
542 542
 
543
-			switch( $key ) {
543
+			switch ($key) {
544 544
 
545 545
 				case 'id' :
546 546
 					// session ID
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 				break;
559 559
 
560 560
 				case 'init_access' :
561
-					$session_data['init_access'] = absint( $value );
561
+					$session_data['init_access'] = absint($value);
562 562
 				break;
563 563
 
564 564
 				case 'last_access' :
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 
569 569
 				case 'expiration' :
570 570
 					// when the session expires
571
-					$session_data['expiration'] = ! empty( $this->_expiration )
571
+					$session_data['expiration'] = ! empty($this->_expiration)
572 572
 						? $this->_expiration
573 573
 						: $session_data['init_access'] + $this->_lifespan;
574 574
 				break;
@@ -580,11 +580,11 @@  discard block
 block discarded – undo
580 580
 
581 581
 				case 'pages_visited' :
582 582
 					$page_visit = $this->_get_page_visit();
583
-					if ( $page_visit ) {
583
+					if ($page_visit) {
584 584
 						// set pages visited where the first will be the http referrer
585
-						$this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit;
585
+						$this->_session_data['pages_visited'][$this->_time] = $page_visit;
586 586
 						// we'll only save the last 10 page visits.
587
-						$session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 );
587
+						$session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
588 588
 					}
589 589
 				break;
590 590
 
@@ -598,9 +598,9 @@  discard block
 block discarded – undo
598 598
 
599 599
 		$this->_session_data = $session_data;
600 600
 		// creating a new session does not require saving to the db just yet
601
-		if ( ! $new_session ) {
601
+		if ( ! $new_session) {
602 602
 			// ready? let's save
603
-			if ( $this->_save_session_to_db() ) {
603
+			if ($this->_save_session_to_db()) {
604 604
 				return TRUE;
605 605
 			} else {
606 606
 				return FALSE;
@@ -621,9 +621,9 @@  discard block
 block discarded – undo
621 621
 	 * 	@return bool
622 622
 	 */
623 623
 	private function _create_espresso_session( ) {
624
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
624
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
625 625
 		// use the update function for now with $new_session arg set to TRUE
626
-		return  $this->update( TRUE ) ? TRUE : FALSE;
626
+		return  $this->update(TRUE) ? TRUE : FALSE;
627 627
 	}
628 628
 
629 629
 
@@ -647,15 +647,15 @@  discard block
 block discarded – undo
647 647
 			return FALSE;
648 648
 		}
649 649
 		// first serialize all of our session data
650
-		$session_data = serialize( $this->_session_data );
650
+		$session_data = serialize($this->_session_data);
651 651
 		// encrypt it if we are using encryption
652
-		$session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data;
652
+		$session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data;
653 653
 		// maybe save hash check
654
-		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
655
-			set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan );
654
+		if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
655
+			set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan);
656 656
 		}
657 657
 		// we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient(  transient ID, data, expiry )
658
-		return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan );
658
+		return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan);
659 659
 	}
660 660
 
661 661
 
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
 			'HTTP_FORWARDED',
682 682
 			'REMOTE_ADDR'
683 683
 		);
684
-		foreach ( $server_keys as $key ){
685
-			if ( isset( $_SERVER[ $key ] )) {
686
-				foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) {
687
-					if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) {
684
+		foreach ($server_keys as $key) {
685
+			if (isset($_SERVER[$key])) {
686
+				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
687
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) {
688 688
 						$visitor_ip = $ip;
689 689
 					}
690 690
 				}
@@ -705,45 +705,45 @@  discard block
 block discarded – undo
705 705
 	public function _get_page_visit() {
706 706
 
707 707
 //		echo '<h3>'. __CLASS__ .'->'.__FUNCTION__.'  ( line no: ' . __LINE__ . ' )</h3>';
708
-		$page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
708
+		$page_visit = home_url('/').'wp-admin/admin-ajax.php';
709 709
 
710 710
 		// check for request url
711
-		if ( isset( $_SERVER['REQUEST_URI'] )) {
711
+		if (isset($_SERVER['REQUEST_URI'])) {
712 712
 
713
-			$request_uri = esc_url( $_SERVER['REQUEST_URI'] );
713
+			$request_uri = esc_url($_SERVER['REQUEST_URI']);
714 714
 
715
-			$ru_bits = explode( '?', $request_uri );
715
+			$ru_bits = explode('?', $request_uri);
716 716
 			$request_uri = $ru_bits[0];
717 717
 			//echo '<h1>$request_uri   ' . $request_uri . '</h1>';
718 718
 
719 719
 			// check for and grab host as well
720
-			if ( isset( $_SERVER['HTTP_HOST'] )) {
721
-				$http_host = esc_url( $_SERVER['HTTP_HOST'] );
720
+			if (isset($_SERVER['HTTP_HOST'])) {
721
+				$http_host = esc_url($_SERVER['HTTP_HOST']);
722 722
 			} else {
723 723
 				$http_host = '';
724 724
 			}
725 725
 			//echo '<h1>$http_host   ' . $http_host . '</h1>';
726 726
 
727 727
 			// check for page_id in SERVER REQUEST
728
-			if ( isset( $_REQUEST['page_id'] )) {
728
+			if (isset($_REQUEST['page_id'])) {
729 729
 				// rebuild $e_reg without any of the extra parameters
730
-				$page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&amp;';
730
+				$page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&amp;';
731 731
 			} else {
732 732
 				$page_id = '?';
733 733
 			}
734 734
 			// check for $e_reg in SERVER REQUEST
735
-			if ( isset( $_REQUEST['ee'] )) {
735
+			if (isset($_REQUEST['ee'])) {
736 736
 				// rebuild $e_reg without any of the extra parameters
737
-				$e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] );
737
+				$e_reg = 'ee='.esc_attr($_REQUEST['ee']);
738 738
 			} else {
739 739
 				$e_reg = '';
740 740
 			}
741 741
 
742
-			$page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' );
742
+			$page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?');
743 743
 
744 744
 		}
745 745
 
746
-		return $page_visit != home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : '';
746
+		return $page_visit != home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
747 747
 
748 748
 	}
749 749
 
@@ -772,14 +772,14 @@  discard block
 block discarded – undo
772 772
 	  * @param string $function
773 773
 	  * @return void
774 774
 	  */
775
-	public function clear_session( $class = '', $function = '' ) {
775
+	public function clear_session($class = '', $function = '') {
776 776
 		//echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span>    <b style="font-size:10px;">  ' . __LINE__ . ' </b></h3>';
777
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
777
+		do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()');
778 778
 		$this->reset_cart();
779 779
 		$this->reset_checkout();
780 780
 		$this->reset_transaction();
781 781
 		// wipe out everything that isn't a default session datum
782
-		$this->reset_data( array_keys( $this->_session_data ));
782
+		$this->reset_data(array_keys($this->_session_data));
783 783
 		// reset initial site access time and the session expiration
784 784
 		$this->_set_init_access_and_expiration();
785 785
 		$this->_save_session_to_db();
@@ -794,42 +794,42 @@  discard block
 block discarded – undo
794 794
 	  * @param bool  $show_all_notices
795 795
 	  * @return TRUE on success, FALSE on fail
796 796
 	  */
797
-	public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) {
797
+	public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) {
798 798
 		// if $data_to_reset is not in an array, then put it in one
799
-		if ( ! is_array( $data_to_reset ) ) {
800
-			$data_to_reset = array ( $data_to_reset );
799
+		if ( ! is_array($data_to_reset)) {
800
+			$data_to_reset = array($data_to_reset);
801 801
 		}
802 802
 		// nothing ??? go home!
803
-		if ( empty( $data_to_reset )) {
804
-			EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
803
+		if (empty($data_to_reset)) {
804
+			EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
805 805
 			return FALSE;
806 806
 		}
807 807
 		$return_value = TRUE;
808 808
 		// since $data_to_reset is an array, cycle through the values
809
-		foreach ( $data_to_reset as $reset ) {
809
+		foreach ($data_to_reset as $reset) {
810 810
 
811 811
 			// first check to make sure it is a valid session var
812
-			if ( isset( $this->_session_data[ $reset ] )) {
812
+			if (isset($this->_session_data[$reset])) {
813 813
 				// then check to make sure it is not a default var
814
-				if ( ! array_key_exists( $reset, $this->_default_session_vars )) {
814
+				if ( ! array_key_exists($reset, $this->_default_session_vars)) {
815 815
 					// remove session var
816
-					unset( $this->_session_data[ $reset ] );
817
-					if ( $show_all_notices ) {
818
-						EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
816
+					unset($this->_session_data[$reset]);
817
+					if ($show_all_notices) {
818
+						EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
819 819
 					}
820
-					$return_value = !isset($return_value) ? TRUE : $return_value;
820
+					$return_value = ! isset($return_value) ? TRUE : $return_value;
821 821
 
822 822
 				} else {
823 823
 					// yeeeeeeeeerrrrrrrrrrr OUT !!!!
824
-					if ( $show_all_notices ) {
825
-						EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
824
+					if ($show_all_notices) {
825
+						EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
826 826
 					}
827 827
 					$return_value = FALSE;
828 828
 				}
829 829
 
830
-			} else if ( $show_all_notices ) {
830
+			} else if ($show_all_notices) {
831 831
 				// oops! that session var does not exist!
832
-				EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
832
+				EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
833 833
 				$return_value = FALSE;
834 834
 			}
835 835
 
@@ -850,8 +850,8 @@  discard block
 block discarded – undo
850 850
 	 *   @return	 string
851 851
 	 */
852 852
 	public function wp_loaded() {
853
-		if ( isset(  EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) {
854
-			$this->clear_session( __CLASS__, __FUNCTION__ );
853
+		if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) {
854
+			$this->clear_session(__CLASS__, __FUNCTION__);
855 855
 		}
856 856
 	}
857 857
 
@@ -876,24 +876,24 @@  discard block
 block discarded – undo
876 876
 	  */
877 877
 	 public function garbage_collection() {
878 878
 		 // only perform during regular requests
879
-		 if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) {
879
+		 if ( ! defined('DOING_AJAX') || ! DOING_AJAX) {
880 880
 			 /** @type WPDB $wpdb */
881 881
 			 global $wpdb;
882 882
 			 // since transient expiration timestamps are set in the future, we can compare against NOW
883 883
 			 $expiration = time();
884
-			 $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 );
884
+			 $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2);
885 885
 			 // filter the query limit. Set to 0 to turn off garbage collection
886
-			 $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 ));
886
+			 $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50));
887 887
 			 // non-zero LIMIT means take out the trash
888
-			 if ( $expired_session_transient_delete_query_limit ) {
888
+			 if ($expired_session_transient_delete_query_limit) {
889 889
 				 //array of transient keys that require garbage collection
890 890
 				 $session_keys = array(
891 891
 					 EE_Session::session_id_prefix,
892 892
 					 EE_Session::hash_check_prefix,
893 893
 				 );
894
-				 foreach ( $session_keys as $session_key ) {
895
-					 $session_key = str_replace( '_', '\_', $session_key );
896
-					 $session_key = '\_transient\_timeout\_' . $session_key . '%';
894
+				 foreach ($session_keys as $session_key) {
895
+					 $session_key = str_replace('_', '\_', $session_key);
896
+					 $session_key = '\_transient\_timeout\_'.$session_key.'%';
897 897
 					 $SQL = "
898 898
 					SELECT option_name
899 899
 					FROM {$wpdb->options}
@@ -903,28 +903,28 @@  discard block
 block discarded – undo
903 903
 					OR option_value > {$too_far_in_the_the_future} )
904 904
 					LIMIT {$expired_session_transient_delete_query_limit}
905 905
 				";
906
-					 $expired_sessions = $wpdb->get_col( $SQL );
906
+					 $expired_sessions = $wpdb->get_col($SQL);
907 907
 					 // valid results?
908
-					 if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) {
908
+					 if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
909 909
 						 // format array of results into something usable within the actual DELETE query's IN clause
910 910
 						 $expired = array();
911
-						 foreach ( $expired_sessions as $expired_session ) {
912
-							 $expired[ ] = "'" . $expired_session . "'";
913
-							 $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'";
911
+						 foreach ($expired_sessions as $expired_session) {
912
+							 $expired[] = "'".$expired_session."'";
913
+							 $expired[] = "'".str_replace('timeout_', '', $expired_session)."'";
914 914
 						 }
915
-						 $expired = implode( ', ', $expired );
915
+						 $expired = implode(', ', $expired);
916 916
 						 $SQL = "
917 917
 						DELETE FROM {$wpdb->options}
918 918
 						WHERE option_name
919 919
 						IN ( $expired );
920 920
 					 ";
921
-						 $results = $wpdb->query( $SQL );
921
+						 $results = $wpdb->query($SQL);
922 922
 						 // if something went wrong, then notify the admin
923
-						 if ( $results instanceof WP_Error && is_admin() ) {
924
-							 EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
923
+						 if ($results instanceof WP_Error && is_admin()) {
924
+							 EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
925 925
 						 }
926 926
 					 }
927
-					 do_action( 'FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit );
927
+					 do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit);
928 928
 				 }
929 929
 			 }
930 930
 		 }
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	 /**
342 342
 	  * retrieve session data
343 343
 	  * @access    public
344
-	  * @param null $key
344
+	  * @param string|null $key
345 345
 	  * @param bool $reset_cache
346 346
 	  * @return    array
347 347
 	  */
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 	  * set session data
365 365
 	  * @access 	public
366 366
 	  * @param 	array $data
367
-	  * @return 	TRUE on success, FALSE on fail
367
+	  * @return 	boolean on success, FALSE on fail
368 368
 	  */
369 369
 	public function set_session_data( $data ) {
370 370
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	 /**
393 393
 	  * @initiate session
394 394
 	  * @access   private
395
-	  * @return TRUE on success, FALSE on fail
395
+	  * @return boolean on success, FALSE on fail
396 396
 	  * @throws \EE_Error
397 397
 	  */
398 398
 	private function _espresso_session() {
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 	  * @update session data  prior to saving to the db
532 532
 	  * @access public
533 533
 	  * @param bool $new_session
534
-	  * @return TRUE on success, FALSE on fail
534
+	  * @return boolean on success, FALSE on fail
535 535
 	  */
536 536
 	public function update( $new_session = FALSE ) {
537 537
 		$this->_session_data = isset( $this->_session_data )
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 	  * @access public
798 798
 	  * @param array $data_to_reset
799 799
 	  * @param bool  $show_all_notices
800
-	  * @return TRUE on success, FALSE on fail
800
+	  * @return boolean on success, FALSE on fail
801 801
 	  */
802 802
 	public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) {
803 803
 		// if $data_to_reset is not in an array, then put it in one
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  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')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  *
4 6
  * Event Espresso
@@ -353,7 +355,7 @@  discard block
 block discarded – undo
353 355
 		}
354 356
 		 if ( ! empty( $key ))  {
355 357
 			return  isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL;
356
-		}  else  {
358
+		} else  {
357 359
 			return $this->_session_data;
358 360
 		}
359 361
 	}
Please login to merge, or discard this patch.
payment_methods/Invoice/EE_PMT_Invoice.pm.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EE_PMT_Invoice extends EE_PMT_Base{
28
+class EE_PMT_Invoice extends EE_PMT_Base {
29 29
 
30 30
 
31 31
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 */
37 37
 	public function __construct($pm_instance = NULL) {
38 38
 		$this->_pretty_name = __("Invoice", 'event_espresso');
39
-		$this->_default_description = __( 'After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.', 'event_espresso' );
39
+		$this->_default_description = __('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.', 'event_espresso');
40 40
 		parent::__construct($pm_instance);
41 41
 		$this->_default_button_url = $this->file_url().'lib'.DS.'invoice-logo.png';
42 42
 	}
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param \EE_Transaction $transaction
49 49
 	 * @return NULL
50 50
 	 */
51
-	public function generate_new_billing_form( EE_Transaction $transaction = NULL ) {
51
+	public function generate_new_billing_form(EE_Transaction $transaction = NULL) {
52 52
 		return NULL;
53 53
 	}
54 54
 
@@ -61,53 +61,53 @@  discard block
 block discarded – undo
61 61
 	public function generate_new_settings_form() {
62 62
 		$pdf_payee_input_name = 'pdf_payee_name';
63 63
 		$confirmation_text_input_name = 'page_confirmation_text';
64
-		$form =  new EE_Payment_Method_Form(array(
64
+		$form = new EE_Payment_Method_Form(array(
65 65
 //				'payment_method_type' => $this,
66 66
 				'extra_meta_inputs'=>array(
67 67
 					$pdf_payee_input_name => new EE_Text_Input(array(
68
-						'html_label_text' => sprintf( __( 'Payee Name %s', 'event_espresso' ), $this->get_help_tab_link())
68
+						'html_label_text' => sprintf(__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
69 69
 					)),
70 70
 					'pdf_payee_email' => new EE_Email_Input(array(
71
-						'html_label_text' => sprintf( __( 'Payee Email %s', 'event_espresso' ), $this->get_help_tab_link()),
71
+						'html_label_text' => sprintf(__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
72 72
 					)),
73 73
 					'pdf_payee_tax_number' => new EE_Text_Input(array(
74
-						'html_label_text' => sprintf( __( 'Payee Tax Number %s', 'event_espresso' ), $this->get_help_tab_link()),
74
+						'html_label_text' => sprintf(__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
75 75
 						)),
76
-					'pdf_payee_address' => new EE_Text_Area_Input( array(
77
-						'html_label_text' => sprintf( __( 'Payee Address %s', 'event_espresso' ), $this->get_help_tab_link() ),
78
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
76
+					'pdf_payee_address' => new EE_Text_Area_Input(array(
77
+						'html_label_text' => sprintf(__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
78
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
79 79
 					)),
80 80
 					'pdf_instructions'=>new EE_Text_Area_Input(array(
81
-						'html_label_text'=>  sprintf(__("Instructions %s", "event_espresso"),  $this->get_help_tab_link()),
81
+						'html_label_text'=>  sprintf(__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
82 82
 						'default'=>  __("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
83
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
83
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
84 84
 					)),
85 85
 					'pdf_logo_image'=>new EE_Admin_File_Uploader_Input(array(
86
-						'html_label_text'=>  sprintf(__("Logo Image %s", "event_espresso"),  $this->get_help_tab_link()),
86
+						'html_label_text'=>  sprintf(__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
87 87
 						'default'=>  EE_Config::instance()->organization->logo_url,
88 88
 						'html_help_text'=>  __("(Logo for the top left of the invoice)", 'event_espresso'),
89 89
 					)),
90 90
 					$confirmation_text_input_name =>new EE_Text_Area_Input(array(
91
-						'html_label_text'=>  sprintf(__("Confirmation Text %s", "event_espresso"),  $this->get_help_tab_link()),
91
+						'html_label_text'=>  sprintf(__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
92 92
 						'default'=>  __("Payment must be received within 48 hours of event date.  Details about where to send payment is included on the invoice.", 'event_espresso'),
93
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
93
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
94 94
 					)),
95 95
 					'page_extra_info'=>new EE_Text_Area_Input(array(
96
-						'html_label_text'=>  sprintf(__("Extra Info %s", "event_espresso"),  $this->get_help_tab_link()),
97
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
96
+						'html_label_text'=>  sprintf(__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
97
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
98 98
 					)),
99 99
 				),
100 100
 				'include'=>array(
101
-					'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
102
-					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
101
+					'PMD_ID', 'PMD_name', 'PMD_desc', 'PMD_admin_name', 'PMD_admin_desc', 'PMD_type', 'PMD_slug', 'PMD_open_by_default', 'PMD_button_url', 'PMD_scope', 'Currency', 'PMD_order',
102
+					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions', 'pdf_logo_image',
103 103
 					$confirmation_text_input_name, 'page_extra_info'),
104 104
 			));
105 105
 		$form->add_subsections(
106
-			array( 'header1' => new EE_Form_Section_HTML_From_Template( 'payment_methods/Invoice/templates/invoice_settings_header_display.template.php' )),
106
+			array('header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
107 107
 			$pdf_payee_input_name
108 108
 		);
109 109
 		$form->add_subsections(
110
-			array( 'header2'=>new EE_Form_Section_HTML_From_Template( 'payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php' )),
110
+			array('header2'=>new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
111 111
 			$confirmation_text_input_name
112 112
 		);
113 113
 		return $form;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @see EE_PMT_Base::help_tabs_config()
121 121
 	 * @return array
122 122
 	 */
123
-	public function help_tabs_config(){
123
+	public function help_tabs_config() {
124 124
 		return array(
125 125
 			$this->get_help_tab_name() => array(
126 126
 				'title' => __('Invoice Settings', 'event_espresso'),
@@ -138,17 +138,17 @@  discard block
 block discarded – undo
138 138
 	 * @param \EE_Payment $payment
139 139
 	 * @return string
140 140
 	 */
141
-	public function payment_overview_content( EE_Payment $payment ){
141
+	public function payment_overview_content(EE_Payment $payment) {
142 142
 		EE_Registry::instance()->load_helper('Template');
143 143
 		return EEH_Template::locate_template(
144
-			'payment_methods' . DS . 'Invoice'. DS . 'templates'.DS.'invoice_payment_details_content.template.php',
144
+			'payment_methods'.DS.'Invoice'.DS.'templates'.DS.'invoice_payment_details_content.template.php',
145 145
 			array_merge(
146 146
 				array(
147 147
 					'payment_method'			=> $this->_pm_instance,
148 148
 					'payment'						=> $payment,
149 149
 					'page_confirmation_text'					=> '',
150 150
 					'page_extra_info'	=> '',
151
-					'invoice_url' 					=> $payment->transaction()->primary_registration()->invoice_url( 'html' )
151
+					'invoice_url' 					=> $payment->transaction()->primary_registration()->invoice_url('html')
152 152
 				),
153 153
 				$this->_pm_instance->all_extra_meta_array()
154 154
 			)
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if (!defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
Please login to merge, or discard this patch.
core/EE_Payment_Processor.core.php 1 patch
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 /**
4 4
  *
5 5
  * EE_Payment_Processor
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function instance() {
29 29
 		// check if class object is instantiated
30
-		if ( ! self::$_instance instanceof EE_Payment_Processor ) {
30
+		if ( ! self::$_instance instanceof EE_Payment_Processor) {
31 31
 			self::$_instance = new self();
32 32
 		}
33 33
 		return self::$_instance;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 *@return EE_Payment_Processor
43 43
 	 */
44 44
 	private function __construct() {
45
-		do_action( 'AHEE__EE_Payment_Processor__construct' );
45
+		do_action('AHEE__EE_Payment_Processor__construct');
46 46
 	}
47 47
 
48 48
 
@@ -64,42 +64,42 @@  discard block
 block discarded – undo
64 64
 	 * @param string 	       						$cancel_url 	URL to return to if off-site payments are cancelled
65 65
 	 * @return EE_Payment
66 66
 	 */
67
-	public function process_payment( EE_Payment_Method $payment_method, EE_Transaction $transaction, $amount = NULL, $billing_form = NULL, $return_url = NULL, $method = 'CART', $by_admin = FALSE, $update_txn = TRUE, $cancel_url = '' ) {
68
-		if( $amount < 0 ) {
67
+	public function process_payment(EE_Payment_Method $payment_method, EE_Transaction $transaction, $amount = NULL, $billing_form = NULL, $return_url = NULL, $method = 'CART', $by_admin = FALSE, $update_txn = TRUE, $cancel_url = '') {
68
+		if ($amount < 0) {
69 69
 			throw new EE_Error( 
70 70
 					sprintf(
71
-							__( 'Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', 'event_espresso' ),
71
+							__('Attempting to make a payment for a negative amount of %1$d for transaction %2$d. That should be a refund', 'event_espresso'),
72 72
 							$amount,
73 73
 							$transaction->ID() ) );
74 74
 		}
75 75
 		// verify payment method
76
-		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj( $payment_method, TRUE );
76
+		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, TRUE);
77 77
 		// verify transaction
78
-		EEM_Transaction::instance()->ensure_is_obj( $transaction );
79
-		$transaction->set_payment_method_ID( $payment_method->ID() );
78
+		EEM_Transaction::instance()->ensure_is_obj($transaction);
79
+		$transaction->set_payment_method_ID($payment_method->ID());
80 80
 		// verify payment method type
81
-		if ( $payment_method->type_obj() instanceof EE_PMT_Base ){
81
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
82 82
 			$payment = $payment_method->type_obj()->process_payment(
83 83
 				$transaction,
84
-				min( $amount, $transaction->remaining() ),//make sure we don't overcharge
84
+				min($amount, $transaction->remaining()), //make sure we don't overcharge
85 85
 				$billing_form,
86 86
 				$return_url,
87
-				add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ),
87
+				add_query_arg(array('ee_cancel_payment' => true), $return_url),
88 88
 				$method,
89 89
 				$by_admin
90 90
 			);
91 91
 			// check if payment method uses an off-site gateway
92
-			if ( $payment_method->type_obj()->payment_occurs() != EE_PMT_Base::offsite ) {
92
+			if ($payment_method->type_obj()->payment_occurs() != EE_PMT_Base::offsite) {
93 93
 				// don't process payments for off-site gateways yet because no payment has occurred yet
94
-				$this->update_txn_based_on_payment( $transaction, $payment, $update_txn );
94
+				$this->update_txn_based_on_payment($transaction, $payment, $update_txn);
95 95
 			}
96 96
 			return $payment;
97 97
 		} else {
98 98
 			EE_Error::add_error(
99 99
 				sprintf(
100
-					__( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
100
+					__('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
101 101
 					'<br/>',
102
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
102
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
103 103
 				), __FILE__, __FUNCTION__, __LINE__
104 104
 			);
105 105
 			return NULL;
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 	 * @throws EE_Error
116 116
 	 * @return string
117 117
 	 */
118
-	public function get_ipn_url_for_payment_method( $transaction, $payment_method ){
118
+	public function get_ipn_url_for_payment_method($transaction, $payment_method) {
119 119
 		/** @type EE_Transaction $transaction */
120
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
120
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
121 121
 		$primary_reg = $transaction->primary_registration();
122
-		if( ! $primary_reg instanceof EE_Registration ){
123
-			throw new EE_Error(sprintf(__("Cannot get IPN URL for transaction with ID %d because it has no primary registration", "event_espresso"),$transaction->ID()));
122
+		if ( ! $primary_reg instanceof EE_Registration) {
123
+			throw new EE_Error(sprintf(__("Cannot get IPN URL for transaction with ID %d because it has no primary registration", "event_espresso"), $transaction->ID()));
124 124
 		}
125
-		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method,true);
125
+		$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method, true);
126 126
 		$url = add_query_arg(
127 127
 			array(
128 128
 				'e_reg_url_link'=>$primary_reg->reg_url_link(),
@@ -149,81 +149,81 @@  discard block
 block discarded – undo
149 149
 	 * @throws Exception
150 150
 	 * @return EE_Payment
151 151
 	 */
152
-	public function process_ipn( $_req_data, $transaction = NULL, $payment_method = NULL, $update_txn = true, $separate_IPN_request = true ){
153
-		$_req_data = $this->_remove_unusable_characters( $_req_data );
154
-		EE_Registry::instance()->load_model( 'Change_Log' );
155
-		EE_Processor_Base::set_IPN( $separate_IPN_request );
156
-		if( $transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method ){
157
-			$obj_for_log = EEM_Payment::instance()->get_one( array( array( 'TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID() ), 'order_by' => array( 'PAY_timestamp' => 'desc' ) ) );
158
-		}elseif( $payment_method instanceof EE_Payment ){
152
+	public function process_ipn($_req_data, $transaction = NULL, $payment_method = NULL, $update_txn = true, $separate_IPN_request = true) {
153
+		$_req_data = $this->_remove_unusable_characters($_req_data);
154
+		EE_Registry::instance()->load_model('Change_Log');
155
+		EE_Processor_Base::set_IPN($separate_IPN_request);
156
+		if ($transaction instanceof EE_Transaction && $payment_method instanceof EE_Payment_Method) {
157
+			$obj_for_log = EEM_Payment::instance()->get_one(array(array('TXN_ID' => $transaction->ID(), 'PMD_ID' => $payment_method->ID()), 'order_by' => array('PAY_timestamp' => 'desc')));
158
+		}elseif ($payment_method instanceof EE_Payment) {
159 159
 			$obj_for_log = $payment_method;
160
-		}elseif( $transaction instanceof EE_Transaction ){
160
+		}elseif ($transaction instanceof EE_Transaction) {
161 161
 			$obj_for_log = $transaction;
162
-		}else{
162
+		} else {
163 163
 			$obj_for_log = null;
164 164
 		}
165 165
 		$log = EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data received'=>$_req_data), $obj_for_log);
166
-		try{
166
+		try {
167 167
 			/**
168 168
 			 * @var EE_Payment $payment
169 169
 			 */
170 170
 			$payment = NULL;
171
-			if($transaction && $payment_method){
171
+			if ($transaction && $payment_method) {
172 172
 				/** @type EE_Transaction $transaction */
173 173
 				$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
174 174
 				/** @type EE_Payment_Method $payment_method */
175 175
 				$payment_method = EEM_Payment_Method::instance()->ensure_is_obj($payment_method);
176
-				if ( $payment_method->type_obj() instanceof EE_PMT_Base ) {
177
-						$payment = $payment_method->type_obj()->handle_ipn( $_req_data, $transaction );
176
+				if ($payment_method->type_obj() instanceof EE_PMT_Base) {
177
+						$payment = $payment_method->type_obj()->handle_ipn($_req_data, $transaction);
178 178
 						$log->set_object($payment);
179 179
 				} else {
180 180
 					// not a payment
181 181
 					EE_Error::add_error(
182 182
 						sprintf(
183
-							__( 'A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso' ),
183
+							__('A valid payment method could not be determined due to a technical issue.%sPlease refresh your browser and try again or contact %s for assistance.', 'event_espresso'),
184 184
 							'<br/>',
185
-							EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
185
+							EE_Registry::instance()->CFG->organization->get_pretty('email')
186 186
 						),
187 187
 						__FILE__, __FUNCTION__, __LINE__
188 188
 					);
189 189
 				}
190
-			}else{
190
+			} else {
191 191
 				//that's actually pretty ok. The IPN just wasn't able
192 192
 				//to identify which transaction or payment method this was for
193 193
 				// give all active payment methods a chance to claim it
194 194
 				$active_pms = EEM_Payment_Method::instance()->get_all_active();
195
-				foreach( $active_pms as $payment_method ){
196
-					try{
197
-						$payment = $payment_method->type_obj()->handle_unclaimed_ipn( $_req_data );
195
+				foreach ($active_pms as $payment_method) {
196
+					try {
197
+						$payment = $payment_method->type_obj()->handle_unclaimed_ipn($_req_data);
198 198
 						EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment);
199 199
 						break;
200
-					} catch( EE_Error $e ) {
200
+					} catch (EE_Error $e) {
201 201
 						//that's fine- it apparently couldn't handle the IPN
202 202
 					}
203 203
 				}
204 204
 
205 205
 			}
206 206
 // 			EEM_Payment_Log::instance()->log("got to 7",$transaction,$payment_method);
207
-			if( $payment instanceof EE_Payment){
207
+			if ($payment instanceof EE_Payment) {
208 208
 				$payment->save();
209 209
 				//  update the TXN
210
-				$this->update_txn_based_on_payment( $transaction, $payment, $update_txn, $separate_IPN_request );
211
-			}else{
210
+				$this->update_txn_based_on_payment($transaction, $payment, $update_txn, $separate_IPN_request);
211
+			} else {
212 212
 				//we couldn't find the payment for this IPN... let's try and log at least SOMETHING
213
-				if($payment_method){
213
+				if ($payment_method) {
214 214
 					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $payment_method);
215
-				}elseif($transaction){
215
+				}elseif ($transaction) {
216 216
 					EEM_Change_Log::instance()->log(EEM_Change_Log::type_gateway, array('IPN data'=>$_req_data), $transaction);
217 217
 				}
218 218
 			}
219 219
 			return $payment;
220 220
 
221
-		} catch( EE_Error $e ) {
221
+		} catch (EE_Error $e) {
222 222
 			do_action(
223 223
 				'AHEE__log', __FILE__, __FUNCTION__, sprintf(
224
-					__( 'Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso' ),
225
-					print_r( $transaction, TRUE ),
226
-					print_r( $_req_data, TRUE ),
224
+					__('Error occurred while receiving IPN. Transaction: %1$s, req data: %2$s. The error was "%3$s"', 'event_espresso'),
225
+					print_r($transaction, TRUE),
226
+					print_r($_req_data, TRUE),
227 227
 					$e->getMessage()
228 228
 				)
229 229
 			);
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
 	 * @param array $request_data
238 238
 	 * @return array|string
239 239
 	 */
240
-	protected function _remove_unusable_characters( $request_data ) {
241
-		if( is_array( $request_data ) ) {
240
+	protected function _remove_unusable_characters($request_data) {
241
+		if (is_array($request_data)) {
242 242
 			$return_data = array();
243
-			foreach( $request_data as $key => $value ) {
244
-				$return_data[ $this->_remove_unusable_characters( $key ) ] = $this->_remove_unusable_characters( $value );
243
+			foreach ($request_data as $key => $value) {
244
+				$return_data[$this->_remove_unusable_characters($key)] = $this->_remove_unusable_characters($value);
245 245
 			}
246
-		}else{
247
-			$return_data =  preg_replace('/[^[:print:]]/', '', $request_data);
246
+		} else {
247
+			$return_data = preg_replace('/[^[:print:]]/', '', $request_data);
248 248
 		}
249 249
 		return $return_data;
250 250
 	}
@@ -266,13 +266,13 @@  discard block
 block discarded – undo
266 266
 	 * @return EE_Payment
267 267
 	 * @deprecated 4.6.24 method is no longer used. Instead it is up to client code, like SPCO, to call handle_ipn() for offsite gateways that don't receive separate IPNs
268 268
 	 */
269
-	public function finalize_payment_for( $transaction, $update_txn = TRUE ){
269
+	public function finalize_payment_for($transaction, $update_txn = TRUE) {
270 270
 		/** @var $transaction EE_Transaction */
271
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
271
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
272 272
 		$last_payment_method = $transaction->payment_method();
273
-		if ( $last_payment_method instanceof EE_Payment_Method ) {
274
-			$payment = $last_payment_method->type_obj()->finalize_payment_for( $transaction );
275
-			$this->update_txn_based_on_payment( $transaction, $payment, $update_txn );
273
+		if ($last_payment_method instanceof EE_Payment_Method) {
274
+			$payment = $last_payment_method->type_obj()->finalize_payment_for($transaction);
275
+			$this->update_txn_based_on_payment($transaction, $payment, $update_txn);
276 276
 			return $payment;
277 277
 		} else {
278 278
 			return NULL;
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 	 * @internal param float $amount
290 290
 	 * @return EE_Payment
291 291
 	 */
292
-	public function process_refund( EE_Payment_Method $payment_method, EE_Payment $payment_to_refund, $refund_info = array() ){
293
-		if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds() ) {
294
-			$payment_method->type_obj()->process_refund( $payment_to_refund, $refund_info );
295
-			$this->update_txn_based_on_payment( $payment_to_refund->transaction(), $payment_to_refund );
292
+	public function process_refund(EE_Payment_Method $payment_method, EE_Payment $payment_to_refund, $refund_info = array()) {
293
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj()->supports_sending_refunds()) {
294
+			$payment_method->type_obj()->process_refund($payment_to_refund, $refund_info);
295
+			$this->update_txn_based_on_payment($payment_to_refund->transaction(), $payment_to_refund);
296 296
 		}
297 297
 		return $payment_to_refund;
298 298
 	}
@@ -334,12 +334,12 @@  discard block
 block discarded – undo
334 334
 	 *                        TXN is locked before updating
335 335
 	 * @throws \EE_Error
336 336
 	 */
337
-	public function update_txn_based_on_payment( $transaction, $payment, $update_txn = true, $IPN = false ){
337
+	public function update_txn_based_on_payment($transaction, $payment, $update_txn = true, $IPN = false) {
338 338
 		$do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__not_successful';
339 339
 		/** @type EE_Transaction $transaction */
340
-		$transaction = EEM_Transaction::instance()->ensure_is_obj( $transaction );
340
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
341 341
 		// can we freely update the TXN at this moment?
342
-		if ( $IPN && $transaction->is_locked() ) {
342
+		if ($IPN && $transaction->is_locked()) {
343 343
 			// don't update the transaction at this exact moment
344 344
 			// because the TXN is active in another request
345 345
 			EE_Cron_Tasks::schedule_update_transaction_with_payment(
@@ -349,40 +349,40 @@  discard block
 block discarded – undo
349 349
 			);
350 350
 		} else {
351 351
 			// verify payment and that it has been saved
352
-			if ( $payment instanceof EE_Payment && $payment->ID() ) {
353
-				if( $payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->type_obj() instanceof EE_PMT_Base ){
354
-					$payment->payment_method()->type_obj()->update_txn_based_on_payment( $payment );
352
+			if ($payment instanceof EE_Payment && $payment->ID()) {
353
+				if ($payment->payment_method() instanceof EE_Payment_Method && $payment->payment_method()->type_obj() instanceof EE_PMT_Base) {
354
+					$payment->payment_method()->type_obj()->update_txn_based_on_payment($payment);
355 355
 					// update TXN registrations with payment info
356
-					$this->process_registration_payments( $transaction, $payment );
356
+					$this->process_registration_payments($transaction, $payment);
357 357
 				}
358 358
 				$do_action = $payment->just_approved() ? 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__successful' : $do_action;
359 359
 			} else {
360 360
 				// send out notifications
361
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
361
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
362 362
 				$do_action = 'AHEE__EE_Payment_Processor__update_txn_based_on_payment__no_payment_made';
363 363
 			}
364 364
 			// if this is an IPN, then we want to know the initial TXN status prior to updating the TXN
365 365
 			// so that we know whether the status has changed and notifications should be triggered
366
-			if ( $IPN ) {
366
+			if ($IPN) {
367 367
 				/** @type EE_Transaction_Processor $transaction_processor */
368
-				$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
369
-				$transaction_processor->set_old_txn_status( $transaction->status_ID() );
368
+				$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
369
+				$transaction_processor->set_old_txn_status($transaction->status_ID());
370 370
 			}
371
-			if ( $payment->status() !== EEM_Payment::status_id_failed ) {
371
+			if ($payment->status() !== EEM_Payment::status_id_failed) {
372 372
 				/** @type EE_Transaction_Payments $transaction_payments */
373
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
373
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
374 374
 				// set new value for total paid
375
-				$transaction_payments->calculate_total_payments_and_update_status( $transaction );
375
+				$transaction_payments->calculate_total_payments_and_update_status($transaction);
376 376
 				// call EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment() ???
377
-				if ( $update_txn ) {
378
-					$this->_post_payment_processing( $transaction, $payment, $IPN );
377
+				if ($update_txn) {
378
+					$this->_post_payment_processing($transaction, $payment, $IPN);
379 379
 				}
380 380
 			}
381 381
 			// granular hook for others to use.
382
-			do_action( $do_action, $transaction, $payment );
383
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action' );
382
+			do_action($do_action, $transaction, $payment);
383
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $do_action, '$do_action');
384 384
 			//global hook for others to use.
385
-			do_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment );
385
+			do_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', $transaction, $payment);
386 386
 		}
387 387
 	}
388 388
 
@@ -396,25 +396,25 @@  discard block
 block discarded – undo
396 396
 	 * @param EE_Registration[] $registrations
397 397
 	 * @throws \EE_Error
398 398
 	 */
399
-	public function process_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $registrations = array() ) {
399
+	public function process_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $registrations = array()) {
400 400
 		// only process if payment was successful
401
-		if ( $payment->status() !== EEM_Payment::status_id_approved ) {
401
+		if ($payment->status() !== EEM_Payment::status_id_approved) {
402 402
 			return;
403 403
 		}
404 404
 		//EEM_Registration::instance()->show_next_x_db_queries();
405
-		if ( empty( $registrations )) {
405
+		if (empty($registrations)) {
406 406
 			// find registrations with monies owing that can receive a payment
407
-			$registrations = $transaction->registrations( array(
407
+			$registrations = $transaction->registrations(array(
408 408
 				array(
409 409
 					// only these reg statuses can receive payments
410
-					'STS_ID'  => array( 'IN', EEM_Registration::reg_statuses_that_allow_payment() ),
411
-					'REG_final_price'  => array( '!=', 0 ),
412
-					'REG_final_price*' => array( '!=', 'REG_paid', true ),
410
+					'STS_ID'  => array('IN', EEM_Registration::reg_statuses_that_allow_payment()),
411
+					'REG_final_price'  => array('!=', 0),
412
+					'REG_final_price*' => array('!=', 'REG_paid', true),
413 413
 				)
414
-			) );
414
+			));
415 415
 		}
416 416
 		// still nothing ??!??
417
-		if ( empty( $registrations )) {
417
+		if (empty($registrations)) {
418 418
 			return;
419 419
 		}
420 420
 		// todo: break out the following logic into a separate strategy class
@@ -426,28 +426,28 @@  discard block
 block discarded – undo
426 426
 
427 427
 		$refund = $payment->is_a_refund();
428 428
 		// how much is available to apply to registrations?
429
-		$available_payment_amount = abs( $payment->amount() );
430
-		foreach ( $registrations as $registration ) {
431
-			if ( $registration instanceof EE_Registration ) {
429
+		$available_payment_amount = abs($payment->amount());
430
+		foreach ($registrations as $registration) {
431
+			if ($registration instanceof EE_Registration) {
432 432
 				// nothing left?
433
-				if ( $available_payment_amount <= 0 ) {
433
+				if ($available_payment_amount <= 0) {
434 434
 					break;
435 435
 				}
436
-				if ( $refund ) {
437
-					$available_payment_amount = $this->process_registration_refund( $registration, $payment, $available_payment_amount );
436
+				if ($refund) {
437
+					$available_payment_amount = $this->process_registration_refund($registration, $payment, $available_payment_amount);
438 438
 				} else {
439
-					$available_payment_amount = $this->process_registration_payment( $registration, $payment, $available_payment_amount );
439
+					$available_payment_amount = $this->process_registration_payment($registration, $payment, $available_payment_amount);
440 440
 				}
441 441
 			}
442 442
 		}
443
-		if ( $available_payment_amount > 0 && apply_filters( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false ) ) {
443
+		if ($available_payment_amount > 0 && apply_filters('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', false)) {
444 444
 			EE_Error::add_attention(
445 445
 				sprintf(
446
-					__( 'A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso' ),
447
-					EEH_Template::format_currency( $available_payment_amount ),
448
-					implode( ', ',  array_keys( $registrations ) ),
446
+					__('A remainder of %1$s exists after applying this payment to Registration(s) %2$s.%3$sPlease verify that the original payment amount of %4$s is correct. If so, you should edit this payment and select at least one additional registration in the "Registrations to Apply Payment to" section, so that the remainder of this payment can be applied to the additional registration(s).', 'event_espresso'),
447
+					EEH_Template::format_currency($available_payment_amount),
448
+					implode(', ', array_keys($registrations)),
449 449
 					'<br/>',
450
-					EEH_Template::format_currency( $payment->amount() )
450
+					EEH_Template::format_currency($payment->amount())
451 451
 				),
452 452
 				__FILE__, __FUNCTION__, __LINE__
453 453
 			);
@@ -464,17 +464,17 @@  discard block
 block discarded – undo
464 464
 	 * @param float $available_payment_amount
465 465
 	 * @return float
466 466
 	 */
467
-	public function process_registration_payment( EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00 ) {
467
+	public function process_registration_payment(EE_Registration $registration, EE_Payment $payment, $available_payment_amount = 0.00) {
468 468
 		$owing = $registration->final_price() - $registration->paid();
469
-		if ( $owing > 0 ) {
469
+		if ($owing > 0) {
470 470
 			// don't allow payment amount to exceed the available payment amount, OR the amount owing
471
-			$payment_amount = min( $available_payment_amount, $owing );
471
+			$payment_amount = min($available_payment_amount, $owing);
472 472
 			// update $available_payment_amount
473 473
 			$available_payment_amount = $available_payment_amount - $payment_amount;
474 474
 			//calculate and set new REG_paid
475
-			$registration->set_paid( $registration->paid() + $payment_amount );
475
+			$registration->set_paid($registration->paid() + $payment_amount);
476 476
 			// now save it
477
-			$this->_apply_registration_payment( $registration, $payment, $payment_amount );
477
+			$this->_apply_registration_payment($registration, $payment, $payment_amount);
478 478
 		}
479 479
 		return $available_payment_amount;
480 480
 	}
@@ -489,19 +489,19 @@  discard block
 block discarded – undo
489 489
 	 * @param float $payment_amount
490 490
 	 * @return float
491 491
 	 */
492
-	protected function _apply_registration_payment( EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00 ) {
492
+	protected function _apply_registration_payment(EE_Registration $registration, EE_Payment $payment, $payment_amount = 0.00) {
493 493
 		// find any existing reg payment records for this registration and payment
494 494
 		$existing_reg_payment = EEM_Registration_Payment::instance()->get_one(
495
-			array( array( 'REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID() ) )
495
+			array(array('REG_ID' => $registration->ID(), 'PAY_ID' => $payment->ID()))
496 496
 		);
497 497
 		// if existing registration payment exists
498
-		if ( $existing_reg_payment instanceof EE_Registration_Payment ) {
498
+		if ($existing_reg_payment instanceof EE_Registration_Payment) {
499 499
 			// then update that record
500
-			$existing_reg_payment->set_amount( $payment_amount );
500
+			$existing_reg_payment->set_amount($payment_amount);
501 501
 			$existing_reg_payment->save();
502 502
 		} else {
503 503
 			// or add new relation between registration and payment and set amount
504
-			$registration->_add_relation_to( $payment, 'Payment', array( 'RPY_amount' => $payment_amount ) );
504
+			$registration->_add_relation_to($payment, 'Payment', array('RPY_amount' => $payment_amount));
505 505
 			// make it stick
506 506
 			$registration->save();
507 507
 		}
@@ -517,21 +517,21 @@  discard block
 block discarded – undo
517 517
 	 * @param float $available_refund_amount - IMPORTANT !!! SEND AVAILABLE REFUND AMOUNT AS A POSITIVE NUMBER
518 518
 	 * @return float
519 519
 	 */
520
-	public function process_registration_refund( EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00 ) {
520
+	public function process_registration_refund(EE_Registration $registration, EE_Payment $payment, $available_refund_amount = 0.00) {
521 521
 		//EEH_Debug_Tools::printr( $payment->amount(), '$payment->amount()', __FILE__, __LINE__ );
522
-		if ( $registration->paid() > 0 ) {
522
+		if ($registration->paid() > 0) {
523 523
 			// ensure $available_refund_amount is NOT negative
524
-			$available_refund_amount = abs( $available_refund_amount );
524
+			$available_refund_amount = abs($available_refund_amount);
525 525
 			// don't allow refund amount to exceed the available payment amount, OR the amount paid
526
-			$refund_amount = min( $available_refund_amount, $registration->paid() );
526
+			$refund_amount = min($available_refund_amount, $registration->paid());
527 527
 			// update $available_payment_amount
528 528
 			$available_refund_amount = $available_refund_amount - $refund_amount;
529 529
 			//calculate and set new REG_paid
530
-			$registration->set_paid( $registration->paid() - $refund_amount );
530
+			$registration->set_paid($registration->paid() - $refund_amount);
531 531
 			// convert payment amount back to a negative value for storage in the db
532
-			$refund_amount = abs( $refund_amount ) * -1;
532
+			$refund_amount = abs($refund_amount) * -1;
533 533
 			// now save it
534
-			$this->_apply_registration_payment( $registration, $payment, $refund_amount );
534
+			$this->_apply_registration_payment($registration, $payment, $refund_amount);
535 535
 		}
536 536
 		return $available_refund_amount;
537 537
 	}
@@ -549,12 +549,12 @@  discard block
 block discarded – undo
549 549
 	 * @param EE_Payment     $payment
550 550
 	 * @param bool           $IPN
551 551
 	 */
552
-	protected function _post_payment_processing( EE_Transaction $transaction, EE_Payment $payment, $IPN = false ) {
552
+	protected function _post_payment_processing(EE_Transaction $transaction, EE_Payment $payment, $IPN = false) {
553 553
 
554 554
 		/** @type EE_Transaction_Processor $transaction_processor */
555
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
555
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
556 556
 		// is the Payment Options Reg Step completed ?
557
-		$payment_options_step_completed = $transaction_processor->reg_step_completed( $transaction, 'payment_options' );
557
+		$payment_options_step_completed = $transaction_processor->reg_step_completed($transaction, 'payment_options');
558 558
 		// DEBUG LOG
559 559
 		//$this->log(
560 560
 		//	__CLASS__, __FUNCTION__, __LINE__,
@@ -567,14 +567,14 @@  discard block
 block discarded – undo
567 567
 		// if the Payment Options Reg Step is completed...
568 568
 		$revisit = $payment_options_step_completed === true ? true : false;
569 569
 		// then this is kinda sorta a revisit with regards to payments at least
570
-		$transaction_processor->set_revisit( $revisit );
570
+		$transaction_processor->set_revisit($revisit);
571 571
 		// if this is an IPN, let's consider the Payment Options Reg Step completed if not already
572 572
 		if (
573 573
 			$IPN &&
574 574
 			$payment_options_step_completed !== true &&
575
-			( $payment->is_approved() || $payment->is_pending() )
575
+			($payment->is_approved() || $payment->is_pending())
576 576
 		) {
577
-			$payment_options_step_completed = $transaction_processor->set_reg_step_completed( $transaction, 'payment_options' );
577
+			$payment_options_step_completed = $transaction_processor->set_reg_step_completed($transaction, 'payment_options');
578 578
 		}
579 579
 		// DEBUG LOG
580 580
 		//$this->log(
@@ -586,11 +586,11 @@  discard block
 block discarded – undo
586 586
 		//	)
587 587
 		//);
588 588
 		/** @type EE_Transaction_Payments $transaction_payments */
589
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
589
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
590 590
 		// maybe update status, but don't save transaction just yet
591
-		$transaction_payments->update_transaction_status_based_on_total_paid( $transaction, false );
591
+		$transaction_payments->update_transaction_status_based_on_total_paid($transaction, false);
592 592
 		// check if 'finalize_registration' step has been completed...
593
-		$finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' );
593
+		$finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration');
594 594
 		// DEBUG LOG
595 595
 		//$this->log(
596 596
 		//	__CLASS__, __FUNCTION__, __LINE__,
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 		//	)
602 602
 		//);
603 603
 		//  if this is an IPN and the final step has not been initiated
604
-		if ( $IPN && $payment_options_step_completed && $finalized === false ) {
604
+		if ($IPN && $payment_options_step_completed && $finalized === false) {
605 605
 			// and if it hasn't already been set as being started...
606
-			$finalized = $transaction_processor->set_reg_step_initiated( $transaction, 'finalize_registration' );
606
+			$finalized = $transaction_processor->set_reg_step_initiated($transaction, 'finalize_registration');
607 607
 			// DEBUG LOG
608 608
 			//$this->log(
609 609
 			//	__CLASS__, __FUNCTION__, __LINE__,
@@ -616,13 +616,13 @@  discard block
 block discarded – undo
616 616
 		}
617 617
 		$transaction->save();
618 618
 		// because the above will return false if the final step was not fully completed, we need to check again...
619
-		if ( $IPN && $finalized !== false ) {
619
+		if ($IPN && $finalized !== false) {
620 620
 			// and if we are all good to go, then send out notifications
621
-			add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
621
+			add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
622 622
 			// DEBUG LOG
623 623
 			//$this->log( __CLASS__, __FUNCTION__, __LINE__, $transaction );
624 624
 			//ok, now process the transaction according to the payment
625
-			$transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $transaction, $payment );
625
+			$transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($transaction, $payment);
626 626
 		}
627 627
 		// DEBUG LOG
628 628
 		//$this->log(
Please login to merge, or discard this patch.
core/db_classes/EE_Ticket.class.php 2 patches
Spacing   +181 added lines, -181 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
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 *                             		    date_format and the second value is the time format
67 67
 	 * @return EE_Ticket
68 68
 	 */
69
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
70
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
71
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
69
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
70
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
71
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
72 72
 	}
73 73
 
74 74
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	 *                          		the website will be used.
80 80
 	 * @return EE_Ticket
81 81
 	 */
82
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
83
-		return new self( $props_n_values, TRUE, $timezone );
82
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
83
+		return new self($props_n_values, TRUE, $timezone);
84 84
 	}
85 85
 
86 86
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return bool
90 90
 	 */
91 91
 	public function parent() {
92
-		return $this->get( 'TKT_parent' );
92
+		return $this->get('TKT_parent');
93 93
 	}
94 94
 
95 95
 
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 	 * @param  int $DTT_ID the primary key for a particular datetime
100 100
 	 * @return boolean
101 101
 	 */
102
-	public function available( $DTT_ID = 0 ) {
102
+	public function available($DTT_ID = 0) {
103 103
 		// are we checking availability for a particular datetime ?
104
-		if ( $DTT_ID ) {
104
+		if ($DTT_ID) {
105 105
 			// get that datetime object
106
-			$datetime = $this->get_first_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) );
106
+			$datetime = $this->get_first_related('Datetime', array(array('DTT_ID' => $DTT_ID)));
107 107
 			// if  ticket sales for this datetime have exceeded the reg limit...
108
-			if ( $datetime instanceof EE_Datetime && $datetime->sold_out() ) {
108
+			if ($datetime instanceof EE_Datetime && $datetime->sold_out()) {
109 109
 				return FALSE;
110 110
 			}
111 111
 		}
@@ -120,21 +120,21 @@  discard block
 block discarded – undo
120 120
 	 * @param bool $display true = we'll return a localized string, otherwise we just return the value of the relevant status const
121 121
 	 * @return mixed(int|string) status int if the display string isn't requested
122 122
 	 */
123
-	public function ticket_status( $display = FALSE ) {
124
-		if ( ! $this->is_remaining() ) {
125
-			return $display ? EEH_Template::pretty_status( EE_Ticket::sold_out, FALSE, 'sentence' ) : EE_Ticket::sold_out;
123
+	public function ticket_status($display = FALSE) {
124
+		if ( ! $this->is_remaining()) {
125
+			return $display ? EEH_Template::pretty_status(EE_Ticket::sold_out, FALSE, 'sentence') : EE_Ticket::sold_out;
126 126
 		}
127
-		if ( $this->get( 'TKT_deleted' ) ) {
128
-			return $display ? EEH_Template::pretty_status( EE_Ticket::archived, FALSE, 'sentence' ) : EE_Ticket::archived;
127
+		if ($this->get('TKT_deleted')) {
128
+			return $display ? EEH_Template::pretty_status(EE_Ticket::archived, FALSE, 'sentence') : EE_Ticket::archived;
129 129
 		}
130
-		if ( $this->is_expired() ) {
131
-			return $display ? EEH_Template::pretty_status( EE_Ticket::expired, FALSE, 'sentence' ) : EE_Ticket::expired;
130
+		if ($this->is_expired()) {
131
+			return $display ? EEH_Template::pretty_status(EE_Ticket::expired, FALSE, 'sentence') : EE_Ticket::expired;
132 132
 		}
133
-		if ( $this->is_pending() ) {
134
-			return $display ? EEH_Template::pretty_status( EE_Ticket::pending, FALSE, 'sentence' ) : EE_Ticket::pending;
133
+		if ($this->is_pending()) {
134
+			return $display ? EEH_Template::pretty_status(EE_Ticket::pending, FALSE, 'sentence') : EE_Ticket::pending;
135 135
 		}
136
-		if ( $this->is_on_sale() ) {
137
-			return $display ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence' ) : EE_Ticket::onsale;
136
+		if ($this->is_on_sale()) {
137
+			return $display ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : EE_Ticket::onsale;
138 138
 		}
139 139
 		return '';
140 140
 	}
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 	 * @param  int $DTT_ID if an int above 0 is included here then we get a specific dtt.
149 149
 	 * @return boolean         true = tickets remaining, false not.
150 150
 	 */
151
-	public function is_remaining( $DTT_ID = 0 ) {
152
-		$num_remaining = $this->remaining( $DTT_ID );
153
-		if ( $num_remaining === 0 ) {
151
+	public function is_remaining($DTT_ID = 0) {
152
+		$num_remaining = $this->remaining($DTT_ID);
153
+		if ($num_remaining === 0) {
154 154
 			return FALSE;
155 155
 		}
156
-		if ( $num_remaining > 0 && $num_remaining < $this->min() ) {
156
+		if ($num_remaining > 0 && $num_remaining < $this->min()) {
157 157
 			return FALSE;
158 158
 		}
159 159
 		return TRUE;
@@ -167,25 +167,25 @@  discard block
 block discarded – undo
167 167
 	 *                     all related datetimes
168 168
 	 * @return int
169 169
 	 */
170
-	public function remaining( $DTT_ID = 0 ) {
170
+	public function remaining($DTT_ID = 0) {
171 171
 		// are we checking availability for a particular datetime ?
172
-		if ( $DTT_ID ) {
172
+		if ($DTT_ID) {
173 173
 			// get array with the one requested datetime
174
-			$datetimes = $this->get_many_related( 'Datetime', array( array( 'DTT_ID' => $DTT_ID ) ) );
174
+			$datetimes = $this->get_many_related('Datetime', array(array('DTT_ID' => $DTT_ID)));
175 175
 		} else {
176 176
 			// we need to check availability of ALL datetimes
177
-			$datetimes = $this->get_many_related( 'Datetime', array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) );
177
+			$datetimes = $this->get_many_related('Datetime', array('order_by' => array('DTT_EVT_start' => 'ASC')));
178 178
 		}
179 179
 		//		d( $datetimes );
180 180
 		// if datetime reg limit is not unlimited
181
-		if ( ! empty( $datetimes ) ) {
181
+		if ( ! empty($datetimes)) {
182 182
 			// although TKT_qty and $datetime->spaces_remaining() could both be EE_INF
183 183
 			// we only need to check for EE_INF explicitly if we want to optimize.
184 184
 			// because EE_INF - x = EE_INF; and min(x,EE_INF) = x;
185 185
 			$tickets_remaining = $this->qty() - $this->sold();
186
-			foreach ( $datetimes as $datetime ) {
187
-				if ( $datetime instanceof EE_Datetime ) {
188
-					$tickets_remaining = min( $tickets_remaining, $datetime->spaces_remaining() );
186
+			foreach ($datetimes as $datetime) {
187
+				if ($datetime instanceof EE_Datetime) {
188
+					$tickets_remaining = min($tickets_remaining, $datetime->spaces_remaining());
189 189
 				}
190 190
 			}
191 191
 			return $tickets_remaining;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @return int
201 201
 	 */
202 202
 	function min() {
203
-		return $this->get( 'TKT_min' );
203
+		return $this->get('TKT_min');
204 204
 	}
205 205
 
206 206
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @return boolean
211 211
 	 */
212 212
 	public function is_expired() {
213
-		return ( $this->get_raw( 'TKT_end_date' ) < time() );
213
+		return ($this->get_raw('TKT_end_date') < time());
214 214
 	}
215 215
 
216 216
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return boolean
221 221
 	 */
222 222
 	public function is_pending() {
223
-		return ( $this->get_raw( 'TKT_start_date' ) > time() );
223
+		return ($this->get_raw('TKT_start_date') > time());
224 224
 	}
225 225
 
226 226
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @return boolean
231 231
 	 */
232 232
 	public function is_on_sale() {
233
-		return ( $this->get_raw( 'TKT_start_date' ) < time() && $this->get_raw( 'TKT_end_date' ) > time() );
233
+		return ($this->get_raw('TKT_start_date') < time() && $this->get_raw('TKT_end_date') > time());
234 234
 	}
235 235
 
236 236
 
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 	 * @param string 	$conjunction - conjunction junction what's your function ? this string joins the start date with the end date ie: Jan 01 "to" Dec 31
242 242
 	 * @return array
243 243
 	 */
244
-	public function date_range( $dt_frmt = '', $conjunction = ' - ' ) {
245
-		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date( $dt_frmt ) : '';
246
-		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date( $dt_frmt ) : '';
244
+	public function date_range($dt_frmt = '', $conjunction = ' - ') {
245
+		$first_date = $this->first_datetime() instanceof EE_Datetime ? $this->first_datetime()->start_date($dt_frmt) : '';
246
+		$last_date = $this->last_datetime() instanceof EE_Datetime ? $this->last_datetime()->end_date($dt_frmt) : '';
247 247
 
248
-		return $first_date && $last_date ? $first_date . $conjunction  . $last_date : '';
248
+		return $first_date && $last_date ? $first_date.$conjunction.$last_date : '';
249 249
 	}
250 250
 
251 251
 
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 	 * @return EE_Datetime
256 256
 	 */
257 257
 	public function first_datetime() {
258
-		$datetimes = $this->datetimes( array( 'limit' => 1 ) );
259
-		return reset( $datetimes );
258
+		$datetimes = $this->datetimes(array('limit' => 1));
259
+		return reset($datetimes);
260 260
 	}
261 261
 
262 262
 
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 	 * @param array $query_params see EEM_Base::get_all()
268 268
 	 * @return EE_Datetime[]
269 269
 	 */
270
-	public function datetimes( $query_params = array() ) {
271
-		if ( ! isset( $query_params[ 'order_by' ] ) ) {
272
-			$query_params[ 'order_by' ][ 'DTT_order' ] = 'ASC';
270
+	public function datetimes($query_params = array()) {
271
+		if ( ! isset($query_params['order_by'])) {
272
+			$query_params['order_by']['DTT_order'] = 'ASC';
273 273
 		}
274
-		return $this->get_many_related( 'Datetime', $query_params );
274
+		return $this->get_many_related('Datetime', $query_params);
275 275
 	}
276 276
 
277 277
 
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @return EE_Datetime
282 282
 	 */
283 283
 	public function last_datetime() {
284
-		$datetimes = $this->datetimes( array( 'limit' => 1, 'order_by' => array( 'DTT_EVT_start' => 'DESC' ) ) );
285
-		return end( $datetimes );
284
+		$datetimes = $this->datetimes(array('limit' => 1, 'order_by' => array('DTT_EVT_start' => 'DESC')));
285
+		return end($datetimes);
286 286
 	}
287 287
 
288 288
 
@@ -296,22 +296,22 @@  discard block
 block discarded – undo
296 296
 	 * @param  int    $dtt_id [optional] include the dtt_id with $what = 'datetime'.
297 297
 	 * @return mixed (array|int)          how many tickets have sold
298 298
 	 */
299
-	public function tickets_sold( $what = 'ticket', $dtt_id = NULL ) {
299
+	public function tickets_sold($what = 'ticket', $dtt_id = NULL) {
300 300
 		$total = 0;
301 301
 		$tickets_sold = $this->_all_tickets_sold();
302
-		switch ( $what ) {
302
+		switch ($what) {
303 303
 			case 'ticket' :
304
-				return $tickets_sold[ 'ticket' ];
304
+				return $tickets_sold['ticket'];
305 305
 				break;
306 306
 			case 'datetime' :
307
-				if ( empty( $tickets_sold[ 'datetime' ] ) ) {
307
+				if (empty($tickets_sold['datetime'])) {
308 308
 					return $total;
309 309
 				}
310
-				if ( ! empty( $dtt_id ) && ! isset( $tickets_sold[ 'datetime' ][ $dtt_id ] ) ) {
311
-					EE_Error::add_error( __( "You've requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included.  Are you SURE that is a datetime related to this ticket?", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
310
+				if ( ! empty($dtt_id) && ! isset($tickets_sold['datetime'][$dtt_id])) {
311
+					EE_Error::add_error(__("You've requested the amount of tickets sold for a given ticket and datetime, however there are no records for the datetime id you included.  Are you SURE that is a datetime related to this ticket?", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
312 312
 					return $total;
313 313
 				}
314
-				return empty( $dtt_id ) ? $tickets_sold[ 'datetime' ] : $tickets_sold[ 'datetime' ][ $dtt_id ];
314
+				return empty($dtt_id) ? $tickets_sold['datetime'] : $tickets_sold['datetime'][$dtt_id];
315 315
 				break;
316 316
 			default:
317 317
 				return $total;
@@ -325,15 +325,15 @@  discard block
 block discarded – undo
325 325
 	 * @return EE_Ticket[]
326 326
 	 */
327 327
 	protected function _all_tickets_sold() {
328
-		$datetimes = $this->get_many_related( 'Datetime' );
328
+		$datetimes = $this->get_many_related('Datetime');
329 329
 		$tickets_sold = array();
330
-		if ( ! empty( $datetimes ) ) {
331
-			foreach ( $datetimes as $datetime ) {
332
-				$tickets_sold[ 'datetime' ][ $datetime->ID() ] = $datetime->get( 'DTT_sold' );
330
+		if ( ! empty($datetimes)) {
331
+			foreach ($datetimes as $datetime) {
332
+				$tickets_sold['datetime'][$datetime->ID()] = $datetime->get('DTT_sold');
333 333
 			}
334 334
 		}
335 335
 		//Tickets sold
336
-		$tickets_sold[ 'ticket' ] = $this->sold();
336
+		$tickets_sold['ticket'] = $this->sold();
337 337
 		return $tickets_sold;
338 338
 	}
339 339
 
@@ -346,9 +346,9 @@  discard block
 block discarded – undo
346 346
 	 * @param  bool $return_array whether to return as an array indexed by price id or just the object.
347 347
 	 * @return EE_Price
348 348
 	 */
349
-	public function base_price( $return_array = FALSE ) {
350
-		$_where = array( 'Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price );
351
-		return $return_array ? $this->get_many_related( 'Price', array( $_where ) ) : $this->get_first_related( 'Price', array( $_where ) );
349
+	public function base_price($return_array = FALSE) {
350
+		$_where = array('Price_Type.PBT_ID' => EEM_Price_Type::base_type_base_price);
351
+		return $return_array ? $this->get_many_related('Price', array($_where)) : $this->get_first_related('Price', array($_where));
352 352
 	}
353 353
 
354 354
 
@@ -360,8 +360,8 @@  discard block
 block discarded – undo
360 360
 	 * @return EE_Price[]
361 361
 	 */
362 362
 	public function price_modifiers() {
363
-		$query_params = array( 0 => array( 'Price_Type.PBT_ID' => array( 'NOT IN', array( EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax ) ) ) );
364
-		return $this->prices( $query_params );
363
+		$query_params = array(0 => array('Price_Type.PBT_ID' => array('NOT IN', array(EEM_Price_Type::base_type_base_price, EEM_Price_Type::base_type_tax))));
364
+		return $this->prices($query_params);
365 365
 	}
366 366
 
367 367
 
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @param array $query_params like EEM_Base::get_all
372 372
 	 * @return EE_Price[]
373 373
 	 */
374
-	public function prices( $query_params = array() ) {
375
-		return $this->get_many_related( 'Price', $query_params );
374
+	public function prices($query_params = array()) {
375
+		return $this->get_many_related('Price', $query_params);
376 376
 	}
377 377
 
378 378
 
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param array $query_params see EEM_Base::get_all()
383 383
 	 * @return EE_Datetime_Ticket
384 384
 	 */
385
-	public function datetime_tickets( $query_params = array() ) {
386
-		return $this->get_many_related( 'Datetime_Ticket', $query_params );
385
+	public function datetime_tickets($query_params = array()) {
386
+		return $this->get_many_related('Datetime_Ticket', $query_params);
387 387
 	}
388 388
 
389 389
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @param boolean $show_deleted
395 395
 	 * @return EE_Datetime[]
396 396
 	 */
397
-	public function datetimes_ordered( $show_expired = TRUE, $show_deleted = FALSE ) {
398
-		return EEM_Datetime::instance( $this->_timezone )->get_datetimes_for_ticket_ordered_by_DTT_order( $this->ID(), $show_expired, $show_deleted );
397
+	public function datetimes_ordered($show_expired = TRUE, $show_deleted = FALSE) {
398
+		return EEM_Datetime::instance($this->_timezone)->get_datetimes_for_ticket_ordered_by_DTT_order($this->ID(), $show_expired, $show_deleted);
399 399
 	}
400 400
 
401 401
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @return string
406 406
 	 */
407 407
 	function ID() {
408
-		return $this->get( 'TKT_ID' );
408
+		return $this->get('TKT_ID');
409 409
 	}
410 410
 
411 411
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 * @return EE_Ticket_Template
430 430
 	 */
431 431
 	public function template() {
432
-		return $this->get_first_related( 'Ticket_Template' );
432
+		return $this->get_first_related('Ticket_Template');
433 433
 	}
434 434
 
435 435
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	 * @return bool
449 449
 	 */
450 450
 	public function ticket_price() {
451
-		return $this->get( 'TKT_price' );
451
+		return $this->get('TKT_price');
452 452
 	}
453 453
 
454 454
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	 * @return mixed
458 458
 	 */
459 459
 	public function pretty_price() {
460
-		return $this->get_pretty( 'TKT_price' );
460
+		return $this->get_pretty('TKT_price');
461 461
 	}
462 462
 
463 463
 
@@ -476,17 +476,17 @@  discard block
 block discarded – undo
476 476
 	 * @param bool $no_cache
477 477
 	 * @return float
478 478
 	 */
479
-	public function get_ticket_total_with_taxes( $no_cache = FALSE ) {
480
-		if ( ! isset( $this->_ticket_total_with_taxes ) || $no_cache ) {
479
+	public function get_ticket_total_with_taxes($no_cache = FALSE) {
480
+		if ( ! isset($this->_ticket_total_with_taxes) || $no_cache) {
481 481
 			$this->_ticket_total_with_taxes = $this->get_ticket_subtotal() + $this->get_ticket_taxes_total_for_admin();
482 482
 		}
483
-		return (float)$this->_ticket_total_with_taxes;
483
+		return (float) $this->_ticket_total_with_taxes;
484 484
 	}
485 485
 
486 486
 
487 487
 
488 488
 	public function ensure_TKT_Price_correct() {
489
-		$this->set( 'TKT_price', EE_Taxes::get_subtotal_for_admin( $this ) );
489
+		$this->set('TKT_price', EE_Taxes::get_subtotal_for_admin($this));
490 490
 		$this->save();
491 491
 	}
492 492
 
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 	 * @return float
497 497
 	 */
498 498
 	public function get_ticket_subtotal() {
499
-		return EE_Taxes::get_subtotal_for_admin( $this );
499
+		return EE_Taxes::get_subtotal_for_admin($this);
500 500
 	}
501 501
 
502 502
 
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 	 * @return float
507 507
 	 */
508 508
 	public function get_ticket_taxes_total_for_admin() {
509
-		return EE_Taxes::get_total_taxes_for_admin( $this );
509
+		return EE_Taxes::get_total_taxes_for_admin($this);
510 510
 	}
511 511
 
512 512
 
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
 	 * @param string $name
517 517
 	 * @return boolean
518 518
 	 */
519
-	function set_name( $name ) {
520
-		$this->set( 'TKT_name', $name );
519
+	function set_name($name) {
520
+		$this->set('TKT_name', $name);
521 521
 	}
522 522
 
523 523
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 	 * @return string
528 528
 	 */
529 529
 	function description() {
530
-		return $this->get( 'TKT_description' );
530
+		return $this->get('TKT_description');
531 531
 	}
532 532
 
533 533
 
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
 	 * @param string $description
538 538
 	 * @return boolean
539 539
 	 */
540
-	function set_description( $description ) {
541
-		$this->set( 'TKT_description', $description );
540
+	function set_description($description) {
541
+		$this->set('TKT_description', $description);
542 542
 	}
543 543
 
544 544
 
@@ -549,8 +549,8 @@  discard block
 block discarded – undo
549 549
 	 * @param string $tm_frmt
550 550
 	 * @return string
551 551
 	 */
552
-	function start_date( $dt_frmt = '', $tm_frmt = '' ) {
553
-		return $this->_get_datetime( 'TKT_start_date', $dt_frmt, $tm_frmt );
552
+	function start_date($dt_frmt = '', $tm_frmt = '') {
553
+		return $this->_get_datetime('TKT_start_date', $dt_frmt, $tm_frmt);
554 554
 	}
555 555
 
556 556
 
@@ -560,8 +560,8 @@  discard block
 block discarded – undo
560 560
 	 * @param string $start_date
561 561
 	 * @return void
562 562
 	 */
563
-	function set_start_date( $start_date ) {
564
-		$this->_set_date_time( 'B', $start_date, 'TKT_start_date' );
563
+	function set_start_date($start_date) {
564
+		$this->_set_date_time('B', $start_date, 'TKT_start_date');
565 565
 	}
566 566
 
567 567
 
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * @param string $tm_frmt
573 573
 	 * @return string
574 574
 	 */
575
-	function end_date( $dt_frmt = '', $tm_frmt = '' ) {
576
-		return $this->_get_datetime( 'TKT_end_date', $dt_frmt, $tm_frmt );
575
+	function end_date($dt_frmt = '', $tm_frmt = '') {
576
+		return $this->_get_datetime('TKT_end_date', $dt_frmt, $tm_frmt);
577 577
 	}
578 578
 
579 579
 
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
 	 * @param string $end_date
584 584
 	 * @return void
585 585
 	 */
586
-	function set_end_date( $end_date ) {
587
-		$this->_set_date_time( 'B', $end_date, 'TKT_end_date' );
586
+	function set_end_date($end_date) {
587
+		$this->_set_date_time('B', $end_date, 'TKT_end_date');
588 588
 	}
589 589
 
590 590
 
@@ -596,8 +596,8 @@  discard block
 block discarded – undo
596 596
 	 *
597 597
 	 * @param string $time a string representation of the sell until time (ex 9am or 7:30pm)
598 598
 	 */
599
-	function set_end_time( $time ) {
600
-		$this->_set_time_for( $time, 'TKT_end_date' );
599
+	function set_end_time($time) {
600
+		$this->_set_time_for($time, 'TKT_end_date');
601 601
 	}
602 602
 
603 603
 
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
 	 * @param int $min
608 608
 	 * @return boolean
609 609
 	 */
610
-	function set_min( $min ) {
611
-		$this->set( 'TKT_min', $min );
610
+	function set_min($min) {
611
+		$this->set('TKT_min', $min);
612 612
 	}
613 613
 
614 614
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	 * @return int
619 619
 	 */
620 620
 	function max() {
621
-		return $this->get( 'TKT_max' );
621
+		return $this->get('TKT_max');
622 622
 	}
623 623
 
624 624
 
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
 	 * @param int $max
629 629
 	 * @return boolean
630 630
 	 */
631
-	function set_max( $max ) {
632
-		$this->set( 'TKT_max', $max );
631
+	function set_max($max) {
632
+		$this->set('TKT_max', $max);
633 633
 	}
634 634
 
635 635
 
@@ -639,8 +639,8 @@  discard block
 block discarded – undo
639 639
 	 * @param float $price
640 640
 	 * @return boolean
641 641
 	 */
642
-	function set_price( $price ) {
643
-		$this->set( 'TKT_price', $price );
642
+	function set_price($price) {
643
+		$this->set('TKT_price', $price);
644 644
 	}
645 645
 
646 646
 
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	 * @return int
651 651
 	 */
652 652
 	function sold() {
653
-		return $this->get_raw( 'TKT_sold' );
653
+		return $this->get_raw('TKT_sold');
654 654
 	}
655 655
 
656 656
 
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
 	 * @param int $qty
661 661
 	 * @return boolean
662 662
 	 */
663
-	function increase_sold( $qty = 1 ) {
663
+	function increase_sold($qty = 1) {
664 664
 		$sold = $this->sold() + $qty;
665
-		$this->_increase_sold_for_datetimes( $qty );
666
-		return $this->set_sold( $sold );
665
+		$this->_increase_sold_for_datetimes($qty);
666
+		return $this->set_sold($sold);
667 667
 	}
668 668
 
669 669
 
@@ -673,12 +673,12 @@  discard block
 block discarded – undo
673 673
 	 * @param int $qty
674 674
 	 * @return boolean
675 675
 	 */
676
-	protected function _increase_sold_for_datetimes( $qty = 1 ) {
676
+	protected function _increase_sold_for_datetimes($qty = 1) {
677 677
 		$datetimes = $this->datetimes();
678
-		if ( is_array( $datetimes ) ) {
679
-			foreach ( $datetimes as $datetime ) {
680
-				if ( $datetime instanceof EE_Datetime ) {
681
-					$datetime->increase_sold( $qty );
678
+		if (is_array($datetimes)) {
679
+			foreach ($datetimes as $datetime) {
680
+				if ($datetime instanceof EE_Datetime) {
681
+					$datetime->increase_sold($qty);
682 682
 					$datetime->save();
683 683
 				}
684 684
 			}
@@ -692,10 +692,10 @@  discard block
 block discarded – undo
692 692
 	 * @param int $sold
693 693
 	 * @return boolean
694 694
 	 */
695
-	function set_sold( $sold ) {
695
+	function set_sold($sold) {
696 696
 		// sold can not go below zero
697
-		$sold = max( 0, $sold );
698
-		$this->set( 'TKT_sold', $sold );
697
+		$sold = max(0, $sold);
698
+		$this->set('TKT_sold', $sold);
699 699
 	}
700 700
 
701 701
 
@@ -705,10 +705,10 @@  discard block
 block discarded – undo
705 705
 	 * @param int $qty
706 706
 	 * @return boolean
707 707
 	 */
708
-	function decrease_sold( $qty = 1 ) {
708
+	function decrease_sold($qty = 1) {
709 709
 		$sold = $this->sold() - $qty;
710
-		$this->_decrease_sold_for_datetimes( $qty );
711
-		return $this->set_sold( $sold );
710
+		$this->_decrease_sold_for_datetimes($qty);
711
+		return $this->set_sold($sold);
712 712
 	}
713 713
 
714 714
 
@@ -719,12 +719,12 @@  discard block
 block discarded – undo
719 719
 	* @param int $qty
720 720
 	* @return boolean
721 721
 	*/
722
-	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
722
+	protected function _decrease_sold_for_datetimes($qty = 1) {
723 723
 		$datetimes = $this->datetimes();
724
-		if ( is_array( $datetimes ) ) {
725
-			foreach ( $datetimes as $datetime ) {
726
-				if ( $datetime instanceof EE_Datetime ) {
727
-					$datetime->decrease_sold( $qty );
724
+		if (is_array($datetimes)) {
725
+			foreach ($datetimes as $datetime) {
726
+				if ($datetime instanceof EE_Datetime) {
727
+					$datetime->decrease_sold($qty);
728 728
 					$datetime->save();
729 729
 				}
730 730
 			}
@@ -745,14 +745,14 @@  discard block
 block discarded – undo
745 745
 	 *
746 746
 	 * @return int
747 747
 	 */
748
-	function qty( $context = '' ) {
749
-		switch ( $context ) {
748
+	function qty($context = '') {
749
+		switch ($context) {
750 750
 			case 'reg_limit' :
751 751
 				return $this->real_quantity_on_ticket();
752 752
 			case 'saleable' :
753
-				return $this->real_quantity_on_ticket( 'saleable' );
753
+				return $this->real_quantity_on_ticket('saleable');
754 754
 			default:
755
-				return $this->get_raw( 'TKT_qty' );
755
+				return $this->get_raw('TKT_qty');
756 756
 		}
757 757
 	}
758 758
 
@@ -769,38 +769,38 @@  discard block
 block discarded – undo
769 769
 	 *
770 770
 	 * @return int
771 771
 	 */
772
-	function real_quantity_on_ticket( $context = 'reg_limit' ) {
772
+	function real_quantity_on_ticket($context = 'reg_limit') {
773 773
 		// start with the original db value for ticket quantity
774
-		$raw = $this->get_raw( 'TKT_qty' );
774
+		$raw = $this->get_raw('TKT_qty');
775 775
 		// return immediately if it's zero
776
-		if ( $raw === 0 ) {
776
+		if ($raw === 0) {
777 777
 			return $raw;
778 778
 		}
779 779
 		// ensure qty doesn't exceed raw value for THIS ticket
780
-		$qty = min( EE_INF, $raw );
780
+		$qty = min(EE_INF, $raw);
781 781
 		// NOW that we know the  maximum number of tickets available for the ticket
782 782
 		// we need to calculate the maximum number of tickets available for the datetime
783 783
 		// without really factoring this ticket into the calculations
784 784
 		$datetimes = $this->datetimes();
785
-		foreach ( $datetimes as $datetime ) {
786
-			if ( $datetime instanceof EE_Datetime ) {
785
+		foreach ($datetimes as $datetime) {
786
+			if ($datetime instanceof EE_Datetime) {
787 787
 				// initialize with no restrictions for each datetime
788 788
 				// but adjust datetime qty based on datetime reg limit
789
-				$datetime_qty = min( EE_INF, $datetime->reg_limit() );
789
+				$datetime_qty = min(EE_INF, $datetime->reg_limit());
790 790
 				// if we want the actual saleable amount, then we need to consider OTHER ticket sales
791 791
 				// for this datetime, that do NOT include sales for this ticket (so we add THIS ticket's sales back in)
792
-				if ( $context == 'saleable' ) {
793
-					$datetime_qty = max( $datetime_qty - $datetime->sold() + $this->sold(), 0 );
792
+				if ($context == 'saleable') {
793
+					$datetime_qty = max($datetime_qty - $datetime->sold() + $this->sold(), 0);
794 794
 					$datetime_qty = ! $datetime->sold_out() ? $datetime_qty : 0;
795 795
 				}
796
-				$qty = min( $datetime_qty, $qty );
796
+				$qty = min($datetime_qty, $qty);
797 797
 			}
798 798
 
799 799
 		}
800 800
 		// we need to factor in the details for this specific ticket
801
-		if ( $qty > 0 && $context == 'saleable' ) {
801
+		if ($qty > 0 && $context == 'saleable') {
802 802
 			// and subtract the sales for THIS ticket
803
-			$qty = max( $qty - $this->sold(), 0 );
803
+			$qty = max($qty - $this->sold(), 0);
804 804
 			//echo '&nbsp; $qty: ' . $qty . "<br />";
805 805
 		}
806 806
 		//echo '$qty: ' . $qty . "<br />";
@@ -816,14 +816,14 @@  discard block
 block discarded – undo
816 816
 	 * @return bool
817 817
 	 * @throws \EE_Error
818 818
 	 */
819
-	function set_qty( $qty ) {
819
+	function set_qty($qty) {
820 820
 		$datetimes = $this->datetimes();
821
-		foreach ( $datetimes as $datetime ) {
822
-			if ( $datetime instanceof EE_Datetime ) {
823
-				$qty = min( $qty, $datetime->reg_limit() );
821
+		foreach ($datetimes as $datetime) {
822
+			if ($datetime instanceof EE_Datetime) {
823
+				$qty = min($qty, $datetime->reg_limit());
824 824
 			}
825 825
 		}
826
-		$this->set( 'TKT_qty', $qty );
826
+		$this->set('TKT_qty', $qty);
827 827
 	}
828 828
 
829 829
 
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 	 * @return int
834 834
 	 */
835 835
 	function uses() {
836
-		return $this->get( 'TKT_uses' );
836
+		return $this->get('TKT_uses');
837 837
 	}
838 838
 
839 839
 
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 	 * @param int $uses
844 844
 	 * @return boolean
845 845
 	 */
846
-	function set_uses( $uses ) {
847
-		$this->set( 'TKT_uses', $uses );
846
+	function set_uses($uses) {
847
+		$this->set('TKT_uses', $uses);
848 848
 	}
849 849
 
850 850
 
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 	 * @return boolean
855 855
 	 */
856 856
 	public function required() {
857
-		return $this->get( 'TKT_required' );
857
+		return $this->get('TKT_required');
858 858
 	}
859 859
 
860 860
 
@@ -864,8 +864,8 @@  discard block
 block discarded – undo
864 864
 	 * @param boolean $required
865 865
 	 * @return boolean
866 866
 	 */
867
-	public function set_required( $required ) {
868
-		$this->set( 'TKT_required', $required );
867
+	public function set_required($required) {
868
+		$this->set('TKT_required', $required);
869 869
 	}
870 870
 
871 871
 
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 	 * @return boolean
876 876
 	 */
877 877
 	function taxable() {
878
-		return $this->get( 'TKT_taxable' );
878
+		return $this->get('TKT_taxable');
879 879
 	}
880 880
 
881 881
 
@@ -885,8 +885,8 @@  discard block
 block discarded – undo
885 885
 	 * @param boolean $taxable
886 886
 	 * @return boolean
887 887
 	 */
888
-	function set_taxable( $taxable ) {
889
-		$this->set( 'TKT_taxable', $taxable );
888
+	function set_taxable($taxable) {
889
+		$this->set('TKT_taxable', $taxable);
890 890
 	}
891 891
 
892 892
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 	 * @return boolean
897 897
 	 */
898 898
 	function is_default() {
899
-		return $this->get( 'TKT_is_default' );
899
+		return $this->get('TKT_is_default');
900 900
 	}
901 901
 
902 902
 
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
 	 * @param boolean $is_default
907 907
 	 * @return boolean
908 908
 	 */
909
-	function set_is_default( $is_default ) {
910
-		$this->set( 'TKT_is_default', $is_default );
909
+	function set_is_default($is_default) {
910
+		$this->set('TKT_is_default', $is_default);
911 911
 	}
912 912
 
913 913
 
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
 	 * @return int
918 918
 	 */
919 919
 	function order() {
920
-		return $this->get( 'TKT_order' );
920
+		return $this->get('TKT_order');
921 921
 	}
922 922
 
923 923
 
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
 	 * @param int $order
928 928
 	 * @return boolean
929 929
 	 */
930
-	function set_order( $order ) {
931
-		$this->set( 'TKT_order', $order );
930
+	function set_order($order) {
931
+		$this->set('TKT_order', $order);
932 932
 	}
933 933
 
934 934
 
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
 	 * @return int
939 939
 	 */
940 940
 	function row() {
941
-		return $this->get( 'TKT_row' );
941
+		return $this->get('TKT_row');
942 942
 	}
943 943
 
944 944
 
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 	 * @param int $row
949 949
 	 * @return boolean
950 950
 	 */
951
-	function set_row( $row ) {
952
-		$this->set( 'TKT_row', $row );
951
+	function set_row($row) {
952
+		$this->set('TKT_row', $row);
953 953
 	}
954 954
 
955 955
 
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 	 * @return boolean
960 960
 	 */
961 961
 	function deleted() {
962
-		return $this->get( 'TKT_deleted' );
962
+		return $this->get('TKT_deleted');
963 963
 	}
964 964
 
965 965
 
@@ -969,8 +969,8 @@  discard block
 block discarded – undo
969 969
 	 * @param boolean $deleted
970 970
 	 * @return boolean
971 971
 	 */
972
-	function set_deleted( $deleted ) {
973
-		$this->set( 'TKT_deleted', $deleted );
972
+	function set_deleted($deleted) {
973
+		$this->set('TKT_deleted', $deleted);
974 974
 	}
975 975
 
976 976
 
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 	 * @return int
981 981
 	 */
982 982
 	function parent_ID() {
983
-		return $this->get( 'TKT_parent' );
983
+		return $this->get('TKT_parent');
984 984
 	}
985 985
 
986 986
 
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
 	 * @param int $parent
991 991
 	 * @return boolean
992 992
 	 */
993
-	function set_parent_ID( $parent ) {
994
-		$this->set( 'TKT_parent', $parent );
993
+	function set_parent_ID($parent) {
994
+		$this->set('TKT_parent', $parent);
995 995
 	}
996 996
 
997 997
 
@@ -1002,10 +1002,10 @@  discard block
 block discarded – undo
1002 1002
 	 */
1003 1003
 	function name_and_info() {
1004 1004
 		$times = array();
1005
-		foreach ( $this->datetimes() as $datetime ) {
1005
+		foreach ($this->datetimes() as $datetime) {
1006 1006
 			$times[] = $datetime->start_date_and_time();
1007 1007
 		}
1008
-		return $this->name() . " @ " . implode( ", ", $times ) . " for " . $this->price();
1008
+		return $this->name()." @ ".implode(", ", $times)." for ".$this->price();
1009 1009
 	}
1010 1010
 
1011 1011
 
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 	 * @return string
1016 1016
 	 */
1017 1017
 	function name() {
1018
-		return $this->get( 'TKT_name' );
1018
+		return $this->get('TKT_name');
1019 1019
 	}
1020 1020
 
1021 1021
 
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 	 * @return float
1026 1026
 	 */
1027 1027
 	function price() {
1028
-		return $this->get( 'TKT_price' );
1028
+		return $this->get('TKT_price');
1029 1029
 	}
1030 1030
 
1031 1031
 
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
 	 * @param array $query_params like EEM_Base::get_all's
1036 1036
 	 * @return EE_Registration[]
1037 1037
 	 */
1038
-	public function registrations( $query_params = array() ) {
1039
-		return $this->get_many_related( 'Registration', $query_params );
1038
+	public function registrations($query_params = array()) {
1039
+		return $this->get_many_related('Registration', $query_params);
1040 1040
 	}
1041 1041
 
1042 1042
 
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 	 * @return int
1048 1048
 	 */
1049 1049
 	public function update_tickets_sold() {
1050
-		$count_regs_for_this_ticket = $this->count_registrations( array( array( 'STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0 ) ) );
1051
-		$this->set_sold( $count_regs_for_this_ticket );
1050
+		$count_regs_for_this_ticket = $this->count_registrations(array(array('STS_ID' => EEM_Registration::status_id_approved, 'REG_deleted' => 0)));
1051
+		$this->set_sold($count_regs_for_this_ticket);
1052 1052
 		$this->save();
1053 1053
 		return $count_regs_for_this_ticket;
1054 1054
 	}
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 	 * @param array $query_params like EEM_Base::get_all's
1061 1061
 	 * @return int
1062 1062
 	 */
1063
-	public function count_registrations( $query_params = array() ) {
1063
+	public function count_registrations($query_params = array()) {
1064 1064
 		return $this->count_related('Registration', $query_params);
1065 1065
 	}
1066 1066
 
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 	public function get_related_event() {
1086 1086
 		//get one datetime to use for getting the event
1087 1087
 		$datetime = $this->first_datetime();
1088
-		if ( $datetime instanceof EE_Datetime ) {
1088
+		if ($datetime instanceof EE_Datetime) {
1089 1089
 			return $datetime->event();
1090 1090
 		}
1091 1091
 		return null;
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -714,11 +714,11 @@
 block discarded – undo
714 714
 
715 715
 
716 716
 	/**
717
-	* Decreases sold on related datetimes
718
-	*
719
-	* @param int $qty
720
-	* @return boolean
721
-	*/
717
+	 * Decreases sold on related datetimes
718
+	 *
719
+	 * @param int $qty
720
+	 * @return boolean
721
+	 */
722 722
 	protected function _decrease_sold_for_datetimes( $qty = 1 ) {
723 723
 		$datetimes = $this->datetimes();
724 724
 		if ( is_array( $datetimes ) ) {
Please login to merge, or discard this patch.
modules/ticket_selector/templates/ticket_selector_chart.template.php 1 patch
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -8,32 +8,32 @@  discard block
 block discarded – undo
8 8
 
9 9
 $row = 1;
10 10
 $max = 1;
11
-$ticket_count = count( $tickets );
11
+$ticket_count = count($tickets);
12 12
 
13
-if ( ! $ticket_count ) {
13
+if ( ! $ticket_count) {
14 14
 	return;
15 15
 }
16 16
 
17 17
 $required_ticket_sold_out = FALSE;
18
-$template_settings = isset ( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector : new EE_Ticket_Selector_Config();
18
+$template_settings = isset (EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector) ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector : new EE_Ticket_Selector_Config();
19 19
 ob_start();
20 20
 
21
-foreach ( $tickets as $TKT_ID => $ticket ) {
22
-	if ( $ticket instanceof EE_Ticket ) {
21
+foreach ($tickets as $TKT_ID => $ticket) {
22
+	if ($ticket instanceof EE_Ticket) {
23 23
 		//	d( $ticket );
24
-		$max =$ticket->max();
24
+		$max = $ticket->max();
25 25
 		$min = 0;
26 26
 		$remaining = $ticket->remaining();
27
-		if ( $ticket->is_on_sale() && $ticket->is_remaining() ) {
27
+		if ($ticket->is_on_sale() && $ticket->is_remaining()) {
28 28
 			// offer the number of $tickets_remaining or $max_atndz, whichever is smaller
29
-			$max = min( $remaining, $max_atndz );
29
+			$max = min($remaining, $max_atndz);
30 30
 			// but... we also want to restrict the number of tickets by the ticket max setting,
31 31
 			// however, the max still can't be higher than what was just set above
32
-			$max = $ticket->max() > 0 ? min( $ticket->max(), $max ) : $max;
32
+			$max = $ticket->max() > 0 ? min($ticket->max(), $max) : $max;
33 33
 			// and we also want to restrict the minimum number of tickets by the ticket min setting
34 34
 			$min = $ticket->min() > 0 ? $ticket->min() : 0;
35 35
 			// and if the ticket is required, then make sure that min qty is at least 1
36
-			$min = $ticket->required() ? max( $min, 1 ) : $min;
36
+			$min = $ticket->required() ? max($min, 1) : $min;
37 37
 		} else {
38 38
 			// set flag if ticket is required (flag is set to start date so that future tickets are not blocked)
39 39
 			$required_ticket_sold_out = $ticket->required() && ! $remaining ? $ticket->start_date() : $required_ticket_sold_out;
@@ -42,40 +42,40 @@  discard block
 block discarded – undo
42 42
 		$ticket_price = $ticket->get_ticket_total_with_taxes();
43 43
 		$ticket_bundle = FALSE;
44 44
 		// for ticket bundles, set min and max qty the same
45
-		if ( $ticket->min() != 0 && $ticket->min() == $ticket->max() ) {
45
+		if ($ticket->min() != 0 && $ticket->min() == $ticket->max()) {
46 46
 			$ticket_price = $ticket_price * $ticket->min();
47 47
 			$ticket_bundle = TRUE;
48 48
 		}
49
-		$ticket_price = apply_filters( 'FHEE__ticket_selector_chart_template__ticket_price', $ticket_price, $ticket );
49
+		$ticket_price = apply_filters('FHEE__ticket_selector_chart_template__ticket_price', $ticket_price, $ticket);
50 50
 		// if a previous required ticket with the same sale start date is sold out, then mark this ticket as sold out as well.
51 51
 		// tickets that go on sale at a later date than the required ticket  will NOT be affected
52 52
 		$tkt_status = $required_ticket_sold_out !== FALSE && $required_ticket_sold_out === $ticket->start_date() ? EE_Ticket::sold_out : $ticket->ticket_status();
53 53
 		$tkt_status = $event_status === EE_Datetime::sold_out ? EE_Ticket::sold_out : $tkt_status;
54 54
 		// check ticket status
55
-		switch ( $tkt_status ) {
55
+		switch ($tkt_status) {
56 56
 			// sold_out
57 57
 			case EE_Ticket::sold_out :
58
-				$ticket_status = '<span class="ticket-sales-sold-out">' . $ticket->ticket_status( TRUE ) . '</span>';
58
+				$ticket_status = '<span class="ticket-sales-sold-out">'.$ticket->ticket_status(TRUE).'</span>';
59 59
 				$status_class = 'ticket-sales-sold-out lt-grey-text';
60 60
 			break;
61 61
 			// expired
62 62
 			case EE_Ticket::expired :
63
-				$ticket_status = '<span class="ticket-sales-expired">' . $ticket->ticket_status( TRUE ) . '</span>';
63
+				$ticket_status = '<span class="ticket-sales-expired">'.$ticket->ticket_status(TRUE).'</span>';
64 64
 				$status_class = 'ticket-sales-expired lt-grey-text';
65 65
 			break;
66 66
 			// archived
67 67
 			case EE_Ticket::archived :
68
-				$ticket_status = '<span class="archived-ticket">' . $ticket->ticket_status( TRUE ) . '</span>';
68
+				$ticket_status = '<span class="archived-ticket">'.$ticket->ticket_status(TRUE).'</span>';
69 69
 				$status_class = 'archived-ticket hidden';
70 70
 			break;
71 71
 			// pending
72 72
 			case EE_Ticket::pending :
73
-				$ticket_status = '<span class="ticket-pending">' . $ticket->ticket_status( TRUE ) . '</span>';
73
+				$ticket_status = '<span class="ticket-pending">'.$ticket->ticket_status(TRUE).'</span>';
74 74
 				$status_class = 'ticket-pending';
75 75
 			break;
76 76
 			// onsale
77 77
 			case EE_Ticket::onsale :
78
-				$ticket_status = '<span class="ticket-on-sale">' . $ticket->ticket_status( TRUE ) . '</span>';
78
+				$ticket_status = '<span class="ticket-on-sale">'.$ticket->ticket_status(TRUE).'</span>';
79 79
 				$status_class = 'ticket-on-sale';
80 80
 			break;
81 81
 		}
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 		 *
91 91
 		 * @var string|bool
92 92
 		 */
93
-		if ( false !== ( $new_row_content = apply_filters( 'FHEE__ticket_selector_chart_template__do_ticket_entire_row', false, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class ) ) ) {
93
+		if (false !== ($new_row_content = apply_filters('FHEE__ticket_selector_chart_template__do_ticket_entire_row', false, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class))) {
94 94
 			echo $new_row_content;
95 95
 			continue;
96 96
 		}
97 97
 	?>
98
-				<tr class="tckt-slctr-tbl-tr <?php echo $status_class . ' ' . espresso_get_object_css_class( $ticket ); ?>">
98
+				<tr class="tckt-slctr-tbl-tr <?php echo $status_class.' '.espresso_get_object_css_class($ticket); ?>">
99 99
 		<?php
100 100
 		/**
101 101
 		 * Allow plugins to hook in and abort the generation and display of the contents of this
@@ -107,24 +107,24 @@  discard block
 block discarded – undo
107 107
 		 *
108 108
 		 * @var string|bool
109 109
 		 */
110
-		if ( false !== ( $new_row_cells_content = apply_filters( 'FHEE__ticket_selector_chart_template__do_ticket_inside_row', false, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class ) ) ) {
110
+		if (false !== ($new_row_cells_content = apply_filters('FHEE__ticket_selector_chart_template__do_ticket_inside_row', false, $ticket, $max, $min, $required_ticket_sold_out, $ticket_price, $ticket_bundle, $ticket_status, $status_class))) {
111 111
 			echo $new_row_cells_content;
112 112
 			echo '</tr>';
113 113
 			continue;
114 114
 		}
115 115
 		?>
116 116
 					<td class="tckt-slctr-tbl-td-name">
117
-						<b><?php echo $ticket->get_pretty('TKT_name');?></b>
118
-						<?php if ( $template_settings->show_ticket_details ) : ?>
119
-							<a id="display-tckt-slctr-tkt-details-<?php echo $EVT_ID . '-' . $TKT_ID; ?>" class="display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="tckt-slctr-tkt-details-<?php echo $EVT_ID . '-' . $TKT_ID; ?>" title="<?php echo esc_attr( apply_filters( 'FHEE__ticket_selector_chart_template__show_ticket_details_link_title', __( 'click to show additional ticket details', 'event_espresso' )) ); ?>">
120
-								<?php echo sprintf( __( 'show%1$sdetails%1$s+', 'event_espresso' ), '&nbsp;' ); ?>
117
+						<b><?php echo $ticket->get_pretty('TKT_name'); ?></b>
118
+						<?php if ($template_settings->show_ticket_details) : ?>
119
+							<a id="display-tckt-slctr-tkt-details-<?php echo $EVT_ID.'-'.$TKT_ID; ?>" class="display-tckt-slctr-tkt-details display-the-hidden lt-grey-text smaller-text hide-if-no-js" rel="tckt-slctr-tkt-details-<?php echo $EVT_ID.'-'.$TKT_ID; ?>" title="<?php echo esc_attr(apply_filters('FHEE__ticket_selector_chart_template__show_ticket_details_link_title', __('click to show additional ticket details', 'event_espresso'))); ?>">
120
+								<?php echo sprintf(__('show%1$sdetails%1$s+', 'event_espresso'), '&nbsp;'); ?>
121 121
 							</a>
122
-							<a id="hide-tckt-slctr-tkt-details-<?php echo $EVT_ID . '-' . $TKT_ID; ?>" class="hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js" rel="tckt-slctr-tkt-details-<?php echo $EVT_ID . '-' . $TKT_ID; ?>" title="<?php echo esc_attr( apply_filters( 'FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', __( 'click to hide additional ticket details', 'event_espresso' )) ); ?>" style="display:none;">
123
-								<?php echo sprintf( __( 'hide%1$sdetails%1$s-', 'event_espresso' ), '&nbsp;' ); ?>
122
+							<a id="hide-tckt-slctr-tkt-details-<?php echo $EVT_ID.'-'.$TKT_ID; ?>" class="hide-tckt-slctr-tkt-details hide-the-displayed lt-grey-text smaller-text hide-if-no-js" rel="tckt-slctr-tkt-details-<?php echo $EVT_ID.'-'.$TKT_ID; ?>" title="<?php echo esc_attr(apply_filters('FHEE__ticket_selector_chart_template__hide_ticket_details_link_title', __('click to hide additional ticket details', 'event_espresso'))); ?>" style="display:none;">
123
+								<?php echo sprintf(__('hide%1$sdetails%1$s-', 'event_espresso'), '&nbsp;'); ?>
124 124
 							</a>
125 125
 						<?php endif; //end show details check ?>
126
-					<?php if ( $ticket->required() ) { ?>
127
-						<p class="ticket-required-pg"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_required_message', __( 'This ticket is required and must be purchased.', 'event_espresso' )); ?></p>
126
+					<?php if ($ticket->required()) { ?>
127
+						<p class="ticket-required-pg"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_required_message', __('This ticket is required and must be purchased.', 'event_espresso')); ?></p>
128 128
 					<?php } ?>
129 129
 					<?php
130 130
 //	echo '<br/><b>$max_atndz : ' . $max_atndz . '</b>';
@@ -138,63 +138,63 @@  discard block
 block discarded – undo
138 138
 //	echo '<br/><b> $ticket->required() : ' .  $ticket->uses() . '</b>';
139 139
 					?>
140 140
 					</td>
141
-					<?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE )) { ?>
142
-					<td class="tckt-slctr-tbl-td-price jst-rght"><?php echo EEH_Template::format_currency( $ticket_price ); ?>&nbsp;<span class="smaller-text no-bold"><?php
143
-						if ( $ticket_bundle ) {
144
-							echo apply_filters( 'FHEE__ticket_selector_chart_template__per_ticket_bundle_text', __( ' / bundle', 'event_espresso' ));
141
+					<?php if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?>
142
+					<td class="tckt-slctr-tbl-td-price jst-rght"><?php echo EEH_Template::format_currency($ticket_price); ?>&nbsp;<span class="smaller-text no-bold"><?php
143
+						if ($ticket_bundle) {
144
+							echo apply_filters('FHEE__ticket_selector_chart_template__per_ticket_bundle_text', __(' / bundle', 'event_espresso'));
145 145
 						} else {
146
-							echo apply_filters( 'FHEE__ticket_selector_chart_template__per_ticket_text', __( '', 'event_espresso' ));
146
+							echo apply_filters('FHEE__ticket_selector_chart_template__per_ticket_text', __('', 'event_espresso'));
147 147
 						}?></span>&nbsp;</td>
148 148
 					<?php } ?>
149 149
 					<td class="tckt-slctr-tbl-td-qty cntr">
150 150
 					<?php
151 151
 					$hidden_input_qty = $max_atndz > 1 ? TRUE : FALSE;
152 152
 					// sold out or other status ?
153
-					if ( $tkt_status == EE_Ticket::sold_out || $remaining == 0 ) {
153
+					if ($tkt_status == EE_Ticket::sold_out || $remaining == 0) {
154 154
 					?>
155
-						<span class="sold-out"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', __( 'Sold&nbsp;Out', 'event_espresso' ));?></span>
155
+						<span class="sold-out"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_sold_out_msg', __('Sold&nbsp;Out', 'event_espresso')); ?></span>
156 156
 					<?php
157
-					} else if ( $tkt_status == EE_Ticket::expired || $tkt_status == EE_Ticket::archived ) {
157
+					} else if ($tkt_status == EE_Ticket::expired || $tkt_status == EE_Ticket::archived) {
158 158
 						echo $ticket_status;
159
-					} else if ( $tkt_status == EE_Ticket::pending ) {
159
+					} else if ($tkt_status == EE_Ticket::pending) {
160 160
 					?>
161 161
 					<div class="ticket-pending-pg">
162
-						<span class="ticket-pending"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', __( 'Goes&nbsp;On&nbsp;Sale', 'event_espresso' )); ?></span><br/>
163
-						<span class="small-text"><?php echo $ticket->get_i18n_datetime( 'TKT_start_date', apply_filters( 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', $date_format ) ); ?></span>
162
+						<span class="ticket-pending"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', __('Goes&nbsp;On&nbsp;Sale', 'event_espresso')); ?></span><br/>
163
+						<span class="small-text"><?php echo $ticket->get_i18n_datetime('TKT_start_date', apply_filters('FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', $date_format)); ?></span>
164 164
 					</div>
165 165
 					<?php
166 166
 					// min qty purchasable is less than tickets available
167
-					} else if ( $ticket->min() > $remaining ) {
167
+					} else if ($ticket->min() > $remaining) {
168 168
 					?>
169 169
 					<div class="archived-ticket-pg">
170
-						<span class="archived-ticket small-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', __( 'Not Available', 'event_espresso' )); ?></span><br/>
170
+						<span class="archived-ticket small-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_not_available_msg', __('Not Available', 'event_espresso')); ?></span><br/>
171 171
 					</div>
172 172
 					<?php
173 173
 					// if only one attendee is allowed to register at a time
174
-					} else if ( $max_atndz  == 1 ) {
174
+					} else if ($max_atndz == 1) {
175 175
 						// display submit button since we have tickets available
176
-						add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
176
+						add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
177 177
 				?>
178
-					<input type="radio" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID . '-' . $row; ?>" class="ticket-selector-tbl-qty-slct" value="<?php echo $row . '-'; ?>1" <?php echo $row == 1 ? ' checked="checked"' : ''; ?>  title=""/>
178
+					<input type="radio" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID.'-'.$row; ?>" class="ticket-selector-tbl-qty-slct" value="<?php echo $row.'-'; ?>1" <?php echo $row == 1 ? ' checked="checked"' : ''; ?>  title=""/>
179 179
 			<?php
180 180
 						$hidden_input_qty = FALSE;
181 181
 
182
-					} else if ( $max_atndz  == 0 ) {
183
-						echo '<span class="sold-out">' . apply_filters( 'FHEE__ticket_selector_chart_template__ticket_closed_msg', __( 'Closed', 'event_espresso' )) . '</span>';
184
-					} elseif ( $max > 0 ) {
182
+					} else if ($max_atndz == 0) {
183
+						echo '<span class="sold-out">'.apply_filters('FHEE__ticket_selector_chart_template__ticket_closed_msg', __('Closed', 'event_espresso')).'</span>';
184
+					} elseif ($max > 0) {
185 185
 						// display submit button since we have tickets available
186
-						add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
186
+						add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
187 187
 
188 188
 				?>
189
-					<select name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID . '-' . $row; ?>" class="ticket-selector-tbl-qty-slct" title="">
189
+					<select name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" id="ticket-selector-tbl-qty-slct-<?php echo $EVT_ID.'-'.$row; ?>" class="ticket-selector-tbl-qty-slct" title="">
190 190
 					<?php
191 191
 						// this ensures that non-required tickets with non-zero MIN QTYs don't HAVE to be purchased
192
-						if ( ! $ticket->required() && $min !== 0 ) {
192
+						if ( ! $ticket->required() && $min !== 0) {
193 193
 					?>
194 194
 						<option value="0">&nbsp;0&nbsp;</option>
195 195
 					<?php }
196 196
 						// offer ticket quantities from the min to the max
197
-						for ( $i = $min; $i <= $max; $i++) {
197
+						for ($i = $min; $i <= $max; $i++) {
198 198
 					?>
199 199
 						<option value="<?php echo $i; ?>">&nbsp;<?php echo $i; ?>&nbsp;</option>
200 200
 					<?php } ?>
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
 					}
206 206
 					// depending on group reg we need to change the format for qty
207
-					if ( $hidden_input_qty ) {
207
+					if ($hidden_input_qty) {
208 208
 					?>
209 209
 					<input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="0" />
210 210
 					<?php
@@ -214,33 +214,33 @@  discard block
 block discarded – undo
214 214
 
215 215
 					</td>
216 216
 				</tr>
217
-				<?php if ( $template_settings->show_ticket_details ) : ?>
218
-					<tr class="tckt-slctr-tkt-details-tr <?php echo espresso_get_object_css_class( $ticket, '', 'details' );?>">
217
+				<?php if ($template_settings->show_ticket_details) : ?>
218
+					<tr class="tckt-slctr-tkt-details-tr <?php echo espresso_get_object_css_class($ticket, '', 'details'); ?>">
219 219
 						<td class="tckt-slctr-tkt-details-td" colspan="3" >
220
-							<div id="tckt-slctr-tkt-details-<?php echo $EVT_ID . '-' . $TKT_ID; ?>-dv" class="tckt-slctr-tkt-details-dv" style="display: none;">
220
+							<div id="tckt-slctr-tkt-details-<?php echo $EVT_ID.'-'.$TKT_ID; ?>-dv" class="tckt-slctr-tkt-details-dv" style="display: none;">
221 221
 
222 222
 								<section class="tckt-slctr-tkt-details-sctn">
223
-									<h3><?php _e( 'Details', 'event_espresso' ); ?></h3>
223
+									<h3><?php _e('Details', 'event_espresso'); ?></h3>
224 224
 									<p><?php echo $ticket->description(); ?></p>
225 225
 
226
-									<?php if ( $ticket_price != 0 && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE )) { ?>
226
+									<?php if ($ticket_price != 0 && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?>
227 227
 									<section class="tckt-slctr-tkt-price-sctn">
228
-										<h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', __( 'Price', 'event_espresso' )); ?></h5>
228
+										<h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', __('Price', 'event_espresso')); ?></h5>
229 229
 										<div class="tckt-slctr-tkt-details-tbl-wrap-dv">
230 230
 											<table class="tckt-slctr-tkt-details-tbl">
231 231
 												<thead>
232 232
 													<tr>
233
-														<th class="ee-third-width"><span class="small-text"><?php _e( 'Name', 'event_espresso' ); ?></span></th>
234
-														<th class="jst-cntr"><span class="small-text"><?php _e( 'Description', 'event_espresso' ); ?></span></th>
235
-														<th class="ee-fourth-width jst-rght"><span class="small-text"><?php _e( 'Amount', 'event_espresso' ); ?></span></th>
233
+														<th class="ee-third-width"><span class="small-text"><?php _e('Name', 'event_espresso'); ?></span></th>
234
+														<th class="jst-cntr"><span class="small-text"><?php _e('Description', 'event_espresso'); ?></span></th>
235
+														<th class="ee-fourth-width jst-rght"><span class="small-text"><?php _e('Amount', 'event_espresso'); ?></span></th>
236 236
 													</tr>
237 237
 												</thead>
238 238
 												<tbody>
239
-										<?php if ( $ticket->base_price() instanceof EE_Price ) { ?>
239
+										<?php if ($ticket->base_price() instanceof EE_Price) { ?>
240 240
 													<tr>
241
-														<td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="small-text"><b><?php echo $ticket->base_price()->name(); ?></b></td>
242
-														<td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $ticket->base_price()->desc(); ?></td>
243
-														<td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $ticket->base_price()->pretty_price(); ?></td>
241
+														<td data-th="<?php _e('Name', 'event_espresso'); ?>" class="small-text"><b><?php echo $ticket->base_price()->name(); ?></b></td>
242
+														<td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $ticket->base_price()->desc(); ?></td>
243
+														<td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $ticket->base_price()->pretty_price(); ?></td>
244 244
 													</tr>
245 245
 													<?php
246 246
 															$running_total = $ticket->base_price()->amount();
@@ -248,44 +248,44 @@  discard block
 block discarded – undo
248 248
 															$running_total = 0;
249 249
 														}
250 250
 														// now add price modifiers
251
-														foreach ( $ticket->price_modifiers() as $price_mod ) { ?>
251
+														foreach ($ticket->price_modifiers() as $price_mod) { ?>
252 252
 													<tr>
253
-														<td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $price_mod->name(); ?></td>
254
-													<?php if ( $price_mod->is_percent() ) { ?>
255
-														<td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $price_mod->desc(); ?> <?php echo $price_mod->amount(); ?>%</td>
253
+														<td data-th="<?php _e('Name', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $price_mod->name(); ?></td>
254
+													<?php if ($price_mod->is_percent()) { ?>
255
+														<td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $price_mod->desc(); ?> <?php echo $price_mod->amount(); ?>%</td>
256 256
 														<?php
257
-															$new_sub_total = $running_total * ( $price_mod->amount() / 100 );
257
+															$new_sub_total = $running_total * ($price_mod->amount() / 100);
258 258
 															$new_sub_total = $price_mod->is_discount() ? $new_sub_total * -1 : $new_sub_total;
259 259
 														?>
260 260
 													<?php } else { ?>
261 261
 														<?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 : $price_mod->amount(); ?>
262
-														<td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="small-text"><?php echo $price_mod->desc(); ?></td>
262
+														<td data-th="<?php _e('Description', 'event_espresso'); ?>" class="small-text"><?php echo $price_mod->desc(); ?></td>
263 263
 														<?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 : $price_mod->amount(); ?>
264 264
 													<?php } ?>
265
-														<td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency( $new_sub_total ); ?></td>
265
+														<td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency($new_sub_total); ?></td>
266 266
 														<?php $running_total += $new_sub_total; ?>
267 267
 													</tr>
268 268
 												<?php } ?>
269
-												<?php if ( $ticket->taxable() ) { ?>
269
+												<?php if ($ticket->taxable()) { ?>
270 270
 													<?php //$ticket_subtotal =$ticket->get_ticket_subtotal(); ?>
271 271
 													<tr>
272
-														<td colspan="2" class="jst-rght small-text sbttl"><b><?php _e( 'subtotal', 'event_espresso' ); ?></b></td>
273
-														<td data-th="<?php _e( 'subtotal', 'event_espresso' ); ?>" class="jst-rght small-text"><b><?php echo  EEH_Template::format_currency( $running_total ); ?></b></td>
272
+														<td colspan="2" class="jst-rght small-text sbttl"><b><?php _e('subtotal', 'event_espresso'); ?></b></td>
273
+														<td data-th="<?php _e('subtotal', 'event_espresso'); ?>" class="jst-rght small-text"><b><?php echo  EEH_Template::format_currency($running_total); ?></b></td>
274 274
 													</tr>
275 275
 
276
-													<?php foreach ( $ticket->get_ticket_taxes_for_admin() as $tax ) { ?>
276
+													<?php foreach ($ticket->get_ticket_taxes_for_admin() as $tax) { ?>
277 277
 													<tr>
278
-														<td data-th="<?php _e( 'Name', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $tax->name(); ?></td>
279
-														<td data-th="<?php _e( 'Description', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo $tax->amount(); ?>%</td>
280
-														<?php $tax_amount = $running_total * ( $tax->amount() / 100 ); ?>
281
-														<td data-th="<?php _e( 'Amount', 'event_espresso' ); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency( $tax_amount ); ?></td>
278
+														<td data-th="<?php _e('Name', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $tax->name(); ?></td>
279
+														<td data-th="<?php _e('Description', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo $tax->amount(); ?>%</td>
280
+														<?php $tax_amount = $running_total * ($tax->amount() / 100); ?>
281
+														<td data-th="<?php _e('Amount', 'event_espresso'); ?>" class="jst-rght small-text"><?php echo EEH_Template::format_currency($tax_amount); ?></td>
282 282
 														<?php $running_total += $tax_amount; ?>
283 283
 													</tr>
284 284
 													<?php } ?>
285 285
 												<?php } ?>
286 286
 													<tr>
287
-														<td colspan="2" class="jst-rght small-text ttl-lbl-td"><b><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_total_price', __( 'Total', 'event_espresso' )); ?></b></td>
288
-														<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_total_price', __( 'Total', 'event_espresso' )); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency( $running_total ); ?></b></td>
287
+														<td colspan="2" class="jst-rght small-text ttl-lbl-td"><b><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', __('Total', 'event_espresso')); ?></b></td>
288
+														<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', __('Total', 'event_espresso')); ?>" class="jst-rght small-text"><b><?php echo EEH_Template::format_currency($running_total); ?></b></td>
289 289
 													</tr>
290 290
 												</tbody>
291 291
 											</table>
@@ -295,106 +295,106 @@  discard block
 block discarded – undo
295 295
 									<?php } ?>
296 296
 
297 297
 									<section class="tckt-slctr-tkt-sale-dates-sctn">
298
-										<h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', __( 'Sale Dates', 'event_espresso' )); ?></h5>
299
-										<span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', __( 'The dates when this option is available for purchase.', 'event_espresso' )); ?></span><br/>
300
-										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', __( 'Goes On Sale:', 'event_espresso' )); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime( 'TKT_start_date', $date_format) . ' &nbsp; '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime( 'TKT_start_date',  $time_format ) ; ?><br/>
301
-										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', __( 'Sales End:', 'event_espresso' )); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime( 'TKT_end_date', $date_format ) . ' &nbsp; '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime( 'TKT_end_date', $time_format ) ; ?><br/>
298
+										<h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', __('Sale Dates', 'event_espresso')); ?></h5>
299
+										<span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', __('The dates when this option is available for purchase.', 'event_espresso')); ?></span><br/>
300
+										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', __('Goes On Sale:', 'event_espresso')); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime('TKT_start_date', $date_format).' &nbsp; '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime('TKT_start_date', $time_format); ?><br/>
301
+										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_sales_end', __('Sales End:', 'event_espresso')); ?></span><span class="dashicons dashicons-calendar"></span><?php echo $ticket->get_i18n_datetime('TKT_end_date', $date_format).' &nbsp; '; ?><span class="dashicons dashicons-clock"></span><?php echo $ticket->get_i18n_datetime('TKT_end_date', $time_format); ?><br/>
302 302
 									</section>
303 303
 									<br/>
304 304
 
305
-									<?php do_action( 'AHEE__ticket_selector_chart_template__after_ticket_date', $ticket ); ?>
305
+									<?php do_action('AHEE__ticket_selector_chart_template__after_ticket_date', $ticket); ?>
306 306
 
307
-									<?php if ( $ticket->min() &&$ticket->max() ) { ?>
307
+									<?php if ($ticket->min() && $ticket->max()) { ?>
308 308
 									<section class="tckt-slctr-tkt-quantities-sctn">
309
-										<h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', __( 'Purchasable Quantities', 'event_espresso' )); ?></h5>
310
-										<span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', __( 'The number of tickets that can be purchased per transaction (if available).', 'event_espresso' )); ?></span><br/>
311
-										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', __( 'Minimum Qty:', 'event_espresso' )); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?>
312
-										<?php if ( $ticket->min() > $remaining ) { ?> &nbsp; <span class="important-notice small-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', __( 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', 'event_espresso' )); ?></span><?php } ?><br/>
309
+										<h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', __('Purchasable Quantities', 'event_espresso')); ?></h5>
310
+										<span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', __('The number of tickets that can be purchased per transaction (if available).', 'event_espresso')); ?></span><br/>
311
+										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', __('Minimum Qty:', 'event_espresso')); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?>
312
+										<?php if ($ticket->min() > $remaining) { ?> &nbsp; <span class="important-notice small-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', __('The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', 'event_espresso')); ?></span><?php } ?><br/>
313 313
 										<?php //$max = min( $max, $max_atndz );?>
314
-										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', __( 'Maximum Qty:', 'event_espresso' )); ?></span><?php echo $ticket->max() === EE_INF ? __( 'no limit', 'event_espresso' ) : max( $ticket->max(), 1 ); ?><br/>
314
+										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', __('Maximum Qty:', 'event_espresso')); ?></span><?php echo $ticket->max() === EE_INF ? __('no limit', 'event_espresso') : max($ticket->max(), 1); ?><br/>
315 315
 									</section>
316 316
 									<br/>
317 317
 									<?php } ?>
318 318
 
319
-									<?php if ( $ticket->uses() !== EE_INF && ( ! defined( 'EE_DECAF' ) || EE_DECAF !== TRUE )) { ?>
319
+									<?php if ($ticket->uses() !== EE_INF && ( ! defined('EE_DECAF') || EE_DECAF !== TRUE)) { ?>
320 320
 									<section class="tckt-slctr-tkt-uses-sctn">
321
-										<h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', __( 'Event Date Ticket Uses', 'event_espresso' )); ?></h5>
321
+										<h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', __('Event Date Ticket Uses', 'event_espresso')); ?></h5>
322 322
 										<span class="drk-grey-text small-text no-bold"> - <?php
323 323
 											echo apply_filters(
324 324
 												'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message',
325 325
 												sprintf(
326
-													__( 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', 'event_espresso' ),
326
+													__('The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', 'event_espresso'),
327 327
 													'<br/>',
328 328
 													'<strong>',
329 329
 													'</strong>'
330 330
 												)
331 331
 											);
332 332
 											?></span><br/>
333
-										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', __( '# Datetimes:', 'event_espresso' )); ?></span><?php  echo $ticket->uses();?><br/>
333
+										<span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', __('# Datetimes:', 'event_espresso')); ?></span><?php  echo $ticket->uses(); ?><br/>
334 334
 									</section>
335 335
 									<?php } ?>
336 336
 
337 337
 									<?php
338
-									$datetimes = $ticket->datetimes_ordered( $event_is_expired, FALSE );
338
+									$datetimes = $ticket->datetimes_ordered($event_is_expired, FALSE);
339 339
 									$chart_column_width = $template_settings->show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width';
340
-									if ( ! empty( $datetimes )) { ?>
340
+									if ( ! empty($datetimes)) { ?>
341 341
 									<section class="tckt-slctr-tkt-datetimes-sctn">
342
-										<h5><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', __( 'Access', 'event_espresso' )); ?></h5>
343
-										<span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', __( 'This option allows access to the following dates and times.', 'event_espresso' )); ?></span>
342
+										<h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', __('Access', 'event_espresso')); ?></h5>
343
+										<span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_message', __('This option allows access to the following dates and times.', 'event_espresso')); ?></span>
344 344
 										<div class="tckt-slctr-tkt-details-tbl-wrap-dv">
345 345
 											<table class="tckt-slctr-tkt-details-tbl">
346 346
 												<thead>
347 347
 													<tr>
348 348
 														<th class="tckt-slctr-tkt-details-date-th">
349
-															<span class="dashicons dashicons-calendar"></span><span class="small-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __( 'Date ', 'event_espresso' )); ?></span>
349
+															<span class="dashicons dashicons-calendar"></span><span class="small-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __('Date ', 'event_espresso')); ?></span>
350 350
 														</th>
351 351
 														<th class="tckt-slctr-tkt-details-time-th <?php echo $chart_column_width; ?>">
352
-															<span class="dashicons dashicons-clock"></span><span class="small-text"><?php _e( 'Time ', 'event_espresso' ); ?></span>
352
+															<span class="dashicons dashicons-clock"></span><span class="small-text"><?php _e('Time ', 'event_espresso'); ?></span>
353 353
 														</th>
354
-														<?php if ( $template_settings->show_ticket_sale_columns ) : ?>
354
+														<?php if ($template_settings->show_ticket_sale_columns) : ?>
355 355
 															<th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr">
356
-																<span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', sprintf( __( 'Sold', 'event_espresso' ), '<br/>' )); ?></span>
356
+																<span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', sprintf(__('Sold', 'event_espresso'), '<br/>')); ?></span>
357 357
 															</th>
358 358
 															<th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr">
359
-																<span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', sprintf( __( 'Remaining', 'event_espresso' ), '<br/>' )); ?></span>
359
+																<span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', sprintf(__('Remaining', 'event_espresso'), '<br/>')); ?></span>
360 360
 															</th>
361 361
 															<th class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr">
362
-																<span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', sprintf( __( 'Total%sSold', 'event_espresso' ), '<br/>' )); ?></span>
362
+																<span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', sprintf(__('Total%sSold', 'event_espresso'), '<br/>')); ?></span>
363 363
 															</th>
364 364
 															<th class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr">
365
-																<span class="smaller-text"><?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', sprintf( __( 'Total Spaces%sLeft', 'event_espresso' ), '<br/>' )); ?></span>
365
+																<span class="smaller-text"><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', sprintf(__('Total Spaces%sLeft', 'event_espresso'), '<br/>')); ?></span>
366 366
 															</th>
367 367
 														<?php endif; //end $template_settings->show_ticket_sale_columns conditional ?>
368 368
 													</tr>
369 369
 												</thead>
370 370
 												<tbody>
371 371
 											<?php
372
-												foreach ( $datetimes as $datetime ) {
373
-													if ( $datetime instanceof EE_Datetime ) {
372
+												foreach ($datetimes as $datetime) {
373
+													if ($datetime instanceof EE_Datetime) {
374 374
 											?>
375 375
 
376 376
 												<tr>
377
-													<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __( 'Event Date ', 'event_espresso' )); ?>" class="small-text">
377
+													<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', __('Event Date ', 'event_espresso')); ?>" class="small-text">
378 378
 														<?php $datetime_name = $datetime->name(); ?>
379
-														<?php echo ! empty( $datetime_name ) ? '<b>' . $datetime_name . '</b><br/>' : ''; ?>
380
-														<?php echo $datetime->date_range( $date_format, __( ' to  ', 'event_espresso' )); ?>
379
+														<?php echo ! empty($datetime_name) ? '<b>'.$datetime_name.'</b><br/>' : ''; ?>
380
+														<?php echo $datetime->date_range($date_format, __(' to  ', 'event_espresso')); ?>
381 381
 													</td>
382
-													<td data-th="<?php _e( 'Time ', 'event_espresso' ); ?>" class="cntr small-text">
383
-														<?php echo $datetime->time_range( $time_format, __( ' to  ', 'event_espresso' )); ?>
382
+													<td data-th="<?php _e('Time ', 'event_espresso'); ?>" class="cntr small-text">
383
+														<?php echo $datetime->time_range($time_format, __(' to  ', 'event_espresso')); ?>
384 384
 													</td>
385
-													<?php if ( $template_settings->show_ticket_sale_columns ) : ?>
386
-														<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', __( 'Sold', 'event_espresso' )); ?>" class="cntr small-text">
385
+													<?php if ($template_settings->show_ticket_sale_columns) : ?>
386
+														<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', __('Sold', 'event_espresso')); ?>" class="cntr small-text">
387 387
 															<?php echo $ticket->sold(); ?>
388 388
 														</td>
389
-														<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', __( 'Remaining', 'event_espresso' )); ?>" class="cntr small-text">
390
-															<?php echo $ticket->qty() === EE_INF ? '<span class="smaller-text">' .  __( 'unlimited ', 'event_espresso' ) . '</span>' : $ticket->qty() - $ticket->sold(); ?>
389
+														<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', __('Remaining', 'event_espresso')); ?>" class="cntr small-text">
390
+															<?php echo $ticket->qty() === EE_INF ? '<span class="smaller-text">'.__('unlimited ', 'event_espresso').'</span>' : $ticket->qty() - $ticket->sold(); ?>
391 391
 														</td>
392
-														<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', __( 'Total Sold', 'event_espresso' )); ?>" class="cntr small-text">
392
+														<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', __('Total Sold', 'event_espresso')); ?>" class="cntr small-text">
393 393
 															<?php echo $datetime->sold(); ?>
394 394
 														</td>
395
-												<?php $tkts_left = $datetime->sold_out() ? '<span class="sold-out smaller-text">' . __( 'Sold&nbsp;Out', 'event_espresso' ) . '</span>' : $datetime->spaces_remaining(); ?>
396
-														<td data-th="<?php echo apply_filters( 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', __( 'Total Spaces Left', 'event_espresso' )); ?>" class="cntr small-text">
397
-															<?php echo $tkts_left === EE_INF ? '<span class="smaller-text">' .  __( 'unlimited ', 'event_espresso' ) . '</span>' : $tkts_left; ?>
395
+												<?php $tkts_left = $datetime->sold_out() ? '<span class="sold-out smaller-text">'.__('Sold&nbsp;Out', 'event_espresso').'</span>' : $datetime->spaces_remaining(); ?>
396
+														<td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', __('Total Spaces Left', 'event_espresso')); ?>" class="cntr small-text">
397
+															<?php echo $tkts_left === EE_INF ? '<span class="smaller-text">'.__('unlimited ', 'event_espresso').'</span>' : $tkts_left; ?>
398 398
 														</td>
399 399
 													<?php endif; //end $template_settings->show_ticket_sale_columns conditional ?>
400 400
 												</tr>
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 							</div>
413 413
 						</td>
414 414
 					</tr>
415
-				<?php endif;  //end template_settings->show_ticket_details check?>
415
+				<?php endif; //end template_settings->show_ticket_details check?>
416 416
 	<?php
417 417
 			$row++;
418 418
 		}
@@ -421,32 +421,32 @@  discard block
 block discarded – undo
421 421
 $ticket_row_html = ob_get_clean();
422 422
 // if there is only ONE ticket with a max qty of ONE, and it is free... then not much need for the ticket selector
423 423
 $hide_ticket_selector = $ticket_count == 1 && $max == 1 && $ticket->is_free() ? true : false;
424
-$hide_ticket_selector = apply_filters( 'FHEE__ticket_selector_chart_template__hide_ticket_selector', $hide_ticket_selector, $EVT_ID );
424
+$hide_ticket_selector = apply_filters('FHEE__ticket_selector_chart_template__hide_ticket_selector', $hide_ticket_selector, $EVT_ID);
425 425
 //EEH_Debug_Tools::printr( $ticket_count, '$ticket_count', __FILE__, __LINE__ );
426 426
 //EEH_Debug_Tools::printr( $max, '$max', __FILE__, __LINE__ );
427 427
 //EEH_Debug_Tools::printr( $hide_ticket_selector, '$hide_ticket_selector', __FILE__, __LINE__ );
428 428
 //EEH_Debug_Tools::printr( $table_style, '$table_style', __FILE__, __LINE__ );
429 429
 remove_filter(
430 430
 	'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
431
-	array( 'EED_Ticket_Selector', 'no_tkt_slctr_end_dv' )
431
+	array('EED_Ticket_Selector', 'no_tkt_slctr_end_dv')
432 432
 );
433 433
 remove_filter(
434 434
 	'FHEE__EE_Ticket_Selector__after_view_details_btn',
435
-	array( 'EED_Ticket_Selector', 'no_tkt_slctr_end_dv' )
435
+	array('EED_Ticket_Selector', 'no_tkt_slctr_end_dv')
436 436
 );
437
-if ( ! $hide_ticket_selector ) {
437
+if ( ! $hide_ticket_selector) {
438 438
 ?>
439 439
 <div id="tkt-slctr-tbl-wrap-dv-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl-wrap-dv">
440 440
 
441
-	<?php do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); ?>
441
+	<?php do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); ?>
442 442
 
443 443
 	<table id="tkt-slctr-tbl-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl">
444 444
 		<thead>
445 445
 			<tr>
446 446
 				<th scope="col" class="ee-ticket-selector-ticket-details-th">
447
-					<?php echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_available_tickets', '', $EVT_ID ) ); ?>
447
+					<?php echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_available_tickets', '', $EVT_ID)); ?>
448 448
 				</th>
449
-				<?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE )) { ?>
449
+				<?php if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?>
450 450
 				<th scope="col" class="ee-ticket-selector-ticket-price-th cntr">
451 451
 					<?php
452 452
 						/**
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 						 * @param string 'Price' The translatable text to display in the table header for price
458 458
 						 * @param int $EVT_ID The Event ID
459 459
 						 */
460
-						echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_price', __( 'Price', 'event_espresso' ), $EVT_ID ) );
460
+						echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_price', __('Price', 'event_espresso'), $EVT_ID));
461 461
 					?>
462 462
 				</th>
463 463
 				<?php } ?>
@@ -471,24 +471,24 @@  discard block
 block discarded – undo
471 471
 						* @param string 'Qty*' The translatable text to display in the table header for the Quantity of tickets
472 472
 						* @param int $EVT_ID The Event ID
473 473
 						*/
474
-						echo esc_html( apply_filters( 'FHEE__ticket_selector_chart_template__table_header_qty', __( 'Qty*', 'event_espresso' ), $EVT_ID ) );
474
+						echo esc_html(apply_filters('FHEE__ticket_selector_chart_template__table_header_qty', __('Qty*', 'event_espresso'), $EVT_ID));
475 475
 					?>
476 476
 				</th>
477 477
 			</tr>
478 478
 		</thead>
479 479
 		<tbody>
480
-			<?php echo $ticket_row_html;?>
480
+			<?php echo $ticket_row_html; ?>
481 481
 		</tbody>
482 482
 	</table>
483 483
 
484 484
 	<input type="hidden" name="noheader" value="true" />
485
-	<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url();?>" />
485
+	<input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::filter_input_server_url(); ?>" />
486 486
 	<input type="hidden" name="tkt-slctr-rows-<?php echo $EVT_ID; ?>" value="<?php echo $row - 1; ?>" />
487 487
 	<input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?>" value="<?php echo $max_atndz; ?>" />
488 488
 	<input type="hidden" name="tkt-slctr-event-id" value="<?php echo $EVT_ID; ?>" />
489 489
 
490 490
 <?php
491
-if ( $max_atndz > 0 && ! $hide_ticket_selector ) {
491
+if ($max_atndz > 0 && ! $hide_ticket_selector) {
492 492
 	echo apply_filters(
493 493
 		'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote',
494 494
 		''
@@ -496,10 +496,10 @@  discard block
 block discarded – undo
496 496
 }
497 497
 ?>
498 498
 
499
-	<?php do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); ?>
499
+	<?php do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); ?>
500 500
 
501 501
 </div>
502
-<?php } else if ( isset( $TKT_ID ) ) { ?>
502
+<?php } else if (isset($TKT_ID)) { ?>
503 503
 <input type="hidden" name="tkt-slctr-qty-<?php echo $EVT_ID; ?>[]" value="1"/>
504 504
 <input type="hidden" name="tkt-slctr-ticket-id-<?php echo $EVT_ID; ?>[]" value="<?php echo $TKT_ID; ?>"/>
505 505
 <input type="hidden" name="noheader" value="true"/>
@@ -508,27 +508,27 @@  discard block
 block discarded – undo
508 508
 <input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?>" value="<?php echo $max_atndz; ?>"/>
509 509
 <input type="hidden" name="tkt-slctr-event-id" value="<?php echo $EVT_ID; ?>"/>
510 510
 <?php
511
-	if ( $ticket instanceof EE_Ticket ) {
512
-		do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event );
511
+	if ($ticket instanceof EE_Ticket) {
512
+		do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event);
513 513
 		$ticket_description = $ticket->description();
514 514
 ?>
515 515
 <div id="no-tkt-slctr-ticket-dv-<?php echo $EVT_ID; ?>" class="no-tkt-slctr-ticket-dv">
516 516
 	<div class="no-tkt-slctr-ticket-content-dv">
517 517
 		<h5><?php echo $ticket->name(); ?></h5>
518
-		<?php if ( ! empty( $ticket_description ) ) { ?>
518
+		<?php if ( ! empty($ticket_description)) { ?>
519 519
 		<p><?php echo $ticket_description; ?></p>
520 520
 		<?php } ?>
521 521
 	</div>
522 522
 <?php
523 523
 		add_filter(
524 524
 			'FHEE__EE_Ticket_Selector__after_ticket_selector_submit',
525
-			array( 'EED_Ticket_Selector', 'no_tkt_slctr_end_dv' )
525
+			array('EED_Ticket_Selector', 'no_tkt_slctr_end_dv')
526 526
 		);
527 527
 		add_filter(
528 528
 			'FHEE__EE_Ticket_Selector__after_view_details_btn',
529
-			array( 'EED_Ticket_Selector', 'no_tkt_slctr_end_dv' )
529
+			array('EED_Ticket_Selector', 'no_tkt_slctr_end_dv')
530 530
 		);
531
-		do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event );
531
+		do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event);
532 532
 	}
533 533
 }
534 534
 ?>
Please login to merge, or discard this patch.
core/db_classes/EE_Transaction.class.php 1 patch
Spacing   +111 added lines, -111 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
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @subpackage 	includes/classes/EE_Transaction.class.php
27 27
  * @author 				Brent Christensen
28 28
  */
29
-class EE_Transaction extends EE_Base_Class implements EEI_Transaction{
29
+class EE_Transaction extends EE_Base_Class implements EEI_Transaction {
30 30
 
31 31
 
32 32
 	/**
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 *                             		    date_format and the second value is the time format
39 39
 	 * @return EE_Transaction
40 40
 	 */
41
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
42
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
43
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
41
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
42
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
43
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
44 44
 	}
45 45
 
46 46
 
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 *                          		the website will be used.
52 52
 	 * @return EE_Attendee
53 53
 	 */
54
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
55
-		return new self( $props_n_values, TRUE, $timezone );
54
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
55
+		return new self($props_n_values, TRUE, $timezone);
56 56
 	}
57 57
 
58 58
 
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 * @return 	void
68 68
 	 */
69 69
 	public function lock() {
70
-		$locked_transactions = get_option( 'ee_locked_transactions', array() );
71
-		$locked_transactions[ $this->ID() ] = true;
72
-		update_option( 'ee_locked_transactions', $locked_transactions );
70
+		$locked_transactions = get_option('ee_locked_transactions', array());
71
+		$locked_transactions[$this->ID()] = true;
72
+		update_option('ee_locked_transactions', $locked_transactions);
73 73
 	}
74 74
 
75 75
 
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 	 * @return 	void
84 84
 	 */
85 85
 	public function unlock() {
86
-		$locked_transactions = get_option( 'ee_locked_transactions', array() );
87
-		unset( $locked_transactions[ $this->ID() ] );
88
-		update_option( 'ee_locked_transactions', $locked_transactions );
86
+		$locked_transactions = get_option('ee_locked_transactions', array());
87
+		unset($locked_transactions[$this->ID()]);
88
+		update_option('ee_locked_transactions', $locked_transactions);
89 89
 	}
90 90
 
91 91
 	/**
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	 * @return boolean
103 103
 	 */
104 104
 	public function is_locked() {
105
-		$locked_transactions = get_option( 'ee_locked_transactions', array() );
106
-		return isset( $locked_transactions[ $this->ID() ] ) ? true : false;
105
+		$locked_transactions = get_option('ee_locked_transactions', array());
106
+		return isset($locked_transactions[$this->ID()]) ? true : false;
107 107
 	}
108 108
 
109 109
 
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * @access        public
115 115
 	 * @param        float $total total value of transaction
116 116
 	 */
117
-	public function set_total( $total = 0.00 ) {
118
-		$this->set( 'TXN_total', $total );
117
+	public function set_total($total = 0.00) {
118
+		$this->set('TXN_total', $total);
119 119
 	}
120 120
 
121 121
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 * @access        public
127 127
 	 * @param        float $total_paid total amount paid to date (sum of all payments)
128 128
 	 */
129
-	public function set_paid( $total_paid = 0.00 ) {
130
-		$this->set( 'TXN_paid', $total_paid );
129
+	public function set_paid($total_paid = 0.00) {
130
+		$this->set('TXN_paid', $total_paid);
131 131
 	}
132 132
 
133 133
 
@@ -138,8 +138,8 @@  discard block
 block discarded – undo
138 138
 	 * @access        public
139 139
 	 * @param        string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set
140 140
 	 */
141
-	public function set_status( $status = '' ) {
142
-		$this->set( 'STS_ID', $status );
141
+	public function set_status($status = '') {
142
+		$this->set('STS_ID', $status);
143 143
 	}
144 144
 
145 145
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @access        public
151 151
 	 * @param        string $hash_salt required for some payment gateways
152 152
 	 */
153
-	public function set_hash_salt( $hash_salt = '' ) {
154
-		$this->set( 'TXN_hash_salt', $hash_salt );
153
+	public function set_hash_salt($hash_salt = '') {
154
+		$this->set('TXN_hash_salt', $hash_salt);
155 155
 	}
156 156
 
157 157
 
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 * Sets TXN_reg_steps array
161 161
 	 * @param array $txn_reg_steps
162 162
 	 */
163
-	function set_reg_steps( $txn_reg_steps ) {
164
-		$this->set( 'TXN_reg_steps', $txn_reg_steps );
163
+	function set_reg_steps($txn_reg_steps) {
164
+		$this->set('TXN_reg_steps', $txn_reg_steps);
165 165
 	}
166 166
 
167 167
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @return array
172 172
 	 */
173 173
 	function reg_steps() {
174
-		$TXN_reg_steps = $this->get( 'TXN_reg_steps' );
175
-		return is_array( $TXN_reg_steps ) ? $TXN_reg_steps : array();
174
+		$TXN_reg_steps = $this->get('TXN_reg_steps');
175
+		return is_array($TXN_reg_steps) ? $TXN_reg_steps : array();
176 176
 	}
177 177
 
178 178
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @return string of transaction's total cost, with currency symbol and decimal
183 183
 	 */
184 184
 	public function pretty_total() {
185
-		return $this->get_pretty( 'TXN_total' );
185
+		return $this->get_pretty('TXN_total');
186 186
 	}
187 187
 
188 188
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @return string
193 193
 	 */
194 194
 	public function pretty_paid() {
195
-		return $this->get_pretty( 'TXN_paid' );
195
+		return $this->get_pretty('TXN_paid');
196 196
 	}
197 197
 
198 198
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @return float amount remaining
205 205
 	 */
206 206
 	public function remaining() {
207
-		return (float)( $this->total() - $this->paid() );
207
+		return (float) ($this->total() - $this->paid());
208 208
 	}
209 209
 
210 210
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 * @return float
216 216
 	 */
217 217
 	public function total() {
218
-		return $this->get( 'TXN_total' );
218
+		return $this->get('TXN_total');
219 219
 	}
220 220
 
221 221
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @return float
227 227
 	 */
228 228
 	public function paid() {
229
-		return $this->get( 'TXN_paid' );
229
+		return $this->get('TXN_paid');
230 230
 	}
231 231
 
232 232
 
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 	 * @access        public
237 237
 	 */
238 238
 	public function get_cart_session() {
239
-		$session_data = $this->get( 'TXN_session_data' );
240
-		return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart ? $session_data[ 'cart' ] : NULL;
239
+		$session_data = $this->get('TXN_session_data');
240
+		return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart ? $session_data['cart'] : NULL;
241 241
 	}
242 242
 
243 243
 
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 	 * @access        public
248 248
 	 */
249 249
 	public function session_data() {
250
-		$session_data = $this->get( 'TXN_session_data' );
251
-		if ( empty( $session_data ) ) {
252
-			$session_data = array( 'id' => NULL, 'user_id' => NULL, 'ip_address' => NULL, 'user_agent' => NULL, 'init_access' => NULL, 'last_access' => NULL, 'pages_visited' => array() );
250
+		$session_data = $this->get('TXN_session_data');
251
+		if (empty($session_data)) {
252
+			$session_data = array('id' => NULL, 'user_id' => NULL, 'ip_address' => NULL, 'user_agent' => NULL, 'init_access' => NULL, 'last_access' => NULL, 'pages_visited' => array());
253 253
 		}
254 254
 		return $session_data;
255 255
 	}
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
 	 * @access        public
263 263
 	 * @param        EE_Session|array $session_data
264 264
 	 */
265
-	public function set_txn_session_data( $session_data ) {
266
-		if ( $session_data instanceof EE_Session ) {
267
-			$this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE ));
265
+	public function set_txn_session_data($session_data) {
266
+		if ($session_data instanceof EE_Session) {
267
+			$this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE));
268 268
 		} else {
269
-			$this->set( 'TXN_session_data', $session_data );
269
+			$this->set('TXN_session_data', $session_data);
270 270
 		}
271 271
 	}
272 272
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 * @access        public
278 278
 	 */
279 279
 	public function hash_salt_() {
280
-		return $this->get( 'TXN_hash_salt' );
280
+		return $this->get('TXN_hash_salt');
281 281
 	}
282 282
 
283 283
 
@@ -297,13 +297,13 @@  discard block
 block discarded – undo
297 297
 	 * @param 	boolean 	$gmt - whether to return a unix timestamp with UTC offset applied (default) or no UTC offset applied
298 298
 	 * @return 	string | int
299 299
 	 */
300
-	public function datetime( $format = FALSE, $gmt = FALSE ) {
301
-		if ( $format ) {
302
-			return $this->get_pretty( 'TXN_timestamp' );
303
-		} else if ( $gmt ) {
304
-			return $this->get_raw( 'TXN_timestamp' );
300
+	public function datetime($format = FALSE, $gmt = FALSE) {
301
+		if ($format) {
302
+			return $this->get_pretty('TXN_timestamp');
303
+		} else if ($gmt) {
304
+			return $this->get_raw('TXN_timestamp');
305 305
 		} else {
306
-			return $this->get( 'TXN_timestamp' );
306
+			return $this->get('TXN_timestamp');
307 307
 		}
308 308
 	}
309 309
 
@@ -315,10 +315,10 @@  discard block
 block discarded – undo
315 315
 	 * @param        boolean $get_cached   TRUE to retrieve cached registrations or FALSE to pull from the db
316 316
 	 * @return EE_Registration[]
317 317
 	 */
318
-	public function registrations( $query_params = array(), $get_cached = FALSE ) {
319
-		$query_params = ( empty( $query_params ) || ! is_array( $query_params ) ) ? array( 'order_by' => array( 'Event.EVT_name' => 'ASC', 'Attendee.ATT_lname' => 'ASC', 'Attendee.ATT_fname' => 'ASC' ) ) : $query_params;
318
+	public function registrations($query_params = array(), $get_cached = FALSE) {
319
+		$query_params = (empty($query_params) || ! is_array($query_params)) ? array('order_by' => array('Event.EVT_name' => 'ASC', 'Attendee.ATT_lname' => 'ASC', 'Attendee.ATT_fname' => 'ASC')) : $query_params;
320 320
 		$query_params = $get_cached ? array() : $query_params;
321
-		return $this->get_many_related( 'Registration', $query_params );
321
+		return $this->get_many_related('Registration', $query_params);
322 322
 	}
323 323
 
324 324
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	 * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT'
330 330
 	 */
331 331
 	public function attendees() {
332
-		return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) );
332
+		return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID())));
333 333
 	}
334 334
 
335 335
 
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param array $query_params like EEM_Base::get_all
340 340
 	 * @return EE_Payment[]
341 341
 	 */
342
-	public function payments( $query_params = array() ) {
343
-		return $this->get_many_related( 'Payment', $query_params );
342
+	public function payments($query_params = array()) {
343
+		return $this->get_many_related('Payment', $query_params);
344 344
 	}
345 345
 
346 346
 
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
 	 * @return EE_Payment[]
351 351
 	 */
352 352
 	public function approved_payments() {
353
-		EE_Registry::instance()->load_model( 'Payment' );
354
-		return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) );
353
+		EE_Registry::instance()->load_model('Payment');
354
+		return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC')));
355 355
 	}
356 356
 
357 357
 
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
 	 * @param bool $show_icons
362 362
 	 * @return string
363 363
 	 */
364
-	public function e_pretty_status( $show_icons = FALSE ) {
365
-		echo $this->pretty_status( $show_icons );
364
+	public function e_pretty_status($show_icons = FALSE) {
365
+		echo $this->pretty_status($show_icons);
366 366
 	}
367 367
 
368 368
 
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 	 * @param bool $show_icons
373 373
 	 * @return string
374 374
 	 */
375
-	public function pretty_status( $show_icons = FALSE ) {
376
-		$status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' );
375
+	public function pretty_status($show_icons = FALSE) {
376
+		$status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence');
377 377
 		$icon = '';
378
-		switch ( $this->status_ID() ) {
378
+		switch ($this->status_ID()) {
379 379
 			case EEM_Transaction::complete_status_code:
380 380
 				$icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : '';
381 381
 				break;
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 				$icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : '';
393 393
 				break;
394 394
 		}
395
-		return $icon . $status[ $this->status_ID() ];
395
+		return $icon.$status[$this->status_ID()];
396 396
 	}
397 397
 
398 398
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 	 * @access        public
403 403
 	 */
404 404
 	public function status_ID() {
405
-		return $this->get( 'STS_ID' );
405
+		return $this->get('STS_ID');
406 406
 	}
407 407
 
408 408
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * @return boolean
413 413
 	 */
414 414
 	public function is_free() {
415
-		return (float)$this->get( 'TXN_total' ) == 0 ? TRUE : FALSE;
415
+		return (float) $this->get('TXN_total') == 0 ? TRUE : FALSE;
416 416
 	}
417 417
 
418 418
 
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
 	 * @access public
481 481
 	 * @return string
482 482
 	 */
483
-	public function invoice_url( $type = 'html' ) {
483
+	public function invoice_url($type = 'html') {
484 484
 		$REG = $this->primary_registration();
485
-		if ( ! $REG instanceof EE_Registration ) {
485
+		if ( ! $REG instanceof EE_Registration) {
486 486
 			return '';
487 487
 		}
488
-		return $REG->invoice_url( $type );
488
+		return $REG->invoice_url($type);
489 489
 	}
490 490
 
491 491
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	 * @return EE_Registration
496 496
 	 */
497 497
 	public function primary_registration() {
498
-		return $this->get_first_related( 'Registration', array( array( 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT ) ) );
498
+		return $this->get_first_related('Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
499 499
 	}
500 500
 
501 501
 
@@ -505,12 +505,12 @@  discard block
 block discarded – undo
505 505
 	 * @param string $type 'pdf' or 'html' (default is 'html')
506 506
 	 * @return string
507 507
 	 */
508
-	public function receipt_url( $type = 'html' ) {
508
+	public function receipt_url($type = 'html') {
509 509
 		$REG = $this->primary_registration();
510
-		if ( ! $REG instanceof EE_Registration ) {
510
+		if ( ! $REG instanceof EE_Registration) {
511 511
 			return '';
512 512
 		}
513
-		return $REG->receipt_url( $type );
513
+		return $REG->receipt_url($type);
514 514
 	}
515 515
 
516 516
 
@@ -535,15 +535,15 @@  discard block
 block discarded – undo
535 535
 	 * @deprecated
536 536
 	 * @return boolean
537 537
 	 */
538
-	public function update_based_on_payments(){
538
+	public function update_based_on_payments() {
539 539
 		EE_Error::doing_it_wrong(
540
-			__CLASS__ . '::' . __FUNCTION__,
541
-			sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ),
540
+			__CLASS__.'::'.__FUNCTION__,
541
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
542 542
 			'4.6.0'
543 543
 		);
544 544
 		/** @type EE_Transaction_Processor $transaction_processor */
545
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
546
-		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this );
545
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
546
+		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this);
547 547
 	}
548 548
 
549 549
 
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 	 * @return string
553 553
 	 */
554 554
 	public function gateway_response_on_transaction() {
555
-		$payment = $this->get_first_related( 'Payment' );
555
+		$payment = $this->get_first_related('Payment');
556 556
 		return $payment instanceof EE_Payment ? $payment->gateway_response() : '';
557 557
 	}
558 558
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	 * @return EE_Status
564 564
 	 */
565 565
 	public function status_obj() {
566
-		return $this->get_first_related( 'Status' );
566
+		return $this->get_first_related('Status');
567 567
 	}
568 568
 
569 569
 
@@ -573,8 +573,8 @@  discard block
 block discarded – undo
573 573
 	 * @param array $query_params like EEM_Base::get_all
574 574
 	 * @return EE_Extra_Meta
575 575
 	 */
576
-	public function extra_meta( $query_params = array() ) {
577
-		return $this->get_many_related( 'Extra_Meta', $query_params );
576
+	public function extra_meta($query_params = array()) {
577
+		return $this->get_many_related('Extra_Meta', $query_params);
578 578
 	}
579 579
 
580 580
 
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 	 * @param EE_Registration $registration
585 585
 	 * @return EE_Base_Class the relation was added to
586 586
 	 */
587
-	public function add_registration( EE_Registration $registration ) {
588
-		return $this->_add_relation_to( $registration, 'Registration' );
587
+	public function add_registration(EE_Registration $registration) {
588
+		return $this->_add_relation_to($registration, 'Registration');
589 589
 	}
590 590
 
591 591
 
@@ -596,8 +596,8 @@  discard block
 block discarded – undo
596 596
 	 * @param int $registration_or_id
597 597
 	 * @return EE_Base_Class that was removed from being related
598 598
 	 */
599
-	public function remove_registration_with_id( $registration_or_id ) {
600
-		return $this->_remove_relation_to( $registration_or_id, 'Registration' );
599
+	public function remove_registration_with_id($registration_or_id) {
600
+		return $this->_remove_relation_to($registration_or_id, 'Registration');
601 601
 	}
602 602
 
603 603
 
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	 * @return EE_Line_Item[]
608 608
 	 */
609 609
 	public function items_purchased() {
610
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) );
610
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item)));
611 611
 	}
612 612
 
613 613
 
@@ -617,8 +617,8 @@  discard block
 block discarded – undo
617 617
 	 * @param EE_Line_Item $line_item
618 618
 	 * @return EE_Base_Class the relation was added to
619 619
 	 */
620
-	public function add_line_item( EE_Line_Item $line_item ) {
621
-		return $this->_add_relation_to( $line_item, 'Line_Item' );
620
+	public function add_line_item(EE_Line_Item $line_item) {
621
+		return $this->_add_relation_to($line_item, 'Line_Item');
622 622
 	}
623 623
 
624 624
 
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
 	 * @param array $query_params
629 629
 	 * @return EE_Line_Item[]
630 630
 	 */
631
-	public function line_items( $query_params = array() ) {
632
-		return $this->get_many_related( 'Line_Item', $query_params );
631
+	public function line_items($query_params = array()) {
632
+		return $this->get_many_related('Line_Item', $query_params);
633 633
 	}
634 634
 
635 635
 
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 	 * @return EE_Line_Item[]
640 640
 	 */
641 641
 	public function tax_items() {
642
-		return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) );
642
+		return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax)));
643 643
 	}
644 644
 
645 645
 
@@ -650,10 +650,10 @@  discard block
 block discarded – undo
650 650
 	 * @return EE_Line_Item
651 651
 	 */
652 652
 	public function total_line_item() {
653
-		$item =  $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) );
654
-		if( ! $item ){
655
-			EE_Registry::instance()->load_helper( 'Line_Item' );
656
-			$item = EEH_Line_Item::create_total_line_item( $this );
653
+		$item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total)));
654
+		if ( ! $item) {
655
+			EE_Registry::instance()->load_helper('Line_Item');
656
+			$item = EEH_Line_Item::create_total_line_item($this);
657 657
 		}
658 658
 		return $item;
659 659
 	}
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	 */
668 668
 	public function tax_total() {
669 669
 		$tax_line_item = $this->tax_total_line_item();
670
-		if ( $tax_line_item ) {
670
+		if ($tax_line_item) {
671 671
 			return $tax_line_item->total();
672 672
 		} else {
673 673
 			return 0;
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 	 * @return EE_Line_Item
682 682
 	 */
683 683
 	public function tax_total_line_item() {
684
-		return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() );
684
+		return EEH_Line_Item::get_taxes_subtotal($this->total_line_item());
685 685
 	}
686 686
 
687 687
 
@@ -690,20 +690,20 @@  discard block
 block discarded – undo
690 690
 	 *  Gets the array of billing info for the gateway and for this transaction's primary registration's attendee.
691 691
 	 * @return EE_Form_Section_Proper
692 692
 	 */
693
-	public function billing_info(){
693
+	public function billing_info() {
694 694
 		$payment_method = $this->payment_method();
695
-		if ( !$payment_method){
695
+		if ( ! $payment_method) {
696 696
 			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__);
697 697
 			return false;
698 698
 		}
699 699
 		$primary_reg = $this->primary_registration();
700
-		if ( ! $primary_reg ) {
701
-			EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ );
700
+		if ( ! $primary_reg) {
701
+			EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__);
702 702
 			return FALSE;
703 703
 		}
704 704
 		$attendee = $primary_reg->attendee();
705
-		if ( ! $attendee ) {
706
-			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__ );
705
+		if ( ! $attendee) {
706
+			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__);
707 707
 			return FALSE;
708 708
 		}
709 709
 		return $attendee->billing_info_for_payment_method($payment_method);
@@ -738,15 +738,15 @@  discard block
 block discarded – undo
738 738
 	 * offline ones, dont' create payments)
739 739
 	 * @return EE_Payment_Method
740 740
 	 */
741
-	function payment_method(){
741
+	function payment_method() {
742 742
 		$pm = $this->get_first_related('Payment_Method');
743
-		if( $pm instanceof EE_Payment_Method ){
743
+		if ($pm instanceof EE_Payment_Method) {
744 744
 			return $pm;
745
-		}else{
745
+		} else {
746 746
 			$last_payment = $this->last_payment();
747
-			if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){
747
+			if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) {
748 748
 				return $last_payment->payment_method();
749
-			}else{
749
+			} else {
750 750
 				return NULL;
751 751
 			}
752 752
 		}
@@ -757,15 +757,15 @@  discard block
 block discarded – undo
757 757
 	 * @return EE_Payment
758 758
 	 */
759 759
 	public function last_payment() {
760
-		return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) );
760
+		return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc')));
761 761
 	}
762 762
 
763 763
 	/**
764 764
 	 * Gets all the line items which are unrelated to tickets on this transaction
765 765
 	 * @return EE_Line_Item[]
766 766
 	 */
767
-	public function non_ticket_line_items(){
768
-		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() );
767
+	public function non_ticket_line_items() {
768
+		return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID());
769 769
 	}
770 770
 
771 771
 
Please login to merge, or discard this patch.
core/interfaces/EEI_Interfaces.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -295,23 +295,23 @@  discard block
 block discarded – undo
295 295
 	 * @param float $amount
296 296
 	 * @param string $name
297 297
 	 * @param string $description
298
-         * @param string $code 
299
-         * @param boolean $add_to_existing_line_item if true and a duplicate line item with 
300
-         *  the same code is found, $amount will be added onto it; otherwise will simply
301
-         *  set the taxes to match $amount
298
+	 * @param string $code 
299
+	 * @param boolean $add_to_existing_line_item if true and a duplicate line item with 
300
+	 *  the same code is found, $amount will be added onto it; otherwise will simply
301
+	 *  set the taxes to match $amount
302 302
 	 * @return EE_Line_Item the new tax created
303 303
 	 */
304 304
 	public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name  = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false );
305 305
         
306
-         /**
307
-         * Makes all the line items which are children of $line_item taxable (or not).
308
-         * Does NOT save the line items
309
-         * @param EE_Line_Item $line_item
310
-         * @param boolean $taxable
311
-         * @param string $code_substring_for_whitelist if this string is part of the line item's code
312
-         *  it will be whitelisted (ie, except from becoming taxable)
313
-         */
314
-        public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null );
306
+		 /**
307
+		  * Makes all the line items which are children of $line_item taxable (or not).
308
+		  * Does NOT save the line items
309
+		  * @param EE_Line_Item $line_item
310
+		  * @param boolean $taxable
311
+		  * @param string $code_substring_for_whitelist if this string is part of the line item's code
312
+		  *  it will be whitelisted (ie, except from becoming taxable)
313
+		  */
314
+		public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null );
315 315
 
316 316
 	/**
317 317
 	 * Adds a simple item ( unrelated to any other model object) to the total line item,
@@ -341,15 +341,15 @@  discard block
 block discarded – undo
341 341
  */
342 342
 interface EEHI_Money{
343 343
 		/**
344
-	 * For comparing floats. Default operator is '=', but see the $operator below for all options.
345
-	 * This should be used to compare floats instead of normal '==' because floats
346
-	 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
347
-	 * but actually differ by 0.00000001.
348
-	 * @param float $float1
349
-	 * @param float $float2
350
-	 * @param string $operator  The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
351
-	 * @return boolean whether the equation is true or false
352
-	 */
344
+		 * For comparing floats. Default operator is '=', but see the $operator below for all options.
345
+		 * This should be used to compare floats instead of normal '==' because floats
346
+		 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
347
+		 * but actually differ by 0.00000001.
348
+		 * @param float $float1
349
+		 * @param float $float2
350
+		 * @param string $operator  The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
351
+		 * @return boolean whether the equation is true or false
352
+		 */
353 353
 	function compare_floats( $float1, $float2, $operator='=' );
354 354
 }
355 355
 
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 /**
6 6
  * Interface EEI_Base
7 7
  */
8
-interface EEI_Base{
8
+interface EEI_Base {
9 9
 	/**
10 10
 	 * gets the unique ID of the model object. If it hasn't been saved yet
11 11
 	 * to the database, this should be 0 or NULL
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row)
33 33
 	 * NOTE: if the values haven't changed, returns 0
34 34
 	 */
35
-	public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL);
35
+	public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL);
36 36
 
37 37
 	/**
38 38
 	 * Adds a new extra meta record. If $unique is set to TRUE, we'll first double-check
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param boolean $unique
44 44
 	 * @return boolean
45 45
 	 */
46
-	public function add_extra_meta($meta_key,$meta_value,$unique = false);
46
+	public function add_extra_meta($meta_key, $meta_value, $unique = false);
47 47
 
48 48
 	/**
49 49
 	 * Deletes all the extra meta rows for this record as specified by key. If $meta_value
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param string $meta_value
53 53
 	 * @return int number of extra meta rows deleted
54 54
 	 */
55
-	public function delete_extra_meta($meta_key,$meta_value = NULL);
55
+	public function delete_extra_meta($meta_key, $meta_value = NULL);
56 56
 
57 57
 	/**
58 58
 	 * Gets the extra meta with the given meta key. If you specify "single" we just return 1, otherwise
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param mixed $default if we don't find anything, what should we return?
64 64
 	 * @return mixed single value if $single; array if ! $single
65 65
 	 */
66
-	public function get_extra_meta($meta_key,$single = FALSE,$default = NULL);
66
+	public function get_extra_meta($meta_key, $single = FALSE, $default = NULL);
67 67
 }
68 68
 
69 69
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param 	EE_Response $response
91 91
 	 * @return 	EE_Response
92 92
 	 */
93
-	public function handle_request( EE_Request $request, EE_Response $response );
93
+	public function handle_request(EE_Request $request, EE_Response $response);
94 94
 }
95 95
 
96 96
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param EE_Request $request
107 107
 	 * @param EE_Response $response
108 108
 	 */
109
-	public function handle_response( EE_Request $request, EE_Response $response );
109
+	public function handle_response(EE_Request $request, EE_Response $response);
110 110
 }
111 111
 
112 112
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @param string $country
272 272
 	 * @param string $CNT_ISO
273 273
 	 */
274
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO );
274
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO);
275 275
 }
276 276
 
277 277
 
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 /**
282 282
  * Interface EEHI_Line_Item
283 283
  */
284
-interface EEHI_Line_Item{
284
+interface EEHI_Line_Item {
285 285
 	/**
286 286
 	 * Adds an item to the purchase in the right spot
287 287
 	 * @param EE_Line_Item $total_line_item
288 288
 	 * @param EE_Line_Item $line_item
289 289
 	 */
290
-	public function add_item( EE_line_Item $total_line_item, EE_Line_Item $line_item );
290
+	public function add_item(EE_line_Item $total_line_item, EE_Line_Item $line_item);
291 291
 	/**
292 292
 	 * Overwrites the previous tax by clearing out the old taxes, and creates a new
293 293
 	 * tax and updates the total line item accordingly
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
          *  set the taxes to match $amount
302 302
 	 * @return EE_Line_Item the new tax created
303 303
 	 */
304
-	public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name  = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false );
304
+	public function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false);
305 305
         
306 306
          /**
307 307
          * Makes all the line items which are children of $line_item taxable (or not).
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
          * @param string $code_substring_for_whitelist if this string is part of the line item's code
312 312
          *  it will be whitelisted (ie, except from becoming taxable)
313 313
          */
314
-        public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null );
314
+        public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null);
315 315
 
316 316
 	/**
317 317
 	 * Adds a simple item ( unrelated to any other model object) to the total line item,
@@ -325,21 +325,21 @@  discard block
 block discarded – undo
325 325
 	 * @param boolean $code if set to a value, ensures there is only one line item with that code
326 326
 	 * @return boolean success
327 327
 	 */
328
-	public function add_unrelated_item( EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null );
328
+	public function add_unrelated_item(EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null);
329 329
 
330 330
 	/**
331 331
 	 * Gets the line item for the taxes subtotal
332 332
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
333 333
 	 * @return \EE_Line_Item
334 334
 	 */
335
-	public static function get_taxes_subtotal( EE_Line_Item $total_line_item );
335
+	public static function get_taxes_subtotal(EE_Line_Item $total_line_item);
336 336
 }
337 337
 
338 338
 
339 339
 /**
340 340
  * Money-related helper
341 341
  */
342
-interface EEHI_Money{
342
+interface EEHI_Money {
343 343
 		/**
344 344
 	 * For comparing floats. Default operator is '=', but see the $operator below for all options.
345 345
 	 * This should be used to compare floats instead of normal '==' because floats
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 	 * @param string $operator  The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
351 351
 	 * @return boolean whether the equation is true or false
352 352
 	 */
353
-	function compare_floats( $float1, $float2, $operator='=' );
353
+	function compare_floats($float1, $float2, $operator = '=');
354 354
 }
355 355
 
356 356
 /**
357 357
  * Interface EEHI_Template
358 358
  */
359
-interface EEHI_Template{
359
+interface EEHI_Template {
360 360
 
361 361
 	/**
362 362
 	 * EEH_Template::format_currency
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 * @param string   $cur_code_span_class
370 370
 	 * @return string the html output for the formatted money value
371 371
 	 */
372
-	public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' );
372
+	public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code');
373 373
 }
374 374
 
375 375
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	 * @param array $options
385 385
 	 * @return mixed
386 386
 	 */
387
-	public function display_line_item( EE_Line_Item $line_item, $options = array() );
387
+	public function display_line_item(EE_Line_Item $line_item, $options = array());
388 388
 
389 389
 }
390 390
 
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	 * @throws EE_Error
397 397
 	 * @return bool
398 398
 	 */
399
-	public static function ensure_file_exists_and_is_writable( $full_file_path = '' );
399
+	public static function ensure_file_exists_and_is_writable($full_file_path = '');
400 400
 	
401 401
 	/**
402 402
 	 * ensure_folder_exists_and_is_writable
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @throws EE_Error
406 406
 	 * @return bool
407 407
 	 */
408
-	public static function ensure_folder_exists_and_is_writable( $folder = '' );
408
+	public static function ensure_folder_exists_and_is_writable($folder = '');
409 409
 }
410 410
 
411 411
 // End of file EEI_Interfaces.php
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EE_Paypal_Standard_Form.form.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -21,37 +21,37 @@  discard block
 block discarded – undo
21 21
 	/**
22 22
 	 * @param EE_PMT_Paypal_Standard $payment_method_type
23 23
 	 */
24
-	public function __construct( $payment_method_type ){
24
+	public function __construct($payment_method_type) {
25 25
 		parent::__construct(
26 26
 			array(
27 27
 				'payment_method_type'          => $payment_method_type,
28 28
 				'extra_meta_inputs'            => array(
29
-					'paypal_id'        => new EE_Text_Input( array(
30
-						'html_label_text' => sprintf( __( "Paypal Email %s", 'event_espresso' ), $payment_method_type->get_help_tab_link() ),
31
-						'html_help_text'  => __( "Typically [email protected]", 'event_espresso' ),
29
+					'paypal_id'        => new EE_Text_Input(array(
30
+						'html_label_text' => sprintf(__("Paypal Email %s", 'event_espresso'), $payment_method_type->get_help_tab_link()),
31
+						'html_help_text'  => __("Typically [email protected]", 'event_espresso'),
32 32
 						'required'        => true
33
-					) ),
34
-					'image_url'        => new EE_Admin_File_Uploader_Input( array(
35
-						'html_help_text'  => __( "Used for your business/personal logo on the PayPal page", 'event_espresso' ),
36
-						'html_label_text' => __( 'Image URL', 'event_espresso' )
37
-					) ),
38
-					'paypal_taxes'     => new EE_Yes_No_Input( array(
39
-						'html_label_text' => sprintf( __( 'Paypal Calculates Taxes %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ),
40
-						'html_help_text'  => __( 'Whether Paypal should add taxes to the order', 'event_espresso' ),
33
+					)),
34
+					'image_url'        => new EE_Admin_File_Uploader_Input(array(
35
+						'html_help_text'  => __("Used for your business/personal logo on the PayPal page", 'event_espresso'),
36
+						'html_label_text' => __('Image URL', 'event_espresso')
37
+					)),
38
+					'paypal_taxes'     => new EE_Yes_No_Input(array(
39
+						'html_label_text' => sprintf(__('Paypal Calculates Taxes %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
40
+						'html_help_text'  => __('Whether Paypal should add taxes to the order', 'event_espresso'),
41 41
 						'default'         => false
42
-					) ),
43
-					'paypal_shipping'  => new EE_Yes_No_Input( array(
44
-						'html_label_text' => sprintf( __( 'Paypal Calculates Shipping %s', 'event_espresso' ), $payment_method_type->get_help_tab_link() ),
45
-						'html_help_text'  => __( 'Whether Paypal should add shipping surcharges', 'event_espresso' ),
42
+					)),
43
+					'paypal_shipping'  => new EE_Yes_No_Input(array(
44
+						'html_label_text' => sprintf(__('Paypal Calculates Shipping %s', 'event_espresso'), $payment_method_type->get_help_tab_link()),
45
+						'html_help_text'  => __('Whether Paypal should add shipping surcharges', 'event_espresso'),
46 46
 						'default'         => false
47
-					) ),
48
-					'shipping_details' => new EE_Select_Input( array(
49
-						EE_PMT_Paypal_Standard::shipping_info_none     => __( "Do not prompt for an address", 'event_espresso' ),
50
-						EE_PMT_Paypal_Standard::shipping_info_optional => __( "Prompt for an address, but do not require it", 'event_espresso' ),
51
-						EE_PMT_Paypal_Standard::shipping_info_required => __( "Prompt for an address, and require it", 'event_espresso' )
52
-					) ),
47
+					)),
48
+					'shipping_details' => new EE_Select_Input(array(
49
+						EE_PMT_Paypal_Standard::shipping_info_none     => __("Do not prompt for an address", 'event_espresso'),
50
+						EE_PMT_Paypal_Standard::shipping_info_optional => __("Prompt for an address, but do not require it", 'event_espresso'),
51
+						EE_PMT_Paypal_Standard::shipping_info_required => __("Prompt for an address, and require it", 'event_espresso')
52
+					)),
53 53
 				),
54
-				'before_form_content_template' => $payment_method_type->file_folder() . DS . 'templates' . DS . 'paypal_standard_settings_before_form.template.php',
54
+				'before_form_content_template' => $payment_method_type->file_folder().DS.'templates'.DS.'paypal_standard_settings_before_form.template.php',
55 55
 			)
56 56
 		);
57 57
 	}
@@ -61,28 +61,28 @@  discard block
 block discarded – undo
61 61
 	/**
62 62
 	 * @param array $req_data
63 63
 	 */
64
-	protected function _normalize( $req_data ) {
65
-		parent::_normalize( $req_data );
66
-		$paypal_calculates_shipping = $this->get_input_value( 'paypal_shipping' );
67
-		$paypal_calculates_taxes = $this->get_input_value( 'paypal_taxes' );
68
-		$paypal_requests_address_info = $this->get_input_value( 'shipping_details' );
64
+	protected function _normalize($req_data) {
65
+		parent::_normalize($req_data);
66
+		$paypal_calculates_shipping = $this->get_input_value('paypal_shipping');
67
+		$paypal_calculates_taxes = $this->get_input_value('paypal_taxes');
68
+		$paypal_requests_address_info = $this->get_input_value('shipping_details');
69 69
 		if (
70
-			( $paypal_calculates_shipping || $paypal_calculates_taxes ) &&
70
+			($paypal_calculates_shipping || $paypal_calculates_taxes) &&
71 71
 			$paypal_requests_address_info == EE_PMT_Paypal_Standard::shipping_info_none
72 72
 		) {
73 73
 			//they want paypal to calculate taxes or shipping. They need to ask for
74 74
 			//address info, otherwise paypal can't calculate taxes or shipping
75 75
 			/** @type EE_Select_Input $shipping_details_input */
76
-			$shipping_details_input = $this->get_input( 'shipping_details' );
77
-			$shipping_details_input->set_default( EE_PMT_Paypal_Standard::shipping_info_optional );
76
+			$shipping_details_input = $this->get_input('shipping_details');
77
+			$shipping_details_input->set_default(EE_PMT_Paypal_Standard::shipping_info_optional);
78 78
 			$shipping_details_input_options = $shipping_details_input->options();
79 79
 			EE_Error::add_attention(
80 80
 				sprintf(
81
-					__( 'Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso' ),
82
-					strip_tags( $shipping_details_input->html_label_text() ),
83
-					isset( $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ] )
84
-						? $shipping_details_input_options[ EE_PMT_Paypal_Standard::shipping_info_optional ]
85
-						: __( 'Unknown', 'event_espresso' )
81
+					__('Automatically set "%s" to "%s" because Paypal requires address info in order to calculate shipping or taxes.', 'event_espresso'),
82
+					strip_tags($shipping_details_input->html_label_text()),
83
+					isset($shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional])
84
+						? $shipping_details_input_options[EE_PMT_Paypal_Standard::shipping_info_optional]
85
+						: __('Unknown', 'event_espresso')
86 86
 				),
87 87
 				__FILE__, __FUNCTION__, __LINE__
88 88
 			);
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EEG_Paypal_Standard.gateway.php 3 patches
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		parent::set_settings($settings_array);
78 78
 		if($this->_debug_mode){
79 79
 			$this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
80
-		}else{
80
+		} else{
81 81
 			$this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr';
82 82
 		}
83 83
 	}
@@ -340,8 +340,9 @@  discard block
 block discarded – undo
340 340
 		$update_info = array();
341 341
 		foreach ( $raw_post_array as $keyval ) {
342 342
 			$keyval = explode( '=', $keyval );
343
-			if ( count( $keyval ) == 2 )
344
-				$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
343
+			if ( count( $keyval ) == 2 ) {
344
+							$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
345
+			}
345 346
 		}
346 347
 		// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
347 348
 		$req = 'cmd=_notify-validate';
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -456,16 +456,16 @@
 block discarded – undo
456 456
 
457 457
 		//might paypal have changed the taxes?
458 458
 		if( $this->_paypal_taxes && $payment_was_itemized ){
459
-                    //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable
460
-                    $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' );
461
-                    $this->_line_item->set_total_tax_to(
462
-                            $transaction->total_line_item(),
463
-                            floatval( $update_info['tax'] ),
464
-                            __( 'Taxes', 'event_espresso' ),
465
-                            __( 'Calculated by Paypal', 'event_espresso' ),
466
-                            'paypal_tax'
467
-                    );
468
-                    $grand_total_needs_resaving = TRUE;
459
+					//note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable
460
+					$this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' );
461
+					$this->_line_item->set_total_tax_to(
462
+							$transaction->total_line_item(),
463
+							floatval( $update_info['tax'] ),
464
+							__( 'Taxes', 'event_espresso' ),
465
+							__( 'Calculated by Paypal', 'event_espresso' ),
466
+							'paypal_tax'
467
+					);
468
+					$grand_total_needs_resaving = TRUE;
469 469
 		}
470 470
 
471 471
 		$shipping_amount = floatval( $update_info[ 'mc_shipping' ] );
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return EEG_Paypal_Standard
69 69
 	 */
70 70
 	public function __construct() {
71
-		$this->set_uses_separate_IPN_request( true ) ;
71
+		$this->set_uses_separate_IPN_request(true);
72 72
 		parent::__construct();
73 73
 	}
74 74
 
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 	 * Also sets the gateway url class variable based on whether debug mode is enabled or not
79 79
 	 * @param array $settings_array
80 80
 	 */
81
-	public function set_settings($settings_array){
81
+	public function set_settings($settings_array) {
82 82
 		parent::set_settings($settings_array);
83
-		if($this->_debug_mode){
83
+		if ($this->_debug_mode) {
84 84
 			$this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
85
-		}else{
85
+		} else {
86 86
 			$this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr';
87 87
 		}
88 88
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @param string      $cancel_url   URL to send the user to after a cancelled payment attempt on teh payment provider's website
98 98
 	 * @return EEI_Payment
99 99
 	 */
100
-	public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ){
100
+	public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) {
101 101
 		$redirect_args = array();
102 102
 		$transaction = $payment->transaction();
103 103
 		$primary_registrant = $transaction->primary_registration();
@@ -107,42 +107,42 @@  discard block
 block discarded – undo
107 107
 
108 108
 		$total_discounts_to_cart_total = $transaction->paid();
109 109
 		//only itemize the order if we're paying for the rest of the order's amount
110
-		if( $payment->amount() == $transaction->total() ) {
111
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true );
110
+		if ($payment->amount() == $transaction->total()) {
111
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true);
112 112
 			//this payment is for the remaining transaction amount,
113 113
 			//keep track of exactly how much the itemized order amount equals
114 114
 			$itemized_sum = 0;
115 115
 			$shipping_previously_added = 0;
116 116
 			//so let's show all the line items
117
-			foreach($total_line_item->get_items() as $line_item){
118
-				if ( $line_item instanceof EE_Line_Item ) {
117
+			foreach ($total_line_item->get_items() as $line_item) {
118
+				if ($line_item instanceof EE_Line_Item) {
119 119
 					//it's some kind of discount
120
-					if( $line_item->total() < 0 ) {
121
-						$total_discounts_to_cart_total += abs( $line_item->total() );
120
+					if ($line_item->total() < 0) {
121
+						$total_discounts_to_cart_total += abs($line_item->total());
122 122
 						$itemized_sum += $line_item->total();
123 123
 						continue;
124 124
 					}
125 125
 					//dont include shipping again.
126
-					if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) {
126
+					if (strpos($line_item->code(), 'paypal_shipping_') === 0) {
127 127
 						$shipping_previously_added = $line_item->total();
128 128
 						continue;
129 129
 					}
130
-					$redirect_args[ 'item_name_' . $item_num ] = substr(
131
-						sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ),
130
+					$redirect_args['item_name_'.$item_num] = substr(
131
+						sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()),
132 132
 						0, 127
133 133
 					);
134
-					$redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price();
135
-					$redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity();
134
+					$redirect_args['amount_'.$item_num] = $line_item->unit_price();
135
+					$redirect_args['quantity_'.$item_num] = $line_item->quantity();
136 136
 					//if we're not letting PayPal calculate shipping, tell them its 0
137
-					if ( ! $this->_paypal_shipping ) {
138
-						$redirect_args[ 'shipping_' . $item_num ] = '0';
139
-						$redirect_args[ 'shipping2_' . $item_num ] = '0';
137
+					if ( ! $this->_paypal_shipping) {
138
+						$redirect_args['shipping_'.$item_num] = '0';
139
+						$redirect_args['shipping2_'.$item_num] = '0';
140 140
 					}
141 141
 					$item_num++;
142 142
 					$itemized_sum += $line_item->total();
143 143
 				}
144 144
 			}
145
-			$taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item );
145
+			$taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item);
146 146
 			//ideally itemized sum equals the transaction total. but if not (which is weird)
147 147
 			//and the itemized sum is LESS than the transaction total
148 148
 			//add another line item
@@ -152,47 +152,47 @@  discard block
 block discarded – undo
152 152
 					$transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added,
153 153
 					2 
154 154
 				);
155
-			if( $itemized_sum_diff_from_txn_total < 0 ) {
155
+			if ($itemized_sum_diff_from_txn_total < 0) {
156 156
 				//itemized sum is too big
157
-				$total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total );
158
-			} elseif( $itemized_sum_diff_from_txn_total > 0 ) {
159
-				$redirect_args[ 'item_name_' . $item_num ] = substr(
160
-						__( 'Other charges', 'event_espresso' ), 0, 127 );
161
-				$redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total );
162
-				$redirect_args[ 'quantity_' . $item_num ] = 1;
157
+				$total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total);
158
+			} elseif ($itemized_sum_diff_from_txn_total > 0) {
159
+				$redirect_args['item_name_'.$item_num] = substr(
160
+						__('Other charges', 'event_espresso'), 0, 127 );
161
+				$redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total);
162
+				$redirect_args['quantity_'.$item_num] = 1;
163 163
 				$item_num++;
164 164
 			}
165
-			if( $total_discounts_to_cart_total > 0 ) {
166
-				$redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total );
165
+			if ($total_discounts_to_cart_total > 0) {
166
+				$redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total);
167 167
 			}
168 168
 			//add our taxes to the order if we're NOT using PayPal's
169
-			if( ! $this->_paypal_taxes ){
169
+			if ( ! $this->_paypal_taxes) {
170 170
 				$redirect_args['tax_cart'] = $total_line_item->get_total_tax();
171 171
 			}
172 172
 		} else {
173
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false );
173
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false);
174 174
 			//partial payment that's not for the remaining amount, so we can't send an itemized list
175
-			$redirect_args['item_name_' . $item_num] = substr(
176
-				sprintf( __('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code() ),
175
+			$redirect_args['item_name_'.$item_num] = substr(
176
+				sprintf(__('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code()),
177 177
 				0, 127
178 178
 			);
179
-			$redirect_args['amount_' . $item_num] = $payment->amount();
180
-			$redirect_args['shipping_' . $item_num ] = '0';
181
-			$redirect_args['shipping2_' . $item_num ] = '0';
179
+			$redirect_args['amount_'.$item_num] = $payment->amount();
180
+			$redirect_args['shipping_'.$item_num] = '0';
181
+			$redirect_args['shipping2_'.$item_num] = '0';
182 182
 			$redirect_args['tax_cart'] = '0';
183 183
 			$item_num++;
184 184
 		}
185 185
 
186
-		if($this->_debug_mode){
187
-			$redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode';
188
-			$redirect_args['amount_' . $item_num] = 0;
186
+		if ($this->_debug_mode) {
187
+			$redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode';
188
+			$redirect_args['amount_'.$item_num] = 0;
189 189
 			$redirect_args['on0_'.$item_num] = 'NOTIFY URL';
190
-			$redirect_args['os0_' . $item_num] = $notify_url;
190
+			$redirect_args['os0_'.$item_num] = $notify_url;
191 191
 			$redirect_args['on1_'.$item_num] = 'RETURN URL';
192
-			$redirect_args['os1_' . $item_num] = $return_url;
192
+			$redirect_args['os1_'.$item_num] = $return_url;
193 193
 //			$redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ?
194
-			$redirect_args['shipping_' . $item_num ] = '0';
195
-			$redirect_args['shipping2_' . $item_num ] = '0';
194
+			$redirect_args['shipping_'.$item_num] = '0';
195
+			$redirect_args['shipping2_'.$item_num] = '0';
196 196
 		}
197 197
 
198 198
 		$redirect_args['business'] = $this->_paypal_id;
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 		$redirect_args['cmd'] = '_cart';
203 203
 		$redirect_args['upload'] = 1;
204 204
 		$redirect_args['currency_code'] = $payment->currency_code();
205
-		$redirect_args['rm'] = 2;//makes the user return with method=POST
206
-		if($this->_image_url){
205
+		$redirect_args['rm'] = 2; //makes the user return with method=POST
206
+		if ($this->_image_url) {
207 207
 			$redirect_args['image_url'] = $this->_image_url;
208 208
 		}
209 209
 		$redirect_args['no_shipping'] = $this->_shipping_details;
210
-		$redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this
210
+		$redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this
211 211
 
212
-		$redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this );
212
+		$redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this);
213 213
 
214 214
 		$payment->set_redirect_url($this->_gateway_url);
215 215
 		$payment->set_redirect_args($redirect_args);
@@ -230,55 +230,55 @@  discard block
 block discarded – undo
230 230
 	 * @return \EEI_Payment updated
231 231
 	 * @throws \EE_Error
232 232
 	 */
233
-	public function handle_payment_update( $update_info, $transaction ){
233
+	public function handle_payment_update($update_info, $transaction) {
234 234
 		//verify there's payment data that's been sent
235
-		if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) {
235
+		if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) {
236 236
 			// waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/)
237 237
 			// indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes
238
-			if ( isset( $update_info[ 'tx' ] ) ) {
238
+			if (isset($update_info['tx'])) {
239 239
 				return $transaction->last_payment();
240 240
 			} else {
241 241
 				return null;
242 242
 			}
243 243
 		}
244
-		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
245
-		if ( ! $payment instanceof EEI_Payment ) {
244
+		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']);
245
+		if ( ! $payment instanceof EEI_Payment) {
246 246
 			$payment = $transaction->last_payment();
247 247
 		}
248 248
 		// ok, then validate the IPN. Even if we've already processed this payment,
249 249
 		// let PayPal know we don't want to hear from them anymore!
250
-		if ( ! $this->validate_ipn( $update_info, $payment ) ) {
250
+		if ( ! $this->validate_ipn($update_info, $payment)) {
251 251
 			return $payment;
252 252
 		}
253 253
 		//ok, well let's process this payment then!
254
-		switch ( $update_info[ 'payment_status' ] ) {
254
+		switch ($update_info['payment_status']) {
255 255
 
256 256
 			case 'Completed' :
257 257
 				$status = $this->_pay_model->approved_status();
258
-				$gateway_response = __( 'The payment is approved.', 'event_espresso' );
258
+				$gateway_response = __('The payment is approved.', 'event_espresso');
259 259
 				break;
260 260
 
261 261
 			case 'Pending' :
262 262
 				$status = $this->_pay_model->pending_status();
263
-				$gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' );
263
+				$gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso');
264 264
 				break;
265 265
 
266 266
 			case 'Denied' :
267 267
 				$status = $this->_pay_model->declined_status();
268
-				$gateway_response = __( 'The payment has been declined.', 'event_espresso' );
268
+				$gateway_response = __('The payment has been declined.', 'event_espresso');
269 269
 				break;
270 270
 
271 271
 			case 'Expired' :
272 272
 			case 'Failed' :
273 273
 				$status = $this->_pay_model->failed_status();
274
-				$gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' );
274
+				$gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso');
275 275
 				break;
276 276
 
277 277
 			case 'Refunded' :
278 278
 			case 'Partially_Refunded' :
279 279
 				// even though it's a refund, we consider the payment as approved, it just has a negative value
280 280
 				$status = $this->_pay_model->approved_status();
281
-				$gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' );
281
+				$gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso');
282 282
 				break;
283 283
 
284 284
 			case 'Voided' :
@@ -286,25 +286,25 @@  discard block
 block discarded – undo
286 286
 			case 'Canceled_Reversal' :
287 287
 			default :
288 288
 				$status = $this->_pay_model->cancelled_status();
289
-				$gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' );
289
+				$gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso');
290 290
 				break;
291 291
 
292 292
 		}
293 293
 
294 294
 		//check if we've already processed this payment
295
-		if ( $payment instanceof EEI_Payment ) {
295
+		if ($payment instanceof EEI_Payment) {
296 296
 			//payment exists. if this has the exact same status and amount, don't bother updating. just return
297
-			if ( $payment->status() == $status && $payment->amount() == $update_info[ 'mc_gross' ] ) {
297
+			if ($payment->status() == $status && $payment->amount() == $update_info['mc_gross']) {
298 298
 				// DUPLICATED IPN! dont bother updating transaction foo!;
299
-				$message_log = sprintf( __( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ), $payment->ID() );
299
+				$message_log = sprintf(__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'), $payment->ID());
300 300
 			} else {
301 301
 				// new payment yippee !!!
302
-				$payment->set_status( $status );
303
-				$payment->set_amount( floatval( $update_info[ 'mc_gross' ] ) );
304
-				$payment->set_gateway_response( $gateway_response );
305
-				$payment->set_details( $update_info );
306
-				$payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
307
-				$message_log = sprintf( __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ) );
302
+				$payment->set_status($status);
303
+				$payment->set_amount(floatval($update_info['mc_gross']));
304
+				$payment->set_gateway_response($gateway_response);
305
+				$payment->set_details($update_info);
306
+				$payment->set_txn_id_chq_nmbr($update_info['txn_id']);
307
+				$message_log = sprintf(__('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso'));
308 308
 			}
309 309
 			$this->log(
310 310
 				array(
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
 				$payment
317 317
 			);
318 318
 		}
319
-		do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this );
319
+		do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this);
320 320
 		// kill request here if this is a refund
321
-		if ( $update_info[ 'payment_status' ] == 'Refunded' || $update_info[ 'payment_status' ] == 'Partially_Refunded'   ) {
322
-			if ( apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) ) {
323
-				status_header( 200 );
321
+		if ($update_info['payment_status'] == 'Refunded' || $update_info['payment_status'] == 'Partially_Refunded') {
322
+			if (apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)) {
323
+				status_header(200);
324 324
 				exit();
325 325
 			}
326 326
 		}
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	 * @param EE_Payment|EEI_Payment $payment
337 337
 	 * @return boolean
338 338
 	 */
339
-	public function validate_ipn( $update_info, $payment ) {
339
+	public function validate_ipn($update_info, $payment) {
340 340
 		//allow us to skip validating IPNs with PayPal (useful for testing)
341
-		if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) {
341
+		if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) {
342 342
 			return true;
343 343
 		}
344 344
 		//...otherwise, we actually don't care what the $update_info is, we need to look
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
 		// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
347 347
 		// Instead, read raw POST data from the input stream.
348 348
 		// @see https://gist.github.com/xcommerce-gists/3440401
349
-		$raw_post_data = file_get_contents( 'php://input' );
350
-		$raw_post_array = explode( '&', $raw_post_data );
349
+		$raw_post_data = file_get_contents('php://input');
350
+		$raw_post_array = explode('&', $raw_post_data);
351 351
 		$update_info = array();
352
-		foreach ( $raw_post_array as $keyval ) {
353
-			$keyval = explode( '=', $keyval );
354
-			if ( count( $keyval ) == 2 )
355
-				$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
352
+		foreach ($raw_post_array as $keyval) {
353
+			$keyval = explode('=', $keyval);
354
+			if (count($keyval) == 2)
355
+				$update_info[$keyval[0]] = urldecode($keyval[1]);
356 356
 		}
357 357
 		// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
358 358
 		$req = 'cmd=_notify-validate';
359
-		$get_magic_quotes_exists = function_exists( 'get_magic_quotes_gpc' ) ? true : false;
360
-		foreach ( $update_info as $key => $value ) {
361
-			if ( $get_magic_quotes_exists && get_magic_quotes_gpc() == 1 ) {
362
-				$value = urlencode( stripslashes( $value ) );
359
+		$get_magic_quotes_exists = function_exists('get_magic_quotes_gpc') ? true : false;
360
+		foreach ($update_info as $key => $value) {
361
+			if ($get_magic_quotes_exists && get_magic_quotes_gpc() == 1) {
362
+				$value = urlencode(stripslashes($value));
363 363
 			} else {
364
-				$value = urlencode( $value );
364
+				$value = urlencode($value);
365 365
 			}
366 366
 			$req .= "&$key=$value";
367 367
 		}
@@ -371,22 +371,22 @@  discard block
 block discarded – undo
371 371
 			array(
372 372
 				'body' 				=> $req,
373 373
 				'sslverify' 		=> false,
374
-				'timeout' 		=> 60 ,
374
+				'timeout' 		=> 60,
375 375
 				// make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal
376 376
 				// plz see: https://github.com/websharks/s2member/issues/610
377
-				'user-agent' 	=> 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(),
377
+				'user-agent' 	=> 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(),
378 378
 				'httpversion' => '1.1'
379 379
 			)
380 380
 		);
381 381
 		// then check the response
382
-		if ( ! is_wp_error( $response ) && array_key_exists( 'body', $response ) && strcmp( $response[ 'body' ], "VERIFIED" ) == 0 ) {
382
+		if ( ! is_wp_error($response) && array_key_exists('body', $response) && strcmp($response['body'], "VERIFIED") == 0) {
383 383
 			return true;
384 384
 		} else {
385 385
 			// huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly,
386 386
 			// or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html
387
-			$payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $response[ 'body' ] ) );
388
-			$payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) );
389
-			$payment->set_status( EEM_Payment::status_id_failed );
387
+			$payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $response['body']));
388
+			$payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response));
389
+			$payment->set_status(EEM_Payment::status_id_failed);
390 390
 			// log the results
391 391
 			$this->log(
392 392
 				array(
@@ -408,9 +408,9 @@  discard block
 block discarded – undo
408 408
 	 */
409 409
 	protected function _process_response_url() {
410 410
 		EE_Registry::instance()->load_helper('URL');
411
-		if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) {
411
+		if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
412 412
 			$url = is_ssl() ? 'https://' : 'http://';
413
-			$url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' );
413
+			$url .= EEH_URL::filter_input_server_url('HTTP_HOST');
414 414
 			$url .= EEH_URL::filter_input_server_url();
415 415
 		} else {
416 416
 			$url = 'unknown';
@@ -426,30 +426,30 @@  discard block
 block discarded – undo
426 426
 	 * like the taxes or shipping
427 427
 	 * @param EEI_Payment $payment
428 428
 	 */
429
-	public function update_txn_based_on_payment( $payment ) {
429
+	public function update_txn_based_on_payment($payment) {
430 430
 		$update_info = $payment->details();
431 431
 		$transaction = $payment->transaction();
432
-		$payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false );
433
-		if( ! $transaction ){
434
-			$this->log( __( 'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso' ), $payment );
432
+		$payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false);
433
+		if ( ! $transaction) {
434
+			$this->log(__('Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso'), $payment);
435 435
 			return;
436 436
 		}
437
-		if( ! is_array( $update_info ) || ! isset( $update_info[ 'mc_shipping' ] ) || ! isset( $update_info[ 'tax' ] ) ) {
437
+		if ( ! is_array($update_info) || ! isset($update_info['mc_shipping']) || ! isset($update_info['tax'])) {
438 438
 			$this->log(
439 439
 				array(
440 440
 					'url' 				=> $this->_process_response_url(),
441
-					'message' 	=> __( 'Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso' ),
441
+					'message' 	=> __('Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso'),
442 442
 					'payment' 	=> $payment->model_field_array()
443 443
 				),
444 444
 				$payment
445 445
 			);
446 446
 			return;
447 447
 		}
448
-		if( $payment->status() !== $this->_pay_model->approved_status() ) {
448
+		if ($payment->status() !== $this->_pay_model->approved_status()) {
449 449
 			$this->log(
450 450
 				array(
451 451
 					'url' 				=> $this->_process_response_url(),
452
-					'message' 	=> __( 'We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso' ),
452
+					'message' 	=> __('We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso'),
453 453
 					'payment' 	=> $payment->model_field_array()
454 454
 				),
455 455
 				$payment
@@ -459,43 +459,43 @@  discard block
 block discarded – undo
459 459
 		$grand_total_needs_resaving = false;
460 460
 
461 461
 		//might paypal have changed the taxes?
462
-		if( $this->_paypal_taxes && $payment_was_itemized ){
462
+		if ($this->_paypal_taxes && $payment_was_itemized) {
463 463
                     //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable
464
-                    $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' );
464
+                    $this->_line_item->set_line_items_taxable($transaction->total_line_item(), true, 'paypal_shipping');
465 465
                     $this->_line_item->set_total_tax_to(
466 466
                             $transaction->total_line_item(),
467
-                            floatval( $update_info['tax'] ),
468
-                            __( 'Taxes', 'event_espresso' ),
469
-                            __( 'Calculated by Paypal', 'event_espresso' ),
467
+                            floatval($update_info['tax']),
468
+                            __('Taxes', 'event_espresso'),
469
+                            __('Calculated by Paypal', 'event_espresso'),
470 470
                             'paypal_tax'
471 471
                     );
472 472
                     $grand_total_needs_resaving = TRUE;
473 473
 		}
474 474
 
475
-		$shipping_amount = floatval( $update_info[ 'mc_shipping' ] );
475
+		$shipping_amount = floatval($update_info['mc_shipping']);
476 476
 		//might paypal have added shipping?
477
-		if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){
477
+		if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) {
478 478
 			$this->_line_item->add_unrelated_item(
479 479
 				$transaction->total_line_item(),
480
-				sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ),
480
+				sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()),
481 481
 				$shipping_amount,
482 482
 				__('Shipping charges calculated by Paypal', 'event_espresso'),
483 483
 				1,
484 484
 				false,
485
-				'paypal_shipping_' . $transaction->ID()
485
+				'paypal_shipping_'.$transaction->ID()
486 486
 			);
487 487
 			$grand_total_needs_resaving = true;
488 488
 		}
489 489
 
490
-		if( $grand_total_needs_resaving ){
491
-			$transaction->total_line_item()->save_this_and_descendants_to_txn( $transaction->ID() );
492
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
493
-			$registration_processor->update_registration_final_prices( $transaction );
490
+		if ($grand_total_needs_resaving) {
491
+			$transaction->total_line_item()->save_this_and_descendants_to_txn($transaction->ID());
492
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
493
+			$registration_processor->update_registration_final_prices($transaction);
494 494
 		}
495 495
 		$this->log(
496 496
 			array(
497 497
 				'url' 													=> $this->_process_response_url(),
498
-				'message' 										=> __( 'Updated transaction related to payment', 'event_espresso' ),
498
+				'message' 										=> __('Updated transaction related to payment', 'event_espresso'),
499 499
 				'transaction (updated)' 					=> $transaction->model_field_array(),
500 500
 				'payment (updated)' 						=> $payment->model_field_array(),
501 501
 				'use_paypal_shipping' 					=> $this->_paypal_shipping,
Please login to merge, or discard this patch.