Completed
Branch BUG-9548-transaction-completio... (b10ae2)
by
unknown
556:21 queued 541:18
created
core/db_models/relations/EE_Has_Many_Any_Relation.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 /*
5 5
  *
6 6
  */
7
-require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php');
7
+require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php');
8 8
 
9 9
 
10 10
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @subpackage    core
20 20
  * @author        Michael Nelson
21 21
  */
22
-class EE_Has_Many_Any_Relation extends EE_Has_Many_Relation{
22
+class EE_Has_Many_Any_Relation extends EE_Has_Many_Relation {
23 23
 
24 24
 	/**
25 25
 	 * Gets the SQL string for performing the join between this model and the other model.
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 	 * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = other_model_primary_table.fk" etc
29 29
 	 * @throws \EE_Error
30 30
 	 */
31
-	public function get_join_statement( $model_relation_chain){
31
+	public function get_join_statement($model_relation_chain) {
32 32
 		//create the sql string like
33 33
 		// LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions
34 34
 		$this_table_pk_field = $this->get_this_model()->get_primary_key_field();
35 35
 		$other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
36
-		$pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_pk_field->get_table_alias();
37
-		$fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_fk_field->get_table_alias();
36
+		$pk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_pk_field->get_table_alias();
37
+		$fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_fk_field->get_table_alias();
38 38
 		$fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias);
39 39
 		$field_with_model_name = $this->get_other_model()->get_field_containing_related_model_name();
40 40
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 				$other_table_fk_field->get_table_column(),
44 44
 				$pk_table_alias,
45 45
 				$this_table_pk_field->get_table_column(),
46
-				$fk_table_alias . '.' . $field_with_model_name->get_table_column() . "='" . $this->get_this_model()->get_this_model_name() . "'" )
46
+				$fk_table_alias.'.'.$field_with_model_name->get_table_column()."='".$this->get_this_model()->get_this_model_name()."'")
47 47
 				.$this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias);
48 48
 	}
49 49
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @return \EE_Base_Class
59 59
 	 * @throws \EE_Error
60 60
 	 */
61
-	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){
61
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) {
62 62
 		 $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
63 63
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
64 64
 
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 	 * @return \EE_Base_Class
84 84
 	 * @throws \EE_Error
85 85
 	 */
86
-	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()){
86
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
87 87
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
88 88
 		 //find the field on the other model which is a foreign key to this model
89 89
 		 $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
90 90
 		 //set that field on the other model to this model's ID
91
-		 $other_model_obj->set($fk_field_on_other_model->get_name(),null, true);
91
+		 $other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
92 92
 		 $other_model_obj->set($this->get_other_model()->get_field_containing_related_model_name()->get_name(), null, true);
93 93
 		 $other_model_obj->save();
94 94
 		 return $other_model_obj;
Please login to merge, or discard this patch.
core/db_classes/EE_Base_Class.class.php 2 patches
Spacing   +486 added lines, -486 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
2
-do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2
+do_action('AHEE_log', __FILE__, ' FILE LOADED', '');
3 3
 /**
4 4
  *
5 5
  * Event Espresso
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * ------------------------------------------------------------------------
25 25
  */
26 26
 
27
-abstract class EE_Base_Class{
27
+abstract class EE_Base_Class {
28 28
 
29 29
 	/**
30 30
 	 * This is an array of the original properties and values provided during construction
@@ -117,60 +117,60 @@  discard block
 block discarded – undo
117 117
 	 * @throws EE_Error
118 118
 	 * @return \EE_Base_Class
119 119
 	 */
120
-	protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){
120
+	protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) {
121 121
 
122
-		$className=get_class($this);
122
+		$className = get_class($this);
123 123
 
124
-		do_action("AHEE__{$className}__construct",$this,$fieldValues);
125
-		$model=$this->get_model();
126
-		$model_fields = $model->field_settings( FALSE );
124
+		do_action("AHEE__{$className}__construct", $this, $fieldValues);
125
+		$model = $this->get_model();
126
+		$model_fields = $model->field_settings(FALSE);
127 127
 		// ensure $fieldValues is an array
128
-		$fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues );
128
+		$fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues);
129 129
 		// EEH_Debug_Tools::printr( $fieldValues, '$fieldValues  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
130 130
 		// verify client code has not passed any invalid field names
131
-		foreach($fieldValues as $field_name=> $field_value){
132
-			if( ! isset( $model_fields[ $field_name] ) ){
133
-				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields))));
131
+		foreach ($fieldValues as $field_name=> $field_value) {
132
+			if ( ! isset($model_fields[$field_name])) {
133
+				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields))));
134 134
 			}
135 135
 		}
136 136
 		// EEH_Debug_Tools::printr( $model_fields, '$model_fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
137
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
138
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
137
+		EE_Registry::instance()->load_helper('DTT_Helper');
138
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
139 139
 
140
-		if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
140
+		if ( ! empty($date_formats) && is_array($date_formats)) {
141 141
 			$this->_dt_frmt = $date_formats[0];
142 142
 			$this->_tm_frmt = $date_formats[1];
143 143
 		} else {
144 144
 			//set default formats for date and time
145
-			$this->_dt_frmt = get_option( 'date_format' );
146
-			$this->_tm_frmt = get_option( 'time_format' );
145
+			$this->_dt_frmt = get_option('date_format');
146
+			$this->_tm_frmt = get_option('time_format');
147 147
 		}
148 148
 
149 149
 		//if db model is instantiating
150
-		if ( $bydb ){
150
+		if ($bydb) {
151 151
 			//client code has indicated these field values are from the database
152
-			foreach( $model_fields as $fieldName => $field ){
153
-				$this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null );
152
+			foreach ($model_fields as $fieldName => $field) {
153
+				$this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null);
154 154
 			}
155 155
 		} else {
156 156
 			//we're constructing a brand
157 157
 			//new instance of the model object. Generally, this means we'll need to do more field validation
158
-			foreach( $model_fields as $fieldName => $field ){
159
-				$this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true );
158
+			foreach ($model_fields as $fieldName => $field) {
159
+				$this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true);
160 160
 			}
161 161
 		}
162 162
 
163 163
 		//remember what values were passed to this constructor
164 164
 		$this->_props_n_values_provided_in_constructor = $fieldValues;
165 165
 		//remember in entity mapper
166
-		if( ! $bydb  && $model->has_primary_key_field() && $this->ID() ){
166
+		if ( ! $bydb && $model->has_primary_key_field() && $this->ID()) {
167 167
 			$model->add_to_entity_map($this);
168 168
 		}
169 169
 		//setup all the relations
170
-		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
171
-			if($relation_obj instanceof EE_Belongs_To_Relation){
170
+		foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) {
171
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
172 172
 				$this->_model_relations[$relation_name] = NULL;
173
-			}else{
173
+			} else {
174 174
 				$this->_model_relations[$relation_name] = array();
175 175
 			}
176 176
 		}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		 * Action done at the end of each model object construction
179 179
 		 * @param EE_Base_Class $this the model object just created
180 180
 		 */
181
-		do_action( 'AHEE__EE_Base_Class__construct__finished', $this );
181
+		do_action('AHEE__EE_Base_Class__construct__finished', $this);
182 182
 	}
183 183
 
184 184
 	/**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @param boolean $allow_persist
199 199
 	 * @return boolean
200 200
 	 */
201
-	public function set_allow_persist( $allow_persist ) {
201
+	public function set_allow_persist($allow_persist) {
202 202
 		return $this->_allow_persist = $allow_persist;
203 203
 	}
204 204
 
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 	 * @return mixed|null
213 213
 	 * @throws \EE_Error
214 214
 	 */
215
-	public function get_original( $field_name ){
216
-		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
217
-				$field_settings = $this->get_model()->field_settings_for( $field_name )){
218
-			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
219
-		}else{
215
+	public function get_original($field_name) {
216
+		if (isset($this->_props_n_values_provided_in_constructor[$field_name]) &&
217
+				$field_settings = $this->get_model()->field_settings_for($field_name)) {
218
+			return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]);
219
+		} else {
220 220
 			return NULL;
221 221
 		}
222 222
 	}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @param EE_Base_Class $obj
227 227
 	 * @return string
228 228
 	 */
229
-	public function get_class($obj){
229
+	public function get_class($obj) {
230 230
 		return get_class($obj);
231 231
 	}
232 232
 
@@ -241,19 +241,19 @@  discard block
 block discarded – undo
241 241
 	 * @param bool      $use_default
242 242
 	 * @throws \EE_Error
243 243
 	 */
244
-	public function set( $field_name, $field_value, $use_default = FALSE ){
245
-		$field_obj = $this->get_model()->field_settings_for( $field_name );
246
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
244
+	public function set($field_name, $field_value, $use_default = FALSE) {
245
+		$field_obj = $this->get_model()->field_settings_for($field_name);
246
+		if ($field_obj instanceof EE_Model_Field_Base) {
247 247
 //			if ( method_exists( $field_obj, 'set_timezone' )) {
248
-			if ( $field_obj instanceof EE_Datetime_Field ) {
249
-				$field_obj->set_timezone( $this->_timezone );
250
-				$field_obj->set_date_format( $this->_dt_frmt );
251
-				$field_obj->set_time_format( $this->_tm_frmt );
248
+			if ($field_obj instanceof EE_Datetime_Field) {
249
+				$field_obj->set_timezone($this->_timezone);
250
+				$field_obj->set_date_format($this->_dt_frmt);
251
+				$field_obj->set_time_format($this->_tm_frmt);
252 252
 			}
253 253
 
254 254
 			$holder_of_value = $field_obj->prepare_for_set($field_value);
255 255
 			//should the value be null?
256
-			if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){
256
+			if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) {
257 257
 				$this->_fields[$field_name] = $field_obj->get_default_value();
258 258
 
259 259
 				/**
@@ -265,26 +265,26 @@  discard block
 block discarded – undo
265 265
 				 */
266 266
 				if (
267 267
 					$field_obj instanceof EE_Datetime_Field
268
-					&& $this->_fields[ $field_name ] !== null
268
+					&& $this->_fields[$field_name] !== null
269 269
 					&& ! $this->_fields[$field_name] instanceof DateTime
270 270
 				) {
271
-					empty( $this->_fields[$field_name] )
272
-						? $this->set( $field_name, time() )
273
-						: $this->set( $field_name, $this->_fields[$field_name] );
271
+					empty($this->_fields[$field_name])
272
+						? $this->set($field_name, time())
273
+						: $this->set($field_name, $this->_fields[$field_name]);
274 274
 				}
275 275
 
276
-			}else{
276
+			} else {
277 277
 				$this->_fields[$field_name] = $holder_of_value;
278 278
 			}
279 279
 
280 280
 			//if we're not in the constructor...
281 281
 			//now check if what we set was a primary key
282
-			if(
282
+			if (
283 283
 				//note: props_n_values_provided_in_constructor is only set at the END of the constructor
284 284
 				$this->_props_n_values_provided_in_constructor
285 285
 				&& $field_value
286
-				&& $field_name === self::_get_primary_key_name( get_class( $this ) )
287
-			){
286
+				&& $field_name === self::_get_primary_key_name(get_class($this))
287
+			) {
288 288
 				//if so, we want all this object's fields to be filled either with
289 289
 				//what we've explicitly set on this model
290 290
 				//or what we have in the db
@@ -292,20 +292,20 @@  discard block
 block discarded – undo
292 292
 				$fields_on_model = self::_get_model(get_class($this))->field_settings();
293 293
 
294 294
 				$obj_in_db = self::_get_model(get_class($this))->get_one_by_ID($field_value);
295
-				foreach($fields_on_model as $field_obj){
296
-					if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
297
-						&& $field_obj->get_name() !== $field_name ){
295
+				foreach ($fields_on_model as $field_obj) {
296
+					if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
297
+						&& $field_obj->get_name() !== $field_name) {
298 298
 
299
-						$this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name()));
299
+						$this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name()));
300 300
 					}
301 301
 				}
302 302
 				//oh this model object has an ID? well make sure its in the entity mapper
303 303
 				$this->get_model()->add_to_entity_map($this);
304 304
 			}
305 305
 			//let's unset any cache for this field_name from the $_cached_properties property.
306
-			$this->_clear_cached_property( $field_name );
307
-		}else{
308
-			throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name  ) );
306
+			$this->_clear_cached_property($field_name);
307
+		} else {
308
+			throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name));
309 309
 		}
310 310
 
311 311
 	}
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
 	 * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs.
323 323
 	 * @throws \EE_Error
324 324
 	 */
325
-	public function set_field_or_extra_meta( $field_name, $field_value ) {
326
-		if ( $this->get_model()->has_field( $field_name ) ) {
327
-			$this->set( $field_name, $field_value );
325
+	public function set_field_or_extra_meta($field_name, $field_value) {
326
+		if ($this->get_model()->has_field($field_name)) {
327
+			$this->set($field_name, $field_value);
328 328
 			return true;
329 329
 		} else {
330 330
 			//ensure this object is saved first so that extra meta can be properly related.
331 331
 			$this->save();
332
-			return $this->update_extra_meta( $field_name, $field_value );
332
+			return $this->update_extra_meta($field_name, $field_value);
333 333
 		}
334 334
 	}
335 335
 
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 	 * @return mixed|null  value for the field if found.  null if not found.
351 351
 	 * @throws \EE_Error
352 352
 	 */
353
-	public function get_field_or_extra_meta( $field_name ) {
354
-		if ( $this->get_model()->has_field( $field_name ) ) {
355
-			$column_value = $this->get( $field_name );
353
+	public function get_field_or_extra_meta($field_name) {
354
+		if ($this->get_model()->has_field($field_name)) {
355
+			$column_value = $this->get($field_name);
356 356
 		} else {
357 357
 			//This isn't a column in the main table, let's see if it is in the extra meta.
358
-			$column_value = $this->get_extra_meta( $field_name, true, null );
358
+			$column_value = $this->get_extra_meta($field_name, true, null);
359 359
 		}
360 360
 		return $column_value;
361 361
 	}
@@ -371,19 +371,19 @@  discard block
 block discarded – undo
371 371
 	 * @return void
372 372
 	 * @throws \EE_Error
373 373
 	 */
374
-	public function set_timezone( $timezone = '' ) {
374
+	public function set_timezone($timezone = '') {
375 375
 		EE_Registry::instance()->load_helper('DTT_Helper');
376
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
376
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
377 377
 		//make sure we clear all cached properties because they won't be relevant now
378 378
 		$this->_clear_cached_properties();
379 379
 
380 380
 		//make sure we update field settings and the date for all EE_Datetime_Fields
381
-		$model_fields = $this->get_model()->field_settings( false );
382
-		foreach ( $model_fields as $field_name => $field_obj ) {
383
-			if ( $field_obj instanceof EE_Datetime_Field ) {
384
-				$field_obj->set_timezone( $this->_timezone );
385
-				if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) {
386
-					$this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) );
381
+		$model_fields = $this->get_model()->field_settings(false);
382
+		foreach ($model_fields as $field_name => $field_obj) {
383
+			if ($field_obj instanceof EE_Datetime_Field) {
384
+				$field_obj->set_timezone($this->_timezone);
385
+				if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) {
386
+					$this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone));
387 387
 				}
388 388
 			}
389 389
 		}
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 *
413 413
 	 * @param string $format   should be a format recognizable by PHP date() functions.
414 414
 	 */
415
-	public function set_date_format( $format ) {
415
+	public function set_date_format($format) {
416 416
 		$this->_dt_frmt = $format;
417 417
 		//clear cached_properties because they won't be relevant now.
418 418
 		$this->_clear_cached_properties();
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 * @since 4.6
429 429
 	 * @param string $format should be a format recognizable by PHP date() functions.
430 430
 	 */
431
-	public function set_time_format( $format ) {
431
+	public function set_time_format($format) {
432 432
 		$this->_tm_frmt = $format;
433 433
 		//clear cached_properties because they won't be relevant now.
434 434
 		$this->_clear_cached_properties();
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 	 *
446 446
 	 * @return mixed string|array
447 447
 	 */
448
-	public function get_format( $full = true ) {
449
-		return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt );
448
+	public function get_format($full = true) {
449
+		return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt);
450 450
 	}
451 451
 
452 452
 
@@ -464,17 +464,17 @@  discard block
 block discarded – undo
464 464
 	 * @throws EE_Error
465 465
 	 * @return mixed    index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array)
466 466
 	 */
467
-	public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){
467
+	public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) {
468 468
 		// its entirely possible that there IS no related object yet in which case there is nothing to cache.
469
-		if ( ! $object_to_cache instanceof EE_Base_Class ) {
469
+		if ( ! $object_to_cache instanceof EE_Base_Class) {
470 470
 			return FALSE;
471 471
 		}
472 472
 		// also get "how" the object is related, or throw an error
473
-		if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) {
474
-			throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this )));
473
+		if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) {
474
+			throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this)));
475 475
 		}
476 476
 		// how many things are related ?
477
-		if( $relationship_to_model instanceof EE_Belongs_To_Relation ){
477
+		if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
478 478
 			// if it's a "belongs to" relationship, then there's only one related model object  eg, if this is a registration, there's only 1 attendee for it
479 479
 			// so for these model objects just set it to be cached
480 480
 			$this->_model_relations[$relationName] = $object_to_cache;
@@ -482,26 +482,26 @@  discard block
 block discarded – undo
482 482
 		} else {
483 483
 			// otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type.
484 484
 			// eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array
485
-			if( ! is_array( $this->_model_relations[$relationName] )) {
485
+			if ( ! is_array($this->_model_relations[$relationName])) {
486 486
 				// if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array
487
-				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array();
487
+				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array();
488 488
 			}
489 489
 			// first check for a cache_id which is normally empty
490
-			if ( ! empty( $cache_id )) {
490
+			if ( ! empty($cache_id)) {
491 491
 				// if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on
492
-				$this->_model_relations[$relationName][ $cache_id ] = $object_to_cache;
492
+				$this->_model_relations[$relationName][$cache_id] = $object_to_cache;
493 493
 				$return = $cache_id;
494
-			} elseif ( $object_to_cache->ID() ) {
494
+			} elseif ($object_to_cache->ID()) {
495 495
 				// OR the cached object originally came from the db, so let's just use it's PK for an ID
496
-				$this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache;
496
+				$this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache;
497 497
 				$return = $object_to_cache->ID();
498 498
 			} else {
499 499
 				// OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID
500 500
 				$this->_model_relations[$relationName][] = $object_to_cache;
501 501
 				  // move the internal pointer to the end of the array
502
-				end( $this->_model_relations[$relationName] );
502
+				end($this->_model_relations[$relationName]);
503 503
 				// and grab the key so that we can return it
504
-				$return = key( $this->_model_relations[$relationName] );
504
+				$return = key($this->_model_relations[$relationName]);
505 505
 			}
506 506
 
507 507
 		}
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
 	 * @return void
521 521
 	 * @throws \EE_Error
522 522
 	 */
523
-	protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) {
523
+	protected function _set_cached_property($fieldname, $value, $cache_type = NULL) {
524 524
 		//first make sure this property exists
525 525
 		$this->get_model()->field_settings_for($fieldname);
526 526
 
527
-		$cache_type = empty( $cache_type ) ? 'standard' : $cache_type;
527
+		$cache_type = empty($cache_type) ? 'standard' : $cache_type;
528 528
 		$this->_cached_properties[$fieldname][$cache_type] = $value;
529 529
 	}
530 530
 
@@ -545,36 +545,36 @@  discard block
 block discarded – undo
545 545
 	 * @return mixed                   whatever the value for the property is we're retrieving
546 546
 	 * @throws \EE_Error
547 547
 	 */
548
-	protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) {
548
+	protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) {
549 549
 		//verify the field exists
550 550
 		$this->get_model()->field_settings_for($fieldname);
551 551
 
552 552
 		$cache_type = $pretty ? 'pretty' : 'standard';
553
-		$cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : '';
553
+		$cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : '';
554 554
 
555
-		if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) {
555
+		if (isset($this->_cached_properties[$fieldname][$cache_type])) {
556 556
 			return $this->_cached_properties[$fieldname][$cache_type];
557 557
 		}
558 558
 
559 559
 		$field_obj = $this->get_model()->field_settings_for($fieldname);
560
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
560
+		if ($field_obj instanceof EE_Model_Field_Base) {
561 561
 			/**
562 562
 			 * maybe this is EE_Datetime_Field.  If so we need to make sure timezone and
563 563
 			 * formats are correct.
564 564
 			 */
565
-			if ( $field_obj instanceof EE_Datetime_Field ) {
566
-				$field_obj->set_timezone( $this->_timezone );
567
-				$field_obj->set_date_format( $this->_dt_frmt, $pretty );
568
-				$field_obj->set_time_format( $this->_tm_frmt, $pretty );
565
+			if ($field_obj instanceof EE_Datetime_Field) {
566
+				$field_obj->set_timezone($this->_timezone);
567
+				$field_obj->set_date_format($this->_dt_frmt, $pretty);
568
+				$field_obj->set_time_format($this->_tm_frmt, $pretty);
569 569
 			}
570 570
 
571
-			if( ! isset($this->_fields[$fieldname])){
571
+			if ( ! isset($this->_fields[$fieldname])) {
572 572
 				$this->_fields[$fieldname] = NULL;
573 573
 			}
574 574
 			$value = $pretty
575 575
 				? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref)
576
-				: $field_obj->prepare_for_get($this->_fields[$fieldname] );
577
-			$this->_set_cached_property( $fieldname, $value, $cache_type );
576
+				: $field_obj->prepare_for_get($this->_fields[$fieldname]);
577
+			$this->_set_cached_property($fieldname, $value, $cache_type);
578 578
 			return $value;
579 579
 		}
580 580
 		return null;
@@ -600,9 +600,9 @@  discard block
 block discarded – undo
600 600
 	 * @param  string $property_name the property to remove if it exists (from the _cached_properties array)
601 601
 	 * @return void
602 602
 	 */
603
-	protected function _clear_cached_property( $property_name ) {
604
-		if ( isset( $this->_cached_properties[ $property_name ] ) ) {
605
-			unset( $this->_cached_properties[ $property_name ] );
603
+	protected function _clear_cached_property($property_name) {
604
+		if (isset($this->_cached_properties[$property_name])) {
605
+			unset($this->_cached_properties[$property_name]);
606 606
 		}
607 607
 	}
608 608
 
@@ -616,12 +616,12 @@  discard block
 block discarded – undo
616 616
 	 * @return EE_Base_Class
617 617
 	 * @throws \EE_Error
618 618
 	 */
619
-	protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){
619
+	protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) {
620 620
 		$other_model_instance = self::_get_model_instance_with_name(
621
-			self::_get_model_classname( $model_name ),
621
+			self::_get_model_classname($model_name),
622 622
 			$this->_timezone
623 623
 		);
624
-		return $other_model_instance->ensure_is_obj( $object_or_id );
624
+		return $other_model_instance->ensure_is_obj($object_or_id);
625 625
 	}
626 626
 
627 627
 
@@ -638,32 +638,32 @@  discard block
 block discarded – undo
638 638
 	 * @throws EE_Error
639 639
 	 * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all
640 640
 	 */
641
-	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){
641
+	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) {
642 642
 		$relationship_to_model = $this->get_model()->related_settings_for($relationName);
643 643
 		$index_in_cache = '';
644
-		if( ! $relationship_to_model){
644
+		if ( ! $relationship_to_model) {
645 645
 			throw new EE_Error(
646 646
 				sprintf(
647
-					__( "There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso' ),
647
+					__("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'),
648 648
 					$relationName,
649
-					get_class( $this )
649
+					get_class($this)
650 650
 				)
651 651
 			);
652 652
 		}
653
-		if($clear_all){
653
+		if ($clear_all) {
654 654
 			$obj_removed = true;
655 655
 			$this->_model_relations[$relationName]  = null;
656
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
656
+		}elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) {
657 657
 			$obj_removed = $this->_model_relations[$relationName];
658 658
 			$this->_model_relations[$relationName]  = null;
659
-		}else{
660
-			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
659
+		} else {
660
+			if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) {
661 661
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
662
-				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
662
+				if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) {
663 663
 					$index_found_at = NULL;
664 664
 					//find this object in the array even though it has a different key
665
-					foreach($this->_model_relations[$relationName] as $index=>$obj){
666
-						if(
665
+					foreach ($this->_model_relations[$relationName] as $index=>$obj) {
666
+						if (
667 667
 							$obj instanceof EE_Base_Class
668 668
 							&& (
669 669
 								$obj == $object_to_remove_or_index_into_array
@@ -674,34 +674,34 @@  discard block
 block discarded – undo
674 674
 							break;
675 675
 						}
676 676
 					}
677
-					if($index_found_at){
677
+					if ($index_found_at) {
678 678
 						$index_in_cache = $index_found_at;
679
-					}else{
679
+					} else {
680 680
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
681 681
 						//if it wasn't in it to begin with. So we're done
682 682
 						return $object_to_remove_or_index_into_array;
683 683
 					}
684 684
 				}
685
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
685
+			}elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) {
686 686
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
687
-				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
688
-					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
687
+				foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) {
688
+					if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) {
689 689
 						$index_in_cache = $index;
690 690
 					}
691 691
 				}
692
-			}else{
692
+			} else {
693 693
 				$index_in_cache = $object_to_remove_or_index_into_array;
694 694
 			}
695 695
 			//supposedly we've found it. But it could just be that the client code
696 696
 			//provided a bad index/object
697 697
 			if (
698 698
 				isset(
699
-					$this->_model_relations[ $relationName ],
700
-					$this->_model_relations[ $relationName ][ $index_in_cache ]
699
+					$this->_model_relations[$relationName],
700
+					$this->_model_relations[$relationName][$index_in_cache]
701 701
 				)
702 702
 			) {
703
-				$obj_removed = $this->_model_relations[ $relationName ][ $index_in_cache ];
704
-				unset( $this->_model_relations[ $relationName ][ $index_in_cache ] );
703
+				$obj_removed = $this->_model_relations[$relationName][$index_in_cache];
704
+				unset($this->_model_relations[$relationName][$index_in_cache]);
705 705
 			} else {
706 706
 				//that thing was never cached anyways.
707 707
 				$obj_removed = null;
@@ -722,24 +722,24 @@  discard block
 block discarded – undo
722 722
 	 * @return boolean TRUE on success, FALSE on fail
723 723
 	 * @throws \EE_Error
724 724
 	 */
725
-	public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
725
+	public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
726 726
 		// verify that incoming object is of the correct type
727
-		$obj_class = 'EE_' . $relationName;
728
-		if ( $newly_saved_object instanceof $obj_class ) {
727
+		$obj_class = 'EE_'.$relationName;
728
+		if ($newly_saved_object instanceof $obj_class) {
729 729
 			/* @type EE_Base_Class $newly_saved_object*/
730 730
 			// now get the type of relation
731
-			$relationship_to_model = $this->get_model()->related_settings_for( $relationName );
731
+			$relationship_to_model = $this->get_model()->related_settings_for($relationName);
732 732
 			// if this is a 1:1 relationship
733
-			if( $relationship_to_model instanceof EE_Belongs_To_Relation ) {
733
+			if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
734 734
 				// then just replace the cached object with the newly saved object
735 735
 				$this->_model_relations[$relationName] = $newly_saved_object;
736 736
 				return TRUE;
737 737
 			// or if it's some kind of sordid feral polyamorous relationship...
738
-			} elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) {
738
+			} elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) {
739 739
 				// then remove the current cached item
740
-				unset( $this->_model_relations[$relationName][ $current_cache_id ] );
740
+				unset($this->_model_relations[$relationName][$current_cache_id]);
741 741
 				// and cache the newly saved object using it's new ID
742
-				$this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object;
742
+				$this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object;
743 743
 				return TRUE;
744 744
 			}
745 745
 		}
@@ -755,11 +755,11 @@  discard block
 block discarded – undo
755 755
 	 * @param string $relationName
756 756
 	 * @return EE_Base_Class
757 757
 	 */
758
-	public function get_one_from_cache($relationName){
759
-		$cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null;
760
-		if(is_array($cached_array_or_object)){
758
+	public function get_one_from_cache($relationName) {
759
+		$cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null;
760
+		if (is_array($cached_array_or_object)) {
761 761
 			return array_shift($cached_array_or_object);
762
-		}else{
762
+		} else {
763 763
 			return $cached_array_or_object;
764 764
 		}
765 765
 	}
@@ -774,23 +774,23 @@  discard block
 block discarded – undo
774 774
 	 * @throws \EE_Error
775 775
 	 * @return EE_Base_Class[] NOT necessarily indexed by primary keys
776 776
 	 */
777
-	public function get_all_from_cache($relationName){
778
-		$objects = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array();
777
+	public function get_all_from_cache($relationName) {
778
+		$objects = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array();
779 779
 		// if the result is not an array, but exists, make it an array
780
-		$objects = is_array( $objects ) ? $objects : array( $objects );
780
+		$objects = is_array($objects) ? $objects : array($objects);
781 781
 		//bugfix for https://events.codebasehq.com/projects/event-espresso/tickets/7143
782 782
 		//basically, if this model object was stored in the session, and these cached model objects
783 783
 		//already have IDs, let's make sure they're in their model's entity mapper
784 784
 		//otherwise we will have duplicates next time we call
785 785
 		// EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() );
786
-		$model = EE_Registry::instance()->load_model( $relationName );
787
-		foreach( $objects as $model_object ){
788
-			if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){
786
+		$model = EE_Registry::instance()->load_model($relationName);
787
+		foreach ($objects as $model_object) {
788
+			if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) {
789 789
 				//ensure its in the map if it has an ID; otherwise it will be added to the map when its saved
790
-				if( $model_object->ID() ){
791
-					$model->add_to_entity_map( $model_object );
790
+				if ($model_object->ID()) {
791
+					$model->add_to_entity_map($model_object);
792 792
 				}
793
-			}else{
793
+			} else {
794 794
 				throw new EE_Error(
795 795
 					sprintf(
796 796
 						__(
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 							'event_espresso'
799 799
 						),
800 800
 						$relationName,
801
-						gettype( $model_object )
801
+						gettype($model_object)
802 802
 					)
803 803
 				);
804 804
 			}
@@ -820,15 +820,15 @@  discard block
 block discarded – undo
820 820
 	 * @return array|EE_Base_Class[]
821 821
 	 * @throws \EE_Error
822 822
 	 */
823
-	public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
824
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
823
+	public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
824
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
825 825
 			? $this->get_model()->get_primary_key_field()->get_name()
826 826
 			: $field_to_order_by;
827
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
828
-		if ( empty( $field ) || empty( $current_value ) ) {
827
+		$current_value = ! empty($field) ? $this->get($field) : null;
828
+		if (empty($field) || empty($current_value)) {
829 829
 			return array();
830 830
 		}
831
-		return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select );
831
+		return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
832 832
 	}
833 833
 
834 834
 
@@ -845,15 +845,15 @@  discard block
 block discarded – undo
845 845
 	 * @return array|EE_Base_Class[]
846 846
 	 * @throws \EE_Error
847 847
 	 */
848
-	public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
849
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
848
+	public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
849
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
850 850
 			? $this->get_model()->get_primary_key_field()->get_name()
851 851
 			: $field_to_order_by;
852
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
853
-		if ( empty( $field ) || empty( $current_value ) ) {
852
+		$current_value = ! empty($field) ? $this->get($field) : null;
853
+		if (empty($field) || empty($current_value)) {
854 854
 			return array();
855 855
 		}
856
-		return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select );
856
+		return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
857 857
 	}
858 858
 
859 859
 
@@ -869,15 +869,15 @@  discard block
 block discarded – undo
869 869
 	 * @return array|EE_Base_Class
870 870
 	 * @throws \EE_Error
871 871
 	 */
872
-	public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
873
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
872
+	public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
873
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
874 874
 			? $this->get_model()->get_primary_key_field()->get_name()
875 875
 			: $field_to_order_by;
876
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
877
-		if ( empty( $field ) || empty( $current_value ) ) {
876
+		$current_value = ! empty($field) ? $this->get($field) : null;
877
+		if (empty($field) || empty($current_value)) {
878 878
 			return array();
879 879
 		}
880
-		return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select );
880
+		return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select);
881 881
 	}
882 882
 
883 883
 
@@ -893,15 +893,15 @@  discard block
 block discarded – undo
893 893
 	 * @return array|EE_Base_Class
894 894
 	 * @throws \EE_Error
895 895
 	 */
896
-	public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
897
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
896
+	public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
897
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
898 898
 			? $this->get_model()->get_primary_key_field()->get_name()
899 899
 			: $field_to_order_by;
900
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
901
-		if ( empty( $field ) || empty( $current_value ) ) {
900
+		$current_value = ! empty($field) ? $this->get($field) : null;
901
+		if (empty($field) || empty($current_value)) {
902 902
 			return array();
903 903
 		}
904
-		return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select );
904
+		return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select);
905 905
 	}
906 906
 
907 907
 
@@ -914,25 +914,25 @@  discard block
 block discarded – undo
914 914
 	 * @param mixed  $field_value_from_db
915 915
 	 * @throws \EE_Error
916 916
 	 */
917
-	public function set_from_db($field_name,$field_value_from_db){
917
+	public function set_from_db($field_name, $field_value_from_db) {
918 918
 		$field_obj = $this->get_model()->field_settings_for($field_name);
919
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
919
+		if ($field_obj instanceof EE_Model_Field_Base) {
920 920
 			//you would think the DB has no NULLs for non-null label fields right? wrong!
921 921
 			//eg, a CPT model object could have an entry in the posts table, but no
922 922
 			//entry in the meta table. Meaning that all its columns in the meta table
923 923
 			//are null! yikes! so when we find one like that, use defaults for its meta columns
924
-			if($field_value_from_db === NULL ){
925
-				if( $field_obj->is_nullable()){
924
+			if ($field_value_from_db === NULL) {
925
+				if ($field_obj->is_nullable()) {
926 926
 					//if the field allows nulls, then let it be null
927 927
 					$field_value = NULL;
928
-				}else{
928
+				} else {
929 929
 					$field_value = $field_obj->get_default_value();
930 930
 				}
931
-			}else{
932
-				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
931
+			} else {
932
+				$field_value = $field_obj->prepare_for_set_from_db($field_value_from_db);
933 933
 			}
934 934
 			$this->_fields[$field_name] = $field_value;
935
-			$this->_clear_cached_property( $field_name );
935
+			$this->_clear_cached_property($field_name);
936 936
 		}
937 937
 	}
938 938
 
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 	 * @return mixed
949 949
 	 * @throws \EE_Error
950 950
 	 */
951
-	public function get($field_name, $extra_cache_ref = NULL ){
952
-		return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref );
951
+	public function get($field_name, $extra_cache_ref = NULL) {
952
+		return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref);
953 953
 	}
954 954
 
955 955
 
@@ -982,10 +982,10 @@  discard block
 block discarded – undo
982 982
 	 *                                         just null is returned (because that indicates that likely
983 983
 	 *                                         this field is nullable).
984 984
 	 */
985
-	public function get_DateTime_object( $field_name ) {
986
-		$field_settings = $this->get_model()->field_settings_for( $field_name );
985
+	public function get_DateTime_object($field_name) {
986
+		$field_settings = $this->get_model()->field_settings_for($field_name);
987 987
 
988
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
988
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
989 989
 			EE_Error::add_error(
990 990
 				sprintf(
991 991
 					__(
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 	 * @return void
1018 1018
 	 * @throws \EE_Error
1019 1019
 	 */
1020
-	public function e($field_name, $extra_cache_ref = NULL){
1020
+	public function e($field_name, $extra_cache_ref = NULL) {
1021 1021
 		echo $this->get_pretty($field_name, $extra_cache_ref);
1022 1022
 	}
1023 1023
 
@@ -1031,8 +1031,8 @@  discard block
 block discarded – undo
1031 1031
 	 * @return void
1032 1032
 	 * @throws \EE_Error
1033 1033
 	 */
1034
-	public function f($field_name){
1035
-		$this->e($field_name,'form_input');
1034
+	public function f($field_name) {
1035
+		$this->e($field_name, 'form_input');
1036 1036
 	}
1037 1037
 
1038 1038
 
@@ -1045,8 +1045,8 @@  discard block
 block discarded – undo
1045 1045
 	 * @return mixed
1046 1046
 	 * @throws \EE_Error
1047 1047
 	 */
1048
-	public function get_pretty($field_name, $extra_cache_ref = NULL){
1049
-		return  $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref );
1048
+	public function get_pretty($field_name, $extra_cache_ref = NULL) {
1049
+		return  $this->_get_cached_property($field_name, TRUE, $extra_cache_ref);
1050 1050
 	}
1051 1051
 
1052 1052
 
@@ -1064,36 +1064,36 @@  discard block
 block discarded – undo
1064 1064
 	 * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
1065 1065
 	 * @throws \EE_Error
1066 1066
 	 */
1067
-	protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) {
1067
+	protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) {
1068 1068
 
1069
-		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt :  $dt_frmt;
1069
+		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt;
1070 1070
 		$in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt;
1071 1071
 
1072 1072
 		//validate field for datetime and returns field settings if valid.
1073
-		$field = $this->_get_dtt_field_settings( $field_name );
1073
+		$field = $this->_get_dtt_field_settings($field_name);
1074 1074
 
1075 1075
 		//clear cached property if either formats are not null.
1076
-		if( $dt_frmt !== null || $tm_frmt !== null ) {
1077
-			$this->_clear_cached_property( $field_name );
1076
+		if ($dt_frmt !== null || $tm_frmt !== null) {
1077
+			$this->_clear_cached_property($field_name);
1078 1078
 			//reset format properties because they are used in get()
1079 1079
 			$this->_dt_frmt = $in_dt_frmt;
1080 1080
 			$this->_tm_frmt = $in_tm_frmt;
1081 1081
 		}
1082
-		if ( $echo ) {
1083
-			$field->set_pretty_date_format( $in_dt_frmt );
1082
+		if ($echo) {
1083
+			$field->set_pretty_date_format($in_dt_frmt);
1084 1084
 		} else {
1085
-			$field->set_date_format( $in_dt_frmt );
1085
+			$field->set_date_format($in_dt_frmt);
1086 1086
 		}
1087
-		if ( $echo ) {
1088
-			$field->set_pretty_time_format( $in_tm_frmt );
1087
+		if ($echo) {
1088
+			$field->set_pretty_time_format($in_tm_frmt);
1089 1089
 		} else {
1090
-			$field->set_time_format( $in_tm_frmt );
1090
+			$field->set_time_format($in_tm_frmt);
1091 1091
 		}
1092 1092
 		//set timezone in field object
1093
-		$field->set_timezone( $this->_timezone );
1093
+		$field->set_timezone($this->_timezone);
1094 1094
 
1095 1095
 		//set the output returned
1096
-		switch ( $date_or_time ) {
1096
+		switch ($date_or_time) {
1097 1097
 
1098 1098
 			case 'D' :
1099 1099
 				$field->set_date_time_output('date');
@@ -1108,11 +1108,11 @@  discard block
 block discarded – undo
1108 1108
 		}
1109 1109
 
1110 1110
 
1111
-		if ( $echo ) {
1112
-			$this->e( $field_name, $date_or_time );
1111
+		if ($echo) {
1112
+			$this->e($field_name, $date_or_time);
1113 1113
 			return '';
1114 1114
 		 }
1115
-		return $this->get( $field_name, $date_or_time );
1115
+		return $this->get($field_name, $date_or_time);
1116 1116
 	}
1117 1117
 
1118 1118
 
@@ -1125,8 +1125,8 @@  discard block
 block discarded – undo
1125 1125
 	 * @return string            datetime value formatted
1126 1126
 	 * @throws \EE_Error
1127 1127
 	 */
1128
-	public function get_date( $field_name, $format = NULL ) {
1129
-		return $this->_get_datetime( $field_name, $format, NULL, 'D' );
1128
+	public function get_date($field_name, $format = NULL) {
1129
+		return $this->_get_datetime($field_name, $format, NULL, 'D');
1130 1130
 	}
1131 1131
 
1132 1132
 
@@ -1136,8 +1136,8 @@  discard block
 block discarded – undo
1136 1136
 	 * @param null $format
1137 1137
 	 * @throws \EE_Error
1138 1138
 	 */
1139
-	public function e_date( $field_name, $format = NULL ) {
1140
-		$this->_get_datetime( $field_name, $format, NULL, 'D', TRUE );
1139
+	public function e_date($field_name, $format = NULL) {
1140
+		$this->_get_datetime($field_name, $format, NULL, 'D', TRUE);
1141 1141
 	}
1142 1142
 
1143 1143
 
@@ -1150,8 +1150,8 @@  discard block
 block discarded – undo
1150 1150
 	 * @return string             datetime value formatted
1151 1151
 	 * @throws \EE_Error
1152 1152
 	 */
1153
-	public function get_time( $field_name, $format = NULL ) {
1154
-		return $this->_get_datetime( $field_name, NULL, $format, 'T' );
1153
+	public function get_time($field_name, $format = NULL) {
1154
+		return $this->_get_datetime($field_name, NULL, $format, 'T');
1155 1155
 	}
1156 1156
 
1157 1157
 
@@ -1161,8 +1161,8 @@  discard block
 block discarded – undo
1161 1161
 	 * @param null $format
1162 1162
 	 * @throws \EE_Error
1163 1163
 	 */
1164
-	public function e_time( $field_name, $format = NULL ) {
1165
-		$this->_get_datetime( $field_name, NULL, $format, 'T', TRUE );
1164
+	public function e_time($field_name, $format = NULL) {
1165
+		$this->_get_datetime($field_name, NULL, $format, 'T', TRUE);
1166 1166
 	}
1167 1167
 
1168 1168
 
@@ -1176,8 +1176,8 @@  discard block
 block discarded – undo
1176 1176
 	 * @return string             datetime value formatted
1177 1177
 	 * @throws \EE_Error
1178 1178
 	 */
1179
-	public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1180
-		return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt );
1179
+	public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1180
+		return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt);
1181 1181
 	}
1182 1182
 
1183 1183
 
@@ -1188,8 +1188,8 @@  discard block
 block discarded – undo
1188 1188
 	 * @param null $tm_frmt
1189 1189
 	 * @throws \EE_Error
1190 1190
 	 */
1191
-	public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1192
-		$this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1191
+	public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1192
+		$this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1193 1193
 	}
1194 1194
 
1195 1195
 
@@ -1203,12 +1203,12 @@  discard block
 block discarded – undo
1203 1203
 	 * @throws \EE_Error
1204 1204
 	 *                           field name.
1205 1205
 	 */
1206
-	public function get_i18n_datetime( $field_name, $format = NULL ) {
1207
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
1208
-		$format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format;
1206
+	public function get_i18n_datetime($field_name, $format = NULL) {
1207
+		EE_Registry::instance()->load_helper('DTT_Helper');
1208
+		$format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format;
1209 1209
 		return date_i18n(
1210 1210
 			$format,
1211
-			EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone )
1211
+			EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone)
1212 1212
 		);
1213 1213
 	}
1214 1214
 
@@ -1221,14 +1221,14 @@  discard block
 block discarded – undo
1221 1221
 	 * @throws EE_Error
1222 1222
 	 * @return EE_Datetime_Field
1223 1223
 	 */
1224
-	protected function _get_dtt_field_settings( $field_name ) {
1224
+	protected function _get_dtt_field_settings($field_name) {
1225 1225
 		$field = $this->get_model()->field_settings_for($field_name);
1226 1226
 
1227 1227
 		//check if field is dtt
1228
-		if ( $field instanceof EE_Datetime_Field ) {
1228
+		if ($field instanceof EE_Datetime_Field) {
1229 1229
 			return $field;
1230 1230
 		} else {
1231
-			throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) );
1231
+			throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this))));
1232 1232
 		}
1233 1233
 	}
1234 1234
 
@@ -1249,8 +1249,8 @@  discard block
 block discarded – undo
1249 1249
 	 * @param string          $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field)
1250 1250
 	 * @throws \EE_Error
1251 1251
 	 */
1252
-	protected function _set_time_for( $time, $fieldname ) {
1253
-		$this->_set_date_time( 'T', $time, $fieldname );
1252
+	protected function _set_time_for($time, $fieldname) {
1253
+		$this->_set_date_time('T', $time, $fieldname);
1254 1254
 	}
1255 1255
 
1256 1256
 
@@ -1263,8 +1263,8 @@  discard block
 block discarded – undo
1263 1263
 	 * @param string          $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field)
1264 1264
 	 * @throws \EE_Error
1265 1265
 	 */
1266
-	protected function _set_date_for( $date, $fieldname ) {
1267
-		$this->_set_date_time( 'D', $date, $fieldname );
1266
+	protected function _set_date_for($date, $fieldname) {
1267
+		$this->_set_date_time('D', $date, $fieldname);
1268 1268
 	}
1269 1269
 
1270 1270
 
@@ -1278,26 +1278,26 @@  discard block
 block discarded – undo
1278 1278
 	 * @param string          $fieldname      the name of the field the date OR time is being set on (must match a EE_Datetime_Field property)
1279 1279
 	 * @throws \EE_Error
1280 1280
 	 */
1281
-	protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) {
1282
-		$field = $this->_get_dtt_field_settings( $fieldname );
1283
-		$field->set_timezone( $this->_timezone );
1284
-		$field->set_date_format( $this->_dt_frmt );
1285
-		$field->set_time_format( $this->_tm_frmt );
1286
-		switch ( $what ) {
1281
+	protected function _set_date_time($what = 'T', $datetime_value, $fieldname) {
1282
+		$field = $this->_get_dtt_field_settings($fieldname);
1283
+		$field->set_timezone($this->_timezone);
1284
+		$field->set_date_format($this->_dt_frmt);
1285
+		$field->set_time_format($this->_tm_frmt);
1286
+		switch ($what) {
1287 1287
 			case 'T' :
1288
-				$this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_time(
1288
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_time(
1289 1289
 					$datetime_value,
1290
-					$this->_fields[ $fieldname ]
1290
+					$this->_fields[$fieldname]
1291 1291
 				);
1292 1292
 				break;
1293 1293
 			case 'D' :
1294
-				$this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_date(
1294
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_date(
1295 1295
 					$datetime_value,
1296
-					$this->_fields[ $fieldname ]
1296
+					$this->_fields[$fieldname]
1297 1297
 				);
1298 1298
 				break;
1299 1299
 			case 'B' :
1300
-				$this->_fields[ $fieldname ] = $field->prepare_for_set( $datetime_value );
1300
+				$this->_fields[$fieldname] = $field->prepare_for_set($datetime_value);
1301 1301
 				break;
1302 1302
 		}
1303 1303
 		$this->_clear_cached_property($fieldname);
@@ -1319,18 +1319,18 @@  discard block
 block discarded – undo
1319 1319
 	 * @throws EE_Error
1320 1320
 	 * @return string timestamp
1321 1321
 	 */
1322
-	public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) {
1322
+	public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') {
1323 1323
 		EE_Registry::instance()->load_helper('DTT_Helper');
1324 1324
 		$timezone = EEH_DTT_Helper::get_timezone();
1325
-		if ( $timezone === $this->_timezone ) {
1325
+		if ($timezone === $this->_timezone) {
1326 1326
 			return '';
1327 1327
 		}
1328 1328
 		$original_timezone = $this->_timezone;
1329
-		$this->set_timezone( $timezone );
1329
+		$this->set_timezone($timezone);
1330 1330
 
1331 1331
 		$fn = (array) $field_name;
1332
-		$args = array_merge( $fn, (array) $args );
1333
-		if ( ! method_exists( $this, $callback ) ) {
1332
+		$args = array_merge($fn, (array) $args);
1333
+		if ( ! method_exists($this, $callback)) {
1334 1334
 			throw new EE_Error(
1335 1335
 				sprintf(
1336 1336
 					__(
@@ -1342,9 +1342,9 @@  discard block
 block discarded – undo
1342 1342
 			);
1343 1343
 		}
1344 1344
 		$args = (array) $args;
1345
-		$return =  $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append;
1345
+		$return = $prepend.call_user_func_array(array($this, $callback), $args).$append;
1346 1346
 
1347
-		$this->set_timezone( $original_timezone );
1347
+		$this->set_timezone($original_timezone);
1348 1348
 		return $return;
1349 1349
 	}
1350 1350
 
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
 	 * @return boolean | int
1359 1359
 	 * @throws \EE_Error
1360 1360
 	 */
1361
-	public function delete(){
1361
+	public function delete() {
1362 1362
 		/**
1363 1363
 		 * Called just before the `EE_Base_Class::_delete` method call.
1364 1364
 		 * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions
@@ -1367,7 +1367,7 @@  discard block
 block discarded – undo
1367 1367
 		 *
1368 1368
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1369 1369
 		 */
1370
-		do_action( 'AHEE__EE_Base_Class__delete__before', $this );
1370
+		do_action('AHEE__EE_Base_Class__delete__before', $this);
1371 1371
 		$result = $this->_delete();
1372 1372
 		/**
1373 1373
 		 * Called just after the `EE_Base_Class::_delete` method call.
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1378 1378
 		 * @param boolean $result
1379 1379
 		 */
1380
-		do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result );
1380
+		do_action('AHEE__EE_Base_Class__delete__end', $this, $result);
1381 1381
 		return $result;
1382 1382
 	}
1383 1383
 
@@ -1403,22 +1403,22 @@  discard block
 block discarded – undo
1403 1403
 	 * @return bool | int
1404 1404
 	 * @throws \EE_Error
1405 1405
 	 */
1406
-	public function delete_permanently(){
1406
+	public function delete_permanently() {
1407 1407
 		/**
1408 1408
 		 * Called just before HARD deleting a model object
1409 1409
 		 *
1410 1410
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1411 1411
 		 */
1412
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this );
1413
-		$model=$this->get_model();
1414
-		$result=$model->delete_permanently_by_ID($this->ID());
1412
+		do_action('AHEE__EE_Base_Class__delete_permanently__before', $this);
1413
+		$model = $this->get_model();
1414
+		$result = $model->delete_permanently_by_ID($this->ID());
1415 1415
 		$this->refresh_cache_of_related_objects();
1416 1416
 		/**
1417 1417
 		 * Called just after HARD deleting a model object
1418 1418
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1419 1419
 		 * @param boolean $result
1420 1420
 		 */
1421
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result );
1421
+		do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result);
1422 1422
 		return $result;
1423 1423
 	}
1424 1424
 
@@ -1431,18 +1431,18 @@  discard block
 block discarded – undo
1431 1431
 	 * @throws \EE_Error
1432 1432
 	 */
1433 1433
         public function refresh_cache_of_related_objects() {
1434
-            foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1435
-                if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1436
-                    $related_objects = $this->_model_relations[ $relation_name ];
1437
-                    if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1434
+            foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1435
+                if ( ! empty($this->_model_relations[$relation_name])) {
1436
+                    $related_objects = $this->_model_relations[$relation_name];
1437
+                    if ($relation_obj instanceof EE_Belongs_To_Relation) {
1438 1438
                         //this relation only stores a single model object, not an array
1439 1439
                         //but let's make it consistent
1440
-                        $related_objects = array( $related_objects );
1440
+                        $related_objects = array($related_objects);
1441 1441
                     }
1442
-                    foreach( $related_objects as $related_object ) {
1442
+                    foreach ($related_objects as $related_object) {
1443 1443
                         //only refresh their cache if they're in memory
1444
-                        if( $related_object instanceof EE_Base_Class ) {
1445
-							$related_object->clear_cache( $this->get_model()->get_this_model_name(), $this );
1444
+                        if ($related_object instanceof EE_Base_Class) {
1445
+							$related_object->clear_cache($this->get_model()->get_this_model_name(), $this);
1446 1446
                         }
1447 1447
                     }
1448 1448
                 }
@@ -1462,17 +1462,17 @@  discard block
 block discarded – undo
1462 1462
 	 * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object
1463 1463
 	 * isn't allowed to persist (as determined by EE_Base_Class::allow_persist())
1464 1464
 	 */
1465
-	public function save($set_cols_n_values=array()) {
1465
+	public function save($set_cols_n_values = array()) {
1466 1466
 		/**
1467 1467
 		 * Filters the fields we're about to save on the model object
1468 1468
 		 *
1469 1469
 		 * @param array $set_cols_n_values
1470 1470
 		 * @param EE_Base_Class $model_object
1471 1471
 		 */
1472
-		$set_cols_n_values = (array)apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this  );
1472
+		$set_cols_n_values = (array) apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this);
1473 1473
 		//set attributes as provided in $set_cols_n_values
1474
-		foreach($set_cols_n_values as $column=>$value){
1475
-			$this->set($column,$value);
1474
+		foreach ($set_cols_n_values as $column=>$value) {
1475
+			$this->set($column, $value);
1476 1476
 		}
1477 1477
 		/**
1478 1478
 		 * Saving a model object.
@@ -1480,8 +1480,8 @@  discard block
 block discarded – undo
1480 1480
 		 * Before we perform a save, this action is fired.
1481 1481
 		 * @param EE_Base_Class $model_object the model object about to be saved.
1482 1482
 		 */
1483
-		do_action( 'AHEE__EE_Base_Class__save__begin', $this );
1484
-		if( ! $this->allow_persist() ) {
1483
+		do_action('AHEE__EE_Base_Class__save__begin', $this);
1484
+		if ( ! $this->allow_persist()) {
1485 1485
 			return 0;
1486 1486
 		}
1487 1487
 		//now get current attribute values
@@ -1491,61 +1491,61 @@  discard block
 block discarded – undo
1491 1491
 		$old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object();
1492 1492
 		$this->get_model()->assume_values_already_prepared_by_model_object(true);
1493 1493
 		//does this model have an autoincrement PK?
1494
-		if($this->get_model()->has_primary_key_field()){
1495
-			if($this->get_model()->get_primary_key_field()->is_auto_increment()){
1494
+		if ($this->get_model()->has_primary_key_field()) {
1495
+			if ($this->get_model()->get_primary_key_field()->is_auto_increment()) {
1496 1496
 				//ok check if it's set, if so: update; if not, insert
1497
-				if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){
1498
-					$results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() );
1497
+				if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) {
1498
+					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1499 1499
 				} else {
1500
-					unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]);
1501
-					$results = $this->get_model()->insert( $save_cols_n_values );
1502
-					if($results){
1500
+					unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]);
1501
+					$results = $this->get_model()->insert($save_cols_n_values);
1502
+					if ($results) {
1503 1503
 						//if successful, set the primary key
1504 1504
 						//but don't use the normal SET method, because it will check if
1505 1505
 						//an item with the same ID exists in the mapper & db, then
1506 1506
 						//will find it in the db (because we just added it) and THAT object
1507 1507
 						//will get added to the mapper before we can add this one!
1508 1508
 						//but if we just avoid using the SET method, all that headache can be avoided
1509
-						$pk_field_name =self::_get_primary_key_name( get_class($this));
1509
+						$pk_field_name = self::_get_primary_key_name(get_class($this));
1510 1510
 						$this->_fields[$pk_field_name] = $results;
1511 1511
 						$this->_clear_cached_property($pk_field_name);
1512
-						$this->get_model()->add_to_entity_map( $this );
1512
+						$this->get_model()->add_to_entity_map($this);
1513 1513
 						$this->_update_cached_related_model_objs_fks();
1514 1514
 					}
1515 1515
 				}
1516
-			}else{//PK is NOT auto-increment
1516
+			} else {//PK is NOT auto-increment
1517 1517
 				//so check if one like it already exists in the db
1518
-				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1519
-					if( WP_DEBUG && ! $this->in_entity_map() ){
1518
+				if ($this->get_model()->exists_by_ID($this->ID())) {
1519
+					if (WP_DEBUG && ! $this->in_entity_map()) {
1520 1520
 						throw new EE_Error(
1521 1521
 							sprintf(
1522
-								__( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ),
1522
+								__('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'),
1523 1523
 								get_class($this),
1524
-								get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
1525
-								get_class( $this->get_model() ) . '::instance()->get_one_by_ID()',
1524
+								get_class($this->get_model()).'::instance()->add_to_entity_map()',
1525
+								get_class($this->get_model()).'::instance()->get_one_by_ID()',
1526 1526
 								'<br />'
1527 1527
 							)
1528 1528
 						);
1529 1529
 					}
1530 1530
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1531
-				}else{
1531
+				} else {
1532 1532
 					$results = $this->get_model()->insert($save_cols_n_values);
1533 1533
 					$this->_update_cached_related_model_objs_fks();
1534 1534
 				}
1535 1535
 			}
1536
-		}else{//there is NO primary key
1536
+		} else {//there is NO primary key
1537 1537
 			$already_in_db = false;
1538
-			foreach($this->get_model()->unique_indexes() as $index){
1538
+			foreach ($this->get_model()->unique_indexes() as $index) {
1539 1539
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
1540
-				if($this->get_model()->exists(array($uniqueness_where_params))){
1540
+				if ($this->get_model()->exists(array($uniqueness_where_params))) {
1541 1541
 					$already_in_db = true;
1542 1542
 				}
1543 1543
 			}
1544
-			if( $already_in_db ){
1545
-				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1546
-				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1547
-			}else{
1548
-				$results = $this->get_model()->insert( $save_cols_n_values );
1544
+			if ($already_in_db) {
1545
+				$combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields());
1546
+				$results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values);
1547
+			} else {
1548
+				$results = $this->get_model()->insert($save_cols_n_values);
1549 1549
 			}
1550 1550
 		}
1551 1551
 		//restore the old assumption about values being prepared by the model object
@@ -1558,7 +1558,7 @@  discard block
 block discarded – undo
1558 1558
 		 * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted
1559 1559
 		 * the new ID (or 0 if an error occurred and it wasn't updated)
1560 1560
 		 */
1561
-		do_action( 'AHEE__EE_Base_Class__save__end', $this, $results );
1561
+		do_action('AHEE__EE_Base_Class__save__end', $this, $results);
1562 1562
 		return $results;
1563 1563
 	}
1564 1564
 
@@ -1573,15 +1573,15 @@  discard block
 block discarded – undo
1573 1573
 	 * @return void
1574 1574
 	 * @throws \EE_Error
1575 1575
 	 */
1576
-	protected function _update_cached_related_model_objs_fks(){
1577
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){
1578
-			if( $relation_obj instanceof EE_Has_Many_Relation ){
1579
-				foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) {
1576
+	protected function _update_cached_related_model_objs_fks() {
1577
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1578
+			if ($relation_obj instanceof EE_Has_Many_Relation) {
1579
+				foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) {
1580 1580
 					$fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to(
1581 1581
 						$this->get_model()->get_this_model_name()
1582 1582
 					);
1583
-					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() );
1584
-					if( $related_model_obj_in_cache->ID() ){
1583
+					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID());
1584
+					if ($related_model_obj_in_cache->ID()) {
1585 1585
 						$related_model_obj_in_cache->save();
1586 1586
 					}
1587 1587
 				}
@@ -1602,21 +1602,21 @@  discard block
 block discarded – undo
1602 1602
 	 * @return int ID of new model object on save; 0 on failure+
1603 1603
 	 * @throws \EE_Error
1604 1604
 	 */
1605
-	public function save_new_cached_related_model_objs(){
1605
+	public function save_new_cached_related_model_objs() {
1606 1606
 		//make sure this has been saved
1607
-		if( ! $this->ID()){
1607
+		if ( ! $this->ID()) {
1608 1608
 			$id = $this->save();
1609
-		}else{
1609
+		} else {
1610 1610
 			$id = $this->ID();
1611 1611
 		}
1612 1612
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
1613
-		foreach($this->get_model()->relation_settings() as $relationName => $relationObj){
1613
+		foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) {
1614 1614
 
1615 1615
 
1616
-			if($this->_model_relations[$relationName]){
1616
+			if ($this->_model_relations[$relationName]) {
1617 1617
 				//is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation)
1618 1618
 				//or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)?
1619
-				if($relationObj instanceof EE_Belongs_To_Relation){
1619
+				if ($relationObj instanceof EE_Belongs_To_Relation) {
1620 1620
 					//add a relation to that relation type (which saves the appropriate thing in the process)
1621 1621
 					//but ONLY if it DOES NOT exist in the DB
1622 1622
 					/* @var $related_model_obj EE_Base_Class */
@@ -1625,8 +1625,8 @@  discard block
 block discarded – undo
1625 1625
 						$this->_add_relation_to($related_model_obj, $relationName);
1626 1626
 						$related_model_obj->save_new_cached_related_model_objs();
1627 1627
 //					}
1628
-				}else{
1629
-					foreach($this->_model_relations[$relationName] as $related_model_obj){
1628
+				} else {
1629
+					foreach ($this->_model_relations[$relationName] as $related_model_obj) {
1630 1630
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1631 1631
 						//but ONLY if it DOES NOT exist in the DB
1632 1632
 //						if( ! $related_model_obj->ID()){
@@ -1647,8 +1647,8 @@  discard block
 block discarded – undo
1647 1647
 	 * @return \EEM_Base | \EEM_CPT_Base
1648 1648
 	 */
1649 1649
 	public function get_model() {
1650
-		$modelName = self::_get_model_classname( get_class($this) );
1651
-		return self::_get_model_instance_with_name($modelName, $this->_timezone );
1650
+		$modelName = self::_get_model_classname(get_class($this));
1651
+		return self::_get_model_instance_with_name($modelName, $this->_timezone);
1652 1652
 	}
1653 1653
 
1654 1654
 
@@ -1659,10 +1659,10 @@  discard block
 block discarded – undo
1659 1659
 	 * @return mixed bool|EE_Base_Class|EEM_CPT_Base
1660 1660
 	 * @throws \EE_Error
1661 1661
 	 */
1662
-	protected static function _get_object_from_entity_mapper($props_n_values, $classname){
1662
+	protected static function _get_object_from_entity_mapper($props_n_values, $classname) {
1663 1663
 		//TODO: will not work for Term_Relationships because they have no PK!
1664
-		$primary_id_ref = self::_get_primary_key_name( $classname );
1665
-		if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1664
+		$primary_id_ref = self::_get_primary_key_name($classname);
1665
+		if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) {
1666 1666
 			$id = $props_n_values[$primary_id_ref];
1667 1667
 			return self::_get_model($classname)->get_from_entity_map($id);
1668 1668
 		}
@@ -1683,37 +1683,37 @@  discard block
 block discarded – undo
1683 1683
 	 * @return mixed (EE_Base_Class|bool)
1684 1684
 	 * @throws \EE_Error
1685 1685
 	 */
1686
-	protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) {
1686
+	protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) {
1687 1687
 		$existing = null;
1688
-		if ( self::_get_model( $classname )->has_primary_key_field() ) {
1689
-			$primary_id_ref = self::_get_primary_key_name( $classname );
1690
-			if ( array_key_exists( $primary_id_ref, $props_n_values )
1691
-			     && ! empty( $props_n_values[ $primary_id_ref ] )
1688
+		if (self::_get_model($classname)->has_primary_key_field()) {
1689
+			$primary_id_ref = self::_get_primary_key_name($classname);
1690
+			if (array_key_exists($primary_id_ref, $props_n_values)
1691
+			     && ! empty($props_n_values[$primary_id_ref])
1692 1692
 			) {
1693
-				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID(
1694
-					$props_n_values[ $primary_id_ref ]
1693
+				$existing = self::_get_model($classname, $timezone)->get_one_by_ID(
1694
+					$props_n_values[$primary_id_ref]
1695 1695
 				);
1696 1696
 			}
1697
-		} elseif ( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ) {
1697
+		} elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) {
1698 1698
 			//no primary key on this model, but there's still a matching item in the DB
1699
-			$existing = self::_get_model( $classname, $timezone )->get_one_by_ID(
1700
-				self::_get_model( $classname, $timezone )->get_index_primary_key_string( $props_n_values )
1699
+			$existing = self::_get_model($classname, $timezone)->get_one_by_ID(
1700
+				self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values)
1701 1701
 			);
1702 1702
 		}
1703
-		if ( $existing ) {
1703
+		if ($existing) {
1704 1704
 
1705 1705
 			//set date formats if present before setting values
1706
-			if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
1707
-				$existing->set_date_format( $date_formats[0] );
1708
-				$existing->set_time_format( $date_formats[1] );
1706
+			if ( ! empty($date_formats) && is_array($date_formats)) {
1707
+				$existing->set_date_format($date_formats[0]);
1708
+				$existing->set_time_format($date_formats[1]);
1709 1709
 			} else {
1710 1710
 				//set default formats for date and time
1711
-				$existing->set_date_format( get_option( 'date_format' ) );
1712
-				$existing->set_time_format( get_option( 'time_format' ) );
1711
+				$existing->set_date_format(get_option('date_format'));
1712
+				$existing->set_time_format(get_option('time_format'));
1713 1713
 			}
1714 1714
 
1715
-			foreach ( $props_n_values as $property => $field_value ) {
1716
-				$existing->set( $property, $field_value );
1715
+			foreach ($props_n_values as $property => $field_value) {
1716
+				$existing->set($property, $field_value);
1717 1717
 			}
1718 1718
 			return $existing;
1719 1719
 		} else {
@@ -1731,9 +1731,9 @@  discard block
 block discarded – undo
1731 1731
 	 * @throws EE_Error
1732 1732
 	 * @return EEM_Base
1733 1733
 	 */
1734
-	protected static function  _get_model( $classname, $timezone = NULL ){
1734
+	protected static function  _get_model($classname, $timezone = NULL) {
1735 1735
 		//find model for this class
1736
-		if( ! $classname ){
1736
+		if ( ! $classname) {
1737 1737
 			throw new EE_Error(
1738 1738
 				sprintf(
1739 1739
 					__(
@@ -1744,8 +1744,8 @@  discard block
 block discarded – undo
1744 1744
 				)
1745 1745
 			);
1746 1746
 		}
1747
-		$modelName=self::_get_model_classname($classname);
1748
-		return self::_get_model_instance_with_name($modelName, $timezone );
1747
+		$modelName = self::_get_model_classname($classname);
1748
+		return self::_get_model_instance_with_name($modelName, $timezone);
1749 1749
 	}
1750 1750
 
1751 1751
 
@@ -1756,10 +1756,10 @@  discard block
 block discarded – undo
1756 1756
 	 * @param null   $timezone
1757 1757
 	 * @return EEM_Base
1758 1758
 	 */
1759
-	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){
1760
-		$model_classname = str_replace( 'EEM_', '', $model_classname );
1761
-		$model = EE_Registry::instance()->load_model( $model_classname );
1762
-		$model->set_timezone( $timezone );
1759
+	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) {
1760
+		$model_classname = str_replace('EEM_', '', $model_classname);
1761
+		$model = EE_Registry::instance()->load_model($model_classname);
1762
+		$model->set_timezone($timezone);
1763 1763
 		return $model;
1764 1764
 	}
1765 1765
 
@@ -1771,10 +1771,10 @@  discard block
 block discarded – undo
1771 1771
 	 * @param null $model_name
1772 1772
 	 * @return string like EEM_Attendee
1773 1773
 	 */
1774
-	private static function _get_model_classname( $model_name = null){
1775
-		if(strpos($model_name,"EE_")===0){
1776
-			$model_classname=str_replace("EE_","EEM_",$model_name);
1777
-		}else{
1774
+	private static function _get_model_classname($model_name = null) {
1775
+		if (strpos($model_name, "EE_") === 0) {
1776
+			$model_classname = str_replace("EE_", "EEM_", $model_name);
1777
+		} else {
1778 1778
 			$model_classname = "EEM_".$model_name;
1779 1779
 		}
1780 1780
 		return $model_classname;
@@ -1788,16 +1788,16 @@  discard block
 block discarded – undo
1788 1788
 	 * @throws EE_Error
1789 1789
 	 * @return string
1790 1790
 	 */
1791
-	protected static function _get_primary_key_name( $classname = NULL ){
1792
-		if( ! $classname){
1791
+	protected static function _get_primary_key_name($classname = NULL) {
1792
+		if ( ! $classname) {
1793 1793
 			throw new EE_Error(
1794 1794
 				sprintf(
1795
-					__( "What were you thinking calling _get_primary_key_name(%s)", "event_espresso" ),
1795
+					__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"),
1796 1796
 					$classname
1797 1797
 				)
1798 1798
 			);
1799 1799
 		}
1800
-		return self::_get_model( $classname )->get_primary_key_field()->get_name();
1800
+		return self::_get_model($classname)->get_primary_key_field()->get_name();
1801 1801
 	}
1802 1802
 
1803 1803
 
@@ -1811,12 +1811,12 @@  discard block
 block discarded – undo
1811 1811
 	 * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string
1812 1812
 	 * @throws \EE_Error
1813 1813
 	 */
1814
-	public function ID(){
1814
+	public function ID() {
1815 1815
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1816
-		if( $this->get_model()->has_primary_key_field() ) {
1817
-			return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ];
1818
-		}else{
1819
-			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1816
+		if ($this->get_model()->has_primary_key_field()) {
1817
+			return $this->_fields[self::_get_primary_key_name(get_class($this))];
1818
+		} else {
1819
+			return $this->get_model()->get_index_primary_key_string($this->_fields);
1820 1820
 		}
1821 1821
 	}
1822 1822
 
@@ -1834,38 +1834,38 @@  discard block
 block discarded – undo
1834 1834
 	 * @throws EE_Error
1835 1835
 	 * @return EE_Base_Class the object the relation was added to
1836 1836
 	 */
1837
-	public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){
1837
+	public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) {
1838 1838
 		//if this thing exists in the DB, save the relation to the DB
1839
-		if( $this->ID() ){
1840
-			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values );
1839
+		if ($this->ID()) {
1840
+			$otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values);
1841 1841
 			//clear cache so future get_many_related and get_first_related() return new results.
1842
-			$this->clear_cache( $relationName, $otherObject, TRUE );
1843
-                        if( $otherObject instanceof EE_Base_Class ) {
1844
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1842
+			$this->clear_cache($relationName, $otherObject, TRUE);
1843
+                        if ($otherObject instanceof EE_Base_Class) {
1844
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1845 1845
                         }
1846 1846
 		} else {
1847 1847
 			//this thing doesn't exist in the DB,  so just cache it
1848
-			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
1849
-				throw new EE_Error( sprintf(
1850
-					__( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ),
1848
+			if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) {
1849
+				throw new EE_Error(sprintf(
1850
+					__('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'),
1851 1851
 					$otherObjectModelObjectOrID,
1852
-					get_class( $this )
1852
+					get_class($this)
1853 1853
 				));
1854 1854
 			} else {
1855 1855
 				$otherObject = $otherObjectModelObjectOrID;
1856 1856
 			}
1857
-			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1857
+			$this->cache($relationName, $otherObjectModelObjectOrID, $cache_id);
1858 1858
 		}
1859
-                if( $otherObject instanceof EE_Base_Class ) {
1859
+                if ($otherObject instanceof EE_Base_Class) {
1860 1860
                     //fix the reciprocal relation too
1861
-                    if( $otherObject->ID() ) {
1861
+                    if ($otherObject->ID()) {
1862 1862
                             //its saved so assumed relations exist in the DB, so we can just
1863 1863
                             //clear the cache so future queries use the updated info in the DB
1864
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1864
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true);
1865 1865
                     } else {
1866 1866
 
1867 1867
                             //it's not saved, so it caches relations like this
1868
-                            $otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1868
+                            $otherObject->cache($this->get_model()->get_this_model_name(), $this);
1869 1869
                     }
1870 1870
                 }
1871 1871
 		return $otherObject;
@@ -1889,17 +1889,17 @@  discard block
 block discarded – undo
1889 1889
 	 * @return EE_Base_Class the relation was removed from
1890 1890
 	 * @throws \EE_Error
1891 1891
 	 */
1892
-	public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){
1893
-		if ( $this->ID() ) {
1892
+	public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) {
1893
+		if ($this->ID()) {
1894 1894
 			//if this exists in the DB, save the relation change to the DB too
1895
-			$otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query );
1896
-			$this->clear_cache( $relationName, $otherObject );
1895
+			$otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query);
1896
+			$this->clear_cache($relationName, $otherObject);
1897 1897
 		} else {
1898 1898
 			//this doesn't exist in the DB, just remove it from the cache
1899
-			$otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID );
1899
+			$otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID);
1900 1900
 		}
1901
-                if( $otherObject instanceof EE_Base_Class ) {
1902
-                    $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1901
+                if ($otherObject instanceof EE_Base_Class) {
1902
+                    $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1903 1903
                 }
1904 1904
 		return $otherObject;
1905 1905
 	}
@@ -1914,18 +1914,18 @@  discard block
 block discarded – undo
1914 1914
 	 * @return EE_Base_Class
1915 1915
 	 * @throws \EE_Error
1916 1916
 	 */
1917
-	public function _remove_relations($relationName,$where_query_params = array()){
1918
-		if ( $this->ID() ) {
1917
+	public function _remove_relations($relationName, $where_query_params = array()) {
1918
+		if ($this->ID()) {
1919 1919
 			//if this exists in the DB, save the relation change to the DB too
1920
-			$otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params );
1921
-			$this->clear_cache( $relationName, null, true );
1920
+			$otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params);
1921
+			$this->clear_cache($relationName, null, true);
1922 1922
 		} else {
1923 1923
 			//this doesn't exist in the DB, just remove it from the cache
1924
-			$otherObjects = $this->clear_cache( $relationName, null, true );
1924
+			$otherObjects = $this->clear_cache($relationName, null, true);
1925 1925
 		}
1926
-                if( is_array( $otherObjects ) ) {
1927
-                    foreach ( $otherObjects as $otherObject ) {
1928
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1926
+                if (is_array($otherObjects)) {
1927
+                    foreach ($otherObjects as $otherObject) {
1928
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1929 1929
                     }
1930 1930
                 }
1931 1931
 		return $otherObjects;
@@ -1945,27 +1945,27 @@  discard block
 block discarded – undo
1945 1945
 	 * @throws \EE_Error
1946 1946
 	 *                             or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs
1947 1947
 	 */
1948
-	public function get_many_related($relationName,$query_params = array()){
1949
-		if($this->ID()){
1948
+	public function get_many_related($relationName, $query_params = array()) {
1949
+		if ($this->ID()) {
1950 1950
 			//this exists in the DB, so get the related things from either the cache or the DB
1951 1951
 			//if there are query parameters, forget about caching the related model objects.
1952
-			if( $query_params ){
1952
+			if ($query_params) {
1953 1953
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1954
-			}else{
1954
+			} else {
1955 1955
 				//did we already cache the result of this query?
1956 1956
 				$cached_results = $this->get_all_from_cache($relationName);
1957
-				if ( ! $cached_results ){
1957
+				if ( ! $cached_results) {
1958 1958
 					$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1959 1959
 					//if no query parameters were passed, then we got all the related model objects
1960 1960
 					//for that relation. We can cache them then.
1961
-					foreach($related_model_objects as $related_model_object){
1961
+					foreach ($related_model_objects as $related_model_object) {
1962 1962
 						$this->cache($relationName, $related_model_object);
1963 1963
 					}
1964
-				}else{
1964
+				} else {
1965 1965
 					$related_model_objects = $cached_results;
1966 1966
 				}
1967 1967
 			}
1968
-		}else{
1968
+		} else {
1969 1969
 			//this doesn't exist in the DB, so just get the related things from the cache
1970 1970
 			$related_model_objects = $this->get_all_from_cache($relationName);
1971 1971
 		}
@@ -1983,8 +1983,8 @@  discard block
 block discarded – undo
1983 1983
 	 * @param bool   	$distinct       if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
1984 1984
 	 * @return int
1985 1985
 	 */
1986
-	public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1987
-		return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct);
1986
+	public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1987
+		return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct);
1988 1988
 	}
1989 1989
 
1990 1990
 
@@ -1998,7 +1998,7 @@  discard block
 block discarded – undo
1998 1998
 	 * 						By default, uses primary key (which doesn't make much sense, so you should probably change it)
1999 1999
 	 * @return int
2000 2000
 	 */
2001
-	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){
2001
+	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) {
2002 2002
 		return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum);
2003 2003
 	}
2004 2004
 
@@ -2012,33 +2012,33 @@  discard block
 block discarded – undo
2012 2012
 	 * @return EE_Base_Class (not an array, a single object)
2013 2013
 	 * @throws \EE_Error
2014 2014
 	 */
2015
-	public function get_first_related($relationName,$query_params = array()){
2016
-		if($this->ID()){//this exists in the DB, get from the cache OR the DB
2015
+	public function get_first_related($relationName, $query_params = array()) {
2016
+		if ($this->ID()) {//this exists in the DB, get from the cache OR the DB
2017 2017
 
2018 2018
 			//if they've provided some query parameters, don't bother trying to cache the result
2019 2019
 			//also make sure we're not caching the result of get_first_related
2020 2020
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
2021
-			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
2022
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
2023
-			}else{
2021
+			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
2022
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2023
+			} else {
2024 2024
 				//first, check if we've already cached the result of this query
2025 2025
 				$cached_result = $this->get_one_from_cache($relationName);
2026
-				if ( ! $cached_result ){
2026
+				if ( ! $cached_result) {
2027 2027
 
2028 2028
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2029
-					$this->cache($relationName,$related_model_object);
2030
-				}else{
2029
+					$this->cache($relationName, $related_model_object);
2030
+				} else {
2031 2031
 					$related_model_object = $cached_result;
2032 2032
 				}
2033 2033
 			}
2034
-		}else{
2034
+		} else {
2035 2035
 			$related_model_object = null;
2036 2036
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
2037
-			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
2038
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
2037
+			if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
2038
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2039 2039
 			}
2040 2040
 			//this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object
2041
-			if( ! $related_model_object){
2041
+			if ( ! $related_model_object) {
2042 2042
 				$related_model_object = $this->get_one_from_cache($relationName);
2043 2043
 			}
2044 2044
 
@@ -2060,12 +2060,12 @@  discard block
 block discarded – undo
2060 2060
 	 * @return int how many deleted
2061 2061
 	 * @throws \EE_Error
2062 2062
 	 */
2063
-	public function delete_related($relationName,$query_params = array()){
2064
-		if($this->ID()){
2065
-			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
2066
-		}else{
2063
+	public function delete_related($relationName, $query_params = array()) {
2064
+		if ($this->ID()) {
2065
+			$count = $this->get_model()->delete_related($this, $relationName, $query_params);
2066
+		} else {
2067 2067
 			$count = count($this->get_all_from_cache($relationName));
2068
-			$this->clear_cache($relationName,NULL,TRUE);
2068
+			$this->clear_cache($relationName, NULL, TRUE);
2069 2069
 		}
2070 2070
 		return $count;
2071 2071
 	}
@@ -2084,13 +2084,13 @@  discard block
 block discarded – undo
2084 2084
 	 * @return int how many deleted (including those soft deleted)
2085 2085
 	 * @throws \EE_Error
2086 2086
 	 */
2087
-	public function delete_related_permanently($relationName,$query_params = array()){
2088
-		if($this->ID()){
2089
-			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
2090
-		}else{
2087
+	public function delete_related_permanently($relationName, $query_params = array()) {
2088
+		if ($this->ID()) {
2089
+			$count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
2090
+		} else {
2091 2091
 			$count = count($this->get_all_from_cache($relationName));
2092 2092
 		}
2093
-		$this->clear_cache($relationName,NULL,TRUE);
2093
+		$this->clear_cache($relationName, NULL, TRUE);
2094 2094
 		return $count;
2095 2095
 	}
2096 2096
 
@@ -2106,7 +2106,7 @@  discard block
 block discarded – undo
2106 2106
 	 * @param  string $field_name property to check
2107 2107
 	 * @return bool            				  TRUE if existing,FALSE if not.
2108 2108
 	 */
2109
-	public function is_set( $field_name ) {
2109
+	public function is_set($field_name) {
2110 2110
 		return isset($this->_fields[$field_name]);
2111 2111
 	}
2112 2112
 
@@ -2118,11 +2118,11 @@  discard block
 block discarded – undo
2118 2118
 	 * @throws EE_Error
2119 2119
 	 * @return bool                              TRUE if existing, throw EE_Error if not.
2120 2120
 	 */
2121
-	protected function _property_exists( $properties ) {
2121
+	protected function _property_exists($properties) {
2122 2122
 
2123
-		foreach ( (array) $properties as $property_name ) {
2123
+		foreach ((array) $properties as $property_name) {
2124 2124
 			//first make sure this property exists
2125
-			if ( ! $this->_fields[ $property_name ] ) {
2125
+			if ( ! $this->_fields[$property_name]) {
2126 2126
 				throw new EE_Error(
2127 2127
 					sprintf(
2128 2128
 						__(
@@ -2150,7 +2150,7 @@  discard block
 block discarded – undo
2150 2150
 		$fields = $this->get_model()->field_settings(FALSE);
2151 2151
 		$properties = array();
2152 2152
 		//remove prepended underscore
2153
-		foreach ( $fields as $field_name => $settings ) {
2153
+		foreach ($fields as $field_name => $settings) {
2154 2154
 			$properties[$field_name] = $this->get($field_name);
2155 2155
 		}
2156 2156
 		return $properties;
@@ -2180,10 +2180,10 @@  discard block
 block discarded – undo
2180 2180
 	 * @throws EE_Error
2181 2181
 	 * @return mixed whatever the plugin which calls add_filter decides
2182 2182
 	 */
2183
-	public function __call($methodName,$args){
2184
-		$className=get_class($this);
2185
-		$tagName="FHEE__{$className}__{$methodName}";
2186
-		if ( ! has_filter( $tagName ) ) {
2183
+	public function __call($methodName, $args) {
2184
+		$className = get_class($this);
2185
+		$tagName = "FHEE__{$className}__{$methodName}";
2186
+		if ( ! has_filter($tagName)) {
2187 2187
 			throw new EE_Error(
2188 2188
 				sprintf(
2189 2189
 					__(
@@ -2196,7 +2196,7 @@  discard block
 block discarded – undo
2196 2196
 				)
2197 2197
 			);
2198 2198
 		}
2199
-		return apply_filters($tagName,null,$this,$args);
2199
+		return apply_filters($tagName, null, $this, $args);
2200 2200
 	}
2201 2201
 
2202 2202
 
@@ -2212,7 +2212,7 @@  discard block
 block discarded – undo
2212 2212
 	 * @throws \EE_Error
2213 2213
 	 * NOTE: if the values haven't changed, returns 0
2214 2214
 	 */
2215
-	public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){
2215
+	public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) {
2216 2216
 		$query_params = array(
2217 2217
 			array(
2218 2218
 				'EXM_key'  => $meta_key,
@@ -2220,17 +2220,17 @@  discard block
 block discarded – undo
2220 2220
 				'EXM_type' => $this->get_model()->get_this_model_name()
2221 2221
 			)
2222 2222
 		);
2223
-		if ( $previous_value !== null ) {
2223
+		if ($previous_value !== null) {
2224 2224
 			$query_params[0]['EXM_value'] = $meta_value;
2225 2225
 		}
2226
-		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all( $query_params );
2227
-		if ( ! $existing_rows_like_that ) {
2228
-			return $this->add_extra_meta( $meta_key, $meta_value );
2226
+		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params);
2227
+		if ( ! $existing_rows_like_that) {
2228
+			return $this->add_extra_meta($meta_key, $meta_value);
2229 2229
 		} else {
2230
-			foreach ( $existing_rows_like_that as $existing_row ) {
2231
-				$existing_row->save( array( 'EXM_value' => $meta_value ) );
2230
+			foreach ($existing_rows_like_that as $existing_row) {
2231
+				$existing_row->save(array('EXM_value' => $meta_value));
2232 2232
 			}
2233
-			return count( $existing_rows_like_that );
2233
+			return count($existing_rows_like_that);
2234 2234
 		}
2235 2235
 	}
2236 2236
 
@@ -2247,8 +2247,8 @@  discard block
 block discarded – undo
2247 2247
 	 * @return boolean
2248 2248
 	 * @throws \EE_Error
2249 2249
 	 */
2250
-	public function add_extra_meta($meta_key,$meta_value,$unique = false){
2251
-		if ( $unique ) {
2250
+	public function add_extra_meta($meta_key, $meta_value, $unique = false) {
2251
+		if ($unique) {
2252 2252
 			$existing_extra_meta = EEM_Extra_Meta::instance()->get_one(
2253 2253
 				array(
2254 2254
 					array(
@@ -2258,7 +2258,7 @@  discard block
 block discarded – undo
2258 2258
 					)
2259 2259
 				)
2260 2260
 			);
2261
-			if ( $existing_extra_meta ) {
2261
+			if ($existing_extra_meta) {
2262 2262
 				return false;
2263 2263
 			}
2264 2264
 		}
@@ -2285,7 +2285,7 @@  discard block
 block discarded – undo
2285 2285
 	 * @return int number of extra meta rows deleted
2286 2286
 	 * @throws \EE_Error
2287 2287
 	 */
2288
-	public function delete_extra_meta($meta_key,$meta_value = NULL){
2288
+	public function delete_extra_meta($meta_key, $meta_value = NULL) {
2289 2289
 		$query_params = array(
2290 2290
 			array(
2291 2291
 				'EXM_key'  => $meta_key,
@@ -2293,10 +2293,10 @@  discard block
 block discarded – undo
2293 2293
 				'EXM_type' => $this->get_model()->get_this_model_name()
2294 2294
 			)
2295 2295
 		);
2296
-		if ( $meta_value !== null ) {
2296
+		if ($meta_value !== null) {
2297 2297
 			$query_params[0]['EXM_value'] = $meta_value;
2298 2298
 		}
2299
-		return EEM_Extra_Meta::instance()->delete( $query_params );
2299
+		return EEM_Extra_Meta::instance()->delete($query_params);
2300 2300
 	}
2301 2301
 
2302 2302
 
@@ -2312,25 +2312,25 @@  discard block
 block discarded – undo
2312 2312
 	 * @return mixed single value if $single; array if ! $single
2313 2313
 	 * @throws \EE_Error
2314 2314
 	 */
2315
-	public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){
2316
-		if($single){
2317
-			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2318
-			if ( $result instanceof EE_Extra_Meta ){
2315
+	public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) {
2316
+		if ($single) {
2317
+			$result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2318
+			if ($result instanceof EE_Extra_Meta) {
2319 2319
 				return $result->value();
2320
-			}else{
2320
+			} else {
2321 2321
 				return $default;
2322 2322
 			}
2323
-		}else{
2324
-			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2325
-			if($results){
2323
+		} else {
2324
+			$results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2325
+			if ($results) {
2326 2326
 				$values = array();
2327
-				foreach($results as $result){
2328
-					if ( $result instanceof EE_Extra_Meta ){
2327
+				foreach ($results as $result) {
2328
+					if ($result instanceof EE_Extra_Meta) {
2329 2329
 						$values[$result->ID()] = $result->value();
2330 2330
 					}
2331 2331
 				}
2332 2332
 				return $values;
2333
-			}else{
2333
+			} else {
2334 2334
 				return $default;
2335 2335
 			}
2336 2336
 		}
@@ -2352,20 +2352,20 @@  discard block
 block discarded – undo
2352 2352
 	 * @return array
2353 2353
 	 * @throws \EE_Error
2354 2354
 	 */
2355
-	public function all_extra_meta_array($one_of_each_key = true){
2355
+	public function all_extra_meta_array($one_of_each_key = true) {
2356 2356
 		$return_array = array();
2357
-		if($one_of_each_key){
2357
+		if ($one_of_each_key) {
2358 2358
 			$extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key'));
2359
-			foreach($extra_meta_objs as $extra_meta_obj){
2360
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2359
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2360
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2361 2361
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2362 2362
 				}
2363 2363
 			}
2364
-		}else{
2364
+		} else {
2365 2365
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2366
-			foreach($extra_meta_objs as $extra_meta_obj){
2367
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2368
-					if( ! isset($return_array[$extra_meta_obj->key()])){
2366
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2367
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2368
+					if ( ! isset($return_array[$extra_meta_obj->key()])) {
2369 2369
 						$return_array[$extra_meta_obj->key()] = array();
2370 2370
 					}
2371 2371
 					$return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value();
@@ -2383,19 +2383,19 @@  discard block
 block discarded – undo
2383 2383
 	 * @return string
2384 2384
 	 * @throws \EE_Error
2385 2385
 	 */
2386
-	public function name(){
2386
+	public function name() {
2387 2387
 		//find a field that's not a text field
2388 2388
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2389
-		if($field_we_can_use){
2389
+		if ($field_we_can_use) {
2390 2390
 			return $this->get($field_we_can_use->get_name());
2391
-		}else{
2391
+		} else {
2392 2392
 			$first_few_properties = $this->model_field_array();
2393
-			$first_few_properties = array_slice($first_few_properties,0,3);
2393
+			$first_few_properties = array_slice($first_few_properties, 0, 3);
2394 2394
 			$name_parts = array();
2395
-			foreach( $first_few_properties as $name=> $value ){
2395
+			foreach ($first_few_properties as $name=> $value) {
2396 2396
 				$name_parts[] = "$name:$value";
2397 2397
 			}
2398
-			return implode(",",$name_parts);
2398
+			return implode(",", $name_parts);
2399 2399
 		}
2400 2400
 	}
2401 2401
 
@@ -2408,11 +2408,11 @@  discard block
 block discarded – undo
2408 2408
 	 * @return boolean
2409 2409
 	 * @throws \EE_Error
2410 2410
 	 */
2411
-	public function in_entity_map(){
2412
-		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2411
+	public function in_entity_map() {
2412
+		if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) {
2413 2413
 			//well, if we looked, did we find it in the entity map?
2414 2414
 			return TRUE;
2415
-		}else{
2415
+		} else {
2416 2416
 			return FALSE;
2417 2417
 		}
2418 2418
 	}
@@ -2423,21 +2423,21 @@  discard block
 block discarded – undo
2423 2423
 	 * @throws EE_Error if this model object isn't in the entity mapper (because then you should
2424 2424
 	 * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE
2425 2425
 	 */
2426
-	public function refresh_from_db(){
2427
-		if( $this->ID() && $this->in_entity_map() ){
2428
-			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2429
-		}else{
2426
+	public function refresh_from_db() {
2427
+		if ($this->ID() && $this->in_entity_map()) {
2428
+			$this->get_model()->refresh_entity_map_from_db($this->ID());
2429
+		} else {
2430 2430
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2431 2431
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2432 2432
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
2433 2433
 			//absolutely nothing in it for this ID
2434
-			if( WP_DEBUG ) {
2434
+			if (WP_DEBUG) {
2435 2435
 				throw new EE_Error(
2436 2436
 					sprintf(
2437
-						__( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ),
2437
+						__('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'),
2438 2438
 						$this->ID(),
2439
-						get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
2440
-						get_class( $this->get_model() ) . '::instance()->refresh_entity_map()'
2439
+						get_class($this->get_model()).'::instance()->add_to_entity_map()',
2440
+						get_class($this->get_model()).'::instance()->refresh_entity_map()'
2441 2441
 					)
2442 2442
 				);
2443 2443
 			}
@@ -2451,11 +2451,11 @@  discard block
 block discarded – undo
2451 2451
 	 * (probably a bad assumption they have made, oh well)
2452 2452
 	 * @return string
2453 2453
 	 */
2454
-	public function __toString(){
2454
+	public function __toString() {
2455 2455
 		try {
2456
-			return sprintf( '%s (%s)', $this->name(), $this->ID() );
2457
-		} catch ( Exception $e ) {
2458
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
2456
+			return sprintf('%s (%s)', $this->name(), $this->ID());
2457
+		} catch (Exception $e) {
2458
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
2459 2459
 			return '';
2460 2460
 		}
2461 2461
 	}
@@ -2491,16 +2491,16 @@  discard block
 block discarded – undo
2491 2491
 	 * @throws \EE_Error
2492 2492
 	 */
2493 2493
 	public function __sleep() {
2494
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
2495
-			if( $relation_obj instanceof EE_Belongs_To_Relation ) {
2496
-				$classname = 'EE_' . $this->get_model()->get_this_model_name();
2497
-				if( $this->get_one_from_cache( $relation_name ) instanceof $classname &&
2498
-						$this->get_one_from_cache( $relation_name )->ID() ) {
2499
-					$this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() );
2494
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
2495
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
2496
+				$classname = 'EE_'.$this->get_model()->get_this_model_name();
2497
+				if ($this->get_one_from_cache($relation_name) instanceof $classname &&
2498
+						$this->get_one_from_cache($relation_name)->ID()) {
2499
+					$this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID());
2500 2500
 				}
2501 2501
 			}
2502 2502
 		}
2503
-		return array_keys( get_object_vars( $this ) );
2503
+		return array_keys(get_object_vars($this));
2504 2504
 	}
2505 2505
 
2506 2506
 
Please login to merge, or discard this patch.
Braces   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
171 171
 			if($relation_obj instanceof EE_Belongs_To_Relation){
172 172
 				$this->_model_relations[$relation_name] = NULL;
173
-			}else{
173
+			} else{
174 174
 				$this->_model_relations[$relation_name] = array();
175 175
 			}
176 176
 		}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
217 217
 				$field_settings = $this->get_model()->field_settings_for( $field_name )){
218 218
 			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
219
-		}else{
219
+		} else{
220 220
 			return NULL;
221 221
 		}
222 222
 	}
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 						: $this->set( $field_name, $this->_fields[$field_name] );
274 274
 				}
275 275
 
276
-			}else{
276
+			} else{
277 277
 				$this->_fields[$field_name] = $holder_of_value;
278 278
 			}
279 279
 
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 			}
305 305
 			//let's unset any cache for this field_name from the $_cached_properties property.
306 306
 			$this->_clear_cached_property( $field_name );
307
-		}else{
307
+		} else{
308 308
 			throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name  ) );
309 309
 		}
310 310
 
@@ -653,10 +653,10 @@  discard block
 block discarded – undo
653 653
 		if($clear_all){
654 654
 			$obj_removed = true;
655 655
 			$this->_model_relations[$relationName]  = null;
656
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
656
+		} elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
657 657
 			$obj_removed = $this->_model_relations[$relationName];
658 658
 			$this->_model_relations[$relationName]  = null;
659
-		}else{
659
+		} else{
660 660
 			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
661 661
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
662 662
 				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
@@ -676,20 +676,20 @@  discard block
 block discarded – undo
676 676
 					}
677 677
 					if($index_found_at){
678 678
 						$index_in_cache = $index_found_at;
679
-					}else{
679
+					} else{
680 680
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
681 681
 						//if it wasn't in it to begin with. So we're done
682 682
 						return $object_to_remove_or_index_into_array;
683 683
 					}
684 684
 				}
685
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
685
+			} elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
686 686
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
687 687
 				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
688 688
 					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
689 689
 						$index_in_cache = $index;
690 690
 					}
691 691
 				}
692
-			}else{
692
+			} else{
693 693
 				$index_in_cache = $object_to_remove_or_index_into_array;
694 694
 			}
695 695
 			//supposedly we've found it. But it could just be that the client code
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 		$cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null;
760 760
 		if(is_array($cached_array_or_object)){
761 761
 			return array_shift($cached_array_or_object);
762
-		}else{
762
+		} else{
763 763
 			return $cached_array_or_object;
764 764
 		}
765 765
 	}
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 				if( $model_object->ID() ){
791 791
 					$model->add_to_entity_map( $model_object );
792 792
 				}
793
-			}else{
793
+			} else{
794 794
 				throw new EE_Error(
795 795
 					sprintf(
796 796
 						__(
@@ -925,10 +925,10 @@  discard block
 block discarded – undo
925 925
 				if( $field_obj->is_nullable()){
926 926
 					//if the field allows nulls, then let it be null
927 927
 					$field_value = NULL;
928
-				}else{
928
+				} else{
929 929
 					$field_value = $field_obj->get_default_value();
930 930
 				}
931
-			}else{
931
+			} else{
932 932
 				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
933 933
 			}
934 934
 			$this->_fields[$field_name] = $field_value;
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
 						$this->_update_cached_related_model_objs_fks();
1514 1514
 					}
1515 1515
 				}
1516
-			}else{//PK is NOT auto-increment
1516
+			} else{//PK is NOT auto-increment
1517 1517
 				//so check if one like it already exists in the db
1518 1518
 				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1519 1519
 					if( WP_DEBUG && ! $this->in_entity_map() ){
@@ -1528,12 +1528,12 @@  discard block
 block discarded – undo
1528 1528
 						);
1529 1529
 					}
1530 1530
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1531
-				}else{
1531
+				} else{
1532 1532
 					$results = $this->get_model()->insert($save_cols_n_values);
1533 1533
 					$this->_update_cached_related_model_objs_fks();
1534 1534
 				}
1535 1535
 			}
1536
-		}else{//there is NO primary key
1536
+		} else{//there is NO primary key
1537 1537
 			$already_in_db = false;
1538 1538
 			foreach($this->get_model()->unique_indexes() as $index){
1539 1539
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 			if( $already_in_db ){
1545 1545
 				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1546 1546
 				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1547
-			}else{
1547
+			} else{
1548 1548
 				$results = $this->get_model()->insert( $save_cols_n_values );
1549 1549
 			}
1550 1550
 		}
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
 		//make sure this has been saved
1607 1607
 		if( ! $this->ID()){
1608 1608
 			$id = $this->save();
1609
-		}else{
1609
+		} else{
1610 1610
 			$id = $this->ID();
1611 1611
 		}
1612 1612
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 						$this->_add_relation_to($related_model_obj, $relationName);
1626 1626
 						$related_model_obj->save_new_cached_related_model_objs();
1627 1627
 //					}
1628
-				}else{
1628
+				} else{
1629 1629
 					foreach($this->_model_relations[$relationName] as $related_model_obj){
1630 1630
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1631 1631
 						//but ONLY if it DOES NOT exist in the DB
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 	private static function _get_model_classname( $model_name = null){
1775 1775
 		if(strpos($model_name,"EE_")===0){
1776 1776
 			$model_classname=str_replace("EE_","EEM_",$model_name);
1777
-		}else{
1777
+		} else{
1778 1778
 			$model_classname = "EEM_".$model_name;
1779 1779
 		}
1780 1780
 		return $model_classname;
@@ -1815,7 +1815,7 @@  discard block
 block discarded – undo
1815 1815
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1816 1816
 		if( $this->get_model()->has_primary_key_field() ) {
1817 1817
 			return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ];
1818
-		}else{
1818
+		} else{
1819 1819
 			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1820 1820
 		}
1821 1821
 	}
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
 			//if there are query parameters, forget about caching the related model objects.
1952 1952
 			if( $query_params ){
1953 1953
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1954
-			}else{
1954
+			} else{
1955 1955
 				//did we already cache the result of this query?
1956 1956
 				$cached_results = $this->get_all_from_cache($relationName);
1957 1957
 				if ( ! $cached_results ){
@@ -1961,11 +1961,11 @@  discard block
 block discarded – undo
1961 1961
 					foreach($related_model_objects as $related_model_object){
1962 1962
 						$this->cache($relationName, $related_model_object);
1963 1963
 					}
1964
-				}else{
1964
+				} else{
1965 1965
 					$related_model_objects = $cached_results;
1966 1966
 				}
1967 1967
 			}
1968
-		}else{
1968
+		} else{
1969 1969
 			//this doesn't exist in the DB, so just get the related things from the cache
1970 1970
 			$related_model_objects = $this->get_all_from_cache($relationName);
1971 1971
 		}
@@ -2020,18 +2020,18 @@  discard block
 block discarded – undo
2020 2020
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
2021 2021
 			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
2022 2022
 				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
2023
-			}else{
2023
+			} else{
2024 2024
 				//first, check if we've already cached the result of this query
2025 2025
 				$cached_result = $this->get_one_from_cache($relationName);
2026 2026
 				if ( ! $cached_result ){
2027 2027
 
2028 2028
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2029 2029
 					$this->cache($relationName,$related_model_object);
2030
-				}else{
2030
+				} else{
2031 2031
 					$related_model_object = $cached_result;
2032 2032
 				}
2033 2033
 			}
2034
-		}else{
2034
+		} else{
2035 2035
 			$related_model_object = null;
2036 2036
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
2037 2037
 			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
@@ -2063,7 +2063,7 @@  discard block
 block discarded – undo
2063 2063
 	public function delete_related($relationName,$query_params = array()){
2064 2064
 		if($this->ID()){
2065 2065
 			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
2066
-		}else{
2066
+		} else{
2067 2067
 			$count = count($this->get_all_from_cache($relationName));
2068 2068
 			$this->clear_cache($relationName,NULL,TRUE);
2069 2069
 		}
@@ -2087,7 +2087,7 @@  discard block
 block discarded – undo
2087 2087
 	public function delete_related_permanently($relationName,$query_params = array()){
2088 2088
 		if($this->ID()){
2089 2089
 			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
2090
-		}else{
2090
+		} else{
2091 2091
 			$count = count($this->get_all_from_cache($relationName));
2092 2092
 		}
2093 2093
 		$this->clear_cache($relationName,NULL,TRUE);
@@ -2317,10 +2317,10 @@  discard block
 block discarded – undo
2317 2317
 			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2318 2318
 			if ( $result instanceof EE_Extra_Meta ){
2319 2319
 				return $result->value();
2320
-			}else{
2320
+			} else{
2321 2321
 				return $default;
2322 2322
 			}
2323
-		}else{
2323
+		} else{
2324 2324
 			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2325 2325
 			if($results){
2326 2326
 				$values = array();
@@ -2330,7 +2330,7 @@  discard block
 block discarded – undo
2330 2330
 					}
2331 2331
 				}
2332 2332
 				return $values;
2333
-			}else{
2333
+			} else{
2334 2334
 				return $default;
2335 2335
 			}
2336 2336
 		}
@@ -2361,7 +2361,7 @@  discard block
 block discarded – undo
2361 2361
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2362 2362
 				}
2363 2363
 			}
2364
-		}else{
2364
+		} else{
2365 2365
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2366 2366
 			foreach($extra_meta_objs as $extra_meta_obj){
2367 2367
 				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2389 2389
 		if($field_we_can_use){
2390 2390
 			return $this->get($field_we_can_use->get_name());
2391
-		}else{
2391
+		} else{
2392 2392
 			$first_few_properties = $this->model_field_array();
2393 2393
 			$first_few_properties = array_slice($first_few_properties,0,3);
2394 2394
 			$name_parts = array();
@@ -2412,7 +2412,7 @@  discard block
 block discarded – undo
2412 2412
 		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2413 2413
 			//well, if we looked, did we find it in the entity map?
2414 2414
 			return TRUE;
2415
-		}else{
2415
+		} else{
2416 2416
 			return FALSE;
2417 2417
 		}
2418 2418
 	}
@@ -2426,7 +2426,7 @@  discard block
 block discarded – undo
2426 2426
 	public function refresh_from_db(){
2427 2427
 		if( $this->ID() && $this->in_entity_map() ){
2428 2428
 			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2429
-		}else{
2429
+		} else{
2430 2430
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2431 2431
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2432 2432
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
Please login to merge, or discard this patch.
core/business/EE_Transaction_Processor.class.php 1 patch
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 
4 4
 /**
5 5
  * Class EE_Transaction_Processor
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	 * @param array $registration_query_params
53 53
 	 *@return EE_Transaction_Processor instance
54 54
 	 */
55
-	public static function instance( $registration_query_params = array() ) {
55
+	public static function instance($registration_query_params = array()) {
56 56
 		// check if class object is instantiated
57
-		if ( ! self::$_instance instanceof EE_Transaction_Processor ) {
58
-			self::$_instance = new self( $registration_query_params );
57
+		if ( ! self::$_instance instanceof EE_Transaction_Processor) {
58
+			self::$_instance = new self($registration_query_params);
59 59
 		}
60 60
 		return self::$_instance;
61 61
 	}
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 * @param array $registration_query_params
67 67
 	 * @return EE_Transaction_Processor
68 68
 	 */
69
-	private function __construct( $registration_query_params = array() ) {
69
+	private function __construct($registration_query_params = array()) {
70 70
 		// make sure some query params are set for retrieving registrations
71
-		$this->_set_registration_query_params( $registration_query_params );
71
+		$this->_set_registration_query_params($registration_query_params);
72 72
 	}
73 73
 
74 74
 
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	 * @access private
78 78
 	 * @param array $registration_query_params
79 79
 	 */
80
-	private function _set_registration_query_params( $registration_query_params ) {
81
-		$this->_registration_query_params = ! empty( $registration_query_params ) ? $registration_query_params : array( 'order_by' => array( 'REG_count' => 'ASC' ));
80
+	private function _set_registration_query_params($registration_query_params) {
81
+		$this->_registration_query_params = ! empty($registration_query_params) ? $registration_query_params : array('order_by' => array('REG_count' => 'ASC'));
82 82
 	}
83 83
 
84 84
 
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 	/**
96 96
 	 * @param string $old_txn_status
97 97
 	 */
98
-	public function set_old_txn_status( $old_txn_status ) {
98
+	public function set_old_txn_status($old_txn_status) {
99 99
 		// only set the first time
100
-		if ( $this->_old_txn_status === null ) {
100
+		if ($this->_old_txn_status === null) {
101 101
 			$this->_old_txn_status = $old_txn_status;
102 102
 		}
103 103
 	}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	/**
117 117
 	 * @param string $new_txn_status
118 118
 	 */
119
-	public function set_new_txn_status( $new_txn_status ) {
119
+	public function set_new_txn_status($new_txn_status) {
120 120
 		$this->_new_txn_status = $new_txn_status;
121 121
 	}
122 122
 
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
 	 * @param bool   $check_all
148 148
 	 * @return boolean | int
149 149
 	 */
150
-	private function _reg_steps_completed( EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE ) {
150
+	private function _reg_steps_completed(EE_Transaction $transaction, $reg_step_slug = '', $check_all = TRUE) {
151 151
 		$reg_steps = $transaction->reg_steps();
152
-		if ( ! is_array( $reg_steps ) || empty( $reg_steps )) {
152
+		if ( ! is_array($reg_steps) || empty($reg_steps)) {
153 153
 			return false;
154 154
 		}
155 155
 		// loop thru reg steps array)
156
-		foreach ( $reg_steps as $slug => $reg_step_completed ) {
156
+		foreach ($reg_steps as $slug => $reg_step_completed) {
157 157
 			// if NOT checking ALL steps (only checking one step)
158
-			if ( ! $check_all ) {
158
+			if ( ! $check_all) {
159 159
 				// and this is the one
160
-				if ( $slug === $reg_step_slug ) {
160
+				if ($slug === $reg_step_slug) {
161 161
 					return $reg_step_completed;
162 162
 				} else {
163 163
 					// skip to next reg step in loop
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 				}
166 166
 			}
167 167
 			// $check_all must be true, else we would never have gotten to this point
168
-			if ( $slug === $reg_step_slug ) {
168
+			if ($slug === $reg_step_slug) {
169 169
 				// if we reach this point, then we are testing either:
170 170
 				// all_reg_steps_completed_except() or
171 171
 				// all_reg_steps_completed_except_final_step(),
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 				// ie: "is everything completed except the final step?"
175 175
 				// "that is correct... the final step is not completed, but all others are."
176 176
 				return $reg_step_completed !== true ? true : false;
177
-			} else if ( $reg_step_completed !== true ) {
177
+			} else if ($reg_step_completed !== true) {
178 178
 				// if any reg step is NOT completed, then ALL steps are not completed
179 179
 				return false;
180 180
 			}
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 	 * @param EE_Transaction $transaction
196 196
 	 * @return boolean
197 197
 	 */
198
-	public function all_reg_steps_completed( EE_Transaction $transaction ) {
199
-		return $this->_reg_steps_completed( $transaction );
198
+	public function all_reg_steps_completed(EE_Transaction $transaction) {
199
+		return $this->_reg_steps_completed($transaction);
200 200
 	}
201 201
 
202 202
 
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	 * @param string $exception
214 214
 	 * @return boolean
215 215
 	 */
216
-	public function all_reg_steps_completed_except( EE_Transaction $transaction, $exception = '' ) {
217
-		return $this->_reg_steps_completed( $transaction, $exception );
216
+	public function all_reg_steps_completed_except(EE_Transaction $transaction, $exception = '') {
217
+		return $this->_reg_steps_completed($transaction, $exception);
218 218
 	}
219 219
 
220 220
 
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 	 * @param EE_Transaction $transaction
231 231
 	 * @return boolean
232 232
 	 */
233
-	public function all_reg_steps_completed_except_final_step( EE_Transaction $transaction ) {
234
-		return $this->_reg_steps_completed( $transaction, 'finalize_registration' );
233
+	public function all_reg_steps_completed_except_final_step(EE_Transaction $transaction) {
234
+		return $this->_reg_steps_completed($transaction, 'finalize_registration');
235 235
 	}
236 236
 
237 237
 
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param string $reg_step_slug
249 249
 	 * @return boolean | int
250 250
 	 */
251
-	public function reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) {
252
-		return $this->_reg_steps_completed( $transaction, $reg_step_slug, FALSE );
251
+	public function reg_step_completed(EE_Transaction $transaction, $reg_step_slug) {
252
+		return $this->_reg_steps_completed($transaction, $reg_step_slug, FALSE);
253 253
 	}
254 254
 
255 255
 
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	 * @param EE_Transaction $transaction
266 266
 	 * @return boolean | int
267 267
 	 */
268
-	public function final_reg_step_completed( EE_Transaction $transaction ) {
269
-		return $this->_reg_steps_completed( $transaction, 'finalize_registration', FALSE );
268
+	public function final_reg_step_completed(EE_Transaction $transaction) {
269
+		return $this->_reg_steps_completed($transaction, 'finalize_registration', FALSE);
270 270
 	}
271 271
 
272 272
 
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @return boolean
282 282
 	 * @throws \EE_Error
283 283
 	 */
284
-	public function set_reg_step_initiated( EE_Transaction $transaction, $reg_step_slug ) {
285
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, time() );
284
+	public function set_reg_step_initiated(EE_Transaction $transaction, $reg_step_slug) {
285
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, time());
286 286
 	}
287 287
 
288 288
 
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 * @return boolean
298 298
 	 * @throws \EE_Error
299 299
 	 */
300
-	public function set_reg_step_completed( EE_Transaction $transaction, $reg_step_slug ) {
301
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, true );
300
+	public function set_reg_step_completed(EE_Transaction $transaction, $reg_step_slug) {
301
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, true);
302 302
 	}
303 303
 
304 304
 
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 	 * @return boolean
314 314
 	 * @throws \EE_Error
315 315
 	 */
316
-	public function set_reg_step_not_completed( EE_Transaction $transaction, $reg_step_slug ) {
317
-		return $this->_set_reg_step_completed_status( $transaction, $reg_step_slug, false );
316
+	public function set_reg_step_not_completed(EE_Transaction $transaction, $reg_step_slug) {
317
+		return $this->_set_reg_step_completed_status($transaction, $reg_step_slug, false);
318 318
 	}
319 319
 
320 320
 
@@ -330,37 +330,37 @@  discard block
 block discarded – undo
330 330
 	 * @return boolean
331 331
 	 * @throws \EE_Error
332 332
 	 */
333
-	private function _set_reg_step_completed_status( EE_Transaction $transaction, $reg_step_slug, $status ) {
333
+	private function _set_reg_step_completed_status(EE_Transaction $transaction, $reg_step_slug, $status) {
334 334
 		// validate status
335
-		$status = is_bool( $status ) || is_int( $status ) ? $status : false;
335
+		$status = is_bool($status) || is_int($status) ? $status : false;
336 336
 		// get reg steps array
337 337
 		$txn_reg_steps = $transaction->reg_steps();
338 338
 		// if reg step does NOT exist
339
-		if ( ! isset( $txn_reg_steps[ $reg_step_slug ] )) {
339
+		if ( ! isset($txn_reg_steps[$reg_step_slug])) {
340 340
 			return false;
341 341
 		}
342 342
 		// if  we're trying to complete a step that is already completed
343
-		if ( $txn_reg_steps[ $reg_step_slug ] === true ) {
343
+		if ($txn_reg_steps[$reg_step_slug] === true) {
344 344
 			return true;
345 345
 		}
346 346
 		// if  we're trying to complete a step that hasn't even started
347
-		if ( $status === true && $txn_reg_steps[ $reg_step_slug ] === false ) {
347
+		if ($status === true && $txn_reg_steps[$reg_step_slug] === false) {
348 348
 			return false;
349 349
 		}
350 350
 		// if current status value matches the incoming value (no change)
351 351
 		// type casting as int means values should collapse to either 0, 1, or a timestamp like 1234567890
352
-		if ( (int)$txn_reg_steps[ $reg_step_slug ] === (int)$status ) {
352
+		if ((int) $txn_reg_steps[$reg_step_slug] === (int) $status) {
353 353
 			// this will happen in cases where multiple AJAX requests occur during the same step
354 354
 			return true;
355 355
 		}
356 356
 		// if we're trying to set a start time, but it has already been set...
357
-		if ( is_numeric( $status ) && is_numeric( $txn_reg_steps[ $reg_step_slug ] )) {
357
+		if (is_numeric($status) && is_numeric($txn_reg_steps[$reg_step_slug])) {
358 358
 			// skip the update below, but don't return FALSE so that errors won't be displayed
359 359
 			return true;
360 360
 		}
361 361
 		// update completed status
362
-		$txn_reg_steps[ $reg_step_slug ] = $status;
363
-		$transaction->set_reg_steps( $txn_reg_steps );
362
+		$txn_reg_steps[$reg_step_slug] = $status;
363
+		$transaction->set_reg_steps($txn_reg_steps);
364 364
 		$transaction->save();
365 365
 		// DEBUG LOG
366 366
 		//$this->log(
@@ -386,11 +386,11 @@  discard block
 block discarded – undo
386 386
 	 * @param string $reg_step_slug
387 387
 	 * @return void
388 388
 	 */
389
-	public function remove_reg_step( EE_Transaction $transaction, $reg_step_slug ) {
389
+	public function remove_reg_step(EE_Transaction $transaction, $reg_step_slug) {
390 390
 		// get reg steps array
391 391
 		$txn_reg_steps = $transaction->reg_steps();
392
-		unset( $txn_reg_steps[ $reg_step_slug ] );
393
-		$transaction->set_reg_steps( $txn_reg_steps );
392
+		unset($txn_reg_steps[$reg_step_slug]);
393
+		$transaction->set_reg_steps($txn_reg_steps);
394 394
 	}
395 395
 
396 396
 
@@ -405,15 +405,15 @@  discard block
 block discarded – undo
405 405
 	 * @return    boolean
406 406
 	 * @throws \EE_Error
407 407
 	 */
408
-	public function toggle_failed_transaction_status( EE_Transaction $transaction ) {
408
+	public function toggle_failed_transaction_status(EE_Transaction $transaction) {
409 409
 		$existing_txn_status = $transaction->status_ID();
410 410
 		// set incoming TXN_Status
411
-		$this->set_old_txn_status( $existing_txn_status );
411
+		$this->set_old_txn_status($existing_txn_status);
412 412
 		// if TXN status is still set as "failed"...
413
-		if ( $existing_txn_status === EEM_Transaction::failed_status_code ) {
413
+		if ($existing_txn_status === EEM_Transaction::failed_status_code) {
414 414
 			// set incoming TXN_Status
415
-			$this->set_new_txn_status( EEM_Transaction::abandoned_status_code );
416
-			$transaction->set_status( EEM_Transaction::abandoned_status_code );
415
+			$this->set_new_txn_status(EEM_Transaction::abandoned_status_code);
416
+			$transaction->set_status(EEM_Transaction::abandoned_status_code);
417 417
 			$transaction->save();
418 418
 			return TRUE;
419 419
 		}
@@ -430,27 +430,27 @@  discard block
 block discarded – undo
430 430
 	 * @param  EE_Transaction $transaction
431 431
 	 * @return boolean
432 432
 	 */
433
-	public function toggle_abandoned_transaction_status( EE_Transaction $transaction ) {
433
+	public function toggle_abandoned_transaction_status(EE_Transaction $transaction) {
434 434
 		// set incoming TXN_Status
435
-		$this->set_old_txn_status( $transaction->status_ID() );
435
+		$this->set_old_txn_status($transaction->status_ID());
436 436
 		// if TXN status has not been updated already due to a payment, and is still set as "failed" or "abandoned"...
437 437
 		$txn_status = $transaction->status_ID();
438 438
 		if (
439 439
 			$txn_status === EEM_Transaction::failed_status_code
440 440
 			|| $txn_status === EEM_Transaction::abandoned_status_code
441 441
 		) {
442
-			$this->set_new_txn_status( EEM_Transaction::incomplete_status_code );
442
+			$this->set_new_txn_status(EEM_Transaction::incomplete_status_code);
443 443
 			// if a contact record for the primary registrant has been created
444 444
 			if (
445 445
 				$transaction->primary_registration() instanceof EE_Registration
446 446
 				&& $transaction->primary_registration()->attendee() instanceof EE_Attendee
447 447
 			) {
448
-				$transaction->set_status( EEM_Transaction::incomplete_status_code );
449
-				$this->set_new_txn_status( EEM_Transaction::incomplete_status_code );
448
+				$transaction->set_status(EEM_Transaction::incomplete_status_code);
449
+				$this->set_new_txn_status(EEM_Transaction::incomplete_status_code);
450 450
 			} else {
451 451
 				// no contact record? yer abandoned!
452
-				$transaction->set_status( EEM_Transaction::abandoned_status_code );
453
-				$this->set_new_txn_status( EEM_Transaction::abandoned_status_code );
452
+				$transaction->set_status(EEM_Transaction::abandoned_status_code);
453
+				$this->set_new_txn_status(EEM_Transaction::abandoned_status_code);
454 454
 			}
455 455
 			return TRUE;
456 456
 		}
@@ -483,10 +483,10 @@  discard block
 block discarded – undo
483 483
 		);
484 484
 		// send messages
485 485
 		/** @type EE_Registration_Processor $registration_processor */
486
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
486
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
487 487
 		$registration_processor->trigger_registration_update_notifications(
488 488
 			$transaction->primary_registration(),
489
-			array( 'manually_updated' 	=> true )
489
+			array('manually_updated' 	=> true)
490 490
 		);
491 491
 		do_action(
492 492
 			'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
@@ -573,16 +573,16 @@  discard block
 block discarded – undo
573 573
 		$registration_query_params = array()
574 574
 	) {
575 575
 		// set incoming TXN_Status, and consider it new since old status should have been set
576
-		$this->set_new_txn_status( $transaction->status_ID() );
577
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()' );
576
+		$this->set_new_txn_status($transaction->status_ID());
577
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $transaction->status_ID(), '$transaction->status_ID()');
578 578
 		// make sure some query params are set for retrieving registrations
579
-		$this->_set_registration_query_params( $registration_query_params );
579
+		$this->_set_registration_query_params($registration_query_params);
580 580
 		// get final reg step status
581
-		$finalized = $this->final_reg_step_completed( $transaction );
581
+		$finalized = $this->final_reg_step_completed($transaction);
582 582
 		// if the 'finalize_registration' step has been initiated (has a timestamp)
583 583
 		// but has not yet been fully completed (TRUE)
584
-		if ( is_int( $finalized ) && $finalized !== false && $finalized !== true ) {
585
-			$this->set_reg_step_completed( $transaction, 'finalize_registration' );
584
+		if (is_int($finalized) && $finalized !== false && $finalized !== true) {
585
+			$this->set_reg_step_completed($transaction, 'finalize_registration');
586 586
 			$finalized = true;
587 587
 		}
588 588
 		$transaction->save();
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 
606 606
 		// send messages
607 607
 		/** @type EE_Registration_Processor $registration_processor */
608
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
608
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
609 609
 		$registration_processor->trigger_registration_update_notifications(
610 610
 			$transaction->primary_registration(),
611 611
 			$update_params
@@ -641,22 +641,22 @@  discard block
 block discarded – undo
641 641
 	) {
642 642
 		$response = false;
643 643
 		/** @type EE_Registration_Processor $registration_processor */
644
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
644
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
645 645
 		// check that method exists
646
-		if ( ! method_exists( $registration_processor, $method_name )) {
647
-			throw new EE_Error( __( 'Method does not exist.', 'event_espresso' ));
646
+		if ( ! method_exists($registration_processor, $method_name)) {
647
+			throw new EE_Error(__('Method does not exist.', 'event_espresso'));
648 648
 		}
649 649
 		// make sure some query params are set for retrieving registrations
650
-		$this->_set_registration_query_params( $registration_query_params );
650
+		$this->_set_registration_query_params($registration_query_params);
651 651
 		// loop through cached registrations
652
-		foreach ( $transaction->registrations( $this->_registration_query_params ) as $registration ) {
653
-			if ( $registration instanceof EE_Registration ) {
654
-				if ( $additional_param ) {
655
-					$response = $registration_processor->{$method_name}( $registration, $additional_param )
652
+		foreach ($transaction->registrations($this->_registration_query_params) as $registration) {
653
+			if ($registration instanceof EE_Registration) {
654
+				if ($additional_param) {
655
+					$response = $registration_processor->{$method_name}($registration, $additional_param)
656 656
 						? true
657 657
 						: $response;
658 658
 				} else {
659
-					$response = $registration_processor->{$method_name}( $registration )
659
+					$response = $registration_processor->{$method_name}($registration)
660 660
 						? true
661 661
 						: $response;
662 662
 				}
@@ -683,28 +683,28 @@  discard block
 block discarded – undo
683 683
 	public function set_transaction_payment_method_based_on_registration_statuses(
684 684
 		EE_Registration $edited_registration
685 685
 	) {
686
-		if ( $edited_registration instanceof EE_Registration ) {
686
+		if ($edited_registration instanceof EE_Registration) {
687 687
 			$transaction = $edited_registration->transaction();
688
-			if ( $transaction instanceof EE_Transaction ) {
688
+			if ($transaction instanceof EE_Transaction) {
689 689
 				$all_not_approved = true;
690
-				foreach ( $transaction->registrations() as $registration ) {
691
-					if ( $registration instanceof EE_Registration ) {
690
+				foreach ($transaction->registrations() as $registration) {
691
+					if ($registration instanceof EE_Registration) {
692 692
 						// if any REG != "Not Approved" then toggle to false
693 693
 						$all_not_approved = $registration->is_not_approved() ? $all_not_approved : false;
694 694
 					}
695 695
 				}
696 696
 				// if ALL Registrations are "Not Approved"
697
-				if ( $all_not_approved ) {
698
-					$transaction->set_payment_method_ID( null );
697
+				if ($all_not_approved) {
698
+					$transaction->set_payment_method_ID(null);
699 699
 					$transaction->save();
700 700
 				} else {
701 701
 					$available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
702 702
 						$transaction,
703 703
 						EEM_Payment_Method::scope_cart
704 704
 					);
705
-					if ( ! empty( $available_payment_methods ) ) {
705
+					if ( ! empty($available_payment_methods)) {
706 706
 						$PMD_ID = 0;
707
-						foreach ( $available_payment_methods as $available_payment_method ) {
707
+						foreach ($available_payment_methods as $available_payment_method) {
708 708
 							if (
709 709
 								$available_payment_method instanceof EE_Payment_Method
710 710
 							    && $available_payment_method->open_by_default()
@@ -713,22 +713,22 @@  discard block
 block discarded – undo
713 713
 								break;
714 714
 							}
715 715
 						}
716
-						if ( ! $PMD_ID ) {
717
-							$first_payment_method = reset( $available_payment_methods );
718
-							if ( $first_payment_method instanceof EE_Payment_Method ) {
716
+						if ( ! $PMD_ID) {
717
+							$first_payment_method = reset($available_payment_methods);
718
+							if ($first_payment_method instanceof EE_Payment_Method) {
719 719
 								$PMD_ID = $first_payment_method->ID();
720 720
 							} else {
721 721
 								EE_Error::add_error(
722
-									__( 'A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso' ),
722
+									__('A valid Payment Method could not be determined. Please ensure that at least one Payment Method is activated.', 'event_espresso'),
723 723
 									__FILE__, __LINE__, __FUNCTION__
724 724
 								);
725 725
 							}
726 726
 						}
727
-						$transaction->set_payment_method_ID( $PMD_ID );
727
+						$transaction->set_payment_method_ID($PMD_ID);
728 728
 						$transaction->save();
729 729
 					} else {
730 730
 						EE_Error::add_error(
731
-							__( 'Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso' ),
731
+							__('Please activate at least one Payment Method in order for things to operate correctly.', 'event_espresso'),
732 732
 							__FILE__, __LINE__, __FUNCTION__
733 733
 						);
734 734
 					}
Please login to merge, or discard this patch.
core/business/EE_Registration_Processor.class.php 1 patch
Spacing   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
-EE_Registry::instance()->load_class( 'Processor_Base' );
2
+EE_Registry::instance()->load_class('Processor_Base');
3 3
 
4 4
 /**
5 5
  * Class EE_Registration_Processor
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public static function instance() {
62 62
 		// check if class object is instantiated
63
-		if ( ! self::$_instance instanceof EE_Registration_Processor ) {
63
+		if ( ! self::$_instance instanceof EE_Registration_Processor) {
64 64
 			self::$_instance = new self();
65 65
 		}
66 66
 		return self::$_instance;
@@ -96,37 +96,37 @@  discard block
 block discarded – undo
96 96
 	 * @return \EE_Registration | null
97 97
 	 * @throws \EE_Error
98 98
 	 */
99
-	public function generate_ONE_registration_from_line_item( EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1 ) {
99
+	public function generate_ONE_registration_from_line_item(EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1) {
100 100
 		// grab the related ticket object for this line_item
101 101
 		$ticket = $line_item->ticket();
102
-		if ( ! $ticket instanceof EE_Ticket ) {
103
-			EE_Error::add_error( sprintf( __( "Line item %s did not contain a valid ticket", "event_espresso" ), $line_item->ID() ), __FILE__, __FUNCTION__, __LINE__ );
102
+		if ( ! $ticket instanceof EE_Ticket) {
103
+			EE_Error::add_error(sprintf(__("Line item %s did not contain a valid ticket", "event_espresso"), $line_item->ID()), __FILE__, __FUNCTION__, __LINE__);
104 104
 			return null;
105 105
 		}
106
-		$first_datetime = $ticket->get_first_related( 'Datetime' );
107
-		if ( ! $first_datetime instanceof EE_Datetime ) {
108
-			EE_Error::add_error( sprintf( __( "The ticket (%s) is not associated with any valid datetimes.", "event_espresso" ), $ticket->name() ), __FILE__, __FUNCTION__, __LINE__ );
106
+		$first_datetime = $ticket->get_first_related('Datetime');
107
+		if ( ! $first_datetime instanceof EE_Datetime) {
108
+			EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with any valid datetimes.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__);
109 109
 			return null;
110 110
 		}
111
-		$event = $first_datetime->get_first_related( 'Event' );
112
-		if ( ! $event instanceof EE_Event ) {
113
-			EE_Error::add_error( sprintf( __( "The ticket (%s) is not associated with a valid event.", "event_espresso" ), $ticket->name() ), __FILE__, __FUNCTION__, __LINE__ );
111
+		$event = $first_datetime->get_first_related('Event');
112
+		if ( ! $event instanceof EE_Event) {
113
+			EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with a valid event.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__);
114 114
 			return null;
115 115
 		}
116
-		$reg_url_link = $this->generate_reg_url_link( $att_nmbr, $line_item );
116
+		$reg_url_link = $this->generate_reg_url_link($att_nmbr, $line_item);
117 117
 
118
-		if( $this->_reg_final_price_per_tkt_line_item === null ) {
119
-			$this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() );
118
+		if ($this->_reg_final_price_per_tkt_line_item === null) {
119
+			$this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item());
120 120
 		}
121 121
 		//ok now find this new registration's final price
122
-		if( isset( $this->_reg_final_price_per_tkt_line_item[ $line_item->ID() ] ) ) {
123
-			$final_price = $this->_reg_final_price_per_tkt_line_item[ $line_item->ID() ] ;
124
-		}else{
125
-			$message = sprintf( __( 'The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso' ), $line_item->ID() );
126
-			if( WP_DEBUG ){
127
-				throw new EE_Error( $message );
128
-			}else{
129
-				EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message );
122
+		if (isset($this->_reg_final_price_per_tkt_line_item[$line_item->ID()])) {
123
+			$final_price = $this->_reg_final_price_per_tkt_line_item[$line_item->ID()];
124
+		} else {
125
+			$message = sprintf(__('The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso'), $line_item->ID());
126
+			if (WP_DEBUG) {
127
+				throw new EE_Error($message);
128
+			} else {
129
+				EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message);
130 130
 			}
131 131
 			$final_price = $ticket->get_ticket_total_with_taxes();
132 132
 
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 				'REG_url_link'    => $reg_url_link
147 147
 			)
148 148
 		);
149
-		$registration->set_reg_code( $this->generate_reg_code( $registration ) );
149
+		$registration->set_reg_code($this->generate_reg_code($registration));
150 150
 		$registration->save();
151
-		$registration->_add_relation_to( $event, 'Event', array(), $event->ID() );
152
-		$registration->_add_relation_to( $line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID() );
153
-		$transaction->_add_relation_to( $registration, 'Registration' );
151
+		$registration->_add_relation_to($event, 'Event', array(), $event->ID());
152
+		$registration->_add_relation_to($line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID());
153
+		$transaction->_add_relation_to($registration, 'Registration');
154 154
 		return $registration;
155 155
 	}
156 156
 
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 	 * @param EE_Line_Item | string $item
164 164
 	 * @return string
165 165
 	 */
166
-	public function generate_reg_url_link( $att_nmbr, $item ) {
166
+	public function generate_reg_url_link($att_nmbr, $item) {
167 167
 		$reg_url_link = $item instanceof EE_Line_Item ? $item->code() : $item;
168
-		$reg_url_link = $att_nmbr . '-' . md5( $reg_url_link . microtime() );
168
+		$reg_url_link = $att_nmbr.'-'.md5($reg_url_link.microtime());
169 169
 		return $reg_url_link;
170 170
 	}
171 171
 
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
 	 * @param \EE_Registration $registration
178 178
 	 * @return string
179 179
 	 */
180
-	public function generate_reg_code( EE_Registration $registration ) {
180
+	public function generate_reg_code(EE_Registration $registration) {
181 181
 	// figure out where to start parsing the reg code
182
-		$chars = strpos( $registration->reg_url_link(), '-' ) + 5;
182
+		$chars = strpos($registration->reg_url_link(), '-') + 5;
183 183
 		// TXN_ID + TKT_ID + first 3 and last 3 chars of reg_url_link
184 184
 		$new_reg_code = array(
185 185
 			$registration->transaction_ID(),
186 186
 			$registration->ticket_ID(),
187
-			substr( $registration->reg_url_link(), 0, $chars )
187
+			substr($registration->reg_url_link(), 0, $chars)
188 188
 		);
189 189
 		// now put it all together
190
-		$new_reg_code = implode( '-', $new_reg_code );
191
-		return apply_filters( 'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration );
190
+		$new_reg_code = implode('-', $new_reg_code);
191
+		return apply_filters('FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration);
192 192
 	}
193 193
 
194 194
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param int $REG_ID
198 198
 	 * @return string
199 199
 	 */
200
-	public function old_reg_status( $REG_ID ) {
201
-		return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null;
200
+	public function old_reg_status($REG_ID) {
201
+		return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null;
202 202
 	}
203 203
 
204 204
 
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
 	 * @param int $REG_ID
208 208
 	 * @param string $old_reg_status
209 209
 	 */
210
-	public function set_old_reg_status( $REG_ID, $old_reg_status ) {
210
+	public function set_old_reg_status($REG_ID, $old_reg_status) {
211 211
 		// only set the first time
212
-		if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) {
213
-			$this->_old_reg_status[ $REG_ID ] = $old_reg_status;
212
+		if ( ! isset($this->_old_reg_status[$REG_ID])) {
213
+			$this->_old_reg_status[$REG_ID] = $old_reg_status;
214 214
 		}
215 215
 	}
216 216
 
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 	 * @param int $REG_ID
221 221
 	 * @return string
222 222
 	 */
223
-	public function new_reg_status( $REG_ID ) {
224
-		return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null;
223
+	public function new_reg_status($REG_ID) {
224
+		return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null;
225 225
 	}
226 226
 
227 227
 
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 	 * @param int $REG_ID
231 231
 	 * @param string $new_reg_status
232 232
 	 */
233
-	public function set_new_reg_status( $REG_ID, $new_reg_status ) {
234
-		$this->_new_reg_status[ $REG_ID ] = $new_reg_status;
233
+	public function set_new_reg_status($REG_ID, $new_reg_status) {
234
+		$this->_new_reg_status[$REG_ID] = $new_reg_status;
235 235
 	}
236 236
 
237 237
 
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
 	 * @param int $REG_ID
243 243
 	 * @return bool
244 244
 	 */
245
-	public function reg_status_updated( $REG_ID ) {
246
-		return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false;
245
+	public function reg_status_updated($REG_ID) {
246
+		return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false;
247 247
 	}
248 248
 
249 249
 
@@ -257,19 +257,19 @@  discard block
 block discarded – undo
257 257
 	 * @param bool 	$save TRUE will save the registration if the status is updated, FALSE will leave that up to client code
258 258
 	 * 	@return boolean
259 259
 	 */
260
-	public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) {
260
+	public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) {
261 261
 		// set initial REG_Status
262
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
262
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
263 263
 		// set incoming REG_Status
264
-		$this->set_new_reg_status( $registration->ID(), $new_reg_status );
264
+		$this->set_new_reg_status($registration->ID(), $new_reg_status);
265 265
 		// toggle reg status but only if it has changed and the user can do so
266 266
 		if (
267
-			$this->reg_status_updated( $registration->ID() ) &&
268
-			EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() )
267
+			$this->reg_status_updated($registration->ID()) &&
268
+			EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID())
269 269
 		) {
270 270
 			// change status to new value
271
-			if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) )) {
272
-				if ( $save ) {
271
+			if ($registration->set_status($this->new_reg_status($registration->ID()))) {
272
+				if ($save) {
273 273
 					$registration->save();
274 274
 				}
275 275
 			}
@@ -290,30 +290,30 @@  discard block
 block discarded – undo
290 290
 	 * @return void
291 291
 	 * @throws \EE_Error
292 292
 	 */
293
-	public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) {
293
+	public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) {
294 294
 		$existing_reg_status = $registration->status_ID();
295 295
 		// set initial REG_Status
296
-		$this->set_old_reg_status( $registration->ID(), $existing_reg_status );
296
+		$this->set_old_reg_status($registration->ID(), $existing_reg_status);
297 297
 		// is the registration currently incomplete ?
298
-		if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) {
298
+		if ($registration->status_ID() === EEM_Registration::status_id_incomplete) {
299 299
 			// grab default reg status for the event, if set
300 300
 			$event_default_registration_status = $registration->event()->default_registration_status();
301 301
 			// if no default reg status is set for the event, then use the global value
302
-			$STS_ID = ! empty( $event_default_registration_status )
302
+			$STS_ID = ! empty($event_default_registration_status)
303 303
 				? $event_default_registration_status
304 304
 				: EE_Registry::instance()->CFG->registration->default_STS_ID;
305 305
 			// if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered
306 306
 			$STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID;
307 307
 			// set incoming REG_Status
308
-			$this->set_new_reg_status( $registration->ID(), $STS_ID );
309
-			$registration->set_status( $STS_ID );
310
-			if ( $save ) {
308
+			$this->set_new_reg_status($registration->ID(), $STS_ID);
309
+			$registration->set_status($STS_ID);
310
+			if ($save) {
311 311
 				$registration->save();
312 312
 			}
313 313
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
314
-			if ( ! EE_Processor_Base::$IPN ) {
314
+			if ( ! EE_Processor_Base::$IPN) {
315 315
 				// otherwise, send out notifications
316
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
316
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
317 317
 			}
318 318
 			// DEBUG LOG
319 319
 			//$this->log(
@@ -337,25 +337,25 @@  discard block
 block discarded – undo
337 337
 	 * @param bool 	$save TRUE will save the registration if the status is updated, FALSE will leave that up to client code
338 338
 	 * @return boolean
339 339
 	 */
340
-	public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) {
340
+	public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) {
341 341
 		// set initial REG_Status
342
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
342
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
343 343
 		// if not already, toggle reg status to approved IF the event default reg status is approved
344 344
 		if (
345 345
 			$registration->status_ID() !== EEM_Registration::status_id_approved &&
346 346
 			$registration->event()->default_registration_status() == EEM_Registration::status_id_approved
347 347
 		) {
348 348
 			// set incoming REG_Status
349
-			$this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved );
349
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
350 350
 			// toggle status to approved
351
-			$registration->set_status( EEM_Registration::status_id_approved );
352
-			if ( $save ) {
351
+			$registration->set_status(EEM_Registration::status_id_approved);
352
+			if ($save) {
353 353
 				$registration->save();
354 354
 			}
355 355
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
356
-			if ( ! EE_Processor_Base::$IPN ) {
356
+			if ( ! EE_Processor_Base::$IPN) {
357 357
 				// otherwise, send out notifications
358
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
358
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
359 359
 			}
360 360
 			// DEBUG LOG
361 361
 			//$this->log(
@@ -383,19 +383,19 @@  discard block
 block discarded – undo
383 383
 	 * @return bool
384 384
 	 * @throws \EE_Error
385 385
 	 */
386
-	public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) {
386
+	public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) {
387 387
 		// set initial REG_Status
388
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
388
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
389 389
 		//EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ );
390 390
 		// was a payment just made ?
391 391
 		if (
392
-			isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) &&
393
-			$additional_details[ 'payment_updates' ] &&
394
-			$additional_details[ 'last_payment' ] instanceof EE_Payment
392
+			isset($additional_details['payment_updates'], $additional_details['last_payment']) &&
393
+			$additional_details['payment_updates'] &&
394
+			$additional_details['last_payment'] instanceof EE_Payment
395 395
 		) {
396
-			$payment = $additional_details[ 'last_payment' ];
396
+			$payment = $additional_details['last_payment'];
397 397
 			$total_paid = 0;
398
-			foreach ( self::$_amount_paid as $reg => $amount_paid ) {
398
+			foreach (self::$_amount_paid as $reg => $amount_paid) {
399 399
 				$total_paid += $amount_paid;
400 400
 			}
401 401
 		} else {
@@ -419,30 +419,30 @@  discard block
 block discarded – undo
419 419
 					$registration->transaction()->is_completed() ||
420 420
 					$registration->transaction()->is_overpaid() ||
421 421
 					$registration->transaction()->is_free() ||
422
-					apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration )
422
+					apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration)
423 423
 				) || (
424 424
 					$payment instanceof EE_Payment &&
425 425
 					$payment->is_approved() &&
426 426
 					// this specific registration has not yet been paid for
427
-					! isset( self::$_amount_paid[ $registration->ID() ] ) &&
427
+					! isset(self::$_amount_paid[$registration->ID()]) &&
428 428
 					// payment amount, less what we have already attributed to other registrations, is greater than this reg's final price
429 429
 					$payment->amount() - $total_paid >= $registration->final_price()
430 430
 				)
431 431
 			)
432 432
 		) {
433 433
 			// mark as paid
434
-			self::$_amount_paid[ $registration->ID() ] = $registration->final_price();
434
+			self::$_amount_paid[$registration->ID()] = $registration->final_price();
435 435
 			// track new REG_Status
436
-			$this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved );
436
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
437 437
 			// toggle status to approved
438
-			$registration->set_status( EEM_Registration::status_id_approved );
439
-			if ( $save ) {
438
+			$registration->set_status(EEM_Registration::status_id_approved);
439
+			if ($save) {
440 440
 				$registration->save();
441 441
 			}
442 442
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
443
-			if ( ! EE_Processor_Base::$IPN ) {
443
+			if ( ! EE_Processor_Base::$IPN) {
444 444
 				// otherwise, send out notifications
445
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
445
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
446 446
 			}
447 447
 			// DEBUG LOG
448 448
 			//$this->log(
@@ -468,20 +468,20 @@  discard block
 block discarded – undo
468 468
 	 * @param array 	$additional_details
469 469
 	 * @return void
470 470
 	 */
471
-	public function trigger_registration_update_notifications( $registration, $additional_details = array() ) {
471
+	public function trigger_registration_update_notifications($registration, $additional_details = array()) {
472 472
 		try {
473
-			if ( ! $registration instanceof EE_Registration ) {
474
-				throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) );
473
+			if ( ! $registration instanceof EE_Registration) {
474
+				throw new EE_Error(__('An invalid registration was received.', 'event_espresso'));
475 475
 			}
476
-			EE_Registry::instance()->load_helper( 'Debug_Tools' );
477
-			EEH_Debug_Tools::log( __CLASS__, __FUNCTION__, __LINE__, array( $registration->transaction(), $additional_details ), false, 'EE_Transaction: ' . $registration->transaction()->ID() );
476
+			EE_Registry::instance()->load_helper('Debug_Tools');
477
+			EEH_Debug_Tools::log(__CLASS__, __FUNCTION__, __LINE__, array($registration->transaction(), $additional_details), false, 'EE_Transaction: '.$registration->transaction()->ID());
478 478
 			do_action(
479 479
 				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
480 480
 				$registration,
481 481
 				$additional_details
482 482
 			);
483
-		} catch( Exception $e ) {
484
-			EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() );
483
+		} catch (Exception $e) {
484
+			EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine());
485 485
 		}
486 486
 	}
487 487
 
@@ -494,18 +494,18 @@  discard block
 block discarded – undo
494 494
 	 * @param array 	$additional_details
495 495
 	 * @return bool
496 496
 	 */
497
-	public function update_registration_after_checkout_or_payment(  EE_Registration $registration, $additional_details = array() ) {
497
+	public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) {
498 498
 		// set initial REG_Status
499
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
499
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
500 500
 
501 501
 		// if the registration status gets updated, then save the registration
502
-		if ( $this->toggle_registration_status_for_default_approved_events( $registration, false ) || $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details )) {
502
+		if ($this->toggle_registration_status_for_default_approved_events($registration, false) || $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details)) {
503 503
 			$registration->save();
504 504
 		}
505 505
 
506 506
 		// set new  REG_Status
507
-		$this->set_new_reg_status( $registration->ID(), $registration->status_ID() );
508
-		return $this->reg_status_updated( $registration->ID() ) && $this->new_reg_status( $registration->ID() ) == EEM_Registration::status_id_approved ? true : false;
507
+		$this->set_new_reg_status($registration->ID(), $registration->status_ID());
508
+		return $this->reg_status_updated($registration->ID()) && $this->new_reg_status($registration->ID()) == EEM_Registration::status_id_approved ? true : false;
509 509
 	}
510 510
 
511 511
 	/**
@@ -515,19 +515,19 @@  discard block
 block discarded – undo
515 515
 	 * @param boolean $save_regs whether to immediately save registrations in this function or not
516 516
 	 * @return void
517 517
 	 */
518
-	public function update_registration_final_prices( $transaction, $save_regs = true ) {
519
-		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() );
520
-		foreach( $transaction->registrations() as $registration ) {
521
-			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration );
522
-			if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) {
523
-				$registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] );
524
-				if( $save_regs ) {
518
+	public function update_registration_final_prices($transaction, $save_regs = true) {
519
+		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item());
520
+		foreach ($transaction->registrations() as $registration) {
521
+			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration);
522
+			if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) {
523
+				$registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]);
524
+				if ($save_regs) {
525 525
 					$registration->save();
526 526
 				}
527 527
 			}
528 528
 		}
529 529
 		//and make sure there's no rounding problem
530
-		$this->fix_reg_final_price_rounding_issue( $transaction );
530
+		$this->fix_reg_final_price_rounding_issue($transaction);
531 531
 	}
532 532
 
533 533
 	/**
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	 * @param EE_Transaction $transaction
544 544
 	 * @return boolean success verifying that there is NO difference after this method is done
545 545
 	 */
546
-	public function fix_reg_final_price_rounding_issue( $transaction ) {
546
+	public function fix_reg_final_price_rounding_issue($transaction) {
547 547
 		$reg_final_price_sum = EEM_Registration::instance()->sum(
548 548
 			array(
549 549
 				array(
@@ -552,9 +552,9 @@  discard block
 block discarded – undo
552 552
 			),
553 553
 			'REG_final_price'
554 554
 		);
555
-		$diff =  $transaction->total() - floatval( $reg_final_price_sum );
555
+		$diff = $transaction->total() - floatval($reg_final_price_sum);
556 556
 		//ok then, just grab one of the registrations
557
-		if( $diff != 0 ) {
557
+		if ($diff != 0) {
558 558
 			$a_reg = EEM_Registration::instance()->get_one(
559 559
 					array(
560 560
 						array(
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 					));
564 564
 			$success = $a_reg instanceof EE_Registration ? $a_reg->save(
565 565
 				array(
566
-					'REG_final_price' => ( $a_reg->final_price() + $diff )
566
+					'REG_final_price' => ($a_reg->final_price() + $diff)
567 567
 				)
568 568
 			) : false;
569 569
 			return $success ? true : false;
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 2 patches
Spacing   +379 added lines, -379 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2 2
 /**
3 3
  * EEH_Activation Helper
4 4
  *
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 	 * @param $table_name
49 49
 	 * @return string
50 50
 	 */
51
-	public static function ensure_table_name_has_prefix( $table_name ) {
51
+	public static function ensure_table_name_has_prefix($table_name) {
52 52
 		global $wpdb;
53
-		return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name;
53
+		return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name;
54 54
 	}
55 55
 
56 56
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return boolean success, whether the database and folders are setup properly
79 79
 	 * @throws \EE_Error
80 80
 	 */
81
-	public static function initialize_db_and_folders(){
81
+	public static function initialize_db_and_folders() {
82 82
 		$good_filesystem = EEH_Activation::create_upload_directories();
83 83
 		$good_db = EEH_Activation::create_database_tables();
84 84
 		return $good_filesystem && $good_db;
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @throws \EE_Error
96 96
 	 */
97
-	public static function initialize_db_content(){
97
+	public static function initialize_db_content() {
98 98
 		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
99
-		if( EEH_Activation::$_initialized_db_content_already_in_this_request ) {
99
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
100 100
 			return;
101 101
 		}
102 102
 		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		EEH_Activation::remove_cron_tasks();
114 114
 		EEH_Activation::create_cron_tasks();
115 115
 		// remove all TXN locks since that is being done via extra meta now
116
-		delete_option( 'ee_locked_transactions' );
116
+		delete_option('ee_locked_transactions');
117 117
 		//also, check for CAF default db content
118
-		do_action( 'AHEE__EEH_Activation__initialize_db_content' );
118
+		do_action('AHEE__EEH_Activation__initialize_db_content');
119 119
 		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
120 120
 		//which users really won't care about on initial activation
121 121
 		EE_Error::overwrite_success();
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @return array
135 135
 	 * @throws \EE_Error
136 136
 	 */
137
-	public static function get_cron_tasks( $which_to_include ) {
137
+	public static function get_cron_tasks($which_to_include) {
138 138
 		$cron_tasks = apply_filters(
139 139
 			'FHEE__EEH_Activation__get_cron_tasks',
140 140
 			array(
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
 				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
144 144
 			)
145 145
 		);
146
-		if ( $which_to_include === 'old' ) {
146
+		if ($which_to_include === 'old') {
147 147
 			$cron_tasks = array_filter(
148 148
 				$cron_tasks,
149
-				function ( $value ) {
149
+				function($value) {
150 150
 					return $value === EEH_Activation::cron_task_no_longer_in_use;
151 151
 				}
152 152
 			);
153
-		} elseif ( $which_to_include === 'current' ) {
154
-			$cron_tasks = array_filter( $cron_tasks );
155
-		} elseif ( WP_DEBUG && $which_to_include !== 'all' ) {
153
+		} elseif ($which_to_include === 'current') {
154
+			$cron_tasks = array_filter($cron_tasks);
155
+		} elseif (WP_DEBUG && $which_to_include !== 'all') {
156 156
 			throw new EE_Error(
157 157
 				sprintf(
158 158
 					__(
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	public static function create_cron_tasks() {
177 177
 
178
-		foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) {
179
-			if( ! wp_next_scheduled( $hook_name ) ) {
180
-				wp_schedule_event( time(), $frequency, $hook_name );
178
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
179
+			if ( ! wp_next_scheduled($hook_name)) {
180
+				wp_schedule_event(time(), $frequency, $hook_name);
181 181
 			}
182 182
 		}
183 183
 
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
192 192
 	 * @throws \EE_Error
193 193
 	 */
194
-	public static function remove_cron_tasks( $remove_all = true ) {
194
+	public static function remove_cron_tasks($remove_all = true) {
195 195
 		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
196 196
 		$crons = _get_cron_array();
197
-		$crons = is_array( $crons ) ? $crons : array();
197
+		$crons = is_array($crons) ? $crons : array();
198 198
 		/* reminder of what $crons look like:
199 199
 		 * Top-level keys are timestamps, and their values are arrays.
200 200
 		 * The 2nd level arrays have keys with each of the cron task hook names to run at that time
@@ -212,23 +212,23 @@  discard block
 block discarded – undo
212 212
 		 *					...
213 213
 		 *      ...
214 214
 		 */
215
-		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove );
216
-		foreach ( $crons as $timestamp => $hooks_to_fire_at_time ) {
217
-			if ( is_array( $hooks_to_fire_at_time ) ) {
218
-				foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) {
219
-					if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] )
220
-					     && is_array( $ee_cron_tasks_to_remove[ $hook_name ] )
215
+		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
216
+		foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
217
+			if (is_array($hooks_to_fire_at_time)) {
218
+				foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
219
+					if (isset($ee_cron_tasks_to_remove[$hook_name])
220
+					     && is_array($ee_cron_tasks_to_remove[$hook_name])
221 221
 					) {
222
-						unset( $crons[ $timestamp ][ $hook_name ] );
222
+						unset($crons[$timestamp][$hook_name]);
223 223
 					}
224 224
 				}
225 225
 				//also take care of any empty cron timestamps.
226
-				if ( empty( $hooks_to_fire_at_time ) ) {
227
-					unset( $crons[ $timestamp ] );
226
+				if (empty($hooks_to_fire_at_time)) {
227
+					unset($crons[$timestamp]);
228 228
 				}
229 229
 			}
230 230
 		}
231
-		_set_cron_array( $crons );
231
+		_set_cron_array($crons);
232 232
 	}
233 233
 
234 234
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public static function CPT_initialization() {
245 245
 		// register Custom Post Types
246
-		EE_Registry::instance()->load_core( 'Register_CPTs' );
246
+		EE_Registry::instance()->load_core('Register_CPTs');
247 247
 		flush_rewrite_rules();
248 248
 	}
249 249
 
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
 	 * 	@return void
262 262
 	 */
263 263
 	public static function reset_and_update_config() {
264
-		do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) );
265
-		add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 );
264
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
265
+		add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3);
266 266
 		//EE_Config::reset();
267 267
 	}
268 268
 
@@ -275,28 +275,28 @@  discard block
 block discarded – undo
275 275
 	 */
276 276
 	public static function load_calendar_config() {
277 277
 		// grab array of all plugin folders and loop thru it
278
-		$plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR );
279
-		if ( empty( $plugins ) ) {
278
+		$plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
279
+		if (empty($plugins)) {
280 280
 			return;
281 281
 		}
282
-		foreach ( $plugins as $plugin_path ) {
282
+		foreach ($plugins as $plugin_path) {
283 283
 			// grab plugin folder name from path
284
-			$plugin = basename( $plugin_path );
284
+			$plugin = basename($plugin_path);
285 285
 			// drill down to Espresso plugins
286 286
 			// then to calendar related plugins
287 287
 			if (
288
-				strpos( $plugin, 'espresso' ) !== FALSE
289
-				|| strpos( $plugin, 'Espresso' ) !== FALSE
290
-				|| strpos( $plugin, 'ee4' ) !== FALSE
291
-				|| strpos( $plugin, 'EE4' ) !== FALSE
292
-				|| strpos( $plugin, 'calendar' ) !== false
288
+				strpos($plugin, 'espresso') !== FALSE
289
+				|| strpos($plugin, 'Espresso') !== FALSE
290
+				|| strpos($plugin, 'ee4') !== FALSE
291
+				|| strpos($plugin, 'EE4') !== FALSE
292
+				|| strpos($plugin, 'calendar') !== false
293 293
 			) {
294 294
 				// this is what we are looking for
295
-				$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
295
+				$calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
296 296
 				// does it exist in this folder ?
297
-				if ( is_readable( $calendar_config )) {
297
+				if (is_readable($calendar_config)) {
298 298
 					// YEAH! let's load it
299
-					require_once( $calendar_config );
299
+					require_once($calendar_config);
300 300
 				}
301 301
 			}
302 302
 		}
@@ -312,21 +312,21 @@  discard block
 block discarded – undo
312 312
 	 * @param \EE_Config     $EE_Config
313 313
 	 * @return \stdClass
314 314
 	 */
315
-	public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) {
316
-		$convert_from_array = array( 'addons' );
315
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) {
316
+		$convert_from_array = array('addons');
317 317
 		// in case old settings were saved as an array
318
-		if ( is_array( $settings ) && in_array( $config, $convert_from_array )) {
318
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
319 319
 			// convert existing settings to an object
320 320
 			$config_array = $settings;
321 321
 			$settings = new stdClass();
322
-			foreach ( $config_array as $key => $value ){
323
-				if ( $key === 'calendar' && class_exists( 'EE_Calendar_Config' )) {
324
-					$EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value );
322
+			foreach ($config_array as $key => $value) {
323
+				if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
324
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
325 325
 				} else {
326 326
 					$settings->{$key} = $value;
327 327
 				}
328 328
 			}
329
-			add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' );
329
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
330 330
 		}
331 331
 		return $settings;
332 332
 	}
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 	 */
343 343
 	public static function deactivate_event_espresso() {
344 344
 		// check permissions
345
-		if ( current_user_can( 'activate_plugins' )) {
346
-			deactivate_plugins( EE_PLUGIN_BASENAME, TRUE );
345
+		if (current_user_can('activate_plugins')) {
346
+			deactivate_plugins(EE_PLUGIN_BASENAME, TRUE);
347 347
 		}
348 348
 	}
349 349
 
@@ -365,25 +365,25 @@  discard block
 block discarded – undo
365 365
 		$critical_pages = array(
366 366
 			array(
367 367
 				'id' =>'reg_page_id',
368
-				'name' => __( 'Registration Checkout', 'event_espresso' ),
368
+				'name' => __('Registration Checkout', 'event_espresso'),
369 369
 				'post' => NULL,
370 370
 				'code' => 'ESPRESSO_CHECKOUT'
371 371
 			),
372 372
 			array(
373 373
 				'id' => 'txn_page_id',
374
-				'name' => __( 'Transactions', 'event_espresso' ),
374
+				'name' => __('Transactions', 'event_espresso'),
375 375
 				'post' => NULL,
376 376
 				'code' => 'ESPRESSO_TXN_PAGE'
377 377
 			),
378 378
 			array(
379 379
 				'id' => 'thank_you_page_id',
380
-				'name' => __( 'Thank You', 'event_espresso' ),
380
+				'name' => __('Thank You', 'event_espresso'),
381 381
 				'post' => NULL,
382 382
 				'code' => 'ESPRESSO_THANK_YOU'
383 383
 			),
384 384
 			array(
385 385
 				'id' => 'cancel_page_id',
386
-				'name' => __( 'Registration Cancelled', 'event_espresso' ),
386
+				'name' => __('Registration Cancelled', 'event_espresso'),
387 387
 				'post' => NULL,
388 388
 				'code' => 'ESPRESSO_CANCELLED'
389 389
 			),
@@ -391,62 +391,62 @@  discard block
 block discarded – undo
391 391
 
392 392
 		$EE_Core_Config = EE_Registry::instance()->CFG->core;
393 393
 
394
-		foreach ( $critical_pages as $critical_page ) {
394
+		foreach ($critical_pages as $critical_page) {
395 395
 			// is critical page ID set in config ?
396
-			if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) {
396
+			if ($EE_Core_Config->{$critical_page['id']} !== FALSE) {
397 397
 				// attempt to find post by ID
398
-				$critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} );
398
+				$critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} );
399 399
 			}
400 400
 			// no dice?
401
-			if ( $critical_page['post'] === null ) {
401
+			if ($critical_page['post'] === null) {
402 402
 				// attempt to find post by title
403
-				$critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] );
403
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
404 404
 				// still nothing?
405
-				if ( $critical_page['post'] === null ) {
406
-					$critical_page = EEH_Activation::create_critical_page( $critical_page );
405
+				if ($critical_page['post'] === null) {
406
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
407 407
 					// REALLY? Still nothing ??!?!?
408
-					if ( $critical_page['post'] === null ) {
409
-						$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
410
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
408
+					if ($critical_page['post'] === null) {
409
+						$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
410
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
411 411
 						break;
412 412
 					}
413 413
 				}
414 414
 			}
415 415
 			// track post_shortcodes
416
-			if ( $critical_page['post'] ) {
417
-				EEH_Activation::_track_critical_page_post_shortcodes( $critical_page );
416
+			if ($critical_page['post']) {
417
+				EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
418 418
 			}
419 419
 			// check that Post ID matches critical page ID in config
420 420
 			if (
421
-				isset( $critical_page['post']->ID )
422
-				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page[ 'id' ]}
421
+				isset($critical_page['post']->ID)
422
+				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
423 423
 			) {
424 424
 				//update Config with post ID
425
-				$EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID;
426
-				if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) {
427
-					$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
428
-					EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
425
+				$EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
426
+				if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
427
+					$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
428
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
429 429
 				}
430 430
 			}
431 431
 
432 432
 			$critical_page_problem =
433
-				! isset( $critical_page['post']->post_status )
433
+				! isset($critical_page['post']->post_status)
434 434
 				|| $critical_page['post']->post_status !== 'publish'
435
-				|| strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE
435
+				|| strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE
436 436
 					? TRUE
437 437
 					: $critical_page_problem;
438 438
 
439 439
 		}
440 440
 
441
-		if ( $critical_page_problem ) {
441
+		if ($critical_page_problem) {
442 442
 			$msg = sprintf(
443
-				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ),
444
-				'<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>'
443
+				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'),
444
+				'<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>'
445 445
 			);
446
-			EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg );
446
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
447 447
 		}
448
-		if ( EE_Error::has_notices() ) {
449
-			EE_Error::get_notices( FALSE, TRUE, TRUE );
448
+		if (EE_Error::has_notices()) {
449
+			EE_Error::get_notices(FALSE, TRUE, TRUE);
450 450
 		}
451 451
 	}
452 452
 
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
 	 * parameter to the shortcode
459 459
 	 * @return WP_Post or NULl
460 460
 	 */
461
-	public static function get_page_by_ee_shortcode($ee_shortcode){
461
+	public static function get_page_by_ee_shortcode($ee_shortcode) {
462 462
 		global $wpdb;
463 463
 		$shortcode_and_opening_bracket = '['.$ee_shortcode;
464 464
 		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
465
-		if($post_id){
465
+		if ($post_id) {
466 466
 			return get_post($post_id);
467
-		}else{
467
+		} else {
468 468
 			return NULL;
469 469
 		}
470 470
 
@@ -481,32 +481,32 @@  discard block
 block discarded – undo
481 481
 	 * @param array $critical_page
482 482
 	 * @return array
483 483
 	 */
484
-	public static function create_critical_page( $critical_page ) {
484
+	public static function create_critical_page($critical_page) {
485 485
 
486 486
 		$post_args = array(
487 487
 			'post_title' => $critical_page['name'],
488 488
 			'post_status' => 'publish',
489 489
 			'post_type' => 'page',
490 490
 			'comment_status' => 'closed',
491
-			'post_content' => '[' . $critical_page['code'] . ']'
491
+			'post_content' => '['.$critical_page['code'].']'
492 492
 		);
493 493
 
494
-		$post_id = wp_insert_post( $post_args );
495
-		if ( ! $post_id ) {
494
+		$post_id = wp_insert_post($post_args);
495
+		if ( ! $post_id) {
496 496
 			$msg = sprintf(
497
-				__( 'The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso' ),
497
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
498 498
 				$critical_page['name']
499 499
 			);
500
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
500
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
501 501
 			return $critical_page;
502 502
 		}
503 503
 		// get newly created post's details
504
-		if ( ! $critical_page['post'] = get_post( $post_id )) {
504
+		if ( ! $critical_page['post'] = get_post($post_id)) {
505 505
 			$msg = sprintf(
506
-				__( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ),
506
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
507 507
 				$critical_page['name']
508 508
 			);
509
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
509
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
510 510
 		}
511 511
 
512 512
 		return $critical_page;
@@ -525,35 +525,35 @@  discard block
 block discarded – undo
525 525
 	 * @param array $critical_page
526 526
 	 * @return void
527 527
 	 */
528
-	private static function _track_critical_page_post_shortcodes( $critical_page = array() ) {
528
+	private static function _track_critical_page_post_shortcodes($critical_page = array()) {
529 529
 		// check the goods
530
-		if ( ! $critical_page['post'] instanceof WP_Post ) {
530
+		if ( ! $critical_page['post'] instanceof WP_Post) {
531 531
 			$msg = sprintf(
532
-				__( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ),
532
+				__('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'),
533 533
 				$critical_page['name']
534 534
 			);
535
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
535
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
536 536
 			return;
537 537
 		}
538 538
 		$EE_Core_Config = EE_Registry::instance()->CFG->core;
539 539
 		// map shortcode to post
540
-		$EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID;
540
+		$EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
541 541
 		// and make sure it's NOT added to the WP "Posts Page"
542 542
 		// name of the WP Posts Page
543 543
 		$posts_page = EE_Config::get_page_for_posts();
544
-		if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) {
545
-			unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] );
544
+		if (isset($EE_Core_Config->post_shortcodes[$posts_page])) {
545
+			unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]);
546 546
 		}
547
-		if ( $posts_page !== 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) {
548
-			unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] );
547
+		if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) {
548
+			unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]);
549 549
 		}
550 550
 		// update post_shortcode CFG
551
-		if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) {
551
+		if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
552 552
 			$msg = sprintf(
553
-				__( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ),
553
+				__('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'),
554 554
 				$critical_page['name']
555 555
 			);
556
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
556
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
557 557
 		}
558 558
 	}
559 559
 
@@ -571,24 +571,24 @@  discard block
 block discarded – undo
571 571
 	public static function get_default_creator_id() {
572 572
 		global $wpdb;
573 573
 
574
-		if ( ! empty( self::$_default_creator_id ) ) {
574
+		if ( ! empty(self::$_default_creator_id)) {
575 575
 			return self::$_default_creator_id;
576 576
 		}/**/
577 577
 
578
-		$role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' );
578
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
579 579
 
580 580
 		//let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
581
-		$pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check );
582
-		if ( $pre_filtered_id !== false ) {
581
+		$pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check);
582
+		if ($pre_filtered_id !== false) {
583 583
 			return (int) $pre_filtered_id;
584 584
 		}
585 585
 
586
-		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' );
587
-		$query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' );
588
-		$user_id = $wpdb->get_var( $query );
589
-		 $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id );
590
-		 if ( $user_id && (int)$user_id ) {
591
-		 	self::$_default_creator_id = (int)$user_id;
586
+		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities');
587
+		$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%');
588
+		$user_id = $wpdb->get_var($query);
589
+		 $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
590
+		 if ($user_id && (int) $user_id) {
591
+		 	self::$_default_creator_id = (int) $user_id;
592 592
 		 	return self::$_default_creator_id;
593 593
 		 } else {
594 594
 		 	return NULL;
@@ -615,29 +615,29 @@  discard block
 block discarded – undo
615 615
 	 * 	@return void
616 616
 	 * @throws EE_Error if there are database errors
617 617
 	 */
618
-	public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) {
619
-		if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){
618
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) {
619
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) {
620 620
 			return;
621 621
 		}
622
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
623
-		if ( ! function_exists( 'dbDelta' )) {
624
-			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
622
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
623
+		if ( ! function_exists('dbDelta')) {
624
+			require_once(ABSPATH.'wp-admin/includes/upgrade.php');
625 625
 		}
626 626
 		/** @var WPDB $wpdb */
627 627
 		global $wpdb;
628
-		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
628
+		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
629 629
 		// do we need to first delete an existing version of this table ?
630
-		if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){
630
+		if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) {
631 631
 			// ok, delete the table... but ONLY if it's empty
632
-			$deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name );
632
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
633 633
 			// table is NOT empty, are you SURE you want to delete this table ???
634
-			if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){
635
-				EEH_Activation::delete_unused_db_table( $wp_table_name );
636
-			} else if ( ! $deleted_safely ) {
634
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
635
+				EEH_Activation::delete_unused_db_table($wp_table_name);
636
+			} else if ( ! $deleted_safely) {
637 637
 				// so we should be more cautious rather than just dropping tables so easily
638 638
 				EE_Error::add_persistent_admin_notice(
639
-						'bad_table_' . $wp_table_name . '_detected',
640
-						sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ),
639
+						'bad_table_'.$wp_table_name.'_detected',
640
+						sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'),
641 641
 								$wp_table_name,
642 642
 								"<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>",
643 643
 								'<b>wp-config.php</b>',
@@ -646,25 +646,25 @@  discard block
 block discarded – undo
646 646
 			}
647 647
 		}
648 648
 		// does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
649
-		if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) {
649
+		if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) {
650 650
 			$SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;";
651 651
 			//get $wpdb to echo errors, but buffer them. This way at least WE know an error
652 652
 			//happened. And then we can choose to tell the end user
653
-			$old_show_errors_policy = $wpdb->show_errors( TRUE );
654
-			$old_error_suppression_policy = $wpdb->suppress_errors( FALSE );
653
+			$old_show_errors_policy = $wpdb->show_errors(TRUE);
654
+			$old_error_suppression_policy = $wpdb->suppress_errors(FALSE);
655 655
 			ob_start();
656
-			dbDelta( $SQL );
656
+			dbDelta($SQL);
657 657
 			$output = ob_get_contents();
658 658
 			ob_end_clean();
659
-			$wpdb->show_errors( $old_show_errors_policy );
660
-			$wpdb->suppress_errors( $old_error_suppression_policy );
661
-			if( ! empty( $output ) ){
662
-				throw new EE_Error( $output	);
659
+			$wpdb->show_errors($old_show_errors_policy);
660
+			$wpdb->suppress_errors($old_error_suppression_policy);
661
+			if ( ! empty($output)) {
662
+				throw new EE_Error($output);
663 663
 			}
664 664
 		} else {
665 665
 			throw new EE_Error(
666 666
 				sprintf(
667
-					__( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ),
667
+					__('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'),
668 668
 					'<br />',
669 669
 					$sql
670 670
 				)
@@ -686,15 +686,15 @@  discard block
 block discarded – undo
686 686
 	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)'
687 687
 	 * @return bool|int
688 688
 	 */
689
-	public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){
690
-		if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){
689
+	public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') {
690
+		if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) {
691 691
 			return FALSE;
692 692
 		}
693 693
 		global $wpdb;
694
-		$full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
694
+		$full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
695 695
 		$fields = self::get_fields_on_table($table_name);
696
-		if (!in_array($column_name, $fields)){
697
-			$alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info";
696
+		if ( ! in_array($column_name, $fields)) {
697
+			$alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info";
698 698
 			//echo "alter query:$alter_query";
699 699
 			return $wpdb->query($alter_query);
700 700
 		}
@@ -713,14 +713,14 @@  discard block
 block discarded – undo
713 713
 	 * 	@param string $table_name, without prefixed $wpdb->prefix
714 714
 	 * 	@return array of database column names
715 715
 	 */
716
-	public static function get_fields_on_table( $table_name = NULL ) {
716
+	public static function get_fields_on_table($table_name = NULL) {
717 717
 		global $wpdb;
718
-		$table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
719
-		if ( ! empty( $table_name )) {
718
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
719
+		if ( ! empty($table_name)) {
720 720
 			$columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name ");
721 721
 			if ($columns !== FALSE) {
722 722
 				$field_array = array();
723
-				foreach($columns as $column ){
723
+				foreach ($columns as $column) {
724 724
 					$field_array[] = $column->Field;
725 725
 				}
726 726
 				return $field_array;
@@ -739,12 +739,12 @@  discard block
 block discarded – undo
739 739
 	 * @param string $table_name
740 740
 	 * @return bool
741 741
 	 */
742
-	public static function db_table_is_empty( $table_name ) {
742
+	public static function db_table_is_empty($table_name) {
743 743
 		global $wpdb;
744
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
745
-		if ( EEH_Activation::table_exists( $table_name ) ) {
746
-			$count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
747
-			return absint( $count ) === 0 ? true : false;
744
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
745
+		if (EEH_Activation::table_exists($table_name)) {
746
+			$count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
747
+			return absint($count) === 0 ? true : false;
748 748
 		}
749 749
 		return false;
750 750
 	}
@@ -759,9 +759,9 @@  discard block
 block discarded – undo
759 759
 	 * @param string $table_name
760 760
 	 * @return bool | int
761 761
 	 */
762
-	public static function delete_db_table_if_empty( $table_name ) {
763
-		if ( EEH_Activation::db_table_is_empty( $table_name ) ) {
764
-			return EEH_Activation::delete_unused_db_table( $table_name );
762
+	public static function delete_db_table_if_empty($table_name) {
763
+		if (EEH_Activation::db_table_is_empty($table_name)) {
764
+			return EEH_Activation::delete_unused_db_table($table_name);
765 765
 		}
766 766
 		return false;
767 767
 	}
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
 	 * @param string $table_name
777 777
 	 * @return bool | int
778 778
 	 */
779
-	public static function delete_unused_db_table( $table_name ) {
779
+	public static function delete_unused_db_table($table_name) {
780 780
 		global $wpdb;
781
-		if ( EEH_Activation::table_exists( $table_name ) ) {
782
-			$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
783
-			return $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
781
+		if (EEH_Activation::table_exists($table_name)) {
782
+			$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
783
+			return $wpdb->query("DROP TABLE IF EXISTS $table_name");
784 784
 		}
785 785
 		return false;
786 786
 	}
@@ -796,18 +796,18 @@  discard block
 block discarded – undo
796 796
 	 * @param string $index_name
797 797
 	 * @return bool | int
798 798
 	 */
799
-	public static function drop_index( $table_name, $index_name ) {
800
-		if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){
799
+	public static function drop_index($table_name, $index_name) {
800
+		if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) {
801 801
 			return FALSE;
802 802
 		}
803 803
 		global $wpdb;
804
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
804
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
805 805
 		$index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'";
806 806
 		if (
807
-			$wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) === $table_name
808
-			&& $wpdb->get_var( $index_exists_query ) === $table_name //using get_var with the $index_exists_query returns the table's name
807
+			$wpdb->get_var("SHOW TABLES LIKE '$table_name'") === $table_name
808
+			&& $wpdb->get_var($index_exists_query) === $table_name //using get_var with the $index_exists_query returns the table's name
809 809
 		) {
810
-			return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" );
810
+			return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name");
811 811
 		}
812 812
 		return TRUE;
813 813
 	}
@@ -823,27 +823,27 @@  discard block
 block discarded – undo
823 823
 	 * @return boolean success (whether database is setup properly or not)
824 824
 	 */
825 825
 	public static function create_database_tables() {
826
-		EE_Registry::instance()->load_core( 'Data_Migration_Manager' );
826
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
827 827
 		//find the migration script that sets the database to be compatible with the code
828 828
 		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
829
-		if( $dms_name ){
830
-			$current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name );
831
-			$current_data_migration_script->set_migrating( false );
829
+		if ($dms_name) {
830
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
831
+			$current_data_migration_script->set_migrating(false);
832 832
 			$current_data_migration_script->schema_changes_before_migration();
833 833
 			$current_data_migration_script->schema_changes_after_migration();
834
-			if( $current_data_migration_script->get_errors() ){
835
-				if( WP_DEBUG ){
836
-					foreach( $current_data_migration_script->get_errors() as $error ){
837
-						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ );
834
+			if ($current_data_migration_script->get_errors()) {
835
+				if (WP_DEBUG) {
836
+					foreach ($current_data_migration_script->get_errors() as $error) {
837
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
838 838
 					}
839
-				}else{
840
-					EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) );
839
+				} else {
840
+					EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso'));
841 841
 				}
842 842
 				return false;
843 843
 			}
844 844
 			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
845
-		}else{
846
-			EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
845
+		} else {
846
+			EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
847 847
 			return false;
848 848
 		}
849 849
 		return true;
@@ -863,27 +863,27 @@  discard block
 block discarded – undo
863 863
 	public static function initialize_system_questions() {
864 864
 		// QUESTION GROUPS
865 865
 		global $wpdb;
866
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' );
866
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group');
867 867
 		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
868 868
 		// what we have
869
-		$question_groups = $wpdb->get_col( $SQL );
869
+		$question_groups = $wpdb->get_col($SQL);
870 870
 		// check the response
871
-		$question_groups = is_array( $question_groups ) ? $question_groups : array();
871
+		$question_groups = is_array($question_groups) ? $question_groups : array();
872 872
 		// what we should have
873
-		$QSG_systems = array( 1, 2 );
873
+		$QSG_systems = array(1, 2);
874 874
 		// loop thru what we should have and compare to what we have
875
-		foreach ( $QSG_systems as $QSG_system ) {
875
+		foreach ($QSG_systems as $QSG_system) {
876 876
 			// reset values array
877 877
 			$QSG_values = array();
878 878
 			// if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
879
-			if ( ! in_array( "$QSG_system", $question_groups )) {
879
+			if ( ! in_array("$QSG_system", $question_groups)) {
880 880
 				// add it
881
-				switch ( $QSG_system ) {
881
+				switch ($QSG_system) {
882 882
 
883 883
 					case 1:
884 884
 							$QSG_values = array(
885
-									'QSG_name' => __( 'Personal Information', 'event_espresso' ),
886
-									'QSG_identifier' => 'personal-information-' . time(),
885
+									'QSG_name' => __('Personal Information', 'event_espresso'),
886
+									'QSG_identifier' => 'personal-information-'.time(),
887 887
 									'QSG_desc' => '',
888 888
 									'QSG_order' => 1,
889 889
 									'QSG_show_group_name' => 1,
@@ -895,8 +895,8 @@  discard block
 block discarded – undo
895 895
 
896 896
 					case 2:
897 897
 							$QSG_values = array(
898
-									'QSG_name' => __( 'Address Information','event_espresso' ),
899
-									'QSG_identifier' => 'address-information-' . time(),
898
+									'QSG_name' => __('Address Information', 'event_espresso'),
899
+									'QSG_identifier' => 'address-information-'.time(),
900 900
 									'QSG_desc' => '',
901 901
 									'QSG_order' => 2,
902 902
 									'QSG_show_group_name' => 1,
@@ -908,14 +908,14 @@  discard block
 block discarded – undo
908 908
 
909 909
 				}
910 910
 				// make sure we have some values before inserting them
911
-				if ( ! empty( $QSG_values )) {
911
+				if ( ! empty($QSG_values)) {
912 912
 					// insert system question
913 913
 					$wpdb->insert(
914 914
 						$table_name,
915 915
 						$QSG_values,
916
-						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' )
916
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
917 917
 					);
918
-					$QSG_IDs[ $QSG_system ] = $wpdb->insert_id;
918
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
919 919
 				}
920 920
 			}
921 921
 		}
@@ -924,10 +924,10 @@  discard block
 block discarded – undo
924 924
 
925 925
 		// QUESTIONS
926 926
 		global $wpdb;
927
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' );
927
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question');
928 928
 		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
929 929
 		// what we have
930
-		$questions = $wpdb->get_col( $SQL );
930
+		$questions = $wpdb->get_col($SQL);
931 931
 		// what we should have
932 932
 		$QST_systems = array(
933 933
 			'fname',
@@ -944,25 +944,25 @@  discard block
 block discarded – undo
944 944
 		$order_for_group_1 = 1;
945 945
 		$order_for_group_2 = 1;
946 946
 		// loop thru what we should have and compare to what we have
947
-		foreach ( $QST_systems as $QST_system ) {
947
+		foreach ($QST_systems as $QST_system) {
948 948
 			// reset values array
949 949
 			$QST_values = array();
950 950
 			// if we don't have what we should have
951
-			if ( ! in_array( $QST_system, $questions )) {
951
+			if ( ! in_array($QST_system, $questions)) {
952 952
 				// add it
953
-				switch ( $QST_system ) {
953
+				switch ($QST_system) {
954 954
 
955 955
 					case 'fname':
956 956
 							$QST_values = array(
957
-									'QST_display_text' => __( 'First Name', 'event_espresso' ),
958
-									'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ),
957
+									'QST_display_text' => __('First Name', 'event_espresso'),
958
+									'QST_admin_label' => __('First Name - System Question', 'event_espresso'),
959 959
 									'QST_system' => 'fname',
960 960
 									'QST_type' => 'TEXT',
961 961
 									'QST_required' => 1,
962
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
962
+									'QST_required_text' => __('This field is required', 'event_espresso'),
963 963
 									'QST_order' => 1,
964 964
 									'QST_admin_only' => 0,
965
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
965
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
966 966
 									'QST_wp_user' => self::get_default_creator_id(),
967 967
 									'QST_deleted' => 0
968 968
 								);
@@ -970,15 +970,15 @@  discard block
 block discarded – undo
970 970
 
971 971
 					case 'lname':
972 972
 							$QST_values = array(
973
-									'QST_display_text' => __( 'Last Name', 'event_espresso' ),
974
-									'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ),
973
+									'QST_display_text' => __('Last Name', 'event_espresso'),
974
+									'QST_admin_label' => __('Last Name - System Question', 'event_espresso'),
975 975
 									'QST_system' => 'lname',
976 976
 									'QST_type' => 'TEXT',
977 977
 									'QST_required' => 1,
978
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
978
+									'QST_required_text' => __('This field is required', 'event_espresso'),
979 979
 									'QST_order' => 2,
980 980
 									'QST_admin_only' => 0,
981
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
981
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
982 982
 									'QST_wp_user' => self::get_default_creator_id(),
983 983
 									'QST_deleted' => 0
984 984
 								);
@@ -986,15 +986,15 @@  discard block
 block discarded – undo
986 986
 
987 987
 					case 'email':
988 988
 							$QST_values = array(
989
-									'QST_display_text' => __( 'Email Address', 'event_espresso' ),
990
-									'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ),
989
+									'QST_display_text' => __('Email Address', 'event_espresso'),
990
+									'QST_admin_label' => __('Email Address - System Question', 'event_espresso'),
991 991
 									'QST_system' => 'email',
992 992
 									'QST_type' => 'TEXT',
993 993
 									'QST_required' => 1,
994
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
994
+									'QST_required_text' => __('This field is required', 'event_espresso'),
995 995
 									'QST_order' => 3,
996 996
 									'QST_admin_only' => 0,
997
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
997
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
998 998
 									'QST_wp_user' => self::get_default_creator_id(),
999 999
 									'QST_deleted' => 0
1000 1000
 								);
@@ -1002,15 +1002,15 @@  discard block
 block discarded – undo
1002 1002
 
1003 1003
 					case 'address':
1004 1004
 							$QST_values = array(
1005
-									'QST_display_text' => __( 'Address', 'event_espresso' ),
1006
-									'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ),
1005
+									'QST_display_text' => __('Address', 'event_espresso'),
1006
+									'QST_admin_label' => __('Address - System Question', 'event_espresso'),
1007 1007
 									'QST_system' => 'address',
1008 1008
 									'QST_type' => 'TEXT',
1009 1009
 									'QST_required' => 0,
1010
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1010
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1011 1011
 									'QST_order' => 4,
1012 1012
 									'QST_admin_only' => 0,
1013
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1013
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1014 1014
 									'QST_wp_user' => self::get_default_creator_id(),
1015 1015
 									'QST_deleted' => 0
1016 1016
 								);
@@ -1018,15 +1018,15 @@  discard block
 block discarded – undo
1018 1018
 
1019 1019
 					case 'address2':
1020 1020
 							$QST_values = array(
1021
-									'QST_display_text' => __( 'Address2', 'event_espresso' ),
1022
-									'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ),
1021
+									'QST_display_text' => __('Address2', 'event_espresso'),
1022
+									'QST_admin_label' => __('Address2 - System Question', 'event_espresso'),
1023 1023
 									'QST_system' => 'address2',
1024 1024
 									'QST_type' => 'TEXT',
1025 1025
 									'QST_required' => 0,
1026
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1026
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1027 1027
 									'QST_order' => 5,
1028 1028
 									'QST_admin_only' => 0,
1029
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1029
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1030 1030
 									'QST_wp_user' => self::get_default_creator_id(),
1031 1031
 									'QST_deleted' => 0
1032 1032
 								);
@@ -1034,15 +1034,15 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
 					case 'city':
1036 1036
 							$QST_values = array(
1037
-									'QST_display_text' => __( 'City', 'event_espresso' ),
1038
-									'QST_admin_label' => __( 'City - System Question', 'event_espresso' ),
1037
+									'QST_display_text' => __('City', 'event_espresso'),
1038
+									'QST_admin_label' => __('City - System Question', 'event_espresso'),
1039 1039
 									'QST_system' => 'city',
1040 1040
 									'QST_type' => 'TEXT',
1041 1041
 									'QST_required' => 0,
1042
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1042
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1043 1043
 									'QST_order' => 6,
1044 1044
 									'QST_admin_only' => 0,
1045
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1045
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1046 1046
 									'QST_wp_user' => self::get_default_creator_id(),
1047 1047
 									'QST_deleted' => 0
1048 1048
 								);
@@ -1050,12 +1050,12 @@  discard block
 block discarded – undo
1050 1050
 
1051 1051
 					case 'state':
1052 1052
 							$QST_values = array(
1053
-									'QST_display_text' => __( 'State/Province', 'event_espresso' ),
1054
-									'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ),
1053
+									'QST_display_text' => __('State/Province', 'event_espresso'),
1054
+									'QST_admin_label' => __('State/Province - System Question', 'event_espresso'),
1055 1055
 									'QST_system' => 'state',
1056 1056
 									'QST_type' => 'STATE',
1057 1057
 									'QST_required' => 0,
1058
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1058
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1059 1059
 									'QST_order' => 7,
1060 1060
 									'QST_admin_only' => 0,
1061 1061
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1065,12 +1065,12 @@  discard block
 block discarded – undo
1065 1065
 
1066 1066
 					case 'country' :
1067 1067
 							$QST_values = array(
1068
-									'QST_display_text' => __( 'Country', 'event_espresso' ),
1069
-									'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ),
1068
+									'QST_display_text' => __('Country', 'event_espresso'),
1069
+									'QST_admin_label' => __('Country - System Question', 'event_espresso'),
1070 1070
 									'QST_system' => 'country',
1071 1071
 									'QST_type' => 'COUNTRY',
1072 1072
 									'QST_required' => 0,
1073
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1073
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1074 1074
 									'QST_order' => 8,
1075 1075
 									'QST_admin_only' => 0,
1076 1076
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1080,15 +1080,15 @@  discard block
 block discarded – undo
1080 1080
 
1081 1081
 					case 'zip':
1082 1082
 							$QST_values = array(
1083
-									'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ),
1084
-									'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ),
1083
+									'QST_display_text' => __('Zip/Postal Code', 'event_espresso'),
1084
+									'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'),
1085 1085
 									'QST_system' => 'zip',
1086 1086
 									'QST_type' => 'TEXT',
1087 1087
 									'QST_required' => 0,
1088
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1088
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1089 1089
 									'QST_order' => 9,
1090 1090
 									'QST_admin_only' => 0,
1091
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1091
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1092 1092
 									'QST_wp_user' => self::get_default_creator_id(),
1093 1093
 									'QST_deleted' => 0
1094 1094
 								);
@@ -1096,49 +1096,49 @@  discard block
 block discarded – undo
1096 1096
 
1097 1097
 					case 'phone':
1098 1098
 							$QST_values = array(
1099
-									'QST_display_text' => __( 'Phone Number', 'event_espresso' ),
1100
-									'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ),
1099
+									'QST_display_text' => __('Phone Number', 'event_espresso'),
1100
+									'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'),
1101 1101
 									'QST_system' => 'phone',
1102 1102
 									'QST_type' => 'TEXT',
1103 1103
 									'QST_required' => 0,
1104
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1104
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1105 1105
 									'QST_order' => 10,
1106 1106
 									'QST_admin_only' => 0,
1107
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1107
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1108 1108
 									'QST_wp_user' => self::get_default_creator_id(),
1109 1109
 									'QST_deleted' => 0
1110 1110
 								);
1111 1111
 						break;
1112 1112
 
1113 1113
 				}
1114
-				if ( ! empty( $QST_values )) {
1114
+				if ( ! empty($QST_values)) {
1115 1115
 					// insert system question
1116 1116
 					$wpdb->insert(
1117 1117
 						$table_name,
1118 1118
 						$QST_values,
1119
-						array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' )
1119
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1120 1120
 					);
1121 1121
 					$QST_ID = $wpdb->insert_id;
1122 1122
 
1123 1123
 					// QUESTION GROUP QUESTIONS
1124
-					if(  in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) {
1124
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1125 1125
 						$system_question_we_want = EEM_Question_Group::system_personal;
1126 1126
 					} else {
1127 1127
 						$system_question_we_want = EEM_Question_Group::system_address;
1128 1128
 					}
1129
-					if( isset( $QSG_IDs[ $system_question_we_want ] ) ) {
1130
-						$QSG_ID = $QSG_IDs[ $system_question_we_want ];
1129
+					if (isset($QSG_IDs[$system_question_we_want])) {
1130
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1131 1131
 					} else {
1132
-						$id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) );
1133
-						if( is_array( $id_col ) ) {
1134
-							$QSG_ID = reset( $id_col );
1132
+						$id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want)));
1133
+						if (is_array($id_col)) {
1134
+							$QSG_ID = reset($id_col);
1135 1135
 						} else {
1136 1136
 							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1137 1137
                                                         EE_Log::instance()->log(
1138 1138
                                                                 __FILE__,
1139 1139
                                                                 __FUNCTION__,
1140 1140
                                                                 sprintf(
1141
-                                                                        __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'),
1141
+                                                                        __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'),
1142 1142
                                                                         $QST_ID ),
1143 1143
                                                                 'error' );
1144 1144
                                                         continue;
@@ -1147,12 +1147,12 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
 					// add system questions to groups
1149 1149
 					$wpdb->insert(
1150
-						EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ),
1151
-						array( 'QSG_ID'    => $QSG_ID,
1150
+						EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'),
1151
+						array('QSG_ID'    => $QSG_ID,
1152 1152
 						       'QST_ID'    => $QST_ID,
1153
-						       'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++
1153
+						       'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++
1154 1154
 						),
1155
-						array( '%d', '%d', '%d' )
1155
+						array('%d', '%d', '%d')
1156 1156
 					);
1157 1157
 				}
1158 1158
 			}
@@ -1168,11 +1168,11 @@  discard block
 block discarded – undo
1168 1168
 	 *
1169 1169
 	 * @throws \EE_Error
1170 1170
 	 */
1171
-	public static function insert_default_payment_methods(){
1172
-		if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){
1173
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
1174
-			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
1175
-		}else{
1171
+	public static function insert_default_payment_methods() {
1172
+		if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1173
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1174
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1175
+		} else {
1176 1176
 			EEM_Payment_Method::instance()->verify_button_urls();
1177 1177
 		}
1178 1178
 	}
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 
1189 1189
 		global $wpdb;
1190 1190
 
1191
-		if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) {
1191
+		if (EEH_Activation::table_exists(EEM_Status::instance()->table())) {
1192 1192
 
1193 1193
 			$table_name = EEM_Status::instance()->table();
1194 1194
 
@@ -1254,38 +1254,38 @@  discard block
 block discarded – undo
1254 1254
 	 * 	@return boolean success of verifying upload directories exist
1255 1255
 	 */
1256 1256
 	public static function create_upload_directories() {
1257
-		EE_Registry::instance()->load_helper( 'File' );
1257
+		EE_Registry::instance()->load_helper('File');
1258 1258
 		// Create the required folders
1259 1259
 		$folders = array(
1260 1260
 				EVENT_ESPRESSO_TEMPLATE_DIR,
1261 1261
 				EVENT_ESPRESSO_GATEWAY_DIR,
1262
-				EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1263
-				EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1264
-				EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/'
1262
+				EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1263
+				EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1264
+				EVENT_ESPRESSO_UPLOAD_DIR.'tickets/'
1265 1265
 		);
1266
-		foreach ( $folders as $folder ) {
1266
+		foreach ($folders as $folder) {
1267 1267
 			try {
1268
-				EEH_File::ensure_folder_exists_and_is_writable( $folder );
1269
-				@ chmod( $folder, 0755 );
1270
-			} catch( EE_Error $e ){
1268
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1269
+				@ chmod($folder, 0755);
1270
+			} catch (EE_Error $e) {
1271 1271
 				EE_Error::add_error(
1272 1272
 					sprintf(
1273
-						__(  'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ),
1273
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1274 1274
 						$folder,
1275
-						'<br />' . $e->getMessage()
1275
+						'<br />'.$e->getMessage()
1276 1276
 					),
1277 1277
 					__FILE__, __FUNCTION__, __LINE__
1278 1278
 				);
1279 1279
 				//indicate we'll need to fix this later
1280
-				update_option( EEH_Activation::upload_directories_incomplete_option_name, true );
1280
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1281 1281
 				return FALSE;
1282 1282
 			}
1283 1283
 		}
1284 1284
 		//just add the .htaccess file to the logs directory to begin with. Even if logging
1285 1285
 		//is disabled, there might be activation errors recorded in there
1286
-		EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' );
1286
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/');
1287 1287
 		//remember EE's folders are all good
1288
-		delete_option( EEH_Activation::upload_directories_incomplete_option_name );
1288
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1289 1289
 		return TRUE;
1290 1290
 	}
1291 1291
 
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
 	 * @return boolean
1299 1299
 	 */
1300 1300
 	public static function upload_directories_incomplete() {
1301
-		return get_option( EEH_Activation::upload_directories_incomplete_option_name, false );
1301
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1302 1302
 	}
1303 1303
 
1304 1304
 
@@ -1317,16 +1317,16 @@  discard block
 block discarded – undo
1317 1317
 		$installed_messengers = $default_messengers = array();
1318 1318
 
1319 1319
 		//include our helper
1320
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1320
+		EE_Registry::instance()->load_helper('MSG_Template');
1321 1321
 
1322 1322
 		//get all installed messenger objects
1323 1323
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1324 1324
 
1325 1325
 		//let's setup the $installed messengers in an array AND the messengers that are set to be activated on install.
1326
-		foreach ( $installed['messengers'] as $msgr ) {
1327
-			if ( $msgr instanceof EE_messenger ) {
1326
+		foreach ($installed['messengers'] as $msgr) {
1327
+			if ($msgr instanceof EE_messenger) {
1328 1328
 				$installed_messengers[$msgr->name] = $msgr;
1329
-				if ( $msgr->activate_on_install ) {
1329
+				if ($msgr->activate_on_install) {
1330 1330
 					$default_messengers[] = $msgr->name;
1331 1331
 				}
1332 1332
 			}
@@ -1336,38 +1336,38 @@  discard block
 block discarded – undo
1336 1336
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1337 1337
 
1338 1338
 		//things that have already been activated before
1339
-		$has_activated = get_option( 'ee_has_activated_messenger' );
1339
+		$has_activated = get_option('ee_has_activated_messenger');
1340 1340
 
1341 1341
 		//do an initial loop to determine if we need to continue
1342 1342
 		$def_ms = array();
1343
-		foreach ( $default_messengers as $msgr ) {
1344
-			if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) {
1343
+		foreach ($default_messengers as $msgr) {
1344
+			if (isset($active_messengers[$msgr]) || isset($has_activated[$msgr])) {
1345 1345
 				continue;
1346 1346
 			}
1347 1347
 			$def_ms[] = $msgr;
1348 1348
 		}
1349 1349
 
1350 1350
 		//setup the $installed_mts in an array
1351
-		foreach ( $installed['message_types'] as $imt ) {
1352
-			if ( $imt instanceof EE_message_type ) {
1351
+		foreach ($installed['message_types'] as $imt) {
1352
+			if ($imt instanceof EE_message_type) {
1353 1353
 				$installed_mts[$imt->name] = $imt;
1354 1354
 			}
1355 1355
 		}
1356 1356
 
1357 1357
 		//loop through default array for default messengers (if present)
1358
-		if ( ! empty( $def_ms ) ) {
1359
-			foreach ( $def_ms as $messenger ) {
1358
+		if ( ! empty($def_ms)) {
1359
+			foreach ($def_ms as $messenger) {
1360 1360
 				//all is good so let's setup the default stuff. We need to use the given messenger object (if exists) to get the default message type for the messenger.
1361
-				if ( ! isset( $installed_messengers[$messenger] )) {
1361
+				if ( ! isset($installed_messengers[$messenger])) {
1362 1362
 					continue;
1363 1363
 				}
1364 1364
 				/** @var EE_messenger[] $installed_messengers  */
1365 1365
 				$default_mts = $installed_messengers[$messenger]->get_default_message_types();
1366 1366
 				$active_messengers[$messenger]['obj'] = $installed_messengers[$messenger];
1367
-				foreach ( $default_mts as $index => $mt ) {
1367
+				foreach ($default_mts as $index => $mt) {
1368 1368
 					//is there an installed_mt matching the default string?  If not then nothing to do here.
1369
-					if ( ! isset( $installed_mts[$mt] ) ) {
1370
-						unset( $default_mts[$index] );
1369
+					if ( ! isset($installed_mts[$mt])) {
1370
+						unset($default_mts[$index]);
1371 1371
 						continue;
1372 1372
 					}
1373 1373
 
@@ -1376,41 +1376,41 @@  discard block
 block discarded – undo
1376 1376
 					/** @var EE_message_type[] $installed_mts */
1377 1377
 					$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1378 1378
 					$settings = array();
1379
-					if ( is_array( $settings_fields ) ) {
1380
-						foreach ( $settings_fields as $field => $values ) {
1381
-							if ( isset( $values['default'] ) ) {
1379
+					if (is_array($settings_fields)) {
1380
+						foreach ($settings_fields as $field => $values) {
1381
+							if (isset($values['default'])) {
1382 1382
 								$settings[$field] = $values['default'];
1383 1383
 							}
1384 1384
 						}
1385 1385
 					}
1386 1386
 
1387
-					$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1387
+					$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1388 1388
 					$has_activated[$messenger][] = $mt;
1389 1389
 				}
1390 1390
 
1391 1391
 				//setup any initial settings for the messenger
1392 1392
 				$msgr_settings = $installed_messengers[$messenger]->get_admin_settings_fields();
1393 1393
 
1394
-				if ( !empty( $msgr_settings ) ) {
1395
-					foreach ( $msgr_settings as $field => $value ) {
1394
+				if ( ! empty($msgr_settings)) {
1395
+					foreach ($msgr_settings as $field => $value) {
1396 1396
 						$active_messengers[$messenger]['settings'][$field] = $value;
1397 1397
 					}
1398 1398
 				}
1399 1399
 
1400 1400
 				//now let's save the settings for this messenger! Must do now because the validator checks the db for active messengers to validate.
1401
-				EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1401
+				EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1402 1402
 
1403 1403
 				//let's generate all the templates but only if the messenger has default_mts (otherwise its just activated).
1404
-				if ( !empty( $default_mts ) ) {
1405
-					$success = EEH_MSG_Template::generate_new_templates( $messenger, $default_mts, '', TRUE );
1404
+				if ( ! empty($default_mts)) {
1405
+					$success = EEH_MSG_Template::generate_new_templates($messenger, $default_mts, '', TRUE);
1406 1406
 				}
1407 1407
 			}
1408 1408
 		} //end check for empty( $def_ms )
1409 1409
 
1410 1410
 		//still need to see if there are any message types to activate for active messengers
1411
-		foreach ( $active_messengers as $messenger => $settings ) {
1411
+		foreach ($active_messengers as $messenger => $settings) {
1412 1412
 			$msg_obj = $settings['obj'];
1413
-			if ( ! $msg_obj instanceof EE_messenger ) {
1413
+			if ( ! $msg_obj instanceof EE_messenger) {
1414 1414
 				continue;
1415 1415
 			}
1416 1416
 
@@ -1418,49 +1418,49 @@  discard block
 block discarded – undo
1418 1418
 			$new_default_mts = array();
1419 1419
 
1420 1420
 			//loop through each default mt reported by the messenger and make sure its set in its active db entry.
1421
-			foreach( $all_default_mts as $index => $mt ) {
1421
+			foreach ($all_default_mts as $index => $mt) {
1422 1422
 				//already active? already has generated templates? || has already been activated before (we dont' want to reactivate things users intentionally deactivated).
1423 1423
 				if (
1424
-					isset( $active_messengers[ $messenger ]['settings'][ $messenger . '-message_types' ][ $mt ] )
1425
-					|| ( isset( $has_activated[ $messenger ] ) && in_array( $mt, $has_activated[ $messenger ] ) )
1426
-					||  EEH_MSG_Template::already_generated( $messenger, $mt, 0, FALSE )
1424
+					isset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt])
1425
+					|| (isset($has_activated[$messenger]) && in_array($mt, $has_activated[$messenger]))
1426
+					||  EEH_MSG_Template::already_generated($messenger, $mt, 0, FALSE)
1427 1427
 				) {
1428 1428
 					continue;
1429 1429
 				}
1430 1430
 
1431 1431
 				//is there an installed_mt matching the default string?  If not then nothing to do here.
1432
-				if ( ! isset( $installed_mts[$mt] ) ) {
1433
-					unset( $all_default_mts[$mt] );
1432
+				if ( ! isset($installed_mts[$mt])) {
1433
+					unset($all_default_mts[$mt]);
1434 1434
 					continue;
1435 1435
 				}
1436 1436
 
1437 1437
 				$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1438 1438
 				$settings = array();
1439
-				if ( is_array( $settings_fields ) ) {
1440
-					foreach ( $settings_fields as $field => $values ) {
1441
-						if ( isset( $values['default'] ) ) {
1439
+				if (is_array($settings_fields)) {
1440
+					foreach ($settings_fields as $field => $values) {
1441
+						if (isset($values['default'])) {
1442 1442
 							$settings[$field] = $values['default'];
1443 1443
 						}
1444 1444
 					}
1445 1445
 				}
1446 1446
 
1447
-				$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1447
+				$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1448 1448
 				$new_default_mts[] = $mt;
1449 1449
 				$has_activated[$messenger][] = $mt;
1450 1450
 			}
1451 1451
 
1452 1452
 
1453
-			if ( ! empty( $new_default_mts ) ) {
1454
-				$success = EEH_MSG_Template::generate_new_templates( $messenger, $new_default_mts, '', TRUE );
1453
+			if ( ! empty($new_default_mts)) {
1454
+				$success = EEH_MSG_Template::generate_new_templates($messenger, $new_default_mts, '', TRUE);
1455 1455
 			}
1456 1456
 
1457 1457
 		}
1458 1458
 
1459 1459
 		//now let's save the settings for this messenger!
1460
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1460
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1461 1461
 
1462 1462
 		//update $has_activated record
1463
-		update_option( 'ee_has_activated_messenger', $has_activated );
1463
+		update_option('ee_has_activated_messenger', $has_activated);
1464 1464
 
1465 1465
 		//that's it!
1466 1466
 		return $success;
@@ -1480,47 +1480,47 @@  discard block
 block discarded – undo
1480 1480
 	 */
1481 1481
 	public static function validate_messages_system() {
1482 1482
 		//include our helper
1483
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
1483
+		EE_Registry::instance()->load_helper('MSG_Template');
1484 1484
 
1485 1485
 		//get active and installed  messengers/message types.
1486 1486
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1487 1487
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1488 1488
 		$installed_messengers = $installed_mts = array();
1489 1489
 		//set up the arrays so they can be handled easier.
1490
-		foreach( $installed['messengers'] as $im ) {
1491
-			if ( $im instanceof EE_messenger ) {
1490
+		foreach ($installed['messengers'] as $im) {
1491
+			if ($im instanceof EE_messenger) {
1492 1492
 				$installed_messengers[$im->name] = $im;
1493 1493
 			}
1494 1494
 		}
1495
-		foreach( $installed['message_types'] as $imt ) {
1496
-			if ( $imt instanceof EE_message_type ) {
1495
+		foreach ($installed['message_types'] as $imt) {
1496
+			if ($imt instanceof EE_message_type) {
1497 1497
 				$installed_mts[$imt->name] = $imt;
1498 1498
 			}
1499 1499
 		}
1500 1500
 
1501 1501
 		//now let's loop through the active array and validate
1502
-		foreach( $active_messengers as $messenger => $active_details ) {
1502
+		foreach ($active_messengers as $messenger => $active_details) {
1503 1503
 			//first let's see if this messenger is installed.
1504
-			if ( ! isset( $installed_messengers[$messenger] ) ) {
1504
+			if ( ! isset($installed_messengers[$messenger])) {
1505 1505
 				//not set so let's just remove from actives and make sure templates are inactive.
1506
-				unset( $active_messengers[$messenger] );
1507
-				EEH_MSG_Template::update_to_inactive( $messenger );
1506
+				unset($active_messengers[$messenger]);
1507
+				EEH_MSG_Template::update_to_inactive($messenger);
1508 1508
 				continue;
1509 1509
 			}
1510 1510
 
1511 1511
 			//messenger is active, so let's just make sure that any active message types not installed are deactivated.
1512
-			$mts = ! empty( $active_details['settings'][$messenger . '-message_types'] ) ? $active_details['settings'][$messenger . '-message_types'] : array();
1513
-			foreach ( $mts as $mt_name => $mt ) {
1514
-				if ( ! isset( $installed_mts[$mt_name] )  ) {
1515
-					unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] );
1516
-					EEH_MSG_Template::update_to_inactive( $messenger, $mt_name );
1512
+			$mts = ! empty($active_details['settings'][$messenger.'-message_types']) ? $active_details['settings'][$messenger.'-message_types'] : array();
1513
+			foreach ($mts as $mt_name => $mt) {
1514
+				if ( ! isset($installed_mts[$mt_name])) {
1515
+					unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]);
1516
+					EEH_MSG_Template::update_to_inactive($messenger, $mt_name);
1517 1517
 				}
1518 1518
 			}
1519 1519
 		}
1520 1520
 
1521 1521
 		//all done! let's update the active_messengers.
1522
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1523
-		do_action( 'AHEE__EEH_Activation__validate_messages_system' );
1522
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1523
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1524 1524
 	}
1525 1525
 
1526 1526
 
@@ -1533,12 +1533,12 @@  discard block
 block discarded – undo
1533 1533
 	 * 	@static
1534 1534
 	 * 	@return void
1535 1535
 	 */
1536
-	public static function create_no_ticket_prices_array(){
1536
+	public static function create_no_ticket_prices_array() {
1537 1537
 		// this creates an array for tracking events that have no active ticket prices created
1538 1538
 		// this allows us to warn admins of the situation so that it can be corrected
1539
-		$espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE );
1540
-		if ( ! $espresso_no_ticket_prices ) {
1541
-			add_option( 'ee_no_ticket_prices', array(), '', FALSE );
1539
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE);
1540
+		if ( ! $espresso_no_ticket_prices) {
1541
+			add_option('ee_no_ticket_prices', array(), '', FALSE);
1542 1542
 		}
1543 1543
 	}
1544 1544
 
@@ -1562,24 +1562,24 @@  discard block
 block discarded – undo
1562 1562
 	 * @global wpdb $wpdb
1563 1563
 	 * @throws \EE_Error
1564 1564
 	 */
1565
-	public static function delete_all_espresso_cpt_data(){
1565
+	public static function delete_all_espresso_cpt_data() {
1566 1566
 		global $wpdb;
1567 1567
 		//get all the CPT post_types
1568 1568
 		$ee_post_types = array();
1569
-		foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){
1570
-			if ( method_exists( $model_name, 'instance' )) {
1571
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1572
-				if ( $model_obj instanceof EEM_CPT_Base ) {
1573
-					$ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type());
1569
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1570
+			if (method_exists($model_name, 'instance')) {
1571
+				$model_obj = call_user_func(array($model_name, 'instance'));
1572
+				if ($model_obj instanceof EEM_CPT_Base) {
1573
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1574 1574
 				}
1575 1575
 			}
1576 1576
 		}
1577 1577
 		//get all our CPTs
1578
-		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")";
1578
+		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1579 1579
 		$cpt_ids = $wpdb->get_col($query);
1580 1580
 		//delete each post meta and term relations too
1581
-		foreach($cpt_ids as $post_id){
1582
-			wp_delete_post($post_id,true);
1581
+		foreach ($cpt_ids as $post_id) {
1582
+			wp_delete_post($post_id, true);
1583 1583
 		}
1584 1584
 	}
1585 1585
 
@@ -1593,18 +1593,18 @@  discard block
 block discarded – undo
1593 1593
 	 * @param bool $remove_all
1594 1594
 	 * @return void
1595 1595
 	 */
1596
-	public static function delete_all_espresso_tables_and_data( $remove_all = true ) {
1596
+	public static function delete_all_espresso_tables_and_data($remove_all = true) {
1597 1597
 		global $wpdb;
1598 1598
 		$undeleted_tables = array();
1599 1599
 
1600 1600
 		// load registry
1601
-		foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){
1602
-			if ( method_exists( $model_name, 'instance' )) {
1603
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1604
-				if ( $model_obj instanceof EEM_Base ) {
1605
-					foreach ( $model_obj->get_tables() as $table ) {
1606
-						if ( strpos( $table->get_table_name(), 'esp_' )) {
1607
-							switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) {
1601
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1602
+			if (method_exists($model_name, 'instance')) {
1603
+				$model_obj = call_user_func(array($model_name, 'instance'));
1604
+				if ($model_obj instanceof EEM_Base) {
1605
+					foreach ($model_obj->get_tables() as $table) {
1606
+						if (strpos($table->get_table_name(), 'esp_')) {
1607
+							switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) {
1608 1608
 								case false :
1609 1609
 									$undeleted_tables[] = $table->get_table_name();
1610 1610
 								break;
@@ -1629,8 +1629,8 @@  discard block
 block discarded – undo
1629 1629
 			'esp_promotion_rule',
1630 1630
 			'esp_rule'
1631 1631
 		);
1632
-		foreach( $tables_without_models as $table ){
1633
-			EEH_Activation::delete_db_table_if_empty( $table );
1632
+		foreach ($tables_without_models as $table) {
1633
+			EEH_Activation::delete_db_table_if_empty($table);
1634 1634
 		}
1635 1635
 
1636 1636
 
@@ -1668,58 +1668,58 @@  discard block
 block discarded – undo
1668 1668
 			'ee_job_parameters_' => false,
1669 1669
 			'ee_upload_directories_incomplete' => true,
1670 1670
 		);
1671
-		if( is_main_site() ) {
1672
-			$wp_options_to_delete[ 'ee_network_config' ] = true;
1671
+		if (is_main_site()) {
1672
+			$wp_options_to_delete['ee_network_config'] = true;
1673 1673
 		}
1674 1674
 
1675 1675
 		$undeleted_options = array();
1676
-		foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) {
1676
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1677 1677
 
1678
-			if( $no_wildcard ){
1679
-				if( ! delete_option( $option_name ) ){
1678
+			if ($no_wildcard) {
1679
+				if ( ! delete_option($option_name)) {
1680 1680
 					$undeleted_options[] = $option_name;
1681 1681
 				}
1682
-			}else{
1683
-				$option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" );
1684
-				foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){
1685
-					if( ! delete_option( $option_name_from_wildcard ) ){
1682
+			} else {
1683
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1684
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1685
+					if ( ! delete_option($option_name_from_wildcard)) {
1686 1686
 						$undeleted_options[] = $option_name_from_wildcard;
1687 1687
 					}
1688 1688
 				}
1689 1689
 			}
1690 1690
 		}
1691 1691
                 //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1692
-                remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 );
1692
+                remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1693 1693
 
1694
-		if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) {
1694
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1695 1695
 			$db_update_sans_ee4 = array();
1696
-			foreach($espresso_db_update as $version => $times_activated){
1697
-				if( (string)$version[0] === '3'){//if its NON EE4
1696
+			foreach ($espresso_db_update as $version => $times_activated) {
1697
+				if ((string) $version[0] === '3') {//if its NON EE4
1698 1698
 					$db_update_sans_ee4[$version] = $times_activated;
1699 1699
 				}
1700 1700
 			}
1701
-			update_option( 'espresso_db_update', $db_update_sans_ee4 );
1701
+			update_option('espresso_db_update', $db_update_sans_ee4);
1702 1702
 		}
1703 1703
 
1704 1704
 		$errors = '';
1705
-		if ( ! empty( $undeleted_tables )) {
1705
+		if ( ! empty($undeleted_tables)) {
1706 1706
 			$errors .= sprintf(
1707
-				__( 'The following tables could not be deleted: %s%s', 'event_espresso' ),
1707
+				__('The following tables could not be deleted: %s%s', 'event_espresso'),
1708 1708
 				'<br/>',
1709
-				implode( ',<br/>', $undeleted_tables )
1709
+				implode(',<br/>', $undeleted_tables)
1710 1710
 			);
1711 1711
 		}
1712
-		if ( ! empty( $undeleted_options )) {
1713
-			$errors .= ! empty( $undeleted_tables ) ? '<br/>' : '';
1712
+		if ( ! empty($undeleted_options)) {
1713
+			$errors .= ! empty($undeleted_tables) ? '<br/>' : '';
1714 1714
 			$errors .= sprintf(
1715
-				__( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ),
1715
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1716 1716
 				'<br/>',
1717
-				implode( ',<br/>', $undeleted_options )
1717
+				implode(',<br/>', $undeleted_options)
1718 1718
 			);
1719 1719
 
1720 1720
 		}
1721
-		if ( ! empty( $errors ) ) {
1722
-			EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ );
1721
+		if ( ! empty($errors)) {
1722
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1723 1723
 		}
1724 1724
 	}
1725 1725
 
@@ -1729,23 +1729,23 @@  discard block
 block discarded – undo
1729 1729
 	 * @param string $table_name with or without $wpdb->prefix
1730 1730
 	 * @return boolean
1731 1731
 	 */
1732
-	public static function table_exists( $table_name ){
1732
+	public static function table_exists($table_name) {
1733 1733
 		global $wpdb, $EZSQL_ERROR;
1734
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
1734
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
1735 1735
 		//ignore if this causes an sql error
1736 1736
 		$old_error = $wpdb->last_error;
1737 1737
 		$old_suppress_errors = $wpdb->suppress_errors();
1738
-		$old_show_errors_value = $wpdb->show_errors( FALSE );
1738
+		$old_show_errors_value = $wpdb->show_errors(FALSE);
1739 1739
 		$ezsql_error_cache = $EZSQL_ERROR;
1740
-		$wpdb->get_results( "SELECT * from $table_name LIMIT 1");
1741
-		$wpdb->show_errors( $old_show_errors_value );
1742
-		$wpdb->suppress_errors( $old_suppress_errors );
1740
+		$wpdb->get_results("SELECT * from $table_name LIMIT 1");
1741
+		$wpdb->show_errors($old_show_errors_value);
1742
+		$wpdb->suppress_errors($old_suppress_errors);
1743 1743
 		$new_error = $wpdb->last_error;
1744 1744
 		$wpdb->last_error = $old_error;
1745 1745
 		$EZSQL_ERROR = $ezsql_error_cache;
1746
-		if( empty( $new_error ) ){
1746
+		if (empty($new_error)) {
1747 1747
 			return TRUE;
1748
-		}else{
1748
+		} else {
1749 1749
 			return FALSE;
1750 1750
 		}
1751 1751
 	}
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 	/**
1754 1754
 	 * Resets the cache on EEH_Activation
1755 1755
 	 */
1756
-	public static function reset(){
1756
+	public static function reset() {
1757 1757
 		self::$_default_creator_id = NULL;
1758 1758
 		self::$_initialized_db_content_already_in_this_request = false;
1759 1759
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
465 465
 		if($post_id){
466 466
 			return get_post($post_id);
467
-		}else{
467
+		} else{
468 468
 			return NULL;
469 469
 		}
470 470
 
@@ -836,13 +836,13 @@  discard block
 block discarded – undo
836 836
 					foreach( $current_data_migration_script->get_errors() as $error ){
837 837
 						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ );
838 838
 					}
839
-				}else{
839
+				} else{
840 840
 					EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) );
841 841
 				}
842 842
 				return false;
843 843
 			}
844 844
 			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
845
-		}else{
845
+		} else{
846 846
 			EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
847 847
 			return false;
848 848
 		}
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
 		if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){
1173 1173
 			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
1174 1174
 			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
1175
-		}else{
1175
+		} else{
1176 1176
 			EEM_Payment_Method::instance()->verify_button_urls();
1177 1177
 		}
1178 1178
 	}
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
 				if( ! delete_option( $option_name ) ){
1680 1680
 					$undeleted_options[] = $option_name;
1681 1681
 				}
1682
-			}else{
1682
+			} else{
1683 1683
 				$option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" );
1684 1684
 				foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){
1685 1685
 					if( ! delete_option( $option_name_from_wildcard ) ){
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 		$EZSQL_ERROR = $ezsql_error_cache;
1746 1746
 		if( empty( $new_error ) ){
1747 1747
 			return TRUE;
1748
-		}else{
1748
+		} else{
1749 1749
 			return FALSE;
1750 1750
 		}
1751 1751
 	}
Please login to merge, or discard this patch.
core/EE_Request_Handler.core.php 2 patches
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2 2
 /**
3 3
  * class EE_Request_Handler
4 4
  *
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 	 * @param WP $wp
51 51
 	 * @return \EE_Request_Handler
52 52
 	 */
53
-	public function __construct( $wp = null ) {
53
+	public function __construct($wp = null) {
54 54
 		// grab request vars
55 55
 		// NOTE: WHEN MERGING TO 4.9 PLZ FAVOUR THE CHANGES IN 4.9 OVER THE FOLLOWING LINE
56
-		$this->_params = array_merge( $_GET, $_POST );
56
+		$this->_params = array_merge($_GET, $_POST);
57 57
 		// AJAX ???
58
-		$this->ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false;
59
-		$this->front_ajax = defined( 'EE_FRONT_AJAX' ) && EE_FRONT_AJAX ? true : false;
60
-		do_action( 'AHEE__EE_Request_Handler__construct__complete' );
58
+		$this->ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false;
59
+		$this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX ? true : false;
60
+		do_action('AHEE__EE_Request_Handler__construct__complete');
61 61
 	}
62 62
 
63 63
 
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 	 * @param WP $wp
70 70
 	 * @return void
71 71
 	 */
72
-	public function parse_request( $wp = null ) {
72
+	public function parse_request($wp = null) {
73 73
 		//if somebody forgot to provide us with WP, that's ok because its global
74
-		if ( ! $wp instanceof WP ) {
74
+		if ( ! $wp instanceof WP) {
75 75
 			global $wp;
76 76
 		}
77
-		$this->set_request_vars( $wp );
77
+		$this->set_request_vars($wp);
78 78
 	}
79 79
 
80 80
 
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
 	 * @param WP $wp
87 87
 	 * @return void
88 88
 	 */
89
-	public function set_request_vars( $wp = null ) {
90
-		if ( ! is_admin() ) {
89
+	public function set_request_vars($wp = null) {
90
+		if ( ! is_admin()) {
91 91
 			// set request post_id
92
-			$this->set( 'post_id', $this->get_post_id_from_request( $wp ));
92
+			$this->set('post_id', $this->get_post_id_from_request($wp));
93 93
 			// set request post name
94
-			$this->set( 'post_name', $this->get_post_name_from_request( $wp ));
94
+			$this->set('post_name', $this->get_post_name_from_request($wp));
95 95
 			// set request post_type
96
-			$this->set( 'post_type', $this->get_post_type_from_request( $wp ));
96
+			$this->set('post_type', $this->get_post_type_from_request($wp));
97 97
 			// true or false ? is this page being used by EE ?
98 98
 			$this->set_espresso_page();
99 99
 		}
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
 	 * @param WP $wp
109 109
 	 * @return int
110 110
 	 */
111
-	public function get_post_id_from_request( $wp = null ) {
112
-		if ( ! $wp instanceof WP ){
111
+	public function get_post_id_from_request($wp = null) {
112
+		if ( ! $wp instanceof WP) {
113 113
 			global $wp;
114 114
 		}
115 115
 		$post_id = null;
116
-		if ( isset( $wp->query_vars['p'] )) {
116
+		if (isset($wp->query_vars['p'])) {
117 117
 			$post_id = $wp->query_vars['p'];
118 118
 		}
119
-		if ( ! $post_id && isset( $wp->query_vars['page_id'] )) {
119
+		if ( ! $post_id && isset($wp->query_vars['page_id'])) {
120 120
 			$post_id = $wp->query_vars['page_id'];
121 121
 		}
122
-		if ( ! $post_id && isset( $wp->request ) && is_numeric( basename( $wp->request ))) {
123
-			$post_id = basename( $wp->request );
122
+		if ( ! $post_id && isset($wp->request) && is_numeric(basename($wp->request))) {
123
+			$post_id = basename($wp->request);
124 124
 		}
125 125
 		return $post_id;
126 126
 	}
@@ -134,35 +134,35 @@  discard block
 block discarded – undo
134 134
 	 * @param WP $wp
135 135
 	 * @return string
136 136
 	 */
137
-	public function get_post_name_from_request( $wp = null ) {
138
-		if ( ! $wp instanceof WP ){
137
+	public function get_post_name_from_request($wp = null) {
138
+		if ( ! $wp instanceof WP) {
139 139
 			global $wp;
140 140
 		}
141 141
 		$post_name = null;
142
-		if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) {
142
+		if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) {
143 143
 			$post_name = $wp->query_vars['name'];
144 144
 		}
145
-		if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) {
145
+		if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) {
146 146
 			$post_name = $wp->query_vars['pagename'];
147 147
 		}
148
-		if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) {
149
-			$possible_post_name = basename( $wp->request );
150
-			if ( ! is_numeric( $possible_post_name )) {
148
+		if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) {
149
+			$possible_post_name = basename($wp->request);
150
+			if ( ! is_numeric($possible_post_name)) {
151 151
 				/** @type WPDB $wpdb */
152 152
 				global $wpdb;
153 153
 				$SQL = "SELECT ID from $wpdb->posts WHERE post_status='publish' AND post_name=%s";
154
-				$possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name ));
155
-				if ( $possible_post_name ) {
154
+				$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name));
155
+				if ($possible_post_name) {
156 156
 					$post_name = $possible_post_name;
157 157
 				}
158 158
 			}
159 159
 		}
160
-		if ( ! $post_name && $this->get( 'post_id' )) {
160
+		if ( ! $post_name && $this->get('post_id')) {
161 161
 			/** @type WPDB $wpdb */
162 162
 			global $wpdb;
163 163
 			$SQL = "SELECT post_name from $wpdb->posts WHERE post_status='publish' AND ID=%d";
164
-			$possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' )));
165
-			if( $possible_post_name ) {
164
+			$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id')));
165
+			if ($possible_post_name) {
166 166
 				$post_name = $possible_post_name;
167 167
 			}
168 168
 		}
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 	 * @param WP $wp
179 179
 	 * @return mixed
180 180
 	 */
181
-	public function get_post_type_from_request( $wp = null ) {
182
-		if ( ! $wp instanceof WP ){
181
+	public function get_post_type_from_request($wp = null) {
182
+		if ( ! $wp instanceof WP) {
183 183
 			global $wp;
184 184
 		}
185
-		return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null;
185
+		return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null;
186 186
 	}
187 187
 
188 188
 
@@ -192,18 +192,18 @@  discard block
 block discarded – undo
192 192
 	 * @param  WP $wp
193 193
 	 * @return bool|string|void
194 194
 	 */
195
-	public function get_current_page_permalink( $wp = null ) {
196
-		$post_id = $this->get_post_id_from_request( $wp );
197
-		if ( $post_id ) {
198
-			$current_page_permalink = get_permalink( $post_id );
195
+	public function get_current_page_permalink($wp = null) {
196
+		$post_id = $this->get_post_id_from_request($wp);
197
+		if ($post_id) {
198
+			$current_page_permalink = get_permalink($post_id);
199 199
 		} else {
200
-			if ( ! $wp instanceof WP ) {
200
+			if ( ! $wp instanceof WP) {
201 201
 				global $wp;
202 202
 			}
203
-			if ( $wp->request ) {
204
-				$current_page_permalink = site_url( $wp->request );
203
+			if ($wp->request) {
204
+				$current_page_permalink = site_url($wp->request);
205 205
 			} else {
206
-				$current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) );
206
+				$current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI']));
207 207
 			}
208 208
 		}
209 209
 		return $current_page_permalink;
@@ -220,41 +220,41 @@  discard block
 block discarded – undo
220 220
 	public function test_for_espresso_page() {
221 221
 		global $wp;
222 222
 		/** @type EE_CPT_Strategy $EE_CPT_Strategy */
223
-		$EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' );
223
+		$EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy');
224 224
 		$espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies();
225
-		if ( is_array( $espresso_CPT_taxonomies ) ) {
226
-			foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) {
227
-				if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) {
225
+		if (is_array($espresso_CPT_taxonomies)) {
226
+			foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) {
227
+				if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) {
228 228
 					return true;
229 229
 				}
230 230
 			}
231 231
 		}
232 232
 		// load espresso CPT endpoints
233 233
 		$espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints();
234
-		$post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints );
235
-		$post_types = (array)$this->get( 'post_type' );
236
-		foreach ( $post_types as $post_type ) {
234
+		$post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);
235
+		$post_types = (array) $this->get('post_type');
236
+		foreach ($post_types as $post_type) {
237 237
 			// was a post name passed ?
238
-			if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) {
238
+			if (isset($post_type_CPT_endpoints[$post_type])) {
239 239
 				// kk we know this is an espresso page, but is it a specific post ?
240
-				if ( ! $this->get( 'post_name' ) ) {
240
+				if ( ! $this->get('post_name')) {
241 241
 					// there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events
242
-					$post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] : null;
242
+					$post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) ? $post_type_CPT_endpoints[$this->get('post_type')] : null;
243 243
 					// if the post type matches on of our then set the endpoint
244
-					if ( $post_name ) {
245
-						$this->set( 'post_name', $post_name );
244
+					if ($post_name) {
245
+						$this->set('post_name', $post_name);
246 246
 					}
247 247
 				}
248 248
 				return true;
249 249
 			}
250 250
 		}
251
-		if ( $this->get( 'post_name' )) {
251
+		if ($this->get('post_name')) {
252 252
 			// load all pages using espresso shortcodes
253
-			$post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array();
253
+			$post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array();
254 254
 			// make sure core pages are included
255
-			$espresso_pages = array_merge( $espresso_CPT_endpoints, $post_shortcodes );
255
+			$espresso_pages = array_merge($espresso_CPT_endpoints, $post_shortcodes);
256 256
 			// was a post name passed ?
257
-			if (  isset( $espresso_pages[ $this->get( 'post_name' ) ] )) {
257
+			if (isset($espresso_pages[$this->get('post_name')])) {
258 258
 				 return true;
259 259
 			}
260 260
 		}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @param null|bool $value
271 271
 	 * @return    mixed
272 272
 	 */
273
-	public function set_espresso_page( $value = null ) {
273
+	public function set_espresso_page($value = null) {
274 274
 		$value = $value ? $value : $this->test_for_espresso_page();
275 275
 		$this->_params['is_espresso_page'] = $value;
276 276
 	}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 *  @return 	mixed
285 285
 	 */
286 286
 	public function is_espresso_page() {
287
-		return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false;
287
+		return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false;
288 288
 	}
289 289
 
290 290
 
@@ -308,14 +308,14 @@  discard block
 block discarded – undo
308 308
 	 * @param bool $override_ee
309 309
 	 * @return    void
310 310
 	 */
311
-	public function set( $key, $value, $override_ee = false ) {
311
+	public function set($key, $value, $override_ee = false) {
312 312
 		// don't allow "ee" to be overwritten unless explicitly instructed to do so
313 313
 		if (
314 314
 			$key !== 'ee' ||
315
-			( $key === 'ee' && empty( $this->_params['ee'] ))
316
-			|| ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )
315
+			($key === 'ee' && empty($this->_params['ee']))
316
+			|| ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)
317 317
 		) {
318
-			$this->_params[ $key ] = $value;
318
+			$this->_params[$key] = $value;
319 319
 		}
320 320
 	}
321 321
 
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 	 * @param null $default
330 330
 	 * @return    mixed
331 331
 	 */
332
-	public function get( $key, $default = null ) {
333
-		return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default;
332
+	public function get($key, $default = null) {
333
+		return isset($this->_params[$key]) ? $this->_params[$key] : $default;
334 334
 	}
335 335
 
336 336
 
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 	 * @param $key
343 343
 	 * @return    boolean
344 344
 	 */
345
-	public function is_set( $key ) {
346
-		return isset( $this->_params[ $key ] ) ? true : false;
345
+	public function is_set($key) {
346
+		return isset($this->_params[$key]) ? true : false;
347 347
 	}
348 348
 
349 349
 
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	 * @param $key
356 356
 	 * @return    void
357 357
 	 */
358
-	public function un_set( $key ) {
359
-		unset( $this->_params[ $key ] );
358
+	public function un_set($key) {
359
+		unset($this->_params[$key]);
360 360
 	}
361 361
 
362 362
 
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	 * @param $value
370 370
 	 * @return    void
371 371
 	 */
372
-	public function set_notice( $key, $value ) {
373
-		$this->_notice[ $key ] = $value;
372
+	public function set_notice($key, $value) {
373
+		$this->_notice[$key] = $value;
374 374
 	}
375 375
 
376 376
 
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param $key
383 383
 	 * @return    mixed
384 384
 	 */
385
-	public function get_notice( $key ) {
386
-		return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null;
385
+	public function get_notice($key) {
386
+		return isset($this->_notice[$key]) ? $this->_notice[$key] : null;
387 387
 	}
388 388
 
389 389
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 * @param $string
396 396
 	 * @return    void
397 397
 	 */
398
-	public function add_output( $string ) {
398
+	public function add_output($string) {
399 399
 		$this->_output .= $string;
400 400
 	}
401 401
 
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
 	 * @param $item
418 418
 	 * @param $key
419 419
 	 */
420
-	public function sanitize_text_field_for_array_walk( &$item, &$key ) {
421
-		$item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item );
420
+	public function sanitize_text_field_for_array_walk(&$item, &$key) {
421
+		$item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item);
422 422
 	}
423 423
 
424 424
 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 * @param $b
429 429
 	 * @return bool
430 430
 	 */
431
-	public function __set($a,$b) { return false; }
431
+	public function __set($a, $b) { return false; }
432 432
 
433 433
 
434 434
 
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
2 2
 /**
3
- * class EE_Request_Handler
4
- *
5
- * @package     Event Espresso
6
- * @subpackage  /core/
7
- * @author      Brent Christensen
8
- */
3
+  * class EE_Request_Handler
4
+  *
5
+  * @package     Event Espresso
6
+  * @subpackage  /core/
7
+  * @author      Brent Christensen
8
+  */
9 9
 final class EE_Request_Handler {
10 10
 
11 11
 	/**
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_SPCO_Reg_Step_Attendee_Information
5
- *
6
- * Description
7
- *
8
- * @package 			Event Espresso
9
- * @subpackage 	core
10
- * @author 				Brent Christensen
11
- * @since 				4.5.0
12
- *
13
- */
3
+  *
4
+  * Class EE_SPCO_Reg_Step_Attendee_Information
5
+  *
6
+  * Description
7
+  *
8
+  * @package 			Event Espresso
9
+  * @subpackage 	core
10
+  * @author 				Brent Christensen
11
+  * @since 				4.5.0
12
+  *
13
+  */
14 14
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step {
15 15
 
16 16
 	/**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 				// generate hidden input
172 172
 				if (
173 173
 					isset( $subsections[ $primary_registrant ] )
174
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
174
+					 && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
175 175
 				) {
176 176
 					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
177 177
 				}
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 					if ( isset( $valid_data[ $reg_url_link ] ) ) {
903 903
 						// do we need to copy basic info from primary attendee ?
904 904
 						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
905
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
905
+										&& absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
906 906
 							? true
907 907
 							: false;
908 908
 						// filter form input data for this registration
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 			? $form_input
1080 1080
 			: $form_input . '-' . $registration->reg_url_link();
1081 1081
 		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1082
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1082
+						 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1083 1083
 			? true
1084 1084
 			: false;
1085 1085
 		//rename form_inputs if they are EE_Attendee properties
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 		}
1320 1320
 		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1321 1321
 			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1322
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1322
+				 || empty( $attendee_data[ $critical_attendee_detail ] )
1323 1323
 			) {
1324 1324
 				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1325 1325
 					$critical_attendee_detail
Please login to merge, or discard this patch.
Spacing   +237 added lines, -238 removed lines patch added patch discarded remove patch
@@ -42,21 +42,21 @@  discard block
 block discarded – undo
42 42
 	 * @param    EE_Checkout $checkout
43 43
 	 * @return    \EE_SPCO_Reg_Step_Attendee_Information
44 44
 	 */
45
-	public function __construct( EE_Checkout $checkout ) {
45
+	public function __construct(EE_Checkout $checkout) {
46 46
 		$this->_slug = 'attendee_information';
47 47
 		$this->_name = __('Attendee Information', 'event_espresso');
48
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php';
48
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php';
49 49
 		$this->checkout = $checkout;
50 50
 		$this->_reset_success_message();
51 51
 		$this->set_instructions(
52
-			__( 'Please answer the following registration questions before proceeding.', 'event_espresso' )
52
+			__('Please answer the following registration questions before proceeding.', 'event_espresso')
53 53
 		);
54 54
 	}
55 55
 
56 56
 
57 57
 
58 58
 	public function translate_js_strings() {
59
-		EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' );
59
+		EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso');
60 60
 		EE_Registry::$i18n_js_strings['required_multi_field'] = __(
61 61
 			' is a required question. Please enter a value for at least one of the options.',
62 62
 			'event_espresso'
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		// calculate taxes
117 117
 		$Line_Item_Display->display_line_item(
118 118
 			$this->checkout->cart->get_grand_total(),
119
-			array( 'set_tax_rate' => true )
119
+			array('set_tax_rate' => true)
120 120
 		);
121 121
 		EE_Registry::instance()->load_helper('Line_Item');
122 122
 		/** @var $subsections EE_Form_Section_Proper[] */
@@ -129,51 +129,51 @@  discard block
 block discarded – undo
129 129
 			'ticket_count' 	=> array()
130 130
 		);
131 131
 		// grab the saved registrations from the transaction
132
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
133
-		if ( $registrations ) {
134
-			foreach ( $registrations as $registration ) {
132
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
133
+		if ($registrations) {
134
+			foreach ($registrations as $registration) {
135 135
 				// can this registration be processed during this visit ?
136 136
 				if (
137 137
 					$registration instanceof EE_Registration
138
-					&& $this->checkout->visit_allows_processing_of_this_registration( $registration )
138
+					&& $this->checkout->visit_allows_processing_of_this_registration($registration)
139 139
 				) {
140
-					$subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form( $registration );
141
-					if ( ! $this->checkout->admin_request ) {
142
-						$template_args['registrations'][ $registration->reg_url_link() ] = $registration;
143
-						$template_args['ticket_count'][ $registration->ticket()->ID() ] = isset(
144
-							$template_args['ticket_count'][ $registration->ticket()->ID() ]
140
+					$subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration);
141
+					if ( ! $this->checkout->admin_request) {
142
+						$template_args['registrations'][$registration->reg_url_link()] = $registration;
143
+						$template_args['ticket_count'][$registration->ticket()->ID()] = isset(
144
+							$template_args['ticket_count'][$registration->ticket()->ID()]
145 145
 						)
146
-							? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1
146
+							? $template_args['ticket_count'][$registration->ticket()->ID()] + 1
147 147
 							: 1;
148 148
 						$ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs(
149 149
 							$this->checkout->cart->get_grand_total(),
150 150
 							'Ticket',
151
-							array( $registration->ticket()->ID() )
151
+							array($registration->ticket()->ID())
152 152
 						);
153
-						$ticket_line_item = is_array( $ticket_line_item )
154
-							? reset( $ticket_line_item )
153
+						$ticket_line_item = is_array($ticket_line_item)
154
+							? reset($ticket_line_item)
155 155
 							: $ticket_line_item;
156
-						$template_args['ticket_line_item'][ $registration->ticket()->ID() ] = $Line_Item_Display->display_line_item(
156
+						$template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item(
157 157
 							$ticket_line_item
158 158
 						);
159 159
 					}
160
-					if ( $registration->is_primary_registrant() ) {
160
+					if ($registration->is_primary_registrant()) {
161 161
 						$primary_registrant = $registration->reg_url_link();
162 162
 					}
163 163
 				}
164 164
 			}
165 165
 			// print_copy_info ?
166
-			if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) {
166
+			if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) {
167 167
 				// TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info
168 168
 				$copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info
169 169
 					? $this->_copy_attendee_info_form()
170 170
 					: $this->_auto_copy_attendee_info();
171 171
 				// generate hidden input
172 172
 				if (
173
-					isset( $subsections[ $primary_registrant ] )
174
-				     && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper
173
+					isset($subsections[$primary_registrant])
174
+				     && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper
175 175
 				) {
176
-					$subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false );
176
+					$subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false);
177 177
 				}
178 178
 			}
179 179
 
@@ -185,8 +185,7 @@  discard block
 block discarded – undo
185 185
 				'html_id' 					=> $this->reg_form_name(),
186 186
 				'subsections' 			=> $subsections,
187 187
 				'layout_strategy'		=> $this->checkout->admin_request ?
188
-					new EE_Div_Per_Section_Layout() :
189
-					new EE_Template_Layout(
188
+					new EE_Div_Per_Section_Layout() : new EE_Template_Layout(
190 189
 						array(
191 190
 							'layout_template_file' 	=> $this->_template, // layout_template
192 191
 							'template_args' 				=> $template_args
@@ -204,12 +203,12 @@  discard block
 block discarded – undo
204 203
 	 * @return EE_Form_Section_Proper
205 204
 	 * @throws \EE_Error
206 205
 	 */
207
-	private function _registrations_reg_form( EE_Registration $registration ) {
208
-		EE_Registry::instance()->load_helper( 'Template' );
206
+	private function _registrations_reg_form(EE_Registration $registration) {
207
+		EE_Registry::instance()->load_helper('Template');
209 208
 		static $attendee_nmbr = 1;
210 209
 		// array of params to pass to parent constructor
211 210
 		$form_args = array(
212
-			'html_id'         => 'ee-registration-' . $registration->reg_url_link(),
211
+			'html_id'         => 'ee-registration-'.$registration->reg_url_link(),
213 212
 			'html_class'      => 'ee-reg-form-attendee-dv',
214 213
 			'html_style'      => $this->checkout->admin_request
215 214
 				? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;'
@@ -218,24 +217,24 @@  discard block
 block discarded – undo
218 217
 			'layout_strategy' => new EE_Fieldset_Section_Layout(
219 218
 				array(
220 219
 					'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text',
221
-					'legend_text'  => sprintf( __( 'Attendee %d', 'event_espresso' ), $attendee_nmbr )
220
+					'legend_text'  => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr)
222 221
 				)
223 222
 			)
224 223
 		);
225 224
 		// verify that registration has valid event
226
-		if ( $registration->event() instanceof EE_Event ) {
225
+		if ($registration->event() instanceof EE_Event) {
227 226
 			$query_params = array(
228 227
 				array(
229 228
 					'Event.EVT_ID' => $registration->event()->ID(),
230 229
 					'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false
231 230
 				),
232
-				'order_by'=>array( 'QSG_order'=>'ASC' )
231
+				'order_by'=>array('QSG_order'=>'ASC')
233 232
 			);
234
-			$question_groups = $registration->event()->question_groups( $query_params );
235
-			if ( $question_groups ) {
236
-				foreach ( $question_groups as $question_group ) {
237
-					if ( $question_group instanceof EE_Question_Group ) {
238
-						$form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form(
233
+			$question_groups = $registration->event()->question_groups($query_params);
234
+			if ($question_groups) {
235
+				foreach ($question_groups as $question_group) {
236
+					if ($question_group instanceof EE_Question_Group) {
237
+						$form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form(
239 238
 							$registration,
240 239
 							$question_group
241 240
 						);
@@ -248,10 +247,10 @@  discard block
 block discarded – undo
248 247
 				// if we have question groups for additional attendees, then display the copy options
249 248
 				$this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info;
250 249
 			} else {
251
-				$form_args['subsections'][ 'attendee_info_not_required_' . $registration->reg_url_link(
252
-				) ] = new EE_Form_Section_HTML(
250
+				$form_args['subsections']['attendee_info_not_required_'.$registration->reg_url_link(
251
+				)] = new EE_Form_Section_HTML(
253 252
 					EEH_Template::locate_template(
254
-						SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_not_required.template.php',
253
+						SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_not_required.template.php',
255 254
 						apply_filters(
256 255
 							'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args',
257 256
 							array()
@@ -267,12 +266,12 @@  discard block
 block discarded – undo
267 266
 				);
268 267
 			}
269 268
 		}
270
-		if ( $registration->is_primary_registrant() ) {
269
+		if ($registration->is_primary_registrant()) {
271 270
 			// generate hidden input
272
-			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( $registration );
271
+			$form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration);
273 272
 		}
274 273
 		$attendee_nmbr++;
275
-		return new EE_Form_Section_Proper( $form_args );
274
+		return new EE_Form_Section_Proper($form_args);
276 275
 	}
277 276
 
278 277
 
@@ -293,7 +292,7 @@  discard block
 block discarded – undo
293 292
 		// generate hidden input
294 293
 		return new EE_Hidden_Input(
295 294
 			array(
296
-				'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(),
295
+				'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(),
297 296
 				'default' => $additional_attendee_reg_info
298 297
 			)
299 298
 		);
@@ -307,26 +306,26 @@  discard block
 block discarded – undo
307 306
 	 * @return EE_Form_Section_Proper
308 307
 	 * @throws \EE_Error
309 308
 	 */
310
-	private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){
309
+	private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) {
311 310
 		// array of params to pass to parent constructor
312 311
 		$form_args = array(
313
-			'html_id'         => 'ee-reg-form-qstn-grp-' . $question_group->identifier(),
312
+			'html_id'         => 'ee-reg-form-qstn-grp-'.$question_group->identifier(),
314 313
 			'html_class'      => $this->checkout->admin_request
315 314
 				? 'form-table ee-reg-form-qstn-grp-dv'
316 315
 				: 'ee-reg-form-qstn-grp-dv',
317
-			'html_label_id'   => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl',
316
+			'html_label_id'   => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl',
318 317
 			'subsections'     => array(
319
-				'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group )
318
+				'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group)
320 319
 			),
321 320
 			'layout_strategy' => $this->checkout->admin_request
322 321
 				? new EE_Admin_Two_Column_Layout()
323 322
 				: new EE_Div_Per_Section_Layout()
324 323
 		);
325 324
 		// where params
326
-		$query_params = array( 'QST_deleted' => 0 );
325
+		$query_params = array('QST_deleted' => 0);
327 326
 		// don't load admin only questions on the frontend
328
-		if ( ! $this->checkout->admin_request ) {
329
-			$query_params['QST_admin_only'] = array( '!=', true );
327
+		if ( ! $this->checkout->admin_request) {
328
+			$query_params['QST_admin_only'] = array('!=', true);
330 329
 		}
331 330
 		$questions = $question_group->get_many_related(
332 331
 			'Question',
@@ -348,10 +347,10 @@  discard block
 block discarded – undo
348 347
 			)
349 348
 		);
350 349
 		// loop thru questions
351
-		foreach ( $questions as $question ) {
352
-			if( $question instanceof EE_Question ){
350
+		foreach ($questions as $question) {
351
+			if ($question instanceof EE_Question) {
353 352
 				$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
354
-				$form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question );
353
+				$form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question);
355 354
 			}
356 355
 		}
357 356
 		$form_args['subsections'] = apply_filters(
@@ -372,7 +371,7 @@  discard block
 block discarded – undo
372 371
 			)
373 372
 		);
374 373
 //		d( $form_args );
375
-		$question_group_reg_form = new EE_Form_Section_Proper( $form_args );
374
+		$question_group_reg_form = new EE_Form_Section_Proper($form_args);
376 375
 		return apply_filters(
377 376
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form',
378 377
 			$question_group_reg_form,
@@ -389,12 +388,12 @@  discard block
 block discarded – undo
389 388
 	 * @param EE_Question_Group $question_group
390 389
 	 * @return 	EE_Form_Section_HTML
391 390
 	 */
392
-	private function _question_group_header( EE_Question_Group $question_group ){
391
+	private function _question_group_header(EE_Question_Group $question_group) {
393 392
 		$html = '';
394 393
 		// group_name
395
-		if ( $question_group->show_group_name() && $question_group->name() !== '' ) {
394
+		if ($question_group->show_group_name() && $question_group->name() !== '') {
396 395
 			EE_Registry::instance()->load_helper('HTML');
397
-			if ( $this->checkout->admin_request ) {
396
+			if ($this->checkout->admin_request) {
398 397
 				$html .= EEH_HTML::br();
399 398
 				$html .= EEH_HTML::h3(
400 399
 					$question_group->name(),
@@ -408,7 +407,7 @@  discard block
 block discarded – undo
408 407
 			}
409 408
 		}
410 409
 		// group_desc
411
-		if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) {
410
+		if ($question_group->show_group_desc() && $question_group->desc() !== '') {
412 411
 			$html .= EEH_HTML::p(
413 412
 				$question_group->desc(),
414 413
 				'',
@@ -418,7 +417,7 @@  discard block
 block discarded – undo
418 417
 			);
419 418
 
420 419
 		}
421
-		return new EE_Form_Section_HTML( $html );
420
+		return new EE_Form_Section_HTML($html);
422 421
 	}
423 422
 
424 423
 
@@ -428,7 +427,7 @@  discard block
 block discarded – undo
428 427
 	 * @return    EE_Form_Section_Proper
429 428
 	 * @throws \EE_Error
430 429
 	 */
431
-	private function _copy_attendee_info_form(){
430
+	private function _copy_attendee_info_form() {
432 431
 		// array of params to pass to parent constructor
433 432
 		return new EE_Form_Section_Proper(
434 433
 			array(
@@ -457,7 +456,7 @@  discard block
 block discarded – undo
457 456
 	private function _auto_copy_attendee_info() {
458 457
 		return new EE_Form_Section_HTML(
459 458
 			EEH_Template::locate_template(
460
-				SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php',
459
+				SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php',
461 460
 				apply_filters(
462 461
 					'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args',
463 462
 					array()
@@ -481,32 +480,32 @@  discard block
 block discarded – undo
481 480
 		$copy_attendee_info_inputs = array();
482 481
 		$prev_ticket = NULL;
483 482
 		// grab the saved registrations from the transaction
484
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
485
-		foreach ( $registrations as $registration ) {
483
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
484
+		foreach ($registrations as $registration) {
486 485
 			// for all  attendees other than the primary attendee
487
-			if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) {
486
+			if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) {
488 487
 				// if this is a new ticket OR if this is the very first additional attendee after the primary attendee
489
-				if ( $registration->ticket()->ID() !== $prev_ticket ) {
488
+				if ($registration->ticket()->ID() !== $prev_ticket) {
490 489
 					$item_name = $registration->ticket()->name();
491 490
 					$item_name .= $registration->ticket()->description() !== ''
492
-						? ' - ' . $registration->ticket()->description()
491
+						? ' - '.$registration->ticket()->description()
493 492
 						: '';
494
-					$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML(
495
-						'<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>'
493
+					$copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML(
494
+						'<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>'
496 495
 					);
497 496
 					$prev_ticket = $registration->ticket()->ID();
498 497
 				}
499 498
 
500
-				$copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new
499
+				$copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new
501 500
 				EE_Checkbox_Multi_Input(
502 501
 					array(
503 502
 						$registration->ID() => sprintf(
504
-							__( 'Attendee #%s', 'event_espresso' ),
503
+							__('Attendee #%s', 'event_espresso'),
505 504
 							$registration->count()
506 505
 						)
507 506
 					),
508 507
 					array(
509
-						'html_id'                 => 'spco-copy-attendee-chk-' . $registration->reg_url_link(),
508
+						'html_id'                 => 'spco-copy-attendee-chk-'.$registration->reg_url_link(),
510 509
 						'html_class'              => 'spco-copy-attendee-chk ee-do-not-validate',
511 510
 						'display_html_label_text' => false
512 511
 					)
@@ -526,7 +525,7 @@  discard block
 block discarded – undo
526 525
 	 * @return    EE_Form_Input_Base
527 526
 	 * @throws \EE_Error
528 527
 	 */
529
-	private function _additional_primary_registrant_inputs( EE_Registration $registration ){
528
+	private function _additional_primary_registrant_inputs(EE_Registration $registration) {
530 529
 		// generate hidden input
531 530
 		return new EE_Hidden_Input(
532 531
 			array(
@@ -545,7 +544,7 @@  discard block
 block discarded – undo
545 544
 	 * @return    EE_Form_Input_Base
546 545
 	 * @throws \EE_Error
547 546
 	 */
548
-	public function reg_form_question( EE_Registration $registration, EE_Question $question ){
547
+	public function reg_form_question(EE_Registration $registration, EE_Question $question) {
549 548
 
550 549
 		// if this question was for an attendee detail, then check for that answer
551 550
 		$answer_value = EEM_Answer::instance()->get_attendee_property_answer_value(
@@ -554,31 +553,31 @@  discard block
 block discarded – undo
554 553
 		);
555 554
 		$answer = $answer_value === null
556 555
 			? EEM_Answer::instance()->get_one(
557
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
556
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
558 557
 			)
559 558
 			: null;
560 559
 		// if NOT returning to edit an existing registration
561 560
 		// OR if this question is for an attendee property
562 561
 		// OR we still don't have an EE_Answer object
563
-		if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) {
562
+		if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) {
564 563
 			// create an EE_Answer object for storing everything in
565
-			$answer = EE_Answer::new_instance ( array(
564
+			$answer = EE_Answer::new_instance(array(
566 565
 				'QST_ID'=> $question->ID(),
567 566
 				'REG_ID'=> $registration->ID()
568 567
 			));
569 568
 		}
570 569
 		// verify instance
571
-		if( $answer instanceof EE_Answer ){
572
-			if ( ! empty( $answer_value )) {
573
-				$answer->set( 'ANS_value', $answer_value );
570
+		if ($answer instanceof EE_Answer) {
571
+			if ( ! empty($answer_value)) {
572
+				$answer->set('ANS_value', $answer_value);
574 573
 			}
575
-			$answer->cache( 'Question', $question );
576
-			$answer_cache_id =$question->system_ID() !== null
577
-				? $question->system_ID() . '-' . $registration->reg_url_link()
578
-				: $question->ID() . '-' . $registration->reg_url_link();
579
-			$registration->cache( 'Answer', $answer, $answer_cache_id );
574
+			$answer->cache('Question', $question);
575
+			$answer_cache_id = $question->system_ID() !== null
576
+				? $question->system_ID().'-'.$registration->reg_url_link()
577
+				: $question->ID().'-'.$registration->reg_url_link();
578
+			$registration->cache('Answer', $answer, $answer_cache_id);
580 579
 		}
581
-		return $this->_generate_question_input( $registration, $question, $answer );
580
+		return $this->_generate_question_input($registration, $question, $answer);
582 581
 
583 582
 	}
584 583
 
@@ -591,46 +590,46 @@  discard block
 block discarded – undo
591 590
 	 * @return EE_Form_Input_Base
592 591
 	 * @throws \EE_Error
593 592
 	 */
594
-	private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){
593
+	private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) {
595 594
 		$identifier = $question->is_system_question() ? $question->system_ID() : $question->ID();
596
-		$this->_required_questions[ $identifier ] = $question->required() ? true : false;
595
+		$this->_required_questions[$identifier] = $question->required() ? true : false;
597 596
 		add_filter(
598 597
 			'FHEE__EE_Question__generate_form_input__country_options',
599
-			array( $this, 'use_cached_countries_for_form_input' ),
598
+			array($this, 'use_cached_countries_for_form_input'),
600 599
 			10,
601 600
 			4
602 601
 		);
603 602
 		add_filter(
604 603
 			'FHEE__EE_Question__generate_form_input__state_options',
605
-			array( $this, 'use_cached_states_for_form_input' ),
604
+			array($this, 'use_cached_states_for_form_input'),
606 605
 			10,
607 606
 			4
608 607
 		);
609 608
 		$input_constructor_args = array(
610
-			'html_name'     => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']',
611
-			'html_id'       => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
612
-			'html_class'    => 'ee-reg-qstn ee-reg-qstn-' . $identifier,
613
-			'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier,
609
+			'html_name'     => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']',
610
+			'html_id'       => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
611
+			'html_class'    => 'ee-reg-qstn ee-reg-qstn-'.$identifier,
612
+			'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier,
614 613
 			'html_label_class'	=> 'ee-reg-qstn',
615 614
 		);
616
-		$input_constructor_args['html_label_id'] 	.= '-lbl';
617
-		if ( $answer instanceof EE_Answer && $answer->ID() ) {
618
-			$input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']';
619
-			$input_constructor_args[ 'html_id' ] .= '-' . $answer->ID();
620
-			$input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID();
615
+		$input_constructor_args['html_label_id'] .= '-lbl';
616
+		if ($answer instanceof EE_Answer && $answer->ID()) {
617
+			$input_constructor_args['html_name'] .= '['.$answer->ID().']';
618
+			$input_constructor_args['html_id'] .= '-'.$answer->ID();
619
+			$input_constructor_args['html_label_id'] .= '-'.$answer->ID();
621 620
 		}
622
-		$form_input =  $question->generate_form_input(
621
+		$form_input = $question->generate_form_input(
623 622
 			$registration,
624 623
 			$answer,
625 624
 			$input_constructor_args
626 625
 		);
627 626
 		remove_filter(
628 627
 			'FHEE__EE_Question__generate_form_input__country_options',
629
-			array( $this, 'use_cached_countries_for_form_input' )
628
+			array($this, 'use_cached_countries_for_form_input')
630 629
 		);
631 630
 		remove_filter(
632 631
 			'FHEE__EE_Question__generate_form_input__state_options',
633
-			array( $this, 'use_cached_states_for_form_input' )
632
+			array($this, 'use_cached_states_for_form_input')
634 633
 		);
635 634
 		return $form_input;
636 635
 	}
@@ -646,23 +645,23 @@  discard block
 block discarded – undo
646 645
 	 * @return array 2d keys are country IDs, values are their names
647 646
 	 * @throws \EE_Error
648 647
 	 */
649
-	public function use_cached_countries_for_form_input( $countries_list, $question, $registration, $answer ) {
650
-		$country_options = array( '' => '' );
648
+	public function use_cached_countries_for_form_input($countries_list, $question, $registration, $answer) {
649
+		$country_options = array('' => '');
651 650
 		// get possibly cached list of countries
652 651
 		$countries = $this->checkout->action === 'process_reg_step'
653 652
 			? EEM_Country::instance()->get_all_countries()
654 653
 			: EEM_Country::instance()->get_all_active_countries();
655
-		if ( ! empty( $countries )) {
656
-			foreach( $countries as $country ){
657
-				if ( $country instanceof EE_Country ) {
658
-					$country_options[ $country->ID() ] = $country->name();
654
+		if ( ! empty($countries)) {
655
+			foreach ($countries as $country) {
656
+				if ($country instanceof EE_Country) {
657
+					$country_options[$country->ID()] = $country->name();
659 658
 				}
660 659
 			}
661 660
 		}
662
-		if( $question instanceof EE_Question
663
-			&& $registration instanceof EE_Registration ) {
661
+		if ($question instanceof EE_Question
662
+			&& $registration instanceof EE_Registration) {
664 663
 			$answer = EEM_Answer::instance()->get_one(
665
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
664
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
666 665
 			);
667 666
 		} else {
668 667
 			$answer = EE_Answer::new_instance();
@@ -689,22 +688,22 @@  discard block
 block discarded – undo
689 688
 	 * @return array 2d keys are state IDs, values are their names
690 689
 	 * @throws \EE_Error
691 690
 	 */
692
-	public function use_cached_states_for_form_input( $states_list, $question, $registration, $answer ) {
693
-		$state_options = array( '' => array( '' => ''));
691
+	public function use_cached_states_for_form_input($states_list, $question, $registration, $answer) {
692
+		$state_options = array('' => array('' => ''));
694 693
 		$states = $this->checkout->action === 'process_reg_step'
695 694
 			? EEM_State::instance()->get_all_states()
696 695
 			: EEM_State::instance()->get_all_active_states();
697
-		if ( ! empty( $states )) {
698
-			foreach( $states as $state ){
699
-				if ( $state instanceof EE_State ) {
700
-					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
696
+		if ( ! empty($states)) {
697
+			foreach ($states as $state) {
698
+				if ($state instanceof EE_State) {
699
+					$state_options[$state->country()->name()][$state->ID()] = $state->name();
701 700
 				}
702 701
 			}
703 702
 		}
704
-		if( $question instanceof EE_Question
705
-			&& $registration instanceof EE_Registration ) {
703
+		if ($question instanceof EE_Question
704
+			&& $registration instanceof EE_Registration) {
706 705
 			$answer = EEM_Answer::instance()->get_one(
707
-				array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) )
706
+				array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID()))
708 707
 			);
709 708
 		} else {
710 709
 			$answer = EE_Answer::new_instance();
@@ -733,24 +732,24 @@  discard block
 block discarded – undo
733 732
 	 * @throws \EE_Error
734 733
 	 */
735 734
 	public function process_reg_step() {
736
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
735
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
737 736
 		// grab validated data from form
738 737
 		$valid_data = $this->checkout->current_step->valid_data();
739 738
 		// EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
740 739
 		// EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ );
741 740
 		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
742
-		if ( empty( $valid_data ))  {
741
+		if (empty($valid_data)) {
743 742
 			EE_Error::add_error(
744
-				__( 'No valid question responses were received.', 'event_espresso' ),
743
+				__('No valid question responses were received.', 'event_espresso'),
745 744
 				__FILE__,
746 745
 				__FUNCTION__,
747 746
 				__LINE__
748 747
 			);
749 748
 			return false;
750 749
 		}
751
-		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) {
750
+		if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
752 751
 			EE_Error::add_error(
753
-				__( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ),
752
+				__('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'),
754 753
 				__FILE__,
755 754
 				__FUNCTION__,
756 755
 				__LINE__
@@ -758,11 +757,11 @@  discard block
 block discarded – undo
758 757
 			return false;
759 758
 		}
760 759
 		// get cached registrations
761
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
760
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
762 761
 		// verify we got the goods
763
-		if ( empty( $registrations )) {
762
+		if (empty($registrations)) {
764 763
 			EE_Error::add_error(
765
-				__( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ),
764
+				__('Your form data could not be applied to any valid registrations.', 'event_espresso'),
766 765
 				__FILE__,
767 766
 				__FUNCTION__,
768 767
 				__LINE__
@@ -770,15 +769,15 @@  discard block
 block discarded – undo
770 769
 			return false;
771 770
 		}
772 771
 		// extract attendee info from form data and save to model objects
773
-		$registrations_processed = $this->_process_registrations( $registrations, $valid_data );
772
+		$registrations_processed = $this->_process_registrations($registrations, $valid_data);
774 773
 		// if first pass thru SPCO,
775 774
 		// then let's check processed registrations against the total number of tickets in the cart
776
-		if ( $registrations_processed === false ) {
775
+		if ($registrations_processed === false) {
777 776
 			// but return immediately if the previous step exited early due to errors
778 777
 			return false;
779
-		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) {
778
+		} else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
780 779
 			// generate a correctly translated string for all possible singular/plural combinations
781
-			if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) {
780
+			if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
782 781
 				$error_msg = sprintf(
783 782
 					__(
784 783
 						'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
@@ -787,7 +786,7 @@  discard block
 block discarded – undo
787 786
 					$this->checkout->total_ticket_count,
788 787
 					$registrations_processed
789 788
 				);
790
-			} else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) {
789
+			} else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
791 790
 				$error_msg = sprintf(
792 791
 					__(
793 792
 						'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
@@ -806,17 +805,17 @@  discard block
 block discarded – undo
806 805
 					$registrations_processed
807 806
 				);
808 807
 			}
809
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
808
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
810 809
 			return false;
811 810
 		}
812 811
 		// mark this reg step as completed
813 812
 		$this->set_completed();
814 813
 		$this->_set_success_message(
815
-			__( 'The Attendee Information Step has been successfully completed.', 'event_espresso' )
814
+			__('The Attendee Information Step has been successfully completed.', 'event_espresso')
816 815
 		);
817 816
 		//do action in case a plugin wants to do something with the data submitted in step 1.
818 817
 		//passes EE_Single_Page_Checkout, and it's posted data
819
-		do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data );
818
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
820 819
 		return true;
821 820
 	}
822 821
 
@@ -830,9 +829,9 @@  discard block
 block discarded – undo
830 829
 	 * @return boolean | int
831 830
 	 * @throws \EE_Error
832 831
 	 */
833
-	private function _process_registrations( $registrations = array(), $valid_data = array() ) {
832
+	private function _process_registrations($registrations = array(), $valid_data = array()) {
834 833
 		// load resources and set some defaults
835
-		EE_Registry::instance()->load_model( 'Attendee' );
834
+		EE_Registry::instance()->load_model('Attendee');
836 835
 		// holder for primary registrant attendee object
837 836
 		$this->checkout->primary_attendee_obj = NULL;
838 837
 		// array for tracking reg form data for the primary registrant
@@ -849,9 +848,9 @@  discard block
 block discarded – undo
849 848
 		// attendee counter
850 849
 		$att_nmbr = 0;
851 850
 		// grab the saved registrations from the transaction
852
-		foreach ( $registrations  as $registration ) {
851
+		foreach ($registrations  as $registration) {
853 852
 			// verify EE_Registration object
854
-			if ( ! $registration instanceof EE_Registration ) {
853
+			if ( ! $registration instanceof EE_Registration) {
855 854
 				EE_Error::add_error(
856 855
 					__(
857 856
 						'An invalid Registration object was discovered when attempting to process your registration information.',
@@ -866,12 +865,12 @@  discard block
 block discarded – undo
866 865
 			/** @var string $reg_url_link */
867 866
 			$reg_url_link = $registration->reg_url_link();
868 867
 			// reg_url_link exists ?
869
-			if ( ! empty( $reg_url_link ) ) {
868
+			if ( ! empty($reg_url_link)) {
870 869
 				// should this registration be processed during this visit ?
871
-				if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) {
870
+				if ($this->checkout->visit_allows_processing_of_this_registration($registration)) {
872 871
 					// if NOT revisiting, then let's save the registration now,
873 872
 					// so that we have a REG_ID to use when generating other objects
874
-					if ( ! $this->checkout->revisit ) {
873
+					if ( ! $this->checkout->revisit) {
875 874
 						$registration->save();
876 875
 					}
877 876
 					/**
@@ -881,7 +880,7 @@  discard block
 block discarded – undo
881 880
 					 * @var bool   if true is returned by the plugin then the
882 881
 					 *      		registration processing is halted.
883 882
 					 */
884
-					if ( apply_filters(
883
+					if (apply_filters(
885 884
 						'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process',
886 885
 						false,
887 886
 						$att_nmbr,
@@ -889,38 +888,38 @@  discard block
 block discarded – undo
889 888
 						$registrations,
890 889
 						$valid_data,
891 890
 						$this
892
-					) ) {
891
+					)) {
893 892
 						return false;
894 893
 					}
895 894
 
896 895
 					// Houston, we have a registration!
897 896
 					$att_nmbr++;
898
-					$this->_attendee_data[ $reg_url_link ] = array();
897
+					$this->_attendee_data[$reg_url_link] = array();
899 898
 					// grab any existing related answer objects
900 899
 					$this->_registration_answers = $registration->answers();
901 900
 					// unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] );
902
-					if ( isset( $valid_data[ $reg_url_link ] ) ) {
901
+					if (isset($valid_data[$reg_url_link])) {
903 902
 						// do we need to copy basic info from primary attendee ?
904
-						$copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] )
905
-						                && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0
903
+						$copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info'])
904
+						                && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0
906 905
 							? true
907 906
 							: false;
908 907
 						// filter form input data for this registration
909
-						$valid_data[ $reg_url_link ] = (array)apply_filters(
908
+						$valid_data[$reg_url_link] = (array) apply_filters(
910 909
 							'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item',
911
-							$valid_data[ $reg_url_link ]
910
+							$valid_data[$reg_url_link]
912 911
 						);
913 912
 						// EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ );
914
-						if ( isset( $valid_data['primary_attendee'] )) {
915
-							$primary_registrant['line_item_id'] =  ! empty( $valid_data['primary_attendee'] )
913
+						if (isset($valid_data['primary_attendee'])) {
914
+							$primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee'])
916 915
 								? $valid_data['primary_attendee']
917 916
 								: false;
918
-							unset( $valid_data['primary_attendee'] );
917
+							unset($valid_data['primary_attendee']);
919 918
 						}
920 919
 						// now loop through our array of valid post data && process attendee reg forms
921
-						foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) {
922
-							if ( ! in_array( $form_section, $non_input_form_sections )) {
923
-								foreach ( $form_inputs as $form_input => $input_value ) {
920
+						foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) {
921
+							if ( ! in_array($form_section, $non_input_form_sections)) {
922
+								foreach ($form_inputs as $form_input => $input_value) {
924 923
 									// \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ );
925 924
 									// check for critical inputs
926 925
 									if (
@@ -934,16 +933,16 @@  discard block
 block discarded – undo
934 933
 									// store a bit of data about the primary attendee
935 934
 									if (
936 935
 										$att_nmbr === 1
937
-										&& ! empty( $input_value )
936
+										&& ! empty($input_value)
938 937
 										&& $reg_url_link === $primary_registrant['line_item_id']
939 938
 									) {
940
-										$primary_registrant[ $form_input ] = $input_value;
939
+										$primary_registrant[$form_input] = $input_value;
941 940
 									} else if (
942 941
 										$copy_primary
943 942
 										&& $input_value === null
944
-										&& isset( $primary_registrant[ $form_input ] )
943
+										&& isset($primary_registrant[$form_input])
945 944
 									) {
946
-										$input_value = $primary_registrant[ $form_input ];
945
+										$input_value = $primary_registrant[$form_input];
947 946
 									}
948 947
 									// now attempt to save the input data
949 948
 									if (
@@ -985,57 +984,57 @@  discard block
 block discarded – undo
985 984
 						// have we met before?
986 985
 						$attendee = $this->_find_existing_attendee(
987 986
 							$registration,
988
-							$this->_attendee_data[ $reg_url_link ]
987
+							$this->_attendee_data[$reg_url_link]
989 988
 						);
990 989
 						// did we find an already existing record for this attendee ?
991
-						if ( $attendee instanceof EE_Attendee ) {
990
+						if ($attendee instanceof EE_Attendee) {
992 991
 							$attendee = $this->_update_existing_attendee_data(
993 992
 								$attendee,
994
-								$this->_attendee_data[ $reg_url_link ]
993
+								$this->_attendee_data[$reg_url_link]
995 994
 							);
996 995
 						} else {
997 996
 							// ensure critical details are set for additional attendees
998
-							$this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1
997
+							$this->_attendee_data[$reg_url_link] = $att_nmbr > 1
999 998
 								? $this->_copy_critical_attendee_details_from_primary_registrant(
1000
-									$this->_attendee_data[ $reg_url_link ]
999
+									$this->_attendee_data[$reg_url_link]
1001 1000
 								)
1002
-								: $this->_attendee_data[ $reg_url_link ];
1001
+								: $this->_attendee_data[$reg_url_link];
1003 1002
 							$attendee = $this->_create_new_attendee(
1004 1003
 								$registration,
1005
-								$this->_attendee_data[ $reg_url_link ]
1004
+								$this->_attendee_data[$reg_url_link]
1006 1005
 							);
1007 1006
 						}
1008 1007
 						// who's #1 ?
1009
-						if ( $att_nmbr === 1 ) {
1008
+						if ($att_nmbr === 1) {
1010 1009
 							$this->checkout->primary_attendee_obj = $attendee;
1011 1010
 						}
1012 1011
 					}
1013 1012
 					// EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ );
1014 1013
 					// add relation to registration, set attendee ID, and cache attendee
1015
-					$this->_associate_attendee_with_registration( $registration, $attendee );
1014
+					$this->_associate_attendee_with_registration($registration, $attendee);
1016 1015
 					// \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ );
1017
-					if ( ! $registration->attendee() instanceof EE_Attendee ) {
1018
-						EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ );
1016
+					if ( ! $registration->attendee() instanceof EE_Attendee) {
1017
+						EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__);
1019 1018
 						return false;
1020 1019
 					}
1021 1020
 					/** @type EE_Registration_Processor $registration_processor */
1022
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1021
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1023 1022
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1024
-					$registration_processor->toggle_incomplete_registration_status_to_default( $registration, false );
1023
+					$registration_processor->toggle_incomplete_registration_status_to_default($registration, false);
1025 1024
 					/** @type EE_Transaction_Processor $transaction_processor */
1026
-					$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1025
+					$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1027 1026
 					// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1028
-					$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
1027
+					$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
1029 1028
 					// if we've gotten this far, then let's save what we have
1030 1029
 					$registration->save();
1031 1030
 					// add relation between TXN and registration
1032
-					$this->_associate_registration_with_transaction( $registration );
1031
+					$this->_associate_registration_with_transaction($registration);
1033 1032
 				} // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) {
1034 1033
 
1035
-			}  else {
1036
-				EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1034
+			} else {
1035
+				EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1037 1036
 				// remove malformed data
1038
-				unset( $valid_data[ $reg_url_link ] );
1037
+				unset($valid_data[$reg_url_link]);
1039 1038
 				return false;
1040 1039
 			}
1041 1040
 
@@ -1064,26 +1063,26 @@  discard block
 block discarded – undo
1064 1063
 		// \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ );
1065 1064
 		// allow for plugins to hook in and do their own processing of the form input.
1066 1065
 		// For plugins to bypass normal processing here, they just need to return a boolean value.
1067
-		if ( apply_filters(
1066
+		if (apply_filters(
1068 1067
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input',
1069 1068
 			false,
1070 1069
 			$registration,
1071 1070
 			$form_input,
1072 1071
 			$input_value,
1073 1072
 			$this
1074
-		) ) {
1073
+		)) {
1075 1074
 			return true;
1076 1075
 		}
1077 1076
 		// $answer_cache_id is the key used to find the EE_Answer we want
1078 1077
 		$answer_cache_id = $this->checkout->reg_url_link
1079 1078
 			? $form_input
1080
-			: $form_input . '-' . $registration->reg_url_link();
1081
-		$answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] )
1082
-		                 && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer
1079
+			: $form_input.'-'.$registration->reg_url_link();
1080
+		$answer_is_obj = isset($this->_registration_answers[$answer_cache_id])
1081
+		                 && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer
1083 1082
 			? true
1084 1083
 			: false;
1085 1084
 		//rename form_inputs if they are EE_Attendee properties
1086
-		switch( (string)$form_input ) {
1085
+		switch ((string) $form_input) {
1087 1086
 
1088 1087
 			case 'state' :
1089 1088
 			case 'STA_ID' :
@@ -1098,32 +1097,32 @@  discard block
 block discarded – undo
1098 1097
 				break;
1099 1098
 
1100 1099
 			default :
1101
-				$ATT_input = 'ATT_' . $form_input;
1100
+				$ATT_input = 'ATT_'.$form_input;
1102 1101
 				//EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ );
1103
-				$attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false;
1104
-				$form_input = $attendee_property ? 'ATT_' . $form_input : $form_input;
1102
+				$attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false;
1103
+				$form_input = $attendee_property ? 'ATT_'.$form_input : $form_input;
1105 1104
 		}
1106 1105
 		// EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ );
1107 1106
 		// EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ );
1108 1107
 		// EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ );
1109 1108
 		// if this form input has a corresponding attendee property
1110
-		if ( $attendee_property ) {
1111
-			$this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value;
1112
-			if ( $answer_is_obj ) {
1109
+		if ($attendee_property) {
1110
+			$this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value;
1111
+			if ($answer_is_obj) {
1113 1112
 				// and delete the corresponding answer since we won't be storing this data in that object
1114
-				$registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' );
1115
-				$this->_registration_answers[ $answer_cache_id ]->delete_permanently();
1113
+				$registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer');
1114
+				$this->_registration_answers[$answer_cache_id]->delete_permanently();
1116 1115
 			}
1117 1116
 			return true;
1118
-		} elseif ( $answer_is_obj ) {
1117
+		} elseif ($answer_is_obj) {
1119 1118
 			// save this data to the answer object
1120
-			$this->_registration_answers[ $answer_cache_id ]->set_value( $input_value );
1121
-			$result = $this->_registration_answers[ $answer_cache_id ]->save();
1119
+			$this->_registration_answers[$answer_cache_id]->set_value($input_value);
1120
+			$result = $this->_registration_answers[$answer_cache_id]->save();
1122 1121
 			return $result !== false ? true : false;
1123 1122
 		} else {
1124
-			foreach ( $this->_registration_answers as $answer ) {
1125
-				if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) {
1126
-					$answer->set_value( $input_value );
1123
+			foreach ($this->_registration_answers as $answer) {
1124
+				if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) {
1125
+					$answer->set_value($input_value);
1127 1126
 					$result = $answer->save();
1128 1127
 					return $result !== false ? true : false;
1129 1128
 				}
@@ -1145,15 +1144,15 @@  discard block
 block discarded – undo
1145 1144
 		$form_input = '',
1146 1145
 		$input_value = ''
1147 1146
 	) {
1148
-		if ( empty( $input_value ) ) {
1147
+		if (empty($input_value)) {
1149 1148
 			// if the form input isn't marked as being required, then just return
1150
-			if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) {
1149
+			if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) {
1151 1150
 				return true;
1152 1151
 			}
1153
-			switch ( $form_input ) {
1152
+			switch ($form_input) {
1154 1153
 				case 'fname' :
1155 1154
 					EE_Error::add_error(
1156
-						__( 'First Name is a required value.', 'event_espresso' ),
1155
+						__('First Name is a required value.', 'event_espresso'),
1157 1156
 						__FILE__,
1158 1157
 						__FUNCTION__,
1159 1158
 						__LINE__
@@ -1162,7 +1161,7 @@  discard block
 block discarded – undo
1162 1161
 					break;
1163 1162
 				case 'lname' :
1164 1163
 					EE_Error::add_error(
1165
-						__( 'Last Name is a required value.', 'event_espresso' ),
1164
+						__('Last Name is a required value.', 'event_espresso'),
1166 1165
 						__FILE__,
1167 1166
 						__FUNCTION__,
1168 1167
 						__LINE__
@@ -1171,7 +1170,7 @@  discard block
 block discarded – undo
1171 1170
 					break;
1172 1171
 				case 'email' :
1173 1172
 					EE_Error::add_error(
1174
-						__( 'Please enter a valid email address.', 'event_espresso' ),
1173
+						__('Please enter a valid email address.', 'event_espresso'),
1175 1174
 						__FILE__,
1176 1175
 						__FUNCTION__,
1177 1176
 						__LINE__
@@ -1204,21 +1203,21 @@  discard block
 block discarded – undo
1204 1203
 	 * @param array           $attendee_data
1205 1204
 	 * @return boolean
1206 1205
 	 */
1207
-	private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) {
1206
+	private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) {
1208 1207
 		$existing_attendee = null;
1209 1208
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1210
-		$ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] )
1209
+		$ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname'])
1211 1210
 			? $attendee_data['ATT_fname']
1212 1211
 			: '';
1213
-		$ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] )
1212
+		$ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname'])
1214 1213
 			? $attendee_data['ATT_lname']
1215 1214
 			: '';
1216
-		$ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] )
1215
+		$ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email'])
1217 1216
 			? $attendee_data['ATT_email']
1218 1217
 			: '';
1219 1218
 		// but only if those have values
1220
-		if ( $ATT_fname && $ATT_lname && $ATT_email ) {
1221
-			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array(
1219
+		if ($ATT_fname && $ATT_lname && $ATT_email) {
1220
+			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array(
1222 1221
 				'ATT_fname' => $ATT_fname,
1223 1222
 				'ATT_lname' => $ATT_lname,
1224 1223
 				'ATT_email' => $ATT_email
@@ -1242,13 +1241,13 @@  discard block
 block discarded – undo
1242 1241
 	 * @return \EE_Attendee
1243 1242
 	 * @throws \EE_Error
1244 1243
 	 */
1245
-	private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) {
1244
+	private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) {
1246 1245
 		// first remove fname, lname, and email from attendee data
1247
-		$dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1246
+		$dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email');
1248 1247
 		// now loop thru what's left and add to attendee CPT
1249
-		foreach ( $attendee_data as $property_name => $property_value ) {
1250
-			if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) {
1251
-				$existing_attendee->set( $property_name, $property_value );
1248
+		foreach ($attendee_data as $property_name => $property_value) {
1249
+			if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) {
1250
+				$existing_attendee->set($property_name, $property_value);
1252 1251
 			}
1253 1252
 		}
1254 1253
 		// better save that now
@@ -1266,11 +1265,11 @@  discard block
 block discarded – undo
1266 1265
 	 * @return void
1267 1266
 	 * @throws \EE_Error
1268 1267
 	 */
1269
-	private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) {
1268
+	private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) {
1270 1269
 		// add relation to attendee
1271
-		$registration->_add_relation_to( $attendee, 'Attendee' );
1272
-		$registration->set_attendee_id( $attendee->ID() );
1273
-		$registration->update_cache_after_object_save( 'Attendee', $attendee );
1270
+		$registration->_add_relation_to($attendee, 'Attendee');
1271
+		$registration->set_attendee_id($attendee->ID());
1272
+		$registration->update_cache_after_object_save('Attendee', $attendee);
1274 1273
 	}
1275 1274
 
1276 1275
 
@@ -1282,10 +1281,10 @@  discard block
 block discarded – undo
1282 1281
 	 * @return void
1283 1282
 	 * @throws \EE_Error
1284 1283
 	 */
1285
-	private function _associate_registration_with_transaction( EE_Registration $registration ) {
1284
+	private function _associate_registration_with_transaction(EE_Registration $registration) {
1286 1285
 		// add relation to attendee
1287
-		$this->checkout->transaction->_add_relation_to( $registration, 'Registration' );
1288
-		$this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration );
1286
+		$this->checkout->transaction->_add_relation_to($registration, 'Registration');
1287
+		$this->checkout->transaction->update_cache_after_object_save('Registration', $registration);
1289 1288
 	}
1290 1289
 
1291 1290
 
@@ -1298,14 +1297,14 @@  discard block
 block discarded – undo
1298 1297
 	 * @return array
1299 1298
 	 * @throws \EE_Error
1300 1299
 	 */
1301
-	private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) {
1300
+	private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) {
1302 1301
 		// bare minimum critical details include first name, last name, email address
1303
-		$critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' );
1302
+		$critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email');
1304 1303
 		// add address info to critical details?
1305
-		if ( apply_filters(
1304
+		if (apply_filters(
1306 1305
 			'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details',
1307 1306
 			false
1308
-		) ) {
1307
+		)) {
1309 1308
 			$address_details = array(
1310 1309
 				'ATT_address',
1311 1310
 				'ATT_address2',
@@ -1315,13 +1314,13 @@  discard block
 block discarded – undo
1315 1314
 				'ATT_zip',
1316 1315
 				'ATT_phone'
1317 1316
 			);
1318
-			$critical_attendee_details = array_merge( $critical_attendee_details, $address_details );
1317
+			$critical_attendee_details = array_merge($critical_attendee_details, $address_details);
1319 1318
 		}
1320
-		foreach ( $critical_attendee_details as $critical_attendee_detail ) {
1321
-			if ( ! isset( $attendee_data[ $critical_attendee_detail ] )
1322
-			     || empty( $attendee_data[ $critical_attendee_detail ] )
1319
+		foreach ($critical_attendee_details as $critical_attendee_detail) {
1320
+			if ( ! isset($attendee_data[$critical_attendee_detail])
1321
+			     || empty($attendee_data[$critical_attendee_detail])
1323 1322
 			) {
1324
-				$attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get(
1323
+				$attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get(
1325 1324
 					$critical_attendee_detail
1326 1325
 				);
1327 1326
 			}
@@ -1339,11 +1338,11 @@  discard block
 block discarded – undo
1339 1338
 	 * @return \EE_Attendee
1340 1339
 	 * @throws \EE_Error
1341 1340
 	 */
1342
-	private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) {
1341
+	private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) {
1343 1342
 		// create new attendee object
1344
-		$new_attendee = EE_Attendee::new_instance( $attendee_data );
1343
+		$new_attendee = EE_Attendee::new_instance($attendee_data);
1345 1344
 		// set author to event creator
1346
-		$new_attendee->set( 'ATT_author', $registration->event()->wp_user() );
1345
+		$new_attendee->set('ATT_author', $registration->event()->wp_user());
1347 1346
 		$new_attendee->save();
1348 1347
 		return $new_attendee;
1349 1348
 	}
@@ -1360,7 +1359,7 @@  discard block
 block discarded – undo
1360 1359
 	 */
1361 1360
 	public function update_reg_step() {
1362 1361
 		// save everything
1363
-		if ( $this->process_reg_step() ) {
1362
+		if ($this->process_reg_step()) {
1364 1363
 			$this->checkout->redirect = true;
1365 1364
 			$this->checkout->redirect_url = add_query_arg(
1366 1365
 				array(
@@ -1369,7 +1368,7 @@  discard block
 block discarded – undo
1369 1368
 				),
1370 1369
 				$this->checkout->thank_you_page_url
1371 1370
 			);
1372
-			$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1371
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1373 1372
 			return true;
1374 1373
 		}
1375 1374
 		return false;
Please login to merge, or discard this patch.
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 1 patch
Spacing   +264 added lines, -264 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2 2
 /**
3 3
  * Single Page Checkout (SPCO)
4 4
  *
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 * @return EED_Single_Page_Checkout
39 39
 	 */
40 40
 	public static function instance() {
41
-		add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' );
42
-		return parent::get_instance( __CLASS__ );
41
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
42
+		return parent::get_instance(__CLASS__);
43 43
 	}
44 44
 
45 45
 
@@ -84,22 +84,22 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public static function set_hooks_admin() {
86 86
 		EED_Single_Page_Checkout::set_definitions();
87
-		if ( defined( 'DOING_AJAX' )) {
87
+		if (defined('DOING_AJAX')) {
88 88
 			// going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response
89 89
 			ob_start();
90 90
 			EED_Single_Page_Checkout::load_request_handler();
91 91
 			EED_Single_Page_Checkout::load_reg_steps();
92 92
 		} else {
93 93
 			// hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called
94
-			add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 );
94
+			add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1);
95 95
 		}
96 96
 		// set ajax hooks
97
-		add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' ));
98
-		add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' ));
99
-		add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' ));
100
-		add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' ));
101
-		add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' ));
102
-		add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' ));
97
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
98
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
99
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
100
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
101
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
102
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
103 103
 	}
104 104
 
105 105
 
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 * @param string $ajax_action
111 111
 	 * @throws \EE_Error
112 112
 	 */
113
-	public static function process_ajax_request( $ajax_action ) {
114
-		EE_Registry::instance()->REQ->set( 'action', $ajax_action );
113
+	public static function process_ajax_request($ajax_action) {
114
+		EE_Registry::instance()->REQ->set('action', $ajax_action);
115 115
 		EED_Single_Page_Checkout::instance()->_initialize();
116 116
 	}
117 117
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @throws \EE_Error
124 124
 	 */
125 125
 	public static function display_reg_step() {
126
-		EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' );
126
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
127 127
 	}
128 128
 
129 129
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @throws \EE_Error
135 135
 	 */
136 136
 	public static function process_reg_step() {
137
-		EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' );
137
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
138 138
 	}
139 139
 
140 140
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @throws \EE_Error
146 146
 	 */
147 147
 	public static function update_reg_step() {
148
-		EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' );
148
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
149 149
 	}
150 150
 
151 151
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @throws \EE_Error
159 159
 	 */
160 160
 	public static function update_checkout() {
161
-		EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' );
161
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
162 162
 	}
163 163
 
164 164
 
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	public static function load_request_handler() {
173 173
 		// load core Request_Handler class
174
-		if ( ! isset( EE_Registry::instance()->REQ )) {
175
-			EE_Registry::instance()->load_core( 'Request_Handler' );
174
+		if ( ! isset(EE_Registry::instance()->REQ)) {
175
+			EE_Registry::instance()->load_core('Request_Handler');
176 176
 		}
177 177
 	}
178 178
 
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
 	 * @throws \EE_Error
187 187
 	 */
188 188
 	public static function set_definitions() {
189
-		define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS );
190
-		define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS );
191
-		define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS );
192
-		define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS );
193
-		define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS );
194
-		define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS );
195
-		define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS );
196
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE );
189
+		define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS);
190
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS);
191
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS);
192
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS);
193
+		define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS);
194
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS);
195
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS);
196
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE);
197 197
 	}
198 198
 
199 199
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	public static function load_reg_steps() {
210 210
 		static $reg_steps_loaded = FALSE;
211
-		if ( $reg_steps_loaded ) {
211
+		if ($reg_steps_loaded) {
212 212
 			return;
213 213
 		}
214 214
 		// filter list of reg_steps
@@ -217,24 +217,24 @@  discard block
 block discarded – undo
217 217
 			EED_Single_Page_Checkout::get_reg_steps()
218 218
 		);
219 219
 		// sort by key (order)
220
-		ksort( $reg_steps_to_load );
220
+		ksort($reg_steps_to_load);
221 221
 		// loop through folders
222
-		foreach ( $reg_steps_to_load as $order => $reg_step ) {
222
+		foreach ($reg_steps_to_load as $order => $reg_step) {
223 223
 			// we need a
224
-			if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) {
224
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
225 225
 				// copy over to the reg_steps_array
226
-				EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step;
226
+				EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
227 227
 				// register custom key route for each reg step
228 228
 				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
229
-				EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' );
229
+				EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step');
230 230
 				// add AJAX or other hooks
231
-				if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) {
231
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
232 232
 					// setup autoloaders if necessary
233
-					if ( ! class_exists( $reg_step['class_name'] )) {
234
-						EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE );
233
+					if ( ! class_exists($reg_step['class_name'])) {
234
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE);
235 235
 					}
236
-					if ( is_callable( $reg_step['class_name'], 'set_hooks' )) {
237
-						call_user_func( array( $reg_step['class_name'], 'set_hooks' ));
236
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
237
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
238 238
 					}
239 239
 				}
240 240
 			}
@@ -253,28 +253,28 @@  discard block
 block discarded – undo
253 253
 	 */
254 254
 	public static function get_reg_steps() {
255 255
 		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
256
-		if ( empty( $reg_steps )) {
256
+		if (empty($reg_steps)) {
257 257
 			$reg_steps = array(
258 258
 				10 => array(
259
-					'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information',
259
+					'file_path' => SPCO_REG_STEPS_PATH.'attendee_information',
260 260
 					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
261 261
 					'slug' => 'attendee_information',
262 262
 					'has_hooks' => FALSE
263 263
 				),
264 264
 				20 => array(
265
-					'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation',
265
+					'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation',
266 266
 					'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
267 267
 					'slug' => 'registration_confirmation',
268 268
 					'has_hooks' => FALSE
269 269
 				),
270 270
 				30 => array(
271
-					'file_path' => SPCO_REG_STEPS_PATH . 'payment_options',
271
+					'file_path' => SPCO_REG_STEPS_PATH.'payment_options',
272 272
 					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
273 273
 					'slug' => 'payment_options',
274 274
 					'has_hooks' => TRUE
275 275
 				),
276 276
 				999 => array(
277
-					'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration',
277
+					'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration',
278 278
 					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
279 279
 					'slug' => 'finalize_registration',
280 280
 					'has_hooks' => FALSE
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 	 */
296 296
 	public static function registration_checkout_for_admin() {
297 297
 		EED_Single_Page_Checkout::load_reg_steps();
298
-		EE_Registry::instance()->REQ->set( 'step', 'attendee_information' );
299
-		EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' );
300
-		EE_Registry::instance()->REQ->set( 'process_form_submission', false );
298
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
299
+		EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
300
+		EE_Registry::instance()->REQ->set('process_form_submission', false);
301 301
 		EED_Single_Page_Checkout::instance()->_initialize();
302 302
 		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
303 303
 		return EE_Registry::instance()->REQ->get_output();
@@ -314,15 +314,15 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public static function process_registration_from_admin() {
316 316
 		EED_Single_Page_Checkout::load_reg_steps();
317
-		EE_Registry::instance()->REQ->set( 'step', 'attendee_information' );
318
-		EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' );
319
-		EE_Registry::instance()->REQ->set( 'process_form_submission', true );
317
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
318
+		EE_Registry::instance()->REQ->set('action', 'process_reg_step');
319
+		EE_Registry::instance()->REQ->set('process_form_submission', true);
320 320
 		EED_Single_Page_Checkout::instance()->_initialize();
321
-		if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) {
322
-			$final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps );
323
-			if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) {
324
-				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step );
325
-				if ( $final_reg_step->process_reg_step() ) {
321
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
322
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
323
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
324
+				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
325
+				if ($final_reg_step->process_reg_step()) {
326 326
 					$final_reg_step->set_completed();
327 327
 					EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
328 328
 					return EED_Single_Page_Checkout::instance()->checkout->transaction;
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
 	 * @return    void
343 343
 	 * @throws \EE_Error
344 344
 	 */
345
-	public function run( $WP_Query ) {
345
+	public function run($WP_Query) {
346 346
 		if (
347 347
 			$WP_Query instanceof WP_Query
348 348
 			&& $WP_Query->is_main_query()
349
-			&& apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true )
349
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
350 350
 		) {
351 351
 			$this->_initialize();
352 352
 		}
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
 	 * @return    void
363 363
 	 * @throws \EE_Error
364 364
 	 */
365
-	public static function init( $WP_Query ) {
366
-		EED_Single_Page_Checkout::instance()->run( $WP_Query );
365
+	public static function init($WP_Query) {
366
+		EED_Single_Page_Checkout::instance()->run($WP_Query);
367 367
 	}
368 368
 
369 369
 
@@ -377,36 +377,36 @@  discard block
 block discarded – undo
377 377
 	 */
378 378
 	private function _initialize() {
379 379
 		// ensure SPCO doesn't run twice
380
-		if ( EED_Single_Page_Checkout::$_initialized ) {
380
+		if (EED_Single_Page_Checkout::$_initialized) {
381 381
 			return;
382 382
 		}
383 383
 		try {
384 384
 			// setup the EE_Checkout object
385 385
 			$this->checkout = $this->_initialize_checkout();
386 386
 			// filter checkout
387
-			$this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout );
387
+			$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
388 388
 			// get the $_GET
389 389
 			$this->_get_request_vars();
390 390
 			// filter continue_reg
391
-			$this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout );
391
+			$this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout);
392 392
 			// load the reg steps array
393
-			if ( ! $this->_load_and_instantiate_reg_steps() ) {
393
+			if ( ! $this->_load_and_instantiate_reg_steps()) {
394 394
 				EED_Single_Page_Checkout::$_initialized = true;
395 395
 				return;
396 396
 			}
397 397
 			// set the current step
398
-			$this->checkout->set_current_step( $this->checkout->step );
398
+			$this->checkout->set_current_step($this->checkout->step);
399 399
 			// and the next step
400 400
 			$this->checkout->set_next_step();
401 401
 			// was there already a valid transaction in the checkout from the session ?
402
-			if ( ! $this->checkout->transaction instanceof EE_Transaction ) {
402
+			if ( ! $this->checkout->transaction instanceof EE_Transaction) {
403 403
 				// get transaction from db or session
404 404
 				$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
405 405
 					? $this->_get_transaction_and_cart_for_previous_visit()
406 406
 					: $this->_get_cart_for_current_session_and_setup_new_transaction();
407
-				if ( ! $this->checkout->transaction instanceof EE_Transaction ) {
407
+				if ( ! $this->checkout->transaction instanceof EE_Transaction) {
408 408
 					EE_Error::add_error(
409
-						__( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ),
409
+						__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
410 410
 						__FILE__, __FUNCTION__, __LINE__
411 411
 					);
412 412
 					// add some style and make it dance
@@ -416,10 +416,10 @@  discard block
 block discarded – undo
416 416
 					return;
417 417
 				}
418 418
 				// and the registrations for the transaction
419
-				$this->_get_registrations( $this->checkout->transaction );
419
+				$this->_get_registrations($this->checkout->transaction);
420 420
 			}
421 421
 			// verify that everything has been setup correctly
422
-			if ( ! $this->_final_verifications() ) {
422
+			if ( ! $this->_final_verifications()) {
423 423
 				EED_Single_Page_Checkout::$_initialized = true;
424 424
 				return;
425 425
 			}
@@ -444,9 +444,9 @@  discard block
 block discarded – undo
444 444
 			// set no cache headers and constants
445 445
 			EE_System::do_not_cache();
446 446
 			// add anchor
447
-			add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 );
448
-		} catch ( Exception $e ) {
449
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
447
+			add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
448
+		} catch (Exception $e) {
449
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
450 450
 		}
451 451
 	}
452 452
 
@@ -464,20 +464,20 @@  discard block
 block discarded – undo
464 464
 		// look in session for existing checkout
465 465
 		$checkout = EE_Registry::instance()->SSN->checkout();
466 466
 		// verify
467
-		if ( ! $checkout instanceof EE_Checkout ) {
467
+		if ( ! $checkout instanceof EE_Checkout) {
468 468
 			// instantiate EE_Checkout object for handling the properties of the current checkout process
469
-			$checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE  );
469
+			$checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE);
470 470
 		} else {
471
-			if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true )  {
471
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
472 472
 				$this->unlock_transaction();
473
-				wp_safe_redirect( $checkout->redirect_url );
473
+				wp_safe_redirect($checkout->redirect_url);
474 474
 				exit();
475 475
 			}
476 476
 		}
477
-		$checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout );
477
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
478 478
 		// verify again
479
-		if ( ! $checkout instanceof EE_Checkout ) {
480
-			throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) );
479
+		if ( ! $checkout instanceof EE_Checkout) {
480
+			throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
481 481
 		}
482 482
 		// reset anything that needs a clean slate for each request
483 483
 		$checkout->reset_for_current_request();
@@ -497,24 +497,24 @@  discard block
 block discarded – undo
497 497
 		// load classes
498 498
 		EED_Single_Page_Checkout::load_request_handler();
499 499
 		//make sure this request is marked as belonging to EE
500
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
500
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
501 501
 		// which step is being requested ?
502
-		$this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() );
502
+		$this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
503 503
 		// which step is being edited ?
504
-		$this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' );
504
+		$this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
505 505
 		// and what we're doing on the current step
506
-		$this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' );
506
+		$this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
507 507
 		// returning to edit ?
508
-		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' );
508
+		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
509 509
 		// or some other kind of revisit ?
510
-		$this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE );
510
+		$this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE);
511 511
 		// and whether or not to generate a reg form for this request
512
-		$this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); 		// TRUE 	FALSE
512
+		$this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE 	FALSE
513 513
 		// and whether or not to process a reg form submission for this request
514
-		$this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); 		// TRUE 	FALSE
514
+		$this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE 	FALSE
515 515
 		$this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step'
516 516
 			? $this->checkout->process_form_submission
517
-			: FALSE; 		// TRUE 	FALSE
517
+			: FALSE; // TRUE 	FALSE
518 518
 		// $this->_display_request_vars();
519 519
 	}
520 520
 
@@ -527,17 +527,17 @@  discard block
 block discarded – undo
527 527
 	 * @return    void
528 528
 	 */
529 529
 	protected function _display_request_vars() {
530
-		if ( ! WP_DEBUG ) {
530
+		if ( ! WP_DEBUG) {
531 531
 			return;
532 532
 		}
533
-		EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
534
-		EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ );
535
-		EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ );
536
-		EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ );
537
-		EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ );
538
-		EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ );
539
-		EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ );
540
-		EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ );
533
+		EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
534
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
535
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
536
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
537
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
538
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
539
+		EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
540
+		EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
541 541
 	}
542 542
 
543 543
 
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
 	 * @return    array
552 552
 	 */
553 553
 	private function _get_first_step() {
554
-		$first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array );
555
-		return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information';
554
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
555
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
556 556
 	}
557 557
 
558 558
 
@@ -568,27 +568,27 @@  discard block
 block discarded – undo
568 568
 	private function _load_and_instantiate_reg_steps() {
569 569
 		// have reg_steps already been instantiated ?
570 570
 		if (
571
-			empty( $this->checkout->reg_steps ) ||
572
-			apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout )
571
+			empty($this->checkout->reg_steps) ||
572
+			apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
573 573
 		) {
574 574
 			// if not, then loop through raw reg steps array
575
-			foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) {
576
-				if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) {
575
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
576
+				if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
577 577
 					return false;
578 578
 				}
579 579
 			}
580 580
 			EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE;
581 581
 			EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE;
582 582
 			// skip the registration_confirmation page ?
583
-			if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) {
583
+			if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
584 584
 				// just remove it from the reg steps array
585
-				$this->checkout->remove_reg_step( 'registration_confirmation', false );
585
+				$this->checkout->remove_reg_step('registration_confirmation', false);
586 586
 			} else if (
587
-				isset( $this->checkout->reg_steps['registration_confirmation'] )
587
+				isset($this->checkout->reg_steps['registration_confirmation'])
588 588
 				&& EE_Registry::instance()->CFG->registration->reg_confirmation_last
589 589
 			) {
590 590
 				// set the order to something big like 100
591
-				$this->checkout->set_reg_step_order( 'registration_confirmation', 100 );
591
+				$this->checkout->set_reg_step_order('registration_confirmation', 100);
592 592
 			}
593 593
 			// filter the array for good luck
594 594
 			$this->checkout->reg_steps = apply_filters(
@@ -598,13 +598,13 @@  discard block
 block discarded – undo
598 598
 			// finally re-sort based on the reg step class order properties
599 599
 			$this->checkout->sort_reg_steps();
600 600
 		} else {
601
-			foreach ( $this->checkout->reg_steps as $reg_step ) {
601
+			foreach ($this->checkout->reg_steps as $reg_step) {
602 602
 				// set all current step stati to FALSE
603
-				$reg_step->set_is_current_step( FALSE );
603
+				$reg_step->set_is_current_step(FALSE);
604 604
 			}
605 605
 		}
606
-		if ( empty( $this->checkout->reg_steps )) {
607
-			EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
606
+		if (empty($this->checkout->reg_steps)) {
607
+			EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
608 608
 			return false;
609 609
 		}
610 610
 			// make reg step details available to JS
@@ -622,10 +622,10 @@  discard block
 block discarded – undo
622 622
 	 * @param int   $order
623 623
 	 * @return bool
624 624
 	 */
625
-	private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) {
625
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) {
626 626
 
627 627
 		// we need a file_path, class_name, and slug to add a reg step
628
-		if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) {
628
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
629 629
 			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
630 630
 			if (
631 631
 				$this->checkout->reg_url_link
@@ -643,26 +643,26 @@  discard block
 block discarded – undo
643 643
 				FALSE
644 644
 			);
645 645
 			// did we gets the goods ?
646
-			if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) {
646
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
647 647
 				// set reg step order based on config
648
-				$reg_step_obj->set_order( $order );
648
+				$reg_step_obj->set_order($order);
649 649
 				// add instantiated reg step object to the master reg steps array
650
-				$this->checkout->add_reg_step( $reg_step_obj );
650
+				$this->checkout->add_reg_step($reg_step_obj);
651 651
 			} else {
652 652
 				EE_Error::add_error(
653
-					__( 'The current step could not be set.', 'event_espresso' ),
653
+					__('The current step could not be set.', 'event_espresso'),
654 654
 					__FILE__, __FUNCTION__, __LINE__
655 655
 				);
656 656
 				return false;
657 657
 			}
658 658
 		} else {
659
-			if ( WP_DEBUG ) {
659
+			if (WP_DEBUG) {
660 660
 				EE_Error::add_error(
661 661
 					sprintf(
662
-						__( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ),
663
-						isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '',
664
-						isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '',
665
-						isset( $reg_step['slug'] ) ? $reg_step['slug'] : '',
662
+						__('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'),
663
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
664
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
665
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
666 666
 						'<ul>',
667 667
 						'<li>',
668 668
 						'</li>',
@@ -686,16 +686,16 @@  discard block
 block discarded – undo
686 686
 	 */
687 687
 	private function _get_transaction_and_cart_for_previous_visit() {
688 688
 		/** @var $TXN_model EEM_Transaction */
689
-		$TXN_model = EE_Registry::instance()->load_model( 'Transaction' );
689
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
690 690
 		// because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db
691
-		$transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link );
691
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
692 692
 		// verify transaction
693
-		if ( $transaction instanceof EE_Transaction ) {
693
+		if ($transaction instanceof EE_Transaction) {
694 694
 			// and get the cart that was used for that transaction
695
-			$this->checkout->cart = $this->_get_cart_for_transaction( $transaction );
695
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
696 696
 			return $transaction;
697 697
 		} else {
698
-			EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
698
+			EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
699 699
 			return NULL;
700 700
 		}
701 701
 	}
@@ -709,11 +709,11 @@  discard block
 block discarded – undo
709 709
 	 * @param EE_Transaction $transaction
710 710
 	 * @return EE_Cart
711 711
 	 */
712
-	private function _get_cart_for_transaction( $transaction ) {
713
-		$cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn( $transaction ) : NULL;
712
+	private function _get_cart_for_transaction($transaction) {
713
+		$cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction) : NULL;
714 714
 		// verify cart
715
-		if ( ! $cart instanceof EE_Cart ) {
716
-			$cart = EE_Registry::instance()->load_core( 'Cart' );
715
+		if ( ! $cart instanceof EE_Cart) {
716
+			$cart = EE_Registry::instance()->load_core('Cart');
717 717
 		}
718 718
 		return $cart;
719 719
 	}
@@ -728,8 +728,8 @@  discard block
 block discarded – undo
728 728
 	 * @param EE_Transaction $transaction
729 729
 	 * 	@return EE_Cart
730 730
 	 */
731
-	public function get_cart_for_transaction( EE_Transaction $transaction ) {
732
-		return EE_Cart::get_cart_from_txn( $transaction );
731
+	public function get_cart_for_transaction(EE_Transaction $transaction) {
732
+		return EE_Cart::get_cart_from_txn($transaction);
733 733
 	}
734 734
 
735 735
 
@@ -745,17 +745,17 @@  discard block
 block discarded – undo
745 745
 	private function _get_cart_for_current_session_and_setup_new_transaction() {
746 746
 		//  if there's no transaction, then this is the FIRST visit to SPCO
747 747
 		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
748
-		$this->checkout->cart = $this->_get_cart_for_transaction( NULL );
748
+		$this->checkout->cart = $this->_get_cart_for_transaction(NULL);
749 749
 		// and then create a new transaction
750 750
 		$transaction = $this->_initialize_transaction();
751 751
 		// verify transaction
752
-		if ( $transaction instanceof EE_Transaction ) {
752
+		if ($transaction instanceof EE_Transaction) {
753 753
 			// save it so that we have an ID for other objects to use
754 754
 			$transaction->save();
755 755
 			// and save TXN data to the cart
756
-			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() );
756
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
757 757
 		} else {
758
-			EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
758
+			EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
759 759
 		}
760 760
 		return $transaction;
761 761
 	}
@@ -775,15 +775,15 @@  discard block
 block discarded – undo
775 775
 			// grab the cart grand total
776 776
 			$cart_total = $this->checkout->cart->get_cart_grand_total();
777 777
 			// create new TXN
778
-			return EE_Transaction::new_instance( array(
778
+			return EE_Transaction::new_instance(array(
779 779
 				'TXN_timestamp' 	=> time(),
780 780
 				'TXN_reg_steps' 		=> $this->checkout->initialize_txn_reg_steps_array(),
781 781
 				'TXN_total' 				=> $cart_total > 0 ? $cart_total : 0,
782 782
 				'TXN_paid' 				=> 0,
783 783
 				'STS_ID' 					=> EEM_Transaction::failed_status_code,
784 784
 			));
785
-		} catch( Exception $e ) {
786
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
785
+		} catch (Exception $e) {
786
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
787 787
 		}
788 788
 		return NULL;
789 789
 	}
@@ -798,38 +798,38 @@  discard block
 block discarded – undo
798 798
 	 * @return EE_Cart
799 799
 	 * @throws \EE_Error
800 800
 	 */
801
-	private function _get_registrations( EE_Transaction $transaction ) {
801
+	private function _get_registrations(EE_Transaction $transaction) {
802 802
 		// first step: grab the registrants  { : o
803
-		$registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true );
803
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true);
804 804
 		// verify registrations have been set
805
-		if ( empty( $registrations )) {
805
+		if (empty($registrations)) {
806 806
 			// if no cached registrations, then check the db
807
-			$registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false );
807
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
808 808
 			// still nothing ? well as long as this isn't a revisit
809
-			if ( empty( $registrations ) && ! $this->checkout->revisit ) {
809
+			if (empty($registrations) && ! $this->checkout->revisit) {
810 810
 				// generate new registrations from scratch
811
-				$registrations = $this->_initialize_registrations( $transaction );
811
+				$registrations = $this->_initialize_registrations($transaction);
812 812
 			}
813 813
 		}
814 814
 		// sort by their original registration order
815
-		usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' ));
815
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
816 816
 		// then loop thru the array
817
-		foreach ( $registrations as $registration ) {
817
+		foreach ($registrations as $registration) {
818 818
 			// verify each registration
819
-			if ( $registration instanceof EE_Registration ) {
819
+			if ($registration instanceof EE_Registration) {
820 820
 				// we display all attendee info for the primary registrant
821
-				if ( $this->checkout->reg_url_link === $registration->reg_url_link()
821
+				if ($this->checkout->reg_url_link === $registration->reg_url_link()
822 822
 				     && $registration->is_primary_registrant()
823 823
 				) {
824 824
 					$this->checkout->primary_revisit = true;
825 825
 					break;
826
-				} else if ( $this->checkout->revisit
826
+				} else if ($this->checkout->revisit
827 827
 				            && $this->checkout->reg_url_link !== $registration->reg_url_link()
828 828
 				) {
829 829
 					// but hide info if it doesn't belong to you
830
-					$transaction->clear_cache( 'Registration', $registration->ID() );
830
+					$transaction->clear_cache('Registration', $registration->ID());
831 831
 				}
832
-				$this->checkout->set_reg_status_updated( $registration->ID(), false );
832
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
833 833
 			}
834 834
 		}
835 835
 	}
@@ -844,17 +844,17 @@  discard block
 block discarded – undo
844 844
 	 * @return    array
845 845
 	 * @throws \EE_Error
846 846
 	 */
847
-	private function _initialize_registrations( EE_Transaction $transaction ) {
847
+	private function _initialize_registrations(EE_Transaction $transaction) {
848 848
 		$att_nmbr = 0;
849 849
 		$registrations = array();
850
-		if ( $transaction instanceof EE_Transaction ) {
850
+		if ($transaction instanceof EE_Transaction) {
851 851
 			/** @type EE_Registration_Processor $registration_processor */
852
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
852
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
853 853
 			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
854 854
 			// now let's add the cart items to the $transaction
855
-			foreach ( $this->checkout->cart->get_tickets() as $line_item ) {
855
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
856 856
 				//do the following for each ticket of this type they selected
857
-				for ( $x = 1; $x <= $line_item->quantity(); $x++ ) {
857
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
858 858
 					$att_nmbr++;
859 859
 					$registration = $registration_processor->generate_ONE_registration_from_line_item(
860 860
 						$line_item,
@@ -862,12 +862,12 @@  discard block
 block discarded – undo
862 862
 						$att_nmbr,
863 863
 						$this->checkout->total_ticket_count
864 864
 					);
865
-					if ( $registration instanceof EE_Registration ) {
866
-						$registrations[ $registration->ID() ] = $registration;
865
+					if ($registration instanceof EE_Registration) {
866
+						$registrations[$registration->ID()] = $registration;
867 867
 					}
868 868
 				}
869 869
 			}
870
-			$registration_processor->fix_reg_final_price_rounding_issue( $transaction );
870
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
871 871
 		}
872 872
 		return $registrations;
873 873
 	}
@@ -882,12 +882,12 @@  discard block
 block discarded – undo
882 882
 	 * @param EE_Registration $reg_B
883 883
 	 * @return array()
884 884
 	 */
885
-	public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) {
885
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) {
886 886
 		// this shouldn't ever happen within the same TXN, but oh well
887
-		if ( $reg_A->count() === $reg_B->count() ) {
887
+		if ($reg_A->count() === $reg_B->count()) {
888 888
 			return 0;
889 889
 		}
890
-		return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1;
890
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
891 891
 	}
892 892
 
893 893
 
@@ -902,21 +902,21 @@  discard block
 block discarded – undo
902 902
 	 */
903 903
 	private function _final_verifications() {
904 904
 		// filter checkout
905
-		$this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout );
905
+		$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout);
906 906
 		//verify that current step is still set correctly
907
-		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) {
908
-			EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
907
+		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
908
+			EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
909 909
 			return false;
910 910
 		}
911 911
 		// if returning to SPCO, then verify that primary registrant is set
912
-		if ( ! empty( $this->checkout->reg_url_link )) {
912
+		if ( ! empty($this->checkout->reg_url_link)) {
913 913
 			$valid_registrant = $this->checkout->transaction->primary_registration();
914
-			if ( ! $valid_registrant instanceof EE_Registration ) {
915
-				EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
914
+			if ( ! $valid_registrant instanceof EE_Registration) {
915
+				EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
916 916
 				return false;
917 917
 			}
918 918
 			$valid_registrant = null;
919
-			foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) {
919
+			foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) {
920 920
 				if (
921 921
 					$registration instanceof EE_Registration
922 922
 					&& $registration->reg_url_link() === $this->checkout->reg_url_link
@@ -924,14 +924,14 @@  discard block
 block discarded – undo
924 924
 					$valid_registrant = $registration;
925 925
 				}
926 926
 			}
927
-			if ( ! $valid_registrant instanceof EE_Registration ) {
928
-				EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
927
+			if ( ! $valid_registrant instanceof EE_Registration) {
928
+				EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
929 929
 				return false;
930 930
 			}
931 931
 		}
932 932
 		// now that things have been kinda sufficiently verified,
933 933
 		// let's add the checkout to the session so that's available other systems
934
-		EE_Registry::instance()->SSN->set_checkout( $this->checkout );
934
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
935 935
 		return true;
936 936
 	}
937 937
 
@@ -946,28 +946,28 @@  discard block
 block discarded – undo
946 946
 	 * @param bool $reinitializing
947 947
 	 * @throws \EE_Error
948 948
 	 */
949
-	private function _initialize_reg_steps( $reinitializing = false ) {
950
-		$this->checkout->set_reg_step_initiated( $this->checkout->current_step );
949
+	private function _initialize_reg_steps($reinitializing = false) {
950
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
951 951
 		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
952
-		foreach ( $this->checkout->reg_steps as $reg_step ) {
953
-			if ( ! $reg_step->initialize_reg_step() ) {
952
+		foreach ($this->checkout->reg_steps as $reg_step) {
953
+			if ( ! $reg_step->initialize_reg_step()) {
954 954
 				// if not initialized then maybe this step is being removed...
955
-				if ( ! $reinitializing && $reg_step->is_current_step() ) {
955
+				if ( ! $reinitializing && $reg_step->is_current_step()) {
956 956
 					// if it was the current step, then we need to start over here
957
-					$this->_initialize_reg_steps( true );
957
+					$this->_initialize_reg_steps(true);
958 958
 					return;
959 959
 				}
960 960
 				continue;
961 961
 			}
962 962
 			// i18n
963 963
 			$reg_step->translate_js_strings();
964
-			if ( $reg_step->is_current_step() ) {
964
+			if ($reg_step->is_current_step()) {
965 965
 				// the text that appears on the reg step form submit button
966 966
 				$reg_step->set_submit_button_text();
967 967
 			}
968 968
 		}
969 969
 		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
970
-		do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step );
970
+		do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step);
971 971
 	}
972 972
 
973 973
 
@@ -980,43 +980,43 @@  discard block
 block discarded – undo
980 980
 	 */
981 981
 	private function _check_form_submission() {
982 982
 		//does this request require the reg form to be generated ?
983
-		if ( $this->checkout->generate_reg_form ) {
983
+		if ($this->checkout->generate_reg_form) {
984 984
 			// ever heard that song by Blue Rodeo ?
985 985
 			try {
986 986
 				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
987 987
 				// if not displaying a form, then check for form submission
988
-				if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) {
988
+				if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) {
989 989
 					// clear out any old data in case this step is being run again
990
-					$this->checkout->current_step->set_valid_data( array() );
990
+					$this->checkout->current_step->set_valid_data(array());
991 991
 					// capture submitted form data
992 992
 					$this->checkout->current_step->reg_form->receive_form_submission(
993
-						apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout )
993
+						apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout)
994 994
 					);
995 995
 					// validate submitted form data
996
-					if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid() ) {
996
+					if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid()) {
997 997
 						// thou shall not pass !!!
998 998
 						$this->checkout->continue_reg = FALSE;
999 999
 						// any form validation errors?
1000
-						if ( $this->checkout->current_step->reg_form->submission_error_message() !== '' ) {
1000
+						if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1001 1001
 							$submission_error_messages = array();
1002 1002
 							// bad, bad, bad registrant
1003
-							foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){
1004
-								if ( $validation_error instanceof EE_Validation_Error ) {
1003
+							foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) {
1004
+								if ($validation_error instanceof EE_Validation_Error) {
1005 1005
 									$submission_error_messages[] = sprintf(
1006
-										__( '%s : %s', 'event_espresso' ),
1006
+										__('%s : %s', 'event_espresso'),
1007 1007
 										$validation_error->get_form_section()->html_label_text(),
1008 1008
 										$validation_error->getMessage()
1009 1009
 									);
1010 1010
 								}
1011 1011
 							}
1012
-							EE_Error::add_error( implode( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ );
1012
+							EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1013 1013
 						}
1014 1014
 						// well not really... what will happen is we'll just get redirected back to redo the current step
1015 1015
 						$this->go_to_next_step();
1016 1016
 						return;
1017 1017
 					}
1018 1018
 				}
1019
-			} catch( EE_Error $e ) {
1019
+			} catch (EE_Error $e) {
1020 1020
 				$e->get_error();
1021 1021
 			}
1022 1022
 		}
@@ -1033,22 +1033,22 @@  discard block
 block discarded – undo
1033 1033
 	 */
1034 1034
 	private function _process_form_action() {
1035 1035
 		// what cha wanna do?
1036
-		switch( $this->checkout->action ) {
1036
+		switch ($this->checkout->action) {
1037 1037
 			// AJAX next step reg form
1038 1038
 			case 'display_spco_reg_step' :
1039 1039
 				$this->checkout->redirect = FALSE;
1040
-				if ( EE_Registry::instance()->REQ->ajax ) {
1041
-					$this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() );
1040
+				if (EE_Registry::instance()->REQ->ajax) {
1041
+					$this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form());
1042 1042
 				}
1043 1043
 				break;
1044 1044
 
1045 1045
 			default :
1046 1046
 				// meh... do one of those other steps first
1047
-				if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) {
1047
+				if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) {
1048 1048
 					// dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1049
-					do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step );
1049
+					do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step);
1050 1050
 					// call action on current step
1051
-					if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) {
1051
+					if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1052 1052
 						// good registrant, you get to proceed
1053 1053
 						if (
1054 1054
 							$this->checkout->current_step->success_message() !== ''
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 						) {
1060 1060
 								EE_Error::add_success(
1061 1061
 									$this->checkout->current_step->success_message()
1062
-									. '<br />' . $this->checkout->next_step->_instructions()
1062
+									. '<br />'.$this->checkout->next_step->_instructions()
1063 1063
 								);
1064 1064
 
1065 1065
 						}
@@ -1067,12 +1067,12 @@  discard block
 block discarded – undo
1067 1067
 						$this->_setup_redirect();
1068 1068
 					}
1069 1069
 					// dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1070
-					do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step );
1070
+					do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step);
1071 1071
 
1072 1072
 				} else {
1073 1073
 					EE_Error::add_error(
1074 1074
 						sprintf(
1075
-							__( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ),
1075
+							__('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'),
1076 1076
 							$this->checkout->action,
1077 1077
 							$this->checkout->current_step->name()
1078 1078
 						),
@@ -1098,10 +1098,10 @@  discard block
 block discarded – undo
1098 1098
 	public function add_styles_and_scripts() {
1099 1099
 		// i18n
1100 1100
 		$this->translate_js_strings();
1101
-		if ( $this->checkout->admin_request ) {
1102
-			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 );
1101
+		if ($this->checkout->admin_request) {
1102
+			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1103 1103
 		} else {
1104
-			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 );
1104
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1105 1105
 		}
1106 1106
 	}
1107 1107
 
@@ -1117,42 +1117,42 @@  discard block
 block discarded – undo
1117 1117
 		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1118 1118
 		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1119 1119
 		EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso');
1120
-		EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' );
1121
-		EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' );
1122
-		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' );
1120
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso');
1121
+		EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso');
1122
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso');
1123 1123
 		EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso');
1124 1124
 		EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso');
1125
-		EE_Registry::$i18n_js_strings['process_registration'] = sprintf( __( 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso' ), '<br/>', '<br/>' );
1126
-		EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' );
1125
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), '<br/>', '<br/>');
1126
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1127 1127
 		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1128 1128
 		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1129 1129
 		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1130
-		EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' );
1131
-		EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' );
1132
-		EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' );
1133
-		EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' );
1134
-		EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' );
1135
-		EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' );
1136
-		EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' );
1137
-		EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' );
1138
-		EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' );
1139
-		EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' );
1140
-		EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' );
1141
-		EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' );
1142
-		EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' );
1143
-		EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' );
1130
+		EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1131
+		EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1132
+		EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1133
+		EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1134
+		EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1135
+		EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1136
+		EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1137
+		EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1138
+		EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1139
+		EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1140
+		EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1141
+		EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1142
+		EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1143
+		EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1144 1144
 		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1145
-			__( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ),
1145
+			__('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'),
1146 1146
 			'<h4 class="important-notice">',
1147 1147
 			'</h4>',
1148 1148
 			'<br />',
1149 1149
 			'<p>',
1150
-			'<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="',
1150
+			'<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1151 1151
 			'">',
1152 1152
 			'</a>',
1153 1153
 			'</p>'
1154 1154
 		);
1155
-		EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true );
1155
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true);
1156 1156
 	}
1157 1157
 
1158 1158
 
@@ -1165,25 +1165,25 @@  discard block
 block discarded – undo
1165 1165
 	 */
1166 1166
 	public function enqueue_styles_and_scripts() {
1167 1167
 		// load css
1168
-		wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION );
1169
-		wp_enqueue_style( 'single_page_checkout' );
1168
+		wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION);
1169
+		wp_enqueue_style('single_page_checkout');
1170 1170
 		// load JS
1171
-		wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js', array( 'jquery' ), '1.0.1', TRUE );
1172
-		wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE );
1173
-		wp_register_script( 'single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), EVENT_ESPRESSO_VERSION, TRUE );
1174
-		wp_enqueue_script( 'single_page_checkout' );
1171
+		wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery	.plugin.min.js', array('jquery'), '1.0.1', TRUE);
1172
+		wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery	.countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE);
1173
+		wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, TRUE);
1174
+		wp_enqueue_script('single_page_checkout');
1175 1175
 
1176 1176
 		/**
1177 1177
 		 * global action hook for enqueueing styles and scripts with
1178 1178
 		 * spco calls.
1179 1179
 		 */
1180
-		do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this );
1180
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1181 1181
 
1182 1182
 		/**
1183 1183
 		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1184 1184
 		 * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1185 1185
 		 */
1186
-		do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this );
1186
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this);
1187 1187
 
1188 1188
 		// add css and JS for current step
1189 1189
 		$this->checkout->current_step->enqueue_styles_and_scripts();
@@ -1200,19 +1200,19 @@  discard block
 block discarded – undo
1200 1200
 	 */
1201 1201
 	private function _display_spco_reg_form() {
1202 1202
 		// if registering via the admin, just display the reg form for the current step
1203
-		if ( $this->checkout->admin_request ) {
1204
-			EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() );
1203
+		if ($this->checkout->admin_request) {
1204
+			EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1205 1205
 		} else {
1206 1206
 			// add powered by EE msg
1207
-			add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' ));
1207
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1208 1208
 
1209
-			$empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false;
1209
+			$empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false;
1210 1210
 			$cookies_not_set_msg = '';
1211
-			if ( $empty_cart && ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) {
1211
+			if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) {
1212 1212
 				$cookies_not_set_msg = apply_filters(
1213 1213
 					'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1214 1214
 					sprintf(
1215
-						__( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ),
1215
+						__('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'),
1216 1216
 						'<div class="ee-attention">',
1217 1217
 						'</div>',
1218 1218
 						'<h6 class="important-notice">',
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 					'layout_strategy' =>
1233 1233
 						new EE_Template_Layout(
1234 1234
 							array(
1235
-								'layout_template_file' 			=> SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1235
+								'layout_template_file' 			=> SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php',
1236 1236
 								'template_args' => array(
1237 1237
 									'empty_cart' 		=> $empty_cart,
1238 1238
 									'revisit' 				=> $this->checkout->revisit,
@@ -1241,8 +1241,8 @@  discard block
 block discarded – undo
1241 1241
 									'empty_msg' 		=> apply_filters(
1242 1242
 										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1243 1243
 										sprintf(
1244
-											__( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ),
1245
-											'<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="',
1244
+											__('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'),
1245
+											'<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1246 1246
 											'">',
1247 1247
 											'</a>'
1248 1248
 										)
@@ -1250,14 +1250,14 @@  discard block
 block discarded – undo
1250 1250
 									'cookies_not_set_msg' 		=> $cookies_not_set_msg,
1251 1251
 									'registration_time_limit' 	=> $this->checkout->get_registration_time_limit(),
1252 1252
 									'session_expiration' 			=>
1253
-										gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) )
1253
+										gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS))
1254 1254
 							)
1255 1255
 						)
1256 1256
 					)
1257 1257
 				)
1258 1258
 			);
1259 1259
 			// load template and add to output sent that gets filtered into the_content()
1260
-			EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() );
1260
+			EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js());
1261 1261
 		}
1262 1262
 	}
1263 1263
 
@@ -1271,8 +1271,8 @@  discard block
 block discarded – undo
1271 1271
 	 * @internal  param string $label
1272 1272
 	 * @return        string
1273 1273
 	 */
1274
-	public function add_extra_finalize_registration_inputs( $next_step ) {
1275
-		if ( $next_step === 'finalize_registration' ) {
1274
+	public function add_extra_finalize_registration_inputs($next_step) {
1275
+		if ($next_step === 'finalize_registration') {
1276 1276
 			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1277 1277
 		}
1278 1278
 	}
@@ -1286,18 +1286,18 @@  discard block
 block discarded – undo
1286 1286
 	 *  @return 	string
1287 1287
 	 */
1288 1288
 	public static function display_registration_footer() {
1289
-		if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) {
1290
-			EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default';
1291
-			$url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' );
1292
-			$url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url );
1289
+		if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) {
1290
+			EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default';
1291
+			$url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/');
1292
+			$url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1293 1293
 			echo apply_filters(
1294 1294
 				'FHEE__EE_Front_Controller__display_registration_footer',
1295 1295
 				sprintf(
1296
-					__( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ),
1297
-					'<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="',
1296
+					__('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'),
1297
+					'<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="',
1298 1298
 					'" target="_blank">',
1299 1299
 					'</a>',
1300
-					'<a href="' . $url . '" title="',
1300
+					'<a href="'.$url.'" title="',
1301 1301
 					'" target="_blank">',
1302 1302
 					'</a></div>'
1303 1303
 				)
@@ -1328,12 +1328,12 @@  discard block
 block discarded – undo
1328 1328
 	 * @return 	array
1329 1329
 	 */
1330 1330
 	private function _setup_redirect() {
1331
-		if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) {
1331
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1332 1332
 			$this->checkout->redirect = TRUE;
1333
-			if ( empty( $this->checkout->redirect_url )) {
1333
+			if (empty($this->checkout->redirect_url)) {
1334 1334
 				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1335 1335
 			}
1336
-			$this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout );
1336
+			$this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout);
1337 1337
 		}
1338 1338
 	}
1339 1339
 
@@ -1347,9 +1347,9 @@  discard block
 block discarded – undo
1347 1347
 	 * @throws \EE_Error
1348 1348
 	 */
1349 1349
 	public function go_to_next_step() {
1350
-		if ( EE_Registry::instance()->REQ->ajax ) {
1350
+		if (EE_Registry::instance()->REQ->ajax) {
1351 1351
 			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1352
-			$this->checkout->json_response->set_unexpected_errors( ob_get_clean() );
1352
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1353 1353
 		}
1354 1354
 		$this->unlock_transaction();
1355 1355
 		// just return for these conditions
@@ -1378,7 +1378,7 @@  discard block
 block discarded – undo
1378 1378
 	 */
1379 1379
 	protected function _handle_json_response() {
1380 1380
 		// if this is an ajax request
1381
-		if ( EE_Registry::instance()->REQ->ajax ) {
1381
+		if (EE_Registry::instance()->REQ->ajax) {
1382 1382
 			// DEBUG LOG
1383 1383
 			//$this->checkout->log(
1384 1384
 			//	__CLASS__, __FUNCTION__, __LINE__,
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
 			$this->checkout->json_response->set_registration_time_limit(
1392 1392
 				$this->checkout->get_registration_time_limit()
1393 1393
 			);
1394
-			$this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing );
1394
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1395 1395
 			// just send the ajax (
1396 1396
 			$json_response = apply_filters(
1397 1397
 				'FHEE__EE_Single_Page_Checkout__JSON_response',
@@ -1412,9 +1412,9 @@  discard block
 block discarded – undo
1412 1412
 	 */
1413 1413
 	protected function _handle_html_redirects() {
1414 1414
 		// going somewhere ?
1415
-		if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) {
1415
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1416 1416
 			// store notices in a transient
1417
-			EE_Error::get_notices( false, true, true );
1417
+			EE_Error::get_notices(false, true, true);
1418 1418
 			// DEBUG LOG
1419 1419
 			//$this->checkout->log(
1420 1420
 			//	__CLASS__, __FUNCTION__, __LINE__,
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
 			//		'headers_list'    => headers_list(),
1425 1425
 			//	)
1426 1426
 			//);
1427
-			wp_safe_redirect( $this->checkout->redirect_url );
1427
+			wp_safe_redirect($this->checkout->redirect_url);
1428 1428
 			exit();
1429 1429
 		}
1430 1430
 	}
Please login to merge, or discard this patch.
core/db_models/relations/EE_Belongs_To_Relation.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php');
3 3
 /**
4
- * Class EE_Belongs_To_Relation
5
- *
6
- * The current model has the foreign key pointing to the other model. Eg, Registration belongs to Transaction
7
- * (because Registration's TXN_ID field is on Registration, and points to the Transaction's PK)
8
- *
9
- * @package     Event Espresso
10
- * @subpackage  core
11
- * @author      MIke Nelson
12
- *
13
- */
4
+	  * Class EE_Belongs_To_Relation
5
+	  *
6
+	  * The current model has the foreign key pointing to the other model. Eg, Registration belongs to Transaction
7
+	  * (because Registration's TXN_ID field is on Registration, and points to the Transaction's PK)
8
+	  *
9
+	  * @package     Event Espresso
10
+	  * @subpackage  core
11
+	  * @author      MIke Nelson
12
+	  *
13
+	  */
14 14
 class EE_Belongs_To_Relation extends EE_Model_Relation_Base {
15 15
 
16 16
 	/**
Please login to merge, or discard this patch.