Completed
Branch BUG-8698-ticket-sellouts (d652f0)
by
unknown
198:01 queued 171:26
created
core/db_classes/EE_Soft_Delete_Base_Class.class.php 1 patch
Spacing   +5 added lines, -5 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
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	 * @param bool $delete true=>delete, false=>restore
34 34
 	 * @return bool
35 35
 	 */
36
-	public function delete_or_restore( $delete = TRUE ) {
36
+	public function delete_or_restore($delete = TRUE) {
37 37
 		$model = $this->get_model();
38
-		return $model->delete_or_restore_by_ID( $delete, $this->ID() );
38
+		return $model->delete_or_restore_by_ID($delete, $this->ID());
39 39
 	}
40 40
 
41 41
 
@@ -45,6 +45,6 @@  discard block
 block discarded – undo
45 45
 	 * @return boolean
46 46
 	 */
47 47
 	public function restore() {
48
-		return $this->delete_or_restore( FALSE );
48
+		return $this->delete_or_restore(FALSE);
49 49
 	}
50 50
 }
51 51
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/EEM_CPT_Base.model.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-define('EE_Event_Category_Taxonomy','espresso_event_category');
2
+define('EE_Event_Category_Taxonomy', 'espresso_event_category');
3 3
 /**
4 4
  *
5 5
  * EEM_CPT_Base
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @author 				Mike Nelson
17 17
  *
18 18
  */
19
-abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base{
19
+abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base {
20 20
 
21 21
 	/**
22 22
 	 * @var string post_status_publish - the wp post status for published cpts
@@ -69,55 +69,55 @@  discard block
 block discarded – undo
69 69
 	 * @param string $timezone
70 70
 	 * @throws \EE_Error
71 71
 	 */
72
-	protected function __construct( $timezone = NULL ){
72
+	protected function __construct($timezone = NULL) {
73 73
 
74 74
 		//adds a relationship to Term_Taxonomy for all these models. For this to work
75 75
 		//Term_Relationship must have a relation to each model subclassing EE_CPT_Base explicitly
76 76
 		//eg, in EEM_Term_Relationship, inside the _model_relations array, there must be an entry
77 77
 		//with key equalling the subclassing model's model name (eg 'Event' or 'Venue'), and the value
78 78
 		//must also be new EE_HABTM_Relation('Term_Relationship');
79
-		$this->_model_relations['Term_Taxonomy'] =new EE_HABTM_Relation('Term_Relationship');
79
+		$this->_model_relations['Term_Taxonomy'] = new EE_HABTM_Relation('Term_Relationship');
80 80
 		$primary_table_name = NULL;
81 81
 		//add  the common _status field to all CPT primary tables.
82
-		foreach ( $this->_tables as $alias => $table_obj ) {
83
-			if ( $table_obj instanceof EE_Primary_Table ) {
82
+		foreach ($this->_tables as $alias => $table_obj) {
83
+			if ($table_obj instanceof EE_Primary_Table) {
84 84
 				$primary_table_name = $alias;
85 85
 			}
86 86
 		}
87 87
 		//set default wp post statuses if child has not already set.
88
-		if ( ! isset( $this->_fields[$primary_table_name]['status'] )) {
88
+		if ( ! isset($this->_fields[$primary_table_name]['status'])) {
89 89
 			$this->_fields[$primary_table_name]['status'] = new EE_WP_Post_Status_Field('post_status', __("Event Status", "event_espresso"), false, 'draft');
90 90
 		}
91
-		if( ! isset( $this->_fields[$primary_table_name]['to_ping'])){
92
-			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __( 'To Ping', 'event_espresso' ), FALSE, '');
91
+		if ( ! isset($this->_fields[$primary_table_name]['to_ping'])) {
92
+			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __('To Ping', 'event_espresso'), FALSE, '');
93 93
 		}
94
-		if( ! isset( $this->_fields[$primary_table_name]['pinged'])){
95
-			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __( 'Pinged', 'event_espresso' ), FALSE, '');
94
+		if ( ! isset($this->_fields[$primary_table_name]['pinged'])) {
95
+			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __('Pinged', 'event_espresso'), FALSE, '');
96 96
 		}
97 97
 
98
-		if( ! isset( $this->_fields[$primary_table_name]['comment_status'])){
99
-			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso' ), FALSE, 'open');
98
+		if ( ! isset($this->_fields[$primary_table_name]['comment_status'])) {
99
+			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso'), FALSE, 'open');
100 100
 		}
101 101
 
102
-		if( ! isset( $this->_fields[$primary_table_name]['ping_status'])){
102
+		if ( ! isset($this->_fields[$primary_table_name]['ping_status'])) {
103 103
 			$this->_fields[$primary_table_name]['ping_status'] = new EE_Plain_Text_Field('ping_status', __('Ping Status', 'event_espresso'), FALSE, 'open');
104 104
 		}
105 105
 
106
-		if( ! isset( $this->_fields[$primary_table_name]['post_content_filtered'])){
107
-			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __( 'Post Content Filtered', 'event_espresso' ), FALSE, '');
106
+		if ( ! isset($this->_fields[$primary_table_name]['post_content_filtered'])) {
107
+			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __('Post Content Filtered', 'event_espresso'), FALSE, '');
108 108
 		}
109
-		if( ! isset( $this->_model_relations[ 'Post_Meta' ] ) ) {
109
+		if ( ! isset($this->_model_relations['Post_Meta'])) {
110 110
 			//don't block deletes though because we want to maintain the current behaviour
111
-			$this->_model_relations[ 'Post_Meta' ] = new EE_Has_Many_Relation( false );
111
+			$this->_model_relations['Post_Meta'] = new EE_Has_Many_Relation(false);
112 112
 		}
113
-		if( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions ){
113
+		if ( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
114 114
 			//nothing was set during child constructor, so set default
115
-			$this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions( $this->post_type() );
115
+			$this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions($this->post_type());
116 116
 		}
117
-		if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ) {
117
+		if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
118 118
 			//nothing was set during child constructor, so set default
119 119
 			//it's ok for child classes to specify this, but generally this is more DRY
120
-			$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions( $this->post_type() );
120
+			$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions($this->post_type());
121 121
 		}
122 122
 		parent::__construct($timezone);
123 123
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function public_event_stati() {
132 132
 		// @see wp-includes/post.php
133
-		return get_post_stati( array( 'public' => TRUE ));
133
+		return get_post_stati(array('public' => TRUE));
134 134
 	}
135 135
 
136 136
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @return string
142 142
 	 * @throws EE_Error
143 143
 	 */
144
-	public function deleted_field_name(){
144
+	public function deleted_field_name() {
145 145
 		throw new EE_Error(sprintf(__("EEM_CPT_Base should nto call deleted_field_name! It should instead use post_status_field_name", "event_espresso")));
146 146
 	}
147 147
 
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	 * @return string
153 153
 	 * @throws EE_Error
154 154
 	 */
155
-	public function post_status_field_name(){
155
+	public function post_status_field_name() {
156 156
 		$field = $this->get_a_field_of_type('EE_WP_Post_Status_Field');
157
-		if($field){
157
+		if ($field) {
158 158
 			return $field->get_name();
159
-		}else{
160
-			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this)));
159
+		} else {
160
+			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this)));
161 161
 		}
162 162
 	}
163 163
 
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 	 * @param array $query_params like EEM_Base::get_all's $query_params
169 169
 	 * @return array like EEM_Base::get_all's $query_params
170 170
 	 */
171
-	protected function _alter_query_params_so_only_trashed_items_included($query_params){
172
-		$post_status_field_name=$this->post_status_field_name();
173
-		$query_params[0][$post_status_field_name]=self::post_status_trashed;
171
+	protected function _alter_query_params_so_only_trashed_items_included($query_params) {
172
+		$post_status_field_name = $this->post_status_field_name();
173
+		$query_params[0][$post_status_field_name] = self::post_status_trashed;
174 174
 		return $query_params;
175 175
 	}
176 176
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 * @param array $query_params
182 182
 	 * @return array
183 183
 	 */
184
-	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){
185
-		$query_params[ 'default_where_conditions' ] = 'minimum';
184
+	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) {
185
+		$query_params['default_where_conditions'] = 'minimum';
186 186
 		return $query_params;
187 187
 	}
188 188
 
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 	 * @param array $query_params like EEM_Base::get_all
195 195
 	 * @return boolean success
196 196
 	 */
197
-	function delete_or_restore($delete=true,$query_params = array()){
198
-		$post_status_field_name=$this->post_status_field_name();
197
+	function delete_or_restore($delete = true, $query_params = array()) {
198
+		$post_status_field_name = $this->post_status_field_name();
199 199
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
200 200
 		$new_status = $delete ? self::post_status_trashed : 'draft';
201
-		if ( $this->update (array($post_status_field_name=>$new_status), $query_params )) {
201
+		if ($this->update(array($post_status_field_name=>$new_status), $query_params)) {
202 202
 			return TRUE;
203 203
 		} else {
204 204
 			return FALSE;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function meta_table() {
217 217
 		$meta_table = $this->_get_other_tables();
218
-		$meta_table = reset( $meta_table );
218
+		$meta_table = reset($meta_table);
219 219
 		return $meta_table instanceof EE_Secondary_Table ? $meta_table->get_table_name() : NULL;
220 220
 	}
221 221
 
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
 	 * @param  bool $all triggers whether we include DB_Only fields or JUST non DB_Only fields.  Defaults to false (no db only fields)
228 228
 	 * @return array
229 229
 	 */
230
-	public function get_meta_table_fields( $all = FALSE ) {
230
+	public function get_meta_table_fields($all = FALSE) {
231 231
 		$all_fields = $fields_to_return = array();
232
-		foreach ( $this->_tables as $alias => $table_obj ) {
233
-			if ( $table_obj instanceof EE_Secondary_Table )
234
-				$all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields );
232
+		foreach ($this->_tables as $alias => $table_obj) {
233
+			if ($table_obj instanceof EE_Secondary_Table)
234
+				$all_fields = array_merge($this->_get_fields_for_table($alias), $all_fields);
235 235
 		}
236 236
 
237
-		if ( !$all ) {
238
-			foreach ( $all_fields as $name => $obj ) {
239
-				if ( $obj instanceof EE_DB_Only_Field_Base )
237
+		if ( ! $all) {
238
+			foreach ($all_fields as $name => $obj) {
239
+				if ($obj instanceof EE_DB_Only_Field_Base)
240 240
 					continue;
241 241
 				$fields_to_return[] = $name;
242 242
 			}
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
 	 * @param int $parent_term_taxonomy_id
260 260
 	 * @return EE_Term_Taxonomy
261 261
 	 */
262
-	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description ='',$parent_term_taxonomy_id = null){
262
+	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description = '', $parent_term_taxonomy_id = null) {
263 263
 		//create term
264
-		require_once( EE_MODELS . 'EEM_Term.model.php');
264
+		require_once(EE_MODELS.'EEM_Term.model.php');
265 265
 		//first, check for a term by the same name or slug
266 266
 		$category_slug = sanitize_title($category_name);
267
-		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name,'slug'=>$category_slug))));
268
-		if( ! $term ){
267
+		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name, 'slug'=>$category_slug))));
268
+		if ( ! $term) {
269 269
 			$term = EE_Term::new_instance(array(
270 270
 				'name'=>$category_name,
271 271
 				'slug'=>$category_slug
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 			$term->save();
274 274
 		}
275 275
 		//make sure there's a term-taxonomy entry too
276
-		require_once( EE_MODELS . 'EEM_Term_Taxonomy.model.php');
277
-		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(),'taxonomy'=>EE_Event_Category_Taxonomy)));
276
+		require_once(EE_MODELS.'EEM_Term_Taxonomy.model.php');
277
+		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(), 'taxonomy'=>EE_Event_Category_Taxonomy)));
278 278
 		/** @var $term_taxonomy EE_Term_Taxonomy */
279
-		if( ! $term_taxonomy ){
279
+		if ( ! $term_taxonomy) {
280 280
 			$term_taxonomy = EE_Term_Taxonomy::new_instance(array(
281 281
 				'term_id'=>$term->ID(),
282 282
 				'taxonomy'=>EE_Event_Category_Taxonomy,
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 				'parent'=>$parent_term_taxonomy_id
286 286
 			));
287 287
 			$term_taxonomy->save();
288
-		}else{
288
+		} else {
289 289
 			$term_taxonomy->set_count($term_taxonomy->count() + 1);
290 290
 			$term_taxonomy->save();
291 291
 		}
@@ -300,11 +300,11 @@  discard block
 block discarded – undo
300 300
 	 * @param string $category_name name of the event category (term)
301 301
 	 * @return bool
302 302
 	 */
303
-	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name){
303
+	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name) {
304 304
 		//find the term_taxonomy by that name
305
-		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name,'taxonomy'=>EE_Event_Category_Taxonomy)));
305
+		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name, 'taxonomy'=>EE_Event_Category_Taxonomy)));
306 306
 		/** @var $term_taxonomy EE_Term_Taxonomy */
307
-		if( $term_taxonomy ){
307
+		if ($term_taxonomy) {
308 308
 			$term_taxonomy->set_count($term_taxonomy->count() - 1);
309 309
 			$term_taxonomy->save();
310 310
 		}
@@ -324,8 +324,8 @@  discard block
 block discarded – undo
324 324
 	 * @param string|array $attr Optional. Query string or array of attributes.
325 325
 	 * @return string HTML image element
326 326
 	 */
327
-	public function get_feature_image( $id, $size = 'thumbnail', $attr = '' ) {
328
-		return get_the_post_thumbnail( $id, $size, $attr );
327
+	public function get_feature_image($id, $size = 'thumbnail', $attr = '') {
328
+		return get_the_post_thumbnail($id, $size, $attr);
329 329
 	}
330 330
 
331 331
 
@@ -338,10 +338,10 @@  discard block
 block discarded – undo
338 338
 	 * @global array $wp_post_statuses set in wp core for storing all the post stati
339 339
 	 * @return array
340 340
 	 */
341
-	public function get_post_statuses(){
341
+	public function get_post_statuses() {
342 342
 		global $wp_post_statuses;
343 343
 		$statuses = array();
344
-		foreach($wp_post_statuses as $post_status => $args_object){
344
+		foreach ($wp_post_statuses as $post_status => $args_object) {
345 345
 			$statuses[$post_status] = $args_object->label;
346 346
 		}
347 347
 		return $statuses;
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 	public function get_status_array() {
357 357
 		$statuses = $this->get_post_statuses();
358 358
 		//first the global filter
359
-		$statuses = apply_filters( 'FHEE_EEM_CPT_Base__get_status_array', $statuses );
359
+		$statuses = apply_filters('FHEE_EEM_CPT_Base__get_status_array', $statuses);
360 360
 		//now the class specific filter
361
-		$statuses = apply_filters( 'FHEE_EEM_' . get_class($this) . '__get_status_array', $statuses );
361
+		$statuses = apply_filters('FHEE_EEM_'.get_class($this).'__get_status_array', $statuses);
362 362
 		return $statuses;
363 363
 	}
364 364
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 	 */
371 371
 	public function get_custom_post_statuses() {
372 372
 		$new_stati = array();
373
-		foreach ( $this->_custom_stati as $status => $props ) {
373
+		foreach ($this->_custom_stati as $status => $props) {
374 374
 			$new_stati[$status] = $props['label'];
375 375
 		}
376 376
 		return $new_stati;
@@ -386,24 +386,24 @@  discard block
 block discarded – undo
386 386
 	 * @param WP_Post|array $post
387 387
 	 * @return EE_CPT_Base
388 388
 	 */
389
-	public function instantiate_class_from_post_object_orig($post){
390
-		$post = (array)$post;
389
+	public function instantiate_class_from_post_object_orig($post) {
390
+		$post = (array) $post;
391 391
 		$has_all_necessary_fields_for_table = true;
392 392
 		//check if the post has fields on the meta table already
393
-		foreach($this->_get_other_tables() as $table_obj){
393
+		foreach ($this->_get_other_tables() as $table_obj) {
394 394
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
395
-			foreach($fields_for_that_table as $field_obj){
396
-				if( ! isset($post[$field_obj->get_table_column()])
397
-					&& ! isset($post[$field_obj->get_qualified_column()])){
395
+			foreach ($fields_for_that_table as $field_obj) {
396
+				if ( ! isset($post[$field_obj->get_table_column()])
397
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
398 398
 					$has_all_necessary_fields_for_table = false;
399 399
 				}
400 400
 			}
401 401
 		}
402 402
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
403
-		if( ! $has_all_necessary_fields_for_table){
403
+		if ( ! $has_all_necessary_fields_for_table) {
404 404
 
405 405
 			return $this->get_one_by_ID($post['ID']);
406
-		}else{
406
+		} else {
407 407
 			return $this->instantiate_class_from_array_or_object($post);
408 408
 		}
409 409
 	}
@@ -414,30 +414,30 @@  discard block
 block discarded – undo
414 414
 	 * @param null $post
415 415
 	 * @return EE_Base_Class|EE_Soft_Delete_Base_Class
416 416
 	 */
417
-	public function instantiate_class_from_post_object( $post = NULL ){
418
-		if ( empty( $post )) {
417
+	public function instantiate_class_from_post_object($post = NULL) {
418
+		if (empty($post)) {
419 419
 			global $post;
420 420
 		}
421
-		$post = (array)$post;
421
+		$post = (array) $post;
422 422
 		$tables_needing_to_be_queried = array();
423 423
 		//check if the post has fields on the meta table already
424
-		foreach($this->get_tables() as $table_obj){
424
+		foreach ($this->get_tables() as $table_obj) {
425 425
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
426
-			foreach($fields_for_that_table as $field_obj){
427
-				if( ! isset($post[$field_obj->get_table_column()])
428
-					&& ! isset($post[$field_obj->get_qualified_column()])){
426
+			foreach ($fields_for_that_table as $field_obj) {
427
+				if ( ! isset($post[$field_obj->get_table_column()])
428
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
429 429
 					$tables_needing_to_be_queried[$table_obj->get_table_alias()] = $table_obj;
430 430
 				}
431 431
 			}
432 432
 		}
433 433
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
434
-		if( $tables_needing_to_be_queried){
435
-			if(count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table){
434
+		if ($tables_needing_to_be_queried) {
435
+			if (count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table) {
436 436
 				//so we're only missing data from a secondary table. Well that's not too hard to query for
437 437
 				$table_to_query = reset($tables_needing_to_be_queried);
438
-				$missing_data = $this->_do_wpdb_query( 'get_row', array( 'SELECT * FROM ' . $table_to_query->get_table_name() . ' WHERE ' . $table_to_query->get_fk_on_table() . ' = ' . $post['ID'], ARRAY_A ));
439
-				if ( ! empty( $missing_data )) {
440
-					$post = array_merge( $post, $missing_data );
438
+				$missing_data = $this->_do_wpdb_query('get_row', array('SELECT * FROM '.$table_to_query->get_table_name().' WHERE '.$table_to_query->get_fk_on_table().' = '.$post['ID'], ARRAY_A));
439
+				if ( ! empty($missing_data)) {
440
+					$post = array_merge($post, $missing_data);
441 441
 				}
442 442
 			} else {
443 443
 				return $this->get_one_by_ID($post['ID']);
@@ -454,15 +454,15 @@  discard block
 block discarded – undo
454 454
 	 * @throws EE_Error
455 455
 	 * @return string
456 456
 	 */
457
-	public function post_type(){
457
+	public function post_type() {
458 458
 		$post_type_field = NULL;
459
-		foreach($this->field_settings(true) as $field_obj){
460
-			if($field_obj instanceof EE_WP_Post_Type_Field){
461
-				$post_type_field = $field_obj;break;
459
+		foreach ($this->field_settings(true) as $field_obj) {
460
+			if ($field_obj instanceof EE_WP_Post_Type_Field) {
461
+				$post_type_field = $field_obj; break;
462 462
 			}
463 463
 		}
464
-		if($post_type_field == NULL){
465
-			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"),get_class($this)));
464
+		if ($post_type_field == NULL) {
465
+			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"), get_class($this)));
466 466
 		}
467 467
 		return $post_type_field->get_default_value();
468 468
 	}
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Default_Where_Conditions.strategy.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,18 +3,18 @@
 block discarded – undo
3 3
 	exit( 'No direct script access allowed' );
4 4
 }
5 5
 /**
6
- *
7
- * Class EE_Default_Where_Conditions
8
-  * 
9
- * Strategy to be used for getting default where conditions for EEM_Base children.
10
- * Should be initialized and set on construction of model
11
- *
12
- * @package         Event Espresso
13
- * @subpackage    core/db_models
14
- * @author				Mike Nelson
15
- * @since		 	    4.6.0
16
- *
17
- */
6
+	 *
7
+	 * Class EE_Default_Where_Conditions
8
+	 * 
9
+	 * Strategy to be used for getting default where conditions for EEM_Base children.
10
+	 * Should be initialized and set on construction of model
11
+	 *
12
+	 * @package         Event Espresso
13
+	 * @subpackage    core/db_models
14
+	 * @author				Mike Nelson
15
+	 * @since		 	    4.6.0
16
+	 *
17
+	 */
18 18
 class EE_Default_Where_Conditions{
19 19
 	/**
20 20
 	 * This const can be used in EE_Default_Where_Conditions values, and at the time of querying it will be
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 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
  *
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @since		 	    4.6.0
16 16
  *
17 17
  */
18
-class EE_Default_Where_Conditions{
18
+class EE_Default_Where_Conditions {
19 19
 	/**
20 20
 	 * This const can be used in EE_Default_Where_Conditions values, and at the time of querying it will be
21 21
 	 * replaced with the current user's ID (because we don't want to use the current user's ID at time of
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * onto any field names
48 48
 	 * @param array $custom_where_conditions
49 49
 	 */
50
-	public function __construct( $custom_where_conditions = array() ) {
50
+	public function __construct($custom_where_conditions = array()) {
51 51
 		$this->_where_conditions_provided = $custom_where_conditions;
52 52
 	}
53 53
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * for querying of the model.
57 57
 	 * @param EEM_Base $model
58 58
 	 */
59
-	function _finalize_construct(EEM_Base $model){
59
+	function _finalize_construct(EEM_Base $model) {
60 60
 		$this->_model = $model;
61 61
 	}
62 62
 	/**
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 	 * @param string $model_relation_chain
72 72
 	 * @return array like what's expected in EEM_Base::get_all()'s $query_params[0]
73 73
 	 */
74
-	function get_default_where_conditions( $model_relation_chain = '' ){
75
-		return $this->prepare_where_conditions_for_querying( array_merge( $this->_get_default_where_conditions(), $this->get_where_conditions_provided() ), $model_relation_chain );
74
+	function get_default_where_conditions($model_relation_chain = '') {
75
+		return $this->prepare_where_conditions_for_querying(array_merge($this->_get_default_where_conditions(), $this->get_where_conditions_provided()), $model_relation_chain);
76 76
 	}
77 77
 	/**
78 78
 	 * Gets the default where conditions that are specific to this child of EE_Default_Where_Conditions.
79 79
 	 * Adding model relation chains is handled by the public method get_default_where_conditions
80 80
 	 * @return array
81 81
 	 */
82
-	protected function _get_default_where_conditions(){
82
+	protected function _get_default_where_conditions() {
83 83
 		return array();
84 84
 	}
85 85
 
@@ -93,33 +93,33 @@  discard block
 block discarded – undo
93 93
 	 * @return array
94 94
 	 * @throws \EE_Error
95 95
 	 */
96
-	public function prepare_where_conditions_for_querying( $where_conditions, $model_relation_chain ) {
96
+	public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain) {
97 97
 		$where_conditions_with_model_relation_chain_prefixes = array();
98
-		if( ! is_array( $where_conditions ) ){
98
+		if ( ! is_array($where_conditions)) {
99 99
 			$where_conditions = array();
100 100
 		}
101
-		foreach( $where_conditions as $key => $value ) {
102
-			if( in_array( $key, array( 'OR', 'AND', 'NOT' ) ) ||
103
-			strpos( $key, 'OR*' )  !== false ||
104
-					strpos( $key, 'AND*' ) !== false ||
105
-					strpos( $key, 'NOT*' ) !== false ){
106
-				$where_conditions_with_model_relation_chain_prefixes[ $key ] = $this->prepare_where_conditions_for_querying( $value, $model_relation_chain );
107
-			}else{
108
-				if($model_relation_chain != '' && $model_relation_chain[strlen($model_relation_chain)-1] !='.'){
109
-					$model_relation_chain=$model_relation_chain.".";
101
+		foreach ($where_conditions as $key => $value) {
102
+			if (in_array($key, array('OR', 'AND', 'NOT')) ||
103
+			strpos($key, 'OR*') !== false ||
104
+					strpos($key, 'AND*') !== false ||
105
+					strpos($key, 'NOT*') !== false) {
106
+				$where_conditions_with_model_relation_chain_prefixes[$key] = $this->prepare_where_conditions_for_querying($value, $model_relation_chain);
107
+			} else {
108
+				if ($model_relation_chain != '' && $model_relation_chain[strlen($model_relation_chain) - 1] != '.') {
109
+					$model_relation_chain = $model_relation_chain.".";
110 110
 				}
111 111
 				//check for the current user id place holder, and if present change it
112
-				if( $value === self::current_user_placeholder ){
112
+				if ($value === self::current_user_placeholder) {
113 113
 					$value = get_current_user_id();
114 114
 				}
115 115
 				//check for user field placeholder
116
-				if( $key == self::user_field_name_placeholder ) {
117
-					if( ! $this->_model->wp_user_field_name() ) {
118
-						throw new EE_Error( sprintf( __( 'There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model', 'event_espresso' ), $this->_model->get_this_model_name() ) );
116
+				if ($key == self::user_field_name_placeholder) {
117
+					if ( ! $this->_model->wp_user_field_name()) {
118
+						throw new EE_Error(sprintf(__('There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model', 'event_espresso'), $this->_model->get_this_model_name()));
119 119
 					}
120 120
 					$key = $this->_model->wp_user_field_name();
121 121
 				}
122
-				$where_conditions_with_model_relation_chain_prefixes[ $model_relation_chain . $key ] = $value;
122
+				$where_conditions_with_model_relation_chain_prefixes[$model_relation_chain.$key] = $value;
123 123
 			}
124 124
 		}
125 125
 		return $where_conditions_with_model_relation_chain_prefixes;
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Soft_Delete_Where_Conditions.strategy.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@
 block discarded – undo
3 3
 	exit( 'No direct script access allowed' );
4 4
 }
5 5
 /**
6
- *
7
- * Class EE_Default_Where_Conditions
8
- * 
9
- * Strategy specifically for adding where conditions specific to CPT models.
10
- *
11
- * @package         Event Espresso
12
- * @subpackage    core/db_models
13
- * @author				Mike Nelson
14
- * @since		 	   4.6.0
15
- */
6
+	 *
7
+	 * Class EE_Default_Where_Conditions
8
+	 * 
9
+	 * Strategy specifically for adding where conditions specific to CPT models.
10
+	 *
11
+	 * @package         Event Espresso
12
+	 * @subpackage    core/db_models
13
+	 * @author				Mike Nelson
14
+	 * @since		 	   4.6.0
15
+	 */
16 16
 class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions{
17 17
 	/**
18 18
 	 * Strategy for setting default soft delete where conditions. This strategy will find
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 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
  *
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @author				Mike Nelson
14 14
  * @since		 	   4.6.0
15 15
  */
16
-class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions{
16
+class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions {
17 17
 	/**
18 18
 	 * Strategy for setting default soft delete where conditions. This strategy will find
19 19
 	 * the field of type 'EE_Trashed_Flag_Field', and add a condition that it be FALSE on all queries involving
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 	 * Eg,
23 23
 	 *
24 24
 	 */
25
-	function __construct(){}
25
+	function __construct() {}
26 26
 	/**
27 27
 	 * Gets the where default where conditions for a custom post type model
28 28
 	 * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions)
29 29
 	 */
30
-	protected function _get_default_where_conditions(){
30
+	protected function _get_default_where_conditions() {
31 31
 		$trashed_field_name = $this->deleted_field_name();
32 32
 		return array(
33 33
 			$trashed_field_name => false
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	 * @return string
40 40
 	 * @throws EE_Error
41 41
 	 */
42
-	private function deleted_field_name(){
42
+	private function deleted_field_name() {
43 43
 		$field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field');
44
-		if($field){
44
+		if ($field) {
45 45
 			return $field->get_name();
46
-		}else{
47
-			throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this)));
46
+		} else {
47
+			throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this)));
48 48
 		}
49 49
 	}
50 50
 }
51 51
\ No newline at end of file
Please login to merge, or discard this patch.
reg_steps/payment_options/EE_SPCO_Reg_Step_Payment_Options.class.php 1 patch
Spacing   +385 added lines, -385 removed lines patch added patch discarded remove patch
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
 	 *  @return 	void
29 29
 	 */
30 30
 	public static function set_hooks() {
31
-		add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) );
32
-		add_action( 'wp_ajax_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ));
33
-		add_action( 'wp_ajax_nopriv_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ));
34
-		add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ));
35
-		add_action( 'wp_ajax_nopriv_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ));
36
-		add_action( 'wp_ajax_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) );
37
-		add_action( 'wp_ajax_nopriv_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' )
31
+		add_filter('FHEE__SPCO__EE_Line_Item_Filter_Collection', array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters'));
32
+		add_action('wp_ajax_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form'));
33
+		add_action('wp_ajax_nopriv_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form'));
34
+		add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
35
+		add_action('wp_ajax_nopriv_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
36
+		add_action('wp_ajax_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details'));
37
+		add_action('wp_ajax_nopriv_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
38 38
 		);
39
-		add_filter( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), 10, 1 );
39
+		add_filter('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), 10, 1);
40 40
 	}
41 41
 
42 42
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * 	ajax switch_spco_billing_form
46 46
 	 */
47 47
 	public static function switch_spco_billing_form() {
48
-		EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' );
48
+		EED_Single_Page_Checkout::process_ajax_request('switch_payment_method');
49 49
 	}
50 50
 
51 51
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * 	ajax save_payer_details
55 55
 	 */
56 56
 	public static function save_payer_details() {
57
-		EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' );
57
+		EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax');
58 58
 	}
59 59
 
60 60
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * 	ajax get_transaction_details
64 64
 	 */
65 65
 	public static function get_transaction_details() {
66
-		EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' );
66
+		EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways');
67 67
 	}
68 68
 
69 69
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 	 * @param    EE_Checkout $checkout
92 92
 	 * @return    \EE_SPCO_Reg_Step_Payment_Options
93 93
 	 */
94
-	public function __construct( EE_Checkout $checkout ) {
94
+	public function __construct(EE_Checkout $checkout) {
95 95
 		$this->_slug = 'payment_options';
96 96
 		$this->_name = __('Payment Options', 'event_espresso');
97
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php';
97
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php';
98 98
 		$this->checkout = $checkout;
99 99
 		$this->_reset_success_message();
100
-		$this->set_instructions( __('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso'));
100
+		$this->set_instructions(__('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso'));
101 101
 	}
102 102
 
103 103
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	/**
115 115
 	 * @param null $line_item_display
116 116
 	 */
117
-	public function set_line_item_display( $line_item_display ) {
117
+	public function set_line_item_display($line_item_display) {
118 118
 		$this->line_item_display = $line_item_display;
119 119
 	}
120 120
 
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	 * @return void
126 126
 	 */
127 127
 	public function translate_js_strings() {
128
-		EE_Registry::$i18n_js_strings['no_payment_method'] = __( 'Please select a method of payment in order to continue.', 'event_espresso' );
129
-		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso' );
130
-		EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __( 'Forwarding to Secure Payment Provider.', 'event_espresso' );
128
+		EE_Registry::$i18n_js_strings['no_payment_method'] = __('Please select a method of payment in order to continue.', 'event_espresso');
129
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso');
130
+		EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __('Forwarding to Secure Payment Provider.', 'event_espresso');
131 131
 	}
132 132
 
133 133
 
@@ -156,20 +156,20 @@  discard block
 block discarded – undo
156 156
 			// 	$ 0.00 transactions (no payment required)
157 157
 			! $this->checkout->payment_required()
158 158
 			// but do NOT remove if current action being called belongs to this reg step
159
-			&& ! is_callable( array( $this, $this->checkout->action ) )
159
+			&& ! is_callable(array($this, $this->checkout->action))
160 160
 			&& ! $this->completed()
161 161
 		) {
162 162
 			// and if so, then we no longer need the Payment Options step
163
-			if ( $this->is_current_step() ) {
163
+			if ($this->is_current_step()) {
164 164
 				$this->checkout->generate_reg_form = false;
165 165
 			}
166
-			$this->checkout->remove_reg_step( $this->_slug );
166
+			$this->checkout->remove_reg_step($this->_slug);
167 167
 			// DEBUG LOG
168 168
 			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
169 169
 			return false;
170 170
 		}
171 171
 		// load EEM_Payment_Method
172
-		EE_Registry::instance()->load_model( 'Payment_Method' );
172
+		EE_Registry::instance()->load_model('Payment_Method');
173 173
 		// get all active payment methods
174 174
 		$this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
175 175
 			$this->checkout->transaction, EEM_Payment_Method::scope_cart
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 * @return bool
184 184
 	 */
185 185
 	public function generate_reg_form() {
186
-		EE_Registry::instance()->load_helper( 'HTML' );
186
+		EE_Registry::instance()->load_helper('HTML');
187 187
 		// reset in case someone changes their mind
188 188
 		$this->_reset_selected_method_of_payment();
189 189
 		// set some defaults
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
 		$reg_count = 0;
196 196
 		$no_payment_required = true;
197 197
 		// loop thru registrations to gather info
198
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
199
-		foreach ( $registrations as $registration ) {
198
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
199
+		foreach ($registrations as $registration) {
200 200
 			/** @var $registration EE_Registration */
201 201
 			$reg_count++;
202 202
 			// registrant is NOT Approved
203
-			if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) {
203
+			if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
204 204
 				// add event to list of events with pre-approval reg status
205
-				$registrations_requiring_pre_approval[ $registration->ID() ] = $registration;
205
+				$registrations_requiring_pre_approval[$registration->ID()] = $registration;
206 206
 				do_action(
207 207
 					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
208 208
 					$registration->event(),
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 				&& $registration->event()->is_sold_out()
220 220
 			) {
221 221
 				// add event to list of events that are sold out
222
-				$sold_out_events[ $registration->event()->ID() ] = $registration->event();
222
+				$sold_out_events[$registration->event()->ID()] = $registration->event();
223 223
 				do_action(
224 224
 					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
225 225
 					$registration->event(),
@@ -228,29 +228,29 @@  discard block
 block discarded – undo
228 228
 				continue;
229 229
 			}
230 230
 			// are they allowed to pay now and is there monies owing?
231
-			if ( $registration->owes_monies_and_can_pay() ) {
232
-				$registrations_requiring_payment[ $registration->ID() ] = $registration;
231
+			if ($registration->owes_monies_and_can_pay()) {
232
+				$registrations_requiring_payment[$registration->ID()] = $registration;
233 233
 				do_action(
234 234
 					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
235 235
 					$registration->event(),
236 236
 					$this
237 237
 				);
238
-			} else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()  ) {
239
-				$registrations_for_free_events[ $registration->event()->ID() ] = $registration;
238
+			} else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()) {
239
+				$registrations_for_free_events[$registration->event()->ID()] = $registration;
240 240
 			}
241 241
 		}
242 242
 		$subsections = array();
243 243
 		// now decide which template to load
244
-		if ( ! empty( $sold_out_events )) {
245
-			$subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events );
244
+		if ( ! empty($sold_out_events)) {
245
+			$subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
246 246
 		}
247
-		if ( ! empty( $registrations_requiring_pre_approval )) {
248
-			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( $registrations_requiring_pre_approval );
247
+		if ( ! empty($registrations_requiring_pre_approval)) {
248
+			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval($registrations_requiring_pre_approval);
249 249
 		}
250
-		if ( ! empty( $registrations_for_free_events ) ) {
251
-			$subsections[ 'no_payment_required' ] = $this->_no_payment_required( $registrations_for_free_events );
250
+		if ( ! empty($registrations_for_free_events)) {
251
+			$subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
252 252
 		}
253
-		if ( ! empty( $registrations_requiring_payment ) ) {
253
+		if ( ! empty($registrations_requiring_payment)) {
254 254
 			// autoload Line_Item_Display classes
255 255
 			EEH_Autoloader::register_line_item_filter_autoloaders();
256 256
 			$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
 				$this->checkout->cart->get_grand_total()
262 262
 			);
263 263
 			$filtered_line_item_tree = $line_item_filter_processor->process();
264
-			if ( $this->checkout->amount_owing > 0 ) {
264
+			if ($this->checkout->amount_owing > 0) {
265 265
 				EEH_Autoloader::register_line_item_display_autoloaders();
266
-				$this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) );
267
-				$subsections[ 'payment_options' ] = $this->_display_payment_options(
266
+				$this->set_line_item_display(new EE_Line_Item_Display('spco'));
267
+				$subsections['payment_options'] = $this->_display_payment_options(
268 268
 					$this->line_item_display->display_line_item(
269 269
 						$filtered_line_item_tree,
270
-						array( 'registrations' => $registrations )
270
+						array('registrations' => $registrations)
271 271
 					)
272 272
 				);
273 273
 				$this->checkout->amount_owing = $filtered_line_item_tree->total();
274
-				$this->_apply_registration_payments_to_amount_owing( $registrations );
274
+				$this->_apply_registration_payments_to_amount_owing($registrations);
275 275
 			}
276 276
 			$no_payment_required = false;
277 277
 		} else {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		$this->_save_selected_method_of_payment();
281 281
 
282 282
 		$subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs();
283
-		$subsections['extra_hidden_inputs' ] = $this->_extra_hidden_inputs( $no_payment_required );
283
+		$subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required);
284 284
 
285 285
 		return new EE_Form_Section_Proper(
286 286
 			array(
@@ -308,21 +308,21 @@  discard block
 block discarded – undo
308 308
 	 * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection
309 309
 	 * @return \EE_Line_Item_Filter_Collection
310 310
 	 */
311
-	public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) {
312
-		if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) {
311
+	public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) {
312
+		if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
313 313
 			return $line_item_filter_collection;
314 314
 		}
315
-		if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout ) {
315
+		if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
316 316
 			return $line_item_filter_collection;
317 317
 		}
318
-		if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction ) {
318
+		if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
319 319
 			return $line_item_filter_collection;
320 320
 		}
321 321
 		$registrations = EE_Registry::instance()->SSN->checkout()->transaction->registrations(
322 322
 			EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
323 323
 		);
324
-		$line_item_filter_collection->add( new EE_Billable_Line_Item_Filter( $registrations ) );
325
-		$line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() );
324
+		$line_item_filter_collection->add(new EE_Billable_Line_Item_Filter($registrations));
325
+		$line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter());
326 326
 		return $line_item_filter_collection;
327 327
 	}
328 328
 
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * @return void
337 337
 	 */
338 338
 	protected function _hide_reg_step_submit_button_if_revisit() {
339
-		if ( $this->checkout->revisit ) {
340
-			add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' );
339
+		if ($this->checkout->revisit) {
340
+			add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string');
341 341
 		}
342 342
 	}
343 343
 
@@ -348,25 +348,25 @@  discard block
 block discarded – undo
348 348
 	 * @param \EE_Event[] $sold_out_events_array
349 349
 	 * @return \EE_Form_Section_Proper
350 350
 	 */
351
-	private function _sold_out_events( $sold_out_events_array = array() ) {
351
+	private function _sold_out_events($sold_out_events_array = array()) {
352 352
 		// set some defaults
353 353
 		$this->checkout->selected_method_of_payment = 'events_sold_out';
354 354
 		$sold_out_events = '';
355
-		foreach ( $sold_out_events_array as $sold_out_event ) {
356
-			$sold_out_events .= EEH_HTML::li( EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ));
355
+		foreach ($sold_out_events_array as $sold_out_event) {
356
+			$sold_out_events .= EEH_HTML::li(EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text'));
357 357
 		}
358 358
 		return new EE_Form_Section_Proper(
359 359
 			array(
360 360
 				'layout_strategy'		=> new EE_Template_Layout(
361 361
 					array(
362
-						'layout_template_file' 	=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'sold_out_events.template.php', // layout_template
362
+						'layout_template_file' 	=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'sold_out_events.template.php', // layout_template
363 363
 						'template_args'  				=> apply_filters(
364 364
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
365 365
 							array(
366 366
 								'sold_out_events' 			=> $sold_out_events,
367 367
 								'sold_out_events_msg' 	=> apply_filters(
368 368
 									'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg',
369
-									__( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' )
369
+									__('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso')
370 370
 								)
371 371
 							)
372 372
 						)
@@ -383,14 +383,14 @@  discard block
 block discarded – undo
383 383
 	 * @param array $registrations_requiring_pre_approval
384 384
 	 * @return \EE_Form_Section_Proper
385 385
 	 */
386
-	private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array()) {
386
+	private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) {
387 387
 		$events_requiring_pre_approval = '';
388
-		foreach ( $registrations_requiring_pre_approval as $registration ) {
389
-			if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) {
390
-				$events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
391
-					EEH_HTML::span( '', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text'
388
+		foreach ($registrations_requiring_pre_approval as $registration) {
389
+			if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
390
+				$events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li(
391
+					EEH_HTML::span('', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text'
392 392
 					)
393
-					. EEH_HTML::span( $registration->event()->name(), '', 'orange-text' )
393
+					. EEH_HTML::span($registration->event()->name(), '', 'orange-text')
394 394
 				);
395 395
 			}
396 396
 		}
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
 			array(
399 399
 				'layout_strategy'		=> new EE_Template_Layout(
400 400
 					array(
401
-						'layout_template_file' 	=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'events_requiring_pre_approval.template.php', // layout_template
401
+						'layout_template_file' 	=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'events_requiring_pre_approval.template.php', // layout_template
402 402
 						'template_args'  				=> apply_filters(
403 403
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
404 404
 							array(
405
-								'events_requiring_pre_approval' 			=> implode( '', $events_requiring_pre_approval ),
405
+								'events_requiring_pre_approval' 			=> implode('', $events_requiring_pre_approval),
406 406
 								'events_requiring_pre_approval_msg' 	=> apply_filters(
407 407
 									'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg',
408
-									__( 'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso' )
408
+									__('The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso')
409 409
 								)
410 410
 							)
411 411
 						),
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 * @param \EE_Event[] $registrations_for_free_events
424 424
 	 * @return \EE_Form_Section_Proper
425 425
 	 */
426
-	private function _no_payment_required( $registrations_for_free_events = array() ) {
426
+	private function _no_payment_required($registrations_for_free_events = array()) {
427 427
 		// set some defaults
428 428
 		$this->checkout->selected_method_of_payment = 'no_payment_required';
429 429
 		// generate no_payment_required form
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 			array(
432 432
 				'layout_strategy' 	=> new EE_Template_Layout(
433 433
 					array(
434
-						'layout_template_file' 	=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'no_payment_required.template.php', // layout_template
434
+						'layout_template_file' 	=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'no_payment_required.template.php', // layout_template
435 435
 						'template_args'  				=> apply_filters(
436 436
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args',
437 437
 							array(
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 								'registrations' => array(),
440 440
 								'ticket_count' 	=> array(),
441 441
 								'registrations_for_free_events' 	=> $registrations_for_free_events,
442
-								'no_payment_required_msg' => EEH_HTML::p( __( 'This is a free event, so no billing will occur.', 'event_espresso' ))
442
+								'no_payment_required_msg' => EEH_HTML::p(__('This is a free event, so no billing will occur.', 'event_espresso'))
443 443
 							)
444 444
 						),
445 445
 					)
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 	 * @param string $transaction_details
457 457
 	 * @return \EE_Form_Section_Proper
458 458
 	 */
459
-	private function _display_payment_options( $transaction_details = '' ) {
459
+	private function _display_payment_options($transaction_details = '') {
460 460
 		// has method_of_payment been set by no-js user?
461 461
 		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
462 462
 		// build payment options form
@@ -468,18 +468,18 @@  discard block
 block discarded – undo
468 468
 						'before_payment_options' => apply_filters(
469 469
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options',
470 470
 							new EE_Form_Section_Proper(
471
-								array( 'layout_strategy'	=> new EE_Div_Per_Section_Layout() )
471
+								array('layout_strategy'	=> new EE_Div_Per_Section_Layout())
472 472
 							)
473 473
 						),
474 474
 						'payment_options' => $this->_setup_payment_options(),
475 475
 						'after_payment_options' => apply_filters(
476 476
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options',
477 477
 							new EE_Form_Section_Proper(
478
-								array( 'layout_strategy'	=> new EE_Div_Per_Section_Layout() )
478
+								array('layout_strategy'	=> new EE_Div_Per_Section_Layout())
479 479
 							)
480 480
 						),
481 481
 					),
482
-					'layout_strategy'	=> new EE_Template_Layout( array(
482
+					'layout_strategy'	=> new EE_Template_Layout(array(
483 483
 							'layout_template_file' 	=> $this->_template,
484 484
 							'template_args'  				=> apply_filters(
485 485
 								'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args',
@@ -503,11 +503,11 @@  discard block
 block discarded – undo
503 503
 	 * @param bool $no_payment_required
504 504
 	 * @return \EE_Form_Section_Proper
505 505
 	 */
506
-	private function _extra_hidden_inputs( $no_payment_required = TRUE ) {
506
+	private function _extra_hidden_inputs($no_payment_required = TRUE) {
507 507
 
508 508
 		return new EE_Form_Section_Proper(
509 509
 			array(
510
-				'html_id' 				=> 'ee-' . $this->slug() . '-extra-hidden-inputs',
510
+				'html_id' 				=> 'ee-'.$this->slug().'-extra-hidden-inputs',
511 511
 				'layout_strategy'	=> new EE_Div_Per_Section_Layout(),
512 512
 				'subsections' 		=> array(
513 513
 					'spco_no_payment_required' => new EE_Hidden_Input(
@@ -540,16 +540,16 @@  discard block
 block discarded – undo
540 540
 	 * @access    protected
541 541
 	 * @return    void
542 542
 	 */
543
-	protected function _apply_registration_payments_to_amount_owing( $registrations ) {
543
+	protected function _apply_registration_payments_to_amount_owing($registrations) {
544 544
 		$payments = array();
545
-		foreach ( $registrations as $registration ) {
546
-			if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) {
545
+		foreach ($registrations as $registration) {
546
+			if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
547 547
 				$payments = $payments + $registration->registration_payments();
548 548
 			}
549 549
 		}
550
-		if ( ! empty( $payments ) ) {
551
-			foreach ( $payments as $payment ) {
552
-				if ( $payment instanceof EE_Registration_Payment ) {
550
+		if ( ! empty($payments)) {
551
+			foreach ($payments as $payment) {
552
+				if ($payment instanceof EE_Registration_Payment) {
553 553
 					$this->checkout->amount_owing -= $payment->amount();
554 554
 				}
555 555
 			}
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
 	 * @param 	bool $force_reset
565 565
 	 * @return 	void
566 566
 	 */
567
-	private function _reset_selected_method_of_payment( $force_reset = FALSE ) {
568
-		$reset_payment_method = $force_reset ? TRUE : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', FALSE ));
569
-		if ( $reset_payment_method ) {
567
+	private function _reset_selected_method_of_payment($force_reset = FALSE) {
568
+		$reset_payment_method = $force_reset ? TRUE : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', FALSE));
569
+		if ($reset_payment_method) {
570 570
 			$this->checkout->selected_method_of_payment = NULL;
571 571
 			$this->checkout->payment_method = NULL;
572 572
 			$this->checkout->billing_form = NULL;
@@ -585,9 +585,9 @@  discard block
 block discarded – undo
585 585
 	 * @param string $selected_method_of_payment
586 586
 	 * 	@return 		EE_Billing_Info_Form
587 587
 	 */
588
-	private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) {
589
-		$selected_method_of_payment = ! empty( $selected_method_of_payment ) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment;
590
-		EE_Registry::instance()->SSN->set_session_data( array( 'selected_method_of_payment' => $selected_method_of_payment ));
588
+	private function _save_selected_method_of_payment($selected_method_of_payment = '') {
589
+		$selected_method_of_payment = ! empty($selected_method_of_payment) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment;
590
+		EE_Registry::instance()->SSN->set_session_data(array('selected_method_of_payment' => $selected_method_of_payment));
591 591
 	}
592 592
 
593 593
 
@@ -600,40 +600,40 @@  discard block
 block discarded – undo
600 600
 		// load payment method classes
601 601
 		$this->checkout->available_payment_methods = $this->_get_available_payment_methods();
602 602
 		// switch up header depending on number of available payment methods
603
-		$payment_method_header = count( $this->checkout->available_payment_methods ) > 1
604
-			? apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Please Select Your Method of Payment', 'event_espresso' ))
605
-			: apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Method of Payment', 'event_espresso' ));
603
+		$payment_method_header = count($this->checkout->available_payment_methods) > 1
604
+			? apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Please Select Your Method of Payment', 'event_espresso'))
605
+			: apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Method of Payment', 'event_espresso'));
606 606
 		$available_payment_methods = array(
607 607
 			// display the "Payment Method" header
608 608
 			'payment_method_header' => new EE_Form_Section_HTML(
609
-				EEH_HTML::h4 ( $payment_method_header, 'method-of-payment-hdr' )
609
+				EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr')
610 610
 			)
611 611
 		);
612 612
 		// the list of actual payment methods ( invoice, paypal, etc ) in a  ( slug => HTML )  format
613 613
 		$available_payment_method_options = array();
614 614
 		$default_payment_method_option = array();
615 615
 		// additional instructions to be displayed and hidden below payment methods (adding a clearing div to start)
616
-		$payment_methods_billing_info = array( new EE_Form_Section_HTML( EEH_HTML::div ( '<br />', '', '', 'clear:both;' )));
616
+		$payment_methods_billing_info = array(new EE_Form_Section_HTML(EEH_HTML::div('<br />', '', '', 'clear:both;')));
617 617
 		// loop through payment methods
618
-		foreach( $this->checkout->available_payment_methods as $payment_method ) {
619
-			if ( $payment_method instanceof EE_Payment_Method ) {
620
-				$payment_method_button = EEH_HTML::img( $payment_method->button_url(), $payment_method->name(), 'spco-payment-method-' . $payment_method->slug() . '-btn-img', 'spco-payment-method-btn-img' );
618
+		foreach ($this->checkout->available_payment_methods as $payment_method) {
619
+			if ($payment_method instanceof EE_Payment_Method) {
620
+				$payment_method_button = EEH_HTML::img($payment_method->button_url(), $payment_method->name(), 'spco-payment-method-'.$payment_method->slug().'-btn-img', 'spco-payment-method-btn-img');
621 621
 				// check if any payment methods are set as default
622 622
 				// if payment method is already selected OR nothing is selected and this payment method should be open_by_default
623
-				if (( $this->checkout->selected_method_of_payment == $payment_method->slug() ) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )) {
623
+				if (($this->checkout->selected_method_of_payment == $payment_method->slug()) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())) {
624 624
 					$this->checkout->selected_method_of_payment = $payment_method->slug();
625 625
 					$this->_save_selected_method_of_payment();
626
-					$default_payment_method_option[ $payment_method->slug() ] =  $payment_method_button;
626
+					$default_payment_method_option[$payment_method->slug()] = $payment_method_button;
627 627
 				} else {
628
-					$available_payment_method_options[ $payment_method->slug() ] =  $payment_method_button;
628
+					$available_payment_method_options[$payment_method->slug()] = $payment_method_button;
629 629
 				}
630
-				$payment_methods_billing_info[ $payment_method->slug() . '-info' ] = $this->_payment_method_billing_info( $payment_method );
630
+				$payment_methods_billing_info[$payment_method->slug().'-info'] = $this->_payment_method_billing_info($payment_method);
631 631
 			}
632 632
 		}
633 633
 		// prepend available_payment_method_options with default_payment_method_option so that it appears first in list of PMs
634 634
 		$available_payment_method_options = $default_payment_method_option + $available_payment_method_options;
635 635
 		// now generate the actual form  inputs
636
-		$available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs( $available_payment_method_options );
636
+		$available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs($available_payment_method_options);
637 637
 		$available_payment_methods = $available_payment_methods + $payment_methods_billing_info;
638 638
 
639 639
 		// build the available payment methods form
@@ -653,19 +653,19 @@  discard block
 block discarded – undo
653 653
 	 * @return EE_Payment_Method[]
654 654
 	 */
655 655
 	protected function _get_available_payment_methods() {
656
-		if ( ! empty( $this->checkout->available_payment_methods )) {
656
+		if ( ! empty($this->checkout->available_payment_methods)) {
657 657
 			return $this->checkout->available_payment_methods;
658 658
 		}
659 659
 		$available_payment_methods = array();
660 660
 		// load EEM_Payment_Method
661
-		EE_Registry::instance()->load_model( 'Payment_Method' );
661
+		EE_Registry::instance()->load_model('Payment_Method');
662 662
 		/** @type EEM_Payment_Method $EEM_Payment_Method */
663 663
 		$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
664 664
 		// get all active payment methods
665
-		$payment_methods = $EEM_Payment_Method->get_all_for_transaction( $this->checkout->transaction, EEM_Payment_Method::scope_cart );
666
-		foreach ( $payment_methods as $payment_method ) {
667
-			if ( $payment_method instanceof EE_Payment_Method ) {
668
-				$available_payment_methods[ $payment_method->slug() ] = $payment_method;
665
+		$payment_methods = $EEM_Payment_Method->get_all_for_transaction($this->checkout->transaction, EEM_Payment_Method::scope_cart);
666
+		foreach ($payment_methods as $payment_method) {
667
+			if ($payment_method instanceof EE_Payment_Method) {
668
+				$available_payment_methods[$payment_method->slug()] = $payment_method;
669 669
 			}
670 670
 		}
671 671
 		return $available_payment_methods;
@@ -681,14 +681,14 @@  discard block
 block discarded – undo
681 681
 	 * @param 	array $available_payment_method_options
682 682
 	 * @return 	\EE_Form_Section_Proper
683 683
 	 */
684
-	private function _available_payment_method_inputs( $available_payment_method_options = array() ) {
684
+	private function _available_payment_method_inputs($available_payment_method_options = array()) {
685 685
 		// generate inputs
686 686
 		return new EE_Form_Section_Proper(
687 687
 			array(
688 688
 				'html_id' 				=> 'ee-available-payment-method-inputs',
689 689
 				'layout_strategy'	=> new EE_Div_Per_Section_Layout(),
690 690
 				'subsections' 		=> array(
691
-					'' => new EE_Radio_Button_Input (
691
+					'' => new EE_Radio_Button_Input(
692 692
 						$available_payment_method_options,
693 693
 						array(
694 694
 							'html_name' 				=> 'selected_method_of_payment',
@@ -712,36 +712,36 @@  discard block
 block discarded – undo
712 712
 	 * @param 	EE_Payment_Method $payment_method
713 713
 	 * @return 	\EE_Form_Section_Proper
714 714
 	 */
715
-	private function _payment_method_billing_info( EE_Payment_Method $payment_method ) {
715
+	private function _payment_method_billing_info(EE_Payment_Method $payment_method) {
716 716
 		$currently_selected = $this->checkout->selected_method_of_payment == $payment_method->slug() ? TRUE : FALSE;
717 717
 		// generate the billing form for payment method
718
-		$billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method( $payment_method ) : new EE_Form_Section_HTML();
718
+		$billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method($payment_method) : new EE_Form_Section_HTML();
719 719
 		$this->checkout->billing_form = $currently_selected ? $billing_form : $this->checkout->billing_form;
720 720
 		// it's all in the details
721
-		$info_html = EEH_HTML::h3 ( __( 'Important information regarding your payment', 'event_espresso' ), '', 'spco-payment-method-hdr' );
721
+		$info_html = EEH_HTML::h3(__('Important information regarding your payment', 'event_espresso'), '', 'spco-payment-method-hdr');
722 722
 		// add some info regarding the step, either from what's saved in the admin, or a default string depending on whether the PM has a billing form or not
723
-		if ( $payment_method->description() ) {
723
+		if ($payment_method->description()) {
724 724
 			$payment_method_info = $payment_method->description();
725
-		} elseif ( $billing_form instanceof EE_Billing_Info_Form ) {
726
-			$payment_method_info = sprintf( __( 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() );
725
+		} elseif ($billing_form instanceof EE_Billing_Info_Form) {
726
+			$payment_method_info = sprintf(__('Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text());
727 727
 		} else {
728
-			$payment_method_info = sprintf( __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() );
728
+			$payment_method_info = sprintf(__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text());
729 729
 		}
730
-		$info_html .= EEH_HTML::p (
731
-			apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info ),
730
+		$info_html .= EEH_HTML::p(
731
+			apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info),
732 732
 			'',
733 733
 			'spco-payment-method-desc ee-attention'
734 734
 		);
735 735
 
736 736
 		return new EE_Form_Section_Proper(
737 737
 			array(
738
-				'html_id' 					=> 'spco-payment-method-info-' . $payment_method->slug(),
738
+				'html_id' 					=> 'spco-payment-method-info-'.$payment_method->slug(),
739 739
 				'html_class' 			=> 'spco-payment-method-info-dv',
740 740
 				// only display the selected or default PM
741 741
 				'html_style' 			=> $currently_selected ? '' : 'display:none;',
742 742
 				'layout_strategy'		=> new EE_Div_Per_Section_Layout(),
743 743
 				'subsections' 			=> array(
744
-					'info' 					=> new EE_Form_Section_HTML( $info_html ),
744
+					'info' 					=> new EE_Form_Section_HTML($info_html),
745 745
 					'billing_form' 		=> $currently_selected ? $billing_form : new EE_Form_Section_HTML()
746 746
 				)
747 747
 			)
@@ -759,12 +759,12 @@  discard block
 block discarded – undo
759 759
 	 */
760 760
 	public function get_billing_form_html_for_payment_method() {
761 761
 		// how have they chosen to pay?
762
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE );
762
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE);
763 763
 		$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
764
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
764
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
765 765
 			return FALSE;
766 766
 		}
767
-		if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) {
767
+		if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
768 768
             EE_Error::add_success(
769 769
                 apply_filters(
770 770
                     'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
@@ -773,20 +773,20 @@  discard block
 block discarded – undo
773 773
             );
774 774
         }
775 775
 		// now generate billing form for selected method of payment
776
-		$payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
776
+		$payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
777 777
 		// fill form with attendee info if applicable
778
-		if ( $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) {
779
-			$payment_method_billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() );
778
+		if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) {
779
+			$payment_method_billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee());
780 780
 		}
781 781
 		// and debug content
782
-		if ( $payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) {
783
-			$payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $payment_method_billing_form );
782
+		if ($payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) {
783
+			$payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($payment_method_billing_form);
784 784
 		}
785 785
 		$billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper ? $payment_method_billing_form->get_html() : '';
786
-		$this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ));
786
+		$this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
787 787
 		// localize validation rules for main form
788 788
 		$this->checkout->current_step->reg_form->localize_validation_rules();
789
-		$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
789
+		$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
790 790
 		return TRUE;
791 791
 	}
792 792
 
@@ -799,15 +799,15 @@  discard block
 block discarded – undo
799 799
 	 * @param EE_Payment_Method $payment_method
800 800
 	 * @return \EE_Billing_Info_Form
801 801
 	 */
802
-	private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) {
803
-		$billing_form = $payment_method->type_obj()->billing_form( $this->checkout->transaction, array( 'amount_owing' => $this->checkout->amount_owing ) );
804
-		if ( $billing_form instanceof EE_Billing_Info_Form ) {
805
-			if ( EE_Registry::instance()->REQ->is_set( 'payment_method' )) {
806
-                if ( apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false )) {
802
+	private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) {
803
+		$billing_form = $payment_method->type_obj()->billing_form($this->checkout->transaction, array('amount_owing' => $this->checkout->amount_owing));
804
+		if ($billing_form instanceof EE_Billing_Info_Form) {
805
+			if (EE_Registry::instance()->REQ->is_set('payment_method')) {
806
+                if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
807 807
                     EE_Error::add_success(
808 808
                         apply_filters(
809 809
                             'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
810
-                            sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $payment_method->name() )
810
+                            sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $payment_method->name())
811 811
                         )
812 812
                     );
813 813
                 }
@@ -832,27 +832,27 @@  discard block
 block discarded – undo
832 832
 	 * @param string 		$request_param
833 833
 	 * @return NULL|string
834 834
 	 */
835
-	private function _get_selected_method_of_payment( $required = FALSE, $request_param = 'selected_method_of_payment' ) {
835
+	private function _get_selected_method_of_payment($required = FALSE, $request_param = 'selected_method_of_payment') {
836 836
 		// is selected_method_of_payment set in the request ?
837
-		$selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, FALSE );
838
-		if ( $selected_method_of_payment ) {
837
+		$selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, FALSE);
838
+		if ($selected_method_of_payment) {
839 839
 			// sanitize it
840
-			$selected_method_of_payment = is_array( $selected_method_of_payment ) ? array_shift( $selected_method_of_payment ) : $selected_method_of_payment;
841
-			$selected_method_of_payment = sanitize_text_field( $selected_method_of_payment );
840
+			$selected_method_of_payment = is_array($selected_method_of_payment) ? array_shift($selected_method_of_payment) : $selected_method_of_payment;
841
+			$selected_method_of_payment = sanitize_text_field($selected_method_of_payment);
842 842
 			// store it in the session so that it's available for all subsequent requests including AJAX
843
-			$this->_save_selected_method_of_payment( $selected_method_of_payment );
843
+			$this->_save_selected_method_of_payment($selected_method_of_payment);
844 844
 		} else {
845 845
 			// or is is set in the session ?
846
-			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( 'selected_method_of_payment' );
846
+			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data('selected_method_of_payment');
847 847
 		}
848 848
 		// do ya really really gotta have it?
849
-		if ( empty( $selected_method_of_payment ) && $required ) {
849
+		if (empty($selected_method_of_payment) && $required) {
850 850
 			EE_Error::add_error(
851 851
 				sprintf(
852
-					__( 'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso' ),
852
+					__('The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso'),
853 853
 					'<br/>',
854 854
 					'<br/>',
855
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
855
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
856 856
 				),
857 857
 				__FILE__, __FUNCTION__, __LINE__
858 858
 			);
@@ -878,37 +878,37 @@  discard block
 block discarded – undo
878 878
 	 * @return string
879 879
 	 */
880 880
 	public function switch_payment_method() {
881
-		if ( ! $this->_verify_payment_method_is_set() ) {
881
+		if ( ! $this->_verify_payment_method_is_set()) {
882 882
 			return false;
883 883
 		}
884
-		if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) {
884
+		if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
885 885
 			EE_Error::add_success(
886 886
 				apply_filters(
887 887
 					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
888
-					sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $this->checkout->payment_method->name() )
888
+					sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $this->checkout->payment_method->name())
889 889
 				)
890 890
 			);
891 891
 		}
892 892
 		// generate billing form for selected method of payment if it hasn't been done already
893
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
894
-			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
893
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
894
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
895 895
 		}
896 896
 		// fill form with attendee info if applicable
897
-		if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) {
898
-			$this->checkout->billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() );
897
+		if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) {
898
+			$this->checkout->billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee());
899 899
 		}
900 900
 		// and debug content
901
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) {
902
-			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $this->checkout->billing_form );
901
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) {
902
+			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($this->checkout->billing_form);
903 903
 		}
904 904
 		// get html and validation rules for form
905
-		if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) {
906
-			$this->checkout->json_response->set_return_data( array( 'payment_method_info' => $this->checkout->billing_form->get_html() ));
905
+		if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
906
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => $this->checkout->billing_form->get_html()));
907 907
 			// localize validation rules for main form
908
-			$this->checkout->billing_form->localize_validation_rules( TRUE );
909
-			$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
908
+			$this->checkout->billing_form->localize_validation_rules(TRUE);
909
+			$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
910 910
 		} else {
911
-			$this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ));
911
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
912 912
 		}
913 913
 		//prevents advancement to next step
914 914
 		$this->checkout->continue_reg = FALSE;
@@ -923,18 +923,18 @@  discard block
 block discarded – undo
923 923
 	 */
924 924
 	protected function _verify_payment_method_is_set() {
925 925
 		// generate billing form for selected method of payment if it hasn't been done already
926
-		if ( empty( $this->checkout->selected_method_of_payment )) {
926
+		if (empty($this->checkout->selected_method_of_payment)) {
927 927
 			// how have they chosen to pay?
928
-			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE );
928
+			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE);
929 929
 		} else {
930 930
 			// choose your own adventure based on method_of_payment
931
-			switch ( $this->checkout->selected_method_of_payment ) {
931
+			switch ($this->checkout->selected_method_of_payment) {
932 932
 				case 'events_sold_out' :
933 933
 					EE_Error::add_attention(
934 934
 						apply_filters(
935 935
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg',
936
-							__( 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.',
937
-								'event_espresso' )
936
+							__('It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.',
937
+								'event_espresso')
938 938
 						),
939 939
 						__FILE__, __FUNCTION__, __LINE__
940 940
 					);
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 					EE_Error::add_attention(
945 945
 						apply_filters(
946 946
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg',
947
-							__( 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso' )
947
+							__('It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso')
948 948
 						),
949 949
 						__FILE__, __FUNCTION__, __LINE__
950 950
 					);
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 					EE_Error::add_attention(
955 955
 						apply_filters(
956 956
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg',
957
-							__( 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso' )
957
+							__('It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso')
958 958
 						),
959 959
 						__FILE__, __FUNCTION__, __LINE__
960 960
 					);
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 			}
965 965
 		}
966 966
 		// verify payment method
967
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
967
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
968 968
 			// get payment method for selected method of payment
969 969
 			$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
970 970
 		}
@@ -984,23 +984,23 @@  discard block
 block discarded – undo
984 984
 	 * @return void
985 985
 	 */
986 986
 	public function save_payer_details_via_ajax() {
987
-		if ( ! $this->_verify_payment_method_is_set() ) {
987
+		if ( ! $this->_verify_payment_method_is_set()) {
988 988
 			return;
989 989
 		}
990 990
 		// generate billing form for selected method of payment if it hasn't been done already
991
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
992
-			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
991
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
992
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
993 993
 		}
994 994
 		// generate primary attendee from payer info if applicable
995 995
 		if ( ! $this->checkout->transaction_has_primary_registrant()) {
996 996
 			$attendee = $this->_create_attendee_from_request_data();
997
-			if ( $attendee instanceof EE_Attendee ) {
998
-				foreach ( $this->checkout->transaction->registrations() as $registration ) {
999
-					if ( $registration->is_primary_registrant() ) {
997
+			if ($attendee instanceof EE_Attendee) {
998
+				foreach ($this->checkout->transaction->registrations() as $registration) {
999
+					if ($registration->is_primary_registrant()) {
1000 1000
 						$this->checkout->primary_attendee_obj = $attendee;
1001
-						$registration->_add_relation_to( $attendee, 'Attendee' );
1002
-						$registration->set_attendee_id( $attendee->ID() );
1003
-						$registration->update_cache_after_object_save( 'Attendee', $attendee );
1001
+						$registration->_add_relation_to($attendee, 'Attendee');
1002
+						$registration->set_attendee_id($attendee->ID());
1003
+						$registration->update_cache_after_object_save('Attendee', $attendee);
1004 1004
 					}
1005 1005
 				}
1006 1006
 			}
@@ -1013,56 +1013,56 @@  discard block
 block discarded – undo
1013 1013
 	 * uses info from alternate GET or POST data (such as AJAX) to create a new attendee
1014 1014
 	 * @return \EE_Attendee
1015 1015
 	 */
1016
-	protected function _create_attendee_from_request_data(){
1016
+	protected function _create_attendee_from_request_data() {
1017 1017
 		// get State ID
1018
-		$STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : '';
1019
-		if ( ! empty( $STA_ID )) {
1018
+		$STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1019
+		if ( ! empty($STA_ID)) {
1020 1020
 			// can we get state object from name ?
1021
-			EE_Registry::instance()->load_model( 'State' );
1022
-			$state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1), 'STA_ID' );
1023
-			$STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID;
1021
+			EE_Registry::instance()->load_model('State');
1022
+			$state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
1023
+			$STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID;
1024 1024
 		}
1025 1025
 		// get Country ISO
1026
-		$CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : '';
1027
-		if ( ! empty( $CNT_ISO )) {
1026
+		$CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1027
+		if ( ! empty($CNT_ISO)) {
1028 1028
 			// can we get country object from name ?
1029
-			EE_Registry::instance()->load_model( 'Country' );
1030
-			$country = EEM_Country::instance()->get_col( array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1), 'CNT_ISO' );
1031
-			$CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO;
1029
+			EE_Registry::instance()->load_model('Country');
1030
+			$country = EEM_Country::instance()->get_col(array(array('CNT_name' => $CNT_ISO), 'limit' => 1), 'CNT_ISO');
1031
+			$CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO;
1032 1032
 		}
1033 1033
 		// grab attendee data
1034 1034
 		$attendee_data = array(
1035
-			'ATT_fname' 		=> ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '',
1036
-			'ATT_lname' 		=> ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '',
1037
-			'ATT_email' 		=> ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '',
1038
-			'ATT_address' 		=> ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '',
1039
-			'ATT_address2' 	=> ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '',
1040
-			'ATT_city' 			=> ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '',
1035
+			'ATT_fname' 		=> ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '',
1036
+			'ATT_lname' 		=> ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '',
1037
+			'ATT_email' 		=> ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '',
1038
+			'ATT_address' 		=> ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '',
1039
+			'ATT_address2' 	=> ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '',
1040
+			'ATT_city' 			=> ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '',
1041 1041
 			'STA_ID' 				=> $STA_ID,
1042 1042
 			'CNT_ISO' 			=> $CNT_ISO,
1043
-			'ATT_zip' 				=> ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '',
1044
-			'ATT_phone' 		=> ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '',
1043
+			'ATT_zip' 				=> ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '',
1044
+			'ATT_phone' 		=> ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '',
1045 1045
 		);
1046 1046
 		// validate the email address since it is the most important piece of info
1047
-		if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] != $_REQUEST['email'] ) {
1048
-			EE_Error::add_error( __( 'An invalid email address was submitted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1047
+		if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] != $_REQUEST['email']) {
1048
+			EE_Error::add_error(__('An invalid email address was submitted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1049 1049
 		}
1050 1050
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1051
-		if ( ! empty( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_email'] ) ) {
1052
-			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array(
1051
+		if ( ! empty($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_email'])) {
1052
+			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array(
1053 1053
 				'ATT_fname' => $attendee_data['ATT_fname'],
1054 1054
 				'ATT_lname' => $attendee_data['ATT_lname'],
1055 1055
 				'ATT_email' => $attendee_data['ATT_email']
1056 1056
 			));
1057
-			if ( $existing_attendee instanceof EE_Attendee ) {
1057
+			if ($existing_attendee instanceof EE_Attendee) {
1058 1058
 				return $existing_attendee;
1059 1059
 			}
1060 1060
 		}
1061 1061
 		// no existing attendee? kk let's create a new one
1062 1062
 		// kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist
1063
-		$attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email'];
1064
-		$attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email'];
1065
-		return EE_Attendee::new_instance( $attendee_data );
1063
+		$attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email'];
1064
+		$attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email'];
1065
+		return EE_Attendee::new_instance($attendee_data);
1066 1066
 	}
1067 1067
 
1068 1068
 
@@ -1082,22 +1082,22 @@  discard block
 block discarded – undo
1082 1082
 	 */
1083 1083
 	public function process_reg_step() {
1084 1084
 		// how have they chosen to pay?
1085
-		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment( TRUE );
1085
+		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment(TRUE);
1086 1086
 		// choose your own adventure based on method_of_payment
1087
-		switch(  $this->checkout->selected_method_of_payment ) {
1087
+		switch ($this->checkout->selected_method_of_payment) {
1088 1088
 
1089 1089
 			case 'events_sold_out' :
1090 1090
 				$this->checkout->redirect = TRUE;
1091 1091
 				$this->checkout->redirect_url = $this->checkout->cancel_page_url;
1092
-				$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1092
+				$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1093 1093
 				// mark this reg step as completed
1094 1094
 				$this->set_completed();
1095 1095
 				return FALSE;
1096 1096
 				break;
1097 1097
 
1098 1098
 			case 'payments_closed' :
1099
-				if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false ) ) {
1100
-					EE_Error::add_success( __( 'no payment required at this time.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1099
+				if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false)) {
1100
+					EE_Error::add_success(__('no payment required at this time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1101 1101
 				}
1102 1102
 				// mark this reg step as completed
1103 1103
 				$this->set_completed();
@@ -1105,8 +1105,8 @@  discard block
 block discarded – undo
1105 1105
 				break;
1106 1106
 
1107 1107
 			case 'no_payment_required' :
1108
-				if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false ) ) {
1109
-					EE_Error::add_success( __( 'no payment required.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1108
+				if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false)) {
1109
+					EE_Error::add_success(__('no payment required.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1110 1110
 				}
1111 1111
 				// mark this reg step as completed
1112 1112
 				$this->set_completed();
@@ -1115,9 +1115,9 @@  discard block
 block discarded – undo
1115 1115
 
1116 1116
 			default:
1117 1117
 				$payment_successful = $this->_process_payment();
1118
-				if ( $payment_successful ) {
1118
+				if ($payment_successful) {
1119 1119
 					$this->checkout->continue_reg = true;
1120
-					$this->_maybe_set_completed( $this->checkout->payment_method );
1120
+					$this->_maybe_set_completed($this->checkout->payment_method);
1121 1121
 				} else {
1122 1122
 					$this->checkout->continue_reg = false;
1123 1123
 				}
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 * @param \EE_Payment_Method $payment_method
1136 1136
 	 * @return void
1137 1137
 	 */
1138
-	protected function _maybe_set_completed( EE_Payment_Method $payment_method ) {
1139
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
1138
+	protected function _maybe_set_completed(EE_Payment_Method $payment_method) {
1139
+		switch ($payment_method->type_obj()->payment_occurs()) {
1140 1140
 			case EE_PMT_Base::offsite :
1141 1141
 				break;
1142 1142
 			case EE_PMT_Base::onsite :
@@ -1159,15 +1159,15 @@  discard block
 block discarded – undo
1159 1159
 	public function update_reg_step() {
1160 1160
 		$success = TRUE;
1161 1161
 		// if payment required
1162
-		if ( $this->checkout->transaction->total() > 0 ) {
1163
-			do_action ('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction );
1162
+		if ($this->checkout->transaction->total() > 0) {
1163
+			do_action('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction);
1164 1164
 			// attempt payment via payment method
1165 1165
 			$success = $this->process_reg_step();
1166 1166
 		}
1167
-		if ( $success && ! $this->checkout->redirect ) {
1168
-			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $this->checkout->transaction->ID() );
1167
+		if ($success && ! $this->checkout->redirect) {
1168
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($this->checkout->transaction->ID());
1169 1169
 			 // set return URL
1170
-			$this->checkout->redirect_url = add_query_arg( array( 'e_reg_url_link' => $this->checkout->reg_url_link ), $this->checkout->thank_you_page_url );
1170
+			$this->checkout->redirect_url = add_query_arg(array('e_reg_url_link' => $this->checkout->reg_url_link), $this->checkout->thank_you_page_url);
1171 1171
 		}
1172 1172
 		return $success;
1173 1173
 	}
@@ -1185,32 +1185,32 @@  discard block
 block discarded – undo
1185 1185
 	 */
1186 1186
 	private function _process_payment() {
1187 1187
 		// basically confirm that the event hasn't sold out since they hit the page
1188
-		if ( ! $this->_last_second_ticket_verifications() ) {
1188
+		if ( ! $this->_last_second_ticket_verifications()) {
1189 1189
 			return false;
1190 1190
 		}
1191 1191
 		// ya gotta make a choice man
1192
-		if ( empty( $this->checkout->selected_method_of_payment )) {
1193
-			$this->checkout->json_response->set_plz_select_method_of_payment( __( 'Please select a method of payment before proceeding.', 'event_espresso' ));
1192
+		if (empty($this->checkout->selected_method_of_payment)) {
1193
+			$this->checkout->json_response->set_plz_select_method_of_payment(__('Please select a method of payment before proceeding.', 'event_espresso'));
1194 1194
 			return FALSE;
1195 1195
 		}
1196 1196
 		// get EE_Payment_Method object
1197
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
1197
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1198 1198
 			return FALSE;
1199 1199
 		}
1200 1200
 		// setup billing form
1201
-		if ( $this->checkout->payment_method->is_on_site() ) {
1202
-			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
1201
+		if ($this->checkout->payment_method->is_on_site()) {
1202
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
1203 1203
 			// bad billing form ?
1204
-			if ( ! $this->_billing_form_is_valid() ) {
1204
+			if ( ! $this->_billing_form_is_valid()) {
1205 1205
 				return FALSE;
1206 1206
 			}
1207 1207
 		}
1208 1208
 		// ensure primary registrant has been fully processed
1209
-		if ( ! $this->_setup_primary_registrant_prior_to_payment() ) {
1209
+		if ( ! $this->_setup_primary_registrant_prior_to_payment()) {
1210 1210
 			return FALSE;
1211 1211
 		}
1212 1212
 		// if session is close to expiring (under 10 minutes by default)
1213
-		if ( ( time() - EE_Registry::instance()->SSN->expiration() ) < EE_Registry::instance()->SSN->extension() ) {
1213
+		if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) {
1214 1214
 			// add some time to session expiration so that payment can be completed
1215 1215
 			EE_Registry::instance()->SSN->extend_expiration();
1216 1216
 		}
@@ -1219,24 +1219,24 @@  discard block
 block discarded – undo
1219 1219
 		// in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved
1220 1220
 		//$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params );
1221 1221
 		// attempt payment
1222
-		$payment = $this->_attempt_payment( $this->checkout->payment_method );
1222
+		$payment = $this->_attempt_payment($this->checkout->payment_method);
1223 1223
 		// process results
1224
-		$payment = $this->_validate_payment( $payment );
1225
-		$payment = $this->_post_payment_processing( $payment );
1224
+		$payment = $this->_validate_payment($payment);
1225
+		$payment = $this->_post_payment_processing($payment);
1226 1226
 		// verify payment
1227
-		if ( $payment instanceof EE_Payment ) {
1227
+		if ($payment instanceof EE_Payment) {
1228 1228
 			// store that for later
1229 1229
 			$this->checkout->payment = $payment;
1230 1230
 			/** @type EE_Transaction_Processor $transaction_processor */
1231
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1231
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1232 1232
 			// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1233
-			$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
1234
-			if ( $payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending ) {
1233
+			$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
1234
+			if ($payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending) {
1235 1235
 				return true;
1236 1236
 			} else {
1237 1237
 				return false;
1238 1238
 			}
1239
-		} else if ( $payment === true ) {
1239
+		} else if ($payment === true) {
1240 1240
 			// please note that offline payment methods will NOT make a payment,
1241 1241
 			// but instead just mark themselves as the PMD_ID on the transaction, and return true
1242 1242
 			$this->checkout->payment = $payment;
@@ -1256,22 +1256,22 @@  discard block
 block discarded – undo
1256 1256
 	 */
1257 1257
 	protected function _last_second_ticket_verifications() {
1258 1258
 		// don't bother re-validating if not a return visit
1259
-		if ( ! $this->checkout->revisit ) {
1259
+		if ( ! $this->checkout->revisit) {
1260 1260
 			return true;
1261 1261
 		}
1262 1262
 		$registrations = $this->checkout->transaction->registrations();
1263
-		if ( empty( $registrations ) ) {
1263
+		if (empty($registrations)) {
1264 1264
 			return false;
1265 1265
 		}
1266
-		foreach ( $registrations as $registration ) {
1267
-			if ( $registration instanceof EE_Registration ) {
1266
+		foreach ($registrations as $registration) {
1267
+			if ($registration instanceof EE_Registration) {
1268 1268
 				$event = $registration->event_obj();
1269
-				if ( ! ( $event instanceof EE_Event && $event->is_sold_out( true ) ) ) {
1269
+				if ( ! ($event instanceof EE_Event && $event->is_sold_out(true))) {
1270 1270
 					EE_Error::add_error(
1271 1271
 						apply_filters(
1272 1272
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg',
1273 1273
 							sprintf(
1274
-								__( 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ),
1274
+								__('It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso'),
1275 1275
 								$event->name()
1276 1276
 							)
1277 1277
 						),
@@ -1295,10 +1295,10 @@  discard block
 block discarded – undo
1295 1295
 	 * @return bool
1296 1296
 	 */
1297 1297
 	public function redirect_form() {
1298
-		$payment_method_billing_info = $this->_payment_method_billing_info( $this->_get_payment_method_for_selected_method_of_payment() );
1298
+		$payment_method_billing_info = $this->_payment_method_billing_info($this->_get_payment_method_for_selected_method_of_payment());
1299 1299
 		$html = $payment_method_billing_info->get_html_and_js();
1300 1300
 		$html .= $this->checkout->redirect_form;
1301
-		EE_Registry::instance()->REQ->add_output( $html );
1301
+		EE_Registry::instance()->REQ->add_output($html);
1302 1302
 		return TRUE;
1303 1303
 	}
1304 1304
 
@@ -1311,36 +1311,36 @@  discard block
 block discarded – undo
1311 1311
 	 * @return bool
1312 1312
 	 */
1313 1313
 	private function _billing_form_is_valid() {
1314
-		if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1314
+		if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1315 1315
 			return TRUE;
1316 1316
 		}
1317
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) {
1318
-			if ( $this->checkout->billing_form->was_submitted() ) {
1317
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
1318
+			if ($this->checkout->billing_form->was_submitted()) {
1319 1319
 				$this->checkout->billing_form->receive_form_submission();
1320
-				if ( $this->checkout->billing_form->is_valid() ) {
1320
+				if ($this->checkout->billing_form->is_valid()) {
1321 1321
 					return TRUE;
1322 1322
 				}
1323 1323
 				$validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated();
1324 1324
 				$error_strings = array();
1325
-				foreach( $validation_errors as $validation_error ){
1326
-					if( $validation_error instanceof EE_Validation_Error ){
1325
+				foreach ($validation_errors as $validation_error) {
1326
+					if ($validation_error instanceof EE_Validation_Error) {
1327 1327
 						$form_section = $validation_error->get_form_section();
1328
-						if( $form_section instanceof EE_Form_Input_Base ){
1328
+						if ($form_section instanceof EE_Form_Input_Base) {
1329 1329
 							$label = $form_section->html_label_text();
1330
-						}elseif( $form_section instanceof EE_Form_Section_Base ){
1330
+						}elseif ($form_section instanceof EE_Form_Section_Base) {
1331 1331
 							$label = $form_section->name();
1332
-						}else{
1333
-							$label = __( 'Validation Error', 'event_espresso' );
1332
+						} else {
1333
+							$label = __('Validation Error', 'event_espresso');
1334 1334
 						}
1335
-						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage() );
1335
+						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage());
1336 1336
 					}
1337 1337
 				}
1338
-				EE_Error::add_error( sprintf( __( 'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso' ), '<br/>', implode( '<br/>', $error_strings )  ), __FILE__, __FUNCTION__, __LINE__ );
1338
+				EE_Error::add_error(sprintf(__('One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso'), '<br/>', implode('<br/>', $error_strings)), __FILE__, __FUNCTION__, __LINE__);
1339 1339
 			} else {
1340
-				EE_Error::add_error( __( 'The billing form was not submitted or something prevented it\'s submission.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1340
+				EE_Error::add_error(__('The billing form was not submitted or something prevented it\'s submission.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1341 1341
 			}
1342 1342
 		} else {
1343
-			EE_Error::add_error( __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1343
+			EE_Error::add_error(__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1344 1344
 		}
1345 1345
 		return FALSE;
1346 1346
 	}
@@ -1358,9 +1358,9 @@  discard block
 block discarded – undo
1358 1358
 	 */
1359 1359
 		private function _setup_primary_registrant_prior_to_payment() {
1360 1360
 			// check if transaction has a primary registrant and that it has a related Attendee object
1361
-			if ( ! $this->checkout->transaction_has_primary_registrant() ) {
1361
+			if ( ! $this->checkout->transaction_has_primary_registrant()) {
1362 1362
 				// need to at least gather some primary registrant data before attempting payment
1363
-				if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form() ) {
1363
+				if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form()) {
1364 1364
 					return FALSE;
1365 1365
 				}
1366 1366
 			}
@@ -1368,13 +1368,13 @@  discard block
 block discarded – undo
1368 1368
 			// grab the primary_registration object
1369 1369
 			$primary_registration = $this->checkout->transaction->primary_registration();
1370 1370
 			/** @type EE_Transaction_Processor $transaction_processor */
1371
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1371
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1372 1372
 			// at this point we'll consider a TXN to not have been failed
1373
-			$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
1373
+			$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
1374 1374
 			// save the TXN ( which clears cached copy of primary_registration)
1375 1375
 			$this->checkout->transaction->save();
1376 1376
 			// grab TXN ID and save it to the primary_registration
1377
-			$primary_registration->set_transaction_id( $this->checkout->transaction->ID() );
1377
+			$primary_registration->set_transaction_id($this->checkout->transaction->ID());
1378 1378
 			// save what we have so far
1379 1379
 			$primary_registration->save();
1380 1380
 			return TRUE;
@@ -1391,41 +1391,41 @@  discard block
 block discarded – undo
1391 1391
 		private function _capture_primary_registration_data_from_billing_form() {
1392 1392
 			// convert billing form data into an attendee
1393 1393
 			$this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
1394
-			if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) {
1394
+			if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
1395 1395
 				EE_Error::add_error(
1396 1396
 					sprintf(
1397
-						__( 'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1397
+						__('The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1398 1398
 						'<br/>',
1399
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1399
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1400 1400
 					), __FILE__, __FUNCTION__, __LINE__
1401 1401
 				);
1402 1402
 				return FALSE;
1403 1403
 			}
1404 1404
 			$primary_registration = $this->checkout->transaction->primary_registration();
1405
-			if ( ! $primary_registration instanceof EE_Registration ) {
1405
+			if ( ! $primary_registration instanceof EE_Registration) {
1406 1406
 				EE_Error::add_error(
1407 1407
 					sprintf(
1408
-						__( 'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1408
+						__('The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1409 1409
 						'<br/>',
1410
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1410
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1411 1411
 					), __FILE__, __FUNCTION__, __LINE__
1412 1412
 				);
1413 1413
 				return FALSE;
1414 1414
 			}
1415
-			if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) instanceof EE_Attendee ) {
1415
+			if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') instanceof EE_Attendee) {
1416 1416
 				EE_Error::add_error(
1417 1417
 					sprintf(
1418
-						__( 'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1418
+						__('The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1419 1419
 						'<br/>',
1420
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1420
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1421 1421
 					), __FILE__, __FUNCTION__, __LINE__
1422 1422
 				);
1423 1423
 				return FALSE;
1424 1424
 			}
1425 1425
 			/** @type EE_Registration_Processor $registration_processor */
1426
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1426
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1427 1427
 			// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1428
-			$registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration );
1428
+			$registration_processor->toggle_incomplete_registration_status_to_default($primary_registration);
1429 1429
 
1430 1430
 			return TRUE;
1431 1431
 		}
@@ -1441,35 +1441,35 @@  discard block
 block discarded – undo
1441 1441
 	 */
1442 1442
 		private function _get_payment_method_for_selected_method_of_payment() {
1443 1443
 			// get EE_Payment_Method object
1444
-			if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] )) {
1445
-				$payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
1444
+			if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) {
1445
+				$payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment];
1446 1446
 			} else {
1447 1447
 				// load EEM_Payment_Method
1448
-				EE_Registry::instance()->load_model( 'Payment_Method' );
1448
+				EE_Registry::instance()->load_model('Payment_Method');
1449 1449
 				/** @type EEM_Payment_Method $EEM_Payment_Method */
1450 1450
 				$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
1451
-				$payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment );
1451
+				$payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
1452 1452
 			}
1453 1453
 			// verify $payment_method
1454
-			if ( ! $payment_method instanceof EE_Payment_Method ) {
1454
+			if ( ! $payment_method instanceof EE_Payment_Method) {
1455 1455
 				// not a payment
1456 1456
 				EE_Error::add_error(
1457 1457
 					sprintf(
1458
-						__( 'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1458
+						__('The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1459 1459
 						'<br/>',
1460
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1460
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1461 1461
 					), __FILE__, __FUNCTION__, __LINE__
1462 1462
 				);
1463 1463
 				return NULL;
1464 1464
 			}
1465 1465
 			// and verify it has a valid Payment_Method Type object
1466
-			if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) {
1466
+			if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) {
1467 1467
 				// not a payment
1468 1468
 				EE_Error::add_error(
1469 1469
 					sprintf(
1470
-						__( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1470
+						__('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1471 1471
 						'<br/>',
1472
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1472
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1473 1473
 					), __FILE__, __FUNCTION__, __LINE__
1474 1474
 				);
1475 1475
 				return NULL;
@@ -1488,30 +1488,30 @@  discard block
 block discarded – undo
1488 1488
 	 * 	@type 	EE_Payment_Method $payment_method
1489 1489
 	 * 	@return 	mixed	EE_Payment | boolean
1490 1490
 	 */
1491
-	private function _attempt_payment( EE_Payment_Method $payment_method ) {
1492
-		$payment =NULL;
1491
+	private function _attempt_payment(EE_Payment_Method $payment_method) {
1492
+		$payment = NULL;
1493 1493
 		$this->checkout->transaction->save();
1494
-		$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1495
-		if ( ! $payment_processor instanceof EE_Payment_Processor ) {
1494
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1495
+		if ( ! $payment_processor instanceof EE_Payment_Processor) {
1496 1496
 			return FALSE;
1497 1497
 		}
1498 1498
 		try {
1499
-			$payment_processor->set_revisit( $this->checkout->revisit );
1499
+			$payment_processor->set_revisit($this->checkout->revisit);
1500 1500
 			// generate payment object
1501 1501
 			$payment = $payment_processor->process_payment(
1502 1502
 				$payment_method,
1503 1503
 				$this->checkout->transaction,
1504 1504
 				$this->checkout->amount_owing,
1505 1505
 				$this->checkout->billing_form,
1506
-				$this->_get_return_url( $payment_method ),
1506
+				$this->_get_return_url($payment_method),
1507 1507
 				'CART',
1508 1508
 				$this->checkout->admin_request,
1509 1509
 				TRUE,
1510 1510
 				$this->reg_step_url()
1511 1511
 			);
1512 1512
 
1513
-		} catch( Exception $e ) {
1514
-			$this->_handle_payment_processor_exception( $e );
1513
+		} catch (Exception $e) {
1514
+			$this->_handle_payment_processor_exception($e);
1515 1515
 		}
1516 1516
 		return $payment;
1517 1517
 	}
@@ -1525,12 +1525,12 @@  discard block
 block discarded – undo
1525 1525
 	 * @param \Exception $e
1526 1526
 	 * @return void
1527 1527
 	 */
1528
-	protected function _handle_payment_processor_exception( Exception $e ) {
1528
+	protected function _handle_payment_processor_exception(Exception $e) {
1529 1529
 		EE_Error::add_error(
1530 1530
 			sprintf(
1531
-				__( 'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso' ),
1531
+				__('The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso'),
1532 1532
 				'<br/>',
1533
-				EE_Registry::instance()->CFG->organization->get_pretty( 'email' ),
1533
+				EE_Registry::instance()->CFG->organization->get_pretty('email'),
1534 1534
 				$e->getMessage(),
1535 1535
 				$e->getFile(),
1536 1536
 				$e->getLine()
@@ -1547,9 +1547,9 @@  discard block
 block discarded – undo
1547 1547
 	 * @param \EE_Payment_Method $payment_method
1548 1548
 	 * @return string
1549 1549
 	 */
1550
-	protected function _get_return_url( EE_Payment_Method $payment_method ) {
1550
+	protected function _get_return_url(EE_Payment_Method $payment_method) {
1551 1551
 		$return_url = '';
1552
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
1552
+		switch ($payment_method->type_obj()->payment_occurs()) {
1553 1553
 
1554 1554
 			case EE_PMT_Base::offsite :
1555 1555
 				$return_url = add_query_arg(
@@ -1580,27 +1580,27 @@  discard block
 block discarded – undo
1580 1580
 	 * @param EE_Payment $payment
1581 1581
 	 * @return EE_Payment | FALSE
1582 1582
 	 */
1583
-	private function _validate_payment( $payment = NULL ) {
1584
-		if (  $this->checkout->payment_method->is_off_line() ) {
1583
+	private function _validate_payment($payment = NULL) {
1584
+		if ($this->checkout->payment_method->is_off_line()) {
1585 1585
 			return TRUE;
1586 1586
 		}
1587 1587
 		// verify payment object
1588
-		if ( $payment instanceof EE_Payment ) {
1588
+		if ($payment instanceof EE_Payment) {
1589 1589
 			if (
1590 1590
 				$payment->status() != EEM_Payment::status_id_approved
1591 1591
 				&& $payment->status() != EEM_Payment::status_id_pending
1592 1592
 				&& $payment->status() != EEM_Payment::status_id_cancelled
1593 1593
 				&& $payment->gateway_response() != ''
1594 1594
 			) {
1595
-				EE_Error::add_error( $payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__ );
1595
+				EE_Error::add_error($payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__);
1596 1596
 			}
1597 1597
 		} else {
1598 1598
 			// not a payment
1599 1599
 			EE_Error::add_error(
1600 1600
 				sprintf(
1601
-					__( 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ),
1601
+					__('A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'),
1602 1602
 					'<br/>',
1603
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1603
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1604 1604
 				), __FILE__, __FUNCTION__, __LINE__
1605 1605
 			);
1606 1606
 			return FALSE;
@@ -1617,23 +1617,23 @@  discard block
 block discarded – undo
1617 1617
 	 * @param EE_Payment $payment
1618 1618
 	 * @return bool
1619 1619
 	 */
1620
-	private function _post_payment_processing( $payment = NULL ) {
1620
+	private function _post_payment_processing($payment = NULL) {
1621 1621
 		// On-Site payment?
1622
-		if ( $this->checkout->payment_method->is_on_site() ) {
1623
-			if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite )) {
1622
+		if ($this->checkout->payment_method->is_on_site()) {
1623
+			if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
1624 1624
 				//$this->_setup_redirect_for_next_step();
1625 1625
 				$this->checkout->continue_reg = false;
1626 1626
 			}
1627 1627
 			// Off-Site payment?
1628
-		} else if ( $this->checkout->payment_method->is_off_site() ) {
1628
+		} else if ($this->checkout->payment_method->is_off_site()) {
1629 1629
 			// if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
1630
-			if ( $payment instanceof EE_Payment && $payment->redirect_url() ){
1631
-				do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' );
1630
+			if ($payment instanceof EE_Payment && $payment->redirect_url()) {
1631
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
1632 1632
 				$this->checkout->redirect = TRUE;
1633 1633
 				$this->checkout->redirect_form = $payment->redirect_form();
1634
-				$this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' );
1634
+				$this->checkout->redirect_url = $this->reg_step_url('redirect_form');
1635 1635
 				// set JSON response
1636
-				$this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form );
1636
+				$this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
1637 1637
 				// set cron job for finalizing the TXN
1638 1638
 				// in case the user does not return from the off-site gateway
1639 1639
 				EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
@@ -1641,21 +1641,21 @@  discard block
 block discarded – undo
1641 1641
 					$this->checkout->transaction->ID()
1642 1642
 				);
1643 1643
 				// and lastly, let's bump the payment status to pending
1644
-				$payment->set_status( EEM_Payment::status_id_pending );
1644
+				$payment->set_status(EEM_Payment::status_id_pending);
1645 1645
 				$payment->save();
1646 1646
 			} else {
1647 1647
 				// not a payment
1648 1648
 				$this->checkout->continue_reg = false;
1649 1649
 				EE_Error::add_error(
1650 1650
 					sprintf(
1651
-						__( 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1651
+						__('It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1652 1652
 						'<br/>',
1653
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1653
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1654 1654
 					), __FILE__, __FUNCTION__, __LINE__
1655 1655
 				);
1656 1656
 			}
1657 1657
 			// Off-Line payment?
1658
-		} else if ( $payment === TRUE ) {
1658
+		} else if ($payment === TRUE) {
1659 1659
 			//$this->_setup_redirect_for_next_step();
1660 1660
 			return TRUE;
1661 1661
 		} else {
@@ -1691,65 +1691,65 @@  discard block
 block discarded – undo
1691 1691
 	 * @return bool
1692 1692
 	 * @throws \EE_Error
1693 1693
 	 */
1694
-	private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) {
1694
+	private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) {
1695 1695
 		// off-line payment? carry on
1696
-		if ( $payment_occurs == EE_PMT_Base::offline ) {
1696
+		if ($payment_occurs == EE_PMT_Base::offline) {
1697 1697
 			return true;
1698 1698
 		}
1699 1699
 		// verify payment validity
1700
-		if ( $payment instanceof EE_Payment ) {
1701
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' );
1700
+		if ($payment instanceof EE_Payment) {
1701
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
1702 1702
 			$msg = $payment->gateway_response();
1703 1703
 			// check results
1704
-			switch ( $payment->status() ) {
1704
+			switch ($payment->status()) {
1705 1705
 
1706 1706
 				// good payment
1707 1707
 				case EEM_Payment::status_id_approved :
1708
-					EE_Error::add_success( __( 'Your payment was processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1708
+					EE_Error::add_success(__('Your payment was processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1709 1709
 					return TRUE;
1710 1710
 					break;
1711 1711
 
1712 1712
 				// slow payment
1713 1713
 				case EEM_Payment::status_id_pending :
1714
-					if ( empty( $msg )) {
1715
-						$msg = __( 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso' );
1714
+					if (empty($msg)) {
1715
+						$msg = __('Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso');
1716 1716
 					}
1717
-					EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ );
1717
+					EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
1718 1718
 					return TRUE;
1719 1719
 					break;
1720 1720
 
1721 1721
 				// don't wanna payment
1722 1722
 				case EEM_Payment::status_id_cancelled :
1723
-					if ( empty( $msg )) {
1723
+					if (empty($msg)) {
1724 1724
 						$msg = _n(
1725 1725
 							'Payment cancelled. Please try again.',
1726 1726
 							'Payment cancelled. Please try again or select another method of payment.',
1727
-							count( $this->checkout->available_payment_methods ),
1727
+							count($this->checkout->available_payment_methods),
1728 1728
 							'event_espresso'
1729 1729
 						);
1730 1730
 					}
1731
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
1731
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
1732 1732
 					return FALSE;
1733 1733
 					break;
1734 1734
 
1735 1735
 				// not enough payment
1736 1736
 				case EEM_Payment::status_id_declined :
1737
-					if ( empty( $msg )) {
1737
+					if (empty($msg)) {
1738 1738
 						$msg = _n(
1739 1739
 							'We\'re sorry but your payment was declined. Please try again.',
1740 1740
 							'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
1741
-							count( $this->checkout->available_payment_methods ),
1741
+							count($this->checkout->available_payment_methods),
1742 1742
 							'event_espresso'
1743 1743
 						);
1744 1744
 					}
1745
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
1745
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
1746 1746
 					return FALSE;
1747 1747
 					break;
1748 1748
 
1749 1749
 				// bad payment
1750 1750
 				case EEM_Payment::status_id_failed :
1751
-					if ( ! empty( $msg ) ) {
1752
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1751
+					if ( ! empty($msg)) {
1752
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1753 1753
 						return false;
1754 1754
 					}
1755 1755
 					// default to error below
@@ -1759,14 +1759,14 @@  discard block
 block discarded – undo
1759 1759
 		}
1760 1760
 		// off-site payment gateway responses are too unreliable, so let's just assume that
1761 1761
 		// the payment processing is just running slower than the registrant's request
1762
-		if ( $payment_occurs == EE_PMT_Base::offsite ) {
1762
+		if ($payment_occurs == EE_PMT_Base::offsite) {
1763 1763
 			return true;
1764 1764
 		}
1765 1765
 		EE_Error::add_error(
1766 1766
 				sprintf(
1767
-					__( 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1767
+					__('Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1768 1768
 					'<br/>',
1769
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1769
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1770 1770
 				),
1771 1771
 				__FILE__, __FUNCTION__, __LINE__
1772 1772
 			);
@@ -1799,13 +1799,13 @@  discard block
 block discarded – undo
1799 1799
 	public function process_gateway_response() {
1800 1800
 		$payment = null;
1801 1801
 		// how have they chosen to pay?
1802
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
1802
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1803 1803
 		// get EE_Payment_Method object
1804
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
1804
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1805 1805
 			$this->checkout->continue_reg = false;
1806 1806
 			return false;
1807 1807
 		}
1808
-		if ( ! $this->checkout->payment_method->is_off_site() ) {
1808
+		if ( ! $this->checkout->payment_method->is_off_site()) {
1809 1809
 			return false;
1810 1810
 		}
1811 1811
 		$this->_validate_offsite_return();
@@ -1819,23 +1819,23 @@  discard block
 block discarded – undo
1819 1819
 		//	true
1820 1820
 		//);
1821 1821
 		// verify TXN
1822
-		if ( $this->checkout->transaction instanceof EE_Transaction ) {
1822
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1823 1823
 			$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
1824
-			if ( ! $gateway instanceof EE_Offsite_Gateway ) {
1824
+			if ( ! $gateway instanceof EE_Offsite_Gateway) {
1825 1825
 				$this->checkout->continue_reg = false;
1826 1826
 				return false;
1827 1827
 			}
1828
-			$payment = $this->_process_off_site_payment( $gateway );
1829
-			$payment = $this->_process_cancelled_payments( $payment );
1830
-			$payment = $this->_validate_payment( $payment );
1828
+			$payment = $this->_process_off_site_payment($gateway);
1829
+			$payment = $this->_process_cancelled_payments($payment);
1830
+			$payment = $this->_validate_payment($payment);
1831 1831
 			// if payment was not declined by the payment gateway or cancelled by the registrant
1832
-			if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) {
1832
+			if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
1833 1833
 				//$this->_setup_redirect_for_next_step();
1834 1834
 				// store that for later
1835 1835
 				$this->checkout->payment = $payment;
1836 1836
 				// mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
1837 1837
 				// because we will complete this step during the IPN processing then
1838
-				if ( $gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request() ) {
1838
+				if ($gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request()) {
1839 1839
 					$this->set_completed();
1840 1840
 				}
1841 1841
 				return true;
@@ -1858,19 +1858,19 @@  discard block
 block discarded – undo
1858 1858
 	 * @return bool
1859 1859
 	 */
1860 1860
 	private function _validate_offsite_return() {
1861
-		$TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 );
1862
-		if ( $TXN_ID != $this->checkout->transaction->ID() ) {
1861
+		$TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
1862
+		if ($TXN_ID != $this->checkout->transaction->ID()) {
1863 1863
 			// Houston... we might have a problem
1864 1864
 			$invalid_TXN = false;
1865 1865
 			// first gather some info
1866
-			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
1866
+			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1867 1867
 			$primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null;
1868 1868
 			// let's start by retrieving the cart for this TXN
1869
-			$cart = EE_Cart::get_cart_from_txn( $this->checkout->transaction );
1870
-			if ( $cart instanceof EE_Cart ) {
1869
+			$cart = EE_Cart::get_cart_from_txn($this->checkout->transaction);
1870
+			if ($cart instanceof EE_Cart) {
1871 1871
 				// verify that the current cart has tickets
1872 1872
 				$tickets = $cart->get_tickets();
1873
-				if ( empty( $tickets ) ) {
1873
+				if (empty($tickets)) {
1874 1874
 					$invalid_TXN = true;
1875 1875
 				}
1876 1876
 			} else {
@@ -1878,39 +1878,39 @@  discard block
 block discarded – undo
1878 1878
 			}
1879 1879
 			$valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null;
1880 1880
 			// validate current Session ID and compare against valid TXN session ID
1881
-			if ( EE_Session::instance()->id() === null ) {
1881
+			if (EE_Session::instance()->id() === null) {
1882 1882
 				$invalid_TXN = true;
1883
-			} else if ( EE_Session::instance()->id() === $valid_TXN_SID ) {
1883
+			} else if (EE_Session::instance()->id() === $valid_TXN_SID) {
1884 1884
 				// WARNING !!!
1885 1885
 				// this could be PayPal sending back duplicate requests (ya they do that)
1886 1886
 				// or it **could** mean someone is simply registering AGAIN after having just done so
1887 1887
 				// so now we need to determine if this current TXN looks valid or not
1888 1888
 				/** @type EE_Transaction_Processor $transaction_processor */
1889
-				$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1889
+				$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1890 1890
 				// has this step even been started ?
1891
-				if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false )
1891
+				if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false)
1892 1892
 				) {
1893 1893
 					// really? you're half way through this reg step, but you never started it ?
1894 1894
 					$invalid_TXN = true;
1895 1895
 				}
1896 1896
 			}
1897
-			if ( $invalid_TXN ) {
1897
+			if ($invalid_TXN) {
1898 1898
 				// is the valid TXN completed ?
1899
-				if ( $valid_TXN instanceof EE_Transaction ) {
1899
+				if ($valid_TXN instanceof EE_Transaction) {
1900 1900
 					/** @type EE_Transaction_Processor $transaction_processor */
1901
-					$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1901
+					$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1902 1902
 					// has this step even been started ?
1903
-					$reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() );
1904
-					if ( $reg_step_completed !== false && $reg_step_completed !== true ) {
1903
+					$reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug());
1904
+					if ($reg_step_completed !== false && $reg_step_completed !== true) {
1905 1905
 						// so it **looks** like this is a double request from PayPal
1906 1906
 						// so let's try to pick up where we left off
1907 1907
 						$this->checkout->transaction = $valid_TXN;
1908
-						$this->checkout->refresh_all_entities( true );
1908
+						$this->checkout->refresh_all_entities(true);
1909 1909
 						return;
1910 1910
 					}
1911 1911
 				}
1912 1912
 				// you appear to be lost?
1913
-				$this->_redirect_wayward_request( $primary_registrant );
1913
+				$this->_redirect_wayward_request($primary_registrant);
1914 1914
 			}
1915 1915
 		}
1916 1916
 	}
@@ -1924,16 +1924,16 @@  discard block
 block discarded – undo
1924 1924
 	 * @param \EE_Registration $primary_registrant
1925 1925
 	 * @return bool
1926 1926
 	 */
1927
-	private function _redirect_wayward_request( EE_Registration $primary_registrant ) {
1928
-		if ( ! $primary_registrant instanceof EE_Registration ) {
1927
+	private function _redirect_wayward_request(EE_Registration $primary_registrant) {
1928
+		if ( ! $primary_registrant instanceof EE_Registration) {
1929 1929
 			// try redirecting based on the current TXN
1930 1930
 			$primary_registrant = $this->checkout->transaction instanceof EE_Transaction ? $this->checkout->transaction->primary_registration() : null;
1931
-			if ( ! $primary_registrant instanceof EE_Registration ) {
1931
+			if ( ! $primary_registrant instanceof EE_Registration) {
1932 1932
 				EE_Error::add_error(
1933 1933
 					sprintf(
1934
-						__( 'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ),
1934
+						__('Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'),
1935 1935
 						'<br/>',
1936
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1936
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1937 1937
 					),
1938 1938
 					__FILE__, __FUNCTION__, __LINE__
1939 1939
 				);
@@ -1961,16 +1961,16 @@  discard block
 block discarded – undo
1961 1961
 	 * @param \EE_Offsite_Gateway $gateway
1962 1962
 	 * @return \EE_Payment
1963 1963
 	 */
1964
-	private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) {
1964
+	private function _process_off_site_payment(EE_Offsite_Gateway $gateway) {
1965 1965
 		try {
1966 1966
 			// if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
1967
-			if ( $gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request() ) {
1967
+			if ($gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request()) {
1968 1968
 				$payment = $this->checkout->transaction->last_payment();
1969 1969
 				//$payment_source = 'last_payment';
1970 1970
 			} else {
1971 1971
 				// get payment details and process results
1972 1972
 				/** @type EE_Payment_Processor $payment_processor */
1973
-				$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1973
+				$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1974 1974
 				$payment = $payment_processor->process_ipn(
1975 1975
 					$_REQUEST,
1976 1976
 					$this->checkout->transaction,
@@ -1980,14 +1980,14 @@  discard block
 block discarded – undo
1980 1980
 				);
1981 1981
 				//$payment_source = 'process_ipn';
1982 1982
 			}
1983
-		} catch ( Exception $e ) {
1983
+		} catch (Exception $e) {
1984 1984
 			// let's just eat the exception and try to move on using any previously set payment info
1985 1985
 			$payment = $this->checkout->transaction->last_payment();
1986 1986
 			//$payment_source = 'last_payment after Exception';
1987 1987
 			// but if we STILL don't have a payment object
1988
-			if ( ! $payment instanceof EE_Payment ) {
1988
+			if ( ! $payment instanceof EE_Payment) {
1989 1989
 				// then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
1990
-				$this->_handle_payment_processor_exception( $e );
1990
+				$this->_handle_payment_processor_exception($e);
1991 1991
 			}
1992 1992
 		}
1993 1993
 		// DEBUG LOG
@@ -2011,13 +2011,13 @@  discard block
 block discarded – undo
2011 2011
 	 * @param EE_Payment $payment
2012 2012
 	 * @return EE_Payment | FALSE
2013 2013
 	 */
2014
-	private function _process_cancelled_payments( $payment = NULL ) {
2014
+	private function _process_cancelled_payments($payment = NULL) {
2015 2015
 		if (
2016
-			isset( $_REQUEST[ 'ee_cancel_payment' ] )
2016
+			isset($_REQUEST['ee_cancel_payment'])
2017 2017
 			&& $payment instanceof EE_Payment
2018 2018
 			&& $payment->status() == EEM_Payment::status_id_failed
2019 2019
 		) {
2020
-			$payment->set_status( EEM_Payment::status_id_cancelled );
2020
+			$payment->set_status(EEM_Payment::status_id_cancelled);
2021 2021
 		}
2022 2022
 		return $payment;
2023 2023
 	}
@@ -2034,23 +2034,23 @@  discard block
 block discarded – undo
2034 2034
 	public function get_transaction_details_for_gateways() {
2035 2035
 		$txn_details = array();
2036 2036
 		// ya gotta make a choice man
2037
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
2037
+		if (empty($this->checkout->selected_method_of_payment)) {
2038 2038
 			$txn_details = array(
2039
-				'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' )
2039
+				'error' => __('Please select a method of payment before proceeding.', 'event_espresso')
2040 2040
 			);
2041 2041
 		}
2042 2042
 		// get EE_Payment_Method object
2043 2043
 		if (
2044
-			empty( $txn_details ) &&
2044
+			empty($txn_details) &&
2045 2045
 			! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
2046 2046
 		) {
2047 2047
 			$txn_details = array(
2048 2048
 				'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2049
-				'error' => __( 'A valid Payment Method could not be determined.', 'event_espresso' )
2049
+				'error' => __('A valid Payment Method could not be determined.', 'event_espresso')
2050 2050
 			);
2051 2051
 		}
2052
-		if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) {
2053
-			$return_url = $this->_get_return_url( $this->checkout->payment_method );
2052
+		if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
2053
+			$return_url = $this->_get_return_url($this->checkout->payment_method);
2054 2054
 			$txn_details = array(
2055 2055
 				'TXN_ID'        			=> $this->checkout->transaction->ID(),
2056 2056
 				'TXN_timestamp' 	=> $this->checkout->transaction->datetime(),
@@ -2061,7 +2061,7 @@  discard block
 block discarded – undo
2061 2061
 				'PMD_ID'        			=> $this->checkout->transaction->payment_method_ID(),
2062 2062
 				'payment_amount' => $this->checkout->amount_owing,
2063 2063
 				'return_url' 				=> $return_url,
2064
-				'cancel_url' 				=> add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ),
2064
+				'cancel_url' 				=> add_query_arg(array('ee_cancel_payment' => true), $return_url),
2065 2065
 				'notify_url' 				=> EE_Config::instance()->core->txn_page_url(
2066 2066
 					array(
2067 2067
 						'e_reg_url_link'    			=> $this->checkout->transaction->primary_registration()->reg_url_link(),
@@ -2070,7 +2070,7 @@  discard block
 block discarded – undo
2070 2070
 				)
2071 2071
 			);
2072 2072
 		}
2073
-		echo json_encode( $txn_details );
2073
+		echo json_encode($txn_details);
2074 2074
 		exit();
2075 2075
 	}
2076 2076
 
Please login to merge, or discard this patch.