Completed
Branch FET-9099-unit-test-factories (8a4437)
by
unknown
64:30 queued 53:12
created
core/db_models/EEM_Base.model.php 3 patches
Doc Comments   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	 * Returns the name of the field's name that points to the WP_User table
762 762
 	 *  on this model (or follows the _model_chain_to_wp_user and uses that model's
763 763
 	 * foreign key to the WP_User table)
764
-	 * @return string|boolean string on success, boolean false when there is no
764
+	 * @return string|false string on success, boolean false when there is no
765 765
 	 * foreign key to the WP_User table
766 766
 	 */
767 767
 	function wp_user_field_name() {
@@ -858,6 +858,7 @@  discard block
 block discarded – undo
858 858
 	 * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array.
859 859
 	 * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection
860 860
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
861
+	 * @param string $columns_to_select
861 862
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
862 863
 	 */
863 864
 	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
@@ -1200,7 +1201,7 @@  discard block
 block discarded – undo
1200 1201
 	 * @param bool   $pretty          Whether to return the pretty formats (true) or not (false).
1201 1202
 	 * @throws EE_Error   If the given field_name is not of the EE_Datetime_Field type.
1202 1203
 	 *
1203
-	 * @return array formats in an array with the date format first, and the time format last.
1204
+	 * @return string[] formats in an array with the date format first, and the time format last.
1204 1205
 	 */
1205 1206
 	public function get_formats_for( $field_name, $pretty = false ) {
1206 1207
 		$field_settings = $this->field_settings_for( $field_name );
@@ -1235,7 +1236,7 @@  discard block
 block discarded – undo
1235 1236
 	 *
1236 1237
 	 * @throws EE_Error   	If the given field_name is not of the EE_Datetime_Field type.
1237 1238
 	 *
1238
-	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1239
+	 * @return string|null  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1239 1240
 	 *                    	     exception is triggered.
1240 1241
 	 */
1241 1242
 	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
@@ -1535,7 +1536,7 @@  discard block
 block discarded – undo
1535 1536
 	 * not just have a flag field on it switched
1536 1537
 	 * Wrapper for EEM_Base::delete_permanently()
1537 1538
 	 * @param mixed $id
1538
-	 * @return boolean whether the row got deleted or not
1539
+	 * @return integer whether the row got deleted or not
1539 1540
 	 */
1540 1541
 	public function delete_permanently_by_ID( $id ) {
1541 1542
 		return $this->delete_permanently( 
@@ -1552,7 +1553,7 @@  discard block
 block discarded – undo
1552 1553
 	 * Deletes a single row from the DB given the model object's primary key value. (eg, EE_Attendee->ID()'s value).
1553 1554
 	 * Wrapper for EEM_Base::delete()
1554 1555
 	 * @param mixed $id
1555
-	 * @return boolean whether the row got deleted or not
1556
+	 * @return integer whether the row got deleted or not
1556 1557
 	 */
1557 1558
 	public function delete_by_ID( $id ){
1558 1559
 		return $this->delete( 
@@ -1926,7 +1927,7 @@  discard block
 block discarded – undo
1926 1927
 	/**
1927 1928
 	 * Verifies the EE addons' database is up-to-date and records that we've done it on
1928 1929
 	 * EEM_Base::$_db_verification_level
1929
-	 * @param $wpdb_method
1930
+	 * @param string $wpdb_method
1930 1931
 	 * @param $arguments_to_provide
1931 1932
 	 * @return string
1932 1933
 	 */
@@ -1994,7 +1995,6 @@  discard block
 block discarded – undo
1994 1995
 	 * 'hasAndBelongsToMany' relationships: checks that there isn't already an entry in the join table, and adds one.
1995 1996
 	 * If one of the model Objects has not yet been saved to the database, it is saved before adding the entry in the join table
1996 1997
 	 *
1997
-	 * @param EE_Base_Class/int $thisModelObject
1998 1998
 	 * @param EE_Base_Class/int $id_or_obj EE_base_Class or ID of other Model Object
1999 1999
 	 * @param string $relationName, key in EEM_Base::_relations
2000 2000
 	 * an attendee to a group, you also want to specify which role they will have in that group. So you would use this parameter to specify array('role-column-name'=>'role-id')
@@ -2016,8 +2016,8 @@  discard block
 block discarded – undo
2016 2016
 	 *
2017 2017
 	 * 'hasAndBelongsToMany' relationships:removes any existing entry in the join table between the two models.
2018 2018
 	 *
2019
-	 * @param EE_Base_Class/int $id_or_obj
2020
-	 * @param EE_Base_Class/int $other_model_id_or_obj EE_Base_Class or ID of other Model Object
2019
+	 * @param EE_CPT_Base $id_or_obj
2020
+	 * @param EE_Term_Taxonomy $other_model_id_or_obj EE_Base_Class or ID of other Model Object
2021 2021
 	 * @param string $relationName key in EEM_Base::_relations
2022 2022
 	 * @return boolean of success
2023 2023
 	 * @param array   $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
@@ -2093,7 +2093,7 @@  discard block
 block discarded – undo
2093 2093
 	/**
2094 2094
 	 * Instead of getting the related model objects, simply counts them. Ignores default_where_conditions by default,
2095 2095
 	 * unless otherwise specified in the $query_params
2096
-	 * @param int/EE_Base_Class $id_or_obj
2096
+	 * @param EE_Event $id_or_obj
2097 2097
 	 * @param string $model_name like 'Event', or 'Registration'
2098 2098
 	 * @param array $query_params like EEM_Base::get_all's
2099 2099
 	 * @param string $field_to_count name of field to count by. By default, uses primary key
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
 	/**
2483 2483
 	 * Finds all the fields that correspond to the given table
2484 2484
 	 * @param string $table_alias, array key in EEM_Base::_tables
2485
-	 * @return EE_Model_Field_Base[]
2485
+	 * @return EE_Model_Field_Base
2486 2486
 	 */
2487 2487
 	function _get_fields_for_table($table_alias){
2488 2488
 		return $this->_fields[$table_alias];
@@ -3569,8 +3569,8 @@  discard block
 block discarded – undo
3569 3569
 	/**
3570 3570
 	 * gets the field object of type 'primary_key' from the fieldsSettings attribute.
3571 3571
 	 * Eg, on EE_Answer that would be ANS_ID field object
3572
-	 * @param $field_obj
3573
-	 * @return EE_Model_Field_Base
3572
+	 * @param EE_Model_Field_Base $field_obj
3573
+	 * @return boolean
3574 3574
 	 */
3575 3575
 	public function is_primary_key_field( $field_obj ){
3576 3576
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
@@ -3664,7 +3664,7 @@  discard block
 block discarded – undo
3664 3664
 	 * Gets the actual table for the table alias
3665 3665
 	 * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe
3666 3666
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3667
-	 * @return EE_Table_Base
3667
+	 * @return string
3668 3668
 	 */
3669 3669
 	function get_table_for_alias($table_alias){
3670 3670
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
@@ -3791,7 +3791,7 @@  discard block
 block discarded – undo
3791 3791
 	 * The purpose of this method is to allow us to create a model object that is not in the db that holds default values.
3792 3792
 	 * A typical example of where this is used is when creating a new item and the initial load of a form.  We dont' necessarily want to test for if the object is present but just assume it is BUT load the defaults from the object (as set in the model_field!).
3793 3793
 	 *
3794
-	 * @return EE_Base_Class single EE_Base_Class object with default values for the properties.
3794
+	 * @return boolean single EE_Base_Class object with default values for the properties.
3795 3795
 	 */
3796 3796
 	public function create_default_object() {
3797 3797
 
@@ -3915,7 +3915,7 @@  discard block
 block discarded – undo
3915 3915
 	 * returns an array of their corresponding field names and database values
3916 3916
 	 *
3917 3917
 	 * @param string $cols_n_values
3918
-	 * @return array
3918
+	 * @return string
3919 3919
 	 */
3920 3920
 	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
3921 3921
 		$this_model_fields_n_values = array();
@@ -4176,7 +4176,7 @@  discard block
 block discarded – undo
4176 4176
 	}
4177 4177
 	/**
4178 4178
 	 * Read comments for assume_values_already_prepared_by_model_object()
4179
-	 * @return int
4179
+	 * @return boolean
4180 4180
 	 */
4181 4181
 	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4182 4182
 		return $this->_values_already_prepared_by_model_object;
Please login to merge, or discard this patch.
Spacing   +954 added lines, -954 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @since 				EE4
24 24
  *
25 25
  */
26
-abstract class EEM_Base extends EE_Base{
26
+abstract class EEM_Base extends EE_Base {
27 27
 
28 28
 	//admin posty
29 29
 	//basic -> grants access to mine -> if they don't have it, select none
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * Flag indicating whether this model has a primary key or not
236 236
 	 * @var boolean
237 237
 	 */
238
-	protected $_has_primary_key_field=null;
238
+	protected $_has_primary_key_field = null;
239 239
 
240 240
 	/**
241 241
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -297,19 +297,19 @@  discard block
 block discarded – undo
297 297
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
298 298
 	 * @var array
299 299
 	 */
300
-	protected $_between_style_operators = array( 'BETWEEN' );
300
+	protected $_between_style_operators = array('BETWEEN');
301 301
 
302 302
 	/**
303 303
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
304 304
 	 * @var array
305 305
 	 */
306
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
306
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
307 307
 
308 308
 	/**
309 309
 	 * Allowed values for $query_params['order'] for ordering in queries
310 310
 	 * @var array
311 311
 	 */
312
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
312
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
313 313
 
314 314
 	/**
315 315
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
324 324
 	 * @var array
325 325
 	 */
326
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
326
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
327 327
 
328 328
 	/**
329 329
 	 * All the data types that can be used in $wpdb->prepare statements.
330 330
 	 * @var array
331 331
 	 */
332
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
332
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
333 333
 
334 334
 	/**
335 335
 	 * 	EE_Registry Object
@@ -362,17 +362,17 @@  discard block
 block discarded – undo
362 362
 	/**
363 363
 	 * constant used to show EEM_Base has not yet verified the db on this http request
364 364
 	 */
365
-	const db_verified_none 		= 0;
365
+	const db_verified_none = 0;
366 366
 	/**
367 367
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
368 368
 	 * but not the addons' dbs
369 369
 	 */
370
-	const db_verified_core 		= 1;
370
+	const db_verified_core = 1;
371 371
 	/**
372 372
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
373 373
 	 * the EE core db too)
374 374
 	 */
375
-	const db_verified_addons 	= 2;
375
+	const db_verified_addons = 2;
376 376
 
377 377
 	/**
378 378
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
 	 * @param null $timezone
404 404
 	 * @throws \EE_Error
405 405
 	 */
406
-	protected function __construct( $timezone = NULL ){
406
+	protected function __construct($timezone = NULL) {
407 407
 		// check that the model has not been loaded too soon
408
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
409
-			throw new EE_Error (
408
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
409
+			throw new EE_Error(
410 410
 				sprintf(
411
-					__( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ),
412
-					get_class( $this )
411
+					__('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'),
412
+					get_class($this)
413 413
 				)
414 414
 			);
415 415
 		}
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
 		 * just use EE_Register_Model_Extension
420 420
 		 * @var EE_Table_Base[] $_tables
421 421
 		 */
422
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
423
-		foreach($this->_tables as $table_alias => $table_obj){
422
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
423
+		foreach ($this->_tables as $table_alias => $table_obj) {
424 424
 			/** @var $table_obj EE_Table_Base */
425 425
 			$table_obj->_construct_finalize_with_alias($table_alias);
426
-			if( $table_obj instanceof EE_Secondary_Table ){
426
+			if ($table_obj instanceof EE_Secondary_Table) {
427 427
 				/** @var $table_obj EE_Secondary_Table */
428 428
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
429 429
 			}
@@ -433,54 +433,54 @@  discard block
 block discarded – undo
433 433
 		 * EE_Register_Model_Extension
434 434
 		 * @param EE_Model_Field_Base[] $_fields
435 435
 		 */
436
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
436
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
437 437
 		$this->_invalidate_field_caches();
438
-		foreach($this->_fields as $table_alias => $fields_for_table){
439
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
440
-				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields)));
438
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
439
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
440
+				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields)));
441 441
 			}
442
-			foreach($fields_for_table as $field_name => $field_obj){
442
+			foreach ($fields_for_table as $field_name => $field_obj) {
443 443
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
444 444
 				//primary key field base has a slightly different _construct_finalize
445 445
 				/** @var $field_obj EE_Model_Field_Base */
446
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
446
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
447 447
 			}
448 448
 		}
449 449
 
450 450
 		// everything is related to Extra_Meta
451
-		if( get_class($this) != 'EEM_Extra_Meta'){
451
+		if (get_class($this) != 'EEM_Extra_Meta') {
452 452
 			//make extra meta related to everything, but don't block deleting things just
453 453
 			//because they have related extra meta info. For now just orphan those extra meta
454 454
 			//in the future we should automatically delete them
455
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
455
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
456 456
 		}
457 457
 		//and change logs
458
-		if( get_class( $this) !=  'EEM_Change_Log' ) {
459
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
458
+		if (get_class($this) != 'EEM_Change_Log') {
459
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
460 460
 		}
461 461
 		/**
462 462
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
463 463
 		 * EE_Register_Model_Extension
464 464
 		 * @param EE_Model_Relation_Base[] $_model_relations
465 465
 		 */
466
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
467
-		foreach($this->_model_relations as $model_name => $relation_obj){
466
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
467
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
468 468
 			/** @var $relation_obj EE_Model_Relation_Base */
469 469
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
470 470
 		}
471
-		foreach($this->_indexes as $index_name => $index_obj){
471
+		foreach ($this->_indexes as $index_name => $index_obj) {
472 472
 			/** @var $index_obj EE_Index */
473 473
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
474 474
 		}
475 475
 
476 476
 		$this->set_timezone($timezone);
477 477
 		//finalize default where condition strategy, or set default
478
-		if( ! $this->_default_where_conditions_strategy){
478
+		if ( ! $this->_default_where_conditions_strategy) {
479 479
 			//nothing was set during child constructor, so set default
480 480
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
481 481
 		}
482 482
 		$this->_default_where_conditions_strategy->_finalize_construct($this);
483
-		if( ! $this->_minimum_where_conditions_strategy){
483
+		if ( ! $this->_minimum_where_conditions_strategy) {
484 484
 			//nothing was set during child constructor, so set default
485 485
 			$this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions();
486 486
 		}
@@ -488,15 +488,15 @@  discard block
 block discarded – undo
488 488
 
489 489
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
490 490
 		//to indicate to NOT set it, set it to the logical default
491
-		if( $this->_caps_slug === null ) {
492
-			EE_Registry::instance()->load_helper( 'Inflector' );
493
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
491
+		if ($this->_caps_slug === null) {
492
+			EE_Registry::instance()->load_helper('Inflector');
493
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
494 494
 		}
495 495
 		//initialize the standard cap restriction generators if none were specified by the child constructor
496
-		if( $this->_cap_restriction_generators !== false ){
497
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
498
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
499
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
496
+		if ($this->_cap_restriction_generators !== false) {
497
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
498
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
499
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
500 500
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
501 501
 						new EE_Restriction_Generator_Protected(),
502 502
 						$cap_context,
@@ -506,23 +506,23 @@  discard block
 block discarded – undo
506 506
 			}
507 507
 		}
508 508
 		//if there are cap restriction generators, use them to make the default cap restrictions
509
-		if( $this->_cap_restriction_generators !== false ){
510
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
511
-				if( ! $generator_object ){
509
+		if ($this->_cap_restriction_generators !== false) {
510
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
511
+				if ( ! $generator_object) {
512 512
 					continue;
513 513
 				}
514
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
514
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
515 515
 					throw new EE_Error(
516 516
 						sprintf(
517
-							__( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ),
517
+							__('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'),
518 518
 							$context,
519 519
 							$this->get_this_model_name()
520 520
 						)
521 521
 					);
522 522
 				}
523
-				$action = $this->cap_action_for_context( $context );
524
-				if( ! $generator_object->construction_finalized() ){
525
-					$generator_object->_construct_finalize( $this, $action );
523
+				$action = $this->cap_action_for_context($context);
524
+				if ( ! $generator_object->construction_finalized()) {
525
+					$generator_object->_construct_finalize($this, $action);
526 526
 				}
527 527
 
528 528
 			}
@@ -536,11 +536,11 @@  discard block
 block discarded – undo
536 536
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
537 537
 	 * @return EE_Default_Where_Conditions[]
538 538
 	 */
539
-	protected function _generate_cap_restrictions( $context ){
540
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
541
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
542
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
543
-		}else{
539
+	protected function _generate_cap_restrictions($context) {
540
+		if (isset($this->_cap_restriction_generators[$context]) &&
541
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
542
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
543
+		} else {
544 544
 			return array();
545 545
 		}
546 546
 }
@@ -553,16 +553,16 @@  discard block
 block discarded – undo
553 553
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
554 554
 	 *		@return static (as in the concrete child class)
555 555
 	 */
556
-	public static function instance( $timezone = NULL ){
556
+	public static function instance($timezone = NULL) {
557 557
 
558 558
 		// check if instance of Espresso_model already exists
559 559
 		if ( ! static::$_instance instanceof static) {
560 560
 			// instantiate Espresso_model
561
-			static::$_instance = new static( $timezone );
561
+			static::$_instance = new static($timezone);
562 562
 		}
563 563
 
564 564
 		//we might have a timezone set, let set_timezone decide what to do with it
565
-		static::$_instance->set_timezone( $timezone );
565
+		static::$_instance->set_timezone($timezone);
566 566
 
567 567
 		// Espresso_model object
568 568
 		return static::$_instance;
@@ -575,11 +575,11 @@  discard block
 block discarded – undo
575 575
 	 * @param null | string $timezone
576 576
 	 * @return static
577 577
 	 */
578
-	public static function reset(  $timezone = NULL ){
579
-		if ( ! is_null( static::$_instance ) ) {
578
+	public static function reset($timezone = NULL) {
579
+		if ( ! is_null(static::$_instance)) {
580 580
 			static::$_instance = null;
581 581
 
582
-			return self::instance( $timezone );
582
+			return self::instance($timezone);
583 583
 		}
584 584
 		return null;
585 585
 	}
@@ -590,15 +590,15 @@  discard block
 block discarded – undo
590 590
 	 * @param  boolean $translated return localized strings or JUST the array.
591 591
 	 * @return array
592 592
 	 */
593
-	 public function status_array( $translated = FALSE ) {
594
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
593
+	 public function status_array($translated = FALSE) {
594
+	 	if ( ! array_key_exists('Status', $this->_model_relations))
595 595
 	 		return array();
596 596
 	 	$model_name = $this->get_this_model_name();
597
-	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
598
-	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
597
+	 	$status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
598
+	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
599 599
 	 	$status_array = array();
600
-	 	foreach ( $stati as $status ) {
601
-            $status_array[ $status->ID() ] = $status->get('STS_code');
600
+	 	foreach ($stati as $status) {
601
+            $status_array[$status->ID()] = $status->get('STS_code');
602 602
         }
603 603
         return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
604 604
     }
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 	 *			'order_by'=>array('ANS_value'=>'ASC')
740 740
 	 *		));
741 741
 	 */
742
-	function get_all($query_params = array()){
742
+	function get_all($query_params = array()) {
743 743
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
744 744
 	}
745 745
 
@@ -749,10 +749,10 @@  discard block
 block discarded – undo
749 749
 	 * @param array $query_params @see EEM_Base::get_all()
750 750
 	 * @return array like EEM_Base::get_all
751 751
 	 */
752
-	function alter_query_params_to_only_include_mine( $query_params = array() ) {
752
+	function alter_query_params_to_only_include_mine($query_params = array()) {
753 753
 		$wp_user_field_name = $this->wp_user_field_name();
754
-		if( $wp_user_field_name ){
755
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
754
+		if ($wp_user_field_name) {
755
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
756 756
 		}
757 757
 		return $query_params;
758 758
 	}
@@ -765,19 +765,19 @@  discard block
 block discarded – undo
765 765
 	 * foreign key to the WP_User table
766 766
 	 */
767 767
 	function wp_user_field_name() {
768
-		try{
769
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
770
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
771
-				$last_model_name = end( $models_to_follow_to_wp_users );
772
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
773
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
774
-			}else{
768
+		try {
769
+			if ( ! empty($this->_model_chain_to_wp_user)) {
770
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
771
+				$last_model_name = end($models_to_follow_to_wp_users);
772
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
773
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
774
+			} else {
775 775
 				$model_with_fk_to_wp_users = $this;
776 776
 				$model_chain_to_wp_user = '';
777 777
 			}
778
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
779
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
780
-		}catch( EE_Error $e ) {
778
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
779
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
780
+		} catch (EE_Error $e) {
781 781
 			return false;
782 782
 		}
783 783
 	}
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	 * (or transiently-related model)
792 792
 	 * @return string
793 793
 	 */
794
-	public function model_chain_to_wp_user(){
794
+	public function model_chain_to_wp_user() {
795 795
 		return $this->_model_chain_to_wp_user;
796 796
 	}
797 797
 
@@ -803,13 +803,13 @@  discard block
 block discarded – undo
803 803
 	 * @return boolean
804 804
 	 */
805 805
 	public function is_owned() {
806
-		if( $this->model_chain_to_wp_user() ){
806
+		if ($this->model_chain_to_wp_user()) {
807 807
 			return true;
808
-		}else{
809
-			try{
810
-				$this->get_foreign_key_to( 'WP_User' );
808
+		} else {
809
+			try {
810
+				$this->get_foreign_key_to('WP_User');
811 811
 				return true;
812
-			}catch( EE_Error $e ){
812
+			} catch (EE_Error $e) {
813 813
 				return false;
814 814
 			}
815 815
 		}
@@ -828,21 +828,21 @@  discard block
 block discarded – undo
828 828
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
829 829
 	 * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
830 830
 	 */
831
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
831
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
832 832
 		//remember the custom selections, if any
833
-		if(is_array($columns_to_select)){
833
+		if (is_array($columns_to_select)) {
834 834
 			$this->_custom_selections = $columns_to_select;
835
-		}elseif(is_string($columns_to_select)){
835
+		}elseif (is_string($columns_to_select)) {
836 836
 			$this->_custom_selections = array($this->_custom_selections);
837
-		}else{
837
+		} else {
838 838
 			$this->_custom_selections = array();
839 839
 		}
840 840
 
841 841
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
842 842
 		$select_expressions = $columns_to_select ? $this->_construct_select_from_input($columns_to_select) : $this->_construct_default_select_sql($model_query_info);
843
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
843
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
844 844
 //		echo "sql:$SQL";
845
-		$results =  $this->_do_wpdb_query( 'get_results', array($SQL, $output ) );// $wpdb->get_results($SQL, $output);
845
+		$results = $this->_do_wpdb_query('get_results', array($SQL, $output)); // $wpdb->get_results($SQL, $output);
846 846
 		return $results;
847 847
 	}
848 848
 
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
861 861
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
862 862
 	 */
863
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
863
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
864 864
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
865 865
 	}
866 866
 
@@ -872,12 +872,12 @@  discard block
 block discarded – undo
872 872
 	 * @throws EE_Error
873 873
 	 * @return string
874 874
 	 */
875
-	private function _construct_select_from_input($columns_to_select){
876
-		if(is_array($columns_to_select)){
875
+	private function _construct_select_from_input($columns_to_select) {
876
+		if (is_array($columns_to_select)) {
877 877
 			$select_sql_array = array();
878 878
 
879
-			foreach($columns_to_select as $alias => $selection_and_datatype){
880
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
879
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
880
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
881 881
 					throw new EE_Error(
882 882
 						sprintf(
883 883
 							__(
@@ -889,24 +889,24 @@  discard block
 block discarded – undo
889 889
 						)
890 890
 					);
891 891
 				}
892
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
892
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
893 893
 					throw new EE_Error(
894 894
 						sprintf(
895 895
 							__(
896 896
 								"Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)",
897 897
 								"event_espresso"
898 898
 							),
899
-							$selection_and_datatype[ 1 ],
900
-							$selection_and_datatype[ 0 ],
899
+							$selection_and_datatype[1],
900
+							$selection_and_datatype[0],
901 901
 							$alias,
902
-							implode( ",", $this->_valid_wpdb_data_types )
902
+							implode(",", $this->_valid_wpdb_data_types)
903 903
 						)
904 904
 					);
905 905
 				}
906 906
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
907 907
 			}
908
-			$columns_to_select_string = implode(", ",$select_sql_array);
909
-		}else{
908
+			$columns_to_select_string = implode(", ", $select_sql_array);
909
+		} else {
910 910
 			$columns_to_select_string = $columns_to_select;
911 911
 		}
912 912
 		return $columns_to_select_string;
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 	 * Convenient wrapper for getting the primary key field's name. Eg, on Registration, this would be 'REG_ID'
920 920
 	 * @return string
921 921
 	 */
922
-	function primary_key_name(){
922
+	function primary_key_name() {
923 923
 		return $this->get_primary_key_field()->get_name();
924 924
 	}
925 925
 
@@ -931,14 +931,14 @@  discard block
 block discarded – undo
931 931
 	 * @param mixed $id int or string, depending on the type of the model's primary key
932 932
 	 * @return EE_Base_Class
933 933
 	 */
934
-	function get_one_by_ID($id){
935
-		if( $this->get_from_entity_map( $id ) ){
936
-			return $this->get_from_entity_map( $id );
934
+	function get_one_by_ID($id) {
935
+		if ($this->get_from_entity_map($id)) {
936
+			return $this->get_from_entity_map($id);
937 937
 		}
938 938
 		return $this->get_one( 
939 939
 			$this->alter_query_params_to_restrict_by_ID( 
940 940
 				$id,
941
-				array( 'default_where_conditions' => 'minimum' )
941
+				array('default_where_conditions' => 'minimum')
942 942
 			) 
943 943
 		);
944 944
 	}
@@ -950,15 +950,15 @@  discard block
 block discarded – undo
950 950
 	 * @param array $query_params
951 951
 	 * @return array of normal query params, @see EEM_Base::get_all
952 952
 	 */
953
-	public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) {
954
-		if( ! isset( $query_params[ 0 ] ) ) {
955
-			$query_params[ 0 ] = array();
953
+	public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) {
954
+		if ( ! isset($query_params[0])) {
955
+			$query_params[0] = array();
956 956
 		}
957
-		if( $this->has_primary_key_field ( ) ) {
958
-			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
959
-		}else{
957
+		if ($this->has_primary_key_field( )) {
958
+			$query_params[0][$this->primary_key_name()] = $id;
959
+		} else {
960 960
 			//no primary key, so the $id must be from the get_index_primary_key_string()
961
-			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
961
+			$query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id));
962 962
 		}
963 963
 		return $query_params;
964 964
 	}
@@ -970,16 +970,16 @@  discard block
 block discarded – undo
970 970
 	 * @param array $query_params like EEM_Base's $query_params variable.
971 971
 	 * @return EE_Base_Class | NULL
972 972
 	 */
973
-	function get_one($query_params = array()){
974
-		if( ! is_array( $query_params ) ){
975
-			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
973
+	function get_one($query_params = array()) {
974
+		if ( ! is_array($query_params)) {
975
+			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
976 976
 			$query_params = array();
977 977
 		}
978 978
 		$query_params['limit'] = 1;
979 979
 		$items = $this->get_all($query_params);
980
-		if(empty($items)){
980
+		if (empty($items)) {
981 981
 			return null;
982
-		}else{
982
+		} else {
983 983
 			return array_shift($items);
984 984
 		}
985 985
 	}
@@ -1003,8 +1003,8 @@  discard block
 block discarded – undo
1003 1003
 	 *
1004 1004
 	 * @return EE_Base_Class[]|array
1005 1005
 	 */
1006
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1007
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
1006
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1007
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
1008 1008
 	}
1009 1009
 
1010 1010
 
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 	 *
1028 1028
 	 * @return EE_Base_Class[]|array
1029 1029
 	 */
1030
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1031
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1030
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1031
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1032 1032
 	}
1033 1033
 
1034 1034
 
@@ -1050,9 +1050,9 @@  discard block
 block discarded – undo
1050 1050
 	 *
1051 1051
 	 * @return EE_Base_Class|null|array()
1052 1052
 	 */
1053
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1054
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1055
-		return empty( $results ) ? null : reset( $results );
1053
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1054
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1055
+		return empty($results) ? null : reset($results);
1056 1056
 	}
1057 1057
 
1058 1058
 
@@ -1074,9 +1074,9 @@  discard block
 block discarded – undo
1074 1074
 	 *
1075 1075
 	 * @return EE_Base_Class|null|array()
1076 1076
 	 */
1077
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1078
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1079
-		return empty( $results ) ? null : reset( $results );
1077
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1078
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1079
+		return empty($results) ? null : reset($results);
1080 1080
 	}
1081 1081
 
1082 1082
 
@@ -1102,40 +1102,40 @@  discard block
 block discarded – undo
1102 1102
 	 * @return EE_Base_Class[]|array
1103 1103
 	 * @throws EE_Error
1104 1104
 	 */
1105
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1105
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1106 1106
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1107
-		if ( empty( $field_to_order_by ) ) {
1108
-			if ( $this->has_primary_key_field() ) {
1107
+		if (empty($field_to_order_by)) {
1108
+			if ($this->has_primary_key_field()) {
1109 1109
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1110 1110
 			} else {
1111 1111
 
1112
-				if ( WP_DEBUG ) {
1113
-					throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) );
1112
+				if (WP_DEBUG) {
1113
+					throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso'));
1114 1114
 				}
1115
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1115
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1116 1116
 				return array();
1117 1117
 			}
1118 1118
 		}
1119 1119
 
1120
-		if( ! is_array( $query_params ) ){
1121
-			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1120
+		if ( ! is_array($query_params)) {
1121
+			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1122 1122
 			$query_params = array();
1123 1123
 		}
1124 1124
 
1125 1125
 		//let's add the where query param for consecutive look up.
1126
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1126
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1127 1127
 		$query_params['limit'] = $limit;
1128 1128
 
1129 1129
 		//set direction
1130
-		$incoming_orderby = isset( $query_params['order_by'] ) ? $query_params['order_by'] : array();
1131
-		$query_params['order_by'] = $operand == '>' ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby : array( $field_to_order_by => 'DESC') + $incoming_orderby;
1130
+		$incoming_orderby = isset($query_params['order_by']) ? $query_params['order_by'] : array();
1131
+		$query_params['order_by'] = $operand == '>' ? array($field_to_order_by => 'ASC') + $incoming_orderby : array($field_to_order_by => 'DESC') + $incoming_orderby;
1132 1132
 
1133 1133
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1134
-		if ( empty( $columns_to_select ) ) {
1135
-			return $this->get_all( $query_params );
1134
+		if (empty($columns_to_select)) {
1135
+			return $this->get_all($query_params);
1136 1136
 		} else {
1137 1137
 			//getting just the fields
1138
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1138
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1139 1139
 		}
1140 1140
 	}
1141 1141
 
@@ -1146,18 +1146,18 @@  discard block
 block discarded – undo
1146 1146
 	 * This sets the _timezone property after model object has been instantiated.
1147 1147
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1148 1148
 	 */
1149
-	public function set_timezone( $timezone ) {
1150
-		if ( $timezone !== null ) {
1149
+	public function set_timezone($timezone) {
1150
+		if ($timezone !== null) {
1151 1151
 			$this->_timezone = $timezone;
1152 1152
 		}
1153 1153
 		//note we need to loop through relations and set the timezone on those objects as well.
1154
-		foreach ( $this->_model_relations as $relation ) {
1155
-			$relation->set_timezone( $timezone );
1154
+		foreach ($this->_model_relations as $relation) {
1155
+			$relation->set_timezone($timezone);
1156 1156
 		}
1157 1157
 		//and finally we do the same for any datetime fields
1158
-		foreach ( $this->_fields as $field ) {
1159
-			if ( $field instanceof EE_Datetime_Field ) {
1160
-				$field->set_timezone( $timezone );
1158
+		foreach ($this->_fields as $field) {
1159
+			if ($field instanceof EE_Datetime_Field) {
1160
+				$field->set_timezone($timezone);
1161 1161
 			}
1162 1162
 		}
1163 1163
 	}
@@ -1172,9 +1172,9 @@  discard block
 block discarded – undo
1172 1172
 	 */
1173 1173
 	public function get_timezone() {
1174 1174
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1175
-		if ( empty( $this->_timezone ) ) {
1176
-			foreach( $this->_fields as $field ) {
1177
-				if ( $field instanceof EE_Datetime_Field ) {
1175
+		if (empty($this->_timezone)) {
1176
+			foreach ($this->_fields as $field) {
1177
+				if ($field instanceof EE_Datetime_Field) {
1178 1178
 					$this->set_timezone($field->get_timezone());
1179 1179
 					break;
1180 1180
 				}
@@ -1182,9 +1182,9 @@  discard block
 block discarded – undo
1182 1182
 		}
1183 1183
 
1184 1184
 		//if timezone STILL empty then return the default timezone for the site.
1185
-		if ( empty( $this->_timezone ) ) {
1186
-			EE_Registry::instance()->load_helper( 'DTT_Helper' );
1187
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1185
+		if (empty($this->_timezone)) {
1186
+			EE_Registry::instance()->load_helper('DTT_Helper');
1187
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1188 1188
 		}
1189 1189
 		return $this->_timezone;
1190 1190
 	}
@@ -1202,19 +1202,19 @@  discard block
 block discarded – undo
1202 1202
 	 *
1203 1203
 	 * @return array formats in an array with the date format first, and the time format last.
1204 1204
 	 */
1205
-	public function get_formats_for( $field_name, $pretty = false ) {
1206
-		$field_settings = $this->field_settings_for( $field_name );
1205
+	public function get_formats_for($field_name, $pretty = false) {
1206
+		$field_settings = $this->field_settings_for($field_name);
1207 1207
 
1208 1208
 		//if not a valid EE_Datetime_Field then throw error
1209
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1210
-			throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) );
1209
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1210
+			throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name));
1211 1211
 		}
1212 1212
 
1213 1213
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1214 1214
 		//the field.
1215 1215
 		$this->_timezone = $field_settings->get_timezone();
1216 1216
 
1217
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1217
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1218 1218
 	}
1219 1219
 
1220 1220
 
@@ -1238,25 +1238,25 @@  discard block
 block discarded – undo
1238 1238
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1239 1239
 	 *                    	     exception is triggered.
1240 1240
 	 */
1241
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1242
-		$formats = $this->get_formats_for( $field_name );
1241
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1242
+		$formats = $this->get_formats_for($field_name);
1243 1243
 
1244
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1244
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1245 1245
 
1246
-		if ( $timestamp ) {
1247
-			return $DateTime->format( 'U' );
1246
+		if ($timestamp) {
1247
+			return $DateTime->format('U');
1248 1248
 		}
1249 1249
 
1250 1250
 		//not returning timestamp, so return formatted string in timezone.
1251
-		switch( $what ) {
1251
+		switch ($what) {
1252 1252
 			case 'time' :
1253
-				return $DateTime->format( $formats[1] );
1253
+				return $DateTime->format($formats[1]);
1254 1254
 				break;
1255 1255
 			case 'date' :
1256
-				return $DateTime->format( $formats[0] );
1256
+				return $DateTime->format($formats[0]);
1257 1257
 				break;
1258 1258
 			default :
1259
-				return $DateTime->format( implode( ' ', $formats ) );
1259
+				return $DateTime->format(implode(' ', $formats));
1260 1260
 				break;
1261 1261
 		}
1262 1262
 	}
@@ -1280,18 +1280,18 @@  discard block
 block discarded – undo
1280 1280
 	 *                           		'U', this is ignored.
1281 1281
 	 * @return DateTime
1282 1282
 	 */
1283
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1283
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1284 1284
 
1285 1285
 		//just using this to ensure the timezone is set correctly internally
1286
-		$this->get_formats_for( $field_name );
1286
+		$this->get_formats_for($field_name);
1287 1287
 
1288 1288
 		//load EEH_DTT_Helper
1289
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
1290
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1289
+		EE_Registry::instance()->load_helper('DTT_Helper');
1290
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1291 1291
 
1292
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1292
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1293 1293
 
1294
-		return $incomingDateTime->setTimeZone( new DateTimeZone( $this->_timezone ) );
1294
+		return $incomingDateTime->setTimeZone(new DateTimeZone($this->_timezone));
1295 1295
 	}
1296 1296
 
1297 1297
 
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1302 1302
 	 * @return EE_Table_Base[]
1303 1303
 	 */
1304
-	function get_tables(){
1304
+	function get_tables() {
1305 1305
 		return $this->_tables;
1306 1306
 	}
1307 1307
 
@@ -1335,9 +1335,9 @@  discard block
 block discarded – undo
1335 1335
 	 * be aware that model objects being used could get out-of-sync with the database
1336 1336
 	 * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad)
1337 1337
 	 */
1338
-	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1339
-		if( ! is_array( $query_params ) ){
1340
-			EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1338
+	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1339
+		if ( ! is_array($query_params)) {
1340
+			EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1341 1341
 			$query_params = array();
1342 1342
 		}
1343 1343
 		/**
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
 		 * @param array $fields_n_values the updated fields and their new values
1348 1348
 		 * @param array $query_params @see EEM_Base::get_all()
1349 1349
 		 */
1350
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1350
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1351 1351
 		/**
1352 1352
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1353 1353
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1355,10 +1355,10 @@  discard block
 block discarded – undo
1355 1355
 		 * @param EEM_Base $model the model being queried
1356 1356
 		 * @param array $query_params see EEM_Base::get_all()
1357 1357
 		 */
1358
-		$fields_n_values = apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1358
+		$fields_n_values = apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1359 1359
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1360 1360
 		//to do that, for each table, verify that it's PK isn't null.
1361
-		$tables= $this->get_tables();
1361
+		$tables = $this->get_tables();
1362 1362
 
1363 1363
 		//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1364 1364
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1368,29 +1368,29 @@  discard block
 block discarded – undo
1368 1368
 			//we want to make sure the default_where strategy is ignored
1369 1369
 			$this->_ignore_where_strategy = TRUE;
1370 1370
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1371
-			foreach( $wpdb_select_results as $wpdb_result ){
1371
+			foreach ($wpdb_select_results as $wpdb_result) {
1372 1372
 				// type cast stdClass as array
1373
-				$wpdb_result = (array)$wpdb_result;
1373
+				$wpdb_result = (array) $wpdb_result;
1374 1374
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1375
-				if( $this->has_primary_key_field() ){
1376
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1377
-				}else{
1375
+				if ($this->has_primary_key_field()) {
1376
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1377
+				} else {
1378 1378
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1379 1379
 					$main_table_pk_value = null;
1380 1380
 				}
1381 1381
 				//if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables
1382 1382
 				//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1383
-				if(count($tables) > 1){
1383
+				if (count($tables) > 1) {
1384 1384
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1385 1385
 					//in that table, and so we'll want to insert one
1386
-					foreach($tables as $table_obj){
1386
+					foreach ($tables as $table_obj) {
1387 1387
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1388 1388
 						//if there is no private key for this table on the results, it means there's no entry
1389 1389
 						//in this table, right? so insert a row in the current table, using any fields available
1390
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1390
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1391 1391
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1392 1392
 							//if we died here, report the error
1393
-							if( ! $success ) {
1393
+							if ( ! $success) {
1394 1394
 								return false;
1395 1395
 							}
1396 1396
 						}
@@ -1410,44 +1410,44 @@  discard block
 block discarded – undo
1410 1410
 		//if this wasn't called from a model object (to update itself)
1411 1411
 		//then we want to make sure we keep all the existing
1412 1412
 		//model objects in sync with the db
1413
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1414
-			if( $this->has_primary_key_field() ){
1415
-				$model_objs_affected_ids = $this->get_col( $query_params );
1416
-			}else{
1413
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1414
+			if ($this->has_primary_key_field()) {
1415
+				$model_objs_affected_ids = $this->get_col($query_params);
1416
+			} else {
1417 1417
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1418
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1418
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1419 1419
 				$model_objs_affected_ids = array();
1420
-				foreach( $models_affected_key_columns as $row ){
1421
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1422
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1420
+				foreach ($models_affected_key_columns as $row) {
1421
+					$combined_index_key = $this->get_index_primary_key_string($row);
1422
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1423 1423
 				}
1424 1424
 
1425 1425
 			}
1426 1426
 
1427
-			if( ! $model_objs_affected_ids ){
1427
+			if ( ! $model_objs_affected_ids) {
1428 1428
 				//wait wait wait- if nothing was affected let's stop here
1429 1429
 				return 0;
1430 1430
 			}
1431
-			foreach( $model_objs_affected_ids as $id ){
1432
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1433
-				if( $model_obj_in_entity_map ){
1434
-					foreach( $fields_n_values as $field => $new_value ){
1435
-						$model_obj_in_entity_map->set( $field, $new_value );
1431
+			foreach ($model_objs_affected_ids as $id) {
1432
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1433
+				if ($model_obj_in_entity_map) {
1434
+					foreach ($fields_n_values as $field => $new_value) {
1435
+						$model_obj_in_entity_map->set($field, $new_value);
1436 1436
 					}
1437 1437
 				}
1438 1438
 			}
1439 1439
 			//if there is a primary key on this model, we can now do a slight optimization
1440
-			if( $this->has_primary_key_field() ){
1440
+			if ($this->has_primary_key_field()) {
1441 1441
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1442 1442
 				$query_params = array(
1443
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1444
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1443
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1444
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1445 1445
 			}
1446 1446
 		}
1447 1447
 
1448
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1449
-		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1450
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1448
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1449
+		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1450
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1451 1451
 		/**
1452 1452
 		 * Action called after a model update call has been made.
1453 1453
 		 *
@@ -1456,8 +1456,8 @@  discard block
 block discarded – undo
1456 1456
 		 * @param array $query_params @see EEM_Base::get_all()
1457 1457
 		 * @param int $rows_affected
1458 1458
 		 */
1459
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1460
-		return $rows_affected;//how many supposedly got updated
1459
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1460
+		return $rows_affected; //how many supposedly got updated
1461 1461
 	}
1462 1462
 
1463 1463
 	/**
@@ -1469,22 +1469,22 @@  discard block
 block discarded – undo
1469 1469
 	 * @param string $field_to_select
1470 1470
 	 * @return array just like $wpdb->get_col()
1471 1471
 	 */
1472
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1472
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1473 1473
 
1474
-		if( $field_to_select ){
1475
-			$field = $this->field_settings_for( $field_to_select );
1476
-		}elseif( $this->has_primary_key_field ( ) ){
1474
+		if ($field_to_select) {
1475
+			$field = $this->field_settings_for($field_to_select);
1476
+		}elseif ($this->has_primary_key_field( )) {
1477 1477
 			$field = $this->get_primary_key_field();
1478
-		}else{
1478
+		} else {
1479 1479
 			//no primary key, just grab the first column
1480
-			$field = reset( $this->field_settings());
1480
+			$field = reset($this->field_settings());
1481 1481
 		}
1482 1482
 
1483 1483
 
1484 1484
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1485 1485
 		$select_expressions = $field->get_qualified_column();
1486
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1487
-		$results =  $this->_do_wpdb_query('get_col', array( $SQL ) );
1486
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1487
+		$results = $this->_do_wpdb_query('get_col', array($SQL));
1488 1488
 		return $results;
1489 1489
 	}
1490 1490
 
@@ -1494,12 +1494,12 @@  discard block
 block discarded – undo
1494 1494
 	 * @param string $field_to_select @see EEM_Base::get_col()
1495 1495
 	 * @return string
1496 1496
 	 */
1497
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1498
-		$query_params[ 'limit' ] = 1;
1499
-		$col = $this->get_col( $query_params, $field_to_select );
1500
-		if( ! empty( $col ) ) {
1501
-			return reset( $col );
1502
-		}else{
1497
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1498
+		$query_params['limit'] = 1;
1499
+		$col = $this->get_col($query_params, $field_to_select);
1500
+		if ( ! empty($col)) {
1501
+			return reset($col);
1502
+		} else {
1503 1503
 			return NULL;
1504 1504
 		}
1505 1505
 	}
@@ -1513,19 +1513,19 @@  discard block
 block discarded – undo
1513 1513
 	 * @param array $fields_n_values array keys are field names on this model, and values are what those fields should be updated to in the DB
1514 1514
 	 * @return string of SQL
1515 1515
 	 */
1516
-	function _construct_update_sql($fields_n_values){
1516
+	function _construct_update_sql($fields_n_values) {
1517 1517
 		/** @type WPDB $wpdb */
1518 1518
 		global $wpdb;
1519 1519
 		$cols_n_values = array();
1520
-		foreach($fields_n_values as $field_name => $value){
1520
+		foreach ($fields_n_values as $field_name => $value) {
1521 1521
 			$field_obj = $this->field_settings_for($field_name);
1522 1522
 			//if the value is NULL, we want to assign the value to that.
1523 1523
 			//wpdb->prepare doesn't really handle that properly
1524
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1525
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1524
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1525
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1526 1526
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1527 1527
 		}
1528
-		return implode(",",$cols_n_values);
1528
+		return implode(",", $cols_n_values);
1529 1529
 
1530 1530
 	}
1531 1531
 	
@@ -1537,10 +1537,10 @@  discard block
 block discarded – undo
1537 1537
 	 * @param mixed $id
1538 1538
 	 * @return boolean whether the row got deleted or not
1539 1539
 	 */
1540
-	public function delete_permanently_by_ID( $id ) {
1540
+	public function delete_permanently_by_ID($id) {
1541 1541
 		return $this->delete_permanently( 
1542 1542
 			array(
1543
-				array( $this->get_primary_key_field()->get_name() => $id ),
1543
+				array($this->get_primary_key_field()->get_name() => $id),
1544 1544
 				'limit' 	=> 1
1545 1545
 			) 
1546 1546
 		);
@@ -1554,10 +1554,10 @@  discard block
 block discarded – undo
1554 1554
 	 * @param mixed $id
1555 1555
 	 * @return boolean whether the row got deleted or not
1556 1556
 	 */
1557
-	public function delete_by_ID( $id ){
1557
+	public function delete_by_ID($id) {
1558 1558
 		return $this->delete( 
1559 1559
 			array(
1560
-				array( $this->get_primary_key_field()->get_name() => $id ),
1560
+				array($this->get_primary_key_field()->get_name() => $id),
1561 1561
 				'limit' 	=> 1
1562 1562
 			) 
1563 1563
 		);
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
 	 * @param boolean $allow_blocking
1572 1572
 	 * @return @see EEM_Base::delete_permanently
1573 1573
 	 */
1574
-	function delete($query_params,$allow_blocking = true){
1574
+	function delete($query_params, $allow_blocking = true) {
1575 1575
 		return $this->delete_permanently($query_params, $allow_blocking);
1576 1576
 	}
1577 1577
 
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1588 1588
 	 * @return int how many rows got deleted
1589 1589
 	 */
1590
-	function delete_permanently($query_params,$allow_blocking = true){
1590
+	function delete_permanently($query_params, $allow_blocking = true) {
1591 1591
 		/**
1592 1592
 		 * Action called just before performing a real deletion query. You can use the
1593 1593
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1596,34 +1596,34 @@  discard block
 block discarded – undo
1596 1596
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1597 1597
 		 * to block (prevent) this deletion
1598 1598
 		 */
1599
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1599
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1600 1600
 		//some MySQL databases may be running safe mode, which may restrict
1601 1601
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1602 1602
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1603 1603
 		//to delete them
1604 1604
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1605
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1606
-		if($deletion_where){
1605
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1606
+		if ($deletion_where) {
1607 1607
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1608 1608
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1609 1609
 			$table_aliases = array();
1610
-			foreach(array_keys($this->_tables) as $table_alias){
1610
+			foreach (array_keys($this->_tables) as $table_alias) {
1611 1611
 				$table_aliases[] = $table_alias;
1612 1612
 			}
1613
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1613
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1614 1614
 
1615 1615
 			//		/echo "delete sql:$SQL";
1616
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1617
-		}else{
1616
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1617
+		} else {
1618 1618
 			$rows_deleted = 0;
1619 1619
 		}
1620 1620
 
1621 1621
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1622
-		if( $this->has_primary_key_field() ){
1623
-			foreach($items_for_deletion as $item_for_deletion_row ){
1624
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1625
-				if( isset( $this->_entity_map[ $pk_value ] ) ){
1626
-					unset( $this->_entity_map[ $pk_value ] );
1622
+		if ($this->has_primary_key_field()) {
1623
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1624
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1625
+				if (isset($this->_entity_map[$pk_value])) {
1626
+					unset($this->_entity_map[$pk_value]);
1627 1627
 				}
1628 1628
 			}
1629 1629
 		}
@@ -1635,8 +1635,8 @@  discard block
 block discarded – undo
1635 1635
 		 * @param array $query_params @see EEM_Base::get_all()
1636 1636
 		 * @param int $rows_deleted
1637 1637
 		 */
1638
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1639
-		return $rows_deleted;//how many supposedly got deleted
1638
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1639
+		return $rows_deleted; //how many supposedly got deleted
1640 1640
 	}
1641 1641
 
1642 1642
 
@@ -1652,28 +1652,28 @@  discard block
 block discarded – undo
1652 1652
 	 * blocking its deletion before removing the relation between A and B
1653 1653
 	 * @return boolean
1654 1654
 	 */
1655
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1655
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1656 1656
 		//first, if $ignore_this_model_obj was supplied, get its model
1657
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1657
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1658 1658
 			$ignored_model = $ignore_this_model_obj->get_model();
1659
-		}else{
1659
+		} else {
1660 1660
 			$ignored_model = null;
1661 1661
 		}
1662 1662
 		//now check all the relations of $this_model_obj_or_id and see if there
1663 1663
 		//are any related model objects blocking it?
1664 1664
 		$is_blocked = false;
1665
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1666
-			if( $relation_obj->block_delete_if_related_models_exist()){
1665
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1666
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1667 1667
 				//if $ignore_this_model_obj was supplied, then for the query
1668 1668
 				//on that model needs to be told to ignore $ignore_this_model_obj
1669
-				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1670
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1671
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1672
-				}else{
1669
+				if ($ignored_model && $relation_name == $ignored_model->get_this_model_name()) {
1670
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1671
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1672
+				} else {
1673 1673
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1674 1674
 				}
1675 1675
 
1676
-				if($related_model_objects){
1676
+				if ($related_model_objects) {
1677 1677
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1678 1678
 					$is_blocked = true;
1679 1679
 				}
@@ -1693,65 +1693,65 @@  discard block
 block discarded – undo
1693 1693
 	 * @throws EE_Error
1694 1694
 	 * @return string    everything that comes after the WHERE statement.
1695 1695
 	 */
1696
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1697
-		if($this->has_primary_key_field()){
1696
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1697
+		if ($this->has_primary_key_field()) {
1698 1698
 			$primary_table = $this->_get_main_table();
1699 1699
 			$other_tables = $this->_get_other_tables();
1700 1700
 			$deletes = $query = array();
1701
-			foreach ( $objects_for_deletion as $delete_object ) {
1701
+			foreach ($objects_for_deletion as $delete_object) {
1702 1702
 				//before we mark this object for deletion,
1703 1703
 				//make sure there's no related objects blocking its deletion (if we're checking)
1704
-				if( $allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()]) ){
1704
+				if ($allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1705 1705
 					continue;
1706 1706
 				}
1707 1707
 
1708 1708
 				//primary table deletes
1709
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1709
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()]))
1710 1710
 					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1711 1711
 
1712 1712
 				//other tables
1713
-				if ( !empty( $other_tables ) ) {
1714
-					foreach ( $other_tables as $ot ) {
1713
+				if ( ! empty($other_tables)) {
1714
+					foreach ($other_tables as $ot) {
1715 1715
 
1716 1716
 						//first check if we've got the foreign key column here.
1717
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1717
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()]))
1718 1718
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1719 1719
 
1720 1720
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1721
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1721
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()]))
1722 1722
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1723 1723
 
1724 1724
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1725
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1725
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()]))
1726 1726
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1727 1727
 					}
1728 1728
 				}
1729 1729
 			}
1730 1730
 
1731 1731
 			//we should have deletes now, so let's just go through and setup the where statement
1732
-			foreach ( $deletes as $column => $values ) {
1732
+			foreach ($deletes as $column => $values) {
1733 1733
 				//make sure we have unique $values;
1734 1734
 				$values = array_unique($values);
1735
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1735
+				$query[] = $column.' IN('.implode(",", $values).')';
1736 1736
 			}
1737 1737
 
1738
-			return !empty($query) ? implode(' AND ', $query ) : '';
1739
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1738
+			return ! empty($query) ? implode(' AND ', $query) : '';
1739
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1740 1740
 			$ways_to_identify_a_row = array();
1741 1741
 			$fields = $this->get_combined_primary_key_fields();
1742 1742
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1743
-			foreach($objects_for_deletion as  $delete_object){
1743
+			foreach ($objects_for_deletion as  $delete_object) {
1744 1744
 				$values_for_each_cpk_for_a_row = array();
1745
-				foreach($fields as $cpk_field){
1745
+				foreach ($fields as $cpk_field) {
1746 1746
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1747 1747
 				}
1748
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1748
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1749 1749
 			}
1750
-			return implode(" OR ",$ways_to_identify_a_row);
1751
-		}else{
1750
+			return implode(" OR ", $ways_to_identify_a_row);
1751
+		} else {
1752 1752
 			//so there's no primary key and no combined key...
1753 1753
 			//sorry, can't help you
1754
-			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
1754
+			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this)));
1755 1755
 		}
1756 1756
 	}
1757 1757
 
@@ -1765,21 +1765,21 @@  discard block
 block discarded – undo
1765 1765
 	 * @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;
1766 1766
 	 * @return int
1767 1767
 	 */
1768
-	function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1768
+	function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1769 1769
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1770
-		if($field_to_count){
1770
+		if ($field_to_count) {
1771 1771
 			$field_obj = $this->field_settings_for($field_to_count);
1772 1772
 			$column_to_count = $field_obj->get_qualified_column();
1773
-		}elseif($this->has_primary_key_field ()){
1773
+		}elseif ($this->has_primary_key_field()) {
1774 1774
 			$pk_field_obj = $this->get_primary_key_field();
1775 1775
 			$column_to_count = $pk_field_obj->get_qualified_column();
1776
-		}else{//there's no primary key
1776
+		} else {//there's no primary key
1777 1777
 			$column_to_count = '*';
1778 1778
 		}
1779 1779
 
1780
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1781
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1782
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1780
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1781
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1782
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1783 1783
 	}
1784 1784
 
1785 1785
 	/**
@@ -1789,23 +1789,23 @@  discard block
 block discarded – undo
1789 1789
 	 * @param string $field_to_sum name of field (array key in $_fields array)
1790 1790
 	 * @return float
1791 1791
 	 */
1792
-	function sum($query_params, $field_to_sum = NULL){
1792
+	function sum($query_params, $field_to_sum = NULL) {
1793 1793
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1794 1794
 
1795
-		if($field_to_sum){
1795
+		if ($field_to_sum) {
1796 1796
 			$field_obj = $this->field_settings_for($field_to_sum);
1797 1797
 
1798
-		}else{
1798
+		} else {
1799 1799
 			$field_obj = $this->get_primary_key_field();
1800 1800
 		}
1801 1801
 		$column_to_count = $field_obj->get_qualified_column();
1802 1802
 
1803
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1804
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1805
-		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1806
-			return (float)$return_value;
1807
-		}else{//must be %f
1808
-			return (float)$return_value;
1803
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1804
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1805
+		if ($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s') {
1806
+			return (float) $return_value;
1807
+		} else {//must be %f
1808
+			return (float) $return_value;
1809 1809
 		}
1810 1810
 	}
1811 1811
 
@@ -1820,33 +1820,33 @@  discard block
 block discarded – undo
1820 1820
 	 * @global wpdb $wpdb
1821 1821
 	 * @return mixed
1822 1822
 	 */
1823
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1823
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1824 1824
 		//if we're in maintenance mode level 2, DON'T run any queries
1825 1825
 		//because level 2 indicates the database needs updating and
1826 1826
 		//is probably out of sync with the code
1827
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1827
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1828 1828
 			throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso")));
1829 1829
 		}
1830 1830
 		/** @type WPDB $wpdb */
1831 1831
 		global $wpdb;
1832
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1833
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1832
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1833
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1834 1834
 		}
1835
-		if( WP_DEBUG ){
1835
+		if (WP_DEBUG) {
1836 1836
 			$old_show_errors_value = $wpdb->show_errors;
1837
-			$wpdb->show_errors( FALSE );
1838
-		}
1839
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1840
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1841
-		if( WP_DEBUG ){
1842
-			$wpdb->show_errors( $old_show_errors_value );
1843
-			if( ! empty( $wpdb->last_error ) ){
1844
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1845
-			}elseif( $result === false ){
1846
-				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1837
+			$wpdb->show_errors(FALSE);
1838
+		}
1839
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1840
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1841
+		if (WP_DEBUG) {
1842
+			$wpdb->show_errors($old_show_errors_value);
1843
+			if ( ! empty($wpdb->last_error)) {
1844
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1845
+			}elseif ($result === false) {
1846
+				throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true)));
1847 1847
 			}
1848
-		}elseif( $result === false ) {
1849
-			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1848
+		}elseif ($result === false) {
1849
+			EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
1850 1850
 		}
1851 1851
 		return $result;
1852 1852
 	}
@@ -1862,23 +1862,23 @@  discard block
 block discarded – undo
1862 1862
 	 * @param array $arguments_to_provide
1863 1863
 	 * @return mixed
1864 1864
 	 */
1865
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1865
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1866 1866
 		/** @type WPDB $wpdb */
1867 1867
 		global $wpdb;
1868 1868
 		$wpdb->last_error = null;
1869
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1869
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1870 1870
 		// was there an error running the query?
1871
-		if ( ( $result === false || ! empty( $wpdb->last_error ) ) ) {
1872
-			switch ( EEM_Base::$_db_verification_level ) {
1871
+		if (($result === false || ! empty($wpdb->last_error))) {
1872
+			switch (EEM_Base::$_db_verification_level) {
1873 1873
 
1874 1874
 				case EEM_Base::db_verified_none :
1875 1875
 					// let's double-check core's DB
1876
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1876
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1877 1877
 					break;
1878 1878
 
1879 1879
 				case EEM_Base::db_verified_core :
1880 1880
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1881
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1881
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1882 1882
 					break;
1883 1883
 
1884 1884
 				case EEM_Base::db_verified_addons :
@@ -1886,11 +1886,11 @@  discard block
 block discarded – undo
1886 1886
 					return $result;
1887 1887
 					break;
1888 1888
 			}
1889
-			if ( ! empty( $error_message ) ) {
1890
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1891
-				trigger_error( $error_message );
1889
+			if ( ! empty($error_message)) {
1890
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1891
+				trigger_error($error_message);
1892 1892
 			}
1893
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1893
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1894 1894
 
1895 1895
 		}
1896 1896
 
@@ -1906,18 +1906,18 @@  discard block
 block discarded – undo
1906 1906
 	 * @param array $arguments_to_provide
1907 1907
 	 * @return string
1908 1908
 	 */
1909
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1909
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1910 1910
 		/** @type WPDB $wpdb */
1911 1911
 		global $wpdb;
1912 1912
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
1913 1913
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
1914 1914
 		$error_message = sprintf(
1915
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
1915
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
1916 1916
 			$wpdb->last_error,
1917 1917
 			$wpdb_method,
1918
-			json_encode( $arguments_to_provide )
1918
+			json_encode($arguments_to_provide)
1919 1919
 		);
1920
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
1920
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
1921 1921
 		return $error_message;
1922 1922
 	}
1923 1923
 
@@ -1930,16 +1930,16 @@  discard block
 block discarded – undo
1930 1930
 	 * @param $arguments_to_provide
1931 1931
 	 * @return string
1932 1932
 	 */
1933
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
1933
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
1934 1934
 		/** @type WPDB $wpdb */
1935 1935
 		global $wpdb;
1936 1936
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
1937 1937
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
1938 1938
 		$error_message = sprintf(
1939
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
1939
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
1940 1940
 			$wpdb->last_error,
1941 1941
 			$wpdb_method,
1942
-			json_encode( $arguments_to_provide )
1942
+			json_encode($arguments_to_provide)
1943 1943
 		);
1944 1944
 		EE_System::instance()->initialize_addons();
1945 1945
 		return $error_message;
@@ -1954,7 +1954,7 @@  discard block
 block discarded – undo
1954 1954
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
1955 1955
 	 * @return string
1956 1956
 	 */
1957
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
1957
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
1958 1958
 		return " FROM ".$model_query_info->get_full_join_sql().
1959 1959
 				$model_query_info->get_where_sql().
1960 1960
 				$model_query_info->get_group_by_sql().
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
 	 * Set to easily debug the next X queries ran from this model.
1968 1968
 	 * @param int $count
1969 1969
 	 */
1970
-	function show_next_x_db_queries($count = 1){
1970
+	function show_next_x_db_queries($count = 1) {
1971 1971
 		$this->_show_next_x_db_queries = $count;
1972 1972
 	}
1973 1973
 
@@ -1976,8 +1976,8 @@  discard block
 block discarded – undo
1976 1976
 	/**
1977 1977
 	 * @param $sql_query
1978 1978
 	 */
1979
-	function show_db_query_if_previously_requested($sql_query){
1980
-		if($this->_show_next_x_db_queries > 0){
1979
+	function show_db_query_if_previously_requested($sql_query) {
1980
+		if ($this->_show_next_x_db_queries > 0) {
1981 1981
 			echo $sql_query;
1982 1982
 			$this->_show_next_x_db_queries--;
1983 1983
 		}
@@ -2001,9 +2001,9 @@  discard block
 block discarded – undo
2001 2001
 	 * @param array   $extra_join_model_fields_n_values This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2002 2002
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
2003 2003
 	 */
2004
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
2004
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
2005 2005
 		$relation_obj = $this->related_settings_for($relationName);
2006
-		return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2006
+		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2007 2007
 	}
2008 2008
 
2009 2009
 	/**
@@ -2022,9 +2022,9 @@  discard block
 block discarded – undo
2022 2022
 	 * @return boolean of success
2023 2023
 	 * @param array   $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2024 2024
 	 */
2025
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2025
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
2026 2026
 		$relation_obj = $this->related_settings_for($relationName);
2027
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
2027
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
2028 2028
 	}
2029 2029
 
2030 2030
 
@@ -2037,9 +2037,9 @@  discard block
 block discarded – undo
2037 2037
 	 * @param EE_Base_Class[] objects to which relations were removed
2038 2038
 	 * @return \EE_Base_Class[]
2039 2039
 	 */
2040
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
2040
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2041 2041
 		$relation_obj = $this->related_settings_for($relationName);
2042
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2042
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2043 2043
 	}
2044 2044
 
2045 2045
 
@@ -2052,10 +2052,10 @@  discard block
 block discarded – undo
2052 2052
 	 * @param array $query_params like EEM_Base::get_all
2053 2053
 	 * @return EE_Base_Class[]
2054 2054
 	 */
2055
-	function get_all_related($id_or_obj, $model_name, $query_params = null){
2055
+	function get_all_related($id_or_obj, $model_name, $query_params = null) {
2056 2056
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2057 2057
 		$relation_settings = $this->related_settings_for($model_name);
2058
-		return $relation_settings->get_all_related($model_obj,$query_params);
2058
+		return $relation_settings->get_all_related($model_obj, $query_params);
2059 2059
 	}
2060 2060
 
2061 2061
 	/**
@@ -2068,10 +2068,10 @@  discard block
 block discarded – undo
2068 2068
 	 * @param array $query_params
2069 2069
 	 * @return int how many deleted
2070 2070
 	 */
2071
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2071
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2072 2072
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2073 2073
 		$relation_settings = $this->related_settings_for($model_name);
2074
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2074
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2075 2075
 	}
2076 2076
 
2077 2077
 	/**
@@ -2084,10 +2084,10 @@  discard block
 block discarded – undo
2084 2084
 	 * @param array $query_params
2085 2085
 	 * @return int how many deleted
2086 2086
 	 */
2087
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2087
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2088 2088
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2089 2089
 		$relation_settings = $this->related_settings_for($model_name);
2090
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2090
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2091 2091
 	}
2092 2092
 
2093 2093
 	/**
@@ -2100,17 +2100,17 @@  discard block
 block discarded – undo
2100 2100
 	 * @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;
2101 2101
 	 * @return int
2102 2102
 	 */
2103
-	function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2103
+	function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2104 2104
 		$related_model = $this->get_related_model_obj($model_name);
2105 2105
 		//we're just going to use the query params on the related model's normal get_all query,
2106 2106
 		//except add a condition to say to match the current mod
2107
-		if( ! isset($query_params['default_where_conditions'])){
2108
-			$query_params['default_where_conditions']='none';
2107
+		if ( ! isset($query_params['default_where_conditions'])) {
2108
+			$query_params['default_where_conditions'] = 'none';
2109 2109
 		}
2110 2110
 		$this_model_name = $this->get_this_model_name();
2111 2111
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2112
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2113
-		return $related_model->count($query_params,$field_to_count,$distinct);
2112
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2113
+		return $related_model->count($query_params, $field_to_count, $distinct);
2114 2114
 	}
2115 2115
 
2116 2116
 
@@ -2124,21 +2124,21 @@  discard block
 block discarded – undo
2124 2124
 	 * @param string $field_to_sum name of field to count by. By default, uses primary key
2125 2125
 	 * @return float
2126 2126
 	 */
2127
-	function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2127
+	function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2128 2128
 		$related_model = $this->get_related_model_obj($model_name);
2129
-		if( ! is_array( $query_params ) ){
2130
-			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2129
+		if ( ! is_array($query_params)) {
2130
+			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2131 2131
 			$query_params = array();
2132 2132
 		}
2133 2133
 		//we're just going to use the query params on the related model's normal get_all query,
2134 2134
 		//except add a condition to say to match the current mod
2135
-		if( ! isset($query_params['default_where_conditions'])){
2136
-			$query_params['default_where_conditions']='none';
2135
+		if ( ! isset($query_params['default_where_conditions'])) {
2136
+			$query_params['default_where_conditions'] = 'none';
2137 2137
 		}
2138 2138
 		$this_model_name = $this->get_this_model_name();
2139 2139
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2140
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2141
-		return $related_model->sum($query_params,$field_to_sum);
2140
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2141
+		return $related_model->sum($query_params, $field_to_sum);
2142 2142
 	}
2143 2143
 
2144 2144
 
@@ -2150,12 +2150,12 @@  discard block
 block discarded – undo
2150 2150
 	 * @param array $query_params like EEM_Base::get_all's
2151 2151
 	 * @return EE_Base_Class
2152 2152
 	 */
2153
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2154
-		$query_params['limit']=1;
2155
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2156
-		if( $results ){
2153
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2154
+		$query_params['limit'] = 1;
2155
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2156
+		if ($results) {
2157 2157
 			return array_shift($results);
2158
-		}else{
2158
+		} else {
2159 2159
 			return null;
2160 2160
 		}
2161 2161
 
@@ -2165,8 +2165,8 @@  discard block
 block discarded – undo
2165 2165
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2166 2166
 	 * @return string
2167 2167
 	 */
2168
-	function get_this_model_name(){
2169
-		return str_replace("EEM_","",get_class($this));
2168
+	function get_this_model_name() {
2169
+		return str_replace("EEM_", "", get_class($this));
2170 2170
 	}
2171 2171
 
2172 2172
 	/**
@@ -2174,14 +2174,14 @@  discard block
 block discarded – undo
2174 2174
 	 * @return EE_Any_Foreign_Model_Name_Field
2175 2175
 	 * @throws EE_Error
2176 2176
 	 */
2177
-	public function get_field_containing_related_model_name(){
2178
-		foreach($this->field_settings(true) as $field){
2179
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2177
+	public function get_field_containing_related_model_name() {
2178
+		foreach ($this->field_settings(true) as $field) {
2179
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2180 2180
 				$field_with_model_name = $field;
2181 2181
 			}
2182 2182
 		}
2183
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2184
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2183
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2184
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2185 2185
 		}
2186 2186
 		return $field_with_model_name;
2187 2187
 	}
@@ -2202,19 +2202,19 @@  discard block
 block discarded – undo
2202 2202
 	 * @return int new primary key on main table that got inserted
2203 2203
 	 * @throws EE_Error
2204 2204
 	 */
2205
-	function insert($field_n_values){
2205
+	function insert($field_n_values) {
2206 2206
 		/**
2207 2207
 		 * Filters the fields and their values before inserting an item using the models
2208 2208
 		 * @param array $fields_n_values keys are the fields and values are their new values
2209 2209
 		 * @param EEM_Base $model the model used
2210 2210
 		 */
2211
-		$field_n_values = apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2212
-		if($this->_satisfies_unique_indexes($field_n_values)){
2211
+		$field_n_values = apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2212
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2213 2213
 			$main_table = $this->_get_main_table();
2214 2214
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2215
-			if( $new_id !== false ) {
2216
-				foreach($this->_get_other_tables() as $other_table){
2217
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2215
+			if ($new_id !== false) {
2216
+				foreach ($this->_get_other_tables() as $other_table) {
2217
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2218 2218
 				}
2219 2219
 			}
2220 2220
 			/**
@@ -2224,9 +2224,9 @@  discard block
 block discarded – undo
2224 2224
 			 * @param array $fields_n_values fields and their values
2225 2225
 			 * @param int|string the ID of the newly-inserted model object
2226 2226
 			 */
2227
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2227
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2228 2228
 			return $new_id;
2229
-		}else{
2229
+		} else {
2230 2230
 			return FALSE;
2231 2231
 		}
2232 2232
 	}
@@ -2239,11 +2239,11 @@  discard block
 block discarded – undo
2239 2239
 	 * @param string $action
2240 2240
 	 * @return boolean
2241 2241
 	 */
2242
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2243
-		foreach($this->unique_indexes() as $index_name => $index){
2242
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2243
+		foreach ($this->unique_indexes() as $index_name => $index) {
2244 2244
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2245
-			if($this->exists(array($uniqueness_where_params))){
2246
-				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"),$action,$this->_get_class_name(),$index_name,implode(",",$index->field_names()),http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__ );
2245
+			if ($this->exists(array($uniqueness_where_params))) {
2246
+				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"), $action, $this->_get_class_name(), $index_name, implode(",", $index->field_names()), http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__);
2247 2247
 				return false;
2248 2248
 			}
2249 2249
 		}
@@ -2264,28 +2264,28 @@  discard block
 block discarded – undo
2264 2264
 	 * @throws EE_Error
2265 2265
 	 * @return EE_Base_Class
2266 2266
 	 */
2267
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2268
-		if($obj_or_fields_array instanceof EE_Base_Class){
2267
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2268
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2269 2269
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2270
-		}elseif( is_array($obj_or_fields_array)){
2270
+		}elseif (is_array($obj_or_fields_array)) {
2271 2271
 			$fields_n_values = $obj_or_fields_array;
2272
-		}else{
2273
-			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
2272
+		} else {
2273
+			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"), get_class($this), $obj_or_fields_array));
2274 2274
 		}
2275 2275
 		$query_params = array();
2276
-		if( $this->has_primary_key_field() &&
2277
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2278
-				isset($fields_n_values[$this->primary_key_name()])){
2276
+		if ($this->has_primary_key_field() &&
2277
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2278
+				isset($fields_n_values[$this->primary_key_name()])) {
2279 2279
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2280 2280
 		}
2281
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2281
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2282 2282
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2283 2283
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2284 2284
 		}
2285 2285
 		//if there is nothing to base this search on, then we shouldn't find anything
2286
-		if( empty( $query_params ) ){
2286
+		if (empty($query_params)) {
2287 2287
 			return array();
2288
-		}else{
2288
+		} else {
2289 2289
 			return $this->get_one($query_params);
2290 2290
 		}
2291 2291
 	}
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
 	 * @param array $query_params
2296 2296
 	 * @return boolean
2297 2297
 	 */
2298
-	function exists($query_params){
2298
+	function exists($query_params) {
2299 2299
 		$query_params['limit'] = 1;
2300 2300
 		return $this->count($query_params) > 0;
2301 2301
 	}
@@ -2305,7 +2305,7 @@  discard block
 block discarded – undo
2305 2305
 	 * @param int|string $id
2306 2306
 	 * @return boolean
2307 2307
 	 */
2308
-	function exists_by_ID($id){
2308
+	function exists_by_ID($id) {
2309 2309
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2310 2310
 	}
2311 2311
 
@@ -2325,45 +2325,45 @@  discard block
 block discarded – undo
2325 2325
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2326 2326
 	 * @return int ID of new row inserted, or FALSE on failure
2327 2327
 	 */
2328
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2328
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2329 2329
 		global $wpdb;
2330 2330
 		$insertion_col_n_values = array();
2331 2331
 		$format_for_insertion = array();
2332 2332
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2333
-		foreach($fields_on_table as $field_name => $field_obj){
2333
+		foreach ($fields_on_table as $field_name => $field_obj) {
2334 2334
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2335
-			if($field_obj->is_auto_increment()){
2335
+			if ($field_obj->is_auto_increment()) {
2336 2336
 				continue;
2337 2337
 			}
2338 2338
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2339 2339
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2340
-			if( $prepared_value !== NULL ){
2341
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2340
+			if ($prepared_value !== NULL) {
2341
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2342 2342
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2343 2343
 			}
2344 2344
 		}
2345 2345
 
2346
-		if($table instanceof EE_Secondary_Table && $new_id){
2346
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2347 2347
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2348 2348
 			//so add the fk to the main table as a column
2349 2349
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2350
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2350
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2351 2351
 		}
2352 2352
 		//insert the new entry
2353
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2354
-		if( $result === false ) {
2353
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2354
+		if ($result === false) {
2355 2355
 			return false;
2356 2356
 		}
2357 2357
 		//ok, now what do we return for the ID of the newly-inserted thing?
2358
-		if($this->has_primary_key_field()){
2359
-			if($this->get_primary_key_field()->is_auto_increment()){
2358
+		if ($this->has_primary_key_field()) {
2359
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2360 2360
 				return $wpdb->insert_id;
2361
-			}else{
2361
+			} else {
2362 2362
 				//it's not an auto-increment primary key, so
2363 2363
 				//it must have been supplied
2364 2364
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2365 2365
 			}
2366
-		}else{
2366
+		} else {
2367 2367
 			//we can't return a  primary key because there is none. instead return
2368 2368
 			//a unique string indicating this model
2369 2369
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2378,15 +2378,15 @@  discard block
 block discarded – undo
2378 2378
 	 * @param array $fields_n_values
2379 2379
 	 * @return mixed string|int|float depending on what the table column will be expecting
2380 2380
 	 */
2381
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2381
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2382 2382
 		//if this field doesn't allow nullable, don't allow it
2383
-		if( ! $field_obj->is_nullable() && (
2384
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2385
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2386
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2383
+		if ( ! $field_obj->is_nullable() && (
2384
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2385
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2386
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2387 2387
 		}
2388
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2389
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2388
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2389
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2390 2390
 	}
2391 2391
 
2392 2392
 
@@ -2398,9 +2398,9 @@  discard block
 block discarded – undo
2398 2398
 	 * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection
2399 2399
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2400 2400
 	 */
2401
-	private function _prepare_value_for_use_in_db($value, $field){
2402
-		if($field && $field instanceof EE_Model_Field_Base){
2403
-			switch( $this->_values_already_prepared_by_model_object ){
2401
+	private function _prepare_value_for_use_in_db($value, $field) {
2402
+		if ($field && $field instanceof EE_Model_Field_Base) {
2403
+			switch ($this->_values_already_prepared_by_model_object) {
2404 2404
 				/** @noinspection PhpMissingBreakStatementInspection */
2405 2405
 				case self::not_prepared_by_model_object:
2406 2406
 					$value = $field->prepare_for_set($value);
@@ -2411,7 +2411,7 @@  discard block
 block discarded – undo
2411 2411
 					//leave the value alone
2412 2412
 			}
2413 2413
 			return $value;
2414
-		}else{
2414
+		} else {
2415 2415
 			return $value;
2416 2416
 		}
2417 2417
 	}
@@ -2421,13 +2421,13 @@  discard block
 block discarded – undo
2421 2421
 	 * @return EE_Primary_Table
2422 2422
 	 * @throws EE_Error
2423 2423
 	 */
2424
-	protected function _get_main_table(){
2425
-		foreach($this->_tables as $table){
2426
-			if($table instanceof EE_Primary_Table){
2424
+	protected function _get_main_table() {
2425
+		foreach ($this->_tables as $table) {
2426
+			if ($table instanceof EE_Primary_Table) {
2427 2427
 				return $table;
2428 2428
 			}
2429 2429
 		}
2430
-		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this)));
2430
+		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this)));
2431 2431
 	}
2432 2432
 
2433 2433
 	/**
@@ -2446,7 +2446,7 @@  discard block
 block discarded – undo
2446 2446
 	 */
2447 2447
 	public function second_table() {
2448 2448
 		// grab second table from tables array
2449
-		$second_table = end( $this->_tables );
2449
+		$second_table = end($this->_tables);
2450 2450
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2451 2451
 	}
2452 2452
 
@@ -2459,8 +2459,8 @@  discard block
 block discarded – undo
2459 2459
 	 * @param string $table_alias
2460 2460
 	 * @return EE_Primary_Table | EE_Secondary_Table
2461 2461
 	 */
2462
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2463
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2462
+	public function get_table_obj_by_alias($table_alias = '') {
2463
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2464 2464
 	}
2465 2465
 
2466 2466
 
@@ -2469,10 +2469,10 @@  discard block
 block discarded – undo
2469 2469
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2470 2470
 	 * @return EE_Secondary_Table[]
2471 2471
 	 */
2472
-	protected function _get_other_tables(){
2473
-		$other_tables =array();
2474
-		foreach($this->_tables as $table_alias => $table){
2475
-			if($table instanceof EE_Secondary_Table){
2472
+	protected function _get_other_tables() {
2473
+		$other_tables = array();
2474
+		foreach ($this->_tables as $table_alias => $table) {
2475
+			if ($table instanceof EE_Secondary_Table) {
2476 2476
 				$other_tables[$table_alias] = $table;
2477 2477
 			}
2478 2478
 		}
@@ -2484,7 +2484,7 @@  discard block
 block discarded – undo
2484 2484
 	 * @param string $table_alias, array key in EEM_Base::_tables
2485 2485
 	 * @return EE_Model_Field_Base[]
2486 2486
 	 */
2487
-	function _get_fields_for_table($table_alias){
2487
+	function _get_fields_for_table($table_alias) {
2488 2488
 		return $this->_fields[$table_alias];
2489 2489
 	}
2490 2490
 
@@ -2496,29 +2496,29 @@  discard block
 block discarded – undo
2496 2496
 	 * @param array $query_params like EEM_Base::get_all's $query_parameters['where']
2497 2497
 	 * @return EE_Model_Query_Info_Carrier
2498 2498
 	 */
2499
-	function _extract_related_models_from_query($query_params){
2499
+	function _extract_related_models_from_query($query_params) {
2500 2500
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2501
-		if(array_key_exists(0,$query_params)){
2502
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,0);
2503
-		}
2504
-		if(array_key_exists('group_by', $query_params)){
2505
-			if(is_array($query_params['group_by'])){
2506
-				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2507
-			}elseif( ! empty ( $query_params['group_by'] )){
2508
-				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2501
+		if (array_key_exists(0, $query_params)) {
2502
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2503
+		}
2504
+		if (array_key_exists('group_by', $query_params)) {
2505
+			if (is_array($query_params['group_by'])) {
2506
+				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'], $query_info_carrier, 'group_by');
2507
+			}elseif ( ! empty ($query_params['group_by'])) {
2508
+				$this->_extract_related_model_info_from_query_param($query_params['group_by'], $query_info_carrier, 'group_by');
2509 2509
 			}
2510 2510
 		}
2511
-		if(array_key_exists('having',$query_params)){
2512
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2511
+		if (array_key_exists('having', $query_params)) {
2512
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 'having');
2513 2513
 		}
2514
-		if(array_key_exists('order_by', $query_params)){
2515
-			if ( is_array( $query_params['order_by'] ) )
2516
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2517
-			elseif( ! empty( $query_params['order_by'] ))
2518
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2514
+		if (array_key_exists('order_by', $query_params)) {
2515
+			if (is_array($query_params['order_by']))
2516
+				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_info_carrier, 'order_by');
2517
+			elseif ( ! empty($query_params['order_by']))
2518
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_info_carrier, 'order_by');
2519 2519
 		}
2520
-		if(array_key_exists('force_join', $query_params)){
2521
-			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
2520
+		if (array_key_exists('force_join', $query_params)) {
2521
+			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'], $query_info_carrier, 'force_join');
2522 2522
 		}
2523 2523
 		return $query_info_carrier;
2524 2524
 	}
@@ -2531,34 +2531,34 @@  discard block
 block discarded – undo
2531 2531
 	 * @throws EE_Error
2532 2532
 	 * @return \EE_Model_Query_Info_Carrier
2533 2533
 	 */
2534
-	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2535
-		if (!empty($sub_query_params)){
2534
+	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2535
+		if ( ! empty($sub_query_params)) {
2536 2536
 			$sub_query_params = (array) $sub_query_params;
2537
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2537
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2538 2538
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2539
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2539
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2540 2540
 
2541 2541
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2542 2542
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2543 2543
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2544 2544
 				//of array('Registration.TXN_ID'=>23)
2545 2545
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2546
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2547
-					if (! is_array($possibly_array_of_params)){
2546
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2547
+					if ( ! is_array($possibly_array_of_params)) {
2548 2548
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2549
-							$param,$possibly_array_of_params));
2550
-					}else{
2551
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2549
+							$param, $possibly_array_of_params));
2550
+					} else {
2551
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2552 2552
 					}
2553
-				}elseif($query_param_type === 0 //ie WHERE
2553
+				}elseif ($query_param_type === 0 //ie WHERE
2554 2554
 						&& is_array($possibly_array_of_params)
2555 2555
 						&& isset($possibly_array_of_params[2])
2556
-						&& $possibly_array_of_params[2] == true){
2556
+						&& $possibly_array_of_params[2] == true) {
2557 2557
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2558 2558
 					//indicating that $possible_array_of_params[1] is actually a field name,
2559 2559
 					//from which we should extract query parameters!
2560
-					if(! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])){
2561
-						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params)));
2560
+					if ( ! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])) {
2561
+						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params)));
2562 2562
 					}
2563 2563
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2564 2564
 				}
@@ -2577,14 +2577,14 @@  discard block
 block discarded – undo
2577 2577
 	 * @throws EE_Error
2578 2578
 	 * @return \EE_Model_Query_Info_Carrier
2579 2579
 	 */
2580
-	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2581
-		if (!empty($sub_query_params)){
2582
-			if(!is_array($sub_query_params)){
2583
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2580
+	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2581
+		if ( ! empty($sub_query_params)) {
2582
+			if ( ! is_array($sub_query_params)) {
2583
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2584 2584
 			}
2585
-			foreach($sub_query_params as $param){
2585
+			foreach ($sub_query_params as $param) {
2586 2586
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2587
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2587
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2588 2588
 			}
2589 2589
 		}
2590 2590
 		return $model_query_info_carrier;
@@ -2603,81 +2603,81 @@  discard block
 block discarded – undo
2603 2603
 	 * @throws EE_Error
2604 2604
 	 * @return EE_Model_Query_Info_Carrier
2605 2605
 	 */
2606
-	function _create_model_query_info_carrier($query_params){
2607
-		if( ! is_array( $query_params ) ){
2608
-			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2606
+	function _create_model_query_info_carrier($query_params) {
2607
+		if ( ! is_array($query_params)) {
2608
+			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2609 2609
 			$query_params = array();
2610 2610
 		}
2611
-		if( isset( $query_params[0] ) ) {
2611
+		if (isset($query_params[0])) {
2612 2612
 			$where_query_params = $query_params[0];
2613
-		}else{
2613
+		} else {
2614 2614
 			$where_query_params = array();
2615 2615
 		}
2616 2616
 		//first check if we should alter the query to account for caps or not
2617 2617
 		//because the caps might require us to do extra joins
2618
-		if( isset( $query_params[ 'caps' ] ) && $query_params[ 'caps' ] != 'none' ) {
2619
-			$query_params[0] = $where_query_params = array_replace_recursive( $where_query_params, $this->caps_where_conditions( $query_params[ 'caps' ] ) );
2618
+		if (isset($query_params['caps']) && $query_params['caps'] != 'none') {
2619
+			$query_params[0] = $where_query_params = array_replace_recursive($where_query_params, $this->caps_where_conditions($query_params['caps']));
2620 2620
 		}
2621 2621
 		$query_object = $this->_extract_related_models_from_query($query_params);
2622 2622
 
2623 2623
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2624
-		foreach($where_query_params as $key => $value){
2625
-			if(is_int($key)){
2626
-				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"),$key, var_export( $value, true ), var_export( $query_params, true ), get_class($this)));
2624
+		foreach ($where_query_params as $key => $value) {
2625
+			if (is_int($key)) {
2626
+				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"), $key, var_export($value, true), var_export($query_params, true), get_class($this)));
2627 2627
 			}
2628 2628
 		}
2629
-		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2629
+		if (array_key_exists('default_where_conditions', $query_params) && ! empty($query_params['default_where_conditions'])) {
2630 2630
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2631
-		}else{
2631
+		} else {
2632 2632
 			$use_default_where_conditions = 'all';
2633 2633
 		}
2634
-		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
2635
-		$query_object->set_where_sql( $this->_construct_where_clause($where_query_params));
2634
+		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object, $use_default_where_conditions, $where_query_params), $where_query_params);
2635
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2636 2636
 
2637 2637
 
2638 2638
 		//if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.  So we need to setup a subquery and use that for the main join.  Note for now this only works on the primary table for the model.  So for instance, you could set the limit array like this:
2639 2639
 		//array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2640
-		if ( array_key_exists('on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] )) {
2641
-			$query_object->set_main_model_join_sql( $this->_construct_limit_join_select( $query_params['on_join_limit'][0], $query_params['on_join_limit'][1] ) );
2640
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2641
+			$query_object->set_main_model_join_sql($this->_construct_limit_join_select($query_params['on_join_limit'][0], $query_params['on_join_limit'][1]));
2642 2642
 		}
2643 2643
 
2644 2644
 
2645 2645
 		//set limit
2646
-		if(array_key_exists('limit',$query_params)){
2647
-			if(is_array($query_params['limit'])){
2648
-				if( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])){
2649
-					$e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"),  http_build_query($query_params['limit']));
2646
+		if (array_key_exists('limit', $query_params)) {
2647
+			if (is_array($query_params['limit'])) {
2648
+				if ( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])) {
2649
+					$e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"), http_build_query($query_params['limit']));
2650 2650
 					throw new EE_Error($e."|".$e);
2651 2651
 				}
2652 2652
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2653 2653
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2654
-			}elseif( ! empty ( $query_params['limit'] )){
2654
+			}elseif ( ! empty ($query_params['limit'])) {
2655 2655
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2656 2656
 			}
2657 2657
 		}
2658 2658
 		//set order by
2659
-		if(array_key_exists('order_by',$query_params)){
2660
-			if(is_array($query_params['order_by'])){
2659
+		if (array_key_exists('order_by', $query_params)) {
2660
+			if (is_array($query_params['order_by'])) {
2661 2661
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2662 2662
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2663 2663
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2664
-				if(array_key_exists('order', $query_params)){
2664
+				if (array_key_exists('order', $query_params)) {
2665 2665
 					throw new EE_Error(sprintf(__("In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ", "event_espresso"),
2666
-							get_class($this),implode(", ",array_keys($query_params['order_by'])),implode(", ",$query_params['order_by']),$query_params['order']));
2666
+							get_class($this), implode(", ", array_keys($query_params['order_by'])), implode(", ", $query_params['order_by']), $query_params['order']));
2667 2667
 				}
2668
-				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_object,'order_by');
2668
+				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_object, 'order_by');
2669 2669
 				//assume it's an array of fields to order by
2670 2670
 				$order_array = array();
2671
-				foreach($query_params['order_by'] as $field_name_to_order_by => $order){
2671
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2672 2672
 					$order = $this->_extract_order($order);
2673 2673
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2674 2674
 				}
2675
-				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2676
-			}elseif( ! empty ( $query_params['order_by'] )){
2677
-				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2678
-				if(isset($query_params['order'])){
2675
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2676
+			}elseif ( ! empty ($query_params['order_by'])) {
2677
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_object, 'order', $query_params['order_by']);
2678
+				if (isset($query_params['order'])) {
2679 2679
 					$order = $this->_extract_order($query_params['order']);
2680
-				}else{
2680
+				} else {
2681 2681
 					$order = 'DESC';
2682 2682
 				}
2683 2683
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2685,46 +2685,46 @@  discard block
 block discarded – undo
2685 2685
 		}
2686 2686
 
2687 2687
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2688
-		if( ! array_key_exists('order_by',$query_params) && array_key_exists('order',$query_params) && ! empty( $query_params['order'] )){
2688
+		if ( ! array_key_exists('order_by', $query_params) && array_key_exists('order', $query_params) && ! empty($query_params['order'])) {
2689 2689
 			$pk_field = $this->get_primary_key_field();
2690 2690
 			$order = $this->_extract_order($query_params['order']);
2691 2691
 			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2692 2692
 		}
2693 2693
 
2694 2694
 		//set group by
2695
-		if(array_key_exists('group_by',$query_params)){
2696
-			if(is_array($query_params['group_by'])){
2695
+		if (array_key_exists('group_by', $query_params)) {
2696
+			if (is_array($query_params['group_by'])) {
2697 2697
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2698 2698
 				$group_by_array = array();
2699
-				foreach($query_params['group_by'] as $field_name_to_group_by){
2699
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2700 2700
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2701 2701
 				}
2702
-				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2703
-			}elseif( ! empty ( $query_params['group_by'] )){
2702
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2703
+			}elseif ( ! empty ($query_params['group_by'])) {
2704 2704
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2705 2705
 			}
2706 2706
 		}
2707 2707
 		//set having
2708
-		if(array_key_exists('having',$query_params) && $query_params['having']){
2709
-			$query_object->set_having_sql( $this->_construct_having_clause($query_params['having']));
2708
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2709
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2710 2710
 		}
2711 2711
 
2712 2712
 		//now, just verify they didn't pass anything wack
2713
-		foreach($query_params as $query_key => $query_value){
2714
-			if( ! in_array($query_key,$this->_allowed_query_params,true)){
2713
+		foreach ($query_params as $query_key => $query_value) {
2714
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2715 2715
 				throw new EE_Error(
2716 2716
 					sprintf(
2717
-						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s",'event_espresso'),
2717
+						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s", 'event_espresso'),
2718 2718
 						$query_key,
2719 2719
 						get_class($this),
2720 2720
 //						print_r( $this->_allowed_query_params, TRUE )
2721
-						implode( ', ', $this->_allowed_query_params )
2721
+						implode(', ', $this->_allowed_query_params)
2722 2722
 					)
2723 2723
 				);
2724 2724
 			}
2725 2725
 		}
2726 2726
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2727
-		if ( empty( $main_model_join_sql ) )
2727
+		if (empty($main_model_join_sql))
2728 2728
 			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2729 2729
 		return $query_object;
2730 2730
 	}
@@ -2735,17 +2735,17 @@  discard block
 block discarded – undo
2735 2735
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
2736 2736
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2737 2737
 	 */
2738
-	public function caps_where_conditions( $context = self::caps_read ) {
2739
-		EEM_Base::verify_is_valid_cap_context( $context );
2738
+	public function caps_where_conditions($context = self::caps_read) {
2739
+		EEM_Base::verify_is_valid_cap_context($context);
2740 2740
 		$cap_where_conditions = array();
2741
-		$cap_restrictions = $this->caps_missing( $context );
2741
+		$cap_restrictions = $this->caps_missing($context);
2742 2742
 		/**
2743 2743
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2744 2744
 		 */
2745
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2746
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2745
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2746
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2747 2747
 		}
2748
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2748
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2749 2749
 	}
2750 2750
 
2751 2751
 	/**
@@ -2755,11 +2755,11 @@  discard block
 block discarded – undo
2755 2755
 	 * @return string either ASC, asc, DESC or desc
2756 2756
 	 * @throws EE_Error
2757 2757
 	 */
2758
-	private function _extract_order($should_be_order_string){
2759
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2758
+	private function _extract_order($should_be_order_string) {
2759
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2760 2760
 			return $should_be_order_string;
2761
-		}else{
2762
-			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2761
+		} else {
2762
+			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string));
2763 2763
 		}
2764 2764
 	}
2765 2765
 
@@ -2777,7 +2777,7 @@  discard block
 block discarded – undo
2777 2777
 	 * @throws EE_Error
2778 2778
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
2779 2779
 	 */
2780
-	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){
2780
+	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) {
2781 2781
 		$allowed_used_default_where_conditions_values = array(
2782 2782
 				'all',
2783 2783
 				'this_model_only', 
@@ -2785,19 +2785,19 @@  discard block
 block discarded – undo
2785 2785
 				'minimum',
2786 2786
 				'none'
2787 2787
 			);
2788
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
2789
-			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values)));
2788
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
2789
+			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values)));
2790 2790
 		}
2791
-		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2791
+		if (in_array($use_default_where_conditions, array('all', 'this_model_only'))) {
2792 2792
 			$universal_query_params = $this->_get_default_where_conditions();
2793
-		}elseif( in_array( $use_default_where_conditions, array( 'minimum' ) ) ) {
2793
+		}elseif (in_array($use_default_where_conditions, array('minimum'))) {
2794 2794
 			$universal_query_params = $this->_get_minimum_where_conditions();
2795
-		}else{
2795
+		} else {
2796 2796
 			$universal_query_params = array();
2797 2797
 		}
2798 2798
 
2799
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
2800
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
2799
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
2800
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
2801 2801
 				$related_model = $this->get_related_model_obj($model_name);
2802 2802
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2803 2803
 
@@ -2824,22 +2824,22 @@  discard block
 block discarded – undo
2824 2824
 	 * @param string $model_relation_path like 'Transaction.Payment.'
2825 2825
 	 * @return array like EEM_Base::get_all's $query_params[0]
2826 2826
 	 */
2827
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
2827
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
2828 2828
 		$null_friendly_where_conditions = array();
2829 2829
 		$none_overridden = true;
2830 2830
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
2831 2831
 
2832
-		foreach($default_where_conditions as $key => $val){
2833
-			if( isset($provided_where_conditions[$key])){
2832
+		foreach ($default_where_conditions as $key => $val) {
2833
+			if (isset($provided_where_conditions[$key])) {
2834 2834
 				$none_overridden = false;
2835
-			}else{
2835
+			} else {
2836 2836
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2837 2837
 			}
2838 2838
 		}
2839
-		if( $none_overridden && $default_where_conditions){
2840
-			if($model->has_primary_key_field()){
2839
+		if ($none_overridden && $default_where_conditions) {
2840
+			if ($model->has_primary_key_field()) {
2841 2841
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2842
-			}else{
2842
+			} else {
2843 2843
 				//@todo NO PK, use other defaults
2844 2844
 			}
2845 2845
 		}
@@ -2854,8 +2854,8 @@  discard block
 block discarded – undo
2854 2854
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2855 2855
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2856 2856
 	 */
2857
-	private function _get_default_where_conditions($model_relation_path = null){
2858
-		if ( $this->_ignore_where_strategy )
2857
+	private function _get_default_where_conditions($model_relation_path = null) {
2858
+		if ($this->_ignore_where_strategy)
2859 2859
 			return array();
2860 2860
 
2861 2861
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2869,8 +2869,8 @@  discard block
 block discarded – undo
2869 2869
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2870 2870
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2871 2871
 	 */
2872
-	protected function _get_minimum_where_conditions($model_relation_path = null){
2873
-		if ( $this->_ignore_where_strategy )
2872
+	protected function _get_minimum_where_conditions($model_relation_path = null) {
2873
+		if ($this->_ignore_where_strategy)
2874 2874
 			return array();
2875 2875
 
2876 2876
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2881,13 +2881,13 @@  discard block
 block discarded – undo
2881 2881
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2882 2882
 	 * @return string
2883 2883
 	 */
2884
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
2884
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
2885 2885
 		$selects = $this->_get_columns_to_select_for_this_model();
2886
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
2886
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
2887 2887
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
2888 2888
 			$selects = array_merge($selects, $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain));
2889 2889
 		}
2890
-		return implode(", ",$selects);
2890
+		return implode(", ", $selects);
2891 2891
 	}
2892 2892
 
2893 2893
 	/**
@@ -2896,19 +2896,19 @@  discard block
 block discarded – undo
2896 2896
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
2897 2897
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
2898 2898
 	 */
2899
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
2899
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
2900 2900
 		$fields = $this->field_settings();
2901 2901
 		$selects = array();
2902 2902
 		$table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name());
2903
-		foreach($fields as $field_obj){
2904
-			$selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
2903
+		foreach ($fields as $field_obj) {
2904
+			$selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
2905 2905
 		}
2906 2906
 		//make sure we are also getting the PKs of each table
2907 2907
 		$tables = $this->get_tables();
2908
-		if(count($tables) > 1){
2909
-			foreach($tables as $table_obj){
2910
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
2911
-				if( ! in_array($qualified_pk_column,$selects)){
2908
+		if (count($tables) > 1) {
2909
+			foreach ($tables as $table_obj) {
2910
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
2911
+				if ( ! in_array($qualified_pk_column, $selects)) {
2912 2912
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
2913 2913
 				}
2914 2914
 			}
@@ -2932,66 +2932,66 @@  discard block
 block discarded – undo
2932 2932
 	 * @throws EE_Error
2933 2933
 	 * @return void only modifies the EEM_Related_Model_Info_Carrier passed into it
2934 2934
 	 */
2935
-	private function _extract_related_model_info_from_query_param( $query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL ){
2936
-		if($original_query_param == NULL){
2935
+	private function _extract_related_model_info_from_query_param($query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL) {
2936
+		if ($original_query_param == NULL) {
2937 2937
 			$original_query_param = $query_param;
2938 2938
 		}
2939 2939
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
2940 2940
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
2941
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
2942
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
2941
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
2942
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
2943 2943
 		//check to see if we have a field on this model
2944 2944
 		$this_model_fields = $this->field_settings(true);
2945
-		if(array_key_exists($query_param,$this_model_fields)){
2946
-			if($allow_fields){
2945
+		if (array_key_exists($query_param, $this_model_fields)) {
2946
+			if ($allow_fields) {
2947 2947
 				return;
2948
-			}else{
2948
+			} else {
2949 2949
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
2950
-						$query_param,get_class($this),$query_param_type,$original_query_param));
2950
+						$query_param, get_class($this), $query_param_type, $original_query_param));
2951 2951
 			}
2952 2952
 		}
2953 2953
 		//check if this is a special logic query param
2954
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2955
-			if($allow_logic_query_params){
2954
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
2955
+			if ($allow_logic_query_params) {
2956 2956
 				return;
2957
-			}else{
2957
+			} else {
2958 2958
 				throw new EE_Error(
2959 2959
 					sprintf(
2960
-						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
2961
-						implode( '", "', $this->_logic_query_param_keys ),
2962
-						$query_param ,
2963
-						get_class( $this ),
2960
+						__('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'),
2961
+						implode('", "', $this->_logic_query_param_keys),
2962
+						$query_param,
2963
+						get_class($this),
2964 2964
 						'<br />',
2965
-						"\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param
2965
+						"\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param
2966 2966
 					)
2967 2967
 				);
2968 2968
 			}
2969 2969
 		}
2970 2970
 
2971 2971
 		//check if it's a custom selection
2972
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
2972
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
2973 2973
 			return;
2974 2974
 		}
2975 2975
 
2976 2976
 		//check if has a model name at the beginning
2977 2977
 		//and
2978 2978
 		//check if it's a field on a related model
2979
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
2980
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
2981
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2979
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
2980
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
2981
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2982 2982
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
2983
-				if($query_param == ''){
2983
+				if ($query_param == '') {
2984 2984
 					//nothing left to $query_param
2985 2985
 					//we should actually end in a field name, not a model like this!
2986 2986
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2987
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2988
-				}else{
2987
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
2988
+				} else {
2989 2989
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2990 2990
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2991 2991
 					return;
2992 2992
 				}
2993
-			}elseif($query_param == $valid_related_model_name){
2994
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2993
+			}elseif ($query_param == $valid_related_model_name) {
2994
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2995 2995
 				return;
2996 2996
 			}
2997 2997
 		}
@@ -3001,7 +3001,7 @@  discard block
 block discarded – undo
3001 3001
 		//and we previously confirmed it wasn't a logic query param or field on the current model
3002 3002
 		//it's wack, that's what it is
3003 3003
 		throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"),
3004
-				$query_param,get_class($this),$query_param_type,$original_query_param));
3004
+				$query_param, get_class($this), $query_param_type, $original_query_param));
3005 3005
 
3006 3006
 	}
3007 3007
 
@@ -3018,26 +3018,26 @@  discard block
 block discarded – undo
3018 3018
 	 * what models to prepend onto its default query params or in case it wants to rename tables (in case there are multiple joins to the same table)
3019 3019
 	 * @return void
3020 3020
 	 */
3021
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
3021
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
3022 3022
 		$relation_obj = $this->related_settings_for($model_name);
3023 3023
 
3024 3024
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
3025 3025
 		//check if the relation is HABTM, because then we're essentially doing two joins
3026 3026
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
3027
-		if($relation_obj instanceof EE_HABTM_Relation){
3027
+		if ($relation_obj instanceof EE_HABTM_Relation) {
3028 3028
 			$join_model_obj = $relation_obj->get_join_model();
3029 3029
 			//replace the model specified with the join model for this relation chain, whi
3030 3030
 			$relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain);
3031 3031
 			$new_query_info = new EE_Model_Query_Info_Carrier(
3032 3032
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
3033 3033
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
3034
-			$passed_in_query_info->merge( $new_query_info  );
3034
+			$passed_in_query_info->merge($new_query_info);
3035 3035
 		}
3036 3036
 		//now just join to the other table pointed to by the relation object, and add its data types
3037 3037
 		$new_query_info = new EE_Model_Query_Info_Carrier(
3038 3038
 				array($model_relation_chain=>$model_name),
3039 3039
 				$relation_obj->get_join_statement($model_relation_chain));
3040
-		$passed_in_query_info->merge( $new_query_info  );
3040
+		$passed_in_query_info->merge($new_query_info);
3041 3041
 	}
3042 3042
 
3043 3043
 
@@ -3046,11 +3046,11 @@  discard block
 block discarded – undo
3046 3046
 	 * @param array $where_params like EEM_Base::get_all
3047 3047
 	 * @return string of SQL
3048 3048
 	 */
3049
-	private function _construct_where_clause($where_params){
3049
+	private function _construct_where_clause($where_params) {
3050 3050
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3051
-		if($SQL){
3052
-			return " WHERE ". $SQL;
3053
-		}else{
3051
+		if ($SQL) {
3052
+			return " WHERE ".$SQL;
3053
+		} else {
3054 3054
 			return '';
3055 3055
 		}
3056 3056
 	}
@@ -3061,11 +3061,11 @@  discard block
 block discarded – undo
3061 3061
 	 * @param array $having_params
3062 3062
 	 * @return string
3063 3063
 	 */
3064
-	private function _construct_having_clause($having_params){
3064
+	private function _construct_having_clause($having_params) {
3065 3065
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3066
-		if($SQL){
3067
-			return " HAVING ". $SQL;
3068
-		}else{
3066
+		if ($SQL) {
3067
+			return " HAVING ".$SQL;
3068
+		} else {
3069 3069
 			return '';
3070 3070
 		}
3071 3071
 
@@ -3079,17 +3079,17 @@  discard block
 block discarded – undo
3079 3079
 	 * @return EE_Model_Field_Base
3080 3080
 	 * @throws EE_Error
3081 3081
 	 */
3082
-	protected function _get_field_on_model($field_name,$model_name){
3082
+	protected function _get_field_on_model($field_name, $model_name) {
3083 3083
 		$model_class = 'EEM_'.$model_name;
3084 3084
 		$model_filepath = $model_class.".model.php";
3085
-		EE_Registry::instance()->load_helper( 'File' );
3086
-		if ( is_readable($model_filepath)){
3085
+		EE_Registry::instance()->load_helper('File');
3086
+		if (is_readable($model_filepath)) {
3087 3087
 			require_once($model_filepath);
3088
-			$model_instance=call_user_func($model_name."::instance");
3088
+			$model_instance = call_user_func($model_name."::instance");
3089 3089
 			/* @var $model_instance EEM_Base */
3090 3090
 			return $model_instance->field_settings_for($field_name);
3091
-		}else{
3092
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3091
+		} else {
3092
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3093 3093
 		}
3094 3094
 	}
3095 3095
 
@@ -3102,43 +3102,43 @@  discard block
 block discarded – undo
3102 3102
 	 * @throws EE_Error
3103 3103
 	 * @return string of SQL
3104 3104
 	 */
3105
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3106
-		$where_clauses=array();
3107
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3108
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3109
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3110
-				switch($query_param){
3105
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3106
+		$where_clauses = array();
3107
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3108
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3109
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3110
+				switch ($query_param) {
3111 3111
 					case 'not':
3112 3112
 					case 'NOT':
3113
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3113
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3114 3114
 						break;
3115 3115
 					case 'and':
3116 3116
 					case 'AND':
3117
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3117
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3118 3118
 						break;
3119 3119
 					case 'or':
3120 3120
 					case 'OR':
3121
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3121
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3122 3122
 						break;
3123 3123
 				}
3124
-			}else{
3124
+			} else {
3125 3125
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3126 3126
 
3127 3127
 				//if it's not a normal field, maybe it's a custom selection?
3128
-				if( ! $field_obj){
3129
-					if(isset( $this->_custom_selections[$query_param][1])){
3128
+				if ( ! $field_obj) {
3129
+					if (isset($this->_custom_selections[$query_param][1])) {
3130 3130
 						$field_obj = $this->_custom_selections[$query_param][1];
3131
-					}else{
3132
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3131
+					} else {
3132
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3133 3133
 					}
3134 3134
 				}
3135 3135
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3136
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3136
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3137 3137
 			}
3138 3138
 		}
3139
-		if($where_clauses){
3140
-			$SQL = implode($glue,$where_clauses);
3141
-		}else{
3139
+		if ($where_clauses) {
3140
+			$SQL = implode($glue, $where_clauses);
3141
+		} else {
3142 3142
 			$SQL = '';
3143 3143
 		}
3144 3144
 		return $SQL;
@@ -3152,18 +3152,18 @@  discard block
 block discarded – undo
3152 3152
 	 * @throws EE_Error
3153 3153
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3154 3154
 	 */
3155
-	private function _deduce_column_name_from_query_param($query_param){
3155
+	private function _deduce_column_name_from_query_param($query_param) {
3156 3156
 		$field = $this->_deduce_field_from_query_param($query_param);
3157 3157
 
3158
-		if( $field ){
3159
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3160
-			return $table_alias_prefix . $field->get_qualified_column();
3161
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3158
+		if ($field) {
3159
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3160
+			return $table_alias_prefix.$field->get_qualified_column();
3161
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3162 3162
 			//maybe it's custom selection item?
3163 3163
 			//if so, just use it as the "column name"
3164 3164
 			return $query_param;
3165
-		}else{
3166
-			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3165
+		} else {
3166
+			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections)));
3167 3167
 		}
3168 3168
 	}
3169 3169
 
@@ -3175,11 +3175,11 @@  discard block
 block discarded – undo
3175 3175
 	 * @param string $condition_query_param_key
3176 3176
 	 * @return string
3177 3177
 	 */
3178
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3178
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3179 3179
 		$pos_of_star = strpos($condition_query_param_key, '*');
3180
-		if($pos_of_star === FALSE){
3180
+		if ($pos_of_star === FALSE) {
3181 3181
 			return $condition_query_param_key;
3182
-		}else{
3182
+		} else {
3183 3183
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3184 3184
 			return $condition_query_param_sans_star;
3185 3185
 		}
@@ -3194,54 +3194,54 @@  discard block
 block discarded – undo
3194 3194
 	 * @throws EE_Error
3195 3195
 	 * @return string
3196 3196
 	 */
3197
-	private function _construct_op_and_value($op_and_value, $field_obj){
3198
-		if(is_array( $op_and_value )){
3197
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3198
+		if (is_array($op_and_value)) {
3199 3199
 			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3200
-			if( ! $operator){
3200
+			if ( ! $operator) {
3201 3201
 				$php_array_like_string = array();
3202
-				foreach($op_and_value as $key => $value){
3202
+				foreach ($op_and_value as $key => $value) {
3203 3203
 					$php_array_like_string[] = "$key=>$value";
3204 3204
 				}
3205
-				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string)));
3205
+				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",", $php_array_like_string)));
3206 3206
 			}
3207 3207
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3208
-		}else{
3208
+		} else {
3209 3209
 			$operator = '=';
3210 3210
 			$value = $op_and_value;
3211 3211
 		}
3212 3212
 
3213 3213
 		//check to see if the value is actually another field
3214
-		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
3214
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3215 3215
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3216
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3216
+		}elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3217 3217
 			//in this case, the value should be an array, or at least a comma-separated list
3218 3218
 			//it will need to handle a little differently
3219 3219
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3220 3220
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3221 3221
 			return $operator.SP.$cleaned_value;
3222
-		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3222
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3223 3223
 			//the value should be an array with count of two.
3224
-			if ( count($value) !== 2 )
3225
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3226
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3224
+			if (count($value) !== 2)
3225
+				throw new EE_Error(sprintf(__("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN"));
3226
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3227 3227
 			return $operator.SP.$cleaned_value;
3228
-		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
3229
-			if($value != NULL){
3230
-				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
3228
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3229
+			if ($value != NULL) {
3230
+				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"), $value, $operator));
3231 3231
 			}
3232 3232
 			return $operator;
3233
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
3233
+		}elseif ($operator == 'LIKE' && ! is_array($value)) {
3234 3234
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3235 3235
 			//remove other junk. So just treat it as a string.
3236 3236
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3237
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3238
-			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
3239
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3240
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
3241
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3242
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
3243
-		}else{
3244
-			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
3237
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3238
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3239
+		}elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3240
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))", 'event_espresso'), $operator, $operator));
3241
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3242
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))", 'event_espresso'), $operator, $operator));
3243
+		} else {
3244
+			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value)));
3245 3245
 		}
3246 3246
 	}
3247 3247
 
@@ -3253,12 +3253,12 @@  discard block
 block discarded – undo
3253 3253
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be the datatype to be used when querying, eg '%s'
3254 3254
 	 * @return string
3255 3255
 	 */
3256
-	function _construct_between_value( $values, $field_obj ) {
3256
+	function _construct_between_value($values, $field_obj) {
3257 3257
 		$cleaned_values = array();
3258
-		foreach ( $values as $value ) {
3259
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3258
+		foreach ($values as $value) {
3259
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3260 3260
 		}
3261
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3261
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3262 3262
 	}
3263 3263
 
3264 3264
 
@@ -3274,26 +3274,26 @@  discard block
 block discarded – undo
3274 3274
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be a wpdb data type like '%s', or '%d'
3275 3275
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3276 3276
 	 */
3277
-	function _construct_in_value($values,  $field_obj){
3277
+	function _construct_in_value($values, $field_obj) {
3278 3278
 		//check if the value is a CSV list
3279
-		if(is_string($values)){
3279
+		if (is_string($values)) {
3280 3280
 			//in which case, turn it into an array
3281
-			$values = explode(",",$values);
3281
+			$values = explode(",", $values);
3282 3282
 		}
3283 3283
 		$cleaned_values = array();
3284
-		foreach($values as $value){
3285
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3284
+		foreach ($values as $value) {
3285
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3286 3286
 		}
3287 3287
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3288 3288
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3289 3289
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3290
-		if(empty($cleaned_values)){
3290
+		if (empty($cleaned_values)) {
3291 3291
 			$all_fields = $this->field_settings();
3292 3292
 			$a_field = array_shift($all_fields);
3293 3293
 			$main_table = $this->_get_main_table();
3294 3294
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3295 3295
 		}
3296
-		return "(".implode(",",$cleaned_values).")";
3296
+		return "(".implode(",", $cleaned_values).")";
3297 3297
 	}
3298 3298
 
3299 3299
 
@@ -3305,16 +3305,16 @@  discard block
 block discarded – undo
3305 3305
 	 * @throws EE_Error
3306 3306
 	 * @return false|null|string
3307 3307
 	 */
3308
-	private function _wpdb_prepare_using_field($value,$field_obj){
3308
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3309 3309
 		/** @type WPDB $wpdb */
3310 3310
 		global $wpdb;
3311
-		if($field_obj instanceof EE_Model_Field_Base){
3312
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3313
-		}else{//$field_obj should really just be a data type
3314
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3315
-				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3311
+		if ($field_obj instanceof EE_Model_Field_Base) {
3312
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3313
+		} else {//$field_obj should really just be a data type
3314
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3315
+				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types)));
3316 3316
 			}
3317
-			return $wpdb->prepare($field_obj,$value);
3317
+			return $wpdb->prepare($field_obj, $value);
3318 3318
 		}
3319 3319
 	}
3320 3320
 
@@ -3326,27 +3326,27 @@  discard block
 block discarded – undo
3326 3326
 	 * @throws EE_Error
3327 3327
 	 * @return EE_Model_Field_Base
3328 3328
 	 */
3329
-	protected function _deduce_field_from_query_param($query_param_name){
3329
+	protected function _deduce_field_from_query_param($query_param_name) {
3330 3330
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3331 3331
 		//which will help us find the database table and column
3332 3332
 
3333
-		$query_param_parts = explode(".",$query_param_name);
3334
-		if(empty($query_param_parts)){
3335
-			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name));
3333
+		$query_param_parts = explode(".", $query_param_name);
3334
+		if (empty($query_param_parts)) {
3335
+			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name));
3336 3336
 		}
3337 3337
 		$number_of_parts = count($query_param_parts);
3338
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3339
-		if($number_of_parts == 1){
3338
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3339
+		if ($number_of_parts == 1) {
3340 3340
 			$field_name = $last_query_param_part;
3341 3341
 			$model_obj = $this;
3342
-		}else{// $number_of_parts >= 2
3342
+		} else {// $number_of_parts >= 2
3343 3343
 			//the last part is the column name, and there are only 2parts. therefore...
3344 3344
 			$field_name = $last_query_param_part;
3345
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3345
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3346 3346
 		}
3347
-		try{
3347
+		try {
3348 3348
 			return $model_obj->field_settings_for($field_name);
3349
-		}catch(EE_Error $e){
3349
+		} catch (EE_Error $e) {
3350 3350
 			return null;
3351 3351
 		}
3352 3352
 	}
@@ -3360,13 +3360,13 @@  discard block
 block discarded – undo
3360 3360
 	 * @throws EE_Error
3361 3361
 	 * @return string
3362 3362
 	 */
3363
-	function _get_qualified_column_for_field($field_name){
3363
+	function _get_qualified_column_for_field($field_name) {
3364 3364
 		$all_fields = $this->field_settings();
3365 3365
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3366
-		if($field){
3366
+		if ($field) {
3367 3367
 			return $field->get_qualified_column();
3368
-		}else{
3369
-			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3368
+		} else {
3369
+			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this)));
3370 3370
 		}
3371 3371
 	}
3372 3372
 
@@ -3380,14 +3380,14 @@  discard block
 block discarded – undo
3380 3380
 	 * @param  mixed|string $limit The limit for this select
3381 3381
 	 * @return string 				The final select join element for the query.
3382 3382
 	 */
3383
-	function _construct_limit_join_select( $table_alias, $limit ) {
3383
+	function _construct_limit_join_select($table_alias, $limit) {
3384 3384
 		$SQL = '';
3385 3385
 
3386
-		foreach ( $this->_tables as $table_obj ) {
3387
-			if ( $table_obj instanceof EE_Primary_Table ) {
3388
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit( $limit ) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3389
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3390
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP . $table_obj->get_join_sql( $table_alias ).SP;
3386
+		foreach ($this->_tables as $table_obj) {
3387
+			if ($table_obj instanceof EE_Primary_Table) {
3388
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit($limit) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3389
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3390
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP.$table_obj->get_join_sql($table_alias).SP;
3391 3391
 			}
3392 3392
 		}
3393 3393
 		return $SQL;
@@ -3400,7 +3400,7 @@  discard block
 block discarded – undo
3400 3400
 	 * Eg "wp_post AS Event" or "wp_post AS Event INNER JOIN wp_postmeta Event_Meta ON Event.ID = Event_Meta.post_id"
3401 3401
 	 * @return string SQL
3402 3402
 	 */
3403
-	function _construct_internal_join(){
3403
+	function _construct_internal_join() {
3404 3404
 		$SQL = $this->_get_main_table()->get_table_sql();
3405 3405
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3406 3406
 		return $SQL;
@@ -3421,17 +3421,17 @@  discard block
 block discarded – undo
3421 3421
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3422 3422
 	 * @return string
3423 3423
 	 */
3424
-	function _construct_internal_join_to_table_with_alias($alias_prefixed){
3424
+	function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3425 3425
 		$SQL = '';
3426 3426
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3427
-		foreach($this->_tables as $table_obj){
3428
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3429
-				if($alias_sans_prefix == $table_obj->get_table_alias()){
3427
+		foreach ($this->_tables as $table_obj) {
3428
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3429
+				if ($alias_sans_prefix == $table_obj->get_table_alias()) {
3430 3430
 					//so we're joining to this table, meaning the table is already in
3431 3431
 					//the FROM statement, BUT the primary table isn't. So we want
3432 3432
 					//to add the inverse join sql
3433 3433
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3434
-				}else{
3434
+				} else {
3435 3435
 					//just add a regular JOIN to this table from the primary table
3436 3436
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3437 3437
 				}
@@ -3445,9 +3445,9 @@  discard block
 block discarded – undo
3445 3445
 	 * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc)
3446 3446
 	 * @return array
3447 3447
 	 */
3448
-	function _get_data_types(){
3448
+	function _get_data_types() {
3449 3449
 		$data_types = array();
3450
-		foreach(array_values($this->field_settings()) as $field_obj){
3450
+		foreach (array_values($this->field_settings()) as $field_obj) {
3451 3451
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3452 3452
 			/** @var $field_obj EE_Model_Field_Base */
3453 3453
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3463,11 +3463,11 @@  discard block
 block discarded – undo
3463 3463
 	 * @throws EE_Error
3464 3464
 	 * @return EEM_Base
3465 3465
 	 */
3466
-	function get_related_model_obj($model_name){
3466
+	function get_related_model_obj($model_name) {
3467 3467
 
3468
-		$model_classname = strpos( $model_name, 'EEM_' ) === 0 ? $model_name : 'EEM_' . $model_name;
3469
-		if(!class_exists($model_classname)){
3470
-			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname));
3468
+		$model_classname = strpos($model_name, 'EEM_') === 0 ? $model_name : 'EEM_'.$model_name;
3469
+		if ( ! class_exists($model_classname)) {
3470
+			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname));
3471 3471
 		}
3472 3472
 		$model_obj = call_user_func($model_classname."::instance");
3473 3473
 		return $model_obj;
@@ -3478,7 +3478,7 @@  discard block
 block discarded – undo
3478 3478
 	 * Returns the array of EE_ModelRelations for this model.
3479 3479
 	 * @return EE_Model_Relation_Base[]
3480 3480
 	 */
3481
-	public function relation_settings(){
3481
+	public function relation_settings() {
3482 3482
 		return $this->_model_relations;
3483 3483
 	}
3484 3484
 
@@ -3488,10 +3488,10 @@  discard block
 block discarded – undo
3488 3488
 	 * (Eg, without an event, datetimes have little purpose.)
3489 3489
 	 * @return EE_Belongs_To_Relation[]
3490 3490
 	 */
3491
-	public function belongs_to_relations(){
3491
+	public function belongs_to_relations() {
3492 3492
 		$belongs_to_relations = array();
3493
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3494
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3493
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3494
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3495 3495
 				$belongs_to_relations[$model_name] = $relation_obj;
3496 3496
 			}
3497 3497
 		}
@@ -3506,15 +3506,15 @@  discard block
 block discarded – undo
3506 3506
 	 * @throws EE_Error
3507 3507
 	 * @return EE_Model_Relation_Base
3508 3508
 	 */
3509
-	public function related_settings_for($relation_name){
3510
-		$relatedModels=$this->relation_settings();
3511
-		if(!array_key_exists($relation_name,$relatedModels)){
3509
+	public function related_settings_for($relation_name) {
3510
+		$relatedModels = $this->relation_settings();
3511
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3512 3512
 			throw new EE_Error(
3513 3513
 				sprintf(
3514
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3514
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3515 3515
 					$relation_name,
3516 3516
 					$this->_get_class_name(),
3517
-					implode( ', ', array_keys( $relatedModels ))
3517
+					implode(', ', array_keys($relatedModels))
3518 3518
 				)
3519 3519
 			);
3520 3520
 		}
@@ -3529,10 +3529,10 @@  discard block
 block discarded – undo
3529 3529
 	 * @throws EE_Error
3530 3530
 	 * @return EE_Model_Field_Base
3531 3531
 	 */
3532
-	public function field_settings_for($fieldName){
3533
-		$fieldSettings=$this->field_settings(true);
3534
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3535
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3532
+	public function field_settings_for($fieldName) {
3533
+		$fieldSettings = $this->field_settings(true);
3534
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3535
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3536 3536
 		}
3537 3537
 		return $fieldSettings[$fieldName];
3538 3538
 	}
@@ -3542,11 +3542,11 @@  discard block
 block discarded – undo
3542 3542
 	 * @param string $fieldName a key in the model's _field_settings array
3543 3543
 	 * @return boolean
3544 3544
 	 */
3545
-	public function has_field($fieldName){
3545
+	public function has_field($fieldName) {
3546 3546
 		$fieldSettings = $this->field_settings(true);
3547
-		if( isset($fieldSettings[$fieldName])){
3547
+		if (isset($fieldSettings[$fieldName])) {
3548 3548
 			return true;
3549
-		}else{
3549
+		} else {
3550 3550
 			return false;
3551 3551
 		}
3552 3552
 	}
@@ -3556,11 +3556,11 @@  discard block
 block discarded – undo
3556 3556
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3557 3557
 	 * @return boolean
3558 3558
 	 */
3559
-	public function has_relation($relation_name){
3559
+	public function has_relation($relation_name) {
3560 3560
 		$relations = $this->relation_settings();
3561
-		if(isset($relations[$relation_name])){
3561
+		if (isset($relations[$relation_name])) {
3562 3562
 			return true;
3563
-		}else{
3563
+		} else {
3564 3564
 			return false;
3565 3565
 		}
3566 3566
 	}
@@ -3572,7 +3572,7 @@  discard block
 block discarded – undo
3572 3572
 	 * @param $field_obj
3573 3573
 	 * @return EE_Model_Field_Base
3574 3574
 	 */
3575
-	public function is_primary_key_field( $field_obj ){
3575
+	public function is_primary_key_field($field_obj) {
3576 3576
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3577 3577
 	}
3578 3578
 
@@ -3584,16 +3584,16 @@  discard block
 block discarded – undo
3584 3584
 	 * @return EE_Model_Field_Base
3585 3585
 	 * @throws EE_Error
3586 3586
 	 */
3587
-	public function get_primary_key_field(){
3588
-		if( $this->_primary_key_field === NULL ){
3589
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3590
-				if( $this->is_primary_key_field( $field_obj )){
3587
+	public function get_primary_key_field() {
3588
+		if ($this->_primary_key_field === NULL) {
3589
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3590
+				if ($this->is_primary_key_field($field_obj)) {
3591 3591
 					$this->_primary_key_field = $field_obj;
3592 3592
 					break;
3593 3593
 				}
3594 3594
 			}
3595
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3596
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3595
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3596
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3597 3597
 			}
3598 3598
 		}
3599 3599
 		return $this->_primary_key_field;
@@ -3606,12 +3606,12 @@  discard block
 block discarded – undo
3606 3606
 	 * Internally does some caching.
3607 3607
 	 * @return boolean
3608 3608
 	 */
3609
-	public function has_primary_key_field(){
3610
-		if($this->_has_primary_key_field === null){
3611
-			try{
3609
+	public function has_primary_key_field() {
3610
+		if ($this->_has_primary_key_field === null) {
3611
+			try {
3612 3612
 				$this->get_primary_key_field();
3613 3613
 				$this->_has_primary_key_field = true;
3614
-			}catch(EE_Error $e){
3614
+			} catch (EE_Error $e) {
3615 3615
 				$this->_has_primary_key_field = false;
3616 3616
 			}
3617 3617
 		}
@@ -3625,9 +3625,9 @@  discard block
 block discarded – undo
3625 3625
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3626 3626
 	 * @return EE_Model_Field_Base or null if none is found
3627 3627
 	 */
3628
-	public function get_a_field_of_type($field_class_name){
3629
-		foreach($this->field_settings() as $field){
3630
-			if( $field instanceof $field_class_name ){
3628
+	public function get_a_field_of_type($field_class_name) {
3629
+		foreach ($this->field_settings() as $field) {
3630
+			if ($field instanceof $field_class_name) {
3631 3631
 				return $field;
3632 3632
 			}
3633 3633
 		}
@@ -3641,21 +3641,21 @@  discard block
 block discarded – undo
3641 3641
 	 * @return EE_Foreign_Key_Field_Base
3642 3642
 	 * @throws EE_Error
3643 3643
 	 */
3644
-	public function get_foreign_key_to($model_name){
3645
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3646
-			foreach($this->field_settings() as $field){
3644
+	public function get_foreign_key_to($model_name) {
3645
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3646
+			foreach ($this->field_settings() as $field) {
3647 3647
 //				if(is_subclass_of($field, 'EE_Foreign_Key_Field_Base')){
3648
-				if( $field instanceof EE_Foreign_Key_Field_Base ){
3649
-					if (in_array($model_name,$field->get_model_names_pointed_to() ) ) {
3650
-						$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3648
+				if ($field instanceof EE_Foreign_Key_Field_Base) {
3649
+					if (in_array($model_name, $field->get_model_names_pointed_to())) {
3650
+						$this->_cache_foreign_key_to_fields[$model_name] = $field;
3651 3651
 					}
3652 3652
 				}
3653 3653
 			}
3654
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3655
-				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this)));
3654
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3655
+				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this)));
3656 3656
 			}
3657 3657
 		}
3658
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3658
+		return $this->_cache_foreign_key_to_fields[$model_name];
3659 3659
 	}
3660 3660
 
3661 3661
 
@@ -3666,7 +3666,7 @@  discard block
 block discarded – undo
3666 3666
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3667 3667
 	 * @return EE_Table_Base
3668 3668
 	 */
3669
-	function get_table_for_alias($table_alias){
3669
+	function get_table_for_alias($table_alias) {
3670 3670
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3671 3671
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3672 3672
 	}
@@ -3679,25 +3679,25 @@  discard block
 block discarded – undo
3679 3679
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
3680 3680
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
3681 3681
 	 */
3682
-	public function field_settings($include_db_only_fields = false){
3683
-		if( $include_db_only_fields ){
3684
-			if( $this->_cached_fields === NULL ){
3682
+	public function field_settings($include_db_only_fields = false) {
3683
+		if ($include_db_only_fields) {
3684
+			if ($this->_cached_fields === NULL) {
3685 3685
 				$this->_cached_fields = array();
3686
-				foreach($this->_fields as $fields_corresponding_to_table){
3687
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3688
-						$this->_cached_fields[$field_name]=$field_obj;
3686
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3687
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3688
+						$this->_cached_fields[$field_name] = $field_obj;
3689 3689
 					}
3690 3690
 				}
3691 3691
 			}
3692 3692
 			return $this->_cached_fields;
3693
-		}else{
3694
-			if( $this->_cached_fields_non_db_only === NULL ){
3693
+		} else {
3694
+			if ($this->_cached_fields_non_db_only === NULL) {
3695 3695
 				$this->_cached_fields_non_db_only = array();
3696
-				foreach($this->_fields as $fields_corresponding_to_table){
3697
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3696
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3697
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3698 3698
 						/** @var $field_obj EE_Model_Field_Base */
3699
-						if( ! $field_obj->is_db_only_field() ){
3700
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
3699
+						if ( ! $field_obj->is_db_only_field()) {
3700
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
3701 3701
 						}
3702 3702
 					}
3703 3703
 				}
@@ -3716,67 +3716,67 @@  discard block
 block discarded – undo
3716 3716
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3717 3717
 	 * @throws \EE_Error
3718 3718
 	 */
3719
-	protected function _create_objects( $rows = array() ) {
3720
-		$array_of_objects=array();
3721
-		if(empty($rows)){
3719
+	protected function _create_objects($rows = array()) {
3720
+		$array_of_objects = array();
3721
+		if (empty($rows)) {
3722 3722
 			return array();
3723 3723
 		}
3724 3724
 		$count_if_model_has_no_primary_key = 0;
3725 3725
 		$has_primary_key = $this->has_primary_key_field();
3726
-		if( $has_primary_key ) {
3726
+		if ($has_primary_key) {
3727 3727
 			$primary_key_field = $this->get_primary_key_field();
3728 3728
 		} else {
3729 3729
 			$primary_key_field = null;
3730 3730
 		}
3731
-		foreach ( $rows as $row ) {
3732
-			if(empty($row)){
3731
+		foreach ($rows as $row) {
3732
+			if (empty($row)) {
3733 3733
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3734 3734
 				return array();
3735 3735
 			}
3736 3736
 			//check if we've already set this object in the results array,
3737 3737
 			//in which case there's no need to process it further (again)
3738
-			if( $has_primary_key ) {
3738
+			if ($has_primary_key) {
3739 3739
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
3740 3740
 					$row,
3741 3741
 					$primary_key_field->get_qualified_column(),
3742 3742
 					$primary_key_field->get_table_column()
3743 3743
 				);
3744
-				if( $table_pk_value &&
3745
-					isset( $array_of_objects[ $table_pk_value ] ) ) {
3744
+				if ($table_pk_value &&
3745
+					isset($array_of_objects[$table_pk_value])) {
3746 3746
 					continue;
3747 3747
 				}
3748 3748
 			}
3749
-			$classInstance=$this->instantiate_class_from_array_or_object($row);
3750
-			if( ! $classInstance ) {
3749
+			$classInstance = $this->instantiate_class_from_array_or_object($row);
3750
+			if ( ! $classInstance) {
3751 3751
 				throw new EE_Error(
3752 3752
 					sprintf(
3753
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
3753
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
3754 3754
 						$this->get_this_model_name(),
3755
-						http_build_query( $row )
3755
+						http_build_query($row)
3756 3756
 					)
3757 3757
 				);
3758 3758
 			}
3759 3759
 			//set the timezone on the instantiated objects
3760
-			$classInstance->set_timezone( $this->_timezone );
3760
+			$classInstance->set_timezone($this->_timezone);
3761 3761
 			//make sure if there is any timezone setting present that we set the timezone for the object
3762 3762
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
3763
-			$array_of_objects[ $key ] = $classInstance;
3763
+			$array_of_objects[$key] = $classInstance;
3764 3764
 			//also, for all the relations of type BelongsTo, see if we can cache
3765 3765
 			//those related models
3766 3766
 			//(we could do this for other relations too, but if there are conditions
3767 3767
 			//that filtered out some fo the results, then we'd be caching an incomplete set
3768 3768
 			//so it requires a little more thought than just caching them immediately...)
3769
-			foreach($this->_model_relations as $modelName => $relation_obj){
3770
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
3769
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
3770
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
3771 3771
 					//check if this model's INFO is present. If so, cache it on the model
3772 3772
 					$other_model = $relation_obj->get_other_model();
3773 3773
 
3774 3774
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
3775 3775
 
3776 3776
 					//if we managed to make a model object from the results, cache it on the main model object
3777
-					if( $other_model_obj_maybe ){
3777
+					if ($other_model_obj_maybe) {
3778 3778
 						//set timezone on these other model objects if they are present
3779
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
3779
+						$other_model_obj_maybe->set_timezone($this->_timezone);
3780 3780
 						$classInstance->cache($modelName, $other_model_obj_maybe);
3781 3781
 					}
3782 3782
 				}
@@ -3797,12 +3797,12 @@  discard block
 block discarded – undo
3797 3797
 
3798 3798
 		$this_model_fields_and_values = array();
3799 3799
 		//setup the row using default values;
3800
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
3800
+		foreach ($this->field_settings() as $field_name => $field_obj) {
3801 3801
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
3802 3802
 		}
3803 3803
 
3804 3804
 		$className = $this->_get_class_name();
3805
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
3805
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
3806 3806
 
3807 3807
 		return $classInstance;
3808 3808
 	}
@@ -3815,40 +3815,40 @@  discard block
 block discarded – undo
3815 3815
 	 * or an stdClass where each property is the name of a column,
3816 3816
 	 * @return EE_Base_Class
3817 3817
 	 */
3818
-	public function instantiate_class_from_array_or_object($cols_n_values){
3819
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
3820
-			$cols_n_values = get_object_vars( $cols_n_values );
3818
+	public function instantiate_class_from_array_or_object($cols_n_values) {
3819
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
3820
+			$cols_n_values = get_object_vars($cols_n_values);
3821 3821
 		}
3822 3822
 		$primary_key = NULL;
3823 3823
 		//make sure the array only has keys that are fields/columns on this model
3824
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3825
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
3826
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
3824
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3825
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
3826
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
3827 3827
 		}
3828
-		$className=$this->_get_class_name();
3828
+		$className = $this->_get_class_name();
3829 3829
 
3830 3830
 		//check we actually found results that we can use to build our model object
3831 3831
 		//if not, return null
3832
-		if( $this->has_primary_key_field()){
3833
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3832
+		if ($this->has_primary_key_field()) {
3833
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
3834 3834
 				return NULL;
3835 3835
 			}
3836 3836
 		}
3837 3837
 
3838 3838
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
3839
-		if ( $primary_key){
3840
-			$classInstance = $this->get_from_entity_map( $primary_key );
3841
-			if( ! $classInstance) {
3842
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3839
+		if ($primary_key) {
3840
+			$classInstance = $this->get_from_entity_map($primary_key);
3841
+			if ( ! $classInstance) {
3842
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3843 3843
 				// add this new object to the entity map
3844
-				$classInstance = $this->add_to_entity_map( $classInstance );
3844
+				$classInstance = $this->add_to_entity_map($classInstance);
3845 3845
 			}
3846
-		}else{
3847
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3846
+		} else {
3847
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3848 3848
 		}
3849 3849
 
3850 3850
 			//it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example).  In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property.
3851
-		$this->set_timezone( $classInstance->get_timezone() );
3851
+		$this->set_timezone($classInstance->get_timezone());
3852 3852
 		return $classInstance;
3853 3853
 	}
3854 3854
 	/**
@@ -3856,8 +3856,8 @@  discard block
 block discarded – undo
3856 3856
 	 * @param int|string $id the ID of the model object
3857 3857
 	 * @return EE_Base_Class
3858 3858
 	 */
3859
-	public function get_from_entity_map( $id ){
3860
-		return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL;
3859
+	public function get_from_entity_map($id) {
3860
+		return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL;
3861 3861
 	}
3862 3862
 
3863 3863
 
@@ -3876,21 +3876,21 @@  discard block
 block discarded – undo
3876 3876
 	 * @throws EE_Error
3877 3877
 	 * @return \EE_Base_Class
3878 3878
 	 */
3879
-	public function add_to_entity_map( EE_Base_Class $object) {
3879
+	public function add_to_entity_map(EE_Base_Class $object) {
3880 3880
 		$className = $this->_get_class_name();
3881
-		if( ! $object instanceof $className ){
3882
-			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) );
3881
+		if ( ! $object instanceof $className) {
3882
+			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className));
3883 3883
 		}
3884 3884
 		/** @var $object EE_Base_Class */
3885
-		if ( ! $object->ID() ){
3886
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
3885
+		if ( ! $object->ID()) {
3886
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
3887 3887
 		}
3888 3888
 		// double check it's not already there
3889
-		$classInstance = $this->get_from_entity_map( $object->ID() );
3890
-		if ( $classInstance ) {
3889
+		$classInstance = $this->get_from_entity_map($object->ID());
3890
+		if ($classInstance) {
3891 3891
 			return $classInstance;
3892 3892
 		} else {
3893
-			$this->_entity_map[ $object->ID() ] = $object;
3893
+			$this->_entity_map[$object->ID()] = $object;
3894 3894
 			return $object;
3895 3895
 		}
3896 3896
 	}
@@ -3903,8 +3903,8 @@  discard block
 block discarded – undo
3903 3903
 	 * @param array $cols_n_values
3904 3904
 	 * @return array
3905 3905
 	 */
3906
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
3907
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3906
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3907
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3908 3908
 	}
3909 3909
 
3910 3910
 
@@ -3917,40 +3917,40 @@  discard block
 block discarded – undo
3917 3917
 	 * @param string $cols_n_values
3918 3918
 	 * @return array
3919 3919
 	 */
3920
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
3920
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3921 3921
 		$this_model_fields_n_values = array();
3922
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
3923
-			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() );
3922
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
3923
+			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column());
3924 3924
 			//there is a primary key on this table and its not set. Use defaults for all its columns
3925
-			if( $table_obj->get_pk_column() && $table_pk_value === NULL ){
3926
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3927
-					if( ! $field_obj->is_db_only_field() ){
3925
+			if ($table_obj->get_pk_column() && $table_pk_value === NULL) {
3926
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3927
+					if ( ! $field_obj->is_db_only_field()) {
3928 3928
 						//prepare field as if its coming from db
3929
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
3930
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
3929
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
3930
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
3931 3931
 					}
3932 3932
 				}
3933
-			}else{
3933
+			} else {
3934 3934
 				//the table's rows existed. Use their values
3935
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3936
-					if( ! $field_obj->is_db_only_field() )
3937
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3935
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3936
+					if ( ! $field_obj->is_db_only_field())
3937
+					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column());
3938 3938
 				}
3939 3939
 			}
3940 3940
 		}
3941 3941
 		return $this_model_fields_n_values;
3942 3942
 	}
3943 3943
 
3944
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
3944
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
3945 3945
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
3946 3946
 		//does the field on the model relate to this column retrieved from the db?
3947 3947
 		//or is it a db-only field? (not relating to the model)
3948
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
3949
-			$value = $cols_n_values[ $qualified_column ];
3948
+		if (isset($cols_n_values[$qualified_column])) {
3949
+			$value = $cols_n_values[$qualified_column];
3950 3950
 
3951
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3952
-			$value = $cols_n_values[ $regular_column ];
3953
-		}else{
3951
+		}elseif (isset($cols_n_values[$regular_column])) {
3952
+			$value = $cols_n_values[$regular_column];
3953
+		} else {
3954 3954
 			$value = NULL;
3955 3955
 		}
3956 3956
 
@@ -3968,23 +3968,23 @@  discard block
 block discarded – undo
3968 3968
 	 * @param int|string $id
3969 3969
 	 * @return EE_Base_Class
3970 3970
 	 */
3971
-	public function refresh_entity_map_from_db( $id ){
3972
-		$obj_in_map = $this->get_from_entity_map( $id );
3973
-		if( $obj_in_map ){
3974
-			$wpdb_results = $this->_get_all_wpdb_results( array( array ( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) );
3975
-			if( $wpdb_results && is_array( $wpdb_results ) ){
3976
-				$one_row = reset( $wpdb_results );
3977
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
3978
-					$obj_in_map->set_from_db( $field_name, $db_value );
3971
+	public function refresh_entity_map_from_db($id) {
3972
+		$obj_in_map = $this->get_from_entity_map($id);
3973
+		if ($obj_in_map) {
3974
+			$wpdb_results = $this->_get_all_wpdb_results(array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1));
3975
+			if ($wpdb_results && is_array($wpdb_results)) {
3976
+				$one_row = reset($wpdb_results);
3977
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
3978
+					$obj_in_map->set_from_db($field_name, $db_value);
3979 3979
 				}
3980 3980
 				//clear the cache of related model objects
3981
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3982
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3981
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3982
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3983 3983
 				}
3984 3984
 			}
3985 3985
 			return $obj_in_map;
3986
-		}else{
3987
-			return $this->get_one_by_ID( $id );
3986
+		} else {
3987
+			return $this->get_one_by_ID($id);
3988 3988
 		}
3989 3989
 	}
3990 3990
 
@@ -4002,24 +4002,24 @@  discard block
 block discarded – undo
4002 4002
 	 * @param EE_Base_Class $replacing_model_obj
4003 4003
 	 * @return \EE_Base_Class
4004 4004
 	 */
4005
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
4006
-		$obj_in_map = $this->get_from_entity_map( $id );
4007
-		if( $obj_in_map ){
4008
-			if( $replacing_model_obj instanceof EE_Base_Class ){
4009
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
4010
-					$obj_in_map->set( $field_name, $value );
4005
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
4006
+		$obj_in_map = $this->get_from_entity_map($id);
4007
+		if ($obj_in_map) {
4008
+			if ($replacing_model_obj instanceof EE_Base_Class) {
4009
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
4010
+					$obj_in_map->set($field_name, $value);
4011 4011
 				}
4012 4012
 				//make the model object in the entity map's cache match the $replacing_model_obj
4013
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4014
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4015
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
4016
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
4013
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4014
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4015
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
4016
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
4017 4017
 					}
4018 4018
 				}
4019 4019
 			}
4020 4020
 			return $obj_in_map;
4021
-		}else{
4022
-			$this->add_to_entity_map( $replacing_model_obj );
4021
+		} else {
4022
+			$this->add_to_entity_map($replacing_model_obj);
4023 4023
 			return $replacing_model_obj;
4024 4024
 		}
4025 4025
 	}
@@ -4032,7 +4032,7 @@  discard block
 block discarded – undo
4032 4032
 	 * require_once($this->_getClassName().".class.php");
4033 4033
 	 * @return string
4034 4034
 	 */
4035
-	private function _get_class_name(){
4035
+	private function _get_class_name() {
4036 4036
 		return "EE_".$this->get_this_model_name();
4037 4037
 	}
4038 4038
 
@@ -4045,10 +4045,10 @@  discard block
 block discarded – undo
4045 4045
 	 * @param int $quantity
4046 4046
 	 * @return string
4047 4047
 	 */
4048
-	public function item_name($quantity = 1){
4049
-		if($quantity == 1){
4048
+	public function item_name($quantity = 1) {
4049
+		if ($quantity == 1) {
4050 4050
 			return $this->singular_item;
4051
-		}else{
4051
+		} else {
4052 4052
 			return $this->plural_item;
4053 4053
 		}
4054 4054
 	}
@@ -4077,13 +4077,13 @@  discard block
 block discarded – undo
4077 4077
 	 * @throws EE_Error
4078 4078
 	 * @return mixed whatever the plugin which calls add_filter decides
4079 4079
 	 */
4080
-	public function __call($methodName,$args){
4081
-		$className=get_class($this);
4082
-		$tagName="FHEE__{$className}__{$methodName}";
4083
-		if(!has_filter($tagName)){
4080
+	public function __call($methodName, $args) {
4081
+		$className = get_class($this);
4082
+		$tagName = "FHEE__{$className}__{$methodName}";
4083
+		if ( ! has_filter($tagName)) {
4084 4084
 			throw new EE_Error(
4085 4085
 				sprintf(
4086
-					__( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ),
4086
+					__('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'),
4087 4087
 					$methodName,
4088 4088
 					$className,
4089 4089
 					$tagName,
@@ -4092,7 +4092,7 @@  discard block
 block discarded – undo
4092 4092
 			);
4093 4093
 		}
4094 4094
 
4095
-		return apply_filters($tagName,null,$this,$args);
4095
+		return apply_filters($tagName, null, $this, $args);
4096 4096
 	}
4097 4097
 
4098 4098
 
@@ -4105,22 +4105,22 @@  discard block
 block discarded – undo
4105 4105
 	 * @throws EE_Error
4106 4106
 	 * @return EE_Base_Class
4107 4107
 	 */
4108
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4108
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4109 4109
 		$className = $this->_get_class_name();
4110 4110
 		$primary_key_field = $this->get_primary_key_field();
4111
-		if( $base_class_obj_or_id instanceof $className ){
4111
+		if ($base_class_obj_or_id instanceof $className) {
4112 4112
 			$model_object = $base_class_obj_or_id;
4113
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4114
-				is_int( $base_class_obj_or_id ) ||
4115
-				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4113
+		}elseif ($primary_key_field instanceof EE_Primary_Key_Int_Field && (
4114
+				is_int($base_class_obj_or_id) ||
4115
+				is_string($base_class_obj_or_id) )) {//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4116 4116
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4117
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4117
+		}elseif ($primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id)) {
4118 4118
 			//assume its a string representation of the object
4119 4119
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4120
-		}else{
4121
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4120
+		} else {
4121
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4122 4122
 		}
4123
-		if( $model_object->ID() == NULL && $ensure_is_in_db){
4123
+		if ($model_object->ID() == NULL && $ensure_is_in_db) {
4124 4124
 			$model_object->save();
4125 4125
 		}
4126 4126
 		return $model_object;
@@ -4136,19 +4136,19 @@  discard block
 block discarded – undo
4136 4136
 	 * @return int|string depending on the type of this model object's ID
4137 4137
 	 * @throws EE_Error
4138 4138
 	 */
4139
-	public function ensure_is_ID($base_class_obj_or_id){
4139
+	public function ensure_is_ID($base_class_obj_or_id) {
4140 4140
 		$className = $this->_get_class_name();
4141
-		if( $base_class_obj_or_id instanceof $className ){
4141
+		if ($base_class_obj_or_id instanceof $className) {
4142 4142
 			/** @var $base_class_obj_or_id EE_Base_Class */
4143 4143
 			$id = $base_class_obj_or_id->ID();
4144
-		}elseif(is_int($base_class_obj_or_id)){
4144
+		}elseif (is_int($base_class_obj_or_id)) {
4145 4145
 			//assume it's an ID
4146 4146
 			$id = $base_class_obj_or_id;
4147
-		}elseif(is_string($base_class_obj_or_id)){
4147
+		}elseif (is_string($base_class_obj_or_id)) {
4148 4148
 			//assume its a string representation of the object
4149 4149
 			$id = $base_class_obj_or_id;
4150
-		}else{
4151
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4150
+		} else {
4151
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4152 4152
 		}
4153 4153
 		return $id;
4154 4154
 	}
@@ -4171,14 +4171,14 @@  discard block
 block discarded – undo
4171 4171
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4172 4172
 	 * @return void
4173 4173
 	 */
4174
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4174
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4175 4175
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4176 4176
 	}
4177 4177
 	/**
4178 4178
 	 * Read comments for assume_values_already_prepared_by_model_object()
4179 4179
 	 * @return int
4180 4180
 	 */
4181
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4181
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4182 4182
 		return $this->_values_already_prepared_by_model_object;
4183 4183
 	}
4184 4184
 
@@ -4186,17 +4186,17 @@  discard block
 block discarded – undo
4186 4186
 	 * Gets all the indexes on this model
4187 4187
 	 * @return EE_Index[]
4188 4188
 	 */
4189
-	public function indexes(){
4189
+	public function indexes() {
4190 4190
 		return $this->_indexes;
4191 4191
 	}
4192 4192
 	/**
4193 4193
 	 * Gets all the Unique Indexes on this model
4194 4194
 	 * @return EE_Unique_Index[]
4195 4195
 	 */
4196
-	public function unique_indexes(){
4196
+	public function unique_indexes() {
4197 4197
 		$unique_indexes = array();
4198
-		foreach($this->_indexes as $name => $index){
4199
-			if($index instanceof EE_Unique_Index){
4198
+		foreach ($this->_indexes as $name => $index) {
4199
+			if ($index instanceof EE_Unique_Index) {
4200 4200
 				$unique_indexes [$name] = $index;
4201 4201
 			}
4202 4202
 		}
@@ -4209,9 +4209,9 @@  discard block
 block discarded – undo
4209 4209
 	 * on a primary index
4210 4210
 	 * @return EE_Model_Field_Base[]
4211 4211
 	 */
4212
-	public function get_combined_primary_key_fields(){
4213
-		foreach($this->indexes() as $index){
4214
-			if($index instanceof EE_Primary_Key_Index){
4212
+	public function get_combined_primary_key_fields() {
4213
+		foreach ($this->indexes() as $index) {
4214
+			if ($index instanceof EE_Primary_Key_Index) {
4215 4215
 				return $index->fields();
4216 4216
 			}
4217 4217
 		}
@@ -4224,7 +4224,7 @@  discard block
 block discarded – undo
4224 4224
 	 * @param array $cols_n_values keys are field names, values are their values
4225 4225
 	 * @return string
4226 4226
 	 */
4227
-	public function get_index_primary_key_string($cols_n_values){
4227
+	public function get_index_primary_key_string($cols_n_values) {
4228 4228
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4229 4229
 		return http_build_query($cols_n_values_for_primary_key_index);
4230 4230
 	}
@@ -4236,13 +4236,13 @@  discard block
 block discarded – undo
4236 4236
 	 * @param string $index_primary_key_string
4237 4237
 	 * @return null|array
4238 4238
 	 */
4239
-	function parse_index_primary_key_string( $index_primary_key_string) {
4239
+	function parse_index_primary_key_string($index_primary_key_string) {
4240 4240
 		$key_fields = $this->get_combined_primary_key_fields();
4241 4241
 		//check all of them are in the $id
4242 4242
 		$key_vals_in_combined_pk = array();
4243
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4244
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4245
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4243
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4244
+		foreach ($key_fields as $key_field_name => $field_obj) {
4245
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4246 4246
 				return NULL;
4247 4247
 			}
4248 4248
 		}
@@ -4255,10 +4255,10 @@  discard block
 block discarded – undo
4255 4255
 	 * @param array $key_vals
4256 4256
 	 * @return boolean
4257 4257
 	 */
4258
-	function has_all_combined_primary_key_fields( $key_vals ) {
4259
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4260
-		foreach( $keys_it_should_have as $key ){
4261
-			if( ! isset( $key_vals[ $key ] ) ){
4258
+	function has_all_combined_primary_key_fields($key_vals) {
4259
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4260
+		foreach ($keys_it_should_have as $key) {
4261
+			if ( ! isset($key_vals[$key])) {
4262 4262
 				return false;
4263 4263
 			}
4264 4264
 		}
@@ -4274,23 +4274,23 @@  discard block
 block discarded – undo
4274 4274
 	 * @throws EE_Error
4275 4275
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4276 4276
 	 */
4277
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4277
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4278 4278
 
4279
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4279
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4280 4280
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4281
-		}elseif(is_array($model_object_or_attributes_array)){
4281
+		}elseif (is_array($model_object_or_attributes_array)) {
4282 4282
 			$attributes_array = $model_object_or_attributes_array;
4283
-		}else{
4284
-			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4283
+		} else {
4284
+			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array));
4285 4285
 		}
4286 4286
 		//even copies obviously won't have the same ID, so remove the primary key
4287 4287
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4288
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4288
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4289 4289
 			unset($attributes_array[$this->primary_key_name()]);
4290 4290
 		}
4291
-		if(isset($query_params[0])){
4292
-			$query_params[0] = array_merge($attributes_array,$query_params);
4293
-		}else{
4291
+		if (isset($query_params[0])) {
4292
+			$query_params[0] = array_merge($attributes_array, $query_params);
4293
+		} else {
4294 4294
 			$query_params[0] = $attributes_array;
4295 4295
 		}
4296 4296
 		return $this->get_all($query_params);
@@ -4304,16 +4304,16 @@  discard block
 block discarded – undo
4304 4304
 	 * @param array $query_params
4305 4305
 	 * @return EE_Base_Class
4306 4306
 	 */
4307
-	function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4308
-		if( ! is_array( $query_params ) ){
4309
-			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
4307
+	function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4308
+		if ( ! is_array($query_params)) {
4309
+			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
4310 4310
 			$query_params = array();
4311 4311
 		}
4312 4312
 		$query_params['limit'] = 1;
4313
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4314
-		if(is_array($copies)){
4313
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4314
+		if (is_array($copies)) {
4315 4315
 			return array_shift($copies);
4316
-		}else{
4316
+		} else {
4317 4317
 			return null;
4318 4318
 		}
4319 4319
 	}
@@ -4327,10 +4327,10 @@  discard block
 block discarded – undo
4327 4327
 	 * @param int|string $id the value of the primary key to update
4328 4328
 	 * @return int number of rows updated
4329 4329
 	 */
4330
-	public function update_by_ID($fields_n_values,$id){
4330
+	public function update_by_ID($fields_n_values, $id) {
4331 4331
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4332 4332
 			'default_where_conditions'=>'other_models_only',);
4333
-		return $this->update($fields_n_values,$query_params);
4333
+		return $this->update($fields_n_values, $query_params);
4334 4334
 	}
4335 4335
 
4336 4336
 
@@ -4341,12 +4341,12 @@  discard block
 block discarded – undo
4341 4341
 	 * @return string an operator which can be used in SQL
4342 4342
 	 * @throws EE_Error
4343 4343
 	 */
4344
-	private function _prepare_operator_for_sql($operator_supplied){
4344
+	private function _prepare_operator_for_sql($operator_supplied) {
4345 4345
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4346
-		if($sql_operator){
4346
+		if ($sql_operator) {
4347 4347
 			return $sql_operator;
4348
-		}else{
4349
-			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4348
+		} else {
4349
+			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators))));
4350 4350
 		}
4351 4351
 	}
4352 4352
 
@@ -4356,10 +4356,10 @@  discard block
 block discarded – undo
4356 4356
 	 * @param array $query_params like get_all's
4357 4357
 	 * @return string[]
4358 4358
 	 */
4359
-	public function get_all_names($query_params = array()){
4359
+	public function get_all_names($query_params = array()) {
4360 4360
 		$objs = $this->get_all($query_params);
4361 4361
 		$names = array();
4362
-		foreach($objs as $obj){
4362
+		foreach ($objs as $obj) {
4363 4363
 			$names[$obj->ID()] = $obj->name();
4364 4364
 		}
4365 4365
 		return $names;
@@ -4374,22 +4374,22 @@  discard block
 block discarded – undo
4374 4374
 	 * @param boolean $filter_out_empty_ids if a model object has an ID of '' or 0, don't bother including it in the returned array
4375 4375
 	 * @return array
4376 4376
 	 */
4377
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4378
-		if( ! $this->has_primary_key_field() ) {
4379
-			if( WP_DEBUG ) {
4380
-				EE_Error::add_error( __( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
4377
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4378
+		if ( ! $this->has_primary_key_field()) {
4379
+			if (WP_DEBUG) {
4380
+				EE_Error::add_error(__('Trying to get IDs from a model than has no primary key', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
4381 4381
 				return array();
4382 4382
 			}
4383 4383
 		}
4384 4384
 		$IDs = array();
4385
-		foreach( $model_objects as $model_object ) {
4385
+		foreach ($model_objects as $model_object) {
4386 4386
 			$id = $model_object->ID();
4387
-			if( ! $id ) {
4388
-				if( $filter_out_empty_ids ) {
4387
+			if ( ! $id) {
4388
+				if ($filter_out_empty_ids) {
4389 4389
 					continue;
4390 4390
 				}
4391
-				if( WP_DEBUG ) {
4392
-					EE_Error::add_error(__( 'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
4391
+				if (WP_DEBUG) {
4392
+					EE_Error::add_error(__('Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
4393 4393
 				}
4394 4394
 			}
4395 4395
 			$IDs[] = $id;
@@ -4402,8 +4402,8 @@  discard block
 block discarded – undo
4402 4402
 	 * are no capabilities that relate to this model returns false
4403 4403
 	 * @return string|false
4404 4404
 	 */
4405
-	public function cap_slug(){
4406
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4405
+	public function cap_slug() {
4406
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4407 4407
 	}
4408 4408
 
4409 4409
 	/**
@@ -4415,27 +4415,27 @@  discard block
 block discarded – undo
4415 4415
 	 * @param string $context
4416 4416
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4417 4417
 	 */
4418
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4419
-		EEM_Base::verify_is_valid_cap_context( $context );
4418
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4419
+		EEM_Base::verify_is_valid_cap_context($context);
4420 4420
 		//check if we ought to run the restriction generator first
4421
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
4422
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base &&
4423
-				! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions() ) {
4424
-			$this->_cap_restrictions[ $context ] = array_merge( $this->_cap_restrictions[ $context ],  $this->_cap_restriction_generators[ $context ]->generate_restrictions() );
4421
+		if (isset($this->_cap_restriction_generators[$context]) &&
4422
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base &&
4423
+				! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()) {
4424
+			$this->_cap_restrictions[$context] = array_merge($this->_cap_restrictions[$context], $this->_cap_restriction_generators[$context]->generate_restrictions());
4425 4425
 		}
4426 4426
 		//and make sure we've finalized the construction of each restriction
4427
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4428
-			$where_conditions_obj->_finalize_construct( $this );
4427
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4428
+			$where_conditions_obj->_finalize_construct($this);
4429 4429
 		}
4430 4430
 
4431
-		return $this->_cap_restrictions[ $context ];
4431
+		return $this->_cap_restrictions[$context];
4432 4432
 	}
4433 4433
 
4434 4434
 	/**
4435 4435
 	 * Indicating whether or not this model thinks its a wp core model
4436 4436
 	 * @return boolean
4437 4437
 	 */
4438
-	public function is_wp_core_model(){
4438
+	public function is_wp_core_model() {
4439 4439
 		return $this->_wp_core_model;
4440 4440
 	}
4441 4441
 
@@ -4445,12 +4445,12 @@  discard block
 block discarded – undo
4445 4445
 	 * @param string $context one of EEM_Base::caps_ constants
4446 4446
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4447 4447
 	 */
4448
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4448
+	public function caps_missing($context = EEM_Base::caps_read) {
4449 4449
 		$missing_caps = array();
4450
-		$cap_restrictions = $this->cap_restrictions( $context );
4451
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4452
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4453
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4450
+		$cap_restrictions = $this->cap_restrictions($context);
4451
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4452
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4453
+				$missing_caps[$cap] = $restriction_if_no_cap;
4454 4454
 			}
4455 4455
 		}
4456 4456
 		return $missing_caps;
@@ -4462,7 +4462,7 @@  discard block
 block discarded – undo
4462 4462
 	 * one of 'read', 'edit', or 'delete'
4463 4463
 	 */
4464 4464
 	public function cap_contexts_to_cap_action_map() {
4465
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4465
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4466 4466
 	}
4467 4467
 
4468 4468
 
@@ -4473,19 +4473,19 @@  discard block
 block discarded – undo
4473 4473
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4474 4474
 	 * @throws \EE_Error
4475 4475
 	 */
4476
-	public function cap_action_for_context( $context ) {
4476
+	public function cap_action_for_context($context) {
4477 4477
 		$mapping = $this->cap_contexts_to_cap_action_map();
4478
-		if( isset( $mapping[ $context ] ) ) {
4479
-			return $mapping[ $context ];
4478
+		if (isset($mapping[$context])) {
4479
+			return $mapping[$context];
4480 4480
 		}
4481
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4481
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4482 4482
 			return $action;
4483 4483
 		}
4484 4484
 		throw new EE_Error(
4485 4485
 			sprintf(
4486
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4486
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4487 4487
 				$context,
4488
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4488
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4489 4489
 			)
4490 4490
 		);
4491 4491
 
@@ -4496,7 +4496,7 @@  discard block
 block discarded – undo
4496 4496
 	 * @return array
4497 4497
 	 */
4498 4498
 	static public function valid_cap_contexts() {
4499
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4499
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4500 4500
 			self::caps_read,
4501 4501
 			self::caps_read_admin,
4502 4502
 			self::caps_edit,
@@ -4512,17 +4512,17 @@  discard block
 block discarded – undo
4512 4512
 	 * @return bool
4513 4513
 	 * @throws \EE_Error
4514 4514
 	 */
4515
-	static public function verify_is_valid_cap_context( $context ) {
4515
+	static public function verify_is_valid_cap_context($context) {
4516 4516
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4517
-		if( in_array( $context, $valid_cap_contexts ) ) {
4517
+		if (in_array($context, $valid_cap_contexts)) {
4518 4518
 			return true;
4519
-		}else{
4519
+		} else {
4520 4520
 			throw new EE_Error(
4521 4521
 				sprintf(
4522
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4522
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4523 4523
 					$context,
4524
-					'EEM_Base' ,
4525
-					implode(',', $valid_cap_contexts )
4524
+					'EEM_Base',
4525
+					implode(',', $valid_cap_contexts)
4526 4526
 				)
4527 4527
 			);
4528 4528
 		}
Please login to merge, or discard this patch.
Braces   +131 added lines, -120 removed lines patch added patch discarded remove patch
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
541 541
 				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
542 542
 			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
543
-		}else{
543
+		} else{
544 544
 			return array();
545 545
 		}
546 546
 }
@@ -591,8 +591,9 @@  discard block
 block discarded – undo
591 591
 	 * @return array
592 592
 	 */
593 593
 	 public function status_array( $translated = FALSE ) {
594
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
595
-	 		return array();
594
+	 	if ( !array_key_exists('Status', $this->_model_relations ) ) {
595
+	 		 		return array();
596
+	 	}
596 597
 	 	$model_name = $this->get_this_model_name();
597 598
 	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
598 599
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
@@ -771,13 +772,13 @@  discard block
 block discarded – undo
771 772
 				$last_model_name = end( $models_to_follow_to_wp_users );
772 773
 				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
773 774
 				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
774
-			}else{
775
+			} else{
775 776
 				$model_with_fk_to_wp_users = $this;
776 777
 				$model_chain_to_wp_user = '';
777 778
 			}
778 779
 			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
779 780
 			return $model_chain_to_wp_user . $wp_user_field->get_name();
780
-		}catch( EE_Error $e ) {
781
+		} catch( EE_Error $e ) {
781 782
 			return false;
782 783
 		}
783 784
 	}
@@ -805,11 +806,11 @@  discard block
 block discarded – undo
805 806
 	public function is_owned() {
806 807
 		if( $this->model_chain_to_wp_user() ){
807 808
 			return true;
808
-		}else{
809
+		} else{
809 810
 			try{
810 811
 				$this->get_foreign_key_to( 'WP_User' );
811 812
 				return true;
812
-			}catch( EE_Error $e ){
813
+			} catch( EE_Error $e ){
813 814
 				return false;
814 815
 			}
815 816
 		}
@@ -832,9 +833,9 @@  discard block
 block discarded – undo
832 833
 		//remember the custom selections, if any
833 834
 		if(is_array($columns_to_select)){
834 835
 			$this->_custom_selections = $columns_to_select;
835
-		}elseif(is_string($columns_to_select)){
836
+		} elseif(is_string($columns_to_select)){
836 837
 			$this->_custom_selections = array($this->_custom_selections);
837
-		}else{
838
+		} else{
838 839
 			$this->_custom_selections = array();
839 840
 		}
840 841
 
@@ -906,7 +907,7 @@  discard block
 block discarded – undo
906 907
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
907 908
 			}
908 909
 			$columns_to_select_string = implode(", ",$select_sql_array);
909
-		}else{
910
+		} else{
910 911
 			$columns_to_select_string = $columns_to_select;
911 912
 		}
912 913
 		return $columns_to_select_string;
@@ -956,7 +957,7 @@  discard block
 block discarded – undo
956 957
 		}
957 958
 		if( $this->has_primary_key_field ( ) ) {
958 959
 			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
959
-		}else{
960
+		} else{
960 961
 			//no primary key, so the $id must be from the get_index_primary_key_string()
961 962
 			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
962 963
 		}
@@ -979,7 +980,7 @@  discard block
 block discarded – undo
979 980
 		$items = $this->get_all($query_params);
980 981
 		if(empty($items)){
981 982
 			return null;
982
-		}else{
983
+		} else{
983 984
 			return array_shift($items);
984 985
 		}
985 986
 	}
@@ -1374,7 +1375,7 @@  discard block
 block discarded – undo
1374 1375
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1375 1376
 				if( $this->has_primary_key_field() ){
1376 1377
 					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1377
-				}else{
1378
+				} else{
1378 1379
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1379 1380
 					$main_table_pk_value = null;
1380 1381
 				}
@@ -1413,7 +1414,7 @@  discard block
 block discarded – undo
1413 1414
 		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1414 1415
 			if( $this->has_primary_key_field() ){
1415 1416
 				$model_objs_affected_ids = $this->get_col( $query_params );
1416
-			}else{
1417
+			} else{
1417 1418
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1418 1419
 				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1419 1420
 				$model_objs_affected_ids = array();
@@ -1473,9 +1474,9 @@  discard block
 block discarded – undo
1473 1474
 
1474 1475
 		if( $field_to_select ){
1475 1476
 			$field = $this->field_settings_for( $field_to_select );
1476
-		}elseif( $this->has_primary_key_field ( ) ){
1477
+		} elseif( $this->has_primary_key_field ( ) ){
1477 1478
 			$field = $this->get_primary_key_field();
1478
-		}else{
1479
+		} else{
1479 1480
 			//no primary key, just grab the first column
1480 1481
 			$field = reset( $this->field_settings());
1481 1482
 		}
@@ -1499,7 +1500,7 @@  discard block
 block discarded – undo
1499 1500
 		$col = $this->get_col( $query_params, $field_to_select );
1500 1501
 		if( ! empty( $col ) ) {
1501 1502
 			return reset( $col );
1502
-		}else{
1503
+		} else{
1503 1504
 			return NULL;
1504 1505
 		}
1505 1506
 	}
@@ -1614,7 +1615,7 @@  discard block
 block discarded – undo
1614 1615
 
1615 1616
 			//		/echo "delete sql:$SQL";
1616 1617
 			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1617
-		}else{
1618
+		} else{
1618 1619
 			$rows_deleted = 0;
1619 1620
 		}
1620 1621
 
@@ -1656,7 +1657,7 @@  discard block
 block discarded – undo
1656 1657
 		//first, if $ignore_this_model_obj was supplied, get its model
1657 1658
 		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1658 1659
 			$ignored_model = $ignore_this_model_obj->get_model();
1659
-		}else{
1660
+		} else{
1660 1661
 			$ignored_model = null;
1661 1662
 		}
1662 1663
 		//now check all the relations of $this_model_obj_or_id and see if there
@@ -1669,7 +1670,7 @@  discard block
 block discarded – undo
1669 1670
 				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1670 1671
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1671 1672
 					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1672
-				}else{
1673
+				} else{
1673 1674
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1674 1675
 				}
1675 1676
 
@@ -1706,24 +1707,28 @@  discard block
 block discarded – undo
1706 1707
 				}
1707 1708
 
1708 1709
 				//primary table deletes
1709
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1710
-					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1710
+				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) ) {
1711
+									$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1712
+				}
1711 1713
 
1712 1714
 				//other tables
1713 1715
 				if ( !empty( $other_tables ) ) {
1714 1716
 					foreach ( $other_tables as $ot ) {
1715 1717
 
1716 1718
 						//first check if we've got the foreign key column here.
1717
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1718
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1719
+						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) ) {
1720
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1721
+						}
1719 1722
 
1720 1723
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1721
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1722
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1724
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) ) {
1725
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1726
+						}
1723 1727
 
1724 1728
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1725
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1726
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1729
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) ) {
1730
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1731
+						}
1727 1732
 					}
1728 1733
 				}
1729 1734
 			}
@@ -1736,7 +1741,7 @@  discard block
 block discarded – undo
1736 1741
 			}
1737 1742
 
1738 1743
 			return !empty($query) ? implode(' AND ', $query ) : '';
1739
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1744
+		} elseif(count($this->get_combined_primary_key_fields()) > 1){
1740 1745
 			$ways_to_identify_a_row = array();
1741 1746
 			$fields = $this->get_combined_primary_key_fields();
1742 1747
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
@@ -1748,7 +1753,7 @@  discard block
 block discarded – undo
1748 1753
 				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1749 1754
 			}
1750 1755
 			return implode(" OR ",$ways_to_identify_a_row);
1751
-		}else{
1756
+		} else{
1752 1757
 			//so there's no primary key and no combined key...
1753 1758
 			//sorry, can't help you
1754 1759
 			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
@@ -1770,10 +1775,10 @@  discard block
 block discarded – undo
1770 1775
 		if($field_to_count){
1771 1776
 			$field_obj = $this->field_settings_for($field_to_count);
1772 1777
 			$column_to_count = $field_obj->get_qualified_column();
1773
-		}elseif($this->has_primary_key_field ()){
1778
+		} elseif($this->has_primary_key_field ()){
1774 1779
 			$pk_field_obj = $this->get_primary_key_field();
1775 1780
 			$column_to_count = $pk_field_obj->get_qualified_column();
1776
-		}else{//there's no primary key
1781
+		} else{//there's no primary key
1777 1782
 			$column_to_count = '*';
1778 1783
 		}
1779 1784
 
@@ -1795,7 +1800,7 @@  discard block
 block discarded – undo
1795 1800
 		if($field_to_sum){
1796 1801
 			$field_obj = $this->field_settings_for($field_to_sum);
1797 1802
 
1798
-		}else{
1803
+		} else{
1799 1804
 			$field_obj = $this->get_primary_key_field();
1800 1805
 		}
1801 1806
 		$column_to_count = $field_obj->get_qualified_column();
@@ -1804,7 +1809,7 @@  discard block
 block discarded – undo
1804 1809
 		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1805 1810
 		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1806 1811
 			return (float)$return_value;
1807
-		}else{//must be %f
1812
+		} else{//must be %f
1808 1813
 			return (float)$return_value;
1809 1814
 		}
1810 1815
 	}
@@ -1842,10 +1847,10 @@  discard block
 block discarded – undo
1842 1847
 			$wpdb->show_errors( $old_show_errors_value );
1843 1848
 			if( ! empty( $wpdb->last_error ) ){
1844 1849
 				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1845
-			}elseif( $result === false ){
1850
+			} elseif( $result === false ){
1846 1851
 				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1847 1852
 			}
1848
-		}elseif( $result === false ) {
1853
+		} elseif( $result === false ) {
1849 1854
 			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1850 1855
 		}
1851 1856
 		return $result;
@@ -2155,7 +2160,7 @@  discard block
 block discarded – undo
2155 2160
 		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2156 2161
 		if( $results ){
2157 2162
 			return array_shift($results);
2158
-		}else{
2163
+		} else{
2159 2164
 			return null;
2160 2165
 		}
2161 2166
 
@@ -2226,7 +2231,7 @@  discard block
 block discarded – undo
2226 2231
 			 */
2227 2232
 			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2228 2233
 			return $new_id;
2229
-		}else{
2234
+		} else{
2230 2235
 			return FALSE;
2231 2236
 		}
2232 2237
 	}
@@ -2267,9 +2272,9 @@  discard block
 block discarded – undo
2267 2272
 	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2268 2273
 		if($obj_or_fields_array instanceof EE_Base_Class){
2269 2274
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2270
-		}elseif( is_array($obj_or_fields_array)){
2275
+		} elseif( is_array($obj_or_fields_array)){
2271 2276
 			$fields_n_values = $obj_or_fields_array;
2272
-		}else{
2277
+		} else{
2273 2278
 			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
2274 2279
 		}
2275 2280
 		$query_params = array();
@@ -2285,7 +2290,7 @@  discard block
 block discarded – undo
2285 2290
 		//if there is nothing to base this search on, then we shouldn't find anything
2286 2291
 		if( empty( $query_params ) ){
2287 2292
 			return array();
2288
-		}else{
2293
+		} else{
2289 2294
 			return $this->get_one($query_params);
2290 2295
 		}
2291 2296
 	}
@@ -2358,12 +2363,12 @@  discard block
 block discarded – undo
2358 2363
 		if($this->has_primary_key_field()){
2359 2364
 			if($this->get_primary_key_field()->is_auto_increment()){
2360 2365
 				return $wpdb->insert_id;
2361
-			}else{
2366
+			} else{
2362 2367
 				//it's not an auto-increment primary key, so
2363 2368
 				//it must have been supplied
2364 2369
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2365 2370
 			}
2366
-		}else{
2371
+		} else{
2367 2372
 			//we can't return a  primary key because there is none. instead return
2368 2373
 			//a unique string indicating this model
2369 2374
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2411,7 +2416,7 @@  discard block
 block discarded – undo
2411 2416
 					//leave the value alone
2412 2417
 			}
2413 2418
 			return $value;
2414
-		}else{
2419
+		} else{
2415 2420
 			return $value;
2416 2421
 		}
2417 2422
 	}
@@ -2504,7 +2509,7 @@  discard block
 block discarded – undo
2504 2509
 		if(array_key_exists('group_by', $query_params)){
2505 2510
 			if(is_array($query_params['group_by'])){
2506 2511
 				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2507
-			}elseif( ! empty ( $query_params['group_by'] )){
2512
+			} elseif( ! empty ( $query_params['group_by'] )){
2508 2513
 				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2509 2514
 			}
2510 2515
 		}
@@ -2512,10 +2517,11 @@  discard block
 block discarded – undo
2512 2517
 			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2513 2518
 		}
2514 2519
 		if(array_key_exists('order_by', $query_params)){
2515
-			if ( is_array( $query_params['order_by'] ) )
2516
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2517
-			elseif( ! empty( $query_params['order_by'] ))
2518
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2520
+			if ( is_array( $query_params['order_by'] ) ) {
2521
+							$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2522
+			} elseif( ! empty( $query_params['order_by'] )) {
2523
+							$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2524
+			}
2519 2525
 		}
2520 2526
 		if(array_key_exists('force_join', $query_params)){
2521 2527
 			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
@@ -2547,10 +2553,10 @@  discard block
 block discarded – undo
2547 2553
 					if (! is_array($possibly_array_of_params)){
2548 2554
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2549 2555
 							$param,$possibly_array_of_params));
2550
-					}else{
2556
+					} else{
2551 2557
 						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2552 2558
 					}
2553
-				}elseif($query_param_type === 0 //ie WHERE
2559
+				} elseif($query_param_type === 0 //ie WHERE
2554 2560
 						&& is_array($possibly_array_of_params)
2555 2561
 						&& isset($possibly_array_of_params[2])
2556 2562
 						&& $possibly_array_of_params[2] == true){
@@ -2610,7 +2616,7 @@  discard block
 block discarded – undo
2610 2616
 		}
2611 2617
 		if( isset( $query_params[0] ) ) {
2612 2618
 			$where_query_params = $query_params[0];
2613
-		}else{
2619
+		} else{
2614 2620
 			$where_query_params = array();
2615 2621
 		}
2616 2622
 		//first check if we should alter the query to account for caps or not
@@ -2628,7 +2634,7 @@  discard block
 block discarded – undo
2628 2634
 		}
2629 2635
 		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2630 2636
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2631
-		}else{
2637
+		} else{
2632 2638
 			$use_default_where_conditions = 'all';
2633 2639
 		}
2634 2640
 		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
@@ -2651,7 +2657,7 @@  discard block
 block discarded – undo
2651 2657
 				}
2652 2658
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2653 2659
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2654
-			}elseif( ! empty ( $query_params['limit'] )){
2660
+			} elseif( ! empty ( $query_params['limit'] )){
2655 2661
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2656 2662
 			}
2657 2663
 		}
@@ -2673,11 +2679,11 @@  discard block
 block discarded – undo
2673 2679
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2674 2680
 				}
2675 2681
 				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2676
-			}elseif( ! empty ( $query_params['order_by'] )){
2682
+			} elseif( ! empty ( $query_params['order_by'] )){
2677 2683
 				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2678 2684
 				if(isset($query_params['order'])){
2679 2685
 					$order = $this->_extract_order($query_params['order']);
2680
-				}else{
2686
+				} else{
2681 2687
 					$order = 'DESC';
2682 2688
 				}
2683 2689
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2700,7 +2706,7 @@  discard block
 block discarded – undo
2700 2706
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2701 2707
 				}
2702 2708
 				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2703
-			}elseif( ! empty ( $query_params['group_by'] )){
2709
+			} elseif( ! empty ( $query_params['group_by'] )){
2704 2710
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2705 2711
 			}
2706 2712
 		}
@@ -2724,8 +2730,9 @@  discard block
 block discarded – undo
2724 2730
 			}
2725 2731
 		}
2726 2732
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2727
-		if ( empty( $main_model_join_sql ) )
2728
-			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2733
+		if ( empty( $main_model_join_sql ) ) {
2734
+					$query_object->set_main_model_join_sql($this->_construct_internal_join());
2735
+		}
2729 2736
 		return $query_object;
2730 2737
 	}
2731 2738
 
@@ -2758,7 +2765,7 @@  discard block
 block discarded – undo
2758 2765
 	private function _extract_order($should_be_order_string){
2759 2766
 		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2760 2767
 			return $should_be_order_string;
2761
-		}else{
2768
+		} else{
2762 2769
 			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2763 2770
 		}
2764 2771
 	}
@@ -2790,9 +2797,9 @@  discard block
 block discarded – undo
2790 2797
 		}
2791 2798
 		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2792 2799
 			$universal_query_params = $this->_get_default_where_conditions();
2793
-		}elseif( in_array( $use_default_where_conditions, array( 'minimum' ) ) ) {
2800
+		} elseif( in_array( $use_default_where_conditions, array( 'minimum' ) ) ) {
2794 2801
 			$universal_query_params = $this->_get_minimum_where_conditions();
2795
-		}else{
2802
+		} else{
2796 2803
 			$universal_query_params = array();
2797 2804
 		}
2798 2805
 
@@ -2832,14 +2839,14 @@  discard block
 block discarded – undo
2832 2839
 		foreach($default_where_conditions as $key => $val){
2833 2840
 			if( isset($provided_where_conditions[$key])){
2834 2841
 				$none_overridden = false;
2835
-			}else{
2842
+			} else{
2836 2843
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2837 2844
 			}
2838 2845
 		}
2839 2846
 		if( $none_overridden && $default_where_conditions){
2840 2847
 			if($model->has_primary_key_field()){
2841 2848
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2842
-			}else{
2849
+			} else{
2843 2850
 				//@todo NO PK, use other defaults
2844 2851
 			}
2845 2852
 		}
@@ -2855,8 +2862,9 @@  discard block
 block discarded – undo
2855 2862
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2856 2863
 	 */
2857 2864
 	private function _get_default_where_conditions($model_relation_path = null){
2858
-		if ( $this->_ignore_where_strategy )
2859
-			return array();
2865
+		if ( $this->_ignore_where_strategy ) {
2866
+					return array();
2867
+		}
2860 2868
 
2861 2869
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
2862 2870
 	}
@@ -2870,8 +2878,9 @@  discard block
 block discarded – undo
2870 2878
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2871 2879
 	 */
2872 2880
 	protected function _get_minimum_where_conditions($model_relation_path = null){
2873
-		if ( $this->_ignore_where_strategy )
2874
-			return array();
2881
+		if ( $this->_ignore_where_strategy ) {
2882
+					return array();
2883
+		}
2875 2884
 
2876 2885
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
2877 2886
 	}
@@ -2945,7 +2954,7 @@  discard block
 block discarded – undo
2945 2954
 		if(array_key_exists($query_param,$this_model_fields)){
2946 2955
 			if($allow_fields){
2947 2956
 				return;
2948
-			}else{
2957
+			} else{
2949 2958
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
2950 2959
 						$query_param,get_class($this),$query_param_type,$original_query_param));
2951 2960
 			}
@@ -2954,7 +2963,7 @@  discard block
 block discarded – undo
2954 2963
 		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2955 2964
 			if($allow_logic_query_params){
2956 2965
 				return;
2957
-			}else{
2966
+			} else{
2958 2967
 				throw new EE_Error(
2959 2968
 					sprintf(
2960 2969
 						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
@@ -2985,12 +2994,12 @@  discard block
 block discarded – undo
2985 2994
 					//we should actually end in a field name, not a model like this!
2986 2995
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2987 2996
 					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2988
-				}else{
2997
+				} else{
2989 2998
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2990 2999
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2991 3000
 					return;
2992 3001
 				}
2993
-			}elseif($query_param == $valid_related_model_name){
3002
+			} elseif($query_param == $valid_related_model_name){
2994 3003
 				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2995 3004
 				return;
2996 3005
 			}
@@ -3050,7 +3059,7 @@  discard block
 block discarded – undo
3050 3059
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3051 3060
 		if($SQL){
3052 3061
 			return " WHERE ". $SQL;
3053
-		}else{
3062
+		} else{
3054 3063
 			return '';
3055 3064
 		}
3056 3065
 	}
@@ -3065,7 +3074,7 @@  discard block
 block discarded – undo
3065 3074
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3066 3075
 		if($SQL){
3067 3076
 			return " HAVING ". $SQL;
3068
-		}else{
3077
+		} else{
3069 3078
 			return '';
3070 3079
 		}
3071 3080
 
@@ -3088,7 +3097,7 @@  discard block
 block discarded – undo
3088 3097
 			$model_instance=call_user_func($model_name."::instance");
3089 3098
 			/* @var $model_instance EEM_Base */
3090 3099
 			return $model_instance->field_settings_for($field_name);
3091
-		}else{
3100
+		} else{
3092 3101
 			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3093 3102
 		}
3094 3103
 	}
@@ -3121,14 +3130,14 @@  discard block
 block discarded – undo
3121 3130
 						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3122 3131
 						break;
3123 3132
 				}
3124
-			}else{
3133
+			} else{
3125 3134
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3126 3135
 
3127 3136
 				//if it's not a normal field, maybe it's a custom selection?
3128 3137
 				if( ! $field_obj){
3129 3138
 					if(isset( $this->_custom_selections[$query_param][1])){
3130 3139
 						$field_obj = $this->_custom_selections[$query_param][1];
3131
-					}else{
3140
+					} else{
3132 3141
 						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3133 3142
 					}
3134 3143
 				}
@@ -3138,7 +3147,7 @@  discard block
 block discarded – undo
3138 3147
 		}
3139 3148
 		if($where_clauses){
3140 3149
 			$SQL = implode($glue,$where_clauses);
3141
-		}else{
3150
+		} else{
3142 3151
 			$SQL = '';
3143 3152
 		}
3144 3153
 		return $SQL;
@@ -3158,11 +3167,11 @@  discard block
 block discarded – undo
3158 3167
 		if( $field ){
3159 3168
 			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3160 3169
 			return $table_alias_prefix . $field->get_qualified_column();
3161
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3170
+		} elseif(array_key_exists($query_param,$this->_custom_selections)){
3162 3171
 			//maybe it's custom selection item?
3163 3172
 			//if so, just use it as the "column name"
3164 3173
 			return $query_param;
3165
-		}else{
3174
+		} else{
3166 3175
 			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3167 3176
 		}
3168 3177
 	}
@@ -3179,7 +3188,7 @@  discard block
 block discarded – undo
3179 3188
 		$pos_of_star = strpos($condition_query_param_key, '*');
3180 3189
 		if($pos_of_star === FALSE){
3181 3190
 			return $condition_query_param_key;
3182
-		}else{
3191
+		} else{
3183 3192
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3184 3193
 			return $condition_query_param_sans_star;
3185 3194
 		}
@@ -3205,7 +3214,7 @@  discard block
 block discarded – undo
3205 3214
 				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string)));
3206 3215
 			}
3207 3216
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3208
-		}else{
3217
+		} else{
3209 3218
 			$operator = '=';
3210 3219
 			$value = $op_and_value;
3211 3220
 		}
@@ -3213,7 +3222,7 @@  discard block
 block discarded – undo
3213 3222
 		//check to see if the value is actually another field
3214 3223
 		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
3215 3224
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3216
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3225
+		} elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3217 3226
 			//in this case, the value should be an array, or at least a comma-separated list
3218 3227
 			//it will need to handle a little differently
3219 3228
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
@@ -3221,8 +3230,9 @@  discard block
 block discarded – undo
3221 3230
 			return $operator.SP.$cleaned_value;
3222 3231
 		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3223 3232
 			//the value should be an array with count of two.
3224
-			if ( count($value) !== 2 )
3225
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3233
+			if ( count($value) !== 2 ) {
3234
+							throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3235
+			}
3226 3236
 			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3227 3237
 			return $operator.SP.$cleaned_value;
3228 3238
 		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
@@ -3230,17 +3240,17 @@  discard block
 block discarded – undo
3230 3240
 				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
3231 3241
 			}
3232 3242
 			return $operator;
3233
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
3243
+		} elseif( $operator == 'LIKE' && ! is_array($value)){
3234 3244
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3235 3245
 			//remove other junk. So just treat it as a string.
3236 3246
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3237
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3247
+		} elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3238 3248
 			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
3239
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3249
+		} elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3240 3250
 			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
3241
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3251
+		} elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3242 3252
 			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
3243
-		}else{
3253
+		} else{
3244 3254
 			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
3245 3255
 		}
3246 3256
 	}
@@ -3310,7 +3320,7 @@  discard block
 block discarded – undo
3310 3320
 		global $wpdb;
3311 3321
 		if($field_obj instanceof EE_Model_Field_Base){
3312 3322
 			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3313
-		}else{//$field_obj should really just be a data type
3323
+		} else{//$field_obj should really just be a data type
3314 3324
 			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3315 3325
 				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3316 3326
 			}
@@ -3339,14 +3349,14 @@  discard block
 block discarded – undo
3339 3349
 		if($number_of_parts == 1){
3340 3350
 			$field_name = $last_query_param_part;
3341 3351
 			$model_obj = $this;
3342
-		}else{// $number_of_parts >= 2
3352
+		} else{// $number_of_parts >= 2
3343 3353
 			//the last part is the column name, and there are only 2parts. therefore...
3344 3354
 			$field_name = $last_query_param_part;
3345 3355
 			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3346 3356
 		}
3347 3357
 		try{
3348 3358
 			return $model_obj->field_settings_for($field_name);
3349
-		}catch(EE_Error $e){
3359
+		} catch(EE_Error $e){
3350 3360
 			return null;
3351 3361
 		}
3352 3362
 	}
@@ -3365,7 +3375,7 @@  discard block
 block discarded – undo
3365 3375
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3366 3376
 		if($field){
3367 3377
 			return $field->get_qualified_column();
3368
-		}else{
3378
+		} else{
3369 3379
 			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3370 3380
 		}
3371 3381
 	}
@@ -3431,7 +3441,7 @@  discard block
 block discarded – undo
3431 3441
 					//the FROM statement, BUT the primary table isn't. So we want
3432 3442
 					//to add the inverse join sql
3433 3443
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3434
-				}else{
3444
+				} else{
3435 3445
 					//just add a regular JOIN to this table from the primary table
3436 3446
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3437 3447
 				}
@@ -3546,7 +3556,7 @@  discard block
 block discarded – undo
3546 3556
 		$fieldSettings = $this->field_settings(true);
3547 3557
 		if( isset($fieldSettings[$fieldName])){
3548 3558
 			return true;
3549
-		}else{
3559
+		} else{
3550 3560
 			return false;
3551 3561
 		}
3552 3562
 	}
@@ -3560,7 +3570,7 @@  discard block
 block discarded – undo
3560 3570
 		$relations = $this->relation_settings();
3561 3571
 		if(isset($relations[$relation_name])){
3562 3572
 			return true;
3563
-		}else{
3573
+		} else{
3564 3574
 			return false;
3565 3575
 		}
3566 3576
 	}
@@ -3611,7 +3621,7 @@  discard block
 block discarded – undo
3611 3621
 			try{
3612 3622
 				$this->get_primary_key_field();
3613 3623
 				$this->_has_primary_key_field = true;
3614
-			}catch(EE_Error $e){
3624
+			} catch(EE_Error $e){
3615 3625
 				$this->_has_primary_key_field = false;
3616 3626
 			}
3617 3627
 		}
@@ -3690,7 +3700,7 @@  discard block
 block discarded – undo
3690 3700
 				}
3691 3701
 			}
3692 3702
 			return $this->_cached_fields;
3693
-		}else{
3703
+		} else{
3694 3704
 			if( $this->_cached_fields_non_db_only === NULL ){
3695 3705
 				$this->_cached_fields_non_db_only = array();
3696 3706
 				foreach($this->_fields as $fields_corresponding_to_table){
@@ -3843,7 +3853,7 @@  discard block
 block discarded – undo
3843 3853
 				// add this new object to the entity map
3844 3854
 				$classInstance = $this->add_to_entity_map( $classInstance );
3845 3855
 			}
3846
-		}else{
3856
+		} else{
3847 3857
 			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3848 3858
 		}
3849 3859
 
@@ -3930,11 +3940,12 @@  discard block
 block discarded – undo
3930 3940
 						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
3931 3941
 					}
3932 3942
 				}
3933
-			}else{
3943
+			} else{
3934 3944
 				//the table's rows existed. Use their values
3935 3945
 				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3936
-					if( ! $field_obj->is_db_only_field() )
3937
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3946
+					if( ! $field_obj->is_db_only_field() ) {
3947
+										$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3948
+					}
3938 3949
 				}
3939 3950
 			}
3940 3951
 		}
@@ -3948,9 +3959,9 @@  discard block
 block discarded – undo
3948 3959
 		if( isset( $cols_n_values[ $qualified_column ] ) ){
3949 3960
 			$value = $cols_n_values[ $qualified_column ];
3950 3961
 
3951
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3962
+		} elseif( isset( $cols_n_values[ $regular_column ] ) ){
3952 3963
 			$value = $cols_n_values[ $regular_column ];
3953
-		}else{
3964
+		} else{
3954 3965
 			$value = NULL;
3955 3966
 		}
3956 3967
 
@@ -3983,7 +3994,7 @@  discard block
 block discarded – undo
3983 3994
 				}
3984 3995
 			}
3985 3996
 			return $obj_in_map;
3986
-		}else{
3997
+		} else{
3987 3998
 			return $this->get_one_by_ID( $id );
3988 3999
 		}
3989 4000
 	}
@@ -4018,7 +4029,7 @@  discard block
 block discarded – undo
4018 4029
 				}
4019 4030
 			}
4020 4031
 			return $obj_in_map;
4021
-		}else{
4032
+		} else{
4022 4033
 			$this->add_to_entity_map( $replacing_model_obj );
4023 4034
 			return $replacing_model_obj;
4024 4035
 		}
@@ -4048,7 +4059,7 @@  discard block
 block discarded – undo
4048 4059
 	public function item_name($quantity = 1){
4049 4060
 		if($quantity == 1){
4050 4061
 			return $this->singular_item;
4051
-		}else{
4062
+		} else{
4052 4063
 			return $this->plural_item;
4053 4064
 		}
4054 4065
 	}
@@ -4110,14 +4121,14 @@  discard block
 block discarded – undo
4110 4121
 		$primary_key_field = $this->get_primary_key_field();
4111 4122
 		if( $base_class_obj_or_id instanceof $className ){
4112 4123
 			$model_object = $base_class_obj_or_id;
4113
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4124
+		} elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4114 4125
 				is_int( $base_class_obj_or_id ) ||
4115 4126
 				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4116 4127
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4117
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4128
+		} elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4118 4129
 			//assume its a string representation of the object
4119 4130
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4120
-		}else{
4131
+		} else{
4121 4132
 			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4122 4133
 		}
4123 4134
 		if( $model_object->ID() == NULL && $ensure_is_in_db){
@@ -4141,13 +4152,13 @@  discard block
 block discarded – undo
4141 4152
 		if( $base_class_obj_or_id instanceof $className ){
4142 4153
 			/** @var $base_class_obj_or_id EE_Base_Class */
4143 4154
 			$id = $base_class_obj_or_id->ID();
4144
-		}elseif(is_int($base_class_obj_or_id)){
4155
+		} elseif(is_int($base_class_obj_or_id)){
4145 4156
 			//assume it's an ID
4146 4157
 			$id = $base_class_obj_or_id;
4147
-		}elseif(is_string($base_class_obj_or_id)){
4158
+		} elseif(is_string($base_class_obj_or_id)){
4148 4159
 			//assume its a string representation of the object
4149 4160
 			$id = $base_class_obj_or_id;
4150
-		}else{
4161
+		} else{
4151 4162
 			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4152 4163
 		}
4153 4164
 		return $id;
@@ -4278,9 +4289,9 @@  discard block
 block discarded – undo
4278 4289
 
4279 4290
 		if($model_object_or_attributes_array instanceof EE_Base_Class){
4280 4291
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4281
-		}elseif(is_array($model_object_or_attributes_array)){
4292
+		} elseif(is_array($model_object_or_attributes_array)){
4282 4293
 			$attributes_array = $model_object_or_attributes_array;
4283
-		}else{
4294
+		} else{
4284 4295
 			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4285 4296
 		}
4286 4297
 		//even copies obviously won't have the same ID, so remove the primary key
@@ -4290,7 +4301,7 @@  discard block
 block discarded – undo
4290 4301
 		}
4291 4302
 		if(isset($query_params[0])){
4292 4303
 			$query_params[0] = array_merge($attributes_array,$query_params);
4293
-		}else{
4304
+		} else{
4294 4305
 			$query_params[0] = $attributes_array;
4295 4306
 		}
4296 4307
 		return $this->get_all($query_params);
@@ -4313,7 +4324,7 @@  discard block
 block discarded – undo
4313 4324
 		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4314 4325
 		if(is_array($copies)){
4315 4326
 			return array_shift($copies);
4316
-		}else{
4327
+		} else{
4317 4328
 			return null;
4318 4329
 		}
4319 4330
 	}
@@ -4345,7 +4356,7 @@  discard block
 block discarded – undo
4345 4356
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4346 4357
 		if($sql_operator){
4347 4358
 			return $sql_operator;
4348
-		}else{
4359
+		} else{
4349 4360
 			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4350 4361
 		}
4351 4362
 	}
@@ -4516,7 +4527,7 @@  discard block
 block discarded – undo
4516 4527
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4517 4528
 		if( in_array( $context, $valid_cap_contexts ) ) {
4518 4529
 			return true;
4519
-		}else{
4530
+		} else{
4520 4531
 			throw new EE_Error(
4521 4532
 				sprintf(
4522 4533
 					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Spacing   +398 added lines, -398 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public static function instance() {
130 130
 		// check if class object is instantiated, and instantiated properly
131
-		if ( ! self::$_instance instanceof EE_Config ) {
131
+		if ( ! self::$_instance instanceof EE_Config) {
132 132
 			self::$_instance = new self();
133 133
 		}
134 134
 		return self::$_instance;
@@ -145,22 +145,22 @@  discard block
 block discarded – undo
145 145
 	 * not be ready to instantiate EE_Config currently (eg if the site was put into maintenance mode)
146 146
 	 * @return EE_Config
147 147
 	 */
148
-	public static function reset( $hard_reset = FALSE, $reinstantiate = TRUE ){
149
-		if ( $hard_reset ) {
148
+	public static function reset($hard_reset = FALSE, $reinstantiate = TRUE) {
149
+		if ($hard_reset) {
150 150
 			self::$_instance->_config_option_names = array();
151 151
 			self::$_instance->_initialize_config();
152 152
 			self::$_instance->update_espresso_config();
153 153
 		}
154
-		if( self::$_instance instanceof EE_Config ){
154
+		if (self::$_instance instanceof EE_Config) {
155 155
 			self::$_instance->shutdown();
156 156
 		}
157 157
 		self::$_instance = NULL;
158 158
 		//we don't need to reset the static properties imo because those should
159 159
 		//only change when a module is added or removed. Currently we don't
160 160
 		//support removing a module during a request when it previously existed
161
-		if( $reinstantiate ){
161
+		if ($reinstantiate) {
162 162
 			return self::instance();
163
-		}else{
163
+		} else {
164 164
 			return NULL;
165 165
 		}
166 166
 	}
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 * @return \EE_Config
175 175
 	 */
176 176
 	private function __construct() {
177
-		do_action( 'AHEE__EE_Config__construct__begin',$this );
178
-		$this->_config_option_names = get_option( 'ee_config_option_names', array() );
177
+		do_action('AHEE__EE_Config__construct__begin', $this);
178
+		$this->_config_option_names = get_option('ee_config_option_names', array());
179 179
 		// setup empty config classes
180 180
 		$this->_initialize_config();
181 181
 		// load existing EE site settings
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
 		// confirm everything loaded correctly and set filtered defaults if not
184 184
 		$this->_verify_config();
185 185
 		//  register shortcodes and modules
186
-		add_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_and_modules' ), 999 );
186
+		add_action('AHEE__EE_System__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_and_modules'), 999);
187 187
 		//  initialize shortcodes and modules
188
-		add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' ));
188
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
189 189
 		// register widgets
190
-		add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 );
190
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
191 191
 		// shutdown
192
-		add_action( 'shutdown', array( $this, 'shutdown' ), 10 );
192
+		add_action('shutdown', array($this, 'shutdown'), 10);
193 193
 		// construct__end hook
194
-		do_action( 'AHEE__EE_Config__construct__end',$this );
194
+		do_action('AHEE__EE_Config__construct__end', $this);
195 195
 		// hardcoded hack
196 196
 		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
197 197
 	}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @return string current theme set.
205 205
 	 */
206 206
 	public static function get_current_theme() {
207
-		return isset( self::$_instance->template_settings->current_espresso_theme ) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
207
+		return isset(self::$_instance->template_settings->current_espresso_theme) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
208 208
 	}
209 209
 
210 210
 
@@ -238,27 +238,27 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	private function _load_core_config() {
240 240
 		// load_core_config__start hook
241
-		do_action( 'AHEE__EE_Config___load_core_config__start', $this );
241
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
242 242
 		$espresso_config = $this->get_espresso_config();
243
-		foreach ( $espresso_config as $config => $settings ) {
243
+		foreach ($espresso_config as $config => $settings) {
244 244
 			// load_core_config__start hook
245
-			$settings = apply_filters( 'FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this );
246
-			if ( is_object( $settings ) && property_exists( $this, $config ) ) {
247
-				$this->{$config} = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings );
245
+			$settings = apply_filters('FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this);
246
+			if (is_object($settings) && property_exists($this, $config)) {
247
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
248 248
 				//call configs populate method to ensure any defaults are set for empty values.
249
-				if ( method_exists( $settings, 'populate' ) ) {
249
+				if (method_exists($settings, 'populate')) {
250 250
 					$this->{$config}->populate();
251 251
 				}
252
-				if ( method_exists( $settings, 'do_hooks' ) ) {
252
+				if (method_exists($settings, 'do_hooks')) {
253 253
 					$this->{$config}->do_hooks();
254 254
 				}
255 255
 			}
256 256
 		}
257
-		if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', FALSE ) ) {
257
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', FALSE)) {
258 258
 			$this->update_espresso_config();
259 259
 		}
260 260
 		// load_core_config__end hook
261
-		do_action( 'AHEE__EE_Config___load_core_config__end', $this );
261
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
262 262
 	}
263 263
 
264 264
 
@@ -272,40 +272,40 @@  discard block
 block discarded – undo
272 272
 	protected function _verify_config() {
273 273
 
274 274
 		$this->core = $this->core instanceof EE_Core_Config
275
-			? $this->core  : new EE_Core_Config();
276
-		$this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core );
275
+			? $this->core : new EE_Core_Config();
276
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
277 277
 
278 278
 		$this->organization = $this->organization instanceof EE_Organization_Config
279
-			? $this->organization  : new EE_Organization_Config();
280
-		$this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization );
279
+			? $this->organization : new EE_Organization_Config();
280
+		$this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', $this->organization);
281 281
 
282 282
 		$this->currency = $this->currency instanceof EE_Currency_Config
283 283
 			? $this->currency : new EE_Currency_Config();
284
-		$this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency );
284
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
285 285
 
286 286
 		$this->registration = $this->registration instanceof EE_Registration_Config
287 287
 			? $this->registration : new EE_Registration_Config();
288
-		$this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration );
288
+		$this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', $this->registration);
289 289
 
290 290
 		$this->admin = $this->admin instanceof EE_Admin_Config
291 291
 			? $this->admin : new EE_Admin_Config();
292
-		$this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin );
292
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
293 293
 
294 294
 		$this->template_settings = $this->template_settings instanceof EE_Template_Config
295 295
 			? $this->template_settings : new EE_Template_Config();
296
-		$this->template_settings = apply_filters( 'FHEE__EE_Config___initialize_config__template_settings', $this->template_settings );
296
+		$this->template_settings = apply_filters('FHEE__EE_Config___initialize_config__template_settings', $this->template_settings);
297 297
 
298 298
 		$this->map_settings = $this->map_settings instanceof EE_Map_Config
299 299
 			? $this->map_settings : new EE_Map_Config();
300
-		$this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings );
300
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', $this->map_settings);
301 301
 
302 302
 		$this->environment = $this->environment instanceof EE_Environment_Config
303 303
 			? $this->environment : new EE_Environment_Config();
304
-		$this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment );
304
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', $this->environment);
305 305
 
306 306
 		$this->gateway = $this->gateway instanceof EE_Gateway_Config
307 307
 			? $this->gateway : new EE_Gateway_Config();
308
-		$this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway );
308
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
309 309
 
310 310
 	}
311 311
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 */
320 320
 	public function get_espresso_config() {
321 321
 		// grab espresso configuration
322
-		return apply_filters( 'FHEE__EE_Config__get_espresso_config__CFG', get_option( 'ee_config', array() ));
322
+		return apply_filters('FHEE__EE_Config__get_espresso_config__CFG', get_option('ee_config', array()));
323 323
 	}
324 324
 
325 325
 
@@ -332,12 +332,12 @@  discard block
 block discarded – undo
332 332
 	 * @param        $old_value
333 333
 	 * @param        $value
334 334
 	 */
335
-	public function double_check_config_comparison( $option = '', $old_value, $value ) {
335
+	public function double_check_config_comparison($option = '', $old_value, $value) {
336 336
 		// make sure we're checking the ee config
337
-		if ( $option == 'ee_config' ) {
337
+		if ($option == 'ee_config') {
338 338
 			// run a loose comparison of the old value against the new value for type and properties,
339 339
 			// but NOT exact instance like WP update_option does
340
-			if ( $value != $old_value ) {
340
+			if ($value != $old_value) {
341 341
 				// if they are NOT the same, then remove the hook,
342 342
 				// which means the subsequent update results will be based solely on the update query results
343 343
 				// the reason we do this is because, as stated above,
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				// the string it sees in the db looks the same as the new one it has been passed!!!
353 353
 				// This results in the query returning an "affected rows" value of ZERO,
354 354
 				// which gets returned immediately by WP update_option and looks like an error.
355
-				remove_action( 'update_option', array( $this, 'check_config_updated' ));
355
+				remove_action('update_option', array($this, 'check_config_updated'));
356 356
 			}
357 357
 		}
358 358
 	}
@@ -367,11 +367,11 @@  discard block
 block discarded – undo
367 367
 	 */
368 368
 	protected function  _reset_espresso_addon_config() {
369 369
 		$this->_config_option_names = array();
370
-		foreach( $this->addons as $addon_name => $addon_config_obj ) {
371
-			$addon_config_obj = maybe_unserialize( $addon_config_obj );
372
-			$config_class = get_class( $addon_config_obj );
373
-			if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) {
374
-				$this->update_config( 'addons', $addon_name, $addon_config_obj, FALSE );
370
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
371
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
372
+			$config_class = get_class($addon_config_obj);
373
+			if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
374
+				$this->update_config('addons', $addon_name, $addon_config_obj, FALSE);
375 375
 			}
376 376
 			$this->addons->{$addon_name} = NULL;
377 377
 		}
@@ -387,17 +387,17 @@  discard block
 block discarded – undo
387 387
 	 * @param   bool $add_error
388 388
 	 * @return   bool
389 389
 	 */
390
-	public function  update_espresso_config( $add_success = FALSE, $add_error = TRUE ) {
390
+	public function  update_espresso_config($add_success = FALSE, $add_error = TRUE) {
391 391
 		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
392 392
 		//$clone = clone( self::$_instance );
393 393
 		//self::$_instance = NULL;
394
-		do_action( 'AHEE__EE_Config__update_espresso_config__begin',$this );
394
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
395 395
 		$this->_reset_espresso_addon_config();
396 396
 		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
397 397
 		// but BEFORE the actual update occurs
398
-		add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 );
398
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
399 399
 		// now update "ee_config"
400
-		$saved = update_option( 'ee_config', $this );
400
+		$saved = update_option('ee_config', $this);
401 401
 		// if not saved... check if the hook we just added still exists;
402 402
 		// if it does, it means one of two things:
403 403
 		// 		that update_option bailed at the ( $value === $old_value ) conditional,
@@ -408,25 +408,25 @@  discard block
 block discarded – undo
408 408
 		// but just means no update occurred, so don't display an error to the user.
409 409
 		// BUT... if update_option returns FALSE, AND the hook is missing,
410 410
 		// then it means that something truly went wrong
411
-		$saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' )) : $saved;
411
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
412 412
 		// remove our action since we don't want it in the system anymore
413
-		remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 );
414
-		do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved );
413
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
414
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
415 415
 		//self::$_instance = $clone;
416 416
 		//unset( $clone );
417 417
 		// if config remains the same or was updated successfully
418
-		if ( $saved ) {
419
-			if ( $add_success ) {
418
+		if ($saved) {
419
+			if ($add_success) {
420 420
 				EE_Error::add_success(
421
-					__( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ),
421
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
422 422
 					__FILE__, __FUNCTION__, __LINE__
423 423
 				);
424 424
 			}
425 425
 			return TRUE;
426 426
 		} else {
427
-			if ( $add_error ) {
427
+			if ($add_error) {
428 428
 				EE_Error::add_error(
429
-					__( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ),
429
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
430 430
 					__FILE__, __FUNCTION__, __LINE__
431 431
 				);
432 432
 			}
@@ -452,20 +452,20 @@  discard block
 block discarded – undo
452 452
 		$name = '',
453 453
 		$config_class = '',
454 454
 		$config_obj = NULL,
455
-		$tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ),
455
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
456 456
 		$display_errors = TRUE
457 457
 	) {
458 458
 		try {
459
-			foreach ( $tests_to_run as $test ) {
460
-				switch ( $test ) {
459
+			foreach ($tests_to_run as $test) {
460
+				switch ($test) {
461 461
 
462 462
 					// TEST #1 : check that section was set
463 463
 					case 1 :
464
-						if ( empty( $section ) ) {
465
-							if ( $display_errors ) {
464
+						if (empty($section)) {
465
+							if ($display_errors) {
466 466
 								throw new EE_Error(
467 467
 									sprintf(
468
-										__( 'No configuration section has been provided while attempting to save "%s".', 'event_espresso' ),
468
+										__('No configuration section has been provided while attempting to save "%s".', 'event_espresso'),
469 469
 										$config_class
470 470
 									)
471 471
 								);
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 
477 477
 					// TEST #2 : check that settings section exists
478 478
 					case 2 :
479
-						if ( ! isset( $this->{$section} ) ) {
480
-							if ( $display_errors ) {
479
+						if ( ! isset($this->{$section} )) {
480
+							if ($display_errors) {
481 481
 								throw new EE_Error(
482
-									sprintf( __( 'The "%s" configuration section does not exist.', 'event_espresso' ),
483
-											 $section )
482
+									sprintf(__('The "%s" configuration section does not exist.', 'event_espresso'),
483
+											 $section)
484 484
 								);
485 485
 							}
486 486
 							return false;
@@ -490,12 +490,12 @@  discard block
 block discarded – undo
490 490
 					// TEST #3 : check that section is the proper format
491 491
 					case 3 :
492 492
 						if (
493
-							! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass )
493
+							! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
494 494
 						) {
495
-							if ( $display_errors ) {
495
+							if ($display_errors) {
496 496
 								throw new EE_Error(
497 497
 									sprintf(
498
-										__( 'The "%s" configuration settings have not been formatted correctly.', 'event_espresso' ),
498
+										__('The "%s" configuration settings have not been formatted correctly.', 'event_espresso'),
499 499
 										$section
500 500
 									)
501 501
 								);
@@ -506,10 +506,10 @@  discard block
 block discarded – undo
506 506
 
507 507
 					// TEST #4 : check that config section name has been set
508 508
 					case 4 :
509
-						if ( empty( $name ) ) {
510
-							if ( $display_errors ) {
509
+						if (empty($name)) {
510
+							if ($display_errors) {
511 511
 								throw new EE_Error(
512
-									__( 'No name has been provided for the specific configuration section.', 'event_espresso' )
512
+									__('No name has been provided for the specific configuration section.', 'event_espresso')
513 513
 								);
514 514
 							}
515 515
 							return false;
@@ -518,10 +518,10 @@  discard block
 block discarded – undo
518 518
 
519 519
 					// TEST #5 : check that a config class name has been set
520 520
 					case 5 :
521
-						if ( empty( $config_class ) ) {
522
-							if ( $display_errors ) {
521
+						if (empty($config_class)) {
522
+							if ($display_errors) {
523 523
 								throw new EE_Error(
524
-									__( 'No class name has been provided for the specific configuration section.', 'event_espresso' )
524
+									__('No class name has been provided for the specific configuration section.', 'event_espresso')
525 525
 								);
526 526
 							}
527 527
 							return false;
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
 
531 531
 					// TEST #6 : verify config class is accessible
532 532
 					case 6 :
533
-						if ( ! class_exists( $config_class ) ) {
534
-							if ( $display_errors ) {
533
+						if ( ! class_exists($config_class)) {
534
+							if ($display_errors) {
535 535
 								throw new EE_Error(
536 536
 									sprintf(
537
-										__( 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso' ),
537
+										__('The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso'),
538 538
 										$config_class
539 539
 									)
540 540
 								);
@@ -545,11 +545,11 @@  discard block
 block discarded – undo
545 545
 
546 546
 					// TEST #7 : check that config has even been set
547 547
 					case 7 :
548
-						if ( ! isset( $this->{$section}->{$name} ) ) {
549
-							if ( $display_errors ) {
548
+						if ( ! isset($this->{$section}->{$name} )) {
549
+							if ($display_errors) {
550 550
 								throw new EE_Error(
551 551
 									sprintf(
552
-										__( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ),
552
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
553 553
 										$section,
554 554
 										$name
555 555
 									)
@@ -558,17 +558,17 @@  discard block
 block discarded – undo
558 558
 							return false;
559 559
 						} else {
560 560
 							// and make sure it's not serialized
561
-							$this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} );
561
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name} );
562 562
 						}
563 563
 						break;
564 564
 
565 565
 					// TEST #8 : check that config is the requested type
566 566
 					case 8 :
567
-						if ( ! $this->{$section}->{$name} instanceof $config_class ) {
568
-							if ( $display_errors ) {
567
+						if ( ! $this->{$section}->{$name} instanceof $config_class) {
568
+							if ($display_errors) {
569 569
 								throw new EE_Error(
570 570
 									sprintf(
571
-										__( 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso' ),
571
+										__('The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso'),
572 572
 										$section,
573 573
 										$name,
574 574
 										$config_class
@@ -581,12 +581,12 @@  discard block
 block discarded – undo
581 581
 
582 582
 					// TEST #9 : verify config object
583 583
 					case 9 :
584
-						if ( ! $config_obj instanceof EE_Config_Base ) {
585
-							if ( $display_errors ) {
584
+						if ( ! $config_obj instanceof EE_Config_Base) {
585
+							if ($display_errors) {
586 586
 								throw new EE_Error(
587 587
 									sprintf(
588
-										__( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ),
589
-										print_r( $config_obj, true )
588
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
589
+										print_r($config_obj, true)
590 590
 									)
591 591
 								);
592 592
 							}
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 				}
598 598
 			}
599 599
 
600
-		} catch( EE_Error $e ) {
600
+		} catch (EE_Error $e) {
601 601
 			$e->get_error();
602 602
 		}
603 603
 		// you have successfully run the gauntlet
@@ -614,8 +614,8 @@  discard block
 block discarded – undo
614 614
 	 * @param        string          $name
615 615
 	 * @return        string
616 616
 	 */
617
-	private function _generate_config_option_name( $section = '', $name = '' ) {
618
-		return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) );
617
+	private function _generate_config_option_name($section = '', $name = '') {
618
+		return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
619 619
 	}
620 620
 
621 621
 
@@ -629,10 +629,10 @@  discard block
 block discarded – undo
629 629
 	 * @param 	string $name
630 630
 	 * @return 	string
631 631
 	 */
632
-	private function _set_config_class( $config_class = '', $name = '' ) {
633
-		return ! empty( $config_class )
632
+	private function _set_config_class($config_class = '', $name = '') {
633
+		return ! empty($config_class)
634 634
 			? $config_class
635
-			: str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config';
635
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
636 636
 	}
637 637
 
638 638
 
@@ -646,34 +646,34 @@  discard block
 block discarded – undo
646 646
 	 * @param 	EE_Config_Base $config_obj
647 647
 	 * @return 	EE_Config_Base
648 648
 	 */
649
-	public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) {
649
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) {
650 650
 		// ensure config class is set to something
651
-		$config_class = $this->_set_config_class( $config_class, $name );
651
+		$config_class = $this->_set_config_class($config_class, $name);
652 652
 		// run tests 1-4, 6, and 7 to verify all config params are set and valid
653
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ))) {
653
+		if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
654 654
 			return null;
655 655
 		}
656
-		$config_option_name = $this->_generate_config_option_name( $section, $name );
656
+		$config_option_name = $this->_generate_config_option_name($section, $name);
657 657
 		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
658
-		if ( ! isset( $this->_config_option_names[ $config_option_name ] )) {
659
-			$this->_config_option_names[ $config_option_name ] = $config_class;
658
+		if ( ! isset($this->_config_option_names[$config_option_name])) {
659
+			$this->_config_option_names[$config_option_name] = $config_class;
660 660
 		}
661 661
 		// verify the incoming config object but suppress errors
662
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false )) {
662
+		if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
663 663
 			$config_obj = new $config_class();
664 664
 		}
665
-		if ( get_option( $config_option_name ) ) {
666
-			update_option( $config_option_name, $config_obj );
665
+		if (get_option($config_option_name)) {
666
+			update_option($config_option_name, $config_obj);
667 667
 			$this->{$section}->{$name} = $config_obj;
668 668
 			return $this->{$section}->{$name};
669 669
 		} else {
670 670
 			// create a wp-option for this config
671
-			if ( add_option( $config_option_name, $config_obj, '', 'no' )) {
672
-				$this->{$section}->{$name} = maybe_unserialize( $config_obj );
671
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
672
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
673 673
 				return $this->{$section}->{$name};
674 674
 			} else {
675 675
 				EE_Error::add_error(
676
-					sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ),
676
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
677 677
 					__FILE__, __FUNCTION__, __LINE__
678 678
 				);
679 679
 				return null;
@@ -694,37 +694,37 @@  discard block
 block discarded – undo
694 694
 	 * @param 	bool 					$throw_errors
695 695
 	 * @return 	bool
696 696
 	 */
697
-	public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) {
698
-		$config_obj = maybe_unserialize( $config_obj );
697
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) {
698
+		$config_obj = maybe_unserialize($config_obj);
699 699
 		// get class name of the incoming object
700
-		$config_class = get_class( $config_obj );
700
+		$config_class = get_class($config_obj);
701 701
 		// run tests 1-5 and 9 to verify config
702
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 1, 2, 3, 4, 7, 9 ))) {
702
+		if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(1, 2, 3, 4, 7, 9))) {
703 703
 			return false;
704 704
 		}
705
-		$config_option_name = $this->_generate_config_option_name( $section, $name );
705
+		$config_option_name = $this->_generate_config_option_name($section, $name);
706 706
 		// check if config object has been added to db by seeing if config option name is in $this->_config_option_names array
707
-		if ( ! isset( $this->_config_option_names[ $config_option_name ] )) {
707
+		if ( ! isset($this->_config_option_names[$config_option_name])) {
708 708
 			// save new config to db
709
-			return $this->set_config( $section, $name, $config_class, $config_obj );
709
+			return $this->set_config($section, $name, $config_class, $config_obj);
710 710
 		} else {
711 711
 			// first check if the record already exists
712
-			$existing_config = get_option( $config_option_name );
713
-			$config_obj = serialize( $config_obj );
712
+			$existing_config = get_option($config_option_name);
713
+			$config_obj = serialize($config_obj);
714 714
 			// just return if db record is already up to date
715
-			if ( $existing_config == $config_obj ) {
715
+			if ($existing_config == $config_obj) {
716 716
 				$this->{$section}->{$name} = $config_obj;
717 717
 				return true;
718
-			} else if ( update_option( $config_option_name, $config_obj )) {
718
+			} else if (update_option($config_option_name, $config_obj)) {
719 719
 				// update wp-option for this config class
720 720
 				$this->{$section}->{$name} = $config_obj;
721 721
 				return true;
722
-			} elseif ( $throw_errors ) {
722
+			} elseif ($throw_errors) {
723 723
 				EE_Error::add_error(
724 724
 					sprintf(
725
-						__( 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso' ),
725
+						__('The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso'),
726 726
 						$config_class,
727
-						'EE_Config->' . $section . '->' . $name
727
+						'EE_Config->'.$section.'->'.$name
728 728
 					),
729 729
 					__FILE__, __FUNCTION__, __LINE__
730 730
 				);
@@ -744,34 +744,34 @@  discard block
 block discarded – undo
744 744
 	 * @param 	string 	$config_class
745 745
 	 * @return 	mixed EE_Config_Base | NULL
746 746
 	 */
747
-	public function get_config( $section = '', $name = '', $config_class = '' ) {
747
+	public function get_config($section = '', $name = '', $config_class = '') {
748 748
 		// ensure config class is set to something
749
-		$config_class = $this->_set_config_class( $config_class, $name );
749
+		$config_class = $this->_set_config_class($config_class, $name);
750 750
 		// run tests 1-4, 6 and 7 to verify that all params have been set
751
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, NULL, array( 1, 2, 3, 4, 5, 6 ))) {
751
+		if ( ! $this->_verify_config_params($section, $name, $config_class, NULL, array(1, 2, 3, 4, 5, 6))) {
752 752
 			return NULL;
753 753
 		}
754 754
 		// now test if the requested config object exists, but suppress errors
755
-		if ( $this->_verify_config_params( $section, $name, $config_class, NULL, array( 7, 8 ), FALSE )) {
755
+		if ($this->_verify_config_params($section, $name, $config_class, NULL, array(7, 8), FALSE)) {
756 756
 			// config already exists, so pass it back
757 757
 			return $this->{$section}->{$name};
758 758
 		}
759 759
 		// load config option from db if it exists
760
-		$config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name ));
760
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
761 761
 		// verify the newly retrieved config object, but suppress errors
762
-		if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), FALSE )) {
762
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), FALSE)) {
763 763
 			// config is good, so set it and pass it back
764 764
 			$this->{$section}->{$name} = $config_obj;
765 765
 			return $this->{$section}->{$name};
766 766
 		}
767 767
 		// oops! $config_obj is not already set and does not exist in the db, so create a new one
768
-		$config_obj =$this->set_config( $section, $name, $config_class );
768
+		$config_obj = $this->set_config($section, $name, $config_class);
769 769
 		// verify the newly created config object
770
-		if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ))) {
770
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
771 771
 			return $this->{$section}->{$name};
772 772
 		} else {
773 773
 			EE_Error::add_error(
774
-				sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ),
774
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
775 775
 				__FILE__, __FUNCTION__, __LINE__
776 776
 			);
777 777
 		}
@@ -786,9 +786,9 @@  discard block
 block discarded – undo
786 786
 	 * @param 	string 	$config_option_name
787 787
 	 * @return 	mixed EE_Config_Base | FALSE
788 788
 	 */
789
-	public function get_config_option( $config_option_name = '' ) {
789
+	public function get_config_option($config_option_name = '') {
790 790
 		// retrieve the wp-option for this config class.
791
-		return maybe_unserialize( get_option( $config_option_name ));
791
+		return maybe_unserialize(get_option($config_option_name));
792 792
 	}
793 793
 
794 794
 
@@ -801,45 +801,45 @@  discard block
 block discarded – undo
801 801
 	 * @param $page_for_posts
802 802
 	 * @return    void
803 803
 	 */
804
-	public function update_post_shortcodes( $page_for_posts = '' ) {
804
+	public function update_post_shortcodes($page_for_posts = '') {
805 805
 		// make sure page_for_posts is set
806
-		$page_for_posts = ! empty( $page_for_posts ) ? $page_for_posts : EE_Config::get_page_for_posts();
806
+		$page_for_posts = ! empty($page_for_posts) ? $page_for_posts : EE_Config::get_page_for_posts();
807 807
 		// critical page shortcodes that we do NOT want added to the Posts page (blog)
808 808
 		$critical_shortcodes = $this->core->get_critical_pages_shortcodes_array();
809 809
 		// allow others to mess stuff up :D
810
-		do_action( 'AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts );
810
+		do_action('AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts);
811 811
 		// verify that post_shortcodes is set
812
-		$this->core->post_shortcodes = isset( $this->core->post_shortcodes ) && is_array( $this->core->post_shortcodes ) ? $this->core->post_shortcodes : array();
812
+		$this->core->post_shortcodes = isset($this->core->post_shortcodes) && is_array($this->core->post_shortcodes) ? $this->core->post_shortcodes : array();
813 813
 		// cycle thru post_shortcodes
814
-		foreach( $this->core->post_shortcodes as $post_name => $shortcodes ){
814
+		foreach ($this->core->post_shortcodes as $post_name => $shortcodes) {
815 815
 			// are there any shortcodes to track ?
816
-			if ( ! empty( $shortcodes )) {
816
+			if ( ! empty($shortcodes)) {
817 817
 				// loop thru list of tracked shortcodes
818
-				foreach( $shortcodes as $shortcode => $post_id ) {
818
+				foreach ($shortcodes as $shortcode => $post_id) {
819 819
 					// if shortcode is for a critical page, BUT this is NOT the corresponding critical page for that shortcode
820
-					if ( isset( $critical_shortcodes[ $post_id ] ) && $post_name == $page_for_posts ) {
820
+					if (isset($critical_shortcodes[$post_id]) && $post_name == $page_for_posts) {
821 821
 						// then remove this shortcode, because we don't want critical page shortcodes like ESPRESSO_TXN_PAGE running on the "Posts Page" (blog)
822
-						unset( $this->core->post_shortcodes[ $post_name ][ $shortcode ] );
822
+						unset($this->core->post_shortcodes[$post_name][$shortcode]);
823 823
 					}
824 824
 					// skip the posts page, because we want all shortcodes registered for it
825
-					if ( $post_name == $page_for_posts ) {
825
+					if ($post_name == $page_for_posts) {
826 826
 						continue;
827 827
 					}
828 828
 					// make sure post still exists
829
-					$post = get_post( $post_id );
830
-					if ( $post ) {
829
+					$post = get_post($post_id);
830
+					if ($post) {
831 831
 						// check that the post name matches what we have saved
832
-						if ( $post->post_name == $post_name ) {
832
+						if ($post->post_name == $post_name) {
833 833
 							// if so, then break before hitting the unset below
834 834
 							continue;
835 835
 						}
836 836
 					}
837 837
 					// we don't like missing posts around here >:(
838
-					unset( $this->core->post_shortcodes[ $post_name ] );
838
+					unset($this->core->post_shortcodes[$post_name]);
839 839
 				}
840 840
 			} else {
841 841
 				// you got no shortcodes to keep track of !
842
-				unset( $this->core->post_shortcodes[ $post_name ] );
842
+				unset($this->core->post_shortcodes[$post_name]);
843 843
 			}
844 844
 		}
845 845
 		//only show errors
@@ -858,14 +858,14 @@  discard block
 block discarded – undo
858 858
 	 *  @return 	string
859 859
 	 */
860 860
 	public static function get_page_for_posts() {
861
-		$page_for_posts = get_option( 'page_for_posts' );
862
-		if ( ! $page_for_posts ) {
861
+		$page_for_posts = get_option('page_for_posts');
862
+		if ( ! $page_for_posts) {
863 863
 			return 'posts';
864 864
 		}
865 865
 		/** @type WPDB $wpdb */
866 866
 		global $wpdb;
867 867
 		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
868
-		return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts ));
868
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
869 869
 	}
870 870
 
871 871
 
@@ -881,11 +881,11 @@  discard block
 block discarded – undo
881 881
 	 *  @return 	void
882 882
 	 */
883 883
 	public function register_shortcodes_and_modules() {
884
-		if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) {
884
+		if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) {
885 885
 			return;
886 886
 		}
887 887
 		// allow shortcodes to register with WP and to set hooks for the rest of the system
888
-		EE_Registry::instance()->shortcodes =$this->_register_shortcodes();
888
+		EE_Registry::instance()->shortcodes = $this->_register_shortcodes();
889 889
 		// allow modules to set hooks for the rest of the system
890 890
 		EE_Registry::instance()->modules = $this->_register_modules();
891 891
 	}
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 	 *  @return 	void
900 900
 	 */
901 901
 	public function initialize_shortcodes_and_modules() {
902
-		if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) {
902
+		if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) {
903 903
 			return;
904 904
 		}
905 905
 		// allow shortcodes to set hooks for the rest of the system
@@ -918,26 +918,26 @@  discard block
 block discarded – undo
918 918
 	 * 	@return void
919 919
 	 */
920 920
 	public function widgets_init() {
921
-		if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) {
921
+		if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) {
922 922
 			return;
923 923
 		}
924 924
 		//only init widgets on admin pages when not in complete maintenance, and
925 925
 		//on frontend when not in any maintenance mode
926
-		if (( is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance)  || ! EE_Maintenance_Mode::instance()->level() ) {
926
+		if ((is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level()) {
927 927
 			// grab list of installed widgets
928
-			$widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR );
928
+			$widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
929 929
 			// filter list of modules to register
930
-			$widgets_to_register = apply_filters( 'FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register );
930
+			$widgets_to_register = apply_filters('FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register);
931 931
 
932
-			if ( ! empty( $widgets_to_register ) ) {
932
+			if ( ! empty($widgets_to_register)) {
933 933
 				// cycle thru widget folders
934
-				foreach ( $widgets_to_register as $widget_path ) {
934
+				foreach ($widgets_to_register as $widget_path) {
935 935
 					// add to list of installed widget modules
936
-					EE_Config::register_ee_widget( $widget_path );
936
+					EE_Config::register_ee_widget($widget_path);
937 937
 				}
938 938
 			}
939 939
 			// filter list of installed modules
940
-			EE_Registry::instance()->widgets = apply_filters( 'FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets );
940
+			EE_Registry::instance()->widgets = apply_filters('FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets);
941 941
 		}
942 942
 	}
943 943
 
@@ -950,54 +950,54 @@  discard block
 block discarded – undo
950 950
 	 *  @param 	string 	$widget_path - full path up to and including widget folder
951 951
 	 *  @return 	void
952 952
 	 */
953
-	public static function register_ee_widget( $widget_path = NULL ) {
954
-		do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path );
953
+	public static function register_ee_widget($widget_path = NULL) {
954
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
955 955
 		$widget_ext = '.widget.php';
956 956
 		// make all separators match
957
-		$widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS );
957
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
958 958
 		// does the file path INCLUDE the actual file name as part of the path ?
959
-		if ( strpos( $widget_path, $widget_ext ) !== FALSE ) {
959
+		if (strpos($widget_path, $widget_ext) !== FALSE) {
960 960
 			// grab and shortcode file name from directory name and break apart at dots
961
-			$file_name = explode( '.', basename( $widget_path ));
961
+			$file_name = explode('.', basename($widget_path));
962 962
 			// take first segment from file name pieces and remove class prefix if it exists
963
-			$widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0];
963
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
964 964
 			// sanitize shortcode directory name
965
-			$widget = sanitize_key( $widget );
965
+			$widget = sanitize_key($widget);
966 966
 			// now we need to rebuild the shortcode path
967
-			$widget_path = explode( DS, $widget_path );
967
+			$widget_path = explode(DS, $widget_path);
968 968
 			// remove last segment
969
-			array_pop( $widget_path );
969
+			array_pop($widget_path);
970 970
 			// glue it back together
971
-			$widget_path = implode( DS, $widget_path );
971
+			$widget_path = implode(DS, $widget_path);
972 972
 		} else {
973 973
 			// grab and sanitize widget directory name
974
-			$widget = sanitize_key( basename( $widget_path ));
974
+			$widget = sanitize_key(basename($widget_path));
975 975
 		}
976 976
 		// create classname from widget directory name
977
-		$widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget )));
977
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
978 978
 		// add class prefix
979
-		$widget_class = 'EEW_' . $widget;
979
+		$widget_class = 'EEW_'.$widget;
980 980
 		// does the widget exist ?
981
-		if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext )) {
981
+		if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
982 982
 			$msg = sprintf(
983
-				__( 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso' ),
983
+				__('The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'),
984 984
 				$widget_class,
985
-				$widget_path . DS . $widget_class . $widget_ext
985
+				$widget_path.DS.$widget_class.$widget_ext
986 986
 			);
987
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
987
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
988 988
 			return;
989 989
 		}
990 990
 		// load the widget class file
991
-		require_once( $widget_path . DS . $widget_class . $widget_ext );
991
+		require_once($widget_path.DS.$widget_class.$widget_ext);
992 992
 		// verify that class exists
993
-		if ( ! class_exists( $widget_class )) {
994
-			$msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class );
995
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
993
+		if ( ! class_exists($widget_class)) {
994
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
995
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
996 996
 			return;
997 997
 		}
998
-		register_widget( $widget_class );
998
+		register_widget($widget_class);
999 999
 		// add to array of registered widgets
1000
-		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1000
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
1001 1001
 	}
1002 1002
 
1003 1003
 
@@ -1010,18 +1010,18 @@  discard block
 block discarded – undo
1010 1010
 	 */
1011 1011
 	private function _register_shortcodes() {
1012 1012
 		// grab list of installed shortcodes
1013
-		$shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR );
1013
+		$shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR);
1014 1014
 		// filter list of modules to register
1015
-		$shortcodes_to_register = apply_filters( 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register );
1016
-		if ( ! empty( $shortcodes_to_register ) ) {
1015
+		$shortcodes_to_register = apply_filters('FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register);
1016
+		if ( ! empty($shortcodes_to_register)) {
1017 1017
 			// cycle thru shortcode folders
1018
-			foreach ( $shortcodes_to_register as $shortcode_path ) {
1018
+			foreach ($shortcodes_to_register as $shortcode_path) {
1019 1019
 				// add to list of installed shortcode modules
1020
-				EE_Config::register_shortcode( $shortcode_path );
1020
+				EE_Config::register_shortcode($shortcode_path);
1021 1021
 			}
1022 1022
 		}
1023 1023
 		// filter list of installed modules
1024
-		return apply_filters( 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes );
1024
+		return apply_filters('FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes);
1025 1025
 	}
1026 1026
 
1027 1027
 
@@ -1033,56 +1033,56 @@  discard block
 block discarded – undo
1033 1033
 	 *  @param 	string 		$shortcode_path - full path up to and including shortcode folder
1034 1034
 	 *  @return 	bool
1035 1035
 	 */
1036
-	public static function register_shortcode( $shortcode_path = NULL ) {
1037
-		do_action( 'AHEE__EE_Config__register_shortcode__begin',$shortcode_path );
1036
+	public static function register_shortcode($shortcode_path = NULL) {
1037
+		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
1038 1038
 		$shortcode_ext = '.shortcode.php';
1039 1039
 		// make all separators match
1040
-		$shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path );
1040
+		$shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
1041 1041
 		// does the file path INCLUDE the actual file name as part of the path ?
1042
-		if ( strpos( $shortcode_path, $shortcode_ext ) !== FALSE ) {
1042
+		if (strpos($shortcode_path, $shortcode_ext) !== FALSE) {
1043 1043
 			// grab shortcode file name from directory name and break apart at dots
1044
-			$shortcode_file = explode( '.', basename( $shortcode_path ));
1044
+			$shortcode_file = explode('.', basename($shortcode_path));
1045 1045
 			// take first segment from file name pieces and remove class prefix if it exists
1046
-			$shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 ? substr( $shortcode_file[0], 4 ) : $shortcode_file[0];
1046
+			$shortcode = strpos($shortcode_file[0], 'EES_') === 0 ? substr($shortcode_file[0], 4) : $shortcode_file[0];
1047 1047
 			// sanitize shortcode directory name
1048
-			$shortcode = sanitize_key( $shortcode );
1048
+			$shortcode = sanitize_key($shortcode);
1049 1049
 			// now we need to rebuild the shortcode path
1050
-			$shortcode_path = explode( DS, $shortcode_path );
1050
+			$shortcode_path = explode(DS, $shortcode_path);
1051 1051
 			// remove last segment
1052
-			array_pop( $shortcode_path );
1052
+			array_pop($shortcode_path);
1053 1053
 			// glue it back together
1054
-			$shortcode_path = implode( DS, $shortcode_path ) . DS;
1054
+			$shortcode_path = implode(DS, $shortcode_path).DS;
1055 1055
 		} else {
1056 1056
 			// we need to generate the filename based off of the folder name
1057 1057
 			// grab and sanitize shortcode directory name
1058
-			$shortcode = sanitize_key( basename( $shortcode_path ));
1059
-			$shortcode_path = rtrim( $shortcode_path, DS ) . DS;
1058
+			$shortcode = sanitize_key(basename($shortcode_path));
1059
+			$shortcode_path = rtrim($shortcode_path, DS).DS;
1060 1060
 		}
1061 1061
 		// create classname from shortcode directory or file name
1062
-		$shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode )));
1062
+		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
1063 1063
 		// add class prefix
1064
-		$shortcode_class = 'EES_' . $shortcode;
1064
+		$shortcode_class = 'EES_'.$shortcode;
1065 1065
 		// does the shortcode exist ?
1066
-		if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext )) {
1066
+		if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) {
1067 1067
 			$msg = sprintf(
1068
-				__( 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso' ),
1068
+				__('The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso'),
1069 1069
 				$shortcode_class,
1070
-				$shortcode_path . DS . $shortcode_class . $shortcode_ext
1070
+				$shortcode_path.DS.$shortcode_class.$shortcode_ext
1071 1071
 			);
1072
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1072
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1073 1073
 			return FALSE;
1074 1074
 		}
1075 1075
 		// load the shortcode class file
1076
-		require_once( $shortcode_path . $shortcode_class . $shortcode_ext );
1076
+		require_once($shortcode_path.$shortcode_class.$shortcode_ext);
1077 1077
 		// verify that class exists
1078
-		if ( ! class_exists( $shortcode_class )) {
1079
-			$msg = sprintf( __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), $shortcode_class );
1080
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1078
+		if ( ! class_exists($shortcode_class)) {
1079
+			$msg = sprintf(__('The requested %s shortcode class does not exist.', 'event_espresso'), $shortcode_class);
1080
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1081 1081
 			return FALSE;
1082 1082
 		}
1083
-		$shortcode = strtoupper( $shortcode );
1083
+		$shortcode = strtoupper($shortcode);
1084 1084
 		// add to array of registered shortcodes
1085
-		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1085
+		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext;
1086 1086
 		return TRUE;
1087 1087
 	}
1088 1088
 
@@ -1097,23 +1097,23 @@  discard block
 block discarded – undo
1097 1097
 	 */
1098 1098
 	private function _register_modules() {
1099 1099
 		// grab list of installed modules
1100
-		$modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR );
1100
+		$modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1101 1101
 		// filter list of modules to register
1102
-		$modules_to_register = apply_filters( 'FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register );
1102
+		$modules_to_register = apply_filters('FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register);
1103 1103
 
1104 1104
 
1105
-		if ( ! empty( $modules_to_register ) ) {
1105
+		if ( ! empty($modules_to_register)) {
1106 1106
 			// loop through folders
1107
-			foreach ( $modules_to_register as $module_path ) {
1107
+			foreach ($modules_to_register as $module_path) {
1108 1108
 				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1109
-				if ( $module_path != EE_MODULES . 'zzz-copy-this-module-template' && $module_path != EE_MODULES . 'gateways' ) {
1109
+				if ($module_path != EE_MODULES.'zzz-copy-this-module-template' && $module_path != EE_MODULES.'gateways') {
1110 1110
 					// add to list of installed modules
1111
-					EE_Config::register_module( $module_path );
1111
+					EE_Config::register_module($module_path);
1112 1112
 				}
1113 1113
 			}
1114 1114
 		}
1115 1115
 		// filter list of installed modules
1116
-		return apply_filters( 'FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules );
1116
+		return apply_filters('FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules);
1117 1117
 	}
1118 1118
 
1119 1119
 
@@ -1126,39 +1126,39 @@  discard block
 block discarded – undo
1126 1126
 	 *  @param 	string 		$module_path - full path up to and including module folder
1127 1127
 	 *  @return 	bool
1128 1128
 	 */
1129
-	public static function register_module( $module_path = NULL ) {
1130
-		do_action( 'AHEE__EE_Config__register_module__begin', $module_path );
1129
+	public static function register_module($module_path = NULL) {
1130
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1131 1131
 		$module_ext = '.module.php';
1132 1132
 		// make all separators match
1133
-		$module_path = str_replace( array( '\\', '/' ), DS, $module_path );
1133
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1134 1134
 		// does the file path INCLUDE the actual file name as part of the path ?
1135
-		if ( strpos( $module_path, $module_ext ) !== FALSE ) {
1135
+		if (strpos($module_path, $module_ext) !== FALSE) {
1136 1136
 			// grab and shortcode file name from directory name and break apart at dots
1137
-			$module_file = explode( '.', basename( $module_path ));
1137
+			$module_file = explode('.', basename($module_path));
1138 1138
 			// now we need to rebuild the shortcode path
1139
-			$module_path = explode( DS, $module_path );
1139
+			$module_path = explode(DS, $module_path);
1140 1140
 			// remove last segment
1141
-			array_pop( $module_path );
1141
+			array_pop($module_path);
1142 1142
 			// glue it back together
1143
-			$module_path = implode( DS, $module_path ) . DS;
1143
+			$module_path = implode(DS, $module_path).DS;
1144 1144
 			// take first segment from file name pieces and sanitize it
1145
-			$module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] );
1145
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1146 1146
 			// ensure class prefix is added
1147
-			$module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module;
1147
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1148 1148
 		} else {
1149 1149
 			// we need to generate the filename based off of the folder name
1150 1150
 			// grab and sanitize module name
1151
-			$module = strtolower( basename( $module_path ));
1152
-			$module = preg_replace( '/[^a-z0-9_\-]/', '', $module);
1151
+			$module = strtolower(basename($module_path));
1152
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1153 1153
 			// like trailingslashit()
1154
-			$module_path = rtrim( $module_path, DS ) . DS;
1154
+			$module_path = rtrim($module_path, DS).DS;
1155 1155
 			// create classname from module directory name
1156
-			$module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module )));
1156
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1157 1157
 			// add class prefix
1158
-			$module_class = 'EED_' . $module;
1158
+			$module_class = 'EED_'.$module;
1159 1159
 		}
1160 1160
 		// does the module exist ?
1161
-		if ( ! is_readable( $module_path . DS . $module_class . $module_ext )) {
1161
+		if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1162 1162
 			EE_Error::add_error(
1163 1163
 				sprintf(
1164 1164
 					__(
@@ -1174,16 +1174,16 @@  discard block
 block discarded – undo
1174 1174
 			return FALSE;
1175 1175
 		}
1176 1176
 		// load the module class file
1177
-		require_once( $module_path . $module_class . $module_ext );
1177
+		require_once($module_path.$module_class.$module_ext);
1178 1178
 		// verify that class exists
1179
-		if ( ! class_exists( $module_class )) {
1180
-			$msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class );
1181
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1179
+		if ( ! class_exists($module_class)) {
1180
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1181
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1182 1182
 			return FALSE;
1183 1183
 		}
1184 1184
 		// add to array of registered modules
1185
-		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1186
-		do_action( 'AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} );
1185
+		EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1186
+		do_action('AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} );
1187 1187
 		return TRUE;
1188 1188
 	}
1189 1189
 
@@ -1197,23 +1197,23 @@  discard block
 block discarded – undo
1197 1197
 	 */
1198 1198
 	private function _initialize_shortcodes() {
1199 1199
 		// cycle thru shortcode folders
1200
-		foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) {
1200
+		foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1201 1201
 			// add class prefix
1202
-			$shortcode_class = 'EES_' . $shortcode;
1202
+			$shortcode_class = 'EES_'.$shortcode;
1203 1203
 			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1204 1204
 			// which set hooks ?
1205
-			if ( is_admin() ) {
1205
+			if (is_admin()) {
1206 1206
 				// fire immediately
1207
-				call_user_func( array( $shortcode_class, 'set_hooks_admin' ));
1207
+				call_user_func(array($shortcode_class, 'set_hooks_admin'));
1208 1208
 			} else {
1209 1209
 				// delay until other systems are online
1210
-				add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $shortcode_class,'set_hooks' ));
1210
+				add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($shortcode_class, 'set_hooks'));
1211 1211
 				// convert classname to UPPERCASE and create WP shortcode.
1212
-				$shortcode_tag = strtoupper( $shortcode );
1212
+				$shortcode_tag = strtoupper($shortcode);
1213 1213
 				// but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor'
1214
-				if ( ! shortcode_exists( $shortcode_tag )) {
1214
+				if ( ! shortcode_exists($shortcode_tag)) {
1215 1215
 					// NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes()
1216
-					add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' ));
1216
+					add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
1217 1217
 				}
1218 1218
 			}
1219 1219
 		}
@@ -1230,15 +1230,15 @@  discard block
 block discarded – undo
1230 1230
 	 */
1231 1231
 	private function _initialize_modules() {
1232 1232
 		// cycle thru shortcode folders
1233
-		foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) {
1233
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1234 1234
 			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1235 1235
 			// which set hooks ?
1236
-			if ( is_admin() ) {
1236
+			if (is_admin()) {
1237 1237
 				// fire immediately
1238
-				call_user_func( array( $module_class, 'set_hooks_admin' ));
1238
+				call_user_func(array($module_class, 'set_hooks_admin'));
1239 1239
 			} else {
1240 1240
 				// delay until other systems are online
1241
-				add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $module_class,'set_hooks' ));
1241
+				add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($module_class, 'set_hooks'));
1242 1242
 			}
1243 1243
 		}
1244 1244
 	}
@@ -1256,26 +1256,26 @@  discard block
 block discarded – undo
1256 1256
 	 *  @param 	string 		$key - url param key indicating a route is being called
1257 1257
 	 *  @return 	bool
1258 1258
 	 */
1259
-	public static function register_route( $route = NULL, $module = NULL, $method_name = NULL, $key = 'ee' ) {
1260
-		do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name );
1261
-		$module = str_replace( 'EED_', '', $module );
1262
-		$module_class = 'EED_' . $module;
1263
-		if ( ! isset( EE_Registry::instance()->modules->{$module_class} )) {
1264
-			$msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module );
1265
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1259
+	public static function register_route($route = NULL, $module = NULL, $method_name = NULL, $key = 'ee') {
1260
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1261
+		$module = str_replace('EED_', '', $module);
1262
+		$module_class = 'EED_'.$module;
1263
+		if ( ! isset(EE_Registry::instance()->modules->{$module_class} )) {
1264
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1265
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1266 1266
 			return FALSE;
1267 1267
 		}
1268
-		if ( empty( $route )) {
1269
-			$msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route );
1270
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1268
+		if (empty($route)) {
1269
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1270
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1271 1271
 			return FALSE;
1272 1272
 		}
1273
-		if ( ! method_exists ( 'EED_' . $module, $method_name )) {
1274
-			$msg = sprintf( __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), $route );
1275
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1273
+		if ( ! method_exists('EED_'.$module, $method_name)) {
1274
+			$msg = sprintf(__('A valid class method for the %s route has not been supplied.', 'event_espresso'), $route);
1275
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1276 1276
 			return FALSE;
1277 1277
 		}
1278
-		EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name );
1278
+		EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1279 1279
 		return TRUE;
1280 1280
 	}
1281 1281
 
@@ -1289,11 +1289,11 @@  discard block
 block discarded – undo
1289 1289
 	 *  @param 	string 		$key - url param key indicating a route is being called
1290 1290
 	 *  @return 	string
1291 1291
 	 */
1292
-	public static function get_route( $route = NULL, $key = 'ee' ) {
1293
-		do_action( 'AHEE__EE_Config__get_route__begin',$route );
1294
-		$route = apply_filters( 'FHEE__EE_Config__get_route',$route );
1295
-		if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] )) {
1296
-			return EE_Config::$_module_route_map[ $key ][ $route ];
1292
+	public static function get_route($route = NULL, $key = 'ee') {
1293
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1294
+		$route = apply_filters('FHEE__EE_Config__get_route', $route);
1295
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1296
+			return EE_Config::$_module_route_map[$key][$route];
1297 1297
 		}
1298 1298
 		return NULL;
1299 1299
 	}
@@ -1322,35 +1322,35 @@  discard block
 block discarded – undo
1322 1322
 	 * @param    string 		$key - url param key indicating a route is being called
1323 1323
 	 * @return    bool
1324 1324
 	 */
1325
-	public static function register_forward( $route = NULL, $status = 0, $forward = NULL, $key = 'ee' ) {
1326
-		do_action( 'AHEE__EE_Config__register_forward',$route,$status,$forward );
1327
-		if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) ||  empty( $route )) {
1328
-			$msg = sprintf( __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), $route );
1329
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1325
+	public static function register_forward($route = NULL, $status = 0, $forward = NULL, $key = 'ee') {
1326
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1327
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1328
+			$msg = sprintf(__('The module route %s for this forward has not been registered.', 'event_espresso'), $route);
1329
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1330 1330
 			return FALSE;
1331 1331
 		}
1332
-		if ( empty( $forward )) {
1333
-			$msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route );
1334
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1332
+		if (empty($forward)) {
1333
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1335 1335
 			return FALSE;
1336 1336
 		}
1337
-		if ( is_array( $forward )) {
1338
-			if ( ! isset( $forward[1] )) {
1339
-				$msg = sprintf( __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), $route );
1340
-				EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1337
+		if (is_array($forward)) {
1338
+			if ( ! isset($forward[1])) {
1339
+				$msg = sprintf(__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), $route);
1340
+				EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1341 1341
 				return FALSE;
1342 1342
 			}
1343
-			if ( ! method_exists( $forward[0], $forward[1] )) {
1344
-				$msg = sprintf( __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward[1], $route );
1345
-				EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1343
+			if ( ! method_exists($forward[0], $forward[1])) {
1344
+				$msg = sprintf(__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward[1], $route);
1345
+				EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1346 1346
 				return FALSE;
1347 1347
 			}
1348
-		} else if ( ! function_exists( $forward )) {
1349
-			$msg = sprintf( __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward, $route );
1350
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1348
+		} else if ( ! function_exists($forward)) {
1349
+			$msg = sprintf(__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward, $route);
1350
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1351 1351
 			return FALSE;
1352 1352
 		}
1353
-		EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward;
1353
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1354 1354
 		return TRUE;
1355 1355
 	}
1356 1356
 
@@ -1365,10 +1365,10 @@  discard block
 block discarded – undo
1365 1365
 	 *  @param    string 		$key - url param key indicating a route is being called
1366 1366
 	 *  @return 	string
1367 1367
 	 */
1368
-	public static function get_forward( $route = NULL, $status = 0, $key = 'ee' ) {
1369
-		do_action( 'AHEE__EE_Config__get_forward__begin',$route,$status );
1370
-		if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] )) {
1371
-			return apply_filters( 'FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], $route,$status );
1368
+	public static function get_forward($route = NULL, $status = 0, $key = 'ee') {
1369
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1370
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1371
+			return apply_filters('FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[$key][$route][$status], $route, $status);
1372 1372
 		}
1373 1373
 		return NULL;
1374 1374
 	}
@@ -1385,19 +1385,19 @@  discard block
 block discarded – undo
1385 1385
 	 * @param    string 		$key - url param key indicating a route is being called
1386 1386
 	 * @return    bool
1387 1387
 	 */
1388
-	public static function register_view( $route = NULL, $status = 0, $view = NULL, $key = 'ee' ) {
1389
-		do_action( 'AHEE__EE_Config__register_view__begin',$route,$status,$view );
1390
-		if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) ||  empty( $route )) {
1391
-			$msg = sprintf( __( 'The module route %s for this view has not been registered.', 'event_espresso' ), $route );
1392
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1388
+	public static function register_view($route = NULL, $status = 0, $view = NULL, $key = 'ee') {
1389
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1390
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1391
+			$msg = sprintf(__('The module route %s for this view has not been registered.', 'event_espresso'), $route);
1392
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1393 1393
 			return FALSE;
1394 1394
 		}
1395
-		if ( ! is_readable( $view )) {
1396
-			$msg = sprintf( __( 'The %s view file could not be found or is not readable due to file permissions.', 'event_espresso' ), $view );
1397
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1395
+		if ( ! is_readable($view)) {
1396
+			$msg = sprintf(__('The %s view file could not be found or is not readable due to file permissions.', 'event_espresso'), $view);
1397
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1398 1398
 			return FALSE;
1399 1399
 		}
1400
-		EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view;
1400
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1401 1401
 		return TRUE;
1402 1402
 	}
1403 1403
 
@@ -1414,10 +1414,10 @@  discard block
 block discarded – undo
1414 1414
 	 *  @param    string 		$key - url param key indicating a route is being called
1415 1415
 	 *  @return 	string
1416 1416
 	 */
1417
-	public static function get_view( $route = NULL, $status = 0, $key = 'ee' ) {
1418
-		do_action( 'AHEE__EE_Config__get_view__begin',$route,$status );
1419
-		if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] )) {
1420
-			return apply_filters( 'FHEE__EE_Config__get_view', EE_Config::$_module_view_map[ $key ][ $route ][ $status ], $route,$status );
1417
+	public static function get_view($route = NULL, $status = 0, $key = 'ee') {
1418
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1419
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1420
+			return apply_filters('FHEE__EE_Config__get_view', EE_Config::$_module_view_map[$key][$route][$status], $route, $status);
1421 1421
 		}
1422 1422
 		return NULL;
1423 1423
 	}
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 
1426 1426
 
1427 1427
 	public function shutdown() {
1428
-		update_option( 'ee_config_option_names', $this->_config_option_names );
1428
+		update_option('ee_config_option_names', $this->_config_option_names);
1429 1429
 	}
1430 1430
 
1431 1431
 
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
  * magic functions in use, except we'll allow them to magically set and get stuff...
1442 1442
  * basically, they should just be well-defined stdClasses
1443 1443
  */
1444
-class EE_Config_Base{
1444
+class EE_Config_Base {
1445 1445
 
1446 1446
 	/**
1447 1447
 	 * Utility function for escaping the value of a property and returning.
@@ -1450,13 +1450,13 @@  discard block
 block discarded – undo
1450 1450
 	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1451 1451
 	 * @throws \EE_Error
1452 1452
 	 */
1453
-	public function get_pretty( $property ) {
1454
-		if ( ! property_exists( $this, $property ) ) {
1455
-			throw new EE_Error( sprintf( __('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso' ), get_class( $this ), $property ) );
1453
+	public function get_pretty($property) {
1454
+		if ( ! property_exists($this, $property)) {
1455
+			throw new EE_Error(sprintf(__('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso'), get_class($this), $property));
1456 1456
 		}
1457 1457
 		//just handling escaping of strings for now.
1458
-		if ( is_string( $this->{$property} ) ) {
1459
-			return stripslashes( $this->{$property} );
1458
+		if (is_string($this->{$property} )) {
1459
+			return stripslashes($this->{$property} );
1460 1460
 		}
1461 1461
 		return $this->{$property};
1462 1462
 	}
@@ -1465,19 +1465,19 @@  discard block
 block discarded – undo
1465 1465
 
1466 1466
 	public function populate() {
1467 1467
 		//grab defaults via a new instance of this class.
1468
-		$class_name = get_class( $this );
1468
+		$class_name = get_class($this);
1469 1469
 		$defaults = new $class_name;
1470 1470
 
1471 1471
 		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1472 1472
 		//default from our $defaults object.
1473
-		foreach ( get_object_vars( $defaults ) as $property => $value ) {
1474
-			if ( is_null( $this->{$property} ) ) {
1473
+		foreach (get_object_vars($defaults) as $property => $value) {
1474
+			if (is_null($this->{$property} )) {
1475 1475
 				$this->{$property} = $value;
1476 1476
 			}
1477 1477
 		}
1478 1478
 
1479 1479
 		//cleanup
1480
-		unset( $defaults );
1480
+		unset($defaults);
1481 1481
 	}
1482 1482
 
1483 1483
 
@@ -1569,12 +1569,12 @@  discard block
 block discarded – undo
1569 1569
 	 */
1570 1570
 	public function __construct() {
1571 1571
 		$current_network_main_site = is_multisite() ? get_current_site() : NULL;
1572
-		$current_main_site_id = !empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1;
1572
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1573 1573
 		// set default organization settings
1574 1574
 		$this->current_blog_id = get_current_blog_id();
1575 1575
 		$this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id;
1576
-		$this->ee_ueip_optin = is_main_site() ? get_option( 'ee_ueip_optin', TRUE ) : get_blog_option( $current_main_site_id, 'ee_ueip_optin', TRUE );
1577
-		$this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', FALSE ) : TRUE;
1576
+		$this->ee_ueip_optin = is_main_site() ? get_option('ee_ueip_optin', TRUE) : get_blog_option($current_main_site_id, 'ee_ueip_optin', TRUE);
1577
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', FALSE) : TRUE;
1578 1578
 		$this->post_shortcodes = array();
1579 1579
 		$this->module_route_map = array();
1580 1580
 		$this->module_forward_map = array();
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
 		$this->event_cpt_slug = __('events', 'event_espresso');
1594 1594
 
1595 1595
 		//ueip constant check
1596
-		if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) {
1596
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1597 1597
 			$this->ee_ueip_optin = FALSE;
1598 1598
 			$this->ee_ueip_has_notified = TRUE;
1599 1599
 		}
@@ -1633,8 +1633,8 @@  discard block
 block discarded – undo
1633 1633
 	 *  @return 	string
1634 1634
 	 */
1635 1635
 	public function reg_page_url() {
1636
-		if ( ! $this->reg_page_url ) {
1637
-			$this->reg_page_url = get_permalink( $this->reg_page_id ) . '#checkout';
1636
+		if ( ! $this->reg_page_url) {
1637
+			$this->reg_page_url = get_permalink($this->reg_page_id).'#checkout';
1638 1638
 		}
1639 1639
 		return $this->reg_page_url;
1640 1640
 	}
@@ -1647,12 +1647,12 @@  discard block
 block discarded – undo
1647 1647
 	 *  @return 	string
1648 1648
 	 */
1649 1649
 	public function txn_page_url($query_args = array()) {
1650
-		if ( ! $this->txn_page_url ) {
1651
-			$this->txn_page_url = get_permalink( $this->txn_page_id );
1650
+		if ( ! $this->txn_page_url) {
1651
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1652 1652
 		}
1653
-		if($query_args){
1654
-			return add_query_arg($query_args,$this->txn_page_url);
1655
-		}else{
1653
+		if ($query_args) {
1654
+			return add_query_arg($query_args, $this->txn_page_url);
1655
+		} else {
1656 1656
 			return $this->txn_page_url;
1657 1657
 		}
1658 1658
 	}
@@ -1664,12 +1664,12 @@  discard block
 block discarded – undo
1664 1664
 	 *  @return 	string
1665 1665
 	 */
1666 1666
 	public function thank_you_page_url($query_args = array()) {
1667
-		if ( ! $this->thank_you_page_url ) {
1668
-			$this->thank_you_page_url = get_permalink( $this->thank_you_page_id );
1667
+		if ( ! $this->thank_you_page_url) {
1668
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1669 1669
 		}
1670
-		if($query_args){
1671
-			return add_query_arg($query_args,$this->thank_you_page_url);
1672
-		}else{
1670
+		if ($query_args) {
1671
+			return add_query_arg($query_args, $this->thank_you_page_url);
1672
+		} else {
1673 1673
 			return $this->thank_you_page_url;
1674 1674
 		}
1675 1675
 	}
@@ -1680,8 +1680,8 @@  discard block
 block discarded – undo
1680 1680
 	 *  @return 	string
1681 1681
 	 */
1682 1682
 	public function cancel_page_url() {
1683
-		if ( ! $this->cancel_page_url ) {
1684
-			$this->cancel_page_url = get_permalink( $this->cancel_page_id );
1683
+		if ( ! $this->cancel_page_url) {
1684
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1685 1685
 		}
1686 1686
 		return $this->cancel_page_url;
1687 1687
 	}
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
 		//reset all url properties
1710 1710
 		$this->_reset_urls();
1711 1711
 		//return what to save to db
1712
-		return array_keys( get_object_vars( $this ) );
1712
+		return array_keys(get_object_vars($this));
1713 1713
 	}
1714 1714
 
1715 1715
 }
@@ -1941,39 +1941,39 @@  discard block
 block discarded – undo
1941 1941
 	 * @param null $CNT_ISO
1942 1942
 	 * @return \EE_Currency_Config
1943 1943
 	 */
1944
-	public function __construct( $CNT_ISO = NULL ) {
1944
+	public function __construct($CNT_ISO = NULL) {
1945 1945
 
1946 1946
 		// get country code from organization settings or use default
1947
-		$ORG_CNT = isset( EE_Registry::instance()->CFG->organization ) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL;
1947
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL;
1948 1948
 		// but override if requested
1949
-		$CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT;
1950
-		EE_Registry::instance()->load_helper( 'Activation' );
1949
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
1950
+		EE_Registry::instance()->load_helper('Activation');
1951 1951
 		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
1952
-		if ( ! empty( $CNT_ISO ) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists( EE_Registry::instance()->load_model( 'Country' )->table() ) ) {
1952
+		if ( ! empty($CNT_ISO) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists(EE_Registry::instance()->load_model('Country')->table())) {
1953 1953
 			// retrieve the country settings from the db, just in case they have been customized
1954
-			$country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO );
1955
-			if ( $country instanceof EE_Country ) {
1956
-				$this->code = $country->currency_code(); 	// currency code: USD, CAD, EUR
1957
-				$this->name = $country->currency_name_single();	// Dollar
1958
-				$this->plural = $country->currency_name_plural(); 	// Dollars
1959
-				$this->sign =  $country->currency_sign(); 			// currency sign: $
1960
-				$this->sign_b4 = $country->currency_sign_before(); 		// currency sign before or after: $TRUE  or  FALSE$
1961
-				$this->dec_plc = $country->currency_decimal_places();	// decimal places: 2 = 0.00  3 = 0.000
1962
-				$this->dec_mrk = $country->currency_decimal_mark();	// decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1963
-				$this->thsnds = $country->currency_thousands_separator();	// thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1954
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
1955
+			if ($country instanceof EE_Country) {
1956
+				$this->code = $country->currency_code(); // currency code: USD, CAD, EUR
1957
+				$this->name = $country->currency_name_single(); // Dollar
1958
+				$this->plural = $country->currency_name_plural(); // Dollars
1959
+				$this->sign = $country->currency_sign(); // currency sign: $
1960
+				$this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE  or  FALSE$
1961
+				$this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
1962
+				$this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1963
+				$this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1964 1964
 			}
1965 1965
 		}
1966 1966
 		// fallback to hardcoded defaults, in case the above failed
1967
-		if ( empty( $this->code )) {
1967
+		if (empty($this->code)) {
1968 1968
 			// set default currency settings
1969
-			$this->code = 'USD'; 	// currency code: USD, CAD, EUR
1970
-			$this->name = __( 'Dollar', 'event_espresso' ); 	// Dollar
1971
-			$this->plural = __( 'Dollars', 'event_espresso' ); 	// Dollars
1972
-			$this->sign =  '$'; 	// currency sign: $
1973
-			$this->sign_b4 = TRUE; 	// currency sign before or after: $TRUE  or  FALSE$
1974
-			$this->dec_plc = 2; 	// decimal places: 2 = 0.00  3 = 0.000
1975
-			$this->dec_mrk = '.'; 	// decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1976
-			$this->thsnds = ','; 	// thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1969
+			$this->code = 'USD'; // currency code: USD, CAD, EUR
1970
+			$this->name = __('Dollar', 'event_espresso'); // Dollar
1971
+			$this->plural = __('Dollars', 'event_espresso'); // Dollars
1972
+			$this->sign = '$'; // currency sign: $
1973
+			$this->sign_b4 = TRUE; // currency sign before or after: $TRUE  or  FALSE$
1974
+			$this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
1975
+			$this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1976
+			$this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1977 1977
 		}
1978 1978
 	}
1979 1979
 }
@@ -2113,7 +2113,7 @@  discard block
 block discarded – undo
2113 2113
 	 * @since 4.8.8.rc.019
2114 2114
 	 */
2115 2115
 	public function do_hooks() {
2116
-		add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' ));
2116
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2117 2117
 	}
2118 2118
 
2119 2119
 
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
 	 * @return void
2122 2122
 	 */
2123 2123
 	public function set_default_reg_status_on_EEM_Event() {
2124
-		EEM_Event::set_default_reg_status( $this->default_STS_ID );
2124
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2125 2125
 	}
2126 2126
 
2127 2127
 
@@ -2226,10 +2226,10 @@  discard block
 block discarded – undo
2226 2226
 	 * @param bool $reset
2227 2227
 	 * @return string
2228 2228
 	 */
2229
-	public function log_file_name( $reset = FALSE ) {
2230
-		if ( empty( $this->log_file_name ) || $reset ) {
2231
-			$this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', TRUE ))) . '.txt';
2232
-			EE_Config::instance()->update_espresso_config( FALSE, FALSE );
2229
+	public function log_file_name($reset = FALSE) {
2230
+		if (empty($this->log_file_name) || $reset) {
2231
+			$this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', TRUE))).'.txt';
2232
+			EE_Config::instance()->update_espresso_config(FALSE, FALSE);
2233 2233
 		}
2234 2234
 		return $this->log_file_name;
2235 2235
 	}
@@ -2241,10 +2241,10 @@  discard block
 block discarded – undo
2241 2241
 	 * @param bool $reset
2242 2242
 	 * @return string
2243 2243
 	 */
2244
-	public function debug_file_name( $reset = FALSE ) {
2245
-		if ( empty( $this->debug_file_name ) || $reset ) {
2246
-			$this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', TRUE ))) . '.txt';
2247
-			EE_Config::instance()->update_espresso_config( FALSE, FALSE );
2244
+	public function debug_file_name($reset = FALSE) {
2245
+		if (empty($this->debug_file_name) || $reset) {
2246
+			$this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', TRUE))).'.txt';
2247
+			EE_Config::instance()->update_espresso_config(FALSE, FALSE);
2248 2248
 		}
2249 2249
 		return $this->debug_file_name;
2250 2250
 	}
@@ -2417,21 +2417,21 @@  discard block
 block discarded – undo
2417 2417
 		// set default map settings
2418 2418
 		$this->use_google_maps = TRUE;
2419 2419
 		// for event details pages (reg page)
2420
-		$this->event_details_map_width = 585; 			// ee_map_width_single
2421
-		$this->event_details_map_height = 362; 			// ee_map_height_single
2422
-		$this->event_details_map_zoom = 14; 			// ee_map_zoom_single
2423
-		$this->event_details_display_nav = TRUE; 			// ee_map_nav_display_single
2424
-		$this->event_details_nav_size = FALSE; 			// ee_map_nav_size_single
2425
-		$this->event_details_control_type = 'default'; 		// ee_map_type_control_single
2426
-		$this->event_details_map_align = 'center'; 			// ee_map_align_single
2420
+		$this->event_details_map_width = 585; // ee_map_width_single
2421
+		$this->event_details_map_height = 362; // ee_map_height_single
2422
+		$this->event_details_map_zoom = 14; // ee_map_zoom_single
2423
+		$this->event_details_display_nav = TRUE; // ee_map_nav_display_single
2424
+		$this->event_details_nav_size = FALSE; // ee_map_nav_size_single
2425
+		$this->event_details_control_type = 'default'; // ee_map_type_control_single
2426
+		$this->event_details_map_align = 'center'; // ee_map_align_single
2427 2427
 		// for event list pages
2428
-		$this->event_list_map_width = 300; 			// ee_map_width
2429
-		$this->event_list_map_height = 185; 		// ee_map_height
2430
-		$this->event_list_map_zoom = 12; 			// ee_map_zoom
2431
-		$this->event_list_display_nav = FALSE; 		// ee_map_nav_display
2432
-		$this->event_list_nav_size = TRUE; 			// ee_map_nav_size
2433
-		$this->event_list_control_type = 'dropdown'; 		// ee_map_type_control
2434
-		$this->event_list_map_align = 'center'; 			// ee_map_align
2428
+		$this->event_list_map_width = 300; // ee_map_width
2429
+		$this->event_list_map_height = 185; // ee_map_height
2430
+		$this->event_list_map_zoom = 12; // ee_map_zoom
2431
+		$this->event_list_display_nav = FALSE; // ee_map_nav_display
2432
+		$this->event_list_nav_size = TRUE; // ee_map_nav_size
2433
+		$this->event_list_control_type = 'dropdown'; // ee_map_type_control
2434
+		$this->event_list_map_align = 'center'; // ee_map_align
2435 2435
 	}
2436 2436
 
2437 2437
 }
@@ -2442,7 +2442,7 @@  discard block
 block discarded – undo
2442 2442
 /**
2443 2443
  * stores Events_Archive settings
2444 2444
  */
2445
-class EE_Events_Archive_Config extends EE_Config_Base{
2445
+class EE_Events_Archive_Config extends EE_Config_Base {
2446 2446
 
2447 2447
 	public $display_status_banner;
2448 2448
 	public $display_description;
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
 	/**
2462 2462
 	 *	class constructor
2463 2463
 	 */
2464
-	public function __construct(){
2464
+	public function __construct() {
2465 2465
 		$this->display_status_banner = 0;
2466 2466
 		$this->display_description = 1;
2467 2467
 		$this->display_ticket_selector = 0;
@@ -2481,7 +2481,7 @@  discard block
 block discarded – undo
2481 2481
 /**
2482 2482
  * Stores Event_Single_Config settings
2483 2483
  */
2484
-class EE_Event_Single_Config extends EE_Config_Base{
2484
+class EE_Event_Single_Config extends EE_Config_Base {
2485 2485
 
2486 2486
 	public $display_status_banner_single;
2487 2487
 	public $display_venue;
@@ -2510,7 +2510,7 @@  discard block
 block discarded – undo
2510 2510
 /**
2511 2511
  * Stores Ticket_Selector_Config settings
2512 2512
  */
2513
-class EE_Ticket_Selector_Config extends EE_Config_Base{
2513
+class EE_Ticket_Selector_Config extends EE_Config_Base {
2514 2514
 	public $show_ticket_sale_columns;
2515 2515
 	public $show_ticket_details;
2516 2516
 	public $show_expired_tickets;
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
 	 * @return void
2565 2565
 	 */
2566 2566
 	protected function _set_php_values() {
2567
-		$this->php->max_input_vars = ini_get( 'max_input_vars' );
2567
+		$this->php->max_input_vars = ini_get('max_input_vars');
2568 2568
 		$this->php->version = phpversion();
2569 2569
 	}
2570 2570
 
@@ -2583,8 +2583,8 @@  discard block
 block discarded – undo
2583 2583
 	 *         @type string $msg 		Any message to be displayed.
2584 2584
 	 * }
2585 2585
 	 */
2586
-	public function max_input_vars_limit_check( $input_count = 0 ) {
2587
-		if ( ( $input_count >= $this->php->max_input_vars ) && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >=9 ) ) {
2586
+	public function max_input_vars_limit_check($input_count = 0) {
2587
+		if (($input_count >= $this->php->max_input_vars) && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)) {
2588 2588
 			return  __('The number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.', 'event_espresso');
2589 2589
 		} else {
2590 2590
 			return '';
@@ -2620,7 +2620,7 @@  discard block
 block discarded – undo
2620 2620
  * stores payment gateway info
2621 2621
  * @deprecated
2622 2622
  */
2623
-class EE_Gateway_Config extends EE_Config_Base{
2623
+class EE_Gateway_Config extends EE_Config_Base {
2624 2624
 
2625 2625
 	/**
2626 2626
 	 * Array with keys that are payment gateways slugs, and values are arrays
@@ -2642,9 +2642,9 @@  discard block
 block discarded – undo
2642 2642
 	 *	class constructor
2643 2643
 	 * @deprecated
2644 2644
 	 */
2645
-	public function __construct(){
2645
+	public function __construct() {
2646 2646
 		$this->payment_settings = array();
2647
-		$this->active_gateways = array( 'Invoice' => FALSE );
2647
+		$this->active_gateways = array('Invoice' => FALSE);
2648 2648
 	}
2649 2649
 }
2650 2650
 
Please login to merge, or discard this patch.
modules/single_page_checkout/inc/EE_Checkout.class.php 1 patch
Spacing   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 		$this->reg_page_base_url = EE_Registry::instance()->CFG->core->reg_page_url();
243 243
 		$this->thank_you_page_url = EE_Registry::instance()->CFG->core->thank_you_page_url();
244 244
 		$this->cancel_page_url = EE_Registry::instance()->CFG->core->cancel_page_url();
245
-		$this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', TRUE );
245
+		$this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', TRUE);
246 246
 		$this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->ajax;
247
-		$this->reg_cache_where_params = array( 'order_by' => array( 'REG_count' => 'ASC' ));
247
+		$this->reg_cache_where_params = array('order_by' => array('REG_count' => 'ASC'));
248 248
 	}
249 249
 
250 250
 
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 	 * @return array
255 255
 	 */
256 256
 	public function any_reg_status_updated() {
257
-		foreach ( $this->reg_status_updated as $reg_status ) {
258
-			if ( $reg_status ) {
257
+		foreach ($this->reg_status_updated as $reg_status) {
258
+			if ($reg_status) {
259 259
 				return true;
260 260
 			}
261 261
 		}
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	 * @param $REG_ID
269 269
 	 * @return array
270 270
 	 */
271
-	public function reg_status_updated( $REG_ID ) {
272
-		return isset( $this->reg_status_updated[ $REG_ID ] ) ? $this->reg_status_updated[ $REG_ID ] : false;
271
+	public function reg_status_updated($REG_ID) {
272
+		return isset($this->reg_status_updated[$REG_ID]) ? $this->reg_status_updated[$REG_ID] : false;
273 273
 	}
274 274
 
275 275
 
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 	 * @param $REG_ID
279 279
 	 * @param $reg_status
280 280
 	 */
281
-	public function set_reg_status_updated( $REG_ID, $reg_status ) {
282
-		$this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN );
281
+	public function set_reg_status_updated($REG_ID, $reg_status) {
282
+		$this->reg_status_updated[$REG_ID] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN);
283 283
 	}
284 284
 
285 285
 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 * can ONLY be set by the  Finalize_Registration reg step
301 301
 	 */
302 302
 	public function set_exit_spco() {
303
-		if ( $this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) {
303
+		if ($this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
304 304
 			$this->exit_spco = true;
305 305
 		}
306 306
 	}
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	public function reset_for_current_request() {
319 319
 		$this->process_form_submission = FALSE;
320
-		$this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', true );
320
+		$this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true);
321 321
 		$this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->front_ajax;
322 322
 		$this->continue_reg = true;
323 323
 		$this->redirect = false;
324 324
 		// don't reset the cached redirect form if we're about to be asked to display it !!!
325
-		if ( EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ) !== 'redirect_form' ) {
325
+		if (EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step') !== 'redirect_form') {
326 326
 			$this->redirect_form = '';
327 327
 		}
328 328
 		$this->redirect_url = '';
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param EE_SPCO_Reg_Step $reg_step_obj
340 340
 	 * @return    void
341 341
 	 */
342
-	public function add_reg_step( EE_SPCO_Reg_Step $reg_step_obj ) {
343
-		$this->reg_steps[ $reg_step_obj->slug()  ] = $reg_step_obj;
342
+	public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj) {
343
+		$this->reg_steps[$reg_step_obj->slug()] = $reg_step_obj;
344 344
 	}
345 345
 
346 346
 
@@ -356,22 +356,22 @@  discard block
 block discarded – undo
356 356
 	 * @param string $reg_step_slug
357 357
 	 * @return    void
358 358
 	 */
359
-	public function skip_reg_step( $reg_step_slug = '' ) {
360
-		$step_to_skip = $this->find_reg_step( $reg_step_slug );
361
-		if ( $step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step() ) {
362
-			$step_to_skip->set_is_current_step( false );
359
+	public function skip_reg_step($reg_step_slug = '') {
360
+		$step_to_skip = $this->find_reg_step($reg_step_slug);
361
+		if ($step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step()) {
362
+			$step_to_skip->set_is_current_step(false);
363 363
 			$step_to_skip->set_completed();
364 364
 			// advance to the next step
365
-			$this->set_current_step( $this->next_step->slug() );
365
+			$this->set_current_step($this->next_step->slug());
366 366
 			// also reset the step param in the request in case any other code references that directly
367
-			EE_Registry::instance()->REQ->set( 'step', $this->current_step->slug() );
367
+			EE_Registry::instance()->REQ->set('step', $this->current_step->slug());
368 368
 			// since we are skipping a step and setting the current step to be what was previously the next step,
369 369
 			// we need to check that the next step is now correct, and not still set to the current step.
370
-			if ( $this->current_step->slug() == $this->next_step->slug() ) {
370
+			if ($this->current_step->slug() == $this->next_step->slug()) {
371 371
 				// correctly setup the next step
372 372
 				$this->set_next_step();
373 373
 			}
374
-			$this->set_reg_step_initiated( $this->current_step );
374
+			$this->set_reg_step_initiated($this->current_step);
375 375
 		}
376 376
 	}
377 377
 
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
 	 * @param bool   $reset whether to reset reg steps after removal
386 386
 	 * @throws EE_Error
387 387
 	 */
388
-	public function remove_reg_step( $reg_step_slug = '', $reset = true ) {
389
-		unset( $this->reg_steps[ $reg_step_slug  ] );
390
-		if ( $this->transaction instanceof EE_Transaction ) {
388
+	public function remove_reg_step($reg_step_slug = '', $reset = true) {
389
+		unset($this->reg_steps[$reg_step_slug]);
390
+		if ($this->transaction instanceof EE_Transaction) {
391 391
 			/** @type EE_Transaction_Processor $transaction_processor */
392
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
392
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
393 393
 			// now remove reg step from TXN and save
394
-			$transaction_processor->remove_reg_step( $this->transaction, $reg_step_slug );
394
+			$transaction_processor->remove_reg_step($this->transaction, $reg_step_slug);
395 395
 			$this->transaction->save();
396 396
 		}
397
-		if ( $reset ) {
397
+		if ($reset) {
398 398
 			$this->reset_reg_steps();
399 399
 		}
400 400
 	}
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 	 * @param int    $order
410 410
 	 * @return    void
411 411
 	 */
412
-	public function set_reg_step_order( $reg_step_slug = '', $order = 100 ) {
413
-		if ( isset( $this->reg_steps[ $reg_step_slug  ] )) {
414
-			$this->reg_steps[ $reg_step_slug ]->set_order( $order );
412
+	public function set_reg_step_order($reg_step_slug = '', $order = 100) {
413
+		if (isset($this->reg_steps[$reg_step_slug])) {
414
+			$this->reg_steps[$reg_step_slug]->set_order($order);
415 415
 		}
416 416
 	}
417 417
 
@@ -424,25 +424,25 @@  discard block
 block discarded – undo
424 424
 	 * @param string $current_step
425 425
 	 * @return    void
426 426
 	 */
427
-	public function set_current_step( $current_step ) {
427
+	public function set_current_step($current_step) {
428 428
 		// grab what step we're on
429
-		$this->current_step = isset( $this->reg_steps[ $current_step ] ) ? $this->reg_steps[ $current_step ] : reset( $this->reg_steps );
429
+		$this->current_step = isset($this->reg_steps[$current_step]) ? $this->reg_steps[$current_step] : reset($this->reg_steps);
430 430
 		// verify instance
431
-		if ( $this->current_step instanceof EE_SPCO_Reg_Step ) {
431
+		if ($this->current_step instanceof EE_SPCO_Reg_Step) {
432 432
 			// we don't want to repeat completed steps if this is the first time through SPCO
433
-			if ( $this->continue_reg && $this->current_step->completed() && ! $this->revisit ) {
433
+			if ($this->continue_reg && $this->current_step->completed() && ! $this->revisit) {
434 434
 				// so advance to the next step
435 435
 				$this->set_next_step();
436
-				if ( $this->next_step instanceof EE_SPCO_Reg_Step ) {
436
+				if ($this->next_step instanceof EE_SPCO_Reg_Step) {
437 437
 					// and attempt to set it as the current step
438
-					$this->set_current_step( $this->next_step->slug() );
438
+					$this->set_current_step($this->next_step->slug());
439 439
 				}
440 440
 				return;
441 441
 			}
442
-			$this->current_step->set_is_current_step( TRUE );
442
+			$this->current_step->set_is_current_step(TRUE);
443 443
 		} else {
444 444
 			EE_Error::add_error(
445
-				__( 'The current step could not be set.', 'event_espresso' ),
445
+				__('The current step could not be set.', 'event_espresso'),
446 446
 				__FILE__, __FUNCTION__, __LINE__
447 447
 			);
448 448
 		}
@@ -459,20 +459,20 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	public function set_next_step() {
461 461
 		// set pointer to start of array
462
-		reset( $this->reg_steps );
462
+		reset($this->reg_steps);
463 463
 		// if there is more than one step
464
-		if ( count( $this->reg_steps ) > 1 ) {
464
+		if (count($this->reg_steps) > 1) {
465 465
 			// advance to the current step and set pointer
466
-			while ( key( $this->reg_steps ) != $this->current_step->slug() && key( $this->reg_steps ) != '' ) {
467
-				next( $this->reg_steps );
466
+			while (key($this->reg_steps) != $this->current_step->slug() && key($this->reg_steps) != '') {
467
+				next($this->reg_steps);
468 468
 			}
469 469
 		}
470 470
 		// advance one more spot ( if it exists )
471
-		$this->next_step = next( $this->reg_steps );
471
+		$this->next_step = next($this->reg_steps);
472 472
 		// verify instance
473
-		$this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step  : NULL;
473
+		$this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL;
474 474
 		// then back to current step to reset
475
-		prev( $this->reg_steps );
475
+		prev($this->reg_steps);
476 476
 	}
477 477
 
478 478
 
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
 	 *  @return 	EE_SPCO_Reg_Step | null
487 487
 	 */
488 488
 	public function get_next_reg_step() {
489
-		$next = next( $this->reg_steps );
490
-		prev( $this->reg_steps );
489
+		$next = next($this->reg_steps);
490
+		prev($this->reg_steps);
491 491
 		return $next instanceof EE_SPCO_Reg_Step ? $next : null;
492 492
 	}
493 493
 
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 	 *  @return 	EE_SPCO_Reg_Step | null
503 503
 	 */
504 504
 	public function get_prev_reg_step() {
505
-		$prev = prev( $this->reg_steps );
506
-		next( $this->reg_steps );
505
+		$prev = prev($this->reg_steps);
506
+		next($this->reg_steps);
507 507
 		return $prev instanceof EE_SPCO_Reg_Step ? $prev : null;
508 508
 	}
509 509
 
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
 	 * @return void
517 517
 	 */
518 518
 	public function sort_reg_steps() {
519
-		$reg_step_sorting_callback = apply_filters( 'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback' );
520
-		uasort( $this->reg_steps, array( $this, $reg_step_sorting_callback ));
519
+		$reg_step_sorting_callback = apply_filters('FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback');
520
+		uasort($this->reg_steps, array($this, $reg_step_sorting_callback));
521 521
 	}
522 522
 
523 523
 
@@ -530,19 +530,19 @@  discard block
 block discarded – undo
530 530
 	 * @param string $reg_step_slug
531 531
 	 * @return EE_SPCO_Reg_Step|null
532 532
 	 */
533
-	public function find_reg_step( $reg_step_slug = '' ) {
534
-		if ( ! empty( $reg_step_slug ) ) {
533
+	public function find_reg_step($reg_step_slug = '') {
534
+		if ( ! empty($reg_step_slug)) {
535 535
 			// copy reg step array
536 536
 			$reg_steps = $this->reg_steps;
537 537
 			// set pointer to start of array
538
-			reset( $reg_steps );
538
+			reset($reg_steps);
539 539
 			// if there is more than one step
540
-			if ( count( $reg_steps ) > 1 ) {
540
+			if (count($reg_steps) > 1) {
541 541
 				// advance to the current step and set pointer
542
-				while ( key( $reg_steps ) != $reg_step_slug && key( $reg_steps ) != '' ) {
543
-					next( $reg_steps );
542
+				while (key($reg_steps) != $reg_step_slug && key($reg_steps) != '') {
543
+					next($reg_steps);
544 544
 				}
545
-				return current( $reg_steps );
545
+				return current($reg_steps);
546 546
 			}
547 547
 		}
548 548
 		return null;
@@ -558,17 +558,17 @@  discard block
 block discarded – undo
558 558
 	 * @param EE_SPCO_Reg_Step $reg_step_B
559 559
 	 * @return array()
560 560
 	 */
561
-	public function reg_step_sorting_callback( EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B ) {
561
+	public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B) {
562 562
 		// send finalize_registration step to the end of the array
563
-		if ( $reg_step_A->slug() == 'finalize_registration' ) {
563
+		if ($reg_step_A->slug() == 'finalize_registration') {
564 564
 			return 1;
565
-		} else if ( $reg_step_B->slug() == 'finalize_registration' ) {
565
+		} else if ($reg_step_B->slug() == 'finalize_registration') {
566 566
 			return -1;
567 567
 		}
568
-		if ( $reg_step_A->order() == $reg_step_B->order() ) {
568
+		if ($reg_step_A->order() == $reg_step_B->order()) {
569 569
 			return 0;
570 570
 		}
571
-		return ( $reg_step_A->order() > $reg_step_B->order() ) ? 1 : -1;
571
+		return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1;
572 572
 	}
573 573
 
574 574
 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 	 * @access 	public
580 580
 	 * @param 	EE_SPCO_Reg_Step $reg_step
581 581
 	 */
582
-	public function set_reg_step_initiated( EE_SPCO_Reg_Step $reg_step ) {
582
+	public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step) {
583 583
 		// call set_reg_step_initiated ???
584 584
 		if (
585 585
 			// first time visiting SPCO ?
@@ -588,13 +588,13 @@  discard block
 block discarded – undo
588 588
 			&& $this->action === 'display_spco_reg_step'
589 589
 		) {
590 590
 			/** @type EE_Transaction_Processor $transaction_processor */
591
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
591
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
592 592
 			// set the start time for this reg step
593
-			if ( ! $transaction_processor->set_reg_step_initiated( $this->transaction, $reg_step->slug() ) ) {
594
-				if ( WP_DEBUG ) {
593
+			if ( ! $transaction_processor->set_reg_step_initiated($this->transaction, $reg_step->slug())) {
594
+				if (WP_DEBUG) {
595 595
 					EE_Error::add_error(
596 596
 						sprintf(
597
-							__( 'The "%1$s" registration step was not initialized properly.', 'event_espresso' ),
597
+							__('The "%1$s" registration step was not initialized properly.', 'event_espresso'),
598 598
 							$reg_step->name()
599 599
 						),
600 600
 						__FILE__, __FUNCTION__, __LINE__
@@ -613,10 +613,10 @@  discard block
 block discarded – undo
613 613
 	 * 	@return 	void
614 614
 	 */
615 615
 	public function set_reg_step_JSON_info() {
616
-		EE_Registry::$i18n_js_strings[ 'reg_steps' ] = array();
616
+		EE_Registry::$i18n_js_strings['reg_steps'] = array();
617 617
 		// pass basic reg step data to JS
618
-		foreach ( $this->reg_steps as $reg_step ) {
619
-			EE_Registry::$i18n_js_strings[ 'reg_steps' ][] = $reg_step->slug();
618
+		foreach ($this->reg_steps as $reg_step) {
619
+			EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug();
620 620
 		}
621 621
 		// reset reg step html
622 622
 //		$this->json_response->set_reg_step_html( '' );
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	 */
633 633
 	public function reset_reg_steps() {
634 634
 		$this->sort_reg_steps();
635
-		$this->set_current_step( EE_Registry::instance()->REQ->get( 'step' ));
635
+		$this->set_current_step(EE_Registry::instance()->REQ->get('step'));
636 636
 		$this->set_next_step();
637 637
 		// the text that appears on the reg step form submit button
638 638
 		$this->current_step->set_submit_button_text();
@@ -649,9 +649,9 @@  discard block
 block discarded – undo
649 649
 	 */
650 650
 	public function get_registration_time_limit() {
651 651
 
652
-		$registration_time_limit = (float)( EE_Registry::instance()	->SSN->expiration() - time() );
652
+		$registration_time_limit = (float) (EE_Registry::instance()	->SSN->expiration() - time());
653 653
 		$time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s';
654
-		$registration_time_limit = gmdate( $time_limit_format, $registration_time_limit );
654
+		$registration_time_limit = gmdate($time_limit_format, $registration_time_limit);
655 655
 		return apply_filters(
656 656
 			'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit',
657 657
 			$registration_time_limit
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 		//		overpaid TXN
672 672
 		//		free TXN ( total = 0.00 )
673 673
 		// then payment required is TRUE
674
-		return ! ( $this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free() ) ? TRUE : FALSE;
674
+		return ! ($this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free()) ? TRUE : FALSE;
675 675
 	}
676 676
 
677 677
 
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
 	 */
685 685
 	public function initialize_txn_reg_steps_array() {
686 686
 		$txn_reg_steps_array = array();
687
-		foreach ( $this->reg_steps as $reg_step ) {
688
-			$txn_reg_steps_array[ $reg_step->slug() ] = FALSE;
687
+		foreach ($this->reg_steps as $reg_step) {
688
+			$txn_reg_steps_array[$reg_step->slug()] = FALSE;
689 689
 		}
690 690
 		return $txn_reg_steps_array;
691 691
 	}
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
 	public function update_txn_reg_steps_array() {
702 702
 		$updated = FALSE;
703 703
 		/** @type EE_Transaction_Processor $transaction_processor */
704
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
705
-		foreach ( $this->reg_steps as $reg_step ) {
706
-			if ( $reg_step->completed() ) {
707
-				$updated = $transaction_processor->set_reg_step_completed( $this->transaction, $reg_step->slug() ) ? TRUE : $updated;
704
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
705
+		foreach ($this->reg_steps as $reg_step) {
706
+			if ($reg_step->completed()) {
707
+				$updated = $transaction_processor->set_reg_step_completed($this->transaction, $reg_step->slug()) ? TRUE : $updated;
708 708
 			}
709 709
 		}
710
-		if ( $updated ) {
710
+		if ($updated) {
711 711
 			$this->transaction->save();
712 712
 		}
713 713
 		return $updated;
@@ -722,14 +722,14 @@  discard block
 block discarded – undo
722 722
 	 * 	@return 	void
723 723
 	 */
724 724
 	public function stash_transaction_and_checkout() {
725
-		if ( ! $this->revisit ) {
725
+		if ( ! $this->revisit) {
726 726
 			$this->update_txn_reg_steps_array();
727 727
 		}
728 728
 		$this->track_transaction_and_registration_status_updates();
729 729
 		// save all data to the db, but suppress errors
730 730
 		//$this->save_all_data( FALSE );
731 731
 		// cache the checkout in the session
732
-		EE_Registry::instance()->SSN->set_checkout( $this );
732
+		EE_Registry::instance()->SSN->set_checkout($this);
733 733
 	}
734 734
 
735 735
 
@@ -745,21 +745,21 @@  discard block
 block discarded – undo
745 745
 	 */
746 746
 	public function track_transaction_and_registration_status_updates() {
747 747
 		// verify the transaction
748
-		if ( $this->transaction instanceof EE_Transaction ) {
748
+		if ($this->transaction instanceof EE_Transaction) {
749 749
 			/** @type EE_Transaction_Payments $transaction_payments */
750
-			$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
750
+			$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
751 751
 			/** @type EE_Transaction_Processor $transaction_processor */
752
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
752
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
753 753
 			// has there been a TXN status change during this checkout?
754
-			if ( $transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated() ) {
754
+			if ($transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated()) {
755 755
 				$this->txn_status_updated = true;
756 756
 			}
757 757
 			/** @type EE_Registration_Processor $registration_processor */
758
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
758
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
759 759
 			// grab the saved registrations from the transaction
760
-			foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) {
761
-				if ( $registration_processor->reg_status_updated( $registration->ID() ) ) {
762
-					$this->set_reg_status_updated( $registration->ID(), true );
760
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
761
+				if ($registration_processor->reg_status_updated($registration->ID())) {
762
+					$this->set_reg_status_updated($registration->ID(), true);
763 763
 				}
764 764
 			}
765 765
 		}
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
 	 * @param 	EE_Registration 	$registration
782 782
 	 * 	@return 	bool
783 783
 	 */
784
-	public function visit_allows_processing_of_this_registration( EE_Registration $registration ) {
785
-		return ! $this->revisit || $this->primary_revisit || ( $this->revisit && $this->reg_url_link == $registration->reg_url_link() ) ? TRUE : FALSE;
784
+	public function visit_allows_processing_of_this_registration(EE_Registration $registration) {
785
+		return ! $this->revisit || $this->primary_revisit || ($this->revisit && $this->reg_url_link == $registration->reg_url_link()) ? TRUE : FALSE;
786 786
 	}
787 787
 
788 788
 
@@ -807,18 +807,18 @@  discard block
 block discarded – undo
807 807
 	 * @param bool $show_errors
808 808
 	 * @return bool
809 809
 	 */
810
-	public function save_all_data( $show_errors = TRUE ) {
810
+	public function save_all_data($show_errors = TRUE) {
811 811
 		// verify the transaction
812
-		if ( $this->transaction instanceof EE_Transaction ) {
812
+		if ($this->transaction instanceof EE_Transaction) {
813 813
 			// save to ensure that TXN has ID
814 814
 			$this->transaction->save();
815 815
 			// grab the saved registrations from the transaction
816
-			foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as  $registration ) {
817
-				$this->_save_registration( $registration, $show_errors );
816
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as  $registration) {
817
+				$this->_save_registration($registration, $show_errors);
818 818
 			}
819 819
 		} else {
820
-			if ( $show_errors ) {
821
-				EE_Error::add_error( __( 'A valid Transaction was not found when attempting to save your registration information.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
820
+			if ($show_errors) {
821
+				EE_Error::add_error(__('A valid Transaction was not found when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
822 822
 			}
823 823
 			return FALSE;
824 824
 		}
@@ -833,32 +833,32 @@  discard block
 block discarded – undo
833 833
 	 * @param bool $show_errors
834 834
 	 * @return void
835 835
 	 */
836
-	private function _save_registration( $registration, $show_errors = TRUE  ) {
836
+	private function _save_registration($registration, $show_errors = TRUE) {
837 837
 		// verify object
838
-		if ( $registration instanceof EE_Registration ) {
838
+		if ($registration instanceof EE_Registration) {
839 839
 			// should this registration be processed during this visit ?
840
-			if ( $this->visit_allows_processing_of_this_registration( $registration ) ) {
840
+			if ($this->visit_allows_processing_of_this_registration($registration)) {
841 841
 				//set TXN ID
842
-				if ( ! $registration->transaction_ID() ) {
843
-					$registration->set_transaction_id( $this->transaction->ID() );
842
+				if ( ! $registration->transaction_ID()) {
843
+					$registration->set_transaction_id($this->transaction->ID());
844 844
 				}
845 845
 				// verify and save the attendee
846
-				$this->_save_registration_attendee( $registration, $show_errors );
846
+				$this->_save_registration_attendee($registration, $show_errors);
847 847
 				// save answers to reg form questions
848
-				$this->_save_registration_answers( $registration, $show_errors );
848
+				$this->_save_registration_answers($registration, $show_errors);
849 849
 				// save changes
850 850
 				$registration->save();
851 851
 				// update txn cache
852
-				if ( ! $this->transaction->update_cache_after_object_save( 'Registration', $registration )) {
853
-					if ( $show_errors ) {
854
-						EE_Error::add_error( __( 'The newly saved Registration object could not be cached on the Transaction.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
852
+				if ( ! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
853
+					if ($show_errors) {
854
+						EE_Error::add_error(__('The newly saved Registration object could not be cached on the Transaction.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
855 855
 					}
856 856
 				}
857 857
 			}
858 858
 		} else {
859
-			if ( $show_errors ) {
859
+			if ($show_errors) {
860 860
 				EE_Error::add_error(
861
-					__( 'An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso' ),
861
+					__('An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso'),
862 862
 					__FILE__, __FUNCTION__, __LINE__
863 863
 				);
864 864
 			}
@@ -874,26 +874,26 @@  discard block
 block discarded – undo
874 874
 	 * @param bool $show_errors
875 875
 	 * @return void
876 876
 	 */
877
-	private function _save_registration_attendee( $registration, $show_errors = TRUE ) {
878
-		if ( $registration->attendee() instanceof EE_Attendee ) {
877
+	private function _save_registration_attendee($registration, $show_errors = TRUE) {
878
+		if ($registration->attendee() instanceof EE_Attendee) {
879 879
 			// save so that ATT has ID
880 880
 			$registration->attendee()->save();
881
-			if ( ! $registration->update_cache_after_object_save( 'Attendee', $registration->attendee() )) {
882
-				if ( $show_errors ) {
881
+			if ( ! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
882
+				if ($show_errors) {
883 883
 					EE_Error::add_error(
884
-						__( 'The newly saved Attendee object could not be cached on the registration.', 'event_espresso' ),
884
+						__('The newly saved Attendee object could not be cached on the registration.', 'event_espresso'),
885 885
 						__FILE__, __FUNCTION__, __LINE__
886 886
 					);
887 887
 				}
888 888
 			}
889 889
 		} else {
890
-			if ( $show_errors ) {
890
+			if ($show_errors) {
891 891
 				ob_start();
892
-				var_dump( $registration->attendee() );
892
+				var_dump($registration->attendee());
893 893
 				EE_Error::add_error(
894 894
 					sprintf(
895 895
 						'%1$s||%1$s $attendee = %2$s',
896
-						__( 'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso' ),
896
+						__('Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso'),
897 897
 						ob_get_clean()
898 898
 					),
899 899
 					__FILE__, __FUNCTION__, __LINE__
@@ -911,25 +911,25 @@  discard block
 block discarded – undo
911 911
 	 * @param bool $show_errors
912 912
 	 * @return void
913 913
 	 */
914
-	private function _save_registration_answers( $registration, $show_errors = TRUE ) {
914
+	private function _save_registration_answers($registration, $show_errors = TRUE) {
915 915
 		// now save the answers
916
-		foreach ( $registration->answers() as $cache_key => $answer ) {
916
+		foreach ($registration->answers() as $cache_key => $answer) {
917 917
 			// verify object
918
-			if ( $answer instanceof EE_Answer ) {
919
-				$answer->set_registration( $registration->ID() );
918
+			if ($answer instanceof EE_Answer) {
919
+				$answer->set_registration($registration->ID());
920 920
 				$answer->save();
921
-				if ( ! $registration->update_cache_after_object_save( 'Answer', $answer, $cache_key )) {
922
-					if ( $show_errors ) {
921
+				if ( ! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
922
+					if ($show_errors) {
923 923
 						EE_Error::add_error(
924
-							__( 'The newly saved Answer object could not be cached on the registration.', 'event_espresso' ),
924
+							__('The newly saved Answer object could not be cached on the registration.', 'event_espresso'),
925 925
 							__FILE__, __FUNCTION__, __LINE__
926 926
 						);
927 927
 					}
928 928
 				}
929 929
 			} else {
930
-				if ( $show_errors ) {
930
+				if ($show_errors) {
931 931
 					EE_Error::add_error(
932
-						__( 'An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso' ),
932
+						__('An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso'),
933 933
 						__FILE__, __FUNCTION__, __LINE__
934 934
 					);
935 935
 				}
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 	 * @param bool $from_db
948 948
 	 * @return bool
949 949
 	 */
950
-	public function refresh_all_entities( $from_db = false ) {
950
+	public function refresh_all_entities($from_db = false) {
951 951
 		$from_db = $this->current_step->is_final_step() || $this->action == 'process_gateway_response' ? true : $from_db;
952 952
 		//$this->log(
953 953
 		//	__CLASS__, __FUNCTION__, __LINE__,
@@ -968,11 +968,11 @@  discard block
 block discarded – undo
968 968
 	 */
969 969
 	protected function refresh_from_db() {
970 970
 		// verify the transaction
971
-		if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) {
971
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
972 972
 			// pull fresh TXN data from the db
973
-			$this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db( $this->transaction->ID() );
973
+			$this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID());
974 974
 			// update EE_Checkout's cached primary_attendee object
975
-			$this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db( $this->transaction );
975
+			$this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction);
976 976
 			// update EE_Checkout's cached payment object
977 977
 			$payment = $this->transaction->last_payment();
978 978
 			$this->payment = $payment instanceof EE_Payment ? $payment : $this->payment;
@@ -980,15 +980,15 @@  discard block
 block discarded – undo
980 980
 			$payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null;
981 981
 			$this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method : $this->payment_method;
982 982
 			//now refresh the cart, based on the TXN
983
-			$this->cart = EE_Cart::get_cart_from_txn( $this->transaction );
983
+			$this->cart = EE_Cart::get_cart_from_txn($this->transaction);
984 984
 			// verify and update the cart because inaccurate totals are not so much fun
985
-			if ( $this->cart instanceof EE_Cart ) {
985
+			if ($this->cart instanceof EE_Cart) {
986 986
 				$this->cart->get_grand_total()->recalculate_total_including_taxes();
987 987
 			} else {
988
-				$this->cart = EE_Registry::instance()->load_core( 'Cart' );
988
+				$this->cart = EE_Registry::instance()->load_core('Cart');
989 989
 			}
990 990
 		} else {
991
-			EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
991
+			EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
992 992
 			return FALSE;
993 993
 		}
994 994
 		return TRUE;
@@ -1002,24 +1002,24 @@  discard block
 block discarded – undo
1002 1002
 	 * @param   EE_Transaction $transaction
1003 1003
 	 * @return  EE_Attendee | null
1004 1004
 	 */
1005
-	protected function _refresh_primary_attendee_obj_from_db( EE_Transaction $transaction ) {
1005
+	protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction) {
1006 1006
 
1007 1007
 		$primary_attendee_obj = null;
1008 1008
 		// grab the saved registrations from the transaction
1009
-		foreach ( $transaction->registrations( $this->reg_cache_where_params, true ) as $registration ) {
1009
+		foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) {
1010 1010
 			// verify object
1011
-			if ( $registration instanceof EE_Registration ) {
1011
+			if ($registration instanceof EE_Registration) {
1012 1012
 				$attendee = $registration->attendee();
1013 1013
 				// verify object
1014
-				if ( $attendee instanceof EE_Attendee  ) {
1014
+				if ($attendee instanceof EE_Attendee) {
1015 1015
 					// maybe cache primary_attendee_obj ?
1016
-					if ( $registration->is_primary_registrant() ) {
1016
+					if ($registration->is_primary_registrant()) {
1017 1017
 						$primary_attendee_obj = $attendee;
1018 1018
 					}
1019 1019
 				}
1020 1020
 			} else {
1021 1021
 				EE_Error::add_error(
1022
-						__( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ),
1022
+						__('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'),
1023 1023
 						__FILE__, __FUNCTION__, __LINE__
1024 1024
 				);
1025 1025
 			}
@@ -1039,43 +1039,43 @@  discard block
 block discarded – undo
1039 1039
 	 */
1040 1040
 	protected function refresh_entity_map() {
1041 1041
 		// verify the transaction
1042
-		if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) {
1042
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1043 1043
 			// never cache payment info
1044
-			$this->transaction->clear_cache( 'Payment' );
1044
+			$this->transaction->clear_cache('Payment');
1045 1045
 			/** @type EE_Transaction_Processor $transaction_processor */
1046
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1046
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1047 1047
 			// is the Payment Options Reg Step completed ?
1048
-			if ( $transaction_processor->reg_step_completed( $this->transaction, 'payment_options' ) ) {
1048
+			if ($transaction_processor->reg_step_completed($this->transaction, 'payment_options')) {
1049 1049
 				// then check for payments and update TXN accordingly
1050 1050
 				/** @type EE_Transaction_Payments $transaction_payments */
1051
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1052
-				$transaction_payments->calculate_total_payments_and_update_status( $this->transaction );
1051
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1052
+				$transaction_payments->calculate_total_payments_and_update_status($this->transaction);
1053 1053
 			}
1054 1054
 			// grab the saved registrations from the transaction
1055
-			foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $reg_cache_ID => $registration ) {
1056
-				$this->_refresh_registration( $reg_cache_ID, $registration );
1055
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration) {
1056
+				$this->_refresh_registration($reg_cache_ID, $registration);
1057 1057
 			}
1058 1058
 			// make sure our cached TXN is added to the model entity mapper
1059
-			$this->transaction = $this->transaction->get_model()->refresh_entity_map_with( $this->transaction->ID(), $this->transaction );
1059
+			$this->transaction = $this->transaction->get_model()->refresh_entity_map_with($this->transaction->ID(), $this->transaction);
1060 1060
 
1061 1061
 		} else {
1062
-			EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
1062
+			EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1063 1063
 			return FALSE;
1064 1064
 		}
1065 1065
 		// verify and update the cart because inaccurate totals are not so much fun
1066
-		if ( $this->cart instanceof EE_Cart ) {
1066
+		if ($this->cart instanceof EE_Cart) {
1067 1067
 			$grand_total = $this->cart->get_grand_total();
1068
-			if ( $grand_total instanceof EE_Line_Item && $grand_total->ID() ) {
1068
+			if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) {
1069 1069
 				$grand_total->recalculate_total_including_taxes();
1070 1070
 				$grand_total = $grand_total->get_model()->refresh_entity_map_with(
1071 1071
 					$this->cart->get_grand_total()->ID(),
1072 1072
 					$this->cart->get_grand_total()
1073 1073
 				);
1074 1074
 			}
1075
-			if ( $grand_total instanceof EE_Line_Item ) {
1076
-				$this->cart = EE_Cart::instance( $grand_total );
1075
+			if ($grand_total instanceof EE_Line_Item) {
1076
+				$this->cart = EE_Cart::instance($grand_total);
1077 1077
 			} else {
1078
-				EE_Error::add_error( __( 'A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1078
+				EE_Error::add_error(__('A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1079 1079
 				return false;
1080 1080
 			}
1081 1081
 		}
@@ -1091,19 +1091,19 @@  discard block
 block discarded – undo
1091 1091
 	 * @param 	EE_Registration 	$registration
1092 1092
 	 * @return void
1093 1093
 	 */
1094
-	protected function _refresh_registration( $reg_cache_ID, $registration ) {
1094
+	protected function _refresh_registration($reg_cache_ID, $registration) {
1095 1095
 
1096 1096
 		// verify object
1097
-		if ( $registration instanceof EE_Registration ) {
1097
+		if ($registration instanceof EE_Registration) {
1098 1098
 			// update the entity mapper attendee
1099
-			$this->_refresh_registration_attendee( $registration );
1099
+			$this->_refresh_registration_attendee($registration);
1100 1100
 			// update the entity mapper answers for reg form questions
1101
-			$this->_refresh_registration_answers( $registration );
1101
+			$this->_refresh_registration_answers($registration);
1102 1102
 			// make sure the cached registration is added to the model entity mapper
1103
-			$registration->get_model()->refresh_entity_map_with( $reg_cache_ID, $registration );
1103
+			$registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration);
1104 1104
 		} else {
1105 1105
 			EE_Error::add_error(
1106
-				__( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ),
1106
+				__('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'),
1107 1107
 				__FILE__, __FUNCTION__, __LINE__
1108 1108
 			);
1109 1109
 		}
@@ -1117,15 +1117,15 @@  discard block
 block discarded – undo
1117 1117
 	 * @param 	EE_Registration 	$registration
1118 1118
 	 * @return void
1119 1119
 	 */
1120
-	protected function _refresh_registration_attendee( $registration ) {
1120
+	protected function _refresh_registration_attendee($registration) {
1121 1121
 
1122 1122
 		$attendee = $registration->attendee();
1123 1123
 		// verify object
1124
-		if ( $attendee instanceof EE_Attendee && $attendee->ID() ) {
1124
+		if ($attendee instanceof EE_Attendee && $attendee->ID()) {
1125 1125
 			// make sure the cached attendee is added to the model entity mapper
1126
-			$registration->attendee()->get_model()->refresh_entity_map_with( $attendee->ID(), $attendee );
1126
+			$registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee);
1127 1127
 			// maybe cache primary_attendee_obj ?
1128
-			if ( $registration->is_primary_registrant() ) {
1128
+			if ($registration->is_primary_registrant()) {
1129 1129
 				$this->primary_attendee_obj = $attendee;
1130 1130
 			}
1131 1131
 		}
@@ -1139,19 +1139,19 @@  discard block
 block discarded – undo
1139 1139
 	 * @param 	EE_Registration 	$registration
1140 1140
 	 * @return void
1141 1141
 	 */
1142
-	protected function _refresh_registration_answers( $registration ) {
1142
+	protected function _refresh_registration_answers($registration) {
1143 1143
 
1144 1144
 		// now update the answers
1145
-		foreach ( $registration->answers() as $cache_key => $answer ) {
1145
+		foreach ($registration->answers() as $cache_key => $answer) {
1146 1146
 			// verify object
1147
-			if ( $answer instanceof EE_Answer ) {
1148
-				if ( $answer->ID() ) {
1147
+			if ($answer instanceof EE_Answer) {
1148
+				if ($answer->ID()) {
1149 1149
 					// make sure the cached answer is added to the model entity mapper
1150
-					$answer->get_model()->refresh_entity_map_with( $answer->ID(), $answer );
1150
+					$answer->get_model()->refresh_entity_map_with($answer->ID(), $answer);
1151 1151
 				}
1152 1152
 			} else {
1153 1153
 				EE_Error::add_error(
1154
-					__( 'An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso' ),
1154
+					__('An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso'),
1155 1155
 					__FILE__, __FUNCTION__, __LINE__
1156 1156
 				);
1157 1157
 			}
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 	 * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object
1167 1167
 	 */
1168 1168
 	function __wakeup() {
1169
-		foreach ( $this->reg_steps as $reg_step ) {
1169
+		foreach ($this->reg_steps as $reg_step) {
1170 1170
 			$reg_step->checkout = $this;
1171 1171
 		}
1172 1172
 	}
@@ -1182,11 +1182,11 @@  discard block
 block discarded – undo
1182 1182
 	 * @param array $info
1183 1183
 	 * @param bool $display_request
1184 1184
 	 */
1185
-	function log( $class = '', $func = '', $line = '', $info = array(), $display_request = false ) {
1186
-		if ( WP_DEBUG && false ) {
1187
-			$debug_data = get_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array() );
1185
+	function log($class = '', $func = '', $line = '', $info = array(), $display_request = false) {
1186
+		if (WP_DEBUG && false) {
1187
+			$debug_data = get_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), array());
1188 1188
 			$default_data = array(
1189
-				$class 		=> $func . '() : ' . $line,
1189
+				$class 		=> $func.'() : '.$line,
1190 1190
 				'request->step' 		=> $this->step,
1191 1191
 				'request->action' 	=> $this->action,
1192 1192
 				'current_step->slug' => $this->current_step instanceof EE_SPCO_Reg_Step ?
@@ -1198,24 +1198,24 @@  discard block
 block discarded – undo
1198 1198
 				'reg_url_link' => $this->reg_url_link,
1199 1199
 				'REQ' => $display_request ? $_REQUEST : '',
1200 1200
 			);
1201
-			if ( $this->transaction instanceof EE_Transaction ) {
1202
-				$default_data[ 'TXN_status' ] 		= $this->transaction->status_ID();
1203
-				$default_data[ 'TXN_reg_steps' ] 	= $this->transaction->reg_steps();
1204
-				foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $REG_ID => $registration ) {
1205
-					$default_data[ 'registrations' ][ $REG_ID ] = $registration->status_ID();
1201
+			if ($this->transaction instanceof EE_Transaction) {
1202
+				$default_data['TXN_status'] = $this->transaction->status_ID();
1203
+				$default_data['TXN_reg_steps'] = $this->transaction->reg_steps();
1204
+				foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) {
1205
+					$default_data['registrations'][$REG_ID] = $registration->status_ID();
1206 1206
 				}
1207
-				if ( $this->transaction->ID() ) {
1208
-					$TXN_ID = 'EE_Transaction: ' . $this->transaction->ID();
1207
+				if ($this->transaction->ID()) {
1208
+					$TXN_ID = 'EE_Transaction: '.$this->transaction->ID();
1209 1209
 					// don't serialize objects
1210
-					$info = $this->_strip_objects( $info );
1211
-					if ( ! isset( $debug_data[ $TXN_ID ] ) ) {
1212
-						$debug_data[ $TXN_ID ] = array();
1210
+					$info = $this->_strip_objects($info);
1211
+					if ( ! isset($debug_data[$TXN_ID])) {
1212
+						$debug_data[$TXN_ID] = array();
1213 1213
 					}
1214
-					$debug_data[ $TXN_ID ][ microtime() ] = array_merge(
1214
+					$debug_data[$TXN_ID][microtime()] = array_merge(
1215 1215
 						$default_data,
1216 1216
 						$info
1217 1217
 					);
1218
-					update_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data );
1218
+					update_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), $debug_data);
1219 1219
 				}
1220 1220
 			}
1221 1221
 		}
@@ -1228,23 +1228,23 @@  discard block
 block discarded – undo
1228 1228
 	 * @param array $info
1229 1229
 	 * @return array
1230 1230
 	 */
1231
-	function _strip_objects( $info = array() ) {
1232
-		foreach ( $info as $key => $value ) {
1233
-			if ( is_array( $value )) {
1234
-				$info[ $key ] = $this->_strip_objects( $value );
1235
-			} else if ( is_object( $value ) ) {
1236
-				$object_class = get_class( $value );
1237
-				$info[ $object_class ] = array();
1238
-				$info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : 0;
1239
-				if ( method_exists( $value, 'status' ) ) {
1240
-					$info[ $object_class ][ 'status' ] = $value->status();
1241
-				} else if ( method_exists( $value, 'status_ID' ) ) {
1242
-					$info[ $object_class ][ 'status' ] = $value->status_ID();
1231
+	function _strip_objects($info = array()) {
1232
+		foreach ($info as $key => $value) {
1233
+			if (is_array($value)) {
1234
+				$info[$key] = $this->_strip_objects($value);
1235
+			} else if (is_object($value)) {
1236
+				$object_class = get_class($value);
1237
+				$info[$object_class] = array();
1238
+				$info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1239
+				if (method_exists($value, 'status')) {
1240
+					$info[$object_class]['status'] = $value->status();
1241
+				} else if (method_exists($value, 'status_ID')) {
1242
+					$info[$object_class]['status'] = $value->status_ID();
1243 1243
 				}
1244
-				unset( $info[ $key ] );
1244
+				unset($info[$key]);
1245 1245
 			}
1246 1246
 		}
1247
-		return (array)$info;
1247
+		return (array) $info;
1248 1248
 	}
1249 1249
 
1250 1250
 
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 1 patch
Spacing   +381 added lines, -381 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
 		$this->_name = 'pricing';
55 55
 
56 56
 		//capability check
57
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) {
57
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) {
58 58
 			return;
59 59
 		}
60 60
 
61
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
61
+		EE_Registry::instance()->load_helper('DTT_Helper');
62 62
 
63 63
 		//if we were going to add our own metaboxes we'd use the below.
64 64
 		$this->_metaboxes = array(
65 65
 			0 => array(
66
-				'page_route' => array('edit','create_new'),
66
+				'page_route' => array('edit', 'create_new'),
67 67
 				'func' => 'pricing_metabox',
68 68
 				'label' => __('Event Tickets & Datetimes', 'event_espresso'),
69 69
 				'priority' => 'high',
70 70
 				'context' => 'normal'
71 71
 				),
72 72
 
73
-			);/**/
73
+			); /**/
74 74
 
75 75
 		$this->_remove_metaboxes = array(
76 76
 			0 => array(
@@ -89,24 +89,24 @@  discard block
 block discarded – undo
89 89
 		 *
90 90
 		 * @var array  Expected an array returned with 'date' and 'time' keys.
91 91
 		 */
92
-		$this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array(
92
+		$this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array(
93 93
 				'date' => 'Y-m-d',
94 94
 				'time' => 'h:i a'
95 95
 			));
96 96
 
97 97
 		//validate
98
-		$this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null;
99
-		$this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null;
98
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null;
99
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null;
100 100
 
101 101
 		//validate format strings
102
-		$format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
103
-		if ( is_array( $format_validation ) ) {
104
-			$msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>';
105
-			foreach ( $format_validation as $error ) {
106
-				$msg .= '<li>' . $error . '</li>';
102
+		$format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
103
+		if (is_array($format_validation)) {
104
+			$msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>';
105
+			foreach ($format_validation as $error) {
106
+				$msg .= '<li>'.$error.'</li>';
107 107
 			}
108
-			$msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>';
109
-			EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
108
+			$msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
109
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
110 110
 			$this->_date_format_strings = array(
111 111
 				'date' => 'Y-m-d',
112 112
 				'time' => 'h:i a'
@@ -117,60 +117,60 @@  discard block
 block discarded – undo
117 117
 		$this->_scripts_styles = array(
118 118
 			'registers' => array(
119 119
 				'ee-tickets-datetimes-css' => array(
120
-					'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
120
+					'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css',
121 121
 					'type' => 'css'
122 122
 					),
123 123
 				'ee-dtt-ticket-metabox' => array(
124
-					'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
124
+					'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js',
125 125
 					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore')
126 126
 					)
127 127
 				),
128 128
 			'deregisters' => array(
129
-				'event-editor-css' => array('type' => 'css' ),
129
+				'event-editor-css' => array('type' => 'css'),
130 130
 				'event-datetime-metabox' => array('type' => 'js')
131 131
 				),
132 132
 			'enqueues' => array(
133
-				'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ),
134
-				'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' )
133
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
134
+				'ee-dtt-ticket-metabox' => array('edit', 'create_new')
135 135
 				),
136 136
 			'localize' => array(
137 137
 				'ee-dtt-ticket-metabox' => array(
138 138
 					'DTT_TRASH_BLOCK' => array(
139 139
 						'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'),
140 140
 						'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'),
141
-						'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>',
141
+						'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>',
142 142
 						'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'),
143 143
 						'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.', 'event_espresso'),
144
-						'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>'
144
+						'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>'
145 145
 						),
146 146
 					'DTT_ERROR_MSG' => array(
147 147
 						'no_ticket_name' => __('General Admission', 'event_espresso'),
148
-						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>'
148
+						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>'
149 149
 						),
150 150
 					'DTT_OVERSELL_WARNING' => array(
151 151
 						'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'),
152 152
 						'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso')
153 153
 						),
154
-					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ),
155
-					'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) )
154
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']),
155
+					'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week'))
156 156
 					)
157 157
 				)
158 158
 			);
159 159
 
160 160
 
161
-		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 );
162
-		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 );
161
+		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10);
162
+		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10);
163 163
 	}
164 164
 
165 165
 
166 166
 
167
-	public function caf_updates( $update_callbacks ) {
168
-		foreach ( $update_callbacks as $key => $callback ) {
169
-			if ( $callback[1] == '_default_tickets_update' )
170
-				unset( $update_callbacks[$key] );
167
+	public function caf_updates($update_callbacks) {
168
+		foreach ($update_callbacks as $key => $callback) {
169
+			if ($callback[1] == '_default_tickets_update')
170
+				unset($update_callbacks[$key]);
171 171
 		}
172 172
 
173
-		$update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' );
173
+		$update_callbacks[] = array($this, 'dtt_and_tickets_caf_update');
174 174
 		return $update_callbacks;
175 175
 	}
176 176
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	 * @param  array    $data   The request data from the form
184 184
 	 * @return bool             success or fail
185 185
 	 */
186
-	public function dtt_and_tickets_caf_update( $evtobj, $data ) {
186
+	public function dtt_and_tickets_caf_update($evtobj, $data) {
187 187
 		//first we need to start with datetimes cause they are the "root" items attached to events.
188
-		$saved_dtts = $this->_update_dtts( $evtobj, $data );
188
+		$saved_dtts = $this->_update_dtts($evtobj, $data);
189 189
 		//next tackle the tickets (and prices?)
190
-		$this->_update_tkts( $evtobj, $saved_dtts, $data );
190
+		$this->_update_tkts($evtobj, $saved_dtts, $data);
191 191
 	}
192 192
 
193 193
 
@@ -198,41 +198,41 @@  discard block
 block discarded – undo
198 198
 	 * @param  array    	$data    the request data from the form
199 199
 	 * @return EE_Datetime[]
200 200
 	 */
201
-	protected function _update_dtts( $evt_obj, $data ) {
202
-		$timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL;
201
+	protected function _update_dtts($evt_obj, $data) {
202
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL;
203 203
 		$saved_dtt_ids = array();
204 204
 		$saved_dtt_objs = array();
205 205
 
206
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
206
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
207 207
 			//trim all values to ensure any excess whitespace is removed.
208 208
 			$dtt = array_map(
209
-				function( $datetime_data ) {
210
-					return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data );
209
+				function($datetime_data) {
210
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
211 211
 				},
212 212
 				$dtt
213 213
 			);
214
-			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
214
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
215 215
 			$datetime_values = array(
216
-				'DTT_ID' 			=> ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL,
217
-				'DTT_name' 			=> ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '',
218
-				'DTT_description' 	=> ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '',
216
+				'DTT_ID' 			=> ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL,
217
+				'DTT_name' 			=> ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '',
218
+				'DTT_description' 	=> ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '',
219 219
 				'DTT_EVT_start' 	=> $dtt['DTT_EVT_start'],
220 220
 				'DTT_EVT_end' 		=> $dtt['DTT_EVT_end'],
221
-				'DTT_reg_limit' 	=> empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ],
222
-				'DTT_order' 		=> ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'],
221
+				'DTT_reg_limit' 	=> empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
222
+				'DTT_order' 		=> ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'],
223 223
 			);
224 224
 
225 225
 			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
226 226
 
227
-			if ( !empty( $dtt['DTT_ID'] ) ) {
228
-				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] );
227
+			if ( ! empty($dtt['DTT_ID'])) {
228
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']);
229 229
 
230 230
 				//set date and time format according to what is set in this class.
231
-				$DTM->set_date_format( $this->_date_format_strings['date'] );
232
-				$DTM->set_time_format( $this->_date_format_strings['time'] );
231
+				$DTM->set_date_format($this->_date_format_strings['date']);
232
+				$DTM->set_time_format($this->_date_format_strings['time']);
233 233
 
234
-				foreach ( $datetime_values as $field => $value ) {
235
-					$DTM->set( $field, $value );
234
+				foreach ($datetime_values as $field => $value) {
235
+					$DTM->set($field, $value);
236 236
 				}
237 237
 
238 238
 				// make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.
@@ -240,24 +240,24 @@  discard block
 block discarded – undo
240 240
 				$saved_dtt_ids[$DTM->ID()] = $DTM->ID();
241 241
 
242 242
 			} else {
243
-				$DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE );
243
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE);
244 244
 
245 245
 				//reset date and times to match the format
246
-				$DTM->set_date_format( $this->_date_format_strings['date'] );
247
-				$DTM->set_time_format( $this->_date_format_strings['time'] );
248
-				foreach( $datetime_values as $field => $value ) {
249
-					$DTM->set( $field, $value );
246
+				$DTM->set_date_format($this->_date_format_strings['date']);
247
+				$DTM->set_time_format($this->_date_format_strings['time']);
248
+				foreach ($datetime_values as $field => $value) {
249
+					$DTM->set($field, $value);
250 250
 				}
251 251
 			}
252 252
 
253 253
 
254 254
 			$DTM->save();
255
-			$DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' );
255
+			$DTM = $evt_obj->_add_relation_to($DTM, 'Datetime');
256 256
 			$evt_obj->save();
257 257
 
258 258
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
259
-			if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) {
260
-				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') );
259
+			if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) {
260
+				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start'));
261 261
 				EE_Registry::instance()->load_helper('DTT_Helper');
262 262
 				$DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days');
263 263
 				$DTM->save();
@@ -273,25 +273,25 @@  discard block
 block discarded – undo
273 273
 		}
274 274
 
275 275
 		//now we need to REMOVE any dtts that got deleted.  Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point.
276
-		$old_datetimes = explode(',', $data['datetime_IDs'] );
276
+		$old_datetimes = explode(',', $data['datetime_IDs']);
277 277
 		$old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes;
278 278
 
279
-		if ( is_array( $old_datetimes ) ) {
280
-			$dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids );
281
-			foreach ( $dtts_to_delete as $id ) {
282
-				$id = absint( $id );
283
-				if ( empty( $id ) )
279
+		if (is_array($old_datetimes)) {
280
+			$dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
281
+			foreach ($dtts_to_delete as $id) {
282
+				$id = absint($id);
283
+				if (empty($id))
284 284
 					continue;
285 285
 
286 286
 				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
287 287
 
288 288
 				//remove tkt relationships.
289 289
 				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
290
-				foreach ( $related_tickets as $tkt ) {
290
+				foreach ($related_tickets as $tkt) {
291 291
 					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
292 292
 				}
293 293
 
294
-				$evt_obj->_remove_relation_to( $id, 'Datetime' );
294
+				$evt_obj->_remove_relation_to($id, 'Datetime');
295 295
 				$dtt_to_remove->refresh_cache_of_related_objects();
296 296
 
297 297
 			}
@@ -312,86 +312,86 @@  discard block
 block discarded – undo
312 312
 	 * @param  array            $data       incoming request data
313 313
 	 * @return EE_Ticket[]
314 314
 	 */
315
-	protected function _update_tkts( $evtobj, $saved_dtts, $data ) {
315
+	protected function _update_tkts($evtobj, $saved_dtts, $data) {
316 316
 
317 317
 		$new_tkt = null;
318 318
 		$new_default = null;
319 319
 		//stripslashes because WP filtered the $_POST ($data) array to add slashes
320 320
 		$data = stripslashes_deep($data);
321
-		$timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL;
321
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL;
322 322
 		$saved_tickets = $dtts_on_existing = array();
323
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array();
323
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
324 324
 
325 325
 		//load money helper
326
-		EE_Registry::instance()->load_helper( 'Money' );
326
+		EE_Registry::instance()->load_helper('Money');
327 327
 
328
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
328
+		foreach ($data['edit_tickets'] as $row => $tkt) {
329 329
 
330 330
 			$update_prices = $create_new_TKT = FALSE;
331 331
 
332 332
 			//figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session.
333 333
 
334
-			$starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]);
335
-			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] );
334
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
335
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]);
336 336
 			$dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
337 337
 			$dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
338 338
 
339 339
 			// trim inputs to ensure any excess whitespace is removed.
340 340
 			$tkt = array_map(
341
-				function( $ticket_data ) {
342
-					return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data );
341
+				function($ticket_data) {
342
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
343 343
 				},
344 344
 				$tkt
345 345
 			);
346 346
 
347 347
 			//note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models.
348 348
 			//note incoming ['TKT_price'] value is already in standard notation (via js).
349
-			$ticket_price = isset( $tkt['TKT_price'] ) ?  round ( (float) $tkt['TKT_price'], 3 ) : 0;
349
+			$ticket_price = isset($tkt['TKT_price']) ?  round ((float) $tkt['TKT_price'], 3) : 0;
350 350
 
351 351
 			//note incoming base price needs converted from localized value.
352
-			$base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0;
352
+			$base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0;
353 353
 			//if ticket price == 0 and $base_price != 0 then ticket price == base_price
354 354
 			$ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price;
355
-			$base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0;
355
+			$base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
356 356
 
357 357
 			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array();
358 358
 
359 359
 			$now = null;
360
-			if ( empty( $tkt['TKT_start_date'] ) ) {
360
+			if (empty($tkt['TKT_start_date'])) {
361 361
 				//lets' use now in the set timezone.
362
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
363
-				$tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
362
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
363
+				$tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
364 364
 			}
365 365
 
366
-			if ( empty( $tkt['TKT_end_date'] ) ) {
366
+			if (empty($tkt['TKT_end_date'])) {
367 367
 				/**
368 368
 				 * set the TKT_end_date to the first datetime attached to the ticket.
369 369
 				 */
370
-				$first_dtt = $saved_dtts[reset( $tkt_dtt_rows )];
371
-				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] );
370
+				$first_dtt = $saved_dtts[reset($tkt_dtt_rows)];
371
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']);
372 372
 			}
373 373
 
374 374
 			$TKT_values = array(
375
-				'TKT_ID' 			=> ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL,
376
-				'TTM_ID' 			=> ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
377
-				'TKT_name' 			=> ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
378
-				'TKT_description' 	=> ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '',
375
+				'TKT_ID' 			=> ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL,
376
+				'TTM_ID' 			=> ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
377
+				'TKT_name' 			=> ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
378
+				'TKT_description' 	=> ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '',
379 379
 				'TKT_start_date' 	=> $tkt['TKT_start_date'],
380 380
 				'TKT_end_date' 		=> $tkt['TKT_end_date'],
381
-				'TKT_qty' 			=> ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ],
382
-				'TKT_uses' 			=> ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'],
383
-				'TKT_min' 			=> empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
384
-				'TKT_max' 			=> empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
381
+				'TKT_qty' 			=> ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
382
+				'TKT_uses' 			=> ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
383
+				'TKT_min' 			=> empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
384
+				'TKT_max' 			=> empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
385 385
 				'TKT_row' 			=> $row,
386
-				'TKT_order' 		=> isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0,
387
-				'TKT_taxable' 		=> ! empty( $tkt['TKT_taxable'] ) ? 1 : 0,
388
-				'TKT_required' 		=> ! empty( $tkt['TKT_required'] ) ? 1 : 0,
386
+				'TKT_order' 		=> isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
387
+				'TKT_taxable' 		=> ! empty($tkt['TKT_taxable']) ? 1 : 0,
388
+				'TKT_required' 		=> ! empty($tkt['TKT_required']) ? 1 : 0,
389 389
 				'TKT_price' 		=> $ticket_price
390 390
 			);
391 391
 
392 392
 
393 393
 			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
394
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
394
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
395 395
 				$TKT_values['TKT_ID'] = 0;
396 396
 				$TKT_values['TKT_is_default'] = 0;
397 397
 				$update_prices = TRUE;
@@ -403,21 +403,21 @@  discard block
 block discarded – undo
403 403
 			// but DID have it's items modified.
404 404
 			// keep in mind that if the TKT has been sold (and we have changed pricing information),
405 405
 			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
406
-			if ( absint( $TKT_values['TKT_ID'] ) ) {
407
-				$TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] );
408
-				if ( $TKT instanceof EE_Ticket ) {
406
+			if (absint($TKT_values['TKT_ID'])) {
407
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']);
408
+				if ($TKT instanceof EE_Ticket) {
409 409
 
410
-					$TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed );
410
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
411 411
 					// are there any registrations using this ticket ?
412 412
 					$tickets_sold = $TKT->count_related(
413 413
 						'Registration',
414
-						array( array(
415
-								'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) )
416
-						) )
414
+						array(array(
415
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))
416
+						))
417 417
 					);
418 418
 					//set ticket formats
419
-					$TKT->set_date_format( $this->_date_format_strings['date'] );
420
-					$TKT->set_time_format( $this->_date_format_strings['time'] );
419
+					$TKT->set_date_format($this->_date_format_strings['date']);
420
+					$TKT->set_time_format($this->_date_format_strings['time']);
421 421
 
422 422
 					// let's just check the total price for the existing ticket
423 423
 					// and determine if it matches the new total price.
@@ -427,17 +427,17 @@  discard block
 block discarded – undo
427 427
 							? TRUE : FALSE;
428 428
 
429 429
 					//set new values
430
-					foreach ( $TKT_values as $field => $value ) {
431
-						if ( $field === 'TKT_qty' ) {
432
-							$TKT->set_qty( $value );
430
+					foreach ($TKT_values as $field => $value) {
431
+						if ($field === 'TKT_qty') {
432
+							$TKT->set_qty($value);
433 433
 						} else {
434
-							$TKT->set( $field, $value );
434
+							$TKT->set($field, $value);
435 435
 						}
436 436
 					}
437 437
 
438 438
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
439
-					if ( $create_new_TKT ) {
440
-						$new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id );
439
+					if ($create_new_TKT) {
440
+						$new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id);
441 441
 					}
442 442
 				}
443 443
 
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 				$TKT = EE_Ticket::new_instance(
447 447
 					$TKT_values,
448 448
 					$timezone,
449
-					array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ]  )
449
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
450 450
 				);
451
-				if ( $TKT instanceof EE_Ticket ) {
451
+				if ($TKT instanceof EE_Ticket) {
452 452
 					// make sure ticket has an ID of setting relations won't work
453 453
 					$TKT->save();
454
-					$TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed );
454
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
455 455
 					$update_prices = TRUE;
456 456
 				}
457 457
 			}
@@ -459,38 +459,38 @@  discard block
 block discarded – undo
459 459
 			//$TKT->save();
460 460
 
461 461
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
462
-			if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) {
463
-				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date') );
462
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
463
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
464 464
 				EE_Registry::instance()->load_helper('DTT_Helper');
465 465
 				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
466 466
 			}
467 467
 
468 468
 			//let's make sure the base price is handled
469
-			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT;
469
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT;
470 470
 
471 471
 			//add/update price_modifiers
472
-			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT;
472
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT;
473 473
 
474 474
 			//need to make sue that the TKT_price is accurate after saving the prices.
475 475
 			$TKT->ensure_TKT_Price_correct();
476 476
 
477 477
 			//handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
478
-			if ( ! defined('DOING_AUTOSAVE' ) ) {
479
-				if ( !empty($tkt['TKT_is_default_selector'] ) ) {
478
+			if ( ! defined('DOING_AUTOSAVE')) {
479
+				if ( ! empty($tkt['TKT_is_default_selector'])) {
480 480
 					$update_prices = TRUE;
481 481
 					$new_default = clone $TKT;
482
-					$new_default->set( 'TKT_ID', 0 );
483
-					$new_default->set( 'TKT_is_default', 1 );
484
-					$new_default->set( 'TKT_row', 1 );
485
-					$new_default->set( 'TKT_price', $ticket_price );
482
+					$new_default->set('TKT_ID', 0);
483
+					$new_default->set('TKT_is_default', 1);
484
+					$new_default->set('TKT_row', 1);
485
+					$new_default->set('TKT_price', $ticket_price);
486 486
 					//remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object)
487 487
 					$new_default->_remove_relations('Datetime');
488 488
 					//todo we need to add the current attached prices as new prices to the new default ticket.
489
-					$new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices );
489
+					$new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices);
490 490
 					//don't forget the base price!
491
-					$new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id );
491
+					$new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id);
492 492
 					$new_default->save();
493
-					do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data );
493
+					do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data);
494 494
 				}
495 495
 			}
496 496
 
@@ -501,19 +501,19 @@  discard block
 block discarded – undo
501 501
 			//let's assign any tickets that have been setup to the saved_tickets tracker
502 502
 			//save existing TKT
503 503
 			$TKT->save();
504
-			if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) {
504
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
505 505
 				//save new TKT
506 506
 				$new_tkt->save();
507 507
 				//add new ticket to array
508
-				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
508
+				$saved_tickets[$new_tkt->ID()] = $new_tkt;
509 509
 
510
-				do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data );
510
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data);
511 511
 
512 512
 			} else {
513 513
 				//add tkt to saved tkts
514
-				$saved_tickets[ $TKT->ID() ] = $TKT;
514
+				$saved_tickets[$TKT->ID()] = $TKT;
515 515
 
516
-				do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data );
516
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data);
517 517
 			}
518 518
 
519 519
 		}
@@ -523,22 +523,22 @@  discard block
 block discarded – undo
523 523
 		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
524 524
 		// Or a draft event was saved and in the process of editing a ticket is trashed.
525 525
 		// No sense in keeping all the related data in the db!
526
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
527
-		$tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) );
526
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
527
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
528 528
 
529
-		foreach ( $tickets_removed as $id ) {
530
-			$id = absint( $id );
529
+		foreach ($tickets_removed as $id) {
530
+			$id = absint($id);
531 531
 
532 532
 			//get the ticket for this id
533 533
 			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
534 534
 
535 535
 			//if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
536
-			if ( $tkt_to_remove->get('TKT_is_default') )
536
+			if ($tkt_to_remove->get('TKT_is_default'))
537 537
 				continue;
538 538
 
539 539
 			// if this tkt has any registrations attached so then we just ARCHIVE
540 540
 			// because we don't actually permanently delete these tickets.
541
-			if ( $tkt_to_remove->count_related('Registration') > 0 ) {
541
+			if ($tkt_to_remove->count_related('Registration') > 0) {
542 542
 				$tkt_to_remove->delete();
543 543
 				continue;
544 544
 			}
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 			// (remember this process can ONLY kick off if there are NO tkts_sold)
548 548
 			$dtts = $tkt_to_remove->get_many_related('Datetime');
549 549
 
550
-			foreach( $dtts as $dtt ) {
550
+			foreach ($dtts as $dtt) {
551 551
 				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
552 552
 			}
553 553
 
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
556 556
 			$tkt_to_remove->delete_related_permanently('Price');
557 557
 
558
-			do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove );
558
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
559 559
 
560 560
 			// finally let's delete this ticket
561 561
 			// (which should not be blocked at this point b/c we've removed all our relationships)
@@ -587,39 +587,39 @@  discard block
 block discarded – undo
587 587
 		// and removing the ticket from datetimes it got removed from.
588 588
 
589 589
 		// first let's add datetimes
590
-		if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) {
591
-			foreach ( $added_datetimes as $row_id ) {
592
-				$row_id = (int)$row_id;
593
-				if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) {
594
-					$ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' );
590
+		if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
591
+			foreach ($added_datetimes as $row_id) {
592
+				$row_id = (int) $row_id;
593
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
594
+					$ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
595 595
 					// Is this an existing ticket (has an ID) and does it have any sold?
596 596
 					// If so, then we need to add that to the DTT sold because this DTT is getting added.
597
-					if ( $ticket->ID() && $ticket->sold() > 0 ) {
598
-						$saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() );
599
-						$saved_datetimes[ $row_id ]->save();
597
+					if ($ticket->ID() && $ticket->sold() > 0) {
598
+						$saved_datetimes[$row_id]->increase_sold($ticket->sold());
599
+						$saved_datetimes[$row_id]->save();
600 600
 					}
601 601
 				}
602 602
 			}
603 603
 		}
604 604
 		// then remove datetimes
605
-		if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) {
606
-			foreach ( $removed_datetimes as $row_id ) {
607
-				$row_id = (int)$row_id;
605
+		if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
606
+			foreach ($removed_datetimes as $row_id) {
607
+				$row_id = (int) $row_id;
608 608
 				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
609 609
 				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
610
-				if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) {
611
-					$ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' );
610
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
611
+					$ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
612 612
 					// Is this an existing ticket (has an ID) and does it have any sold?
613 613
 					// If so, then we need to remove it's sold from the DTT_sold.
614
-					if ( $ticket->ID() && $ticket->sold() > 0 ) {
615
-						$saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() );
616
-						$saved_datetimes[ $row_id ]->save();
614
+					if ($ticket->ID() && $ticket->sold() > 0) {
615
+						$saved_datetimes[$row_id]->decrease_sold($ticket->sold());
616
+						$saved_datetimes[$row_id]->save();
617 617
 					}
618 618
 				}
619 619
 			}
620 620
 		}
621 621
 		// cap ticket qty by datetime reg limits
622
-		$ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) );
622
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
623 623
 		return $ticket;
624 624
 	}
625 625
 
@@ -640,39 +640,39 @@  discard block
 block discarded – undo
640 640
 		EE_Ticket $ticket,
641 641
 		$price_rows = array(),
642 642
 		$ticket_price = 0,
643
-		$base_price = 0 ,
643
+		$base_price = 0,
644 644
 		$base_price_id = 0
645 645
 	) {
646 646
 
647 647
 		// create new ticket that's a copy of the existing
648 648
 		// except a new id of course (and not archived)
649 649
 		// AND has the new TKT_price associated with it.
650
-		$new_ticket = clone( $ticket );
651
-		$new_ticket->set( 'TKT_ID', 0 );
652
-		$new_ticket->set( 'TKT_deleted', 0 );
653
-		$new_ticket->set( 'TKT_price', $ticket_price );
654
-		$new_ticket->set( 'TKT_sold', 0 );
650
+		$new_ticket = clone($ticket);
651
+		$new_ticket->set('TKT_ID', 0);
652
+		$new_ticket->set('TKT_deleted', 0);
653
+		$new_ticket->set('TKT_price', $ticket_price);
654
+		$new_ticket->set('TKT_sold', 0);
655 655
 		// let's get a new ID for this ticket
656 656
 		$new_ticket->save();
657 657
 		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
658
-		$datetimes_on_existing = $ticket->get_many_related( 'Datetime' );
658
+		$datetimes_on_existing = $ticket->get_many_related('Datetime');
659 659
 		$new_ticket = $this->_update_ticket_datetimes(
660 660
 			$new_ticket,
661 661
 			$datetimes_on_existing,
662
-			array_keys( $datetimes_on_existing )
662
+			array_keys($datetimes_on_existing)
663 663
 		);
664 664
 
665 665
 		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
666 666
 		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
667 667
 		// available.
668
-		if ( $ticket->sold() > 0 ) {
668
+		if ($ticket->sold() > 0) {
669 669
 			$new_qty = $ticket->qty() - $ticket->sold();
670
-			$new_ticket->set_qty( $new_qty );
670
+			$new_ticket->set_qty($new_qty);
671 671
 		}
672 672
 		//now we update the prices just for this ticket
673
-		$new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true );
673
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
674 674
 		//and we update the base price
675
-		$new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id );
675
+		$new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id);
676 676
 		return $new_ticket;
677 677
 	}
678 678
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	 * @param int|bool 		$base_price_id  if present then this is the base_price_id being updated.
693 693
 	 * @return EE_Ticket
694 694
 	 */
695
-	protected function  _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) {
695
+	protected function  _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) {
696 696
 
697 697
 		//let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session.
698 698
 		$current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers();
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		$updated_prices = array();
701 701
 
702 702
 		// if $base_price ! FALSE then updating a base price.
703
-		if ( $base_price !== FALSE ) {
703
+		if ($base_price !== FALSE) {
704 704
 			$prices[1] = array(
705 705
 				'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id,
706 706
 				'PRT_ID' => 1,
@@ -711,47 +711,47 @@  discard block
 block discarded – undo
711 711
 		}
712 712
 
713 713
 		//possibly need to save tkt
714
-		if ( ! $ticket->ID() )
714
+		if ( ! $ticket->ID())
715 715
 			$ticket->save();
716 716
 
717
-		foreach ( $prices as $row => $prc ) {
718
-			$prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL;
719
-			if ( empty($prt_id) )
717
+		foreach ($prices as $row => $prc) {
718
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL;
719
+			if (empty($prt_id))
720 720
 				continue; //prices MUST have a price type id.
721 721
 			$PRC_values = array(
722
-				'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL,
722
+				'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL,
723 723
 				'PRT_ID' => $prt_id,
724
-				'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
725
-				'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
726
-				'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
724
+				'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
725
+				'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
726
+				'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
727 727
 				'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor
728 728
 				'PRC_order' => $row
729 729
 				);
730
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
730
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
731 731
 				$PRC_values['PRC_ID'] = 0;
732
-				$PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE);
732
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE);
733 733
 			} else {
734
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
734
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
735 735
 				//update this price with new values
736
-				foreach ( $PRC_values as $field => $newprc ) {
737
-					$PRC->set( $field, $newprc );
736
+				foreach ($PRC_values as $field => $newprc) {
737
+					$PRC->set($field, $newprc);
738 738
 				}
739 739
 			}
740 740
 			$PRC->save();
741 741
 			$prcid = $PRC->ID();
742 742
 			$updated_prices[$prcid] = $PRC;
743
-			$ticket->_add_relation_to( $PRC, 'Price' );
743
+			$ticket->_add_relation_to($PRC, 'Price');
744 744
 		}
745 745
 
746 746
 		//now let's remove any prices that got removed from the ticket
747
-		if ( !empty ( $current_prices_on_ticket ) ) {
747
+		if ( ! empty ($current_prices_on_ticket)) {
748 748
 			$current = array_keys($current_prices_on_ticket);
749 749
 			$updated = array_keys($updated_prices);
750 750
 			$prices_to_remove = array_diff($current, $updated);
751
-			if ( !empty( $prices_to_remove ) ) {
752
-				foreach ( $prices_to_remove as $prc_id ) {
751
+			if ( ! empty($prices_to_remove)) {
752
+				foreach ($prices_to_remove as $prc_id) {
753 753
 					$p = $current_prices_on_ticket[$prc_id];
754
-					$ticket->_remove_relation_to( $p, 'Price' );
754
+					$ticket->_remove_relation_to($p, 'Price');
755 755
 
756 756
 					//delete permanently the price
757 757
 					$p->delete_permanently();
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
 
766 766
 
767
-	public function autosave_handling( $event_admin_obj ) {
767
+	public function autosave_handling($event_admin_obj) {
768 768
 		return $event_admin_obj; //doing nothing for the moment.
769 769
 		//todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method)
770 770
 
@@ -798,12 +798,12 @@  discard block
 block discarded – undo
798 798
 
799 799
 		//default main template args
800 800
 		$main_template_args = array(
801
-			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
801
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
802 802
 			'existing_datetime_ids' => '',
803 803
 			'total_dtt_rows' => 1,
804
-			'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
804
+			'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
805 805
 			'datetime_rows' => '',
806
-			'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
806
+			'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
807 807
 			'ticket_rows' => '',
808 808
 			'existing_ticket_ids' => '',
809 809
 			'total_ticket_rows' => 1,
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 
814 814
 		$timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL;
815 815
 
816
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
816
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
817 817
 
818 818
 		/**
819 819
 		 * 1. Start with retrieving Datetimes
@@ -821,37 +821,37 @@  discard block
 block discarded – undo
821 821
 		 * 3. For each ticket get related prices
822 822
 		 */
823 823
 
824
-		$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) );
825
-		$times = $DTM->get_all_event_dates( $evtID );
824
+		$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone));
825
+		$times = $DTM->get_all_event_dates($evtID);
826 826
 
827 827
 
828 828
 
829 829
 		$main_template_args['total_dtt_rows'] = count($times);
830
-		foreach ( $times as $time ) {
830
+		foreach ($times as $time) {
831 831
 			$dttid = $time->get('DTT_ID');
832 832
 			$dttrow = $time->get('DTT_order');
833 833
 			$existing_datetime_ids[] = $dttid;
834 834
 
835 835
 			//tickets attached
836
-			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array();
836
+			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array();
837 837
 
838 838
 			//if there are no related tickets this is likely a new event OR autodraft
839 839
 			// event so we need to generate the default tickets because dtts
840 840
 			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
841 841
 			// datetime on the event.
842
-			if ( empty ( $related_tickets ) && count( $times ) < 2 ) {
842
+			if (empty ($related_tickets) && count($times) < 2) {
843 843
 				$related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
844 844
 
845 845
 				//this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
846 846
 				$default_prices = EEM_Price::instance()->get_all_default_prices();
847 847
 
848
-				$main_default_ticket = reset( $related_tickets );
849
-				if ( $main_default_ticket instanceof EE_Ticket ) {
850
-					foreach ( $default_prices as $default_price ) {
851
-						if ( $default_price->is_base_price() ) {
848
+				$main_default_ticket = reset($related_tickets);
849
+				if ($main_default_ticket instanceof EE_Ticket) {
850
+					foreach ($default_prices as $default_price) {
851
+						if ($default_price->is_base_price()) {
852 852
 							continue;
853 853
 						}
854
-						$main_default_ticket->cache( 'Price', $default_price );
854
+						$main_default_ticket->cache('Price', $default_price);
855 855
 					}
856 856
 				}
857 857
 			}
@@ -860,11 +860,11 @@  discard block
 block discarded – undo
860 860
 			//we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information.
861 861
 
862 862
 			//loop through and setup the ticket rows and make sure the order is set.
863
-			foreach ( $related_tickets as $ticket ) {
863
+			foreach ($related_tickets as $ticket) {
864 864
 				$tktid = $ticket->get('TKT_ID');
865 865
 				$tktrow = $ticket->get('TKT_row');
866 866
 				//we only want unique tickets in our final display!!
867
-				if ( !in_array( $tktid, $existing_ticket_ids ) ) {
867
+				if ( ! in_array($tktid, $existing_ticket_ids)) {
868 868
 					$existing_ticket_ids[] = $tktid;
869 869
 					$all_tickets[] = $ticket;
870 870
 				}
@@ -873,56 +873,56 @@  discard block
 block discarded – undo
873 873
 				$datetime_tickets[$dttid][] = $tktrow;
874 874
 
875 875
 				//temporary cache of this datetime info for this ticket for later processing of ticket rows.
876
-				if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) )
876
+				if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid]))
877 877
 					$ticket_datetimes[$tktid][] = $dttrow;
878 878
 			}
879 879
 		}
880 880
 
881
-		$main_template_args['total_ticket_rows'] = count( $existing_ticket_ids );
882
-		$main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids );
883
-		$main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids );
881
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
882
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
883
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
884 884
 
885 885
 		//sort $all_tickets by order
886
-		usort( $all_tickets, function( $a, $b ) {
886
+		usort($all_tickets, function($a, $b) {
887 887
 			$a_order = (int) $a->get('TKT_order');
888 888
 			$b_order = (int) $b->get('TKT_order');
889
-			if ( $a_order == $b_order ) {
889
+			if ($a_order == $b_order) {
890 890
 				return 0;
891 891
 			}
892
-			return ( $a_order < $b_order ) ? -1 : 1;
892
+			return ($a_order < $b_order) ? -1 : 1;
893 893
 		});
894 894
 
895 895
 		//k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again.
896 896
 		$dttrow = 1;
897
-		foreach ( $times as $time ) {
898
-			$main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times );
897
+		foreach ($times as $time) {
898
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times);
899 899
 			$dttrow++;
900 900
 		}
901 901
 
902 902
 		//then loop through all tickets for the ticket rows.
903 903
 		$tktrow = 1;
904
-		foreach ( $all_tickets as $ticket ) {
905
-			$main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets );
904
+		foreach ($all_tickets as $ticket) {
905
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets);
906 906
 			$tktrow++;
907 907
 		}
908 908
 
909 909
 		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets);
910
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php';
911
-		EEH_Template::display_template( $template, $main_template_args );
910
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php';
911
+		EEH_Template::display_template($template, $main_template_args);
912 912
 		return;
913 913
 	}
914 914
 
915 915
 
916 916
 
917
-	protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) {
917
+	protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) {
918 918
 
919 919
 		$dtt_display_template_args = array(
920
-			'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ),
921
-			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ),
920
+			'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts),
921
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default),
922 922
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow
923 923
 			);
924
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php';
925
-		return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE);
924
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php';
925
+		return EEH_Template::display_template($template, $dtt_display_template_args, TRUE);
926 926
 	}
927 927
 
928 928
 
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 	 *
941 941
 	 * @return string Generated edit row.
942 942
 	 */
943
-	protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) {
943
+	protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) {
944 944
 
945 945
 		// if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true.
946 946
 		$default = ! $dtt instanceof EE_Datetime ? true : false;
@@ -948,30 +948,30 @@  discard block
 block discarded – undo
948 948
 		$template_args = array(
949 949
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
950 950
 			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
951
-			'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
951
+			'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
952 952
 			'DTT_ID' => $default ? '' : $dtt->ID(),
953 953
 			'DTT_name' => $default ? '' : $dtt->name(),
954 954
 			'DTT_description' => $default ? '' : $dtt->description(),
955
-			'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
956
-			'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
957
-			'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'),
955
+			'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
956
+			'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
957
+			'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'),
958 958
 			'DTT_order' => $default ? 'DTTNUM' : $dttrow,
959 959
 			'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'),
960
-			'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
961
-			'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0  ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable'
960
+			'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
961
+			'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable'
962 962
 			);
963 963
 
964
-		$template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
964
+		$template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
965 965
 
966 966
 		//allow filtering of template args at this point.
967
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event );
967
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event);
968 968
 
969
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php';
970
-		return EEH_Template::display_template( $template, $template_args, TRUE );
969
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php';
970
+		return EEH_Template::display_template($template, $template_args, TRUE);
971 971
 	}
972 972
 
973 973
 
974
-	protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) {
974
+	protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) {
975 975
 
976 976
 		$template_args = array(
977 977
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
@@ -979,47 +979,47 @@  discard block
 block discarded – undo
979 979
 			'DTT_description' => $default ? '' : $dtt->description(),
980 980
 			'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '',
981 981
 			'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '',
982
-			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
982
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
983 983
 			'DTT_ID' => $default ? '' : $dtt->ID()
984 984
 			);
985 985
 
986 986
 		//need to setup the list items (but only if this isnt' a default skeleton setup)
987
-		if ( !$default ) {
987
+		if ( ! $default) {
988 988
 			$tktrow = 1;
989
-			foreach ( $all_tickets as $ticket ) {
990
-				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default );
989
+			foreach ($all_tickets as $ticket) {
990
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default);
991 991
 				$tktrow++;
992 992
 			}
993 993
 		}
994 994
 
995 995
 		//filter template args at this point
996
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event );
996
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event);
997 997
 
998
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php';
999
-		return EEH_Template::display_template( $template, $template_args, TRUE );
998
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php';
999
+		return EEH_Template::display_template($template, $template_args, TRUE);
1000 1000
 	}
1001 1001
 
1002 1002
 
1003 1003
 
1004
-	protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) {
1005
-		$tktid = !empty( $ticket ) ? $ticket->ID() : 0;
1006
-		$dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array();
1004
+	protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) {
1005
+		$tktid = ! empty($ticket) ? $ticket->ID() : 0;
1006
+		$dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array();
1007 1007
 
1008
-		$displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0;
1008
+		$displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0;
1009 1009
 		$template_args = array(
1010 1010
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
1011
-			'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow,
1011
+			'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1012 1012
 			'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '',
1013 1013
 			'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '',
1014
-			'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'),
1015
-			'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(),
1014
+			'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'),
1015
+			'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(),
1016 1016
 			);
1017 1017
 
1018 1018
 		//filter template args
1019
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event );
1019
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event);
1020 1020
 
1021
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php';
1022
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1021
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php';
1022
+		return EEH_Template::display_template($template, $template_args, TRUE);
1023 1023
 	}
1024 1024
 
1025 1025
 
@@ -1041,37 +1041,37 @@  discard block
 block discarded – undo
1041 1041
 	 *
1042 1042
 	 * @return [type] [description]
1043 1043
 	 */
1044
-	protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) {
1044
+	protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) {
1045 1045
 
1046 1046
 		//if $ticket is not an instance of EE_Ticket then force default to true.
1047
-		$default =  ! $ticket instanceof EE_Ticket ? true : false;
1047
+		$default = ! $ticket instanceof EE_Ticket ? true : false;
1048 1048
 
1049
-		$prices = ! empty( $ticket ) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array();
1049
+		$prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array();
1050 1050
 
1051 1051
 		//if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on
1052 1052
 		//the object.  This is done by not including any query_params.
1053
-		if ( $ticket instanceof EE_Ticket && $ticket->is_default() && ( count( $prices ) === 1  || empty( $prices ) ) ) {
1054
-			$prices = $ticket->get_many_related( 'Price' );
1053
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1054
+			$prices = $ticket->get_many_related('Price');
1055 1055
 		}
1056 1056
 
1057 1057
 		// check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket).  This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1058
-		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE;
1058
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE;
1059 1059
 
1060
-		$tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array();
1060
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1061 1061
 
1062 1062
 		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1063 1063
 		$base_price = $default ? NULL :  $ticket->base_price();
1064 1064
 		$count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE);
1065 1065
 
1066 1066
 		//breaking out complicated condition for ticket_status
1067
-		if ( $default ) {
1068
-			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1067
+		if ($default) {
1068
+			$ticket_status_class = ' tkt-status-'.EE_Ticket::onsale;
1069 1069
 		} else {
1070
-			$ticket_status_class =  $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status();
1070
+			$ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status();
1071 1071
 		}
1072 1072
 
1073 1073
 		//breaking out complicated condition for TKT_taxable
1074
-		if ( $default ) {
1074
+		if ($default) {
1075 1075
 			$TKT_taxable = '';
1076 1076
 		} else {
1077 1077
 			$TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : '';
@@ -1086,19 +1086,19 @@  discard block
 block discarded – undo
1086 1086
 			'edit_tkt_expanded' => '',
1087 1087
 			'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1088 1088
 			'TKT_name' => $default ? '' : $ticket->get('TKT_name'),
1089
-			'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
1090
-			'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']  ),
1091
-			'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE),
1089
+			'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
1090
+			'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
1091
+			'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE),
1092 1092
 			'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE),
1093 1093
 			'TKT_price_code' => EE_Registry::instance()->CFG->currency->code,
1094 1094
 			'TKT_price_amount' => $default ? 0 : $ticket_subtotal,
1095
-			'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'),
1096
-			'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'),
1097
-			'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'),
1098
-			'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ),
1099
-			'TKT_max' => $default ? '' :  $ticket->get_pretty('TKT_max','input'),
1095
+			'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'),
1096
+			'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'),
1097
+			'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'),
1098
+			'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')),
1099
+			'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'),
1100 1100
 			'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'),
1101
-			'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ),
1101
+			'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))),
1102 1102
 			'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'),
1103 1103
 			'TKT_description' => $default ? '' : $ticket->get('TKT_description'),
1104 1104
 			'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'),
@@ -1107,99 +1107,99 @@  discard block
 block discarded – undo
1107 1107
 			'ticket_price_rows' => '',
1108 1108
 			'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'),
1109 1109
 			'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1110
-			'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"',
1111
-			'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '',
1110
+			'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"',
1111
+			'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '',
1112 1112
 			'total_price_rows' => count($prices) > 1 ? count($prices) : 1,
1113 1113
 			'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '',
1114 1114
 			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts),
1115 1115
 			'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts),
1116
-			'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ),
1116
+			'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)),
1117 1117
 			'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'),
1118 1118
 			'TKT_taxable' => $TKT_taxable,
1119 1119
 			'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"',
1120 1120
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1121
-			'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ),
1121
+			'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE),
1122 1122
 			'TKT_subtotal_amount' => $ticket_subtotal,
1123
-			'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ),
1123
+			'tax_rows' => $this->_get_tax_rows($tktrow, $ticket),
1124 1124
 			'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE,
1125 1125
 			'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '',
1126 1126
 			'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable',
1127 1127
 			'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable'
1128 1128
 			);
1129 1129
 
1130
-		$template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1130
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1131 1131
 
1132 1132
 		//handle rows that should NOT be empty
1133
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1133
+		if (empty($template_args['TKT_start_date'])) {
1134 1134
 			//if empty then the start date will be now.
1135
-			$template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp'));
1136
-			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1135
+			$template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp'));
1136
+			$template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1137 1137
 		}
1138 1138
 
1139
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1139
+		if (empty($template_args['TKT_end_date'])) {
1140 1140
 
1141 1141
 			//get the earliest datetime (if present);
1142
-			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1142
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL;
1143 1143
 
1144
-			if ( !empty( $earliest_dtt ) ) {
1145
-				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
1144
+			if ( ! empty($earliest_dtt)) {
1145
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
1146 1146
 			} else {
1147 1147
 				//default so let's just use what's been set for the default date-time which is 30 days from now.
1148
-				$template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") )  );
1148
+				$template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y")));
1149 1149
 			}
1150
-			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1150
+			$template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1151 1151
 		}
1152 1152
 
1153 1153
 		//generate ticket_datetime items
1154
-		if ( ! $default ) {
1154
+		if ( ! $default) {
1155 1155
 			$dttrow = 1;
1156
-			foreach ( $all_dtts as $dtt ) {
1157
-				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default );
1156
+			foreach ($all_dtts as $dtt) {
1157
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default);
1158 1158
 				$dttrow++;
1159 1159
 			}
1160 1160
 		}
1161 1161
 
1162 1162
 		$prcrow = 1;
1163
-		foreach ( $prices as $price ) {
1164
-			if ( $price->is_base_price() ) {
1163
+		foreach ($prices as $price) {
1164
+			if ($price->is_base_price()) {
1165 1165
 				$prcrow++;
1166 1166
 				continue;
1167 1167
 			}
1168
-			$show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1  ? FALSE : TRUE;
1169
-			$show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE;
1170
-			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create );
1168
+			$show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE;
1169
+			$show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE;
1170
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create);
1171 1171
 			$prcrow++;
1172 1172
 		}
1173 1173
 
1174 1174
 		//filter $template_args
1175
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event );
1175
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event);
1176 1176
 
1177
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php';
1178
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1177
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php';
1178
+		return EEH_Template::display_template($template, $template_args, TRUE);
1179 1179
 	}
1180 1180
 
1181 1181
 
1182 1182
 
1183 1183
 
1184 1184
 
1185
-	protected function _get_tax_rows( $tktrow, $ticket ) {
1185
+	protected function _get_tax_rows($tktrow, $ticket) {
1186 1186
 		$tax_rows = '';
1187
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php';
1187
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php';
1188 1188
 		$template_args = array();
1189
-		$taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1190
-		foreach ( $taxes as $tax ) {
1191
-			$tax_added = $this->_get_tax_added( $tax, $ticket );
1189
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1190
+		foreach ($taxes as $tax) {
1191
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1192 1192
 			$template_args = array(
1193
-				'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1193
+				'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1194 1194
 				'tax_id' => $tax->ID(),
1195 1195
 				'tkt_row' => $tktrow,
1196 1196
 				'tax_label' => $tax->get('PRC_name'),
1197 1197
 				'tax_added' => $tax_added,
1198
-				'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ),
1198
+				'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE),
1199 1199
 				'tax_amount' => $tax->get('PRC_amount')
1200 1200
 				);
1201
-			$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event  );
1202
-			$tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE );
1201
+			$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event);
1202
+			$tax_rows .= EEH_Template::display_template($template, $template_args, TRUE);
1203 1203
 		}
1204 1204
 
1205 1205
 
@@ -1207,81 +1207,81 @@  discard block
 block discarded – undo
1207 1207
 	}
1208 1208
 
1209 1209
 
1210
-	protected function _get_tax_added( EE_Price $tax, $ticket ) {
1211
-		$subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal();
1210
+	protected function _get_tax_added(EE_Price $tax, $ticket) {
1211
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1212 1212
 		return $subtotal * $tax->get('PRC_amount') / 100;
1213 1213
 	}
1214 1214
 
1215 1215
 
1216 1216
 
1217 1217
 
1218
-	protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) {
1219
-		$send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE;
1218
+	protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) {
1219
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE;
1220 1220
 		$template_args = array(
1221 1221
 			'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1222 1222
 			'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1223 1223
 			'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices',
1224
-			'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ),
1224
+			'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled),
1225 1225
 			'PRC_ID' => $default && empty($price) ? 0 : $price->ID(),
1226 1226
 			'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'),
1227 1227
 			'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'),
1228 1228
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1229 1229
 			'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"',
1230
-			'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1231
-			'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1232
-			'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ),
1233
-			'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'),
1234
-			'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ),
1230
+			'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1231
+			'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1232
+			'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''),
1233
+			'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'),
1234
+			'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'),
1235 1235
 			'show_trash_icon' => $show_trash ? '' : ' style="display:none;"',
1236 1236
 			'show_create_button' => $show_create ? '' : ' style="display:none;"',
1237
-			'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'),
1238
-			'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE
1237
+			'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'),
1238
+			'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE
1239 1239
 			);
1240 1240
 
1241
-	$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event );
1241
+	$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event);
1242 1242
 
1243
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php';
1244
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1243
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php';
1244
+		return EEH_Template::display_template($template, $template_args, TRUE);
1245 1245
 	}
1246 1246
 
1247 1247
 
1248
-	protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) {
1249
-		if ( $price->is_base_price() ) {
1250
-			return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default );
1248
+	protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) {
1249
+		if ($price->is_base_price()) {
1250
+			return $this->_get_base_price_template($tktrow, $prcrow, $price, $default);
1251 1251
 		} else {
1252
-			return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled );
1252
+			return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled);
1253 1253
 		}
1254 1254
 
1255 1255
 	}
1256 1256
 
1257 1257
 
1258
-	protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) {
1258
+	protected function _get_base_price_template($tktrow, $prcrow, $price, $default) {
1259 1259
 		$template_args = array(
1260 1260
 				'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1261
-				'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow,
1262
-				'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'),
1261
+				'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1262
+				'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1263 1263
 				'PRT_name' => __('Price', 'event_espresso'),
1264 1264
 				'price_selected_operator' => '+',
1265 1265
 				'price_selected_is_percent' => 0
1266 1266
 			);
1267
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php';
1267
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php';
1268 1268
 
1269
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event );
1269
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event);
1270 1270
 
1271
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1271
+		return EEH_Template::display_template($template, $template_args, TRUE);
1272 1272
 	}
1273 1273
 
1274 1274
 
1275 1275
 
1276
-	protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) {
1277
-		$select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]';
1278
-		$price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) );
1279
-		$price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php';
1280
-		$all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array();
1281
-		$selected_price_type_id = $default && empty( $price ) ? 0 : $price->type();
1276
+	protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) {
1277
+		$select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]';
1278
+		$price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3'))));
1279
+		$price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php';
1280
+		$all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array();
1281
+		$selected_price_type_id = $default && empty($price) ? 0 : $price->type();
1282 1282
 		$price_option_spans = '';
1283 1283
 		//setup pricetypes for selector
1284
-		foreach ( $price_types as $price_type ) {
1284
+		foreach ($price_types as $price_type) {
1285 1285
 			$all_price_types[] = array(
1286 1286
 				'id' => $price_type->ID(),
1287 1287
 				'text' => $price_type->get('PRT_name'),
@@ -1293,50 +1293,50 @@  discard block
 block discarded – undo
1293 1293
 				'PRT_operator' => $price_type->is_discount() ? '-' : '+',
1294 1294
 				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0
1295 1295
 				);
1296
-			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE );
1296
+			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE);
1297 1297
 		}
1298 1298
 
1299
-		$select_params = $disabled ? 'style="width:auto;" disabled'  : 'style="width:auto;"';
1299
+		$select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"';
1300 1300
 		$main_name = $select_name;
1301
-		$select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name;
1301
+		$select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name;
1302 1302
 
1303 1303
 		$template_args = array(
1304 1304
 			'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1305
-			'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow,
1306
-			'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ),
1305
+			'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1306
+			'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'),
1307 1307
 			'main_name' => $main_name,
1308 1308
 			'selected_price_type_id' => $selected_price_type_id,
1309 1309
 			'price_option_spans' => $price_option_spans,
1310
-			'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ),
1311
-			'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ),
1310
+			'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'),
1311
+			'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0),
1312 1312
 			'disabled' => $disabled
1313 1313
 			);
1314 1314
 
1315
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event );
1315
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event);
1316 1316
 
1317
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php';
1317
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php';
1318 1318
 
1319
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1319
+		return EEH_Template::display_template($template, $template_args, TRUE);
1320 1320
 	}
1321 1321
 
1322 1322
 
1323 1323
 
1324
-	protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) {
1325
-		$dttid = !empty($dtt) ? $dtt->ID() : 0;
1326
-		$displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0;
1327
-		$tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array();
1324
+	protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) {
1325
+		$dttid = ! empty($dtt) ? $dtt->ID() : 0;
1326
+		$displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0;
1327
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1328 1328
 		$template_args = array(
1329
-			'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow,
1329
+			'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow,
1330 1330
 			'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1331
-			'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '',
1332
-			'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '',
1333
-			'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ),
1331
+			'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '',
1332
+			'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '',
1333
+			'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE),
1334 1334
 			'tkt_status_class' => '',
1335 1335
 			);
1336 1336
 
1337
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event );
1338
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1339
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1337
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event);
1338
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1339
+		return EEH_Template::display_template($template, $template_args, TRUE);
1340 1340
 	}
1341 1341
 
1342 1342
 
@@ -1344,53 +1344,53 @@  discard block
 block discarded – undo
1344 1344
 	protected function _get_ticket_js_structure($all_dtts, $all_tickets) {
1345 1345
 		$template_args = array(
1346 1346
 			'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts),
1347
-			'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE),
1348
-			'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ),
1347
+			'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE),
1348
+			'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL),
1349 1349
 			'default_price_rows' => '',
1350 1350
 			'default_base_price_amount' => 0,
1351 1351
 			'default_base_price_name' => '',
1352 1352
 			'default_base_price_description' => '',
1353
-			'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ),
1354
-			'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ),
1353
+			'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE),
1354
+			'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE),
1355 1355
 			'existing_available_datetime_tickets_list' => '',
1356 1356
 			'existing_available_ticket_datetimes_list' => '',
1357
-			'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ),
1358
-			'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE )
1357
+			'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE),
1358
+			'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE)
1359 1359
 			);
1360 1360
 
1361 1361
 		$tktrow = 1;
1362
-		foreach ( $all_tickets as $ticket ) {
1363
-			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE );
1362
+		foreach ($all_tickets as $ticket) {
1363
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE);
1364 1364
 			$tktrow++;
1365 1365
 		}
1366 1366
 
1367 1367
 
1368 1368
 		$dttrow = 1;
1369
-		foreach ( $all_dtts as $dtt ) {
1370
-			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE );
1369
+		foreach ($all_dtts as $dtt) {
1370
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE);
1371 1371
 			$dttrow++;
1372 1372
 		}
1373 1373
 
1374 1374
 		$default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices();
1375 1375
 		$prcrow = 1;
1376
-		foreach ( $default_prices as $price ) {
1377
-			if ( $price->is_base_price() ) {
1376
+		foreach ($default_prices as $price) {
1377
+			if ($price->is_base_price()) {
1378 1378
 				$template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float');
1379 1379
 				$template_args['default_base_price_name'] = $price->get('PRC_name');
1380 1380
 				$template_args['default_base_price_description'] = $price->get('PRC_desc');
1381 1381
 				$prcrow++;
1382 1382
 				continue;
1383 1383
 			}
1384
-			$show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1  ? FALSE : TRUE;
1385
-			$show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE;
1386
-			$template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create );
1384
+			$show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE;
1385
+			$show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE;
1386
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create);
1387 1387
 			$prcrow++;
1388 1388
 		}
1389 1389
 
1390
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event );
1390
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event);
1391 1391
 
1392
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php';
1393
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1392
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php';
1393
+		return EEH_Template::display_template($template, $template_args, TRUE);
1394 1394
 	}
1395 1395
 
1396 1396
 
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 1 patch
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage
9 9
  * @author				Mike Nelson
10 10
  */
11
-abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{
11
+abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable {
12 12
 
13 13
 	/**
14 14
 	 * the input's name attribute
@@ -141,67 +141,67 @@  discard block
 block discarded – undo
141 141
 	 *		@type EE_Validation_Strategy_Base[] $validation_strategies
142 142
 	 * }
143 143
 	 */
144
-	public function __construct( $input_args = array() ){
145
-		$input_args = apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this );
144
+	public function __construct($input_args = array()) {
145
+		$input_args = apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
146 146
 		// the following properties must be cast as arrays
147 147
 		$set_as_array = array(
148 148
 			'validation_strategies'
149 149
 		);
150 150
 		// loop thru incoming options
151
-		foreach( $input_args as $key => $value ) {
151
+		foreach ($input_args as $key => $value) {
152 152
 			// add underscore to $key to match property names
153
-			$_key = '_' . $key;
154
-			if ( property_exists( $this, $_key )) {
153
+			$_key = '_'.$key;
154
+			if (property_exists($this, $_key)) {
155 155
 				// first check if this property needs to be set as an array
156
-				if ( isset( $set_as_array[ $key ] )) {
156
+				if (isset($set_as_array[$key])) {
157 157
 					// ensure value is an array
158
-					$value = is_array( $value ) ? $value : array( $value );
158
+					$value = is_array($value) ? $value : array($value);
159 159
 					// and merge with existing values
160
-					$this->{$_key} = array_merge( $this->{$_key}, $value );
160
+					$this->{$_key} = array_merge($this->{$_key}, $value);
161 161
 				} else {
162 162
 					$this->{$_key} = $value;
163 163
 				}
164 164
 			}
165 165
 		}
166 166
 		// ensure that "required" is set correctly
167
-		$this->set_required( $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) ? $input_args[ 'required_validation_error_message' ] : NULL );
167
+		$this->set_required($this->_required, isset($input_args['required_validation_error_message']) ? $input_args['required_validation_error_message'] : NULL);
168 168
 
169
-		$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
169
+		$this->_html_name_specified = isset($input_args['html_name']) ? TRUE : FALSE;
170 170
 
171 171
 		$this->_display_strategy->_construct_finalize($this);
172 172
 
173
-		if ( $this->_validation_strategies ){
174
-			foreach( $this->_validation_strategies as $validation_strategy ){
173
+		if ($this->_validation_strategies) {
174
+			foreach ($this->_validation_strategies as $validation_strategy) {
175 175
 				$validation_strategy->_construct_finalize($this);
176 176
 			}
177 177
 		}
178 178
 
179
-		if( ! $this->_normalization_strategy){
179
+		if ( ! $this->_normalization_strategy) {
180 180
 			$this->_normalization_strategy = new EE_Text_Normalization();
181 181
 		}
182 182
 		$this->_normalization_strategy->_construct_finalize($this);
183 183
 
184 184
 		//at least we can use the normalization strategy to populate the default
185
-		if( isset( $input_args[ 'default' ] ) ) {
186
-			$this->set_default( $input_args[ 'default' ] );
185
+		if (isset($input_args['default'])) {
186
+			$this->set_default($input_args['default']);
187 187
 		}
188 188
 
189
-		if( ! $this->_sensitive_data_removal_strategy){
189
+		if ( ! $this->_sensitive_data_removal_strategy) {
190 190
 			$this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
191 191
 		}
192 192
 		$this->_sensitive_data_removal_strategy->_construct_finalize($this);
193
-		parent::__construct( $input_args );
193
+		parent::__construct($input_args);
194 194
 	}
195 195
 
196 196
 	/**
197 197
 	 * Sets the html_name to its default value, if none was specified in teh constructor.
198 198
 	 * Calculation involves using the name and the parent's html_name
199 199
 	 */
200
-	protected function _set_default_html_name_if_empty(){
201
-		if( ! $this->_html_name){
202
-			if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){
203
-				$this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
204
-			}else{
200
+	protected function _set_default_html_name_if_empty() {
201
+		if ( ! $this->_html_name) {
202
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
203
+				$this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]";
204
+			} else {
205 205
 				$this->_html_name = $this->name();
206 206
 			}
207 207
 		}
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
 	function _construct_finalize($parent_form_section, $name) {
217 217
 		parent::_construct_finalize($parent_form_section, $name);
218 218
 		$this->_set_default_html_name_if_empty();
219
-		if( ! $this->_html_label ){
220
-			if( ! $this->_html_label_text){
221
-				$this->_html_label_text = ucwords( str_replace("_"," ",$name));
219
+		if ( ! $this->_html_label) {
220
+			if ( ! $this->_html_label_text) {
221
+				$this->_html_label_text = ucwords(str_replace("_", " ", $name));
222 222
 			}
223 223
 		}
224
-		do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name );
224
+		do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
225 225
 	}
226 226
 
227 227
 	 /**
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 	  * @return EE_Display_Strategy_Base
230 230
 	  * @throws EE_Error
231 231
 	  */
232
-	protected function _get_display_strategy(){
233
-		if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){
234
-			throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"),$this->html_name(),$this->html_id()));
235
-		}else{
232
+	protected function _get_display_strategy() {
233
+		if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
234
+			throw new EE_Error(sprintf(__("Cannot get display strategy for form input with name %s and id %s, because it has not been set in the constructor", "event_espresso"), $this->html_name(), $this->html_id()));
235
+		} else {
236 236
 			return $this->_display_strategy;
237 237
 		}
238 238
 	}
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * Sets the display strategy.
241 241
 	 * @param EE_Display_Strategy_Base $strategy
242 242
 	 */
243
-	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){
243
+	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) {
244 244
 		$this->_display_strategy = $strategy;
245 245
 	}
246 246
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 * Sets the sanitization strategy
249 249
 	 * @param EE_Normalization_Strategy_Base $strategy
250 250
 	 */
251
-	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){
251
+	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) {
252 252
 		$this->_normalization_strategy = $strategy;
253 253
 	}
254 254
 
@@ -274,14 +274,14 @@  discard block
 block discarded – undo
274 274
 	 * Gets the display strategy for this input
275 275
 	 * @return EE_Display_Strategy_Base
276 276
 	 */
277
-	public function get_display_strategy(){
277
+	public function get_display_strategy() {
278 278
 		return $this->_display_strategy;
279 279
 	}
280 280
 	/**
281 281
 	 * Overwrites the display strategy
282 282
 	 * @param EE_Display_Strategy_Base $display_strategy
283 283
 	 */
284
-	public function set_display_strategy($display_strategy){
284
+	public function set_display_strategy($display_strategy) {
285 285
 		$this->_display_strategy = $display_strategy;
286 286
 		$this->_display_strategy->_construct_finalize($this);
287 287
 	}
@@ -289,14 +289,14 @@  discard block
 block discarded – undo
289 289
 	 * Gets the normalization strategy set on this input
290 290
 	 * @return EE_Normalization_Strategy_Base
291 291
 	 */
292
-	public function get_normalization_strategy(){
292
+	public function get_normalization_strategy() {
293 293
 		return $this->_normalization_strategy;
294 294
 	}
295 295
 	/**
296 296
 	 * Overwrites the normalization strategy
297 297
 	 * @param EE_Normalization_Strategy_Base $normalization_strategy
298 298
 	 */
299
-	public function set_normalization_strategy($normalization_strategy){
299
+	public function set_normalization_strategy($normalization_strategy) {
300 300
 		$this->_normalization_strategy = $normalization_strategy;
301 301
 		$this->_normalization_strategy->_construct_finalize($this);
302 302
 	}
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
 	 * Returns all teh validation strategies which apply to this field, numerically indexed
306 306
 	 * @return EE_Validation_Strategy_Base[]
307 307
 	 */
308
-	public function get_validation_strategies(){
309
-		if(is_array($this->_validation_strategies)){
308
+	public function get_validation_strategies() {
309
+		if (is_array($this->_validation_strategies)) {
310 310
 			return $this->_validation_strategies;
311
-		}else{
311
+		} else {
312 312
 			return array();
313 313
 		}
314 314
 
@@ -318,9 +318,9 @@  discard block
 block discarded – undo
318 318
 	 * @param EE_Validation_Strategy_Base $validation_strategy
319 319
 	 * @return void
320 320
 	 */
321
-	protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){
322
-		$validation_strategy->_construct_finalize( $this );
323
-		$this->_validation_strategies[ get_class($validation_strategy) ] = $validation_strategy;
321
+	protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
322
+		$validation_strategy->_construct_finalize($this);
323
+		$this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy;
324 324
 
325 325
 	}
326 326
 
@@ -329,18 +329,18 @@  discard block
 block discarded – undo
329 329
 	 * @param EE_Validation_Strategy_Base $validation_strategy
330 330
 	 * @return void
331 331
 	 */
332
-	public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) {
333
-		$this->_add_validation_strategy( $validation_strategy );
332
+	public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
333
+		$this->_add_validation_strategy($validation_strategy);
334 334
 	}
335 335
 
336 336
 	/**
337 337
 	 * The classname of the validation strategy to remove
338 338
 	 * @param string $validation_strategy_classname
339 339
 	 */
340
-	public function remove_validation_strategy( $validation_strategy_classname ) {
341
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
342
-			if( is_subclass_of( $validation_strategy, $validation_strategy_classname ) ){
343
-				unset( $this->_validation_strategies[ $key ] );
340
+	public function remove_validation_strategy($validation_strategy_classname) {
341
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
342
+			if (is_subclass_of($validation_strategy, $validation_strategy_classname)) {
343
+				unset($this->_validation_strategies[$key]);
344 344
 			}
345 345
 		}
346 346
 	}
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 	 * to the parent form's layout strategy
350 350
 	 * @return string
351 351
 	 */
352
-	public function get_html_and_js(){
352
+	public function get_html_and_js() {
353 353
 		return $this->_parent_section->get_html_for_input($this);
354 354
 	}
355 355
 	/**
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 * Makes sure the JS and CSS are enqueued for it
359 359
 	 * @return string
360 360
 	 */
361
-	public function get_html_for_input(){
361
+	public function get_html_for_input() {
362 362
 		return  $this->_get_display_strategy()->display();
363 363
 	}
364 364
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 * @return string
369 369
 	 */
370 370
 	public function html_other_attributes() {
371
-		return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : '';
371
+		return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : '';
372 372
 	}
373 373
 
374 374
 
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	/**
377 377
 	 * @param string $html_other_attributes
378 378
 	 */
379
-	public function set_html_other_attributes( $html_other_attributes ) {
379
+	public function set_html_other_attributes($html_other_attributes) {
380 380
 		$this->_html_other_attributes = $html_other_attributes;
381 381
 	}
382 382
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	 * according to the form section's layout strategy
386 386
 	 * @return string
387 387
 	 */
388
-	public function get_html_for_label(){
388
+	public function get_html_for_label() {
389 389
 		return $this->_parent_section->get_layout_strategy()->display_label($this);
390 390
 	}
391 391
 	/**
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 	 * according to the form section's layout strategy
394 394
 	 * @return string
395 395
 	 */
396
-	public function get_html_for_errors(){
396
+	public function get_html_for_errors() {
397 397
 		return $this->_parent_section->get_layout_strategy()->display_errors($this);
398 398
 	}
399 399
 	/**
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 	 * according to the form section's layout strategy
402 402
 	 * @return string
403 403
 	 */
404
-	public function get_html_for_help(){
404
+	public function get_html_for_help() {
405 405
 		return $this->_parent_section->get_layout_strategy()->display_help_text($this);
406 406
 	}
407 407
 	/**
@@ -410,20 +410,20 @@  discard block
 block discarded – undo
410 410
 	 * @return boolean
411 411
 	 */
412 412
 	protected function _validate() {
413
-		if(is_array($this->_validation_strategies)){
414
-			foreach($this->_validation_strategies as $validation_strategy){
415
-				if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
416
-					try{
413
+		if (is_array($this->_validation_strategies)) {
414
+			foreach ($this->_validation_strategies as $validation_strategy) {
415
+				if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
416
+					try {
417 417
 						$validation_strategy->validate($this->normalized_value());
418
-					}catch(EE_Validation_Error $e){
418
+					} catch (EE_Validation_Error $e) {
419 419
 						$this->add_validation_error($e);
420 420
 					}
421 421
 				}
422 422
 			}
423 423
 		}
424
-		if( $this->get_validation_errors()){
424
+		if ($this->get_validation_errors()) {
425 425
 			return false;
426
-		}else{
426
+		} else {
427 427
 			return true;
428 428
 		}
429 429
 	}
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
 	 * @param string $value
437 437
 	 * @return null|string
438 438
 	 */
439
-	private function _sanitize($value){
440
-		return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field
439
+	private function _sanitize($value) {
440
+		return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field
441 441
 	}
442 442
 
443 443
 
@@ -449,24 +449,24 @@  discard block
 block discarded – undo
449 449
 	 * @param array $req_data like $_POST
450 450
 	 * @return boolean whether or not there was an error
451 451
 	 */
452
-	protected function _normalize( $req_data ) {
452
+	protected function _normalize($req_data) {
453 453
 		//any existing validation errors don't apply so clear them
454 454
 		$this->_validation_errors = array();
455 455
 		try {
456
-			$raw_input = $this->find_form_data_for_this_section( $req_data );
456
+			$raw_input = $this->find_form_data_for_this_section($req_data);
457 457
 			//super simple sanitization for now
458
-			if ( is_array( $raw_input )) {
458
+			if (is_array($raw_input)) {
459 459
 				$this->_raw_value = array();
460
-				foreach( $raw_input as $key => $value ) {
461
-					$this->_raw_value[ $key ] = $this->_sanitize( $value );
460
+				foreach ($raw_input as $key => $value) {
461
+					$this->_raw_value[$key] = $this->_sanitize($value);
462 462
 				}
463 463
 			} else {
464
-				$this->_raw_value = $this->_sanitize( $raw_input );
464
+				$this->_raw_value = $this->_sanitize($raw_input);
465 465
 			}
466 466
 			//we want ot mostly leave the input alone in case we need to re-display it to the user
467
-			$this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() );
468
-		} catch ( EE_Validation_Error $e ) {
469
-			$this->add_validation_error( $e );
467
+			$this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value());
468
+		} catch (EE_Validation_Error $e) {
469
+			$this->add_validation_error($e);
470 470
 		}
471 471
 	}
472 472
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 	/**
476 476
 	 * @return string
477 477
 	 */
478
-	public function html_name(){
478
+	public function html_name() {
479 479
 		return $this->_html_name;
480 480
 	}
481 481
 
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	/**
485 485
 	 * @return string
486 486
 	 */
487
-	function html_label_id(){
488
-		return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl';
487
+	function html_label_id() {
488
+		return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl';
489 489
 	}
490 490
 
491 491
 
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	/**
494 494
 	 * @return string
495 495
 	 */
496
-	function html_label_class(){
496
+	function html_label_class() {
497 497
 		return $this->_html_label_class;
498 498
 	}
499 499
 
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 	/**
503 503
 	 * @return string
504 504
 	 */
505
-	function html_label_style(){
505
+	function html_label_style() {
506 506
 		return $this->_html_label_style;
507 507
 	}
508 508
 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	/**
512 512
 	 * @return string
513 513
 	 */
514
-	function html_label_text(){
514
+	function html_label_text() {
515 515
 		return $this->_html_label_text;
516 516
 	}
517 517
 
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 	/**
521 521
 	 * @return string
522 522
 	 */
523
-	function html_help_text(){
523
+	function html_help_text() {
524 524
 		return $this->_html_help_text;
525 525
 	}
526 526
 
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 	/**
530 530
 	 * @return string
531 531
 	 */
532
-	function html_help_class(){
532
+	function html_help_class() {
533 533
 		return $this->_html_help_class;
534 534
 	}
535 535
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 	/**
539 539
 	 * @return string
540 540
 	 */
541
-	function html_help_style(){
541
+	function html_help_style() {
542 542
 		return $this->_html_style;
543 543
 	}
544 544
 	/**
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 	 * in which case, we would have stored the malicious content to our database.
552 552
 	 * @return string
553 553
 	 */
554
-	function raw_value(){
554
+	function raw_value() {
555 555
 		return $this->_raw_value;
556 556
 	}
557 557
 	/**
@@ -559,15 +559,15 @@  discard block
 block discarded – undo
559 559
 	 * it escapes all html entities
560 560
 	 * @return string
561 561
 	 */
562
-	function raw_value_in_form(){
563
-		return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8');
562
+	function raw_value_in_form() {
563
+		return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
564 564
 	}
565 565
 	/**
566 566
 	 * returns the value after it's been sanitized, and then converted into it's proper type
567 567
 	 * in PHP. Eg, a string, an int, an array,
568 568
 	 * @return mixed
569 569
 	 */
570
-	function normalized_value(){
570
+	function normalized_value() {
571 571
 		return $this->_normalized_value;
572 572
 	}
573 573
 
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	 * the best thing to display
578 578
 	 * @return string
579 579
 	 */
580
-	function pretty_value(){
580
+	function pretty_value() {
581 581
 		return $this->_normalized_value;
582 582
 	}
583 583
 	/**
@@ -596,15 +596,15 @@  discard block
 block discarded – undo
596 596
 		  }</code>
597 597
 	 * @return array
598 598
 	 */
599
-	function get_jquery_validation_rules(){
599
+	function get_jquery_validation_rules() {
600 600
 		$jquery_validation_rules = array();
601
-		foreach($this->get_validation_strategies() as $validation_strategy){
602
-			$jquery_validation_rules = array_replace_recursive( $jquery_validation_rules, $validation_strategy->get_jquery_validation_rule_array());
601
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
602
+			$jquery_validation_rules = array_replace_recursive($jquery_validation_rules, $validation_strategy->get_jquery_validation_rule_array());
603 603
 		}
604 604
 
605
-		if(! empty($jquery_validation_rules)){
606
-			$jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules;
607
-		}else{
605
+		if ( ! empty($jquery_validation_rules)) {
606
+			$jquery_validation_js[$this->html_id(TRUE)] = $jquery_validation_rules;
607
+		} else {
608 608
 			return array();
609 609
 		}
610 610
 		return $jquery_validation_js;
@@ -616,9 +616,9 @@  discard block
 block discarded – undo
616 616
 	 * @param mixed $value
617 617
 	 * @return void
618 618
 	 */
619
-	function set_default($value){
619
+	function set_default($value) {
620 620
 		$this->_normalized_value = $value;
621
-		$this->_raw_value = $this->_normalization_strategy->unnormalize( $value );
621
+		$this->_raw_value = $this->_normalization_strategy->unnormalize($value);
622 622
 	}
623 623
 
624 624
 	/**
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	 * @param string $label
627 627
 	 * @return void
628 628
 	 */
629
-	function set_html_label_text($label){
629
+	function set_html_label_text($label) {
630 630
 		$this->_html_label_text = $label;
631 631
 	}
632 632
 
@@ -638,12 +638,12 @@  discard block
 block discarded – undo
638 638
 	 * @param boolean $required
639 639
 	 * @param null    $required_text
640 640
 	 */
641
-	function set_required($required = true, $required_text = NULL ){
642
-		$required = filter_var( $required, FILTER_VALIDATE_BOOLEAN );
643
-		if ( $required ) {
644
-			$this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) );
641
+	function set_required($required = true, $required_text = NULL) {
642
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
643
+		if ($required) {
644
+			$this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
645 645
 		} else {
646
-			unset( $this->_validation_strategies[ get_class( new EE_Required_Validation_Strategy() ) ] );
646
+			unset($this->_validation_strategies[get_class(new EE_Required_Validation_Strategy())]);
647 647
 		}
648 648
 		$this->_required = $required;
649 649
 	}
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 	 * Returns whether or not this field is required
652 652
 	 * @return boolean
653 653
 	 */
654
-	public function required(){
654
+	public function required() {
655 655
 		return $this->_required;
656 656
 	}
657 657
 
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 	/**
661 661
 	 * @param string $required_css_class
662 662
 	 */
663
-	public function set_required_css_class( $required_css_class ) {
663
+	public function set_required_css_class($required_css_class) {
664 664
 		$this->_required_css_class = $required_css_class;
665 665
 	}
666 666
 
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 	 * Sets the help text, in case
680 680
 	 * @param string $text
681 681
 	 */
682
-	public function set_html_help_text($text){
682
+	public function set_html_help_text($text) {
683 683
 		$this->_html_help_text = $text;
684 684
 	}
685 685
 	/**
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
 	public function clean_sensitive_data() {
692 692
 		//if we do ANY kind of sensitive data removal on this, then just clear out the raw value
693 693
 		//if we need more logic than this we'll make a strategy for it
694
-		if( $this->_sensitive_data_removal_strategy &&
695
-				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){
694
+		if ($this->_sensitive_data_removal_strategy &&
695
+				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) {
696 696
 			$this->_raw_value = NULL;
697 697
 		}
698 698
 		//and clean the normalized value according to the appropriate strategy
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
 	 * @param string $button_size
707 707
 	 * @param string $other_attributes
708 708
 	 */
709
-	public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) {
709
+	public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') {
710 710
 		$button_css_attributes = 'button';
711 711
 		$button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary';
712
-		switch ( $button_size ) {
712
+		switch ($button_size) {
713 713
 			case 'xs' :
714 714
 			case 'extra-small' :
715 715
 				$button_css_attributes .= ' button-xs';
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 			default :
731 731
 				$button_css_attributes .= '';
732 732
 		}
733
-		$this->_button_css_attributes .= ! empty( $other_attributes ) ? $button_css_attributes . ' ' . $other_attributes : $button_css_attributes;
733
+		$this->_button_css_attributes .= ! empty($other_attributes) ? $button_css_attributes.' '.$other_attributes : $button_css_attributes;
734 734
 	}
735 735
 
736 736
 
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 	 * @return string
740 740
 	 */
741 741
 	public function button_css_attributes() {
742
-		if ( empty( $this->_button_css_attributes )) {
742
+		if (empty($this->_button_css_attributes)) {
743 743
 			$this->set_button_css_attributes();
744 744
 		}
745 745
 		return $this->_button_css_attributes;
@@ -759,27 +759,27 @@  discard block
 block discarded – undo
759 759
 	 * @param array $req_data
760 760
 	 * @return mixed whatever the raw value of this form section is in the request data
761 761
 	 */
762
-	public function find_form_data_for_this_section( $req_data ){
762
+	public function find_form_data_for_this_section($req_data) {
763 763
 		// break up the html name by "[]"
764
-		if ( strpos( $this->html_name(), '[' ) !== FALSE ) {
765
-			$before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') );
764
+		if (strpos($this->html_name(), '[') !== FALSE) {
765
+			$before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
766 766
 		} else {
767 767
 			$before_any_brackets = $this->html_name();
768 768
 		}
769 769
 		// grab all of the segments
770
-		preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches);
771
-		if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){
772
-			$name_parts = $matches[ 1 ];
770
+		preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
771
+		if (isset($matches[1]) && is_array($matches[1])) {
772
+			$name_parts = $matches[1];
773 773
 			array_unshift($name_parts, $before_any_brackets);
774
-		}else{
775
-			$name_parts = array( $before_any_brackets );
774
+		} else {
775
+			$name_parts = array($before_any_brackets);
776 776
 		}
777 777
 		// now get the value for the input
778 778
 		$value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data);
779
-		if( $value === NULL ){
779
+		if ($value === NULL) {
780 780
 			//check if this thing's name is at the TOP level of the request data
781
-			if( isset( $req_data[ $this->name() ] ) ){
782
-				$value = $req_data[ $this->name() ];
781
+			if (isset($req_data[$this->name()])) {
782
+				$value = $req_data[$this->name()];
783 783
 			}
784 784
 		}
785 785
 		return $value;
@@ -793,15 +793,15 @@  discard block
 block discarded – undo
793 793
 	 * @param array $req_data
794 794
 	 * @return array | NULL
795 795
 	 */
796
-	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){
797
-		$first_part_to_consider = array_shift( $html_name_parts );
798
-		if( isset( $req_data[ $first_part_to_consider ] ) ){
799
-			if( empty($html_name_parts ) ){
800
-				return $req_data[ $first_part_to_consider ];
801
-			}else{
802
-				return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[ $first_part_to_consider ] );
796
+	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) {
797
+		$first_part_to_consider = array_shift($html_name_parts);
798
+		if (isset($req_data[$first_part_to_consider])) {
799
+			if (empty($html_name_parts)) {
800
+				return $req_data[$first_part_to_consider];
801
+			} else {
802
+				return $this->_find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data[$first_part_to_consider]);
803 803
 			}
804
-		}else{
804
+		} else {
805 805
 			return NULL;
806 806
 		}
807 807
 	}
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 	 * @param array $req_data like $_POST
814 814
 	 * @return boolean
815 815
 	 */
816
-	public function form_data_present_in($req_data = NULL){
817
-		if( $req_data === NULL ){
816
+	public function form_data_present_in($req_data = NULL) {
817
+		if ($req_data === NULL) {
818 818
 			$req_data = $_POST;
819 819
 		}
820
-		$checked_value = $this->find_form_data_for_this_section( $req_data );
821
-		if( $checked_value !== null ){
820
+		$checked_value = $this->find_form_data_for_this_section($req_data);
821
+		if ($checked_value !== null) {
822 822
 			return TRUE;
823
-		}else{
823
+		} else {
824 824
 			return FALSE;
825 825
 		}
826 826
 	}
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Spacing   +594 added lines, -594 removed lines patch added patch discarded remove patch
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 	 * 		@access public
145 145
 	 * 		@return void
146 146
 	 */
147
-	public function __construct( $routing = TRUE ) {
147
+	public function __construct($routing = TRUE) {
148 148
 
149
-		if ( strpos( $this->_get_dir(), 'caffeinated' ) !== false )
149
+		if (strpos($this->_get_dir(), 'caffeinated') !== false)
150 150
 			$this->_is_caf = TRUE;
151 151
 
152 152
 		$this->_yes_no_values = array(
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 
159 159
 		//set the _req_data property.
160
-		$this->_req_data = array_merge( $_GET, $_POST );
160
+		$this->_req_data = array_merge($_GET, $_POST);
161 161
 
162 162
 
163 163
 		//routing enabled?
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		$this->_do_other_page_hooks();
179 179
 
180 180
 		//This just allows us to have extending clases do something specific before the parent constructor runs _page_setup.
181
-		if ( method_exists( $this, '_before_page_setup' ) )
181
+		if (method_exists($this, '_before_page_setup'))
182 182
 			$this->_before_page_setup();
183 183
 
184 184
 		//set up page dependencies
@@ -448,16 +448,16 @@  discard block
 block discarded – undo
448 448
 	 */
449 449
 	protected function _global_ajax_hooks() {
450 450
 		//for lazy loading of metabox content
451
-		add_action( 'wp_ajax_espresso-ajax-content', array( $this, 'ajax_metabox_content'), 10 );
451
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
452 452
 	}
453 453
 
454 454
 
455 455
 
456 456
 	public function ajax_metabox_content() {
457
-		$contentid = isset( $this->_req_data['contentid'] ) ? $this->_req_data['contentid'] : '';
458
-		$url = isset( $this->_req_data['contenturl'] ) ? $this->_req_data['contenturl'] : '';
457
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
458
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
459 459
 
460
-		self::cached_rss_display( $contentid, $url );
460
+		self::cached_rss_display($contentid, $url);
461 461
 		wp_die();
462 462
 	}
463 463
 
@@ -478,87 +478,87 @@  discard block
 block discarded – undo
478 478
 
479 479
 
480 480
 		//admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
481
-		add_action( 'admin_init', array( $this, 'admin_init_global' ), 5 );
481
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
482 482
 
483 483
 
484 484
 		//next verify if we need to load anything...
485
-		$this->_current_page = !empty( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : FALSE;
486
-		$this->page_folder = strtolower( str_replace( '_Admin_Page', '', str_replace( 'Extend_', '', get_class($this) ) ) );
485
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : FALSE;
486
+		$this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
487 487
 
488 488
 		global $ee_menu_slugs;
489 489
 		$ee_menu_slugs = (array) $ee_menu_slugs;
490 490
 
491
-		if ( ( !$this->_current_page || ! isset( $ee_menu_slugs[$this->_current_page] ) ) && !defined( 'DOING_AJAX') ) return FALSE;
491
+		if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) return FALSE;
492 492
 
493 493
 
494 494
 		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
495
-		if ( isset( $this->_req_data['action2'] ) && $this->_req_data['action'] == -1 ) {
496
-			$this->_req_data['action'] = ! empty( $this->_req_data['action2'] ) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
495
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
496
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
497 497
 		}
498 498
 		// then set blank or -1 action values to 'default'
499
-		$this->_req_action = isset( $this->_req_data['action'] ) && ! empty( $this->_req_data['action'] ) && $this->_req_data['action'] != -1 ? sanitize_key( $this->_req_data['action'] ) : 'default';
499
+		$this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
500 500
 
501 501
 		//if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
502
-		$this->_req_action = $this->_req_action == 'default' && isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : $this->_req_action;
502
+		$this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
503 503
 
504 504
 		//however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
505 505
 		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
506 506
 
507 507
 		$this->_current_view = $this->_req_action;
508
-		$this->_req_nonce = $this->_req_action . '_nonce';
508
+		$this->_req_nonce = $this->_req_action.'_nonce';
509 509
 		$this->_define_page_props();
510 510
 
511
-		$this->_current_page_view_url = add_query_arg( array( 'page' => $this->_current_page, 'action' => $this->_current_view ),  $this->_admin_base_url );
511
+		$this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
512 512
 
513 513
 		//default things
514
-		$this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box' );
514
+		$this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
515 515
 
516 516
 		//set page configs
517 517
 		$this->_set_page_routes();
518 518
 		$this->_set_page_config();
519 519
 
520 520
 		//let's include any referrer data in our default_query_args for this route for "stickiness".
521
-		if ( isset( $this->_req_data['wp_referer'] ) ) {
521
+		if (isset($this->_req_data['wp_referer'])) {
522 522
 			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
523 523
 		}
524 524
 
525 525
 		//for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
526
-		if ( method_exists( $this, '_extend_page_config' ) )
526
+		if (method_exists($this, '_extend_page_config'))
527 527
 			$this->_extend_page_config();
528 528
 
529 529
 		//for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
530
-		if ( method_exists( $this, '_extend_page_config_for_cpt' ) )
530
+		if (method_exists($this, '_extend_page_config_for_cpt'))
531 531
 			$this->_extend_page_config_for_cpt();
532 532
 
533 533
 		//filter routes and page_config so addons can add their stuff. Filtering done per class
534
-		$this->_page_routes = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this );
535
-		$this->_page_config = apply_filters( 'FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this );
534
+		$this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this);
535
+		$this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this);
536 536
 
537 537
 
538 538
 		//if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
539
-		if ( method_exists( $this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view ) ) {
540
-			add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view ), 10, 2 );
539
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
540
+			add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2);
541 541
 		}
542 542
 
543 543
 
544 544
 		//next route only if routing enabled
545
-		if ( $this->_routing && !defined('DOING_AJAX') ) {
545
+		if ($this->_routing && ! defined('DOING_AJAX')) {
546 546
 
547 547
 			$this->_verify_routes();
548 548
 
549 549
 			//next let's just check user_access and kill if no access
550 550
 			$this->check_user_access();
551 551
 
552
-			if ( $this->_is_UI_request ) {
552
+			if ($this->_is_UI_request) {
553 553
 				//admin_init stuff - global, all views for this page class, specific view
554
-				add_action( 'admin_init', array( $this, 'admin_init' ), 10 );
555
-				if ( method_exists( $this, 'admin_init_' . $this->_current_view )) {
556
-					add_action( 'admin_init', array( $this, 'admin_init_' . $this->_current_view ), 15 );
554
+				add_action('admin_init', array($this, 'admin_init'), 10);
555
+				if (method_exists($this, 'admin_init_'.$this->_current_view)) {
556
+					add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
557 557
 				}
558 558
 
559 559
 			} else {
560 560
 				//hijack regular WP loading and route admin request immediately
561
-				@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
561
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
562 562
 				$this->route_admin_request();
563 563
 			}
564 564
 		}
@@ -575,18 +575,18 @@  discard block
 block discarded – undo
575 575
 	 * @return void
576 576
 	 */
577 577
 	private function _do_other_page_hooks() {
578
-		$registered_pages = apply_filters( 'FHEE_do_other_page_hooks_' . $this->page_slug, array() );
578
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
579 579
 
580
-		foreach ( $registered_pages as $page ) {
580
+		foreach ($registered_pages as $page) {
581 581
 
582 582
 			//now let's setup the file name and class that should be present
583 583
 			$classname = str_replace('.class.php', '', $page);
584 584
 
585 585
 			//autoloaders should take care of loading file
586
-			if ( !class_exists( $classname ) ) {
587
-				$error_msg[] = sprintf( __('Something went wrong with loading the %s admin hooks page.', 'event_espresso' ), $page);
588
-				$error_msg[] = $error_msg[0] . "\r\n" . sprintf( __( 'There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', 'event_espresso'), $page, '<br />', $classname );
589
-				throw new EE_Error( implode( '||', $error_msg ));
586
+			if ( ! class_exists($classname)) {
587
+				$error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
588
+				$error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', 'event_espresso'), $page, '<br />', $classname);
589
+				throw new EE_Error(implode('||', $error_msg));
590 590
 			}
591 591
 
592 592
 			$a = new ReflectionClass($classname);
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	public function load_page_dependencies() {
602 602
 		try {
603 603
 			$this->_load_page_dependencies();
604
-		} catch ( EE_Error $e ) {
604
+		} catch (EE_Error $e) {
605 605
 			$e->get_error();
606 606
 		}
607 607
 	}
@@ -619,16 +619,16 @@  discard block
 block discarded – undo
619 619
 		$this->_current_screen = get_current_screen();
620 620
 
621 621
 		//load admin_notices - global, page class, and view specific
622
-		add_action( 'admin_notices', array( $this, 'admin_notices_global'), 5 );
623
-		add_action( 'admin_notices', array( $this, 'admin_notices' ), 10 );
624
-		if ( method_exists( $this, 'admin_notices_' . $this->_current_view ) ) {
625
-			add_action( 'admin_notices', array( $this, 'admin_notices_' . $this->_current_view ), 15 );
622
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
623
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
624
+		if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
625
+			add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
626 626
 		}
627 627
 
628 628
 		//load network admin_notices - global, page class, and view specific
629
-		add_action( 'network_admin_notices', array( $this, 'network_admin_notices_global'), 5 );
630
-		if ( method_exists( $this, 'network_admin_notices_' . $this->_current_view ) ) {
631
-			add_action( 'network_admin_notices', array( $this, 'network_admin_notices_' . $this->_current_view ) );
629
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
630
+		if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
631
+			add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
632 632
 		}
633 633
 
634 634
 		//this will save any per_page screen options if they are present
@@ -644,8 +644,8 @@  discard block
 block discarded – undo
644 644
 		//add screen options - global, page child class, and view specific
645 645
 		$this->_add_global_screen_options();
646 646
 		$this->_add_screen_options();
647
-		if ( method_exists( $this, '_add_screen_options_' . $this->_current_view ) )
648
-			call_user_func( array( $this, '_add_screen_options_' . $this->_current_view ) );
647
+		if (method_exists($this, '_add_screen_options_'.$this->_current_view))
648
+			call_user_func(array($this, '_add_screen_options_'.$this->_current_view));
649 649
 
650 650
 
651 651
 		//add help tab(s) and tours- set via page_config and qtips.
@@ -656,33 +656,33 @@  discard block
 block discarded – undo
656 656
 		//add feature_pointers - global, page child class, and view specific
657 657
 		$this->_add_feature_pointers();
658 658
 		$this->_add_global_feature_pointers();
659
-		if ( method_exists( $this, '_add_feature_pointer_' . $this->_current_view ) )
660
-			call_user_func( array( $this, '_add_feature_pointer_' . $this->_current_view ) );
659
+		if (method_exists($this, '_add_feature_pointer_'.$this->_current_view))
660
+			call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view));
661 661
 
662 662
 		//enqueue scripts/styles - global, page class, and view specific
663
-		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5 );
664
-		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10 );
665
-		if ( method_exists( $this, 'load_scripts_styles_' . $this->_current_view ) )
666
-			add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view ), 15 );
663
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
664
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
665
+		if (method_exists($this, 'load_scripts_styles_'.$this->_current_view))
666
+			add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15);
667 667
 
668
-		add_action('admin_enqueue_scripts', array( $this, 'admin_footer_scripts_eei18n_js_strings' ), 100 );
668
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
669 669
 
670 670
 		//admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
671
-		add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_global' ), 99 );
672
-		add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts' ), 100 );
673
-		if ( method_exists( $this, 'admin_footer_scripts_' . $this->_current_view ) )
674
-			add_action('admin_print_footer_scripts', array( $this, 'admin_footer_scripts_' . $this->_current_view ), 101 );
671
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
672
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
673
+		if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view))
674
+			add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101);
675 675
 
676 676
 		//admin footer scripts
677
-		add_action('admin_footer', array( $this, 'admin_footer_global' ), 99 );
678
-		add_action('admin_footer', array( $this, 'admin_footer'), 100 );
679
-		if ( method_exists( $this, 'admin_footer_' . $this->_current_view ) )
680
-			add_action('admin_footer', array( $this, 'admin_footer_' . $this->_current_view ), 101 );
677
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
678
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
679
+		if (method_exists($this, 'admin_footer_'.$this->_current_view))
680
+			add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101);
681 681
 
682 682
 
683
-		do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug );
683
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
684 684
 		//targeted hook
685
-		do_action( 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action );
685
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action);
686 686
 
687 687
 	}
688 688
 
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 	private function _set_defaults() {
698 698
 		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = NULL;
699 699
 
700
-		$this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config =  $this->_default_route_query_args = array();
700
+		$this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
701 701
 
702 702
 		$this->default_nav_tab_name = 'overview';
703 703
 
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	public function route_admin_request() {
725 725
 		try {
726 726
 			$this->_route_admin_request();
727
-		} catch ( EE_Error $e ) {
727
+		} catch (EE_Error $e) {
728 728
 			$e->get_error();
729 729
 		}
730 730
 	}
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 		$this->_wp_page_slug = $wp_page_slug;
736 736
 
737 737
 		//if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
738
-		if ( is_network_admin() ) {
738
+		if (is_network_admin()) {
739 739
 			$this->_wp_page_slug .= '-network';
740 740
 		}
741 741
 	}
@@ -748,53 +748,53 @@  discard block
 block discarded – undo
748 748
 	 * @return void
749 749
 	 */
750 750
 	protected function _verify_routes() {
751
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
751
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
752 752
 
753
-		if ( !$this->_current_page && !defined( 'DOING_AJAX')) return FALSE;
753
+		if ( ! $this->_current_page && ! defined('DOING_AJAX')) return FALSE;
754 754
 
755 755
 		$this->_route = FALSE;
756 756
 		$func = FALSE;
757 757
 		$args = array();
758 758
 
759 759
 		// check that the page_routes array is not empty
760
-		if ( empty( $this->_page_routes )) {
760
+		if (empty($this->_page_routes)) {
761 761
 			// user error msg
762
-			$error_msg = sprintf( __('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title );
762
+			$error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
763 763
 			// developer error msg
764
-			$error_msg .=  '||' . $error_msg . __( ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso' );
765
-			throw new EE_Error( $error_msg );
764
+			$error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
765
+			throw new EE_Error($error_msg);
766 766
 		}
767 767
 
768 768
 		// and that the requested page route exists
769
-		if ( array_key_exists( $this->_req_action, $this->_page_routes )) {
770
-			$this->_route = $this->_page_routes[ $this->_req_action ];
769
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
770
+			$this->_route = $this->_page_routes[$this->_req_action];
771 771
 			$this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
772 772
 		} else {
773 773
 			// user error msg
774
-			$error_msg =  sprintf( __( 'The requested page route does not exist for the %s admin page.', 'event_espresso' ), $this->_admin_page_title );
774
+			$error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
775 775
 			// developer error msg
776
-			$error_msg .=  '||' . $error_msg . sprintf( __( ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso' ), $this->_req_action );
777
-			throw new EE_Error( $error_msg );
776
+			$error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
777
+			throw new EE_Error($error_msg);
778 778
 		}
779 779
 
780 780
 		// and that a default route exists
781
-		if ( ! array_key_exists( 'default', $this->_page_routes )) {
781
+		if ( ! array_key_exists('default', $this->_page_routes)) {
782 782
 			// user error msg
783
-			$error_msg = sprintf( __( 'A default page route has not been set for the % admin page.', 'event_espresso' ), $this->_admin_page_title );
783
+			$error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
784 784
 			// developer error msg
785
-			$error_msg .=  '||' . $error_msg . __( ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso' );
786
-			throw new EE_Error( $error_msg );
785
+			$error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
786
+			throw new EE_Error($error_msg);
787 787
 		}
788 788
 
789 789
 
790 790
 		//first lets' catch if the UI request has EVER been set.
791
-		if ( $this->_is_UI_request === NULL ) {
791
+		if ($this->_is_UI_request === NULL) {
792 792
 			//lets set if this is a UI request or not.
793
-			$this->_is_UI_request = ( ! isset( $this->_req_data['noheader'] ) || $this->_req_data['noheader'] !== TRUE ) ? TRUE : FALSE;
793
+			$this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== TRUE) ? TRUE : FALSE;
794 794
 
795 795
 
796 796
 			//wait a minute... we might have a noheader in the route array
797
-			$this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader'] ) && $this->_route['noheader'] ? FALSE : $this->_is_UI_request;
797
+			$this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? FALSE : $this->_is_UI_request;
798 798
 		}
799 799
 
800 800
 		$this->_set_current_labels();
@@ -809,15 +809,15 @@  discard block
 block discarded – undo
809 809
 	 * @param  string $route the route name we're verifying
810 810
 	 * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
811 811
 	 */
812
-	protected function _verify_route( $route ) {
813
-		if ( array_key_exists( $this->_req_action, $this->_page_routes )) {
812
+	protected function _verify_route($route) {
813
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
814 814
 			return true;
815 815
 		} else {
816 816
 			// user error msg
817
-			$error_msg =  sprintf( __( 'The given page route does not exist for the %s admin page.', 'event_espresso' ), $this->_admin_page_title );
817
+			$error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
818 818
 			// developer error msg
819
-			$error_msg .=  '||' . $error_msg . sprintf( __( ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso' ), $route );
820
-			throw new EE_Error( $error_msg );
819
+			$error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
820
+			throw new EE_Error($error_msg);
821 821
 		}
822 822
 	}
823 823
 
@@ -831,18 +831,18 @@  discard block
 block discarded – undo
831 831
 	 * @param  string $nonce_ref The nonce reference string (name0)
832 832
 	 * @return mixed (bool|die)
833 833
 	 */
834
-	protected function _verify_nonce( $nonce, $nonce_ref ) {
834
+	protected function _verify_nonce($nonce, $nonce_ref) {
835 835
 		// verify nonce against expected value
836
-		if ( ! wp_verify_nonce( $nonce, $nonce_ref) ) {
836
+		if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
837 837
 			// these are not the droids you are looking for !!!
838
-			$msg = sprintf(__('%sNonce Fail.%s' , 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>' );
839
-			if ( WP_DEBUG ) {
840
-				$msg .= "\n  " . sprintf( __('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso' ), __CLASS__  );
838
+			$msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
839
+			if (WP_DEBUG) {
840
+				$msg .= "\n  ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
841 841
 			}
842
-			if ( ! defined( 'DOING_AJAX' )) {
843
-				wp_die( $msg );
842
+			if ( ! defined('DOING_AJAX')) {
843
+				wp_die($msg);
844 844
 			} else {
845
-				EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
845
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
846 846
 				$this->_return_json();
847 847
 			}
848 848
 		}
@@ -860,63 +860,63 @@  discard block
 block discarded – undo
860 860
 	 * @return void
861 861
 	 */
862 862
 	protected function _route_admin_request() {
863
-		if (  ! $this->_is_UI_request )
863
+		if ( ! $this->_is_UI_request)
864 864
 			$this->_verify_routes();
865 865
 
866
-		$nonce_check = isset( $this->_route_config['require_nonce'] ) ? $this->_route_config['require_nonce'] : TRUE;
866
+		$nonce_check = isset($this->_route_config['require_nonce']) ? $this->_route_config['require_nonce'] : TRUE;
867 867
 
868
-		if ( $this->_req_action != 'default' && $nonce_check ) {
868
+		if ($this->_req_action != 'default' && $nonce_check) {
869 869
 			// set nonce from post data
870
-			$nonce = isset($this->_req_data[ $this->_req_nonce  ]) ? sanitize_text_field( $this->_req_data[ $this->_req_nonce  ] ) : '';
871
-			$this->_verify_nonce( $nonce, $this->_req_nonce );
870
+			$nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
871
+			$this->_verify_nonce($nonce, $this->_req_nonce);
872 872
 		}
873 873
 		//set the nav_tabs array but ONLY if this is  UI_request
874
-		if ( $this->_is_UI_request )
874
+		if ($this->_is_UI_request)
875 875
 			$this->_set_nav_tabs();
876 876
 
877 877
 		// grab callback function
878
-		$func = is_array( $this->_route ) ? $this->_route['func'] : $this->_route;
878
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
879 879
 
880 880
 		// check if callback has args
881
-		$args = is_array( $this->_route ) && isset( $this->_route['args'] ) ? $this->_route['args'] : array();
881
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
882 882
 
883 883
 		$error_msg = '';
884 884
 
885 885
 		//action right before calling route (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
886
-		if ( !did_action('AHEE__EE_Admin_Page__route_admin_request')) {
887
-			do_action( 'AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this );
886
+		if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
887
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
888 888
 		}
889 889
 
890 890
 		//right before calling the route, let's remove _wp_http_referer from the $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
891
-		$_SERVER['REQUEST_URI'] = remove_query_arg( '_wp_http_referer', wp_unslash( $_SERVER['REQUEST_URI'] ) );
891
+		$_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
892 892
 
893
-		if ( ! empty( $func )) {
893
+		if ( ! empty($func)) {
894 894
 			$base_call = $addon_call = FALSE;
895 895
 			//try to access page route via this class
896
-			if ( ! is_array( $func ) && method_exists( $this, $func ) && ( $base_call = call_user_func_array( array( $this, &$func  ), $args ) ) === FALSE ) {
896
+			if ( ! is_array($func) && method_exists($this, $func) && ($base_call = call_user_func_array(array($this, &$func), $args)) === FALSE) {
897 897
 				// user error msg
898
-				$error_msg =  __( 'An error occurred. The  requested page route could not be found.', 'event_espresso' );
898
+				$error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
899 899
 				// developer error msg
900
-				$error_msg .= '||' . sprintf( __( 'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', 'event_espresso' ), $func );
900
+				$error_msg .= '||'.sprintf(__('Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', 'event_espresso'), $func);
901 901
 			}
902 902
 
903 903
 			//for pluggability by addons first let's see if just the function exists (this will also work in the case where $func is an array indicating class/method)
904 904
 			$args['admin_page_object'] = $this; //send along this admin page object for access by addons.
905 905
 
906
-			if ( $base_call === FALSE && ( $addon_call = call_user_func_array( $func, $args ) )=== FALSE ) {
907
-				$error_msg = __('An error occurred. The requested page route could not be found', 'event_espresso' );
908
-				$error_msg .= '||' . sprintf( __('Page route "%s" could not be called.  Check that the spelling for the function name and action in the "_page_routes" array filtered by your plugin is correct.', 'event_espresso'), $func );
906
+			if ($base_call === FALSE && ($addon_call = call_user_func_array($func, $args)) === FALSE) {
907
+				$error_msg = __('An error occurred. The requested page route could not be found', 'event_espresso');
908
+				$error_msg .= '||'.sprintf(__('Page route "%s" could not be called.  Check that the spelling for the function name and action in the "_page_routes" array filtered by your plugin is correct.', 'event_espresso'), $func);
909 909
 			}
910 910
 
911 911
 
912
-			if ( !empty( $error_msg ) && $base_call === FALSE && $addon_call === FALSE )
913
-				throw new EE_Error( $error_msg );
912
+			if ( ! empty($error_msg) && $base_call === FALSE && $addon_call === FALSE)
913
+				throw new EE_Error($error_msg);
914 914
 		}
915 915
 
916 916
 		//if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
917 917
 		//now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
918
-		if ( $this->_is_UI_request === FALSE && is_array( $this->_route) && ! empty( $this->_route['headers_sent_route'] ) ) {
919
-			$this->_reset_routing_properties( $this->_route['headers_sent_route'] );
918
+		if ($this->_is_UI_request === FALSE && is_array($this->_route) && ! empty($this->_route['headers_sent_route'])) {
919
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
920 920
 		}
921 921
 	}
922 922
 
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 	 * @param  string    $new_route   New (non header) route to redirect to.
933 933
 	 * @return   void
934 934
 	 */
935
-	protected function _reset_routing_properties( $new_route ) {
935
+	protected function _reset_routing_properties($new_route) {
936 936
 		$this->_is_UI_request = TRUE;
937 937
 		//now we set the current route to whatever the headers_sent_route is set at
938 938
 		$this->_req_data['action'] = $new_route;
@@ -978,24 +978,24 @@  discard block
 block discarded – undo
978 978
 	 * @param   bool    $exclude_nonce  If true, the the nonce will be excluded from the generated nonce.
979 979
 	 * 	@return string
980 980
 	 */
981
-	public static function add_query_args_and_nonce( $args = array(), $url = false, $sticky = false, $exclude_nonce = false ) {
981
+	public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false) {
982 982
 		EE_Registry::instance()->load_helper('URL');
983 983
 
984 984
 		//if there is a _wp_http_referer include the values from the request but only if sticky = true
985
-		if ( $sticky ) {
985
+		if ($sticky) {
986 986
 			$request = $_REQUEST;
987
-			unset( $request['_wp_http_referer'] );
988
-			unset( $request['wp_referer'] );
989
-			foreach ( $request as $key => $value ) {
987
+			unset($request['_wp_http_referer']);
988
+			unset($request['wp_referer']);
989
+			foreach ($request as $key => $value) {
990 990
 				//do not add nonces
991
-				if ( strpos( $key, 'nonce' ) !== false ) {
991
+				if (strpos($key, 'nonce') !== false) {
992 992
 					continue;
993 993
 				}
994
-				$args['wp_referer[' . $key . ']'] = $value;
994
+				$args['wp_referer['.$key.']'] = $value;
995 995
 			}
996 996
 		}
997 997
 
998
-		return EEH_URL::add_query_args_and_nonce( $args, $url, $exclude_nonce );
998
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
999 999
 	}
1000 1000
 
1001 1001
 
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
 	 * @uses EEH_Template::get_help_tab_link()
1012 1012
 	 * @return string              generated link
1013 1013
 	 */
1014
-	protected function _get_help_tab_link( $help_tab_id, $icon_style = FALSE, $help_text = FALSE ) {
1015
-		return EEH_Template::get_help_tab_link( $help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text );
1014
+	protected function _get_help_tab_link($help_tab_id, $icon_style = FALSE, $help_text = FALSE) {
1015
+		return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
1016 1016
 	}
1017 1017
 
1018 1018
 
@@ -1029,30 +1029,30 @@  discard block
 block discarded – undo
1029 1029
 	 */
1030 1030
 	protected function _add_help_tabs() {
1031 1031
 		$tour_buttons = '';
1032
-		if ( isset( $this->_page_config[$this->_req_action] ) ) {
1032
+		if (isset($this->_page_config[$this->_req_action])) {
1033 1033
 			$config = $this->_page_config[$this->_req_action];
1034 1034
 
1035 1035
 			//is there a help tour for the current route?  if there is let's setup the tour buttons
1036
-			if ( isset( $this->_help_tour[$this->_req_action]) ) {
1036
+			if (isset($this->_help_tour[$this->_req_action])) {
1037 1037
 				$tb = array();
1038 1038
 				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1039
-				foreach ( $this->_help_tour['tours'] as $tour ) {
1039
+				foreach ($this->_help_tour['tours'] as $tour) {
1040 1040
 					//if this is the end tour then we don't need to setup a button
1041
-					if ( $tour instanceof EE_Help_Tour_final_stop )
1041
+					if ($tour instanceof EE_Help_Tour_final_stop)
1042 1042
 						continue;
1043
-					$tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1043
+					$tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>';
1044 1044
 				}
1045 1045
 				$tour_buttons .= implode('<br />', $tb);
1046 1046
 				$tour_buttons .= '</div></div>';
1047 1047
 			}
1048 1048
 
1049 1049
 			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1050
-			if ( is_array( $config ) && isset( $config['help_sidebar'] ) ) {
1050
+			if (is_array($config) && isset($config['help_sidebar'])) {
1051 1051
 				//check that the callback given is valid
1052
-				if ( !method_exists($this, $config['help_sidebar'] ) )
1053
-					throw new EE_Error( sprintf( __('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this) ) );
1052
+				if ( ! method_exists($this, $config['help_sidebar']))
1053
+					throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s', 'event_espresso'), $config['help_sidebar'], get_class($this)));
1054 1054
 
1055
-				$content = apply_filters( 'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func( array( $this, $config['help_sidebar'] ) ) );
1055
+				$content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1056 1056
 
1057 1057
 				$content .= $tour_buttons; //add help tour buttons.
1058 1058
 
@@ -1061,49 +1061,49 @@  discard block
 block discarded – undo
1061 1061
 			}
1062 1062
 
1063 1063
 			//if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1064
-			if ( !isset( $config['help_sidebar'] ) && !empty( $tour_buttons ) ) {
1064
+			if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1065 1065
 				$this->_current_screen->set_help_sidebar($tour_buttons);
1066 1066
 			}
1067 1067
 
1068 1068
 			//handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1069
-			if ( !isset( $config['help_tabs'] ) && !empty($tour_buttons) ) {
1069
+			if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1070 1070
 				$_ht['id'] = $this->page_slug;
1071 1071
 				$_ht['title'] = __('Help Tours', 'event_espresso');
1072
-				$_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1072
+				$_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>';
1073 1073
 				$this->_current_screen->add_help_tab($_ht);
1074 1074
 				}/**/
1075 1075
 
1076 1076
 
1077
-			if ( !isset( $config['help_tabs'] ) ) return; //no help tabs for this route
1077
+			if ( ! isset($config['help_tabs'])) return; //no help tabs for this route
1078 1078
 
1079
-			foreach ( (array) $config['help_tabs'] as $tab_id => $cfg ) {
1079
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1080 1080
 				//we're here so there ARE help tabs!
1081 1081
 
1082 1082
 				//make sure we've got what we need
1083
-				if ( !isset( $cfg['title'] ) )
1084
-					throw new EE_Error( __('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso') );
1083
+				if ( ! isset($cfg['title']))
1084
+					throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1085 1085
 
1086 1086
 
1087
-				if ( !isset($cfg['filename']) && !isset( $cfg['callback'] ) && !isset( $cfg['content'] ) )
1088
-					throw new EE_Error( __('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso') );
1087
+				if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content']))
1088
+					throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', 'event_espresso'));
1089 1089
 
1090 1090
 
1091 1091
 
1092 1092
 				//first priority goes to content.
1093
-				if ( !empty($cfg['content'] ) ) {
1094
-					$content = !empty($cfg['content']) ? $cfg['content'] : NULL;
1093
+				if ( ! empty($cfg['content'])) {
1094
+					$content = ! empty($cfg['content']) ? $cfg['content'] : NULL;
1095 1095
 
1096 1096
 				//second priority goes to filename
1097
-				} else if ( !empty($cfg['filename'] ) ) {
1098
-					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1097
+				} else if ( ! empty($cfg['filename'])) {
1098
+					$file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1099 1099
 
1100 1100
 
1101 1101
 					//it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1102
-					$file_path = !is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1102
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path;
1103 1103
 
1104 1104
 					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1105
-					if ( !is_readable($file_path) && !isset($cfg['callback']) ) {
1106
-						EE_Error::add_error( sprintf( __('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s', 'event_espresso'), $tab_id, key($config), $file_path ), __FILE__, __FUNCTION__, __LINE__ );
1105
+					if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1106
+						EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s', 'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1107 1107
 						return;
1108 1108
 					}
1109 1109
 					$template_args['admin_page_obj'] = $this;
@@ -1114,21 +1114,21 @@  discard block
 block discarded – undo
1114 1114
 
1115 1115
 
1116 1116
 				//check if callback is valid
1117
-				if ( empty($content) && ( !isset($cfg['callback']) || !method_exists( $this, $cfg['callback'] ) ) ) {
1118
-					EE_Error::add_error( sprintf( __('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.', 'event_espresso'), $cfg['title'] ), __FILE__, __FUNCTION__, __LINE__ );
1117
+				if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1118
+					EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.', 'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1119 1119
 					return;
1120 1120
 				}
1121 1121
 
1122 1122
 				//setup config array for help tab method
1123
-				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1123
+				$id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1124 1124
 				$_ht = array(
1125 1125
 					'id' => $id,
1126 1126
 					'title' => $cfg['title'],
1127
-					'callback' => isset( $cfg['callback'] ) && empty($content) ? array( $this, $cfg['callback'] ) : NULL,
1127
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : NULL,
1128 1128
 					'content' => $content
1129 1129
 					);
1130 1130
 
1131
-				$this->_current_screen->add_help_tab( $_ht );
1131
+				$this->_current_screen->add_help_tab($_ht);
1132 1132
 			}
1133 1133
 		}
1134 1134
 	}
@@ -1148,49 +1148,49 @@  discard block
 block discarded – undo
1148 1148
 		$this->_help_tour = array();
1149 1149
 
1150 1150
 		//exit early if help tours are turned off globally
1151
-		if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || ( defined( 'EE_DISABLE_HELP_TOURS' ) && EE_DISABLE_HELP_TOURS ) )
1151
+		if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS))
1152 1152
 			return;
1153 1153
 
1154 1154
 		//loop through _page_config to find any help_tour defined
1155
-		foreach ( $this->_page_config as $route => $config ) {
1155
+		foreach ($this->_page_config as $route => $config) {
1156 1156
 			//we're only going to set things up for this route
1157
-			if ( $route !== $this->_req_action )
1157
+			if ($route !== $this->_req_action)
1158 1158
 				continue;
1159 1159
 
1160
-			if ( isset( $config['help_tour'] ) ) {
1160
+			if (isset($config['help_tour'])) {
1161 1161
 
1162
-				foreach( $config['help_tour'] as $tour ) {
1163
-					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1162
+				foreach ($config['help_tour'] as $tour) {
1163
+					$file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1164 1164
 					//let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1165
-					$file_path = !is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1165
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path;
1166 1166
 
1167 1167
 					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1168
-					if ( !is_readable($file_path) ) {
1169
-						EE_Error::add_error( sprintf( __('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), $file_path, $tour ), __FILE__, __FUNCTION__, __LINE__ );
1168
+					if ( ! is_readable($file_path)) {
1169
+						EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), $file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1170 1170
 						return;
1171 1171
 					}
1172 1172
 
1173 1173
 					require_once $file_path;
1174
-					if ( !class_exists( $tour ) ) {
1175
-						$error_msg[] = sprintf( __('Something went wrong with loading the %s Help Tour Class.', 'event_espresso' ), $tour);
1176
-						$error_msg[] = $error_msg[0] . "\r\n" . sprintf( __( 'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this) );
1177
-						throw new EE_Error( implode( '||', $error_msg ));
1174
+					if ( ! class_exists($tour)) {
1175
+						$error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1176
+						$error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1177
+						throw new EE_Error(implode('||', $error_msg));
1178 1178
 					}
1179 1179
 					$a = new ReflectionClass($tour);
1180 1180
 					$tour_obj = $a->newInstance($this->_is_caf);
1181 1181
 
1182 1182
 					$tours[] = $tour_obj;
1183
-					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator( $tour_obj );
1183
+					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1184 1184
 				}
1185 1185
 
1186 1186
 				//let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1187 1187
 				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1188 1188
 				$tours[] = $end_stop_tour;
1189
-				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator( $end_stop_tour );
1189
+				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1190 1190
 			}
1191 1191
 		}
1192 1192
 
1193
-		if ( !empty( $tours ) )
1193
+		if ( ! empty($tours))
1194 1194
 			$this->_help_tour['tours'] = $tours;
1195 1195
 
1196 1196
 		//thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
@@ -1206,13 +1206,13 @@  discard block
 block discarded – undo
1206 1206
 	 * @return void
1207 1207
 	 */
1208 1208
 	protected function _add_qtips() {
1209
-		if ( isset( $this->_route_config['qtips'] ) ) {
1209
+		if (isset($this->_route_config['qtips'])) {
1210 1210
 			$qtips = (array) $this->_route_config['qtips'];
1211 1211
 			//load qtip loader
1212 1212
 			EE_Registry::instance()->load_helper('Qtip_Loader', array(), TRUE);
1213 1213
 			$path = array(
1214
-				$this->_get_dir() . '/qtips/',
1215
-				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/'
1214
+				$this->_get_dir().'/qtips/',
1215
+				EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/'
1216 1216
 				);
1217 1217
 			EEH_Qtip_Loader::instance()->register($qtips, $path);
1218 1218
 		}
@@ -1229,41 +1229,41 @@  discard block
 block discarded – undo
1229 1229
 	 * @return void
1230 1230
 	 */
1231 1231
 	protected function _set_nav_tabs() {
1232
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1232
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1233 1233
 		$i = 0;
1234
-		foreach ( $this->_page_config as $slug => $config ) {
1235
-			if ( !is_array( $config ) || ( is_array($config) && (isset($config['nav']) && !$config['nav'] ) || !isset($config['nav'] ) ) )
1234
+		foreach ($this->_page_config as $slug => $config) {
1235
+			if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav'])))
1236 1236
 				continue; //no nav tab for this config
1237 1237
 
1238 1238
 			//check for persistent flag
1239
-			if ( isset( $config['nav']['persistent']) && !$config['nav']['persistent'] && $slug !== $this->_req_action )
1239
+			if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action)
1240 1240
 				continue; //nav tab is only to appear when route requested.
1241 1241
 
1242
-			if ( ! $this->check_user_access( $slug, TRUE ) )
1242
+			if ( ! $this->check_user_access($slug, TRUE))
1243 1243
 				continue; //no nav tab becasue current user does not have access.
1244 1244
 
1245
-			$css_class = isset( $config['css_class'] ) ? $config['css_class'] . ' ' : '';
1245
+			$css_class = isset($config['css_class']) ? $config['css_class'].' ' : '';
1246 1246
 			$this->_nav_tabs[$slug] = array(
1247
-				'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce( array( 'action'=>$slug ), $this->_admin_base_url ),
1248
-				'link_text' => isset( $config['nav']['label'] ) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug ) ),
1249
-				'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1250
-				'order' => isset( $config['nav']['order'] ) ? $config['nav']['order'] : $i
1247
+				'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action'=>$slug), $this->_admin_base_url),
1248
+				'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1249
+				'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class,
1250
+				'order' => isset($config['nav']['order']) ? $config['nav']['order'] : $i
1251 1251
 				);
1252 1252
 			$i++;
1253 1253
 		}
1254 1254
 
1255 1255
 		//if $this->_nav_tabs is empty then lets set the default
1256
-		if ( empty( $this->_nav_tabs ) ) {
1256
+		if (empty($this->_nav_tabs)) {
1257 1257
 			$this->_nav_tabs[$this->default_nav_tab_name] = array(
1258 1258
 				'url' => $this->admin_base_url,
1259
-				'link_text' => ucwords( str_replace( '_', ' ', $this->default_nav_tab_name ) ),
1259
+				'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1260 1260
 				'css_class' => 'nav-tab-active',
1261 1261
 				'order' => 10
1262 1262
 				);
1263 1263
 		}
1264 1264
 
1265 1265
 		//now let's sort the tabs according to order
1266
-		usort( $this->_nav_tabs, array($this, '_sort_nav_tabs' ));
1266
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1267 1267
 
1268 1268
 	}
1269 1269
 
@@ -1279,10 +1279,10 @@  discard block
 block discarded – undo
1279 1279
 	 * @return void
1280 1280
 	 */
1281 1281
 	private function _set_current_labels() {
1282
-		if ( is_array($this->_route_config) && isset($this->_route_config['labels']) ) {
1283
-			foreach ( $this->_route_config['labels'] as $label => $text ) {
1284
-				if ( is_array($text) ) {
1285
-					foreach ( $text as $sublabel => $subtext ) {
1282
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1283
+			foreach ($this->_route_config['labels'] as $label => $text) {
1284
+				if (is_array($text)) {
1285
+					foreach ($text as $sublabel => $subtext) {
1286 1286
 						$this->_labels[$label][$sublabel] = $subtext;
1287 1287
 					}
1288 1288
 				} else {
@@ -1303,24 +1303,24 @@  discard block
 block discarded – undo
1303 1303
 	 * 		@param bool   $verify_only Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1304 1304
 	*		@return 		BOOL|wp_die()
1305 1305
 	*/
1306
-	public function check_user_access( $route_to_check = '', $verify_only = FALSE ) {
1307
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1308
-		$route_to_check = empty( $route_to_check ) ? $this->_req_action : $route_to_check;
1309
-		$capability = ! empty( $route_to_check ) && isset( $this->_page_routes[$route_to_check] ) && is_array( $this->_page_routes[$route_to_check] ) && ! empty( $this->_page_routes[$route_to_check]['capability'] ) ? $this->_page_routes[$route_to_check]['capability'] : NULL;
1306
+	public function check_user_access($route_to_check = '', $verify_only = FALSE) {
1307
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1308
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1309
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability']) ? $this->_page_routes[$route_to_check]['capability'] : NULL;
1310 1310
 
1311
-		if ( empty( $capability ) && empty( $route_to_check )  ) {
1312
-			$capability = is_array( $this->_route ) && empty( $this->_route['capability'] ) ? 'manage_options' : $this->_route['capability'];
1311
+		if (empty($capability) && empty($route_to_check)) {
1312
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1313 1313
 		} else {
1314
-			$capability = empty( $capability ) ? 'manage_options' : $capability;
1314
+			$capability = empty($capability) ? 'manage_options' : $capability;
1315 1315
 		}
1316 1316
 
1317
-		$id = is_array( $this->_route ) && ! empty( $this->_route['obj_id'] ) ? $this->_route['obj_id'] : 0;
1317
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1318 1318
 
1319
-		if (( ! function_exists( 'is_admin' ) || ! EE_Registry::instance()->CAP->current_user_can( $capability, $this->page_slug . '_' . $route_to_check, $id ) ) && ! defined( 'DOING_AJAX')) {
1320
-			if ( $verify_only ) {
1319
+		if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) {
1320
+			if ($verify_only) {
1321 1321
 				return FALSE;
1322 1322
 			} else {
1323
-				wp_die( __('You do not have access to this route.', 'event_espresso' ) );
1323
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1324 1324
 			}
1325 1325
 		}
1326 1326
 		return TRUE;
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 		$this->_add_admin_page_overlay();
1398 1398
 
1399 1399
 		//if metaboxes are present we need to add the nonce field
1400
-		if ( ( isset($this->_route_config['metaboxes']) || ( isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'] ) || isset($this->_route_config['list_table']) ) ) {
1400
+		if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1401 1401
 			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1402 1402
 			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1403 1403
 		}
@@ -1416,20 +1416,20 @@  discard block
 block discarded – undo
1416 1416
 	 */
1417 1417
 	public function admin_footer_global() {
1418 1418
 		//dialog container for dialog helper
1419
-		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1419
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1420 1420
 		$d_cont .= '<div class="ee-notices"></div>';
1421 1421
 		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1422 1422
 		$d_cont .= '</div>';
1423 1423
 		echo $d_cont;
1424 1424
 
1425 1425
 		//help tour stuff?
1426
-		if ( isset( $this->_help_tour[$this->_req_action] ) ) {
1426
+		if (isset($this->_help_tour[$this->_req_action])) {
1427 1427
 			echo implode('<br />', $this->_help_tour[$this->_req_action]);
1428 1428
 		}
1429 1429
 
1430 1430
 		//current set timezone for timezone js
1431 1431
 		EE_Registry::instance()->load_helper('DTT_Helper');
1432
-		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1432
+		echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1433 1433
 	}
1434 1434
 
1435 1435
 
@@ -1453,18 +1453,18 @@  discard block
 block discarded – undo
1453 1453
 	 * @access protected
1454 1454
 	 * @return string content
1455 1455
 	 */
1456
-	protected function _set_help_popup_content( $help_array = array(), $display = FALSE ) {
1456
+	protected function _set_help_popup_content($help_array = array(), $display = FALSE) {
1457 1457
 		$content = '';
1458 1458
 
1459
-		$help_array = empty( $help_array ) ? $this->_get_help_content() : $help_array;
1460
-		$template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1459
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1460
+		$template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php';
1461 1461
 
1462 1462
 
1463 1463
 		//loop through the array and setup content
1464
-		foreach ( $help_array as $trigger => $help ) {
1464
+		foreach ($help_array as $trigger => $help) {
1465 1465
 			//make sure the array is setup properly
1466
-			if ( !isset($help['title']) || !isset($help['content'] ) ) {
1467
-				throw new EE_Error( __('Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', 'event_espresso') );
1466
+			if ( ! isset($help['title']) || ! isset($help['content'])) {
1467
+				throw new EE_Error(__('Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', 'event_espresso'));
1468 1468
 			}
1469 1469
 
1470 1470
 			//we're good so let'd setup the template vars and then assign parsed template content to our content.
@@ -1474,10 +1474,10 @@  discard block
 block discarded – undo
1474 1474
 				'help_popup_content' => $help['content']
1475 1475
 				);
1476 1476
 
1477
-			$content .= EEH_Template::display_template( $template_path, $template_args, TRUE );
1477
+			$content .= EEH_Template::display_template($template_path, $template_args, TRUE);
1478 1478
 		}
1479 1479
 
1480
-		if ( $display )
1480
+		if ($display)
1481 1481
 			echo $content;
1482 1482
 		else
1483 1483
 			return $content;
@@ -1494,18 +1494,18 @@  discard block
 block discarded – undo
1494 1494
 	 */
1495 1495
 	private function _get_help_content() {
1496 1496
 		//what is the method we're looking for?
1497
-		$method_name = '_help_popup_content_' . $this->_req_action;
1497
+		$method_name = '_help_popup_content_'.$this->_req_action;
1498 1498
 
1499 1499
 		//if method doesn't exist let's get out.
1500
-		if ( !method_exists( $this, $method_name ) )
1500
+		if ( ! method_exists($this, $method_name))
1501 1501
 			return array();
1502 1502
 
1503 1503
 		//k we're good to go let's retrieve the help array
1504
-		$help_array = call_user_func( array( $this, $method_name ) );
1504
+		$help_array = call_user_func(array($this, $method_name));
1505 1505
 
1506 1506
 		//make sure we've got an array!
1507
-		if ( !is_array($help_array) ) {
1508
-			throw new EE_Error( __('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso' ) );
1507
+		if ( ! is_array($help_array)) {
1508
+			throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1509 1509
 		}
1510 1510
 
1511 1511
 		return $help_array;
@@ -1527,27 +1527,27 @@  discard block
 block discarded – undo
1527 1527
 	 * @param array $dimensions an array of dimensions for the box (array(h,w))
1528 1528
 	 * @return string
1529 1529
 	 */
1530
-	protected function _set_help_trigger( $trigger_id, $display = TRUE, $dimensions = array( '400', '640') ) {
1530
+	protected function _set_help_trigger($trigger_id, $display = TRUE, $dimensions = array('400', '640')) {
1531 1531
 
1532
-		if ( defined('DOING_AJAX') ) return;
1532
+		if (defined('DOING_AJAX')) return;
1533 1533
 
1534 1534
 		//let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1535 1535
 		$help_array = $this->_get_help_content();
1536 1536
 		$help_content = '';
1537 1537
 
1538
-		if ( empty( $help_array ) || !isset( $help_array[$trigger_id] ) ) {
1538
+		if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1539 1539
 			$help_array[$trigger_id] = array(
1540 1540
 				'title' => __('Missing Content', 'event_espresso'),
1541 1541
 				'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)', 'event_espresso')
1542 1542
 				);
1543
-			$help_content = $this->_set_help_popup_content( $help_array, FALSE );
1543
+			$help_content = $this->_set_help_popup_content($help_array, FALSE);
1544 1544
 		}
1545 1545
 
1546 1546
 		//let's setup the trigger
1547
-		$content = '<a class="ee-dialog" href="?height='. $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1548
-		$content = $content . $help_content;
1547
+		$content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1548
+		$content = $content.$help_content;
1549 1549
 
1550
-		if ( $display )
1550
+		if ($display)
1551 1551
 			echo $content;
1552 1552
 		else
1553 1553
 			return $content;
@@ -1604,15 +1604,15 @@  discard block
 block discarded – undo
1604 1604
 	public function load_global_scripts_styles() {
1605 1605
 		/** STYLES **/
1606 1606
 		// add debugging styles
1607
-		if ( WP_DEBUG ) {
1608
-			add_action('admin_head', array( $this, 'add_xdebug_style' ));
1607
+		if (WP_DEBUG) {
1608
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1609 1609
 		}
1610 1610
 
1611 1611
 		//register all styles
1612
-		wp_register_style( 'espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(),EVENT_ESPRESSO_VERSION );
1613
-		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1612
+		wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1613
+		wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1614 1614
 		//helpers styles
1615
-		wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION );
1615
+		wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1616 1616
 		//enqueue global styles
1617 1617
 		wp_enqueue_style('ee-admin-css');
1618 1618
 
@@ -1620,66 +1620,66 @@  discard block
 block discarded – undo
1620 1620
 		/** SCRIPTS **/
1621 1621
 
1622 1622
 		//register all scripts
1623
-		wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE );
1624
-		wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, TRUE );
1625
-		wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array( 'espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true );
1623
+		wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
1624
+		wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, TRUE);
1625
+		wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1626 1626
 
1627
-		wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true );
1627
+		wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1628 1628
 		// register jQuery Validate - see /includes/functions/wp_hooks.php
1629
-		add_filter( 'FHEE_load_jquery_validate', '__return_true' );
1629
+		add_filter('FHEE_load_jquery_validate', '__return_true');
1630 1630
 		add_filter('FHEE_load_joyride', '__return_true');
1631 1631
 
1632 1632
 		//script for sorting tables
1633
-		wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE);
1633
+		wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, TRUE);
1634 1634
 		//script for parsing uri's
1635
-		wp_register_script( 'ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, TRUE );
1635
+		wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, TRUE);
1636 1636
 		//and parsing associative serialized form elements
1637
-		wp_register_script( 'ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE );
1637
+		wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
1638 1638
 		//helpers scripts
1639
-		wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE );
1640
-		wp_register_script( 'ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, TRUE );
1641
-		wp_register_script( 'ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, TRUE );
1642
-		wp_register_script( 'ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon','ee-moment'), EVENT_ESPRESSO_VERSION, TRUE );
1639
+		wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
1640
+		wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, TRUE);
1641
+		wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, TRUE);
1642
+		wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, TRUE);
1643 1643
 
1644 1644
 		//google charts
1645
-		wp_register_script( 'google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false );
1645
+		wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1646 1646
 
1647 1647
 		//enqueue global scripts
1648 1648
 
1649 1649
 		//taking care of metaboxes
1650
-		if ( ( isset($this->_route_config['metaboxes'] ) || isset($this->_route_config['has_metaboxes']) ) && empty( $this->_cpt_route) ) {
1650
+		if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1651 1651
 			wp_enqueue_script('dashboard');
1652 1652
 		}
1653 1653
 
1654 1654
 		//enqueue thickbox for ee help popups.  default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups
1655
-		if ( ! isset( $this->_route_config['has_help_popups']) || ( isset( $this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'] ) ) {
1655
+		if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1656 1656
 			wp_enqueue_script('ee_admin_js');
1657 1657
 			wp_enqueue_style('ee-admin-css');
1658 1658
 		}
1659 1659
 
1660 1660
 
1661 1661
 		//localize script for ajax lazy loading
1662
-		$lazy_loader_container_ids = apply_filters( 'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content') );
1663
-		wp_localize_script( 'ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1662
+		$lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1663
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1664 1664
 
1665 1665
 
1666 1666
 		/**
1667 1667
 		 * help tour stuff
1668 1668
 		 */
1669
-		if ( !empty( $this->_help_tour ) ) {
1669
+		if ( ! empty($this->_help_tour)) {
1670 1670
 
1671 1671
 			//register the js for kicking things off
1672
-			wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, TRUE );
1672
+			wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, TRUE);
1673 1673
 
1674 1674
 			//setup tours for the js tour object
1675
-			foreach ( $this->_help_tour['tours'] as $tour ) {
1675
+			foreach ($this->_help_tour['tours'] as $tour) {
1676 1676
 				$tours[] = array(
1677 1677
 					'id' => $tour->get_slug(),
1678 1678
 					'options' => $tour->get_options()
1679 1679
 					);
1680 1680
 			}
1681 1681
 
1682
-			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours ) );
1682
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1683 1683
 
1684 1684
 			//admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1685 1685
 		}
@@ -1697,52 +1697,52 @@  discard block
 block discarded – undo
1697 1697
 	public function admin_footer_scripts_eei18n_js_strings() {
1698 1698
 
1699 1699
 		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1700
-		EE_Registry::$i18n_js_strings['confirm_delete'] = __( 'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso' );
1701
-
1702
-		EE_Registry::$i18n_js_strings['January'] = __( 'January', 'event_espresso' );
1703
-		EE_Registry::$i18n_js_strings['February'] = __( 'February', 'event_espresso' );
1704
-		EE_Registry::$i18n_js_strings['March'] = __( 'March', 'event_espresso' );
1705
-		EE_Registry::$i18n_js_strings['April'] = __( 'April', 'event_espresso' );
1706
-		EE_Registry::$i18n_js_strings['May'] = __( 'May', 'event_espresso' );
1707
-		EE_Registry::$i18n_js_strings['June'] = __( 'June', 'event_espresso' );
1708
-		EE_Registry::$i18n_js_strings['July'] = __( 'July', 'event_espresso' );
1709
-		EE_Registry::$i18n_js_strings['August'] = __( 'August', 'event_espresso' );
1710
-		EE_Registry::$i18n_js_strings['September'] = __( 'September', 'event_espresso' );
1711
-		EE_Registry::$i18n_js_strings['October'] = __( 'October', 'event_espresso' );
1712
-		EE_Registry::$i18n_js_strings['November'] = __( 'November', 'event_espresso' );
1713
-		EE_Registry::$i18n_js_strings['December'] = __( 'December', 'event_espresso' );
1714
-		EE_Registry::$i18n_js_strings['Jan'] = __( 'Jan', 'event_espresso' );
1715
-		EE_Registry::$i18n_js_strings['Feb'] = __( 'Feb', 'event_espresso' );
1716
-		EE_Registry::$i18n_js_strings['Mar'] = __( 'Mar', 'event_espresso' );
1717
-		EE_Registry::$i18n_js_strings['Apr'] = __( 'Apr', 'event_espresso' );
1718
-		EE_Registry::$i18n_js_strings['May'] = __( 'May', 'event_espresso' );
1719
-		EE_Registry::$i18n_js_strings['Jun'] = __( 'Jun', 'event_espresso' );
1720
-		EE_Registry::$i18n_js_strings['Jul'] = __( 'Jul', 'event_espresso' );
1721
-		EE_Registry::$i18n_js_strings['Aug'] = __( 'Aug', 'event_espresso' );
1722
-		EE_Registry::$i18n_js_strings['Sep'] = __( 'Sep', 'event_espresso' );
1723
-		EE_Registry::$i18n_js_strings['Oct'] = __( 'Oct', 'event_espresso' );
1724
-		EE_Registry::$i18n_js_strings['Nov'] = __( 'Nov', 'event_espresso' );
1725
-		EE_Registry::$i18n_js_strings['Dec'] = __( 'Dec', 'event_espresso' );
1726
-
1727
-		EE_Registry::$i18n_js_strings['Sunday'] = __( 'Sunday', 'event_espresso' );
1728
-		EE_Registry::$i18n_js_strings['Monday'] = __( 'Monday', 'event_espresso' );
1729
-		EE_Registry::$i18n_js_strings['Tuesday'] = __( 'Tuesday', 'event_espresso' );
1730
-		EE_Registry::$i18n_js_strings['Wednesday'] = __( 'Wednesday', 'event_espresso' );
1731
-		EE_Registry::$i18n_js_strings['Thursday'] = __( 'Thursday', 'event_espresso' );
1732
-		EE_Registry::$i18n_js_strings['Friday'] = __( 'Friday', 'event_espresso' );
1733
-		EE_Registry::$i18n_js_strings['Saturday'] = __( 'Saturday', 'event_espresso' );
1734
-		EE_Registry::$i18n_js_strings['Sun'] = __( 'Sun', 'event_espresso' );
1735
-		EE_Registry::$i18n_js_strings['Mon'] = __( 'Mon', 'event_espresso' );
1736
-		EE_Registry::$i18n_js_strings['Tue'] = __( 'Tue', 'event_espresso' );
1737
-		EE_Registry::$i18n_js_strings['Wed'] = __( 'Wed', 'event_espresso' );
1738
-		EE_Registry::$i18n_js_strings['Thu'] = __( 'Thu', 'event_espresso' );
1739
-		EE_Registry::$i18n_js_strings['Fri'] = __( 'Fri', 'event_espresso' );
1740
-		EE_Registry::$i18n_js_strings['Sat'] = __( 'Sat', 'event_espresso' );
1700
+		EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso');
1701
+
1702
+		EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1703
+		EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1704
+		EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1705
+		EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1706
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1707
+		EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1708
+		EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1709
+		EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1710
+		EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1711
+		EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1712
+		EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1713
+		EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1714
+		EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1715
+		EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1716
+		EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1717
+		EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1718
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1719
+		EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1720
+		EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1721
+		EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1722
+		EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1723
+		EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1724
+		EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1725
+		EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1726
+
1727
+		EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1728
+		EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1729
+		EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1730
+		EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1731
+		EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1732
+		EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1733
+		EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1734
+		EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1735
+		EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1736
+		EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1737
+		EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1738
+		EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1739
+		EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1740
+		EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1741 1741
 
1742 1742
 		//setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1743 1743
 		//admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1744 1744
 		//espresso_core is listed as a dependency of ee_admin_js.
1745
-		wp_localize_script( 'espresso_core', 'eei18n', EE_Registry::$i18n_js_strings );
1745
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1746 1746
 
1747 1747
 	}
1748 1748
 
@@ -1776,23 +1776,23 @@  discard block
 block discarded – undo
1776 1776
 	protected function _set_list_table() {
1777 1777
 
1778 1778
 		//first is this a list_table view?
1779
-		if ( !isset($this->_route_config['list_table']) )
1779
+		if ( ! isset($this->_route_config['list_table']))
1780 1780
 			return; //not a list_table view so get out.
1781 1781
 
1782 1782
 		//list table functions are per view specific (because some admin pages might have more than one listtable!)
1783 1783
 
1784
-		if ( call_user_func( array( $this, '_set_list_table_views_' . $this->_req_action ) ) === FALSE ) {
1784
+		if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === FALSE) {
1785 1785
 			//user error msg
1786
-			$error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso' );
1786
+			$error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1787 1787
 			//developer error msg
1788
-			$error_msg .= '||' . sprintf( __('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso' ), $this->_req_action, '_set_list_table_views_' . $this->_req_action );
1789
-			throw new EE_Error( $error_msg );
1788
+			$error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), $this->_req_action, '_set_list_table_views_'.$this->_req_action);
1789
+			throw new EE_Error($error_msg);
1790 1790
 		}
1791 1791
 
1792 1792
 		//let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1793
-		$this->_views = apply_filters( 'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views );
1794
-		$this->_views = apply_filters( 'FHEE_list_table_views_' . $this->page_slug, $this->_views );
1795
-		$this->_views = apply_filters( 'FHEE_list_table_views', $this->_views );
1793
+		$this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views);
1794
+		$this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1795
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1796 1796
 
1797 1797
 		$this->_set_list_table_view();
1798 1798
 		$this->_set_list_table_object();
@@ -1814,14 +1814,14 @@  discard block
 block discarded – undo
1814 1814
 	*		@return array
1815 1815
 	*/
1816 1816
 	protected function _set_list_table_view() {
1817
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1817
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1818 1818
 
1819 1819
 
1820 1820
 		// looking at active items or dumpster diving ?
1821
-		if ( ! isset( $this->_req_data['status'] ) || ! array_key_exists( $this->_req_data['status'], $this->_views )) {
1822
-			$this->_view = isset( $this->_views['in_use'] ) ? 'in_use' : 'all';
1821
+		if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1822
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1823 1823
 		} else {
1824
-			$this->_view = sanitize_key( $this->_req_data['status'] );
1824
+			$this->_view = sanitize_key($this->_req_data['status']);
1825 1825
 		}
1826 1826
 	}
1827 1827
 
@@ -1832,9 +1832,9 @@  discard block
 block discarded – undo
1832 1832
 	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1833 1833
 	 */
1834 1834
 	protected function _set_list_table_object() {
1835
-		if ( isset($this->_route_config['list_table'] ) ) {
1836
-			if ( !class_exists( $this->_route_config['list_table'] ) )
1837
-				throw new EE_Error( sprintf( __('The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.', 'event_espresso'), $this->_route_config['list_table'], get_class($this) ) );
1835
+		if (isset($this->_route_config['list_table'])) {
1836
+			if ( ! class_exists($this->_route_config['list_table']))
1837
+				throw new EE_Error(sprintf(__('The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.', 'event_espresso'), $this->_route_config['list_table'], get_class($this)));
1838 1838
 			$a = new ReflectionClass($this->_route_config['list_table']);
1839 1839
 			$this->_list_table_object = $a->newInstance($this);
1840 1840
 		}
@@ -1853,27 +1853,27 @@  discard block
 block discarded – undo
1853 1853
 	 *
1854 1854
 	 * @return array
1855 1855
 	 */
1856
-	public function get_list_table_view_RLs( $extra_query_args = array() ) {
1856
+	public function get_list_table_view_RLs($extra_query_args = array()) {
1857 1857
 
1858
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1858
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1859 1859
 
1860
-		if ( empty( $this->_views )) {
1860
+		if (empty($this->_views)) {
1861 1861
 			$this->_views = array();
1862 1862
 		}
1863 1863
 
1864 1864
 		// cycle thru views
1865
-		foreach ( $this->_views as $key => $view ) {
1865
+		foreach ($this->_views as $key => $view) {
1866 1866
 			$query_args = array();
1867 1867
 			// check for current view
1868
-			$this->_views[ $key ]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1868
+			$this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1869 1869
 			$query_args['action'] = $this->_req_action;
1870
-			$query_args[$this->_req_action.'_nonce'] = wp_create_nonce( $query_args['action'] . '_nonce' );
1870
+			$query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
1871 1871
 			$query_args['status'] = $view['slug'];
1872 1872
 			//merge any other arguments sent in.
1873
-			if ( isset( $extra_query_args[$view['slug']] ) ) {
1874
-				$query_args = array_merge( $query_args, $extra_query_args[$view['slug']] );
1873
+			if (isset($extra_query_args[$view['slug']])) {
1874
+				$query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1875 1875
 			}
1876
-			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1876
+			$this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1877 1877
 		}
1878 1878
 
1879 1879
 		return $this->_views;
@@ -1890,15 +1890,15 @@  discard block
 block discarded – undo
1890 1890
 	 * @param int $max_entries total number of rows in the table
1891 1891
 	 * @return string
1892 1892
 	*/
1893
-	protected function _entries_per_page_dropdown( $max_entries = FALSE ) {
1893
+	protected function _entries_per_page_dropdown($max_entries = FALSE) {
1894 1894
 
1895
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1896
-		$values = array( 10, 25, 50, 100 );
1897
-		$per_page = ( ! empty( $this->_req_data['per_page'] )) ? absint( $this->_req_data['per_page'] ) : 10;
1895
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1896
+		$values = array(10, 25, 50, 100);
1897
+		$per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1898 1898
 
1899
-		if ( $max_entries ) {
1899
+		if ($max_entries) {
1900 1900
 			$values[] = $max_entries;
1901
-			sort( $values );
1901
+			sort($values);
1902 1902
 		}
1903 1903
 
1904 1904
 		$entries_per_page_dropdown = '
@@ -1907,15 +1907,15 @@  discard block
 block discarded – undo
1907 1907
 					Show
1908 1908
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1909 1909
 
1910
-		foreach ( $values as $value ) {
1911
-			if ( $value < $max_entries ) {
1912
-				$selected = $value == $per_page ?  ' selected="' . $per_page . '"' : '';
1910
+		foreach ($values as $value) {
1911
+			if ($value < $max_entries) {
1912
+				$selected = $value == $per_page ? ' selected="'.$per_page.'"' : '';
1913 1913
 				$entries_per_page_dropdown .= '
1914 1914
 						<option value="'.$value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
1915 1915
 			}
1916 1916
 		}
1917 1917
 
1918
-		$selected = $max_entries == $per_page ?  ' selected="' . $per_page . '"' : '';
1918
+		$selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : '';
1919 1919
 		$entries_per_page_dropdown .= '
1920 1920
 						<option value="'.$max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
1921 1921
 
@@ -1938,8 +1938,8 @@  discard block
 block discarded – undo
1938 1938
 	*		@return 		void
1939 1939
 	*/
1940 1940
 	public function _set_search_attributes() {
1941
-		$this->_template_args['search']['btn_label'] = sprintf( __( 'Search %s', 'event_espresso' ), empty( $this->_search_btn_label ) ? $this->page_label : $this->_search_btn_label );
1942
-		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1941
+		$this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1942
+		$this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
1943 1943
 	}
1944 1944
 
1945 1945
 	/*** END LIST TABLE METHODS **/
@@ -1958,20 +1958,20 @@  discard block
 block discarded – undo
1958 1958
 	 * @return void
1959 1959
 	*/
1960 1960
 	private function _add_registered_meta_boxes() {
1961
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1961
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1962 1962
 
1963 1963
 		//we only add meta boxes if the page_route calls for it
1964
-		if ( is_array($this->_route_config) && isset( $this->_route_config['metaboxes'] ) && is_array($this->_route_config['metaboxes']) ) {
1964
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes']) && is_array($this->_route_config['metaboxes'])) {
1965 1965
 
1966 1966
 
1967 1967
 			//this simply loops through the callbacks provided and checks if there is a corresponding callback registered by the child - if there is then we go ahead and process the metabox loader.
1968
-			foreach ( $this->_route_config['metaboxes'] as $metabox_callback ) {
1969
-				if ( call_user_func( array($this, &$metabox_callback) ) === FALSE ) {
1968
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1969
+				if (call_user_func(array($this, &$metabox_callback)) === FALSE) {
1970 1970
 					// user error msg
1971
-				$error_msg =  __( 'An error occurred. The  requested metabox could not be found.', 'event_espresso' );
1971
+				$error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1972 1972
 				// developer error msg
1973
-				$error_msg .= '||' . sprintf( __( 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', 'event_espresso' ), $metabox_callback );
1974
-				throw new EE_Error( $error_msg );
1973
+				$error_msg .= '||'.sprintf(__('The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', 'event_espresso'), $metabox_callback);
1974
+				throw new EE_Error($error_msg);
1975 1975
 				}
1976 1976
 			}
1977 1977
 		}
@@ -1988,17 +1988,17 @@  discard block
 block discarded – undo
1988 1988
 	 * @return void
1989 1989
 	 */
1990 1990
 	private function _add_screen_columns() {
1991
-		if ( is_array($this->_route_config) && isset( $this->_route_config['columns'] ) && is_array($this->_route_config['columns']) && count( $this->_route_config['columns'] == 2 ) ) {
1991
+		if (is_array($this->_route_config) && isset($this->_route_config['columns']) && is_array($this->_route_config['columns']) && count($this->_route_config['columns'] == 2)) {
1992 1992
 
1993
-			add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1] ) );
1993
+			add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1]));
1994 1994
 			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1995 1995
 			$screen_id = $this->_current_screen->id;
1996 1996
 			$screen_columns = (int) get_user_option("screen_layout_$screen_id");
1997
-			$total_columns = !empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1998
-			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1997
+			$total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1998
+			$this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
1999 1999
 			$this->_template_args['current_page'] = $this->_wp_page_slug;
2000 2000
 			$this->_template_args['screen'] = $this->_current_screen;
2001
-			$this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
2001
+			$this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php';
2002 2002
 
2003 2003
 			//finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2004 2004
 			$this->_route_config['has_metaboxes'] = TRUE;
@@ -2015,11 +2015,11 @@  discard block
 block discarded – undo
2015 2015
 	 */
2016 2016
 
2017 2017
 	private function _espresso_news_post_box() {
2018
-		$news_box_title = apply_filters( 'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __( 'New @ Event Espresso', 'event_espresso' ) );
2019
-		add_meta_box( 'espresso_news_post_box', $news_box_title, array(
2018
+		$news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
2019
+		add_meta_box('espresso_news_post_box', $news_box_title, array(
2020 2020
 			$this,
2021 2021
 			'espresso_news_post_box'
2022
-		), $this->_wp_page_slug, 'side' );
2022
+		), $this->_wp_page_slug, 'side');
2023 2023
 	}
2024 2024
 
2025 2025
 
@@ -2027,14 +2027,14 @@  discard block
 block discarded – undo
2027 2027
 	 * Code for setting up espresso ratings request metabox.
2028 2028
 	 */
2029 2029
 	protected function _espresso_ratings_request() {
2030
-		if ( ! apply_filters( 'FHEE_show_ratings_request_meta_box', true ) ) {
2030
+		if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2031 2031
 			return '';
2032 2032
 		}
2033
-		$ratings_box_title = apply_filters( 'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso') );
2034
-		add_meta_box( 'espresso_ratings_request', $ratings_box_title, array(
2033
+		$ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
2034
+		add_meta_box('espresso_ratings_request', $ratings_box_title, array(
2035 2035
 			$this,
2036 2036
 			'espresso_ratings_request'
2037
-		), $this->_wp_page_slug, 'side' );
2037
+		), $this->_wp_page_slug, 'side');
2038 2038
 	}
2039 2039
 
2040 2040
 
@@ -2042,35 +2042,35 @@  discard block
 block discarded – undo
2042 2042
 	 * Code for setting up espresso ratings request metabox content.
2043 2043
 	 */
2044 2044
 	public function espresso_ratings_request() {
2045
-		$template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
2046
-		EE_Registry::instance()->load_helper( 'Template' );
2047
-		EEH_Template::display_template( $template_path, array() );
2045
+		$template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php';
2046
+		EE_Registry::instance()->load_helper('Template');
2047
+		EEH_Template::display_template($template_path, array());
2048 2048
 	}
2049 2049
 
2050 2050
 
2051 2051
 
2052 2052
 
2053
-	public static function cached_rss_display( $rss_id, $url ) {
2054
-		$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&#8230;' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>';
2055
-		$doing_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX );
2056
-		$pre = '<div class="espresso-rss-display">' . "\n\t";
2057
-		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2058
-		$post = '</div>' . "\n";
2053
+	public static function cached_rss_display($rss_id, $url) {
2054
+		$loading = '<p class="widget-loading hide-if-no-js">'.__('Loading&#8230;').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>';
2055
+		$doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
2056
+		$pre = '<div class="espresso-rss-display">'."\n\t";
2057
+		$pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
2058
+		$post = '</div>'."\n";
2059 2059
 
2060
-		$cache_key = 'ee_rss_' . md5( $rss_id );
2061
-		if ( FALSE != ( $output = get_transient( $cache_key ) ) ) {
2062
-			echo $pre . $output . $post;
2060
+		$cache_key = 'ee_rss_'.md5($rss_id);
2061
+		if (FALSE != ($output = get_transient($cache_key))) {
2062
+			echo $pre.$output.$post;
2063 2063
 			return TRUE;
2064 2064
 		}
2065 2065
 
2066
-		if ( ! $doing_ajax ) {
2067
-			echo $pre . $loading . $post;
2066
+		if ( ! $doing_ajax) {
2067
+			echo $pre.$loading.$post;
2068 2068
 			return FALSE;
2069 2069
 		}
2070 2070
 
2071 2071
 		ob_start();
2072
-		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5) );
2073
-		set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS );
2072
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2073
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2074 2074
 		return TRUE;
2075 2075
 
2076 2076
 	}
@@ -2082,13 +2082,13 @@  discard block
 block discarded – undo
2082 2082
 	  	<div id="espresso_news_post_box_content" class="infolinks">
2083 2083
 	  		<?php
2084 2084
 	  		// Get RSS Feed(s)
2085
-	  		$feed_url = apply_filters( 'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/' );
2085
+	  		$feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
2086 2086
 	  		$url = urlencode($feed_url);
2087
-	  		self::cached_rss_display( 'espresso_news_post_box_content', $url );
2087
+	  		self::cached_rss_display('espresso_news_post_box_content', $url);
2088 2088
 
2089 2089
 	  		?>
2090 2090
 	  	</div>
2091
-	  	<?php do_action( 'AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2091
+	  	<?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2092 2092
 	  </div>
2093 2093
 		<?php
2094 2094
 	}
@@ -2109,32 +2109,32 @@  discard block
 block discarded – undo
2109 2109
 
2110 2110
 	protected function _espresso_sponsors_post_box() {
2111 2111
 
2112
-		$show_sponsors = apply_filters( 'FHEE_show_sponsors_meta_box', TRUE );
2113
-		if ( $show_sponsors )
2114
-			add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array( $this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2112
+		$show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', TRUE);
2113
+		if ($show_sponsors)
2114
+			add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2115 2115
 	}
2116 2116
 
2117 2117
 
2118 2118
 	public function espresso_sponsors_post_box() {
2119
-		$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2120
-		EEH_Template::display_template( $templatepath );
2119
+		$templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php';
2120
+		EEH_Template::display_template($templatepath);
2121 2121
 	}
2122 2122
 
2123 2123
 
2124 2124
 
2125 2125
 	private function _publish_post_box() {
2126
-		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2126
+		$meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2127 2127
 
2128 2128
 		//if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2129
-		if ( !empty( $this->_labels['publishbox'] ) ) {
2130
-			$box_label = is_array( $this->_labels['publishbox'] ) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2129
+		if ( ! empty($this->_labels['publishbox'])) {
2130
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2131 2131
 		} else {
2132 2132
 			$box_label = __('Publish', 'event_espresso');
2133 2133
 		}
2134 2134
 
2135
-		$box_label = apply_filters( 'FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this );
2135
+		$box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2136 2136
 
2137
-		add_meta_box( $meta_box_ref, $box_label, array( $this, 'editor_overview' ), $this->_current_screen->id, 'side', 'high' );
2137
+		add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2138 2138
 
2139 2139
 	}
2140 2140
 
@@ -2142,9 +2142,9 @@  discard block
 block discarded – undo
2142 2142
 
2143 2143
 	public function editor_overview() {
2144 2144
 		//if we have extra content set let's add it in if not make sure its empty
2145
-		$this->_template_args['publish_box_extra_content'] = isset( $this->_template_args['publish_box_extra_content'] ) ? $this->_template_args['publish_box_extra_content'] : '';
2146
-		$template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2147
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2145
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2146
+		$template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php';
2147
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2148 2148
 	}
2149 2149
 
2150 2150
 
@@ -2160,8 +2160,8 @@  discard block
 block discarded – undo
2160 2160
 	 * @see $this->_set_publish_post_box_vars for param details
2161 2161
 	 * @since 4.6.0
2162 2162
 	 */
2163
-	public function set_publish_post_box_vars( $name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true ) {
2164
-		$this->_set_publish_post_box_vars( $name, $id, $delete, $save_close_redirect_URL, $both_btns );
2163
+	public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true) {
2164
+		$this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2165 2165
 	}
2166 2166
 
2167 2167
 
@@ -2180,24 +2180,24 @@  discard block
 block discarded – undo
2180 2180
 	 * @param	string	$post_save_redirect_URL	custom URL to redirect to after Save & Close has been completed
2181 2181
 	 * @param	boolean	$both_btns	whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2182 2182
 	 */
2183
-	protected function _set_publish_post_box_vars( $name = NULL, $id = FALSE, $delete = FALSE, $save_close_redirect_URL = NULL, $both_btns = TRUE ) {
2183
+	protected function _set_publish_post_box_vars($name = NULL, $id = FALSE, $delete = FALSE, $save_close_redirect_URL = NULL, $both_btns = TRUE) {
2184 2184
 
2185 2185
 		// if Save & Close, use a custom redirect URL or default to the main page?
2186
-		$save_close_redirect_URL = ! empty( $save_close_redirect_URL ) ? $save_close_redirect_URL : $this->_admin_base_url;
2186
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2187 2187
 		// create the Save & Close and Save buttons
2188
-		$this->_set_save_buttons( $both_btns, array(), array(), $save_close_redirect_URL );
2188
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2189 2189
 		//if we have extra content set let's add it in if not make sure its empty
2190
-		$this->_template_args['publish_box_extra_content'] = isset( $this->_template_args['publish_box_extra_content'] ) ? $this->_template_args['publish_box_extra_content'] : '';
2190
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2191 2191
 
2192 2192
 
2193
-		if ( $delete && ! empty( $id )  ) {
2193
+		if ($delete && ! empty($id)) {
2194 2194
 			$delete = is_bool($delete) ? 'delete' : $delete; //make sure we have a default if just true is sent.
2195
-			$delete_link_args = array( $name => $id );
2196
-			$delete = $this->get_action_link_or_button( $delete, $delete, $delete_link_args, 'submitdelete deletion');
2195
+			$delete_link_args = array($name => $id);
2196
+			$delete = $this->get_action_link_or_button($delete, $delete, $delete_link_args, 'submitdelete deletion');
2197 2197
 		}
2198 2198
 
2199
-		$this->_template_args['publish_delete_link'] = !empty( $id ) ? $delete : '';
2200
-		if ( ! empty( $name ) && ! empty( $id ) ) {
2199
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2200
+		if ( ! empty($name) && ! empty($id)) {
2201 2201
 			$hidden_field_arr[$name] = array(
2202 2202
 				'type' => 'hidden',
2203 2203
 				'value' => $id
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
 			$hf = '';
2208 2208
 		}
2209 2209
 		// add hidden field
2210
-		$this->_template_args['publish_hidden_fields'] = ! empty( $hf ) ? $hf[$name]['field'] : $hf;
2210
+		$this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2211 2211
 
2212 2212
 	}
2213 2213
 
@@ -2224,8 +2224,8 @@  discard block
 block discarded – undo
2224 2224
 		<noscript>
2225 2225
 			<div id="no-js-message" class="error">
2226 2226
 				<p style="font-size:1.3em;">
2227
-					<span style="color:red;"><?php _e( 'Warning!', 'event_espresso' ); ?></span>
2228
-					<?php _e( 'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.', 'event_espresso' ); ?>
2227
+					<span style="color:red;"><?php _e('Warning!', 'event_espresso'); ?></span>
2228
+					<?php _e('Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.', 'event_espresso'); ?>
2229 2229
 				</p>
2230 2230
 			</div>
2231 2231
 		</noscript>
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
 	*		@return 		string
2246 2246
 	*/
2247 2247
 	private function _display_espresso_notices() {
2248
-		$notices = $this->_get_transient( TRUE );
2248
+		$notices = $this->_get_transient(TRUE);
2249 2249
 		echo stripslashes($notices);
2250 2250
 	}
2251 2251
 
@@ -2297,11 +2297,11 @@  discard block
 block discarded – undo
2297 2297
 	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2298 2298
 	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2299 2299
 	 */
2300
-	public function _add_admin_page_meta_box( $action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true ) {
2301
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, $callback );
2300
+	public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true) {
2301
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2302 2302
 
2303 2303
 		//if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2304
-		if ( empty( $callback_args ) && $create_func ) {
2304
+		if (empty($callback_args) && $create_func) {
2305 2305
 			$callback_args = array(
2306 2306
 				'template_path' => $this->_template_path,
2307 2307
 				'template_args' => $this->_template_args,
@@ -2311,7 +2311,7 @@  discard block
 block discarded – undo
2311 2311
 		//if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2312 2312
 		$call_back_func = $create_func ? create_function('$post, $metabox', 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2313 2313
 
2314
-		add_meta_box( str_replace( '_', '-', $action ) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args );
2314
+		add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2315 2315
 	}
2316 2316
 
2317 2317
 
@@ -2324,7 +2324,7 @@  discard block
 block discarded – undo
2324 2324
 	 */
2325 2325
 	public function display_admin_page_with_metabox_columns() {
2326 2326
 		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2327
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_column_template_path, $this->_template_args, TRUE);
2327
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, TRUE);
2328 2328
 
2329 2329
 		//the final wrapper
2330 2330
 		$this->admin_page_wrapper();
@@ -2367,7 +2367,7 @@  discard block
 block discarded – undo
2367 2367
 	 * @return void
2368 2368
 	 */
2369 2369
 	public function display_about_admin_page() {
2370
-		$this->_display_admin_page( FALSE, TRUE );
2370
+		$this->_display_admin_page(FALSE, TRUE);
2371 2371
 	}
2372 2372
 
2373 2373
 
@@ -2383,26 +2383,26 @@  discard block
 block discarded – undo
2383 2383
 	 * @return html           admin_page
2384 2384
 	 */
2385 2385
 	private function _display_admin_page($sidebar = false, $about = FALSE) {
2386
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2386
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2387 2387
 
2388 2388
 		//custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2389
-		do_action( 'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes' );
2389
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2390 2390
 
2391 2391
 		// set current wp page slug - looks like: event-espresso_page_event_categories
2392 2392
 		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2393 2393
 		$this->_template_args['current_page'] = $this->_wp_page_slug;
2394 2394
 
2395
-		$template_path = $sidebar ?  EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2395
+		$template_path = $sidebar ?  EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2396 2396
 
2397
-		if ( defined('DOING_AJAX' ) )
2398
-			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2397
+		if (defined('DOING_AJAX'))
2398
+			$template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2399 2399
 
2400
-		$template_path = !empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2400
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2401 2401
 
2402
-		$this->_template_args['post_body_content'] = isset( $this->_template_args['admin_page_content'] ) ? $this->_template_args['admin_page_content'] : '';
2402
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2403 2403
 		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2404 2404
 		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2405
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2405
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2406 2406
 
2407 2407
 
2408 2408
 		// the final template wrapper
@@ -2422,7 +2422,7 @@  discard block
 block discarded – undo
2422 2422
 	 * @param bool   $display_sidebar whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2423 2423
 	 * @return void
2424 2424
 	 */
2425
-	public function display_admin_caf_preview_page( $utm_campaign_source = '', $display_sidebar = TRUE ) {
2425
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = TRUE) {
2426 2426
 		//let's generate a default preview action button if there isn't one already present.
2427 2427
 		$this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso');
2428 2428
 		$buy_now_url = add_query_arg(
@@ -2435,10 +2435,10 @@  discard block
 block discarded – undo
2435 2435
 			),
2436 2436
 		'http://eventespresso.com/pricing/'
2437 2437
 		);
2438
-		$this->_template_args['preview_action_button'] = ! isset( $this->_template_args['preview_action_button'] ) ? $this->get_action_link_or_button( '', 'buy_now', array(), 'button-primary button-large', $buy_now_url, true ) : $this->_template_args['preview_action_button'];
2439
-		$template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2440
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2441
-		$this->_display_admin_page( $display_sidebar );
2438
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button']) ? $this->get_action_link_or_button('', 'buy_now', array(), 'button-primary button-large', $buy_now_url, true) : $this->_template_args['preview_action_button'];
2439
+		$template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php';
2440
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2441
+		$this->_display_admin_page($display_sidebar);
2442 2442
 	}
2443 2443
 
2444 2444
 
@@ -2472,41 +2472,41 @@  discard block
 block discarded – undo
2472 2472
 	 * @param boolean $sidebar whether to display with sidebar or not.
2473 2473
 	 * @return html
2474 2474
 	 */
2475
-	private function _display_admin_list_table_page( $sidebar = false ) {
2475
+	private function _display_admin_list_table_page($sidebar = false) {
2476 2476
 		//setup search attributes
2477 2477
 		$this->_set_search_attributes();
2478 2478
 		$this->_template_args['current_page'] = $this->_wp_page_slug;
2479
-		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2479
+		$template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2480 2480
 
2481
-		$this->_template_args['table_url'] = defined( 'DOING_AJAX') ? add_query_arg( array( 'noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url ) : add_query_arg( array( 'route' => $this->_req_action), $this->_admin_base_url);
2481
+		$this->_template_args['table_url'] = defined('DOING_AJAX') ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url) : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2482 2482
 		$this->_template_args['list_table'] = $this->_list_table_object;
2483 2483
 		$this->_template_args['current_route'] = $this->_req_action;
2484
-		$this->_template_args['list_table_class'] = get_class( $this->_list_table_object );
2484
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2485 2485
 
2486 2486
 		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2487
-		if( ! empty( $ajax_sorting_callback )) {
2488
-			$sortable_list_table_form_fields = wp_nonce_field( $ajax_sorting_callback . '_nonce', $ajax_sorting_callback . '_nonce', FALSE, FALSE );
2487
+		if ( ! empty($ajax_sorting_callback)) {
2488
+			$sortable_list_table_form_fields = wp_nonce_field($ajax_sorting_callback.'_nonce', $ajax_sorting_callback.'_nonce', FALSE, FALSE);
2489 2489
 //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2490 2490
 //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2491
-			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug .'" />';
2492
-			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2491
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />';
2492
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />';
2493 2493
 		} else {
2494 2494
 			$sortable_list_table_form_fields = '';
2495 2495
 		}
2496 2496
 
2497 2497
 		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2498
-		$hidden_form_fields = isset( $this->_template_args['list_table_hidden_fields'] ) ? $this->_template_args['list_table_hidden_fields'] : '';
2499
-		$nonce_ref = $this->_req_action . '_nonce';
2500
-		$hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce( $nonce_ref ) . '">';
2498
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2499
+		$nonce_ref = $this->_req_action.'_nonce';
2500
+		$hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2501 2501
 		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2502 2502
 
2503 2503
 		//display message about search results?
2504
-		$this->_template_args['before_list_table'] .= apply_filters( 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', !empty( $this->_req_data['s'] ) ? '<p class="ee-search-results">' . sprintf( __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'), trim($this->_req_data['s'], '%') ) . '</p>' : '', $this->page_slug, $this->_req_data, $this->_req_action );
2504
+		$this->_template_args['before_list_table'] .= apply_filters('FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', ! empty($this->_req_data['s']) ? '<p class="ee-search-results">'.sprintf(__('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'), trim($this->_req_data['s'], '%')).'</p>' : '', $this->page_slug, $this->_req_data, $this->_req_action);
2505 2505
 
2506
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2506
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2507 2507
 
2508 2508
 		// the final template wrapper
2509
-		if ( $sidebar )
2509
+		if ($sidebar)
2510 2510
 			$this->display_admin_page_with_sidebar();
2511 2511
 		else
2512 2512
 			$this->display_admin_page_with_no_sidebar();
@@ -2529,9 +2529,9 @@  discard block
 block discarded – undo
2529 2529
 	 * @param  array $items  see above for format of array
2530 2530
 	 * @return string        html string of legend
2531 2531
 	 */
2532
-	protected function _display_legend( $items ) {
2533
-		$template_args['items'] = apply_filters( 'FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this );
2534
-		$legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2532
+	protected function _display_legend($items) {
2533
+		$template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this);
2534
+		$legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php';
2535 2535
 		return EEH_Template::display_template($legend_template, $template_args, TRUE);
2536 2536
 	}
2537 2537
 
@@ -2556,31 +2556,31 @@  discard block
 block discarded – undo
2556 2556
 	 *
2557 2557
 	 * @return json object
2558 2558
 	 */
2559
-	protected function _return_json( $sticky_notices = FALSE ) {
2559
+	protected function _return_json($sticky_notices = FALSE) {
2560 2560
 
2561 2561
 		//make sure any EE_Error notices have been handled.
2562
-		$this->_process_notices( array(), TRUE, $sticky_notices );
2562
+		$this->_process_notices(array(), TRUE, $sticky_notices);
2563 2563
 
2564 2564
 
2565
-		$data = isset( $this->_template_args['data'] ) ? $this->_template_args['data'] : array();
2565
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2566 2566
 		unset($this->_template_args['data']);
2567 2567
 		$json = array(
2568
-			'error' => isset( $this->_template_args['error'] ) ? $this->_template_args['error'] : FALSE,
2569
-			'success' => isset( $this->_template_args['success'] ) ? $this->_template_args['success'] : FALSE,
2568
+			'error' => isset($this->_template_args['error']) ? $this->_template_args['error'] : FALSE,
2569
+			'success' => isset($this->_template_args['success']) ? $this->_template_args['success'] : FALSE,
2570 2570
 			'notices' => EE_Error::get_notices(),
2571
-			'content' => isset( $this->_template_args['admin_page_content'] ) ? $this->_template_args['admin_page_content'] : '',
2572
-			'data' => array_merge( $data, array('template_args' => $this->_template_args ) ),
2571
+			'content' => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2572
+			'data' => array_merge($data, array('template_args' => $this->_template_args)),
2573 2573
 			'isEEajax' => TRUE //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2574 2574
 			);
2575 2575
 
2576 2576
 
2577 2577
 		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2578
-		if ( NULL === error_get_last() || ! headers_sent() )
2578
+		if (NULL === error_get_last() || ! headers_sent())
2579 2579
 			header('Content-Type: application/json; charset=UTF-8');
2580
-                if( function_exists( 'wp_json_encode' ) ) {
2581
-                    echo wp_json_encode( $json );
2580
+                if (function_exists('wp_json_encode')) {
2581
+                    echo wp_json_encode($json);
2582 2582
                 } else {
2583
-                    echo json_encode( $json );
2583
+                    echo json_encode($json);
2584 2584
                 }
2585 2585
 		exit();
2586 2586
 	}
@@ -2592,11 +2592,11 @@  discard block
 block discarded – undo
2592 2592
 	 * @return json_obj|EE_Error
2593 2593
 	 */
2594 2594
 	public function return_json() {
2595
-		if ( defined('DOING_AJAX') && DOING_AJAX )
2595
+		if (defined('DOING_AJAX') && DOING_AJAX)
2596 2596
 			$this->_return_json();
2597 2597
 
2598 2598
 		else {
2599
-			throw new EE_Error( sprintf( __('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__ ) );
2599
+			throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2600 2600
 		}
2601 2601
 	}
2602 2602
 
@@ -2611,7 +2611,7 @@  discard block
 block discarded – undo
2611 2611
 	 * @access public
2612 2612
 	 * @return void
2613 2613
 	 */
2614
-	public function set_hook_object( EE_Admin_Hooks $hook_obj ) {
2614
+	public function set_hook_object(EE_Admin_Hooks $hook_obj) {
2615 2615
 		$this->_hook_obj = $hook_obj;
2616 2616
 	}
2617 2617
 
@@ -2627,33 +2627,33 @@  discard block
 block discarded – undo
2627 2627
 	*/
2628 2628
 	public function admin_page_wrapper($about = FALSE) {
2629 2629
 
2630
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2630
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2631 2631
 
2632 2632
 		$this->_nav_tabs = $this->_get_main_nav_tabs();
2633 2633
 
2634 2634
 		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
2635 2635
 		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
2636 2636
 
2637
-		$this->_template_args['before_admin_page_content'] = apply_filters( 'FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view, isset( $this->_template_args['before_admin_page_content'] ) ? $this->_template_args['before_admin_page_content'] : '');
2638
-		$this->_template_args['after_admin_page_content'] = apply_filters( 'FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view, isset( $this->_template_args['after_admin_page_content'] ) ? $this->_template_args['after_admin_page_content'] : '');
2637
+		$this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view, isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2638
+		$this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view, isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2639 2639
 
2640 2640
 		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2641 2641
 
2642 2642
 
2643 2643
 
2644 2644
 		// load settings page wrapper template
2645
-		$template_path = !defined( 'DOING_AJAX' ) ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2645
+		$template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php';
2646 2646
 
2647 2647
 		//about page?
2648 2648
 		$template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2649 2649
 
2650 2650
 
2651
-		if ( defined( 'DOING_AJAX' ) ) {
2652
-			$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2651
+		if (defined('DOING_AJAX')) {
2652
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2653 2653
 
2654 2654
 			$this->_return_json();
2655 2655
 		} else {
2656
-			EEH_Template::display_template( $template_path, $this->_template_args );
2656
+			EEH_Template::display_template($template_path, $this->_template_args);
2657 2657
 		}
2658 2658
 
2659 2659
 	}
@@ -2666,7 +2666,7 @@  discard block
 block discarded – undo
2666 2666
 	 */
2667 2667
 	protected function _get_main_nav_tabs() {
2668 2668
 		//let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
2669
-		EE_Registry::instance()->load_helper( 'Tabbed_Content' );
2669
+		EE_Registry::instance()->load_helper('Tabbed_Content');
2670 2670
 		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2671 2671
 	}
2672 2672
 
@@ -2682,7 +2682,7 @@  discard block
 block discarded – undo
2682 2682
 	*		@access public
2683 2683
 	*		@return void
2684 2684
 	*/
2685
-	private function _sort_nav_tabs( $a, $b ) {
2685
+	private function _sort_nav_tabs($a, $b) {
2686 2686
 		if ($a['order'] == $b['order']) {
2687 2687
 	        return 0;
2688 2688
 	    }
@@ -2703,8 +2703,8 @@  discard block
 block discarded – undo
2703 2703
 	 * 	@uses EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2704 2704
 	 * 	@uses EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2705 2705
 	 */
2706
-	protected function _generate_admin_form_fields( $input_vars = array(), $generator = 'string', $id = FALSE ) {
2707
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
2706
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = FALSE) {
2707
+		EE_Registry::instance()->load_helper('Form_Fields');
2708 2708
 		$content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2709 2709
 		return $content;
2710 2710
 	}
@@ -2726,25 +2726,25 @@  discard block
 block discarded – undo
2726 2726
 	 * @param array $actions if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2727 2727
 	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2728 2728
 	 */
2729
-	protected function _set_save_buttons($both = TRUE, $text = array(), $actions = array(), $referrer = NULL ) {
2729
+	protected function _set_save_buttons($both = TRUE, $text = array(), $actions = array(), $referrer = NULL) {
2730 2730
 		//make sure $text and $actions are in an array
2731 2731
 		$text = (array) $text;
2732 2732
 		$actions = (array) $actions;
2733 2733
 		$referrer_url = empty($referrer) ? '' : $referrer;
2734
-		$referrer_url = !$referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] .'" />' : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer .'" />';
2734
+		$referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />' : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />';
2735 2735
 
2736
-		$button_text = !empty($text) ? $text : array( __('Save', 'event_espresso'), __('Save and Close', 'event_espresso') );
2737
-		$default_names = array( 'save', 'save_and_close' );
2736
+		$button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2737
+		$default_names = array('save', 'save_and_close');
2738 2738
 
2739 2739
 		//add in a hidden index for the current page (so save and close redirects properly)
2740 2740
 		$this->_template_args['save_buttons'] = $referrer_url;
2741 2741
 
2742
-		foreach ( $button_text as $key => $button ) {
2742
+		foreach ($button_text as $key => $button) {
2743 2743
 			$ref = $default_names[$key];
2744
-			$id = $this->_current_view . '_' . $ref;
2745
-			$name = !empty($actions) ? $actions[$key] : $ref;
2746
-			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2747
-			if ( !$both ) break;
2744
+			$id = $this->_current_view.'_'.$ref;
2745
+			$name = ! empty($actions) ? $actions[$key] : $ref;
2746
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />';
2747
+			if ( ! $both) break;
2748 2748
 		}
2749 2749
 
2750 2750
 	}
@@ -2757,8 +2757,8 @@  discard block
 block discarded – undo
2757 2757
 	 * @since 4.6.0
2758 2758
 	 *
2759 2759
 	 */
2760
-	public function set_add_edit_form_tags( $route = '', $additional_hidden_fields = array() ) {
2761
-		$this->_set_add_edit_form_tags( $route, $additional_hidden_fields );
2760
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) {
2761
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2762 2762
 	}
2763 2763
 
2764 2764
 
@@ -2771,30 +2771,30 @@  discard block
 block discarded – undo
2771 2771
 	 * @param array $additional_hidden_fields any additional hidden fields required in the form header
2772 2772
 	 * @return void
2773 2773
 	 */
2774
-	protected function _set_add_edit_form_tags( $route = '', $additional_hidden_fields = array() ) {
2774
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) {
2775 2775
 
2776
-		if ( empty( $route )) {
2776
+		if (empty($route)) {
2777 2777
 			$user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2778
-			$dev_msg = $user_msg . "\n" . sprintf( __('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__ );
2779
-			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
2778
+			$dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2779
+			EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
2780 2780
 		}
2781 2781
 		// open form
2782
-		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2782
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >';
2783 2783
 		// add nonce
2784
-		$nonce = wp_nonce_field( $route . '_nonce', $route . '_nonce', FALSE, FALSE );
2784
+		$nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', FALSE, FALSE);
2785 2785
 //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2786
-		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2786
+		$this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
2787 2787
 		// add REQUIRED form action
2788 2788
 		$hidden_fields = array(
2789
-				'action' => array( 'type' => 'hidden', 'value' => $route ),
2789
+				'action' => array('type' => 'hidden', 'value' => $route),
2790 2790
 			);
2791 2791
 		// merge arrays
2792
-		$hidden_fields = is_array( $additional_hidden_fields) ? array_merge( $hidden_fields, $additional_hidden_fields ) : $hidden_fields;
2792
+		$hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2793 2793
 		// generate form fields
2794
-		$form_fields = $this->_generate_admin_form_fields( $hidden_fields, 'array' );
2794
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2795 2795
 		// add fields to form
2796
-		foreach ( $form_fields as $field_name => $form_field ) {
2797
-			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2796
+		foreach ($form_fields as $field_name => $form_field) {
2797
+			$this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
2798 2798
 		}
2799 2799
 
2800 2800
 		// close form
@@ -2811,8 +2811,8 @@  discard block
 block discarded – undo
2811 2811
 	 * @see EE_Admin_Page::_redirect_after_action() for params.
2812 2812
 	 * @since 4.5.0
2813 2813
 	 */
2814
-	public function redirect_after_action( $success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE ) {
2815
-		$this->_redirect_after_action( $success, $what, $action_desc, $query_args, $override_overwrite );
2814
+	public function redirect_after_action($success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE) {
2815
+		$this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2816 2816
 	}
2817 2817
 
2818 2818
 
@@ -2827,32 +2827,32 @@  discard block
 block discarded – undo
2827 2827
 	 *	@access protected
2828 2828
 	 *	@return void
2829 2829
 	 */
2830
-	protected function _redirect_after_action( $success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE ) {
2830
+	protected function _redirect_after_action($success = FALSE, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = FALSE) {
2831 2831
 
2832
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2832
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2833 2833
 
2834 2834
 		//class name for actions/filters.
2835 2835
 		$classname = get_class($this);
2836 2836
 
2837 2837
 		//set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
2838
-		$redirect_url = isset( $query_args['page'] ) ? admin_url('admin.php') : $this->_admin_base_url;
2839
-		$notices = EE_Error::get_notices( FALSE );
2838
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2839
+		$notices = EE_Error::get_notices(FALSE);
2840 2840
 
2841 2841
 		// overwrite default success messages //BUT ONLY if overwrite not overridden
2842
-		if ( ! $override_overwrite || ! empty( $notices['errors'] )) {
2842
+		if ( ! $override_overwrite || ! empty($notices['errors'])) {
2843 2843
 			EE_Error::overwrite_success();
2844 2844
 		}
2845 2845
 		// how many records affected ? more than one record ? or just one ?
2846
-		if ( $success > 1 && empty( $notices['errors'] )) {
2846
+		if ($success > 1 && empty($notices['errors'])) {
2847 2847
 			// set plural msg
2848
-			EE_Error::add_success( sprintf( __('The "%s" have been successfully %s.', 'event_espresso'), $what, $action_desc ), __FILE__, __FUNCTION__, __LINE__);
2849
-		} else if ( $success == 1 && empty( $notices['errors'] )) {
2848
+			EE_Error::add_success(sprintf(__('The "%s" have been successfully %s.', 'event_espresso'), $what, $action_desc), __FILE__, __FUNCTION__, __LINE__);
2849
+		} else if ($success == 1 && empty($notices['errors'])) {
2850 2850
 			// set singular msg
2851
-			EE_Error::add_success( sprintf( __('The "%s" has been successfully %s.', 'event_espresso'), $what, $action_desc), __FILE__, __FUNCTION__, __LINE__ );
2851
+			EE_Error::add_success(sprintf(__('The "%s" has been successfully %s.', 'event_espresso'), $what, $action_desc), __FILE__, __FUNCTION__, __LINE__);
2852 2852
 		}
2853 2853
 
2854 2854
 		// check that $query_args isn't something crazy
2855
-		if ( ! is_array( $query_args )) {
2855
+		if ( ! is_array($query_args)) {
2856 2856
 			$query_args = array();
2857 2857
 		}
2858 2858
 
@@ -2865,36 +2865,36 @@  discard block
 block discarded – undo
2865 2865
 		 * @param array $query_args   The original query_args array coming into the
2866 2866
 		 *                          		method.
2867 2867
 		 */
2868
-		do_action( 'AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args );
2868
+		do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args);
2869 2869
 
2870 2870
 		//calculate where we're going (if we have a "save and close" button pushed)
2871
-		if ( isset($this->_req_data['save_and_close'] ) && isset($this->_req_data['save_and_close_referrer'] ) ) {
2871
+		if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2872 2872
 			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2873
-			$parsed_url = parse_url( $this->_req_data['save_and_close_referrer'] );
2873
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2874 2874
 			// regenerate query args array from refferer URL
2875
-			parse_str( $parsed_url['query'], $query_args );
2875
+			parse_str($parsed_url['query'], $query_args);
2876 2876
 			// correct page and action will be in the query args now
2877
-			$redirect_url = admin_url( 'admin.php' );
2877
+			$redirect_url = admin_url('admin.php');
2878 2878
 		}
2879 2879
 
2880 2880
 		//merge any default query_args set in _default_route_query_args property
2881
-		if ( ! empty( $this->_default_route_query_args ) && ! $this->_is_UI_request ) {
2881
+		if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2882 2882
 			$args_to_merge = array();
2883
-			foreach ( $this->_default_route_query_args as $query_param => $query_value ) {
2883
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
2884 2884
 				//is there a wp_referer array in our _default_route_query_args property?
2885
-				if ( $query_param == 'wp_referer'  ) {
2885
+				if ($query_param == 'wp_referer') {
2886 2886
 					$query_value = (array) $query_value;
2887
-					foreach ( $query_value as $reference => $value ) {
2888
-						if ( strpos( $reference, 'nonce' ) !== false ) {
2887
+					foreach ($query_value as $reference => $value) {
2888
+						if (strpos($reference, 'nonce') !== false) {
2889 2889
 							continue;
2890 2890
 						}
2891 2891
 
2892 2892
 						//finally we will override any arguments in the referer with
2893 2893
 						//what might be set on the _default_route_query_args array.
2894
-						if ( isset( $this->_default_route_query_args[$reference] ) ) {
2895
-							$args_to_merge[$reference] = urlencode( $this->_default_route_query_args[$reference] );
2894
+						if (isset($this->_default_route_query_args[$reference])) {
2895
+							$args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2896 2896
 						} else {
2897
-							$args_to_merge[$reference] = urlencode( $value );
2897
+							$args_to_merge[$reference] = urlencode($value);
2898 2898
 						}
2899 2899
 					}
2900 2900
 					continue;
@@ -2905,7 +2905,7 @@  discard block
 block discarded – undo
2905 2905
 
2906 2906
 			//now let's merge these arguments but override with what was specifically sent in to the
2907 2907
 			//redirect.
2908
-			$query_args = array_merge( $args_to_merge, $query_args );
2908
+			$query_args = array_merge($args_to_merge, $query_args);
2909 2909
 		}
2910 2910
 
2911 2911
 		$this->_process_notices($query_args);
@@ -2914,19 +2914,19 @@  discard block
 block discarded – undo
2914 2914
 		// generate redirect url
2915 2915
 
2916 2916
 		// if redirecting to anything other than the main page, add a nonce
2917
-		if ( isset( $query_args['action'] )) {
2917
+		if (isset($query_args['action'])) {
2918 2918
 			// manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2919
-			$query_args['_wpnonce'] = wp_create_nonce( $query_args['action'] . '_nonce' );
2919
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
2920 2920
 		}
2921 2921
 
2922 2922
 		//we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2923
-		do_action( 'AHEE_redirect_' . $classname . $this->_req_action, $query_args );
2923
+		do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
2924 2924
 
2925
-		$redirect_url = apply_filters( 'FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce( $query_args, $redirect_url ), $query_args );
2925
+		$redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2926 2926
 
2927 2927
 
2928 2928
 		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2929
-		if ( defined('DOING_AJAX' ) ) {
2929
+		if (defined('DOING_AJAX')) {
2930 2930
 			$default_data = array(
2931 2931
 				'close' => TRUE,
2932 2932
 				'redirect_url' => $redirect_url,
@@ -2935,11 +2935,11 @@  discard block
 block discarded – undo
2935 2935
 				);
2936 2936
 
2937 2937
 			$this->_template_args['success'] = $success;
2938
-			$this->_template_args['data'] = !empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data'] ): $default_data;
2938
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2939 2939
 			$this->_return_json();
2940 2940
 		}
2941 2941
 
2942
-		wp_safe_redirect( $redirect_url );
2942
+		wp_safe_redirect($redirect_url);
2943 2943
 		exit();
2944 2944
 	}
2945 2945
 
@@ -2955,14 +2955,14 @@  discard block
 block discarded – undo
2955 2955
 	 * @param bool    $sticky_notices      This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2956 2956
 	 * @return void
2957 2957
 	 */
2958
-	protected function _process_notices( $query_args = array(), $skip_route_verify = FALSE , $sticky_notices = TRUE ) {
2958
+	protected function _process_notices($query_args = array(), $skip_route_verify = FALSE, $sticky_notices = TRUE) {
2959 2959
 
2960 2960
 		$this->_template_args['notices'] = EE_Error::get_notices();
2961 2961
 
2962 2962
 		//IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2963
-		if ( ! defined( 'DOING_AJAX' ) || $sticky_notices ) {
2964
-			$route = isset( $query_args['action'] ) ? $query_args['action'] : 'default';
2965
-			$this->_add_transient( $route, $this->_template_args['notices'], TRUE, $skip_route_verify );
2963
+		if ( ! defined('DOING_AJAX') || $sticky_notices) {
2964
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
2965
+			$this->_add_transient($route, $this->_template_args['notices'], TRUE, $skip_route_verify);
2966 2966
 		}
2967 2967
 	}
2968 2968
 
@@ -2984,32 +2984,32 @@  discard block
 block discarded – undo
2984 2984
 	 *
2985 2985
 	 * @return string html for button
2986 2986
 	 */
2987
-	public function get_action_link_or_button($action, $type = 'add', $extra_request = array(), $class = 'button-primary', $base_url = FALSE, $exclude_nonce = false ) {
2987
+	public function get_action_link_or_button($action, $type = 'add', $extra_request = array(), $class = 'button-primary', $base_url = FALSE, $exclude_nonce = false) {
2988 2988
 		//first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2989
-		if ( !isset($this->_page_routes[$action]) && !$base_url )
2990
-			throw new EE_Error( sprintf( __('There is no page route for given action for the button.  This action was given: %s', 'event_espresso'), $action) );
2989
+		if ( ! isset($this->_page_routes[$action]) && ! $base_url)
2990
+			throw new EE_Error(sprintf(__('There is no page route for given action for the button.  This action was given: %s', 'event_espresso'), $action));
2991 2991
 
2992
-		if ( !isset( $this->_labels['buttons'][$type] ) )
2993
-			throw new EE_Error( sprintf( __('There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.', 'event_espresso'), $type) );
2992
+		if ( ! isset($this->_labels['buttons'][$type]))
2993
+			throw new EE_Error(sprintf(__('There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.', 'event_espresso'), $type));
2994 2994
 
2995 2995
 		//finally check user access for this button.
2996
-		$has_access = $this->check_user_access( $action, TRUE );
2997
-		if ( ! $has_access ) {
2996
+		$has_access = $this->check_user_access($action, TRUE);
2997
+		if ( ! $has_access) {
2998 2998
 			return '';
2999 2999
 		}
3000 3000
 
3001
-		$_base_url = !$base_url ? $this->_admin_base_url : $base_url;
3001
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3002 3002
 
3003 3003
 		$query_args = array(
3004 3004
 			'action' => $action  );
3005 3005
 
3006 3006
 		//merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3007
-		if ( !empty($extra_request) )
3008
-			$query_args = array_merge( $extra_request, $query_args );
3007
+		if ( ! empty($extra_request))
3008
+			$query_args = array_merge($extra_request, $query_args);
3009 3009
 
3010
-		$url = self::add_query_args_and_nonce( $query_args, $_base_url, false, $exclude_nonce );
3010
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3011 3011
 
3012
-		$button = EEH_Template::get_button_or_link( $url, $this->_labels['buttons'][$type], $class );
3012
+		$button = EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3013 3013
 
3014 3014
 		return $button;
3015 3015
 	}
@@ -3029,11 +3029,11 @@  discard block
 block discarded – undo
3029 3029
 		$args = array(
3030 3030
 			'label' => $this->_admin_page_title,
3031 3031
 			'default' => 10,
3032
-			'option' => $this->_current_page . '_' . $this->_current_view . '_per_page'
3032
+			'option' => $this->_current_page.'_'.$this->_current_view.'_per_page'
3033 3033
 			);
3034 3034
 		//ONLY add the screen option if the user has access to it.
3035
-		if ( $this->check_user_access( $this->_current_view, true ) ) {
3036
-			add_screen_option( $option, $args );
3035
+		if ($this->check_user_access($this->_current_view, true)) {
3036
+			add_screen_option($option, $args);
3037 3037
 		}
3038 3038
 	}
3039 3039
 
@@ -3049,36 +3049,36 @@  discard block
 block discarded – undo
3049 3049
 	 * @return void
3050 3050
 	 */
3051 3051
 	private function _set_per_page_screen_options() {
3052
-		if ( isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) {
3053
-			check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' );
3052
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3053
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3054 3054
 
3055
-			if ( !$user = wp_get_current_user() )
3055
+			if ( ! $user = wp_get_current_user())
3056 3056
 			return;
3057 3057
 			$option = $_POST['wp_screen_options']['option'];
3058 3058
 			$value = $_POST['wp_screen_options']['value'];
3059 3059
 
3060
-			if ( $option != sanitize_key( $option ) )
3060
+			if ($option != sanitize_key($option))
3061 3061
 				return;
3062 3062
 
3063 3063
 			$map_option = $option;
3064 3064
 
3065 3065
 			$option = str_replace('-', '_', $option);
3066 3066
 
3067
-			switch ( $map_option ) {
3068
-				case $this->_current_page . '_' .  $this->_current_view . '_per_page':
3067
+			switch ($map_option) {
3068
+				case $this->_current_page.'_'.$this->_current_view.'_per_page':
3069 3069
 					$value = (int) $value;
3070
-					if ( $value < 1 || $value > 999 )
3070
+					if ($value < 1 || $value > 999)
3071 3071
 						return;
3072 3072
 					break;
3073 3073
 				default:
3074
-					$value = apply_filters( 'FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value );
3075
-					if ( false === $value )
3074
+					$value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3075
+					if (false === $value)
3076 3076
 						return;
3077 3077
 					break;
3078 3078
 			}
3079 3079
 
3080 3080
 			update_user_meta($user->ID, $option, $value);
3081
-			wp_safe_redirect( remove_query_arg( array('pagenum', 'apage', 'paged'), wp_get_referer() ) );
3081
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3082 3082
 			exit;
3083 3083
 		}
3084 3084
 	}
@@ -3089,8 +3089,8 @@  discard block
 block discarded – undo
3089 3089
 	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3090 3090
 	 * @param array $data array that will be assigned to template args.
3091 3091
 	 */
3092
-	public function set_template_args( $data ) {
3093
-		$this->_template_args = array_merge( $this->_template_args, (array) $data );
3092
+	public function set_template_args($data) {
3093
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3094 3094
 	}
3095 3095
 
3096 3096
 
@@ -3106,26 +3106,26 @@  discard block
 block discarded – undo
3106 3106
 	 * @param bool $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3107 3107
 	 * @return void
3108 3108
 	 */
3109
-	protected function _add_transient( $route, $data, $notices = FALSE, $skip_route_verify = FALSE ) {
3109
+	protected function _add_transient($route, $data, $notices = FALSE, $skip_route_verify = FALSE) {
3110 3110
 		$user_id = get_current_user_id();
3111 3111
 
3112
-		if ( !$skip_route_verify )
3112
+		if ( ! $skip_route_verify)
3113 3113
 			$this->_verify_route($route);
3114 3114
 
3115 3115
 
3116 3116
 		//now let's set the string for what kind of transient we're setting
3117
-		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3118
-		$data = $notices ? array( 'notices' => $data ) : $data;
3117
+		$transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3118
+		$data = $notices ? array('notices' => $data) : $data;
3119 3119
 		//is there already a transient for this route?  If there is then let's ADD to that transient
3120
-		$existing = is_multisite() && is_network_admin() ? get_site_transient( $transient ) : get_transient( $transient );
3121
-		if ( $existing ) {
3122
-			$data = array_merge( (array) $data, (array) $existing );
3120
+		$existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3121
+		if ($existing) {
3122
+			$data = array_merge((array) $data, (array) $existing);
3123 3123
 		}
3124 3124
 
3125
-		if ( is_multisite() && is_network_admin() ) {
3126
-			set_site_transient( $transient, $data, 8 );
3125
+		if (is_multisite() && is_network_admin()) {
3126
+			set_site_transient($transient, $data, 8);
3127 3127
 		} else {
3128
-			set_transient( $transient, $data, 8 );
3128
+			set_transient($transient, $data, 8);
3129 3129
 		}
3130 3130
 	}
3131 3131
 
@@ -3137,18 +3137,18 @@  discard block
 block discarded – undo
3137 3137
 	 * @param bool $notices true we get notices transient. False we just return normal route transient
3138 3138
 	 * @return mixed data
3139 3139
 	 */
3140
-	protected function _get_transient( $notices = FALSE, $route = FALSE ) {
3140
+	protected function _get_transient($notices = FALSE, $route = FALSE) {
3141 3141
 		$user_id = get_current_user_id();
3142
-		$route = !$route ? $this->_req_action : $route;
3143
-		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3144
-		$data = is_multisite() && is_network_admin() ? get_site_transient( $transient ) : get_transient( $transient );
3142
+		$route = ! $route ? $this->_req_action : $route;
3143
+		$transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3144
+		$data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3145 3145
 		//delete transient after retrieval (just in case it hasn't expired);
3146
-		if ( is_multisite() && is_network_admin() ) {
3147
-			delete_site_transient( $transient );
3146
+		if (is_multisite() && is_network_admin()) {
3147
+			delete_site_transient($transient);
3148 3148
 		} else {
3149
-			delete_transient( $transient );
3149
+			delete_transient($transient);
3150 3150
 		}
3151
-		return $notices && isset( $data['notices'] ) ? $data['notices'] : $data;
3151
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3152 3152
 	}
3153 3153
 
3154 3154
 
@@ -3165,12 +3165,12 @@  discard block
 block discarded – undo
3165 3165
 
3166 3166
 		//retrieve all existing transients
3167 3167
 		$query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3168
-		if ( $results = $wpdb->get_results( $query ) ) {
3169
-			foreach ( $results as $result ) {
3170
-				$transient = str_replace( '_transient_', '', $result->option_name );
3171
-				get_transient( $transient );
3172
-				if ( is_multisite() && is_network_admin() ) {
3173
-					get_site_transient( $transient );
3168
+		if ($results = $wpdb->get_results($query)) {
3169
+			foreach ($results as $result) {
3170
+				$transient = str_replace('_transient_', '', $result->option_name);
3171
+				get_transient($transient);
3172
+				if (is_multisite() && is_network_admin()) {
3173
+					get_site_transient($transient);
3174 3174
 				}
3175 3175
 			}
3176 3176
 		}
@@ -3294,23 +3294,23 @@  discard block
 block discarded – undo
3294 3294
 	 * @param string $line	line no where error occurred
3295 3295
 	 * @return boolean
3296 3296
 	 */
3297
-	protected function _update_espresso_configuration( $tab, $config, $file = '', $func = '', $line = '' ) {
3297
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '') {
3298 3298
 
3299 3299
 		//remove any options that are NOT going to be saved with the config settings.
3300
-		if ( isset( $config->core->ee_ueip_optin ) ) {
3300
+		if (isset($config->core->ee_ueip_optin)) {
3301 3301
 			$config->core->ee_ueip_has_notified = TRUE;
3302 3302
 			// TODO: remove the following two lines and make sure values are migrated from 3.1
3303
-			update_option( 'ee_ueip_optin', $config->core->ee_ueip_optin);
3304
-			update_option( 'ee_ueip_has_notified', TRUE );
3303
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3304
+			update_option('ee_ueip_has_notified', TRUE);
3305 3305
 		}
3306 3306
 		// and save it (note we're also doing the network save here)
3307
-		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config( FALSE, FALSE ) : TRUE;
3308
-		$config_saved = EE_Config::instance()->update_espresso_config( FALSE, FALSE );
3309
-		if ( $config_saved && $net_saved ) {
3310
-			EE_Error::add_success( sprintf( __('"%s" have been successfully updated.', 'event_espresso'), $tab ));
3307
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(FALSE, FALSE) : TRUE;
3308
+		$config_saved = EE_Config::instance()->update_espresso_config(FALSE, FALSE);
3309
+		if ($config_saved && $net_saved) {
3310
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3311 3311
 			return TRUE;
3312 3312
 		} else {
3313
-			EE_Error::add_error( sprintf( __('The "%s" were not updated.', 'event_espresso'), $tab ), $file, $func, $line  );
3313
+			EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3314 3314
 			return FALSE;
3315 3315
 		}
3316 3316
 	}
@@ -3323,7 +3323,7 @@  discard block
 block discarded – undo
3323 3323
 	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3324 3324
 	 * @return array
3325 3325
 	 */
3326
-	public function get_yes_no_values(){
3326
+	public function get_yes_no_values() {
3327 3327
 		return $this->_yes_no_values;
3328 3328
 	}
3329 3329
 
@@ -3345,8 +3345,8 @@  discard block
 block discarded – undo
3345 3345
 	 *
3346 3346
 	 * @return string
3347 3347
 	 */
3348
-	protected function _next_link( $url, $class = 'dashicons dashicons-arrow-right' ) {
3349
-		return '<a class="' . $class . '" href="' . $url . '"></a>';
3348
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right') {
3349
+		return '<a class="'.$class.'" href="'.$url.'"></a>';
3350 3350
 	}
3351 3351
 
3352 3352
 
@@ -3360,8 +3360,8 @@  discard block
 block discarded – undo
3360 3360
 	 *
3361 3361
 	 * @return string
3362 3362
 	 */
3363
-	protected function _previous_link( $url, $class = 'dashicons dashicons-arrow-left' ) {
3364
-		return '<a class="' . $class . '" href="' . $url . '"></a>';
3363
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left') {
3364
+		return '<a class="'.$class.'" href="'.$url.'"></a>';
3365 3365
 	}
3366 3366
 
3367 3367
 
@@ -3380,8 +3380,8 @@  discard block
 block discarded – undo
3380 3380
 	 * @return bool success/fail
3381 3381
 	 */
3382 3382
 	protected function _process_resend_registration() {
3383
-		$this->_template_args['success'] = EED_Messages::process_resend( $this->_req_data );
3384
-		do_action( 'AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data );
3383
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3384
+		do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3385 3385
 		return $this->_template_args['success'];
3386 3386
 	}
3387 3387
 
@@ -3394,9 +3394,9 @@  discard block
 block discarded – undo
3394 3394
 	 * @param \EE_Payment $payment
3395 3395
 	 * @return bool success/fail
3396 3396
 	 */
3397
-	protected function _process_payment_notification( EE_Payment $payment ) {
3398
-		add_filter( 'FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true' );
3399
-		$success = apply_filters( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', FALSE, $payment );
3397
+	protected function _process_payment_notification(EE_Payment $payment) {
3398
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3399
+		$success = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', FALSE, $payment);
3400 3400
 		$this->_template_args['success'] = $success;
3401 3401
 		return $success;
3402 3402
 	}
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Spacing   +284 added lines, -285 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 
41 41
 
42 42
 
43
-	public function __construct( $routing = TRUE ) {
44
-		parent::__construct( $routing );
43
+	public function __construct($routing = TRUE) {
44
+		parent::__construct($routing);
45 45
 	}
46 46
 
47 47
 
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 
58 58
 
59 59
 	protected function _ajax_hooks() {
60
-		add_action('wp_ajax_espresso_display_country_settings', array( $this, 'display_country_settings'));
61
-		add_action('wp_ajax_espresso_display_country_states', array( $this, 'display_country_states'));
62
-		add_action('wp_ajax_espresso_delete_state', array( $this, 'delete_state'), 10, 3 );
63
-		add_action('wp_ajax_espresso_add_new_state', array( $this, 'add_new_state'));
60
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
61
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
62
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
63
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
64 64
 	}
65 65
 
66 66
 
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 					'label' => __('Critical Pages', 'event_espresso'),
154 154
 					'order' => 50
155 155
 					),
156
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
156
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
157 157
                			'help_tabs' => array(
158 158
 					'general_settings_critical_pages_help_tab' => array(
159 159
 						'title' => __('Critical Pages', 'event_espresso'),
160 160
 						'filename' => 'general_settings_critical_pages'
161 161
 						)
162 162
 					),
163
-				'help_tour' => array( 'Critical_Pages_Help_Tour' ),
163
+				'help_tour' => array('Critical_Pages_Help_Tour'),
164 164
 				'require_nonce' => FALSE
165 165
 				),
166 166
 			'default' => array(
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 						'filename' => 'general_settings_your_organization'
175 175
 						)
176 176
 					),
177
-				'help_tour' => array( 'Your_Organization_Help_Tour' ),
178
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
177
+				'help_tour' => array('Your_Organization_Help_Tour'),
178
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
179 179
 				'require_nonce' => FALSE
180 180
 				),
181 181
 			'admin_option_settings' => array(
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 					'label' => __('Admin Options', 'event_espresso'),
184 184
 					'order' => 60
185 185
 					),
186
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
186
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
187 187
                 			'help_tabs' => array(
188 188
 					'general_settings_admin_options_help_tab' => array(
189 189
 						'title' => __('Admin Options', 'event_espresso'),
190 190
 						'filename' => 'general_settings_admin_options'
191 191
 						)
192 192
 					),
193
-				'help_tour' => array( 'Admin_Options_Help_Tour' ),
193
+				'help_tour' => array('Admin_Options_Help_Tour'),
194 194
 				'require_nonce' => FALSE
195 195
 				),
196 196
 			'country_settings' => array(
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 						'filename' => 'general_settings_countries'
205 205
 						)
206 206
 					),
207
-				'help_tour' => array( 'Countries_Help_Tour' ),
207
+				'help_tour' => array('Countries_Help_Tour'),
208 208
 				'require_nonce' => FALSE
209 209
 				)
210 210
 			);
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 	}
223 223
 
224 224
 	public function admin_init() {
225
-		EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = __( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' );
226
-		EE_Registry::$i18n_js_strings[ 'error_occurred' ] = __( 'An error occurred! Please refresh the page and try again.', 'event_espresso' );
227
-		EE_Registry::$i18n_js_strings[ 'confirm_delete_state' ] = __( 'Are you sure you want to delete this State / Province?', 'event_espresso' );
228
-		$protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://';
229
-		EE_Registry::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php?page=espresso_general_settings', $protocol );
225
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso');
226
+		EE_Registry::$i18n_js_strings['error_occurred'] = __('An error occurred! Please refresh the page and try again.', 'event_espresso');
227
+		EE_Registry::$i18n_js_strings['confirm_delete_state'] = __('Are you sure you want to delete this State / Province?', 'event_espresso');
228
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
229
+		EE_Registry::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php?page=espresso_general_settings', $protocol);
230 230
 	}
231 231
 
232 232
 	public function admin_notices() {}
@@ -239,21 +239,21 @@  discard block
 block discarded – undo
239 239
 		//scripts
240 240
 		wp_enqueue_script('media-upload');
241 241
 		wp_enqueue_script('thickbox');
242
-		wp_register_script( 'organization_settings', GEN_SET_ASSETS_URL . 'your_organization_settings.js', array( 'jquery','media-upload','thickbox' ), EVENT_ESPRESSO_VERSION, TRUE );
243
-		wp_register_style( 'organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION );
244
-		wp_enqueue_script( 'organization_settings' );
245
-		wp_enqueue_style( 'organization-css' );
246
-		$confirm_image_delete = array( 'text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.', 'event_espresso'));
247
-		wp_localize_script( 'organization_settings', 'confirm_image_delete', $confirm_image_delete );
242
+		wp_register_script('organization_settings', GEN_SET_ASSETS_URL.'your_organization_settings.js', array('jquery', 'media-upload', 'thickbox'), EVENT_ESPRESSO_VERSION, TRUE);
243
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
244
+		wp_enqueue_script('organization_settings');
245
+		wp_enqueue_style('organization-css');
246
+		$confirm_image_delete = array('text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.', 'event_espresso'));
247
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
248 248
 
249 249
 	}
250 250
 
251 251
 	public function load_scripts_styles_country_settings() {
252 252
 		//scripts
253
-		wp_register_script( 'gen_settings_countries', GEN_SET_ASSETS_URL . 'gen_settings_countries.js', array( 'ee_admin_js' ), EVENT_ESPRESSO_VERSION, TRUE );
254
-		wp_register_style( 'organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION );
255
-		wp_enqueue_script( 'gen_settings_countries' );
256
-		wp_enqueue_style( 'organization-css' );
253
+		wp_register_script('gen_settings_countries', GEN_SET_ASSETS_URL.'gen_settings_countries.js', array('ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
254
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
255
+		wp_enqueue_script('gen_settings_countries');
256
+		wp_enqueue_style('organization-css');
257 257
 
258 258
 	}
259 259
 
@@ -265,37 +265,37 @@  discard block
 block discarded – undo
265 265
 
266 266
 		// Check to make sure all of the main pages are setup properly,
267 267
 		// if not create the default pages and display an admin notice
268
-		EE_Registry::instance()->load_helper( 'Activation' );
268
+		EE_Registry::instance()->load_helper('Activation');
269 269
 		EEH_Activation::verify_default_pages_exist();
270 270
 
271 271
 		$this->_transient_garbage_collection();
272 272
 		$this->_template_args['values'] = $this->_yes_no_values;
273 273
 
274
-		$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id ) ?EE_Registry::instance()->CFG->core->reg_page_id : NULL;
275
-		$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id ) ? get_page(EE_Registry::instance()->CFG->core->reg_page_id ) : FALSE;
274
+		$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) ?EE_Registry::instance()->CFG->core->reg_page_id : NULL;
275
+		$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) : FALSE;
276 276
 
277 277
 		$this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) ?EE_Registry::instance()->CFG->core->txn_page_id : NULL;
278
-		$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id ) ? get_page(EE_Registry::instance()->CFG->core->txn_page_id ) : FALSE;
278
+		$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) : FALSE;
279 279
 
280
-		$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id ) ?EE_Registry::instance()->CFG->core->thank_you_page_id : NULL;
281
-		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id ) ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id ) : FALSE;
280
+		$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) ?EE_Registry::instance()->CFG->core->thank_you_page_id : NULL;
281
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) : FALSE;
282 282
 
283
-		$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id ) ?EE_Registry::instance()->CFG->core->cancel_page_id : NULL;
284
-		$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id ) ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id ) : FALSE;
283
+		$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) ?EE_Registry::instance()->CFG->core->cancel_page_id : NULL;
284
+		$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) : FALSE;
285 285
 
286
-		$this->_set_add_edit_form_tags( 'update_espresso_page_settings' );
287
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
288
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', $this->_template_args, TRUE );
286
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
287
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
288
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php', $this->_template_args, TRUE);
289 289
 		$this->display_admin_page_with_sidebar();
290 290
 
291 291
 	}
292 292
 
293 293
 	protected function _update_espresso_page_settings() {
294 294
 		// capture incoming request data
295
-		$reg_page_id = isset( $this->_req_data['reg_page_id'] ) ? absint( $this->_req_data['reg_page_id'] ) : EE_Registry::instance()->CFG->core->reg_page_id;
296
-		$txn_page_id = isset( $this->_req_data['txn_page_id'] ) ? absint( $this->_req_data['txn_page_id'] ) : EE_Registry::instance()->CFG->core->txn_page_id;
297
-		$thank_you_page_id = isset( $this->_req_data['thank_you_page_id'] ) ? absint( $this->_req_data['thank_you_page_id'] ) : EE_Registry::instance()->CFG->core->thank_you_page_id;
298
-		$cancel_page_id = isset( $this->_req_data['cancel_page_id'] ) ? absint( $this->_req_data['cancel_page_id'] ) : EE_Registry::instance()->CFG->core->cancel_page_id;
295
+		$reg_page_id = isset($this->_req_data['reg_page_id']) ? absint($this->_req_data['reg_page_id']) : EE_Registry::instance()->CFG->core->reg_page_id;
296
+		$txn_page_id = isset($this->_req_data['txn_page_id']) ? absint($this->_req_data['txn_page_id']) : EE_Registry::instance()->CFG->core->txn_page_id;
297
+		$thank_you_page_id = isset($this->_req_data['thank_you_page_id']) ? absint($this->_req_data['thank_you_page_id']) : EE_Registry::instance()->CFG->core->thank_you_page_id;
298
+		$cancel_page_id = isset($this->_req_data['cancel_page_id']) ? absint($this->_req_data['cancel_page_id']) : EE_Registry::instance()->CFG->core->cancel_page_id;
299 299
 		// pack critical_pages into an array
300 300
 		$critical_pages = array(
301 301
 			'reg_page_id' 				=> $reg_page_id,
@@ -303,17 +303,17 @@  discard block
 block discarded – undo
303 303
 			'thank_you_page_id' 	=> $thank_you_page_id,
304 304
 			'cancel_page_id' 		=> $cancel_page_id
305 305
 		);
306
-		foreach ( $critical_pages as $critical_page_name => $critical_page_id ) {
306
+		foreach ($critical_pages as $critical_page_name => $critical_page_id) {
307 307
 			// has the page changed ?
308
-			if ( EE_Registry::instance()->CFG->core->{$critical_page_name} != $critical_page_id ) {
308
+			if (EE_Registry::instance()->CFG->core->{$critical_page_name} != $critical_page_id) {
309 309
 				// grab post object for old page
310
-				$post = get_post( EE_Registry::instance()->CFG->core->{$critical_page_name} );
310
+				$post = get_post(EE_Registry::instance()->CFG->core->{$critical_page_name} );
311 311
 				// update post shortcodes for old page
312
-				EE_Admin::parse_post_content_on_save( $critical_page_id, $post );
312
+				EE_Admin::parse_post_content_on_save($critical_page_id, $post);
313 313
 				// grab post object for new page
314
-				$post = get_post( $critical_page_id );
314
+				$post = get_post($critical_page_id);
315 315
 				// update post shortcodes for new page
316
-				EE_Admin::parse_post_content_on_save( $critical_page_id, $post );
316
+				EE_Admin::parse_post_content_on_save($critical_page_id, $post);
317 317
 			}
318 318
 		}
319 319
 		// set page IDs
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
 		EE_Registry::instance()->CFG->core->thank_you_page_id = $thank_you_page_id;
323 323
 		EE_Registry::instance()->CFG->core->cancel_page_id = $cancel_page_id;
324 324
 
325
-		EE_Registry::instance()->CFG->core = apply_filters( 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', EE_Registry::instance()->CFG->core, $this->_req_data );
325
+		EE_Registry::instance()->CFG->core = apply_filters('FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', EE_Registry::instance()->CFG->core, $this->_req_data);
326 326
 
327 327
 		$what = __('Critical Pages & Shortcodes', 'event_espresso');
328
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->core, __FILE__, __FUNCTION__, __LINE__ );
328
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->core, __FILE__, __FUNCTION__, __LINE__);
329 329
 		$query_args = array(
330 330
 			'action' => 'critical_pages'
331 331
 			);
332
-		$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
332
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
333 333
 
334 334
 	}
335 335
 
@@ -344,35 +344,35 @@  discard block
 block discarded – undo
344 344
 
345 345
 	protected function _your_organization_settings() {
346 346
 
347
-		$this->_template_args['site_license_key'] = isset( EE_Registry::instance()->NET_CFG->core->site_license_key ) ? EE_Registry::instance()->NET_CFG->core->get_pretty( 'site_license_key' ) : '';
348
-		$this->_template_args['organization_name'] = isset( EE_Registry::instance()->CFG->organization->name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : '';
349
-		$this->_template_args['organization_address_1'] = isset( EE_Registry::instance()->CFG->organization->address_1 ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'address_1' ) : '';
350
-		$this->_template_args['organization_address_2'] = isset( EE_Registry::instance()->CFG->organization->address_2 ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'address_2' ) : '';
351
-		$this->_template_args['organization_city'] = isset( EE_Registry::instance()->CFG->organization->city ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'city' ) : '';
352
-		$this->_template_args['organization_zip'] = isset( EE_Registry::instance()->CFG->organization->zip ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'zip' ) : '';
353
-		$this->_template_args['organization_email'] = isset( EE_Registry::instance()->CFG->organization->email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : '';
354
-		$this->_template_args['organization_phone'] = isset( EE_Registry::instance()->CFG->organization->phone ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'phone' ) : '';
355
-		$this->_template_args['organization_vat'] = isset( EE_Registry::instance()->CFG->organization->vat ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'vat' ) : '';
356
-		$this->_template_args['currency_sign'] = isset( EE_Registry::instance()->CFG->currency->sign ) ? EE_Registry::instance()->CFG->currency->get_pretty( 'sign' ) : '$';
357
-		$this->_template_args['organization_logo_url'] = isset( EE_Registry::instance()->CFG->organization->logo_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ) : FALSE;
358
-		$this->_template_args['organization_facebook'] = isset( EE_Registry::instance()->CFG->organization->facebook ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ) : '';
359
-		$this->_template_args['organization_twitter'] = isset( EE_Registry::instance()->CFG->organization->twitter ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ) : '';
360
-		$this->_template_args['organization_linkedin'] = isset( EE_Registry::instance()->CFG->organization->linkedin ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ) : '';
361
-		$this->_template_args['organization_pinterest'] = isset( EE_Registry::instance()->CFG->organization->pinterest ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ) : '';
362
-		$this->_template_args['organization_google'] = isset( EE_Registry::instance()->CFG->organization->google ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'google' ) : '';
363
-		$this->_template_args['organization_instagram'] = isset( EE_Registry::instance()->CFG->organization->instagram ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ) : '';
347
+		$this->_template_args['site_license_key'] = isset(EE_Registry::instance()->NET_CFG->core->site_license_key) ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') : '';
348
+		$this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : '';
349
+		$this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') : '';
350
+		$this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') : '';
351
+		$this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city) ? EE_Registry::instance()->CFG->organization->get_pretty('city') : '';
352
+		$this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip) ? EE_Registry::instance()->CFG->organization->get_pretty('zip') : '';
353
+		$this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : '';
354
+		$this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone) ? EE_Registry::instance()->CFG->organization->get_pretty('phone') : '';
355
+		$this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat) ? EE_Registry::instance()->CFG->organization->get_pretty('vat') : '';
356
+		$this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign) ? EE_Registry::instance()->CFG->currency->get_pretty('sign') : '$';
357
+		$this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url) ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') : FALSE;
358
+		$this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : '';
359
+		$this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : '';
360
+		$this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin) ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') : '';
361
+		$this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') : '';
362
+		$this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google) ? EE_Registry::instance()->CFG->organization->get_pretty('google') : '';
363
+		$this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') : '';
364 364
 		//UXIP settings
365
-		$this->_template_args['ee_ueip_optin'] = isset( EE_Registry::instance()->CFG->core->ee_ueip_optin ) ? EE_Registry::instance()->CFG->core->get_pretty( 'ee_ueip_optin' ) : TRUE;
365
+		$this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') : TRUE;
366 366
 
367
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
368
-		$STA_ID = isset( EE_Registry::instance()->CFG->organization->STA_ID ) ? EE_Registry::instance()->CFG->organization->STA_ID : 4;
367
+		EE_Registry::instance()->load_helper('Form_Fields');
368
+		$STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID) ? EE_Registry::instance()->CFG->organization->STA_ID : 4;
369 369
 		$this->_template_args['states'] = new EE_Question_Form_Input(
370
-				EE_Question::new_instance ( array(
370
+				EE_Question::new_instance(array(
371 371
 					'QST_ID'=> 0,
372 372
 					'QST_display_text'=> __('State/Province', 'event_espresso'),
373 373
 					'QST_system'=>'admin-state'
374 374
 				)),
375
-				EE_Answer::new_instance ( array(
375
+				EE_Answer::new_instance(array(
376 376
 					'ANS_ID' => 0,
377 377
 					'ANS_value' => $STA_ID
378 378
 				)),
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
 				)
385 385
 			);
386 386
 
387
-		$CNT_ISO = isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
387
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
388 388
 		$this->_template_args['countries'] = new EE_Question_Form_Input(
389
-				EE_Question::new_instance ( array(
389
+				EE_Question::new_instance(array(
390 390
 					'QST_ID'=> 0,
391 391
 					'QST_display_text'=> __('Country', 'event_espresso'),
392 392
 					'QST_system'=>'admin-country'
393 393
 				)),
394
-				EE_Answer::new_instance ( array(
394
+				EE_Answer::new_instance(array(
395 395
 					'ANS_ID' => 0,
396 396
 					'ANS_value' => $CNT_ISO
397 397
 				)),
@@ -403,51 +403,51 @@  discard block
 block discarded – undo
403 403
 				)
404 404
 			);
405 405
 
406
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 );
407
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 );
406
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
407
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
408 408
 
409 409
 		//PUE verification stuff
410
-		$ver_option_key = 'puvererr_' . basename( EE_PLUGIN_BASENAME );
411
-		$verify_fail = get_option( $ver_option_key );
412
-		$this->_template_args['site_license_key_verified'] = $verify_fail || !empty( $verify_fail ) || ( empty( $this->_template_args['site_license_key'] ) && empty( $verify_fail ) )? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
410
+		$ver_option_key = 'puvererr_'.basename(EE_PLUGIN_BASENAME);
411
+		$verify_fail = get_option($ver_option_key);
412
+		$this->_template_args['site_license_key_verified'] = $verify_fail || ! empty($verify_fail) || (empty($this->_template_args['site_license_key']) && empty($verify_fail)) ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
413 413
 
414
-		$this->_set_add_edit_form_tags( 'update_your_organization_settings' );
415
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
416
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', $this->_template_args, TRUE );
414
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
415
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
416
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'your_organization_settings.template.php', $this->_template_args, TRUE);
417 417
 
418 418
 		$this->display_admin_page_with_sidebar();
419 419
 	}
420 420
 
421 421
 	protected function _update_your_organization_settings() {
422
-		if ( is_main_site() )
423
-			EE_Registry::instance()->NET_CFG->core->site_license_key = isset( $this->_req_data['site_license_key'] ) ? sanitize_text_field( $this->_req_data['site_license_key'] ) : EE_Registry::instance()->NET_CFG->core->site_license_key;
424
-		EE_Registry::instance()->CFG->organization->name = isset( $this->_req_data['organization_name'] ) ? sanitize_text_field( $this->_req_data['organization_name'] ) : EE_Registry::instance()->CFG->organization->name;
425
-		EE_Registry::instance()->CFG->organization->address_1 = isset( $this->_req_data['organization_address_1'] ) ? sanitize_text_field( $this->_req_data['organization_address_1'] ) : EE_Registry::instance()->CFG->organization->address_1;
426
-		EE_Registry::instance()->CFG->organization->address_2 = isset( $this->_req_data['organization_address_2'] ) ? sanitize_text_field( $this->_req_data['organization_address_2'] ) : EE_Registry::instance()->CFG->organization->address_2;
427
-		EE_Registry::instance()->CFG->organization->city = isset( $this->_req_data['organization_city'] ) ? sanitize_text_field( $this->_req_data['organization_city'] ) : EE_Registry::instance()->CFG->organization->city;
428
-		EE_Registry::instance()->CFG->organization->STA_ID = isset( $this->_req_data['organization_state'] ) ? absint( $this->_req_data['organization_state'] ) : EE_Registry::instance()->CFG->organization->STA_ID;
429
-		EE_Registry::instance()->CFG->organization->CNT_ISO = isset( $this->_req_data['organization_country'] ) ? sanitize_text_field( $this->_req_data['organization_country'] ) : EE_Registry::instance()->CFG->organization->CNT_ISO;
430
-		EE_Registry::instance()->CFG->organization->zip = isset( $this->_req_data['organization_zip'] ) ? sanitize_text_field( $this->_req_data['organization_zip'] ) : EE_Registry::instance()->CFG->organization->zip;
431
-		EE_Registry::instance()->CFG->organization->email = isset( $this->_req_data['organization_email'] ) ? sanitize_email( $this->_req_data['organization_email'] ) : EE_Registry::instance()->CFG->organization->email;
432
-		EE_Registry::instance()->CFG->organization->vat = isset( $this->_req_data['organization_vat'] ) ? sanitize_text_field( $this->_req_data['organization_vat'] ) : EE_Registry::instance()->CFG->organization->vat;
433
-		EE_Registry::instance()->CFG->organization->phone = isset( $this->_req_data['organization_phone'] ) ? sanitize_text_field( $this->_req_data['organization_phone'] ) : EE_Registry::instance()->CFG->organization->phone;
434
-		EE_Registry::instance()->CFG->organization->logo_url = isset( $this->_req_data['organization_logo_url'] ) ? esc_url_raw( $this->_req_data['organization_logo_url'] ) : EE_Registry::instance()->CFG->organization->logo_url;
435
-		EE_Registry::instance()->CFG->organization->facebook = isset( $this->_req_data['organization_facebook'] ) ? esc_url_raw( $this->_req_data['organization_facebook'] ) : EE_Registry::instance()->CFG->organization->facebook;
436
-		EE_Registry::instance()->CFG->organization->twitter = isset( $this->_req_data['organization_twitter'] ) ? esc_url_raw( $this->_req_data['organization_twitter'] ) : EE_Registry::instance()->CFG->organization->twitter;
437
-		EE_Registry::instance()->CFG->organization->linkedin = isset( $this->_req_data['organization_linkedin'] ) ? esc_url_raw( $this->_req_data['organization_linkedin'] ) : EE_Registry::instance()->CFG->organization->linkedin;
438
-		EE_Registry::instance()->CFG->organization->pinterest = isset( $this->_req_data['organization_pinterest'] ) ? esc_url_raw( $this->_req_data['organization_pinterest'] ) : EE_Registry::instance()->CFG->organization->pinterest;
439
-		EE_Registry::instance()->CFG->organization->google = isset( $this->_req_data['organization_google'] ) ? esc_url_raw( $this->_req_data['organization_google'] ) : EE_Registry::instance()->CFG->organization->google;
440
-		EE_Registry::instance()->CFG->organization->instagram = isset( $this->_req_data['organization_instagram'] ) ? esc_url_raw( $this->_req_data['organization_instagram'] ) : EE_Registry::instance()->CFG->organization->instagram;
441
-		EE_Registry::instance()->CFG->core->ee_ueip_optin = isset( $this->_req_data['ueip_optin'] ) && !empty( $this->_req_data['ueip_optin'] ) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin;
442
-
443
-		EE_Registry::instance()->CFG->currency = new EE_Currency_Config( EE_Registry::instance()->CFG->organization->CNT_ISO );
444
-
445
-		EE_Registry::instance()->CFG = apply_filters( 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', EE_Registry::instance()->CFG );
422
+		if (is_main_site())
423
+			EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) ? sanitize_text_field($this->_req_data['site_license_key']) : EE_Registry::instance()->NET_CFG->core->site_license_key;
424
+		EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name']) ? sanitize_text_field($this->_req_data['organization_name']) : EE_Registry::instance()->CFG->organization->name;
425
+		EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) ? sanitize_text_field($this->_req_data['organization_address_1']) : EE_Registry::instance()->CFG->organization->address_1;
426
+		EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) ? sanitize_text_field($this->_req_data['organization_address_2']) : EE_Registry::instance()->CFG->organization->address_2;
427
+		EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city']) ? sanitize_text_field($this->_req_data['organization_city']) : EE_Registry::instance()->CFG->organization->city;
428
+		EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state']) ? absint($this->_req_data['organization_state']) : EE_Registry::instance()->CFG->organization->STA_ID;
429
+		EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country']) ? sanitize_text_field($this->_req_data['organization_country']) : EE_Registry::instance()->CFG->organization->CNT_ISO;
430
+		EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip']) ? sanitize_text_field($this->_req_data['organization_zip']) : EE_Registry::instance()->CFG->organization->zip;
431
+		EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email']) ? sanitize_email($this->_req_data['organization_email']) : EE_Registry::instance()->CFG->organization->email;
432
+		EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat']) ? sanitize_text_field($this->_req_data['organization_vat']) : EE_Registry::instance()->CFG->organization->vat;
433
+		EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone']) ? sanitize_text_field($this->_req_data['organization_phone']) : EE_Registry::instance()->CFG->organization->phone;
434
+		EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url']) ? esc_url_raw($this->_req_data['organization_logo_url']) : EE_Registry::instance()->CFG->organization->logo_url;
435
+		EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook']) ? esc_url_raw($this->_req_data['organization_facebook']) : EE_Registry::instance()->CFG->organization->facebook;
436
+		EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter']) ? esc_url_raw($this->_req_data['organization_twitter']) : EE_Registry::instance()->CFG->organization->twitter;
437
+		EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin']) ? esc_url_raw($this->_req_data['organization_linkedin']) : EE_Registry::instance()->CFG->organization->linkedin;
438
+		EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) ? esc_url_raw($this->_req_data['organization_pinterest']) : EE_Registry::instance()->CFG->organization->pinterest;
439
+		EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google']) ? esc_url_raw($this->_req_data['organization_google']) : EE_Registry::instance()->CFG->organization->google;
440
+		EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) ? esc_url_raw($this->_req_data['organization_instagram']) : EE_Registry::instance()->CFG->organization->instagram;
441
+		EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin']) && ! empty($this->_req_data['ueip_optin']) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin;
442
+
443
+		EE_Registry::instance()->CFG->currency = new EE_Currency_Config(EE_Registry::instance()->CFG->organization->CNT_ISO);
444
+
445
+		EE_Registry::instance()->CFG = apply_filters('FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', EE_Registry::instance()->CFG);
446 446
 
447 447
 		$what = 'Your Organization Settings';
448
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
448
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
449 449
 
450
-		$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'default' ) );
450
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
451 451
 
452 452
 	}
453 453
 
@@ -458,36 +458,36 @@  discard block
 block discarded – undo
458 458
 	protected function _admin_option_settings() {
459 459
 
460 460
 		$this->_template_args['values'] = $this->_yes_no_values;
461
-		$this->_template_args['use_personnel_manager'] = isset( EE_Registry::instance()->CFG->admin->use_personnel_manager ) ? absint( EE_Registry::instance()->CFG->admin->use_personnel_manager ) : FALSE;
462
-		$this->_template_args['use_dashboard_widget'] = isset( EE_Registry::instance()->CFG->admin->use_dashboard_widget ) ? absint( EE_Registry::instance()->CFG->admin->use_dashboard_widget ) : TRUE;
463
-		$this->_template_args['events_in_dashboard'] = isset( EE_Registry::instance()->CFG->admin->events_in_dashboard ) ? absint( EE_Registry::instance()->CFG->admin->events_in_dashboard ) : 30;
464
-		$this->_template_args['use_event_timezones'] = isset( EE_Registry::instance()->CFG->admin->use_event_timezones ) ? absint( EE_Registry::instance()->CFG->admin->use_event_timezones ) : FALSE;
465
-		$this->_template_args['show_reg_footer'] = isset( EE_Registry::instance()->CFG->admin->show_reg_footer ) ? absint( EE_Registry::instance()->CFG->admin->show_reg_footer ) : TRUE;
466
-		$this->_template_args['affiliate_id'] = isset( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->get_pretty('affiliate_id') : '';
467
-		$this->_template_args['help_tour_activation'] = isset( EE_Registry::instance()->CFG->admin->help_tour_activation ) ? absint( EE_Registry::instance()->CFG->admin->help_tour_activation ): 1;
468
-
469
-		$this->_set_add_edit_form_tags( 'update_admin_option_settings' );
470
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
461
+		$this->_template_args['use_personnel_manager'] = isset(EE_Registry::instance()->CFG->admin->use_personnel_manager) ? absint(EE_Registry::instance()->CFG->admin->use_personnel_manager) : FALSE;
462
+		$this->_template_args['use_dashboard_widget'] = isset(EE_Registry::instance()->CFG->admin->use_dashboard_widget) ? absint(EE_Registry::instance()->CFG->admin->use_dashboard_widget) : TRUE;
463
+		$this->_template_args['events_in_dashboard'] = isset(EE_Registry::instance()->CFG->admin->events_in_dashboard) ? absint(EE_Registry::instance()->CFG->admin->events_in_dashboard) : 30;
464
+		$this->_template_args['use_event_timezones'] = isset(EE_Registry::instance()->CFG->admin->use_event_timezones) ? absint(EE_Registry::instance()->CFG->admin->use_event_timezones) : FALSE;
465
+		$this->_template_args['show_reg_footer'] = isset(EE_Registry::instance()->CFG->admin->show_reg_footer) ? absint(EE_Registry::instance()->CFG->admin->show_reg_footer) : TRUE;
466
+		$this->_template_args['affiliate_id'] = isset(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->get_pretty('affiliate_id') : '';
467
+		$this->_template_args['help_tour_activation'] = isset(EE_Registry::instance()->CFG->admin->help_tour_activation) ? absint(EE_Registry::instance()->CFG->admin->help_tour_activation) : 1;
468
+
469
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
470
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
471 471
 		$this->_template_args['template_args'] = $this->_template_args;
472
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'admin_option_settings.template.php', $this->_template_args, TRUE );
472
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'admin_option_settings.template.php', $this->_template_args, TRUE);
473 473
 		$this->display_admin_page_with_sidebar();
474 474
 	}
475 475
 
476 476
 	protected function _update_admin_option_settings() {
477
-		EE_Registry::instance()->CFG->admin->use_personnel_manager = isset( $this->_req_data['use_personnel_manager'] ) ? absint( $this->_req_data['use_personnel_manager'] ) : EE_Registry::instance()->CFG->admin->use_personnel_manager;
478
-		EE_Registry::instance()->CFG->admin->use_dashboard_widget = isset( $this->_req_data['use_dashboard_widget'] ) ? absint( $this->_req_data['use_dashboard_widget'] ) : EE_Registry::instance()->CFG->admin->use_dashboard_widget;
479
-		EE_Registry::instance()->CFG->admin->events_in_dashboard = isset( $this->_req_data['events_in_dashboard'] ) ? absint( $this->_req_data['events_in_dashboard'] ) : EE_Registry::instance()->CFG->admin->events_in_dashboard;
480
-		EE_Registry::instance()->CFG->admin->use_event_timezones = isset( $this->_req_data['use_event_timezones'] ) ? absint( $this->_req_data['use_event_timezones'] ) : EE_Registry::instance()->CFG->admin->use_event_timezones;
481
-		EE_Registry::instance()->CFG->admin->show_reg_footer = isset( $this->_req_data['show_reg_footer'] ) ? absint( $this->_req_data['show_reg_footer'] ) : EE_Registry::instance()->CFG->admin->show_reg_footer;
482
-		EE_Registry::instance()->CFG->admin->affiliate_id = isset( $this->_req_data['affiliate_id'] ) ? sanitize_text_field( $this->_req_data['affiliate_id'] ) : EE_Registry::instance()->CFG->admin->affiliate_id;
483
-		EE_Registry::instance()->CFG->admin->help_tour_activation = isset( $this->_req_data['help_tour_activation'] ) ? absint( $this->_req_data['help_tour_activation'] ) : EE_Registry::instance()->CFG->admin->help_tour_activation;
477
+		EE_Registry::instance()->CFG->admin->use_personnel_manager = isset($this->_req_data['use_personnel_manager']) ? absint($this->_req_data['use_personnel_manager']) : EE_Registry::instance()->CFG->admin->use_personnel_manager;
478
+		EE_Registry::instance()->CFG->admin->use_dashboard_widget = isset($this->_req_data['use_dashboard_widget']) ? absint($this->_req_data['use_dashboard_widget']) : EE_Registry::instance()->CFG->admin->use_dashboard_widget;
479
+		EE_Registry::instance()->CFG->admin->events_in_dashboard = isset($this->_req_data['events_in_dashboard']) ? absint($this->_req_data['events_in_dashboard']) : EE_Registry::instance()->CFG->admin->events_in_dashboard;
480
+		EE_Registry::instance()->CFG->admin->use_event_timezones = isset($this->_req_data['use_event_timezones']) ? absint($this->_req_data['use_event_timezones']) : EE_Registry::instance()->CFG->admin->use_event_timezones;
481
+		EE_Registry::instance()->CFG->admin->show_reg_footer = isset($this->_req_data['show_reg_footer']) ? absint($this->_req_data['show_reg_footer']) : EE_Registry::instance()->CFG->admin->show_reg_footer;
482
+		EE_Registry::instance()->CFG->admin->affiliate_id = isset($this->_req_data['affiliate_id']) ? sanitize_text_field($this->_req_data['affiliate_id']) : EE_Registry::instance()->CFG->admin->affiliate_id;
483
+		EE_Registry::instance()->CFG->admin->help_tour_activation = isset($this->_req_data['help_tour_activation']) ? absint($this->_req_data['help_tour_activation']) : EE_Registry::instance()->CFG->admin->help_tour_activation;
484 484
 
485
-		EE_Registry::instance()->CFG->admin = apply_filters( 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', EE_Registry::instance()->CFG->admin );
485
+		EE_Registry::instance()->CFG->admin = apply_filters('FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', EE_Registry::instance()->CFG->admin);
486 486
 
487 487
 		$what = 'Admin Options';
488
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->admin, __FILE__, __FUNCTION__, __LINE__ );
489
-		$success = apply_filters( 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', $success );
490
-		$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'admin_option_settings' ) );
488
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->admin, __FILE__, __FUNCTION__, __LINE__);
489
+		$success = apply_filters('FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', $success);
490
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'admin_option_settings'));
491 491
 
492 492
 	}
493 493
 
@@ -500,21 +500,21 @@  discard block
 block discarded – undo
500 500
 
501 501
 	protected function _country_settings() {
502 502
 
503
-		$CNT_ISO = isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
504
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : $CNT_ISO;
503
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
504
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
505 505
 
506 506
 		//load field generator helper
507
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
507
+		EE_Registry::instance()->load_helper('Form_Fields');
508 508
 
509 509
 		$this->_template_args['values'] = $this->_yes_no_values;
510 510
 
511 511
 		$this->_template_args['countries'] = new EE_Question_Form_Input(
512
-				EE_Question::new_instance ( array(
512
+				EE_Question::new_instance(array(
513 513
 					'QST_ID'=> 0,
514 514
 					'QST_display_text'=> __('Select Country', 'event_espresso'),
515 515
 					'QST_system'=>'admin-country'
516 516
 				)),
517
-				EE_Answer::new_instance ( array(
517
+				EE_Answer::new_instance(array(
518 518
 					'ANS_ID' => 0,
519 519
 					'ANS_value' => $CNT_ISO
520 520
 				)),
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
 			);
528 528
 //		EEH_Debug_Tools::printr( $this->_template_args['countries'], 'countries  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
529 529
 
530
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 );
531
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 );
530
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
531
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
532 532
 		$this->_template_args['country_details_settings'] = $this->display_country_settings();
533 533
 		$this->_template_args['country_states_settings'] = $this->display_country_states();
534 534
 
535
-		$this->_set_add_edit_form_tags( 'update_country_settings' );
536
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
537
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', $this->_template_args, TRUE );
535
+		$this->_set_add_edit_form_tags('update_country_settings');
536
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
537
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'countries_settings.template.php', $this->_template_args, TRUE);
538 538
 		$this->display_admin_page_with_no_sidebar();
539 539
 	}
540 540
 
@@ -547,44 +547,44 @@  discard block
 block discarded – undo
547 547
 	 * 		@param 	string 		$CNT_ISO
548 548
 	 * 		@return 		mixed		string | array
549 549
 	 */
550
-	public function display_country_settings( $CNT_ISO = '' ) {
550
+	public function display_country_settings($CNT_ISO = '') {
551 551
 
552
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : $CNT_ISO;
553
-		if ( ! $CNT_ISO ) {
552
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
553
+		if ( ! $CNT_ISO) {
554 554
 			return '';
555 555
 		}
556 556
 
557 557
 		// for ajax
558
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
559
-		remove_all_filters( 'FHEE__EEH_Form_Fields__label_html' );
560
-		remove_all_filters( 'FHEE__EEH_Form_Fields__input_html' );
561
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 );
562
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 );
563
-		$country = EEM_Country::instance()->get_one_by_ID( $CNT_ISO );
558
+		EE_Registry::instance()->load_helper('Form_Fields');
559
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
560
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
561
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
562
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
563
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
564 564
 		//EEH_Debug_Tools::printr( $country, '$country  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
565 565
 		$country_input_types = array(
566
-			'CNT_active' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE  ),
567
-			'CNT_ISO' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
568
-			'CNT_ISO3' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
569
-			'RGN_ID' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
570
-			'CNT_name' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'regular-text' ),
571
-			'CNT_cur_code' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
572
-			'CNT_cur_single' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'medium-text' ),
573
-			'CNT_cur_plural' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'medium-text' ),
574
-			'CNT_cur_sign' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text', 'htmlentities' => FALSE ),
575
-			'CNT_cur_sign_b4' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE ),
576
-			'CNT_cur_dec_plc' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => 0, 'text' => '' ), array( 'id' => 1, 'text' => '' ), array( 'id' => 2, 'text' => '' ), array( 'id' => 3, 'text' => '' ))),
577
-			'CNT_cur_dec_mrk' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => ',', 'text' => __(', (comma)', 'event_espresso')), array( 'id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE ),
578
-			'CNT_cur_thsnds' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => ',', 'text' => __(', (comma)', 'event_espresso')), array( 'id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE ),
579
-			'CNT_tel_code' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
580
-			'CNT_is_EU' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE  )
566
+			'CNT_active' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE),
567
+			'CNT_ISO' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
568
+			'CNT_ISO3' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
569
+			'RGN_ID' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
570
+			'CNT_name' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'regular-text'),
571
+			'CNT_cur_code' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
572
+			'CNT_cur_single' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'medium-text'),
573
+			'CNT_cur_plural' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'medium-text'),
574
+			'CNT_cur_sign' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text', 'htmlentities' => FALSE),
575
+			'CNT_cur_sign_b4' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE),
576
+			'CNT_cur_dec_plc' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => array(array('id' => 0, 'text' => ''), array('id' => 1, 'text' => ''), array('id' => 2, 'text' => ''), array('id' => 3, 'text' => ''))),
577
+			'CNT_cur_dec_mrk' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => array(array('id' => ',', 'text' => __(', (comma)', 'event_espresso')), array('id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE),
578
+			'CNT_cur_thsnds' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => array(array('id' => ',', 'text' => __(', (comma)', 'event_espresso')), array('id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE),
579
+			'CNT_tel_code' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
580
+			'CNT_is_EU' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE)
581 581
 		);
582
-		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( $country, $country_input_types );
583
-		$country_details_settings = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', $this->_template_args, TRUE );
582
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($country, $country_input_types);
583
+		$country_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php', $this->_template_args, TRUE);
584 584
 
585
-		if ( defined( 'DOING_AJAX' )) {
586
-			$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
587
-			echo json_encode( array( 'return_data' => $country_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors'] ));
585
+		if (defined('DOING_AJAX')) {
586
+			$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
587
+			echo json_encode(array('return_data' => $country_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors']));
588 588
 			die();
589 589
 		} else {
590 590
 			return $country_details_settings;
@@ -602,50 +602,50 @@  discard block
 block discarded – undo
602 602
 	 * 		@param 	string 		$CNT_ISO
603 603
 	 * 		@return 		string
604 604
 	 */
605
-	public function display_country_states( $CNT_ISO = '' ) {
605
+	public function display_country_states($CNT_ISO = '') {
606 606
 
607
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? sanitize_text_field( $this->_req_data['country'] ) : $CNT_ISO;
607
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
608 608
 
609
-		if ( ! $CNT_ISO ) {
609
+		if ( ! $CNT_ISO) {
610 610
 			return '';
611 611
 		}
612 612
 		// for ajax
613
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
614
-		remove_all_filters( 'FHEE__EEH_Form_Fields__label_html' );
615
-		remove_all_filters( 'FHEE__EEH_Form_Fields__input_html' );
616
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'state_form_field_label_wrap' ), 10, 2 );
617
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'state_form_field_input__wrap' ), 10, 2 );
618
-		$states = EEM_State::instance()->get_all_states_for_these_countries( array( $CNT_ISO => $CNT_ISO ));
613
+		EE_Registry::instance()->load_helper('Form_Fields');
614
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
615
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
616
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
617
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
618
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
619 619
 
620 620
 //			echo '<h4>$CNT_ISO : ' . $CNT_ISO . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
621 621
 //			global $wpdb;
622 622
 //			echo '<h4>' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
623 623
 //			EEH_Debug_Tools::printr( $states, '$states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
624
-		if ( $states ) {
625
-			foreach ( $states as $STA_ID => $state ) {
626
-				if ( $state instanceof EE_State ) {
624
+		if ($states) {
625
+			foreach ($states as $STA_ID => $state) {
626
+				if ($state instanceof EE_State) {
627 627
 					//STA_abbrev 	STA_name 	STA_active
628 628
 					$state_input_types = array(
629
-						'STA_abbrev' => array( 'type' => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'mid-text' ),
630
-						'STA_name'   => array( 'type'       => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'regular-text' ),
631
-						'STA_active' => array( 'type' => 'RADIO_BTN', 'input_name' => 'states[' . $STA_ID . ']', 'options' => $this->_yes_no_values, 'use_desc_4_label' => true )
629
+						'STA_abbrev' => array('type' => 'TEXT', 'input_name' => 'states['.$STA_ID.']', 'class' => 'mid-text'),
630
+						'STA_name'   => array('type'       => 'TEXT', 'input_name' => 'states['.$STA_ID.']', 'class' => 'regular-text'),
631
+						'STA_active' => array('type' => 'RADIO_BTN', 'input_name' => 'states['.$STA_ID.']', 'options' => $this->_yes_no_values, 'use_desc_4_label' => true)
632 632
 					);
633
-					$this->_template_args[ 'states' ][ $STA_ID ][ 'inputs' ] = EE_Question_Form_Input::generate_question_form_inputs_for_object( $state, $state_input_types );
634
-					$query_args = array( 'action'     => 'delete_state', 'STA_ID' => $STA_ID, 'CNT_ISO' => $CNT_ISO, 'STA_abbrev' => $state->abbrev() );
635
-					$this->_template_args[ 'states' ][ $STA_ID ][ 'delete_state_url' ] = EE_Admin_Page::add_query_args_and_nonce( $query_args, GEN_SET_ADMIN_URL );
633
+					$this->_template_args['states'][$STA_ID]['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($state, $state_input_types);
634
+					$query_args = array('action'     => 'delete_state', 'STA_ID' => $STA_ID, 'CNT_ISO' => $CNT_ISO, 'STA_abbrev' => $state->abbrev());
635
+					$this->_template_args['states'][$STA_ID]['delete_state_url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, GEN_SET_ADMIN_URL);
636 636
 				}
637 637
 			}
638 638
 		} else {
639 639
 			$this->_template_args['states'] = FALSE;
640 640
 		}
641 641
 //		EEH_Debug_Tools::printr( $this->_template_args['states'], 'states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
642
-		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'add_new_state' ),  GEN_SET_ADMIN_URL );
642
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'add_new_state'), GEN_SET_ADMIN_URL);
643 643
 
644
-		$state_details_settings = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', $this->_template_args, TRUE );
644
+		$state_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php', $this->_template_args, TRUE);
645 645
 
646
-		if ( defined( 'DOING_AJAX' )) {
647
-			$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
648
-			echo json_encode( array( 'return_data' => $state_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors'] ));
646
+		if (defined('DOING_AJAX')) {
647
+			$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
648
+			echo json_encode(array('return_data' => $state_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors']));
649 649
 			die();
650 650
 		} else {
651 651
 			return $state_details_settings;
@@ -666,40 +666,39 @@  discard block
 block discarded – undo
666 666
 
667 667
 		$success = TRUE;
668 668
 
669
-		$CNT_ISO = isset( $this->_req_data['CNT_ISO'] ) ? strtoupper( sanitize_text_field( $this->_req_data['CNT_ISO'] )) : FALSE;
670
-		if ( ! $CNT_ISO ) {
671
-			EE_Error::add_error( __( 'No Country ISO code or an invalid Country ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
669
+		$CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : FALSE;
670
+		if ( ! $CNT_ISO) {
671
+			EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
672 672
 			$success = FALSE;
673 673
 		}
674
-		$STA_abbrev = isset( $this->_req_data['STA_abbrev'] ) ? sanitize_text_field( $this->_req_data['STA_abbrev'] ) : FALSE;
675
-		if ( ! $STA_abbrev ) {
676
-			EE_Error::add_error( __( 'No State ISO code or an invalid State ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
674
+		$STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : FALSE;
675
+		if ( ! $STA_abbrev) {
676
+			EE_Error::add_error(__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
677 677
 			$success = FALSE;
678 678
 		}
679
-		$STA_name = isset( $this->_req_data['STA_name'] ) ?  sanitize_text_field( $this->_req_data['STA_name'] ) :
680
-			FALSE;
681
-		if ( ! $STA_name ) {
682
-			EE_Error::add_error( __( 'No State name or an invalid State name was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
679
+		$STA_name = isset($this->_req_data['STA_name']) ?  sanitize_text_field($this->_req_data['STA_name']) : FALSE;
680
+		if ( ! $STA_name) {
681
+			EE_Error::add_error(__('No State name or an invalid State name was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
683 682
 			$success = FALSE;
684 683
 		}
685 684
 
686
-		if ( $success ) {
685
+		if ($success) {
687 686
 			$cols_n_values = array(
688 687
 				'CNT_ISO' => $CNT_ISO,
689 688
 				'STA_abbrev' => $STA_abbrev,
690 689
 				'STA_name' => $STA_name,
691 690
 				'STA_active' => TRUE
692 691
 			);
693
-			$success = EEM_State::instance()->insert ( $cols_n_values );
694
-			EE_Error::add_success( __( 'The State was added successfully.', 'event_espresso' ) );
692
+			$success = EEM_State::instance()->insert($cols_n_values);
693
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
695 694
 		}
696 695
 
697
-		if ( defined( 'DOING_AJAX' )) {
698
-			$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
699
-			echo json_encode( array_merge( $notices, array( 'return_data' => $CNT_ISO ) ) );
696
+		if (defined('DOING_AJAX')) {
697
+			$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
698
+			echo json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
700 699
 			die();
701 700
 		} else {
702
-			$this->_redirect_after_action( $success, 'State', 'added', array( 'action' => 'country_settings' ) );
701
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
703 702
 		}
704 703
 	}
705 704
 
@@ -712,25 +711,25 @@  discard block
 block discarded – undo
712 711
 	 * 		@return 		boolean | void
713 712
 	 */
714 713
 	public function delete_state() {
715
-		$CNT_ISO = isset( $this->_req_data['CNT_ISO'] ) ? strtoupper( sanitize_text_field( $this->_req_data['CNT_ISO'] )) : FALSE;
716
-		$STA_ID = isset( $this->_req_data['STA_ID'] ) ? sanitize_text_field( $this->_req_data['STA_ID'] ) : FALSE;
717
-		$STA_abbrev = isset( $this->_req_data['STA_abbrev'] ) ? sanitize_text_field( $this->_req_data['STA_abbrev'] ) : FALSE;
718
-		if ( ! $STA_ID ) {
719
-			EE_Error::add_error( __( 'No State ID or an invalid State ID was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
714
+		$CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : FALSE;
715
+		$STA_ID = isset($this->_req_data['STA_ID']) ? sanitize_text_field($this->_req_data['STA_ID']) : FALSE;
716
+		$STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : FALSE;
717
+		if ( ! $STA_ID) {
718
+			EE_Error::add_error(__('No State ID or an invalid State ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
720 719
 			return FALSE;
721 720
 		}
722
-		$success = EEM_State::instance()->delete_by_ID( $STA_ID );
723
-		if ( $success !== FALSE ) {
724
-			do_action( 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID, array( 'STA_abbrev' => $STA_abbrev ));
725
-			EE_Error::add_success( __( 'The State was deleted successfully.', 'event_espresso' ));
721
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
722
+		if ($success !== FALSE) {
723
+			do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID, array('STA_abbrev' => $STA_abbrev));
724
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
726 725
 		}
727
-		if ( defined( 'DOING_AJAX' )) {
728
-			$notices = EE_Error::get_notices( FALSE, FALSE );
726
+		if (defined('DOING_AJAX')) {
727
+			$notices = EE_Error::get_notices(FALSE, FALSE);
729 728
 			$notices['return_data'] = TRUE;
730
-			echo json_encode( $notices );
729
+			echo json_encode($notices);
731 730
 			die();
732 731
 		} else {
733
-			$this->_redirect_after_action( $success, 'State', 'deleted', array( 'action' => 'country_settings' ) );
732
+			$this->_redirect_after_action($success, 'State', 'deleted', array('action' => 'country_settings'));
734 733
 		}
735 734
 	}
736 735
 
@@ -746,63 +745,63 @@  discard block
 block discarded – undo
746 745
 	protected function _update_country_settings() {
747 746
 //		EEH_Debug_Tools::printr( $this->_req_data, '$this->_req_data  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
748 747
 		// grab the country ISO code
749
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : FALSE;
750
-		if ( ! $CNT_ISO ) {
751
-			EE_Error::add_error( __( 'No Country ISO code or an invalid Country ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
748
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : FALSE;
749
+		if ( ! $CNT_ISO) {
750
+			EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
752 751
 			return;
753 752
 		}
754 753
 		$cols_n_values = array();
755
-		$cols_n_values['CNT_ISO3'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'] ) ? strtoupper( sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'] )) : FALSE;
756
-		$cols_n_values['RGN_ID'] = isset( $this->_req_data['cntry'][$CNT_ISO]['RGN_ID'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['RGN_ID'] ) : NULL;
757
-		$cols_n_values['CNT_name'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_name'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_name'] ) : NULL;
758
-		$cols_n_values['CNT_cur_code'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'] ) ? strtoupper( sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'] )) : 'USD';
759
-		$cols_n_values['CNT_cur_single'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'] ) : 'dollar';
760
-		$cols_n_values['CNT_cur_plural'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'] ) : 'dollars';
761
-		$cols_n_values['CNT_cur_sign'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'] ) : '$';
762
-		$cols_n_values['CNT_cur_sign_b4'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'] ) : TRUE;
763
-		$cols_n_values['CNT_cur_dec_plc'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'] ) : 2;
764
-		$cols_n_values['CNT_cur_dec_mrk'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'] ) : '.';
765
-		$cols_n_values['CNT_cur_thsnds'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'] ) : ',';
766
-		$cols_n_values['CNT_tel_code'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'] ) : NULL;
767
-		$cols_n_values['CNT_is_EU'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'] ) : FALSE;
768
-		$cols_n_values['CNT_active'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_active'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_active'] ) : FALSE;
754
+		$cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) : FALSE;
755
+		$cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) : NULL;
756
+		$cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) : NULL;
757
+		$cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) : 'USD';
758
+		$cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) : 'dollar';
759
+		$cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) : 'dollars';
760
+		$cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) : '$';
761
+		$cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) : TRUE;
762
+		$cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) : 2;
763
+		$cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) : '.';
764
+		$cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) : ',';
765
+		$cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) : NULL;
766
+		$cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) : FALSE;
767
+		$cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) : FALSE;
769 768
 		// allow filtering of country data
770
-		$cols_n_values = apply_filters( 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', $cols_n_values );
769
+		$cols_n_values = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', $cols_n_values);
771 770
 		//EEH_Debug_Tools::printr( $cols_n_values, '$cols_n_values  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
772 771
 		// where values
773
-		$where_cols_n_values = array( array( 'CNT_ISO' => $CNT_ISO ));
772
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
774 773
 		// run the update
775
-		$success = EEM_Country::instance()->update( $cols_n_values, $where_cols_n_values );
774
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
776 775
 //		global $wpdb;
777 776
 //		echo '<h4>' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
778 777
 //		echo '<h4>$success : ' . $success . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
779
-		if ( isset( $this->_req_data['states'] ) && is_array( $this->_req_data['states'] ) && $success !== FALSE ) {
778
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== FALSE) {
780 779
 			// allow filtering of states data
781
-			$states = apply_filters( 'FHEE__General_Settings_Admin_Page___update_country_settings__states', $this->_req_data['states'] );
780
+			$states = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__states', $this->_req_data['states']);
782 781
 //			EEH_Debug_Tools::printr( $states, '$states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
783 782
 			// loop thru state data ( looks like : states[75][STA_name] )
784
-			foreach( $states as $STA_ID => $state ) {
783
+			foreach ($states as $STA_ID => $state) {
785 784
 				$cols_n_values = array(
786 785
 					'CNT_ISO' 		=> $CNT_ISO,
787
-					'STA_abbrev' => sanitize_text_field( $state['STA_abbrev'] ),
788
-					'STA_name' 	=> sanitize_text_field( $state['STA_name'] ),
789
-					'STA_active' 	=> (bool)absint( $state['STA_active'] )
786
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
787
+					'STA_name' 	=> sanitize_text_field($state['STA_name']),
788
+					'STA_active' 	=> (bool) absint($state['STA_active'])
790 789
 				);
791 790
 				// where values
792
-				$where_cols_n_values = array( array( 'STA_ID' => $STA_ID ));
791
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
793 792
 				// run the update
794
-				$success = EEM_State::instance()->update( $cols_n_values, $where_cols_n_values );
795
-				if ( $success !== FALSE ) {
796
-					do_action( 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO, $STA_ID, $cols_n_values );
793
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
794
+				if ($success !== FALSE) {
795
+					do_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO, $STA_ID, $cols_n_values);
797 796
 				}
798 797
 			}
799 798
 		}
800 799
 		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
801
-		if ( isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO ) {
802
-			EE_Registry::instance()->CFG->currency = new EE_Currency_Config( $CNT_ISO );
800
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO) {
801
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
803 802
 			EE_Registry::instance()->CFG->update_espresso_config();
804 803
 		}
805
-		$this->_redirect_after_action( $success, 'Countries', 'updated', array( 'action' => 'country_settings', 'country' => $CNT_ISO ));
804
+		$this->_redirect_after_action($success, 'Countries', 'updated', array('action' => 'country_settings', 'country' => $CNT_ISO));
806 805
 	}
807 806
 
808 807
 
@@ -816,11 +815,11 @@  discard block
 block discarded – undo
816 815
 	 * 		@param 		string 		$label
817 816
 	 * 		@return 		string
818 817
 	 */
819
-	public function country_form_field_label_wrap( $label, $required_text ) {
818
+	public function country_form_field_label_wrap($label, $required_text) {
820 819
 		return '
821 820
 			<tr>
822 821
 				<th>
823
-					' . $label  . '
822
+					' . $label.'
824 823
 				</th>';
825 824
 	}
826 825
 
@@ -834,10 +833,10 @@  discard block
 block discarded – undo
834 833
 	 * 		@param 		string 		$label
835 834
 	 * 		@return 		string
836 835
 	 */
837
-	public function country_form_field_input__wrap( $input, $label ) {
836
+	public function country_form_field_input__wrap($input, $label) {
838 837
 		return '
839 838
 				<td class="general-settings-country-input-td">
840
-					' . $input . '
839
+					' . $input.'
841 840
 				</td>
842 841
 			</tr>';
843 842
 	}
@@ -853,7 +852,7 @@  discard block
 block discarded – undo
853 852
 	 * 		@param 		string 		$required_text
854 853
 	 * 		@return 		string
855 854
 	 */
856
-	public function state_form_field_label_wrap( $label, $required_text  ) {
855
+	public function state_form_field_label_wrap($label, $required_text) {
857 856
 		return $required_text;
858 857
 	}
859 858
 
@@ -867,10 +866,10 @@  discard block
 block discarded – undo
867 866
 	 * 		@param 		string 		$label
868 867
 	 * 		@return 		string
869 868
 	 */
870
-	public function state_form_field_input__wrap( $input, $label ) {
869
+	public function state_form_field_input__wrap($input, $label) {
871 870
 		return '
872 871
 				<td class="general-settings-country-state-input-td">
873
-					' . $input . '
872
+					' . $input.'
874 873
 				</td>';
875 874
 
876 875
 	}
@@ -893,10 +892,10 @@  discard block
 block discarded – undo
893 892
 	 * @param int $ee_page_id
894 893
 	 * @return string
895 894
 	 */
896
-	public static function edit_view_links( $ee_page_id ) {
897
-		$links = '<a href="' . add_query_arg( array( 'post' => $ee_page_id, 'action' => 'edit' ),  admin_url( 'post.php' )) . '" >' . __('Edit', 'event_espresso') . '</a>';
895
+	public static function edit_view_links($ee_page_id) {
896
+		$links = '<a href="'.add_query_arg(array('post' => $ee_page_id, 'action' => 'edit'), admin_url('post.php')).'" >'.__('Edit', 'event_espresso').'</a>';
898 897
 		$links .= ' &nbsp;|&nbsp; ';
899
-		$links .= '<a href="' . get_permalink( $ee_page_id ) . '" >' . __('View', 'event_espresso') . '</a>';
898
+		$links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>';
900 899
 		return $links;
901 900
 	}
902 901
 
@@ -909,27 +908,27 @@  discard block
 block discarded – undo
909 908
 	 * @param WP page object $ee_page
910 909
 	 * @return string
911 910
 	 */
912
-	public static function page_and_shortcode_status( $ee_page, $shortcode ) {
911
+	public static function page_and_shortcode_status($ee_page, $shortcode) {
913 912
 
914 913
 		// page status
915
-		if ( isset( $ee_page->post_status ) && $ee_page->post_status == 'publish') {
914
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
916 915
 			$pg_colour = 'green';
917
-			$pg_status = sprintf( __('Page%sStatus%sOK', 'event_espresso'), '&nbsp;' , '&nbsp;' );
916
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
918 917
 		 } else {
919 918
 			$pg_colour = 'red';
920
-			$pg_status = sprintf( __('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;'  );
919
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
921 920
 		}
922 921
 
923 922
 		// shortcode status
924
-		if ( isset( $ee_page->post_content ) && strpos( $ee_page->post_content, $shortcode ) !== FALSE ) {
923
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== FALSE) {
925 924
 			$sc_colour = 'green';
926
-			$sc_status = sprintf( __('Shortcode%sOK', 'event_espresso'), '&nbsp;' );
925
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
927 926
 		 } else {
928 927
 			$sc_colour = 'red';
929
-			$sc_status = sprintf( __('Shortcode%sProblem', 'event_espresso'), '&nbsp;' );
928
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
930 929
 		}
931 930
 
932
-		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' . $pg_status . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
931
+		return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'.$pg_status.'</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
933 932
 
934 933
 	}
935 934
 
@@ -944,20 +943,20 @@  discard block
 block discarded – undo
944 943
 	 * @param unknown_type $level
945 944
 	 * @return unknown
946 945
 	 */
947
-	public static function page_settings_dropdown( $default = 0, $parent = 0, $level = 0 ) {
946
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) {
948 947
 		global $wpdb;
949
-		$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", $parent) );
948
+		$items = $wpdb->get_results($wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", $parent));
950 949
 
951
-		if ( $items ) {
952
-			foreach ( $items as $item ) {
953
-				$pad = str_repeat( '&nbsp;', $level * 3 );
954
-				if ( $item->ID == $default)
950
+		if ($items) {
951
+			foreach ($items as $item) {
952
+				$pad = str_repeat('&nbsp;', $level * 3);
953
+				if ($item->ID == $default)
955 954
 					$current = ' selected="selected"';
956 955
 				else
957 956
 					$current = '';
958 957
 
959
-				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
960
-				parent_dropdown( $default, $item->ID, $level +1 );
958
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad ".esc_html($item->post_title)."</option>";
959
+				parent_dropdown($default, $item->ID, $level + 1);
961 960
 			}
962 961
 		} else {
963 962
 			return false;
Please login to merge, or discard this patch.