Completed
Branch FET-9795-new-interfaces (4c886e)
by
unknown
353:56 queued 340:21
created
core/db_models/EEM_Base.model.php 1 patch
Spacing   +969 added lines, -969 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * Flag indicating whether this model has a primary key or not
244 244
 	 * @var boolean
245 245
 	 */
246
-	protected $_has_primary_key_field=null;
246
+	protected $_has_primary_key_field = null;
247 247
 
248 248
 	/**
249 249
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -305,19 +305,19 @@  discard block
 block discarded – undo
305 305
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
306 306
 	 * @var array
307 307
 	 */
308
-	protected $_between_style_operators = array( 'BETWEEN' );
308
+	protected $_between_style_operators = array('BETWEEN');
309 309
 
310 310
 	/**
311 311
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
312 312
 	 * @var array
313 313
 	 */
314
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
314
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
315 315
 
316 316
 	/**
317 317
 	 * Allowed values for $query_params['order'] for ordering in queries
318 318
 	 * @var array
319 319
 	 */
320
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
320
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
321 321
 
322 322
 	/**
323 323
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
332 332
 	 * @var array
333 333
 	 */
334
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
334
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
335 335
 
336 336
 	/**
337 337
 	 * All the data types that can be used in $wpdb->prepare statements.
338 338
 	 * @var array
339 339
 	 */
340
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
340
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
341 341
 
342 342
 	/**
343 343
 	 * 	EE_Registry Object
@@ -370,17 +370,17 @@  discard block
 block discarded – undo
370 370
 	/**
371 371
 	 * constant used to show EEM_Base has not yet verified the db on this http request
372 372
 	 */
373
-	const db_verified_none 		= 0;
373
+	const db_verified_none = 0;
374 374
 	/**
375 375
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
376 376
 	 * but not the addons' dbs
377 377
 	 */
378
-	const db_verified_core 		= 1;
378
+	const db_verified_core = 1;
379 379
 	/**
380 380
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
381 381
 	 * the EE core db too)
382 382
 	 */
383
-	const db_verified_addons 	= 2;
383
+	const db_verified_addons = 2;
384 384
 
385 385
 	/**
386 386
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 	 * @param null $timezone
412 412
 	 * @throws \EE_Error
413 413
 	 */
414
-	protected function __construct( $timezone = NULL ){
414
+	protected function __construct($timezone = NULL) {
415 415
 		// check that the model has not been loaded too soon
416
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
417
-			throw new EE_Error (
416
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
417
+			throw new EE_Error(
418 418
 				sprintf(
419
-					__( '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' ),
420
-					get_class( $this )
419
+					__('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'),
420
+					get_class($this)
421 421
 				)
422 422
 			);
423 423
 		}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 		/**
426 426
 		 * Set blogid for models to current blog. However we ONLY do this if $_model_query_blog_id is not already set.
427 427
 		 */
428
-		if ( empty( EEM_Base::$_model_query_blog_id ) ) {
428
+		if (empty(EEM_Base::$_model_query_blog_id)) {
429 429
 			EEM_Base::set_model_query_blog_id();
430 430
 		}
431 431
 
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 		 * just use EE_Register_Model_Extension
435 435
 		 * @var EE_Table_Base[] $_tables
436 436
 		 */
437
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
438
-		foreach($this->_tables as $table_alias => $table_obj){
437
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
438
+		foreach ($this->_tables as $table_alias => $table_obj) {
439 439
 			/** @var $table_obj EE_Table_Base */
440 440
 			$table_obj->_construct_finalize_with_alias($table_alias);
441
-			if( $table_obj instanceof EE_Secondary_Table ){
441
+			if ($table_obj instanceof EE_Secondary_Table) {
442 442
 				/** @var $table_obj EE_Secondary_Table */
443 443
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
444 444
 			}
@@ -448,54 +448,54 @@  discard block
 block discarded – undo
448 448
 		 * EE_Register_Model_Extension
449 449
 		 * @param EE_Model_Field_Base[] $_fields
450 450
 		 */
451
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
451
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
452 452
 		$this->_invalidate_field_caches();
453
-		foreach($this->_fields as $table_alias => $fields_for_table){
454
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
455
-				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)));
453
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
454
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
455
+				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)));
456 456
 			}
457
-			foreach($fields_for_table as $field_name => $field_obj){
457
+			foreach ($fields_for_table as $field_name => $field_obj) {
458 458
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
459 459
 				//primary key field base has a slightly different _construct_finalize
460 460
 				/** @var $field_obj EE_Model_Field_Base */
461
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
461
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
462 462
 			}
463 463
 		}
464 464
 
465 465
 		// everything is related to Extra_Meta
466
-		if( get_class($this) !== 'EEM_Extra_Meta'){
466
+		if (get_class($this) !== 'EEM_Extra_Meta') {
467 467
 			//make extra meta related to everything, but don't block deleting things just
468 468
 			//because they have related extra meta info. For now just orphan those extra meta
469 469
 			//in the future we should automatically delete them
470
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
470
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
471 471
 		}
472 472
 		//and change logs
473
-		if( get_class( $this) !==  'EEM_Change_Log' ) {
474
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
473
+		if (get_class($this) !== 'EEM_Change_Log') {
474
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
475 475
 		}
476 476
 		/**
477 477
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
478 478
 		 * EE_Register_Model_Extension
479 479
 		 * @param EE_Model_Relation_Base[] $_model_relations
480 480
 		 */
481
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
482
-		foreach($this->_model_relations as $model_name => $relation_obj){
481
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
482
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
483 483
 			/** @var $relation_obj EE_Model_Relation_Base */
484 484
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
485 485
 		}
486
-		foreach($this->_indexes as $index_name => $index_obj){
486
+		foreach ($this->_indexes as $index_name => $index_obj) {
487 487
 			/** @var $index_obj EE_Index */
488 488
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
489 489
 		}
490 490
 
491 491
 		$this->set_timezone($timezone);
492 492
 		//finalize default where condition strategy, or set default
493
-		if( ! $this->_default_where_conditions_strategy){
493
+		if ( ! $this->_default_where_conditions_strategy) {
494 494
 			//nothing was set during child constructor, so set default
495 495
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
496 496
 		}
497 497
 		$this->_default_where_conditions_strategy->_finalize_construct($this);
498
-		if( ! $this->_minimum_where_conditions_strategy){
498
+		if ( ! $this->_minimum_where_conditions_strategy) {
499 499
 			//nothing was set during child constructor, so set default
500 500
 			$this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions();
501 501
 		}
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
 
504 504
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
505 505
 		//to indicate to NOT set it, set it to the logical default
506
-		if( $this->_caps_slug === null ) {
507
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
506
+		if ($this->_caps_slug === null) {
507
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
508 508
 		}
509 509
 		//initialize the standard cap restriction generators if none were specified by the child constructor
510
-		if( $this->_cap_restriction_generators !== false ){
511
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
512
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
513
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
510
+		if ($this->_cap_restriction_generators !== false) {
511
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
512
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
513
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
514 514
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
515 515
 						new EE_Restriction_Generator_Protected(),
516 516
 						$cap_context,
@@ -520,23 +520,23 @@  discard block
 block discarded – undo
520 520
 			}
521 521
 		}
522 522
 		//if there are cap restriction generators, use them to make the default cap restrictions
523
-		if( $this->_cap_restriction_generators !== false ){
524
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
525
-				if( ! $generator_object ){
523
+		if ($this->_cap_restriction_generators !== false) {
524
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
525
+				if ( ! $generator_object) {
526 526
 					continue;
527 527
 				}
528
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
528
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
529 529
 					throw new EE_Error(
530 530
 						sprintf(
531
-							__( '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' ),
531
+							__('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'),
532 532
 							$context,
533 533
 							$this->get_this_model_name()
534 534
 						)
535 535
 					);
536 536
 				}
537
-				$action = $this->cap_action_for_context( $context );
538
-				if( ! $generator_object->construction_finalized() ){
539
-					$generator_object->_construct_finalize( $this, $action );
537
+				$action = $this->cap_action_for_context($context);
538
+				if ( ! $generator_object->construction_finalized()) {
539
+					$generator_object->_construct_finalize($this, $action);
540 540
 				}
541 541
 
542 542
 			}
@@ -550,11 +550,11 @@  discard block
 block discarded – undo
550 550
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
551 551
 	 * @return EE_Default_Where_Conditions[]
552 552
 	 */
553
-	protected function _generate_cap_restrictions( $context ){
554
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
555
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
556
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
557
-		}else{
553
+	protected function _generate_cap_restrictions($context) {
554
+		if (isset($this->_cap_restriction_generators[$context]) &&
555
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
556
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
557
+		} else {
558 558
 			return array();
559 559
 		}
560 560
 	}
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 * @param int $blog_id  If provided then will set the blog_id for the models to this id.  If not provided then the
567 567
 	 *                      value for get_current_blog_id() will be used.
568 568
 	 */
569
-	public static function set_model_query_blog_id( $blog_id = 0 ) {
569
+	public static function set_model_query_blog_id($blog_id = 0) {
570 570
 		EEM_Base::$_model_query_blog_id = $blog_id > 0 ? (int) $blog_id : get_current_blog_id();
571 571
 	}
572 572
 
@@ -591,16 +591,16 @@  discard block
 block discarded – undo
591 591
 	 *		@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)
592 592
 	 *		@return static (as in the concrete child class)
593 593
 	 */
594
-	public static function instance( $timezone = NULL ){
594
+	public static function instance($timezone = NULL) {
595 595
 
596 596
 		// check if instance of Espresso_model already exists
597 597
 		if ( ! static::$_instance instanceof static) {
598 598
 			// instantiate Espresso_model
599
-			static::$_instance = new static( $timezone );
599
+			static::$_instance = new static($timezone);
600 600
 		}
601 601
 
602 602
 		//we might have a timezone set, let set_timezone decide what to do with it
603
-		static::$_instance->set_timezone( $timezone );
603
+		static::$_instance->set_timezone($timezone);
604 604
 
605 605
 		// Espresso_model object
606 606
 		return static::$_instance;
@@ -613,14 +613,14 @@  discard block
 block discarded – undo
613 613
 	 * @param null | string $timezone
614 614
 	 * @return static
615 615
 	 */
616
-	public static function reset(  $timezone = NULL ){
617
-		if ( ! is_null( static::$_instance ) ) {
618
-			$model = 'EEM_' . self::instance()->get_this_model_name();
619
-			if ( isset( EE_Registry::instance()->LIB->{$model} ) ) {
616
+	public static function reset($timezone = NULL) {
617
+		if ( ! is_null(static::$_instance)) {
618
+			$model = 'EEM_'.self::instance()->get_this_model_name();
619
+			if (isset(EE_Registry::instance()->LIB->{$model} )) {
620 620
 				EE_Registry::instance()->LIB->{$model} = null;
621 621
 			}
622 622
 			static::$_instance = null;
623
-			return self::instance( $timezone );
623
+			return self::instance($timezone);
624 624
 		}
625 625
 		return null;
626 626
 	}
@@ -634,19 +634,19 @@  discard block
 block discarded – undo
634 634
 	 * @return array
635 635
 	 * @throws \EE_Error
636 636
 	 */
637
-	 public function status_array( $translated = FALSE ) {
638
-		 if ( ! array_key_exists( 'Status', $this->_model_relations ) ) {
637
+	 public function status_array($translated = FALSE) {
638
+		 if ( ! array_key_exists('Status', $this->_model_relations)) {
639 639
 			 return array();
640 640
 		 }
641 641
 		 $model_name = $this->get_this_model_name();
642
-		 $status_type = str_replace( ' ', '_', strtolower( str_replace( '_', ' ', $model_name ) ) );
643
-		 $stati = EEM_Status::instance()->get_all( array( array( 'STS_type' => $status_type ) ) );
642
+		 $status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
643
+		 $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
644 644
 		 $status_array = array();
645
-		 foreach ( $stati as $status ) {
646
-			 $status_array[ $status->ID() ] = $status->get( 'STS_code' );
645
+		 foreach ($stati as $status) {
646
+			 $status_array[$status->ID()] = $status->get('STS_code');
647 647
 		 }
648 648
 		 return $translated
649
-			 ? EEM_Status::instance()->localized_status( $status_array, false, 'sentence' )
649
+			 ? EEM_Status::instance()->localized_status($status_array, false, 'sentence')
650 650
 			 : $status_array;
651 651
 	 }
652 652
 
@@ -779,10 +779,10 @@  discard block
 block discarded – undo
779 779
 	 *		));
780 780
 	 * @throws \EE_Error
781 781
 	 */
782
-	public function get_all($query_params = array()){
783
-		if( isset( $query_params[ 'limit' ] )
784
-			&& ! isset( $query_params[ 'group_by' ] ) ) {
785
-			$query_params[ 'group_by' ] = array_keys( $this->get_combined_primary_key_fields() );
782
+	public function get_all($query_params = array()) {
783
+		if (isset($query_params['limit'])
784
+			&& ! isset($query_params['group_by'])) {
785
+			$query_params['group_by'] = array_keys($this->get_combined_primary_key_fields());
786 786
 		}
787 787
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
788 788
 	}
@@ -793,10 +793,10 @@  discard block
 block discarded – undo
793 793
 	 * @param array $query_params @see EEM_Base::get_all()
794 794
 	 * @return array like EEM_Base::get_all
795 795
 	 */
796
-	public function alter_query_params_to_only_include_mine( $query_params = array() ) {
796
+	public function alter_query_params_to_only_include_mine($query_params = array()) {
797 797
 		$wp_user_field_name = $this->wp_user_field_name();
798
-		if( $wp_user_field_name ){
799
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
798
+		if ($wp_user_field_name) {
799
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
800 800
 		}
801 801
 		return $query_params;
802 802
 	}
@@ -809,19 +809,19 @@  discard block
 block discarded – undo
809 809
 	 * foreign key to the WP_User table
810 810
 	 */
811 811
 	public function wp_user_field_name() {
812
-		try{
813
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
814
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
815
-				$last_model_name = end( $models_to_follow_to_wp_users );
816
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
817
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
818
-			}else{
812
+		try {
813
+			if ( ! empty($this->_model_chain_to_wp_user)) {
814
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
815
+				$last_model_name = end($models_to_follow_to_wp_users);
816
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
817
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
818
+			} else {
819 819
 				$model_with_fk_to_wp_users = $this;
820 820
 				$model_chain_to_wp_user = '';
821 821
 			}
822
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
823
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
824
-		}catch( EE_Error $e ) {
822
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
823
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
824
+		} catch (EE_Error $e) {
825 825
 			return false;
826 826
 		}
827 827
 	}
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 	 * (or transiently-related model)
836 836
 	 * @return string
837 837
 	 */
838
-	public function model_chain_to_wp_user(){
838
+	public function model_chain_to_wp_user() {
839 839
 		return $this->_model_chain_to_wp_user;
840 840
 	}
841 841
 
@@ -847,13 +847,13 @@  discard block
 block discarded – undo
847 847
 	 * @return boolean
848 848
 	 */
849 849
 	public function is_owned() {
850
-		if( $this->model_chain_to_wp_user() ){
850
+		if ($this->model_chain_to_wp_user()) {
851 851
 			return true;
852
-		}else{
853
-			try{
854
-				$this->get_foreign_key_to( 'WP_User' );
852
+		} else {
853
+			try {
854
+				$this->get_foreign_key_to('WP_User');
855 855
 				return true;
856
-			}catch( EE_Error $e ){
856
+			} catch (EE_Error $e) {
857 857
 				return false;
858 858
 			}
859 859
 		}
@@ -875,17 +875,17 @@  discard block
 block discarded – undo
875 875
 	 * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
876 876
 	 * @throws \EE_Error
877 877
 	 */
878
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
878
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
879 879
 		// remember the custom selections, if any, and type cast as array
880 880
 		// (unless $columns_to_select is an object, then just set as an empty array)
881 881
 		// Note: (array) 'some string' === array( 'some string' )
882
-		$this->_custom_selections = ! is_object( $columns_to_select ) ? (array) $columns_to_select : array();
883
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
882
+		$this->_custom_selections = ! is_object($columns_to_select) ? (array) $columns_to_select : array();
883
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
884 884
 		$select_expressions = $columns_to_select !== null
885
-			? $this->_construct_select_from_input( $columns_to_select )
886
-			: $this->_construct_default_select_sql( $model_query_info );
887
-		$SQL = "SELECT $select_expressions " . $this->_construct_2nd_half_of_select_query( $model_query_info );
888
-		return $this->_do_wpdb_query( 'get_results', array( $SQL, $output ) );
885
+			? $this->_construct_select_from_input($columns_to_select)
886
+			: $this->_construct_default_select_sql($model_query_info);
887
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
888
+		return $this->_do_wpdb_query('get_results', array($SQL, $output));
889 889
 	}
890 890
 
891 891
 	/**
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
904 904
 	 * @throws \EE_Error
905 905
 	 */
906
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
906
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
907 907
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
908 908
 	}
909 909
 
@@ -915,12 +915,12 @@  discard block
 block discarded – undo
915 915
 	 * @throws EE_Error
916 916
 	 * @return string
917 917
 	 */
918
-	private function _construct_select_from_input($columns_to_select){
919
-		if(is_array($columns_to_select)){
918
+	private function _construct_select_from_input($columns_to_select) {
919
+		if (is_array($columns_to_select)) {
920 920
 			$select_sql_array = array();
921 921
 
922
-			foreach($columns_to_select as $alias => $selection_and_datatype){
923
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
922
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
923
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
924 924
 					throw new EE_Error(
925 925
 						sprintf(
926 926
 							__(
@@ -932,24 +932,24 @@  discard block
 block discarded – undo
932 932
 						)
933 933
 					);
934 934
 				}
935
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
935
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
936 936
 					throw new EE_Error(
937 937
 						sprintf(
938 938
 							__(
939 939
 								"Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)",
940 940
 								"event_espresso"
941 941
 							),
942
-							$selection_and_datatype[ 1 ],
943
-							$selection_and_datatype[ 0 ],
942
+							$selection_and_datatype[1],
943
+							$selection_and_datatype[0],
944 944
 							$alias,
945
-							implode( ",", $this->_valid_wpdb_data_types )
945
+							implode(",", $this->_valid_wpdb_data_types)
946 946
 						)
947 947
 					);
948 948
 				}
949 949
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
950 950
 			}
951
-			$columns_to_select_string = implode(", ",$select_sql_array);
952
-		}else{
951
+			$columns_to_select_string = implode(", ", $select_sql_array);
952
+		} else {
953 953
 			$columns_to_select_string = $columns_to_select;
954 954
 		}
955 955
 		return $columns_to_select_string;
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 	 * @return string
965 965
 	 * @throws \EE_Error
966 966
 	 */
967
-	public function primary_key_name(){
967
+	public function primary_key_name() {
968 968
 		return $this->get_primary_key_field()->get_name();
969 969
 	}
970 970
 
@@ -976,14 +976,14 @@  discard block
 block discarded – undo
976 976
 	 * @param mixed $id int or string, depending on the type of the model's primary key
977 977
 	 * @return EE_Base_Class
978 978
 	 */
979
-	public function get_one_by_ID($id){
980
-		if( $this->get_from_entity_map( $id ) ){
981
-			return $this->get_from_entity_map( $id );
979
+	public function get_one_by_ID($id) {
980
+		if ($this->get_from_entity_map($id)) {
981
+			return $this->get_from_entity_map($id);
982 982
 		}
983 983
 		return $this->get_one(
984 984
 			$this->alter_query_params_to_restrict_by_ID(
985 985
 				$id,
986
-				array( 'default_where_conditions' => 'minimum' )
986
+				array('default_where_conditions' => 'minimum')
987 987
 			)
988 988
 		);
989 989
 	}
@@ -999,15 +999,15 @@  discard block
 block discarded – undo
999 999
 	 * @return array of normal query params, @see EEM_Base::get_all
1000 1000
 	 * @throws \EE_Error
1001 1001
 	 */
1002
-	public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) {
1003
-		if( ! isset( $query_params[ 0 ] ) ) {
1004
-			$query_params[ 0 ] = array();
1002
+	public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) {
1003
+		if ( ! isset($query_params[0])) {
1004
+			$query_params[0] = array();
1005 1005
 		}
1006
-		if( $this->has_primary_key_field ( ) ) {
1007
-			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
1008
-		}else{
1006
+		if ($this->has_primary_key_field( )) {
1007
+			$query_params[0][$this->primary_key_name()] = $id;
1008
+		} else {
1009 1009
 			//no primary key, so the $id must be from the get_index_primary_key_string()
1010
-			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
1010
+			$query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id));
1011 1011
 		}
1012 1012
 		return $query_params;
1013 1013
 	}
@@ -1022,16 +1022,16 @@  discard block
 block discarded – undo
1022 1022
 	 * @return EE_Base_Class | NULL
1023 1023
 	 * @throws \EE_Error
1024 1024
 	 */
1025
-	public function get_one($query_params = array()){
1026
-		if( ! is_array( $query_params ) ){
1027
-			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' );
1025
+	public function get_one($query_params = array()) {
1026
+		if ( ! is_array($query_params)) {
1027
+			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');
1028 1028
 			$query_params = array();
1029 1029
 		}
1030 1030
 		$query_params['limit'] = 1;
1031 1031
 		$items = $this->get_all($query_params);
1032
-		if(empty($items)){
1032
+		if (empty($items)) {
1033 1033
 			return null;
1034
-		}else{
1034
+		} else {
1035 1035
 			return array_shift($items);
1036 1036
 		}
1037 1037
 	}
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 	 * @return EE_Base_Class[]|array
1055 1055
 	 * @throws \EE_Error
1056 1056
 	 */
1057
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1058
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
1057
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1058
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
1059 1059
 	}
1060 1060
 
1061 1061
 
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
 	 * @return EE_Base_Class[]|array
1077 1077
 	 * @throws \EE_Error
1078 1078
 	 */
1079
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1080
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1079
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1080
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1081 1081
 	}
1082 1082
 
1083 1083
 
@@ -1098,9 +1098,9 @@  discard block
 block discarded – undo
1098 1098
 	 * @return EE_Base_Class|null|array()
1099 1099
 	 * @throws \EE_Error
1100 1100
 	 */
1101
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1102
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1103
-		return empty( $results ) ? null : reset( $results );
1101
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1102
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1103
+		return empty($results) ? null : reset($results);
1104 1104
 	}
1105 1105
 
1106 1106
 
@@ -1122,9 +1122,9 @@  discard block
 block discarded – undo
1122 1122
  * @return EE_Base_Class|null|array()
1123 1123
 	 * @throws EE_Error
1124 1124
 	 */
1125
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1126
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1127
-		return empty( $results ) ? null : reset( $results );
1125
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1126
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1127
+		return empty($results) ? null : reset($results);
1128 1128
 	}
1129 1129
 
1130 1130
 
@@ -1145,42 +1145,42 @@  discard block
 block discarded – undo
1145 1145
 	 * @return EE_Base_Class[]|array
1146 1146
 	 * @throws EE_Error
1147 1147
 	 */
1148
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1148
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1149 1149
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1150
-		if ( empty( $field_to_order_by ) ) {
1151
-			if ( $this->has_primary_key_field() ) {
1150
+		if (empty($field_to_order_by)) {
1151
+			if ($this->has_primary_key_field()) {
1152 1152
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1153 1153
 			} else {
1154 1154
 
1155
-				if ( WP_DEBUG ) {
1156
-					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' ) );
1155
+				if (WP_DEBUG) {
1156
+					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'));
1157 1157
 				}
1158
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1158
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1159 1159
 				return array();
1160 1160
 			}
1161 1161
 		}
1162 1162
 
1163
-		if( ! is_array( $query_params ) ){
1164
-			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' );
1163
+		if ( ! is_array($query_params)) {
1164
+			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');
1165 1165
 			$query_params = array();
1166 1166
 		}
1167 1167
 
1168 1168
 		//let's add the where query param for consecutive look up.
1169
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1169
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1170 1170
 		$query_params['limit'] = $limit;
1171 1171
 
1172 1172
 		//set direction
1173
-		$incoming_orderby = isset( $query_params['order_by'] ) ? (array)$query_params['order_by'] : array();
1173
+		$incoming_orderby = isset($query_params['order_by']) ? (array) $query_params['order_by'] : array();
1174 1174
 		$query_params['order_by'] = $operand === '>'
1175
-			? array( $field_to_order_by => 'ASC' ) + $incoming_orderby
1176
-			: array( $field_to_order_by => 'DESC') + $incoming_orderby;
1175
+			? array($field_to_order_by => 'ASC') + $incoming_orderby
1176
+			: array($field_to_order_by => 'DESC') + $incoming_orderby;
1177 1177
 
1178 1178
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1179
-		if ( empty( $columns_to_select ) ) {
1180
-			return $this->get_all( $query_params );
1179
+		if (empty($columns_to_select)) {
1180
+			return $this->get_all($query_params);
1181 1181
 		} else {
1182 1182
 			//getting just the fields
1183
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1183
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1184 1184
 		}
1185 1185
 	}
1186 1186
 
@@ -1191,18 +1191,18 @@  discard block
 block discarded – undo
1191 1191
 	 * This sets the _timezone property after model object has been instantiated.
1192 1192
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1193 1193
 	 */
1194
-	public function set_timezone( $timezone ) {
1195
-		if ( $timezone !== null ) {
1194
+	public function set_timezone($timezone) {
1195
+		if ($timezone !== null) {
1196 1196
 			$this->_timezone = $timezone;
1197 1197
 		}
1198 1198
 		//note we need to loop through relations and set the timezone on those objects as well.
1199
-		foreach ( $this->_model_relations as $relation ) {
1200
-			$relation->set_timezone( $timezone );
1199
+		foreach ($this->_model_relations as $relation) {
1200
+			$relation->set_timezone($timezone);
1201 1201
 		}
1202 1202
 		//and finally we do the same for any datetime fields
1203
-		foreach ( $this->_fields as $field ) {
1204
-			if ( $field instanceof EE_Datetime_Field ) {
1205
-				$field->set_timezone( $timezone );
1203
+		foreach ($this->_fields as $field) {
1204
+			if ($field instanceof EE_Datetime_Field) {
1205
+				$field->set_timezone($timezone);
1206 1206
 			}
1207 1207
 		}
1208 1208
 	}
@@ -1217,9 +1217,9 @@  discard block
 block discarded – undo
1217 1217
 	 */
1218 1218
 	public function get_timezone() {
1219 1219
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1220
-		if ( empty( $this->_timezone ) ) {
1221
-			foreach( $this->_fields as $field ) {
1222
-				if ( $field instanceof EE_Datetime_Field ) {
1220
+		if (empty($this->_timezone)) {
1221
+			foreach ($this->_fields as $field) {
1222
+				if ($field instanceof EE_Datetime_Field) {
1223 1223
 					$this->set_timezone($field->get_timezone());
1224 1224
 					break;
1225 1225
 				}
@@ -1227,8 +1227,8 @@  discard block
 block discarded – undo
1227 1227
 		}
1228 1228
 
1229 1229
 		//if timezone STILL empty then return the default timezone for the site.
1230
-		if ( empty( $this->_timezone ) ) {
1231
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1230
+		if (empty($this->_timezone)) {
1231
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1232 1232
 		}
1233 1233
 		return $this->_timezone;
1234 1234
 	}
@@ -1246,19 +1246,19 @@  discard block
 block discarded – undo
1246 1246
 	 *
1247 1247
 	 * @return array formats in an array with the date format first, and the time format last.
1248 1248
 	 */
1249
-	public function get_formats_for( $field_name, $pretty = false ) {
1250
-		$field_settings = $this->field_settings_for( $field_name );
1249
+	public function get_formats_for($field_name, $pretty = false) {
1250
+		$field_settings = $this->field_settings_for($field_name);
1251 1251
 
1252 1252
 		//if not a valid EE_Datetime_Field then throw error
1253
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1254
-			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 ) );
1253
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1254
+			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));
1255 1255
 		}
1256 1256
 
1257 1257
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1258 1258
 		//the field.
1259 1259
 		$this->_timezone = $field_settings->get_timezone();
1260 1260
 
1261
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1261
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1262 1262
 	}
1263 1263
 
1264 1264
 
@@ -1282,25 +1282,25 @@  discard block
 block discarded – undo
1282 1282
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1283 1283
 	 *                    	     exception is triggered.
1284 1284
 	 */
1285
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1286
-		$formats = $this->get_formats_for( $field_name );
1285
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1286
+		$formats = $this->get_formats_for($field_name);
1287 1287
 
1288
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1288
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1289 1289
 
1290
-		if ( $timestamp ) {
1291
-			return $DateTime->format( 'U' );
1290
+		if ($timestamp) {
1291
+			return $DateTime->format('U');
1292 1292
 		}
1293 1293
 
1294 1294
 		//not returning timestamp, so return formatted string in timezone.
1295
-		switch( $what ) {
1295
+		switch ($what) {
1296 1296
 			case 'time' :
1297
-				return $DateTime->format( $formats[1] );
1297
+				return $DateTime->format($formats[1]);
1298 1298
 				break;
1299 1299
 			case 'date' :
1300
-				return $DateTime->format( $formats[0] );
1300
+				return $DateTime->format($formats[0]);
1301 1301
 				break;
1302 1302
 			default :
1303
-				return $DateTime->format( implode( ' ', $formats ) );
1303
+				return $DateTime->format(implode(' ', $formats));
1304 1304
 				break;
1305 1305
 		}
1306 1306
 	}
@@ -1322,17 +1322,17 @@  discard block
 block discarded – undo
1322 1322
 	 * @return DateTime
1323 1323
 	 * @throws \EE_Error
1324 1324
 	 */
1325
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1325
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1326 1326
 
1327 1327
 		//just using this to ensure the timezone is set correctly internally
1328
-		$this->get_formats_for( $field_name );
1328
+		$this->get_formats_for($field_name);
1329 1329
 
1330 1330
 		//load EEH_DTT_Helper
1331
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1331
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1332 1332
 
1333
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1333
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1334 1334
 
1335
-		return $incomingDateTime->setTimezone( new DateTimeZone( $this->_timezone ) );
1335
+		return $incomingDateTime->setTimezone(new DateTimeZone($this->_timezone));
1336 1336
 	}
1337 1337
 
1338 1338
 
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1343 1343
 	 * @return EE_Table_Base[]
1344 1344
 	 */
1345
-	public function get_tables(){
1345
+	public function get_tables() {
1346 1346
 		return $this->_tables;
1347 1347
 	}
1348 1348
 
@@ -1378,9 +1378,9 @@  discard block
 block discarded – undo
1378 1378
 	 * @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)
1379 1379
 	 * @throws \EE_Error
1380 1380
 	 */
1381
-	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1382
-		if( ! is_array( $query_params ) ){
1383
-			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' );
1381
+	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1382
+		if ( ! is_array($query_params)) {
1383
+			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');
1384 1384
 			$query_params = array();
1385 1385
 		}
1386 1386
 		/**
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 		 * @param array $fields_n_values the updated fields and their new values
1391 1391
 		 * @param array $query_params @see EEM_Base::get_all()
1392 1392
 		 */
1393
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1393
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1394 1394
 		/**
1395 1395
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1396 1396
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1398,10 +1398,10 @@  discard block
 block discarded – undo
1398 1398
 		 * @param EEM_Base $model the model being queried
1399 1399
 		 * @param array $query_params see EEM_Base::get_all()
1400 1400
 		 */
1401
-		$fields_n_values = (array)apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1401
+		$fields_n_values = (array) apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1402 1402
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1403 1403
 		//to do that, for each table, verify that it's PK isn't null.
1404
-		$tables= $this->get_tables();
1404
+		$tables = $this->get_tables();
1405 1405
 
1406 1406
 		//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
1407 1407
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1411,29 +1411,29 @@  discard block
 block discarded – undo
1411 1411
 			//we want to make sure the default_where strategy is ignored
1412 1412
 			$this->_ignore_where_strategy = TRUE;
1413 1413
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1414
-			foreach( $wpdb_select_results as $wpdb_result ){
1414
+			foreach ($wpdb_select_results as $wpdb_result) {
1415 1415
 				// type cast stdClass as array
1416
-				$wpdb_result = (array)$wpdb_result;
1416
+				$wpdb_result = (array) $wpdb_result;
1417 1417
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1418
-				if( $this->has_primary_key_field() ){
1419
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1420
-				}else{
1418
+				if ($this->has_primary_key_field()) {
1419
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1420
+				} else {
1421 1421
 					//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)
1422 1422
 					$main_table_pk_value = null;
1423 1423
 				}
1424 1424
 				//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
1425 1425
 				//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
1426
-				if(count($tables) > 1){
1426
+				if (count($tables) > 1) {
1427 1427
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1428 1428
 					//in that table, and so we'll want to insert one
1429
-					foreach($tables as $table_obj){
1429
+					foreach ($tables as $table_obj) {
1430 1430
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1431 1431
 						//if there is no private key for this table on the results, it means there's no entry
1432 1432
 						//in this table, right? so insert a row in the current table, using any fields available
1433
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1433
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1434 1434
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1435 1435
 							//if we died here, report the error
1436
-							if( ! $success ) {
1436
+							if ( ! $success) {
1437 1437
 								return false;
1438 1438
 							}
1439 1439
 						}
@@ -1453,44 +1453,44 @@  discard block
 block discarded – undo
1453 1453
 		//if this wasn't called from a model object (to update itself)
1454 1454
 		//then we want to make sure we keep all the existing
1455 1455
 		//model objects in sync with the db
1456
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1457
-			if( $this->has_primary_key_field() ){
1458
-				$model_objs_affected_ids = $this->get_col( $query_params );
1459
-			}else{
1456
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1457
+			if ($this->has_primary_key_field()) {
1458
+				$model_objs_affected_ids = $this->get_col($query_params);
1459
+			} else {
1460 1460
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1461
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1461
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1462 1462
 				$model_objs_affected_ids = array();
1463
-				foreach( $models_affected_key_columns as $row ){
1464
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1465
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1463
+				foreach ($models_affected_key_columns as $row) {
1464
+					$combined_index_key = $this->get_index_primary_key_string($row);
1465
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1466 1466
 				}
1467 1467
 
1468 1468
 			}
1469 1469
 
1470
-			if( ! $model_objs_affected_ids ){
1470
+			if ( ! $model_objs_affected_ids) {
1471 1471
 				//wait wait wait- if nothing was affected let's stop here
1472 1472
 				return 0;
1473 1473
 			}
1474
-			foreach( $model_objs_affected_ids as $id ){
1475
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1476
-				if( $model_obj_in_entity_map ){
1477
-					foreach( $fields_n_values as $field => $new_value ){
1478
-						$model_obj_in_entity_map->set( $field, $new_value );
1474
+			foreach ($model_objs_affected_ids as $id) {
1475
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1476
+				if ($model_obj_in_entity_map) {
1477
+					foreach ($fields_n_values as $field => $new_value) {
1478
+						$model_obj_in_entity_map->set($field, $new_value);
1479 1479
 					}
1480 1480
 				}
1481 1481
 			}
1482 1482
 			//if there is a primary key on this model, we can now do a slight optimization
1483
-			if( $this->has_primary_key_field() ){
1483
+			if ($this->has_primary_key_field()) {
1484 1484
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1485 1485
 				$query_params = array(
1486
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1487
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1486
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1487
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1488 1488
 			}
1489 1489
 		}
1490 1490
 
1491
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1492
-		$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.
1493
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1491
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1492
+		$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.
1493
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1494 1494
 		/**
1495 1495
 		 * Action called after a model update call has been made.
1496 1496
 		 *
@@ -1499,8 +1499,8 @@  discard block
 block discarded – undo
1499 1499
 		 * @param array $query_params @see EEM_Base::get_all()
1500 1500
 		 * @param int $rows_affected
1501 1501
 		 */
1502
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1503
-		return $rows_affected;//how many supposedly got updated
1502
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1503
+		return $rows_affected; //how many supposedly got updated
1504 1504
 	}
1505 1505
 
1506 1506
 
@@ -1516,22 +1516,22 @@  discard block
 block discarded – undo
1516 1516
 	 * @return array just like $wpdb->get_col()
1517 1517
 	 * @throws \EE_Error
1518 1518
 	 */
1519
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1519
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1520 1520
 
1521
-		if( $field_to_select ){
1522
-			$field = $this->field_settings_for( $field_to_select );
1523
-		}elseif( $this->has_primary_key_field ( ) ){
1521
+		if ($field_to_select) {
1522
+			$field = $this->field_settings_for($field_to_select);
1523
+		}elseif ($this->has_primary_key_field( )) {
1524 1524
 			$field = $this->get_primary_key_field();
1525
-		}else{
1525
+		} else {
1526 1526
 			//no primary key, just grab the first column
1527
-			$field = reset( $this->field_settings());
1527
+			$field = reset($this->field_settings());
1528 1528
 		}
1529 1529
 
1530 1530
 
1531 1531
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1532 1532
 		$select_expressions = $field->get_qualified_column();
1533
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1534
-		return $this->_do_wpdb_query('get_col', array( $SQL ) );
1533
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1534
+		return $this->_do_wpdb_query('get_col', array($SQL));
1535 1535
 	}
1536 1536
 
1537 1537
 
@@ -1544,12 +1544,12 @@  discard block
 block discarded – undo
1544 1544
 	 * @return string
1545 1545
 	 * @throws \EE_Error
1546 1546
 	 */
1547
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1548
-		$query_params[ 'limit' ] = 1;
1549
-		$col = $this->get_col( $query_params, $field_to_select );
1550
-		if( ! empty( $col ) ) {
1551
-			return reset( $col );
1552
-		}else{
1547
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1548
+		$query_params['limit'] = 1;
1549
+		$col = $this->get_col($query_params, $field_to_select);
1550
+		if ( ! empty($col)) {
1551
+			return reset($col);
1552
+		} else {
1553 1553
 			return NULL;
1554 1554
 		}
1555 1555
 	}
@@ -1565,19 +1565,19 @@  discard block
 block discarded – undo
1565 1565
 	 * @return string of SQL
1566 1566
 	 * @throws \EE_Error
1567 1567
 	 */
1568
-	public function _construct_update_sql($fields_n_values){
1568
+	public function _construct_update_sql($fields_n_values) {
1569 1569
 		/** @type WPDB $wpdb */
1570 1570
 		global $wpdb;
1571 1571
 		$cols_n_values = array();
1572
-		foreach($fields_n_values as $field_name => $value){
1572
+		foreach ($fields_n_values as $field_name => $value) {
1573 1573
 			$field_obj = $this->field_settings_for($field_name);
1574 1574
 			//if the value is NULL, we want to assign the value to that.
1575 1575
 			//wpdb->prepare doesn't really handle that properly
1576
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1577
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1576
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1577
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1578 1578
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1579 1579
 		}
1580
-		return implode(",",$cols_n_values);
1580
+		return implode(",", $cols_n_values);
1581 1581
 
1582 1582
 	}
1583 1583
 
@@ -1593,10 +1593,10 @@  discard block
 block discarded – undo
1593 1593
 	 * @return boolean whether the row got deleted or not
1594 1594
 	 * @throws \EE_Error
1595 1595
 	 */
1596
-	public function delete_permanently_by_ID( $id ) {
1596
+	public function delete_permanently_by_ID($id) {
1597 1597
 		return $this->delete_permanently(
1598 1598
 			array(
1599
-				array( $this->get_primary_key_field()->get_name() => $id ),
1599
+				array($this->get_primary_key_field()->get_name() => $id),
1600 1600
 				'limit' 	=> 1
1601 1601
 			)
1602 1602
 		);
@@ -1612,10 +1612,10 @@  discard block
 block discarded – undo
1612 1612
 	 * @return boolean whether the row got deleted or not
1613 1613
 	 * @throws \EE_Error
1614 1614
 	 */
1615
-	public function delete_by_ID( $id ){
1615
+	public function delete_by_ID($id) {
1616 1616
 		return $this->delete(
1617 1617
 			array(
1618
-				array( $this->get_primary_key_field()->get_name() => $id ),
1618
+				array($this->get_primary_key_field()->get_name() => $id),
1619 1619
 				'limit' 	=> 1
1620 1620
 			)
1621 1621
 		);
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 	 * @return int how many rows got deleted
1635 1635
 	 * @throws \EE_Error
1636 1636
 	 */
1637
-	public function delete($query_params,$allow_blocking = true){
1637
+	public function delete($query_params, $allow_blocking = true) {
1638 1638
 		return $this->delete_permanently($query_params, $allow_blocking);
1639 1639
 	}
1640 1640
 
@@ -1652,7 +1652,7 @@  discard block
 block discarded – undo
1652 1652
 	 * @return int how many rows got deleted
1653 1653
 	 * @throws \EE_Error
1654 1654
 	 */
1655
-	public function delete_permanently($query_params,$allow_blocking = true){
1655
+	public function delete_permanently($query_params, $allow_blocking = true) {
1656 1656
 		/**
1657 1657
 		 * Action called just before performing a real deletion query. You can use the
1658 1658
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1661,31 +1661,31 @@  discard block
 block discarded – undo
1661 1661
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1662 1662
 		 * to block (prevent) this deletion
1663 1663
 		 */
1664
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1664
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1665 1665
 		//some MySQL databases may be running safe mode, which may restrict
1666 1666
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1667 1667
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1668 1668
 		//to delete them
1669 1669
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1670
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1671
-		if($deletion_where){
1670
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1671
+		if ($deletion_where) {
1672 1672
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1673 1673
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1674
-			$table_aliases = array_keys( $this->_tables );
1675
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1674
+			$table_aliases = array_keys($this->_tables);
1675
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1676 1676
 
1677 1677
 			//		/echo "delete sql:$SQL";
1678
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1679
-		}else{
1678
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1679
+		} else {
1680 1680
 			$rows_deleted = 0;
1681 1681
 		}
1682 1682
 
1683 1683
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1684
-		if( $this->has_primary_key_field() ){
1685
-			foreach($items_for_deletion as $item_for_deletion_row ){
1686
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1687
-				if( isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] ) ){
1688
-					unset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] );
1684
+		if ($this->has_primary_key_field()) {
1685
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1686
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1687
+				if (isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value])) {
1688
+					unset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value]);
1689 1689
 				}
1690 1690
 			}
1691 1691
 		}
@@ -1697,8 +1697,8 @@  discard block
 block discarded – undo
1697 1697
 		 * @param array $query_params @see EEM_Base::get_all()
1698 1698
 		 * @param int $rows_deleted
1699 1699
 		 */
1700
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1701
-		return $rows_deleted;//how many supposedly got deleted
1700
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1701
+		return $rows_deleted; //how many supposedly got deleted
1702 1702
 	}
1703 1703
 
1704 1704
 
@@ -1716,28 +1716,28 @@  discard block
 block discarded – undo
1716 1716
 	 * @return boolean
1717 1717
 	 * @throws \EE_Error
1718 1718
 	 */
1719
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1719
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1720 1720
 		//first, if $ignore_this_model_obj was supplied, get its model
1721
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1721
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1722 1722
 			$ignored_model = $ignore_this_model_obj->get_model();
1723
-		}else{
1723
+		} else {
1724 1724
 			$ignored_model = null;
1725 1725
 		}
1726 1726
 		//now check all the relations of $this_model_obj_or_id and see if there
1727 1727
 		//are any related model objects blocking it?
1728 1728
 		$is_blocked = false;
1729
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1730
-			if( $relation_obj->block_delete_if_related_models_exist()){
1729
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1730
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1731 1731
 				//if $ignore_this_model_obj was supplied, then for the query
1732 1732
 				//on that model needs to be told to ignore $ignore_this_model_obj
1733
-				if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){
1734
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1735
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1736
-				}else{
1733
+				if ($ignored_model && $relation_name === $ignored_model->get_this_model_name()) {
1734
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1735
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1736
+				} else {
1737 1737
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1738 1738
 				}
1739 1739
 
1740
-				if($related_model_objects){
1740
+				if ($related_model_objects) {
1741 1741
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1742 1742
 					$is_blocked = true;
1743 1743
 				}
@@ -1757,71 +1757,71 @@  discard block
 block discarded – undo
1757 1757
 	 * @throws EE_Error
1758 1758
 	 * @return string    everything that comes after the WHERE statement.
1759 1759
 	 */
1760
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1761
-		if($this->has_primary_key_field()){
1760
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1761
+		if ($this->has_primary_key_field()) {
1762 1762
 			$primary_table = $this->_get_main_table();
1763 1763
 			$other_tables = $this->_get_other_tables();
1764 1764
 			$deletes = $query = array();
1765
-			foreach ( $objects_for_deletion as $delete_object ) {
1765
+			foreach ($objects_for_deletion as $delete_object) {
1766 1766
 				//before we mark this object for deletion,
1767 1767
 				//make sure there's no related objects blocking its deletion (if we're checking)
1768 1768
 				if (
1769 1769
 					$allow_blocking
1770 1770
 				    && $this->delete_is_blocked_by_related_models(
1771
-						$delete_object[ $primary_table->get_fully_qualified_pk_column() ]
1771
+						$delete_object[$primary_table->get_fully_qualified_pk_column()]
1772 1772
 					)
1773 1773
 				) {
1774 1774
 					continue;
1775 1775
 				}
1776 1776
 				//primary table deletes
1777
-				if ( isset( $delete_object[ $primary_table->get_fully_qualified_pk_column() ] ) ) {
1778
-					$deletes[ $primary_table->get_fully_qualified_pk_column() ][] = $delete_object[ $primary_table->get_fully_qualified_pk_column() ];
1777
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1778
+					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1779 1779
 				}
1780 1780
 				//other tables
1781
-				if ( ! empty( $other_tables ) ) {
1782
-					foreach ( $other_tables as $ot ) {
1781
+				if ( ! empty($other_tables)) {
1782
+					foreach ($other_tables as $ot) {
1783 1783
 						//first check if we've got the foreign key column here.
1784
-						if ( isset( $delete_object[ $ot->get_fully_qualified_fk_column() ] ) ) {
1785
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_fk_column() ];
1784
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) {
1785
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1786 1786
 						}
1787 1787
 						// wait! it's entirely possible that we'll have a the primary key
1788 1788
 						// for this table in here, if it's a foreign key for one of the other secondary tables
1789
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_column() ] ) ) {
1790
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1789
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) {
1790
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1791 1791
 						}
1792 1792
 						// finally, it is possible that the fk for this table is found
1793 1793
 						// in the fully qualified pk column for the fk table, so let's see if that's there!
1794
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_on_fk_table() ] ) ) {
1795
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1794
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) {
1795
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1796 1796
 						}
1797 1797
 					}
1798 1798
 				}
1799 1799
 			}
1800 1800
 
1801 1801
 			//we should have deletes now, so let's just go through and setup the where statement
1802
-			foreach ( $deletes as $column => $values ) {
1802
+			foreach ($deletes as $column => $values) {
1803 1803
 				//make sure we have unique $values;
1804 1804
 				$values = array_unique($values);
1805
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1805
+				$query[] = $column.' IN('.implode(",", $values).')';
1806 1806
 			}
1807 1807
 
1808
-			return !empty($query) ? implode(' AND ', $query ) : '';
1809
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1808
+			return ! empty($query) ? implode(' AND ', $query) : '';
1809
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1810 1810
 			$ways_to_identify_a_row = array();
1811 1811
 			$fields = $this->get_combined_primary_key_fields();
1812 1812
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1813
-			foreach($objects_for_deletion as  $delete_object){
1813
+			foreach ($objects_for_deletion as  $delete_object) {
1814 1814
 				$values_for_each_cpk_for_a_row = array();
1815
-				foreach($fields as $cpk_field){
1815
+				foreach ($fields as $cpk_field) {
1816 1816
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1817 1817
 				}
1818
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1818
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1819 1819
 			}
1820
-			return implode(" OR ",$ways_to_identify_a_row);
1821
-		}else{
1820
+			return implode(" OR ", $ways_to_identify_a_row);
1821
+		} else {
1822 1822
 			//so there's no primary key and no combined key...
1823 1823
 			//sorry, can't help you
1824
-			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)));
1824
+			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)));
1825 1825
 		}
1826 1826
 	}
1827 1827
 
@@ -1837,21 +1837,21 @@  discard block
 block discarded – undo
1837 1837
 	 * @return int
1838 1838
 	 * @throws \EE_Error
1839 1839
 	 */
1840
-	public function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1840
+	public function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1841 1841
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1842
-		if($field_to_count){
1842
+		if ($field_to_count) {
1843 1843
 			$field_obj = $this->field_settings_for($field_to_count);
1844 1844
 			$column_to_count = $field_obj->get_qualified_column();
1845
-		}elseif($this->has_primary_key_field ()){
1845
+		}elseif ($this->has_primary_key_field()) {
1846 1846
 			$pk_field_obj = $this->get_primary_key_field();
1847 1847
 			$column_to_count = $pk_field_obj->get_qualified_column();
1848
-		}else{//there's no primary key
1848
+		} else {//there's no primary key
1849 1849
 			$column_to_count = '*';
1850 1850
 		}
1851 1851
 
1852
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1853
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1854
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1852
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1853
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1854
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1855 1855
 	}
1856 1856
 
1857 1857
 
@@ -1864,24 +1864,24 @@  discard block
 block discarded – undo
1864 1864
 	 * @return float
1865 1865
 	 * @throws \EE_Error
1866 1866
 	 */
1867
-	public function sum($query_params, $field_to_sum = NULL){
1867
+	public function sum($query_params, $field_to_sum = NULL) {
1868 1868
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1869 1869
 
1870
-		if($field_to_sum){
1870
+		if ($field_to_sum) {
1871 1871
 			$field_obj = $this->field_settings_for($field_to_sum);
1872 1872
 
1873
-		}else{
1873
+		} else {
1874 1874
 			$field_obj = $this->get_primary_key_field();
1875 1875
 		}
1876 1876
 		$column_to_count = $field_obj->get_qualified_column();
1877 1877
 
1878
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1879
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1878
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1879
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1880 1880
 		$data_type = $field_obj->get_wpdb_data_type();
1881
-		if( $data_type === '%d' || $data_type === '%s' ){
1882
-			return (float)$return_value;
1883
-		}else{//must be %f
1884
-			return (float)$return_value;
1881
+		if ($data_type === '%d' || $data_type === '%s') {
1882
+			return (float) $return_value;
1883
+		} else {//must be %f
1884
+			return (float) $return_value;
1885 1885
 		}
1886 1886
 	}
1887 1887
 
@@ -1896,37 +1896,37 @@  discard block
 block discarded – undo
1896 1896
 	 * @global wpdb $wpdb
1897 1897
 	 * @return mixed
1898 1898
 	 */
1899
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1899
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1900 1900
 		//if we're in maintenance mode level 2, DON'T run any queries
1901 1901
 		//because level 2 indicates the database needs updating and
1902 1902
 		//is probably out of sync with the code
1903
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1903
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1904 1904
 			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")));
1905 1905
 		}
1906 1906
 		/** @type WPDB $wpdb */
1907 1907
 		global $wpdb;
1908
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1909
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1908
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1909
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1910 1910
 		}
1911
-		if( WP_DEBUG ){
1911
+		if (WP_DEBUG) {
1912 1912
 			$old_show_errors_value = $wpdb->show_errors;
1913
-			$wpdb->show_errors( FALSE );
1914
-		}
1915
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1916
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1917
-		if( WP_DEBUG ){
1918
-			$wpdb->show_errors( $old_show_errors_value );
1919
-			if( ! empty( $wpdb->last_error ) ){
1920
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1921
-			}elseif( $result === false ){
1922
-				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 ) ) );
1913
+			$wpdb->show_errors(FALSE);
1914
+		}
1915
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1916
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1917
+		if (WP_DEBUG) {
1918
+			$wpdb->show_errors($old_show_errors_value);
1919
+			if ( ! empty($wpdb->last_error)) {
1920
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1921
+			}elseif ($result === false) {
1922
+				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)));
1923 1923
 			}
1924
-		}elseif( $result === false ) {
1924
+		}elseif ($result === false) {
1925 1925
 			EE_Error::add_error(
1926 1926
 				sprintf(
1927
-					__( 'A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso' ),
1927
+					__('A database error has occurred. Turn on WP_DEBUG for more information.||A database error occurred doing wpdb method "%1$s", with arguments "%2$s". The error was "%3$s"', 'event_espresso'),
1928 1928
 					$wpdb_method,
1929
-					var_export( $arguments_to_provide, true ),
1929
+					var_export($arguments_to_provide, true),
1930 1930
 					$wpdb->last_error
1931 1931
 				),
1932 1932
 				__FILE__,
@@ -1948,26 +1948,26 @@  discard block
 block discarded – undo
1948 1948
 	 * @param array $arguments_to_provide
1949 1949
 	 * @return mixed
1950 1950
 	 */
1951
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1951
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1952 1952
 		/** @type WPDB $wpdb */
1953 1953
 		global $wpdb;
1954 1954
 		$wpdb->last_error = null;
1955
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1955
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1956 1956
 		// was there an error running the query? but we don't care on new activations
1957 1957
 		// (we're going to setup the DB anyway on new activations)
1958
-		if ( ( $result === false || ! empty( $wpdb->last_error ) )
1958
+		if (($result === false || ! empty($wpdb->last_error))
1959 1959
 			&& EE_System::instance()->detect_req_type() !== EE_System::req_type_new_activation
1960 1960
 		) {
1961
-			switch ( EEM_Base::$_db_verification_level ) {
1961
+			switch (EEM_Base::$_db_verification_level) {
1962 1962
 
1963 1963
 				case EEM_Base::db_verified_none :
1964 1964
 					// let's double-check core's DB
1965
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1965
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1966 1966
 					break;
1967 1967
 
1968 1968
 				case EEM_Base::db_verified_core :
1969 1969
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1970
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1970
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1971 1971
 					break;
1972 1972
 
1973 1973
 				case EEM_Base::db_verified_addons :
@@ -1975,11 +1975,11 @@  discard block
 block discarded – undo
1975 1975
 					return $result;
1976 1976
 					break;
1977 1977
 			}
1978
-			if ( ! empty( $error_message ) ) {
1979
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1980
-				trigger_error( $error_message );
1978
+			if ( ! empty($error_message)) {
1979
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1980
+				trigger_error($error_message);
1981 1981
 			}
1982
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1982
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1983 1983
 
1984 1984
 		}
1985 1985
 
@@ -1995,18 +1995,18 @@  discard block
 block discarded – undo
1995 1995
 	 * @param array $arguments_to_provide
1996 1996
 	 * @return string
1997 1997
 	 */
1998
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1998
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1999 1999
 		/** @type WPDB $wpdb */
2000 2000
 		global $wpdb;
2001 2001
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
2002 2002
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
2003 2003
 		$error_message = sprintf(
2004
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
2004
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
2005 2005
 			$wpdb->last_error,
2006 2006
 			$wpdb_method,
2007
-			json_encode( $arguments_to_provide )
2007
+			json_encode($arguments_to_provide)
2008 2008
 		);
2009
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
2009
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
2010 2010
 		return $error_message;
2011 2011
 	}
2012 2012
 
@@ -2019,16 +2019,16 @@  discard block
 block discarded – undo
2019 2019
 	 * @param $arguments_to_provide
2020 2020
 	 * @return string
2021 2021
 	 */
2022
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
2022
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
2023 2023
 		/** @type WPDB $wpdb */
2024 2024
 		global $wpdb;
2025 2025
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
2026 2026
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
2027 2027
 		$error_message = sprintf(
2028
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
2028
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
2029 2029
 			$wpdb->last_error,
2030 2030
 			$wpdb_method,
2031
-			json_encode( $arguments_to_provide )
2031
+			json_encode($arguments_to_provide)
2032 2032
 		);
2033 2033
 		EE_System::instance()->initialize_addons();
2034 2034
 		return $error_message;
@@ -2043,7 +2043,7 @@  discard block
 block discarded – undo
2043 2043
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2044 2044
 	 * @return string
2045 2045
 	 */
2046
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
2046
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
2047 2047
 		return " FROM ".$model_query_info->get_full_join_sql().
2048 2048
 				$model_query_info->get_where_sql().
2049 2049
 				$model_query_info->get_group_by_sql().
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
 	 * Set to easily debug the next X queries ran from this model.
2057 2057
 	 * @param int $count
2058 2058
 	 */
2059
-	public function show_next_x_db_queries($count = 1){
2059
+	public function show_next_x_db_queries($count = 1) {
2060 2060
 		$this->_show_next_x_db_queries = $count;
2061 2061
 	}
2062 2062
 
@@ -2065,8 +2065,8 @@  discard block
 block discarded – undo
2065 2065
 	/**
2066 2066
 	 * @param $sql_query
2067 2067
 	 */
2068
-	public function show_db_query_if_previously_requested($sql_query){
2069
-		if($this->_show_next_x_db_queries > 0){
2068
+	public function show_db_query_if_previously_requested($sql_query) {
2069
+		if ($this->_show_next_x_db_queries > 0) {
2070 2070
 			echo $sql_query;
2071 2071
 			$this->_show_next_x_db_queries--;
2072 2072
 		}
@@ -2090,9 +2090,9 @@  discard block
 block discarded – undo
2090 2090
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
2091 2091
 	 * @throws \EE_Error
2092 2092
 	 */
2093
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
2093
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
2094 2094
 		$relation_obj = $this->related_settings_for($relationName);
2095
-		return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2095
+		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2096 2096
 	}
2097 2097
 
2098 2098
 
@@ -2111,9 +2111,9 @@  discard block
 block discarded – undo
2111 2111
 	 * @throws \EE_Error
2112 2112
 	 * @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.
2113 2113
 	 */
2114
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2114
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
2115 2115
 		$relation_obj = $this->related_settings_for($relationName);
2116
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
2116
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
2117 2117
 	}
2118 2118
 
2119 2119
 
@@ -2126,9 +2126,9 @@  discard block
 block discarded – undo
2126 2126
 	 * @return \EE_Base_Class[]
2127 2127
 	 * @throws \EE_Error
2128 2128
 	 */
2129
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
2129
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2130 2130
 		$relation_obj = $this->related_settings_for($relationName);
2131
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2131
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2132 2132
 	}
2133 2133
 
2134 2134
 
@@ -2144,10 +2144,10 @@  discard block
 block discarded – undo
2144 2144
 	 * @return EE_Base_Class[]
2145 2145
 	 * @throws \EE_Error
2146 2146
 	 */
2147
-	public function get_all_related($id_or_obj, $model_name, $query_params = null){
2147
+	public function get_all_related($id_or_obj, $model_name, $query_params = null) {
2148 2148
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2149 2149
 		$relation_settings = $this->related_settings_for($model_name);
2150
-		return $relation_settings->get_all_related($model_obj,$query_params);
2150
+		return $relation_settings->get_all_related($model_obj, $query_params);
2151 2151
 	}
2152 2152
 
2153 2153
 
@@ -2164,10 +2164,10 @@  discard block
 block discarded – undo
2164 2164
 	 * @return int how many deleted
2165 2165
 	 * @throws \EE_Error
2166 2166
 	 */
2167
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2167
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2168 2168
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2169 2169
 		$relation_settings = $this->related_settings_for($model_name);
2170
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2170
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2171 2171
 	}
2172 2172
 
2173 2173
 
@@ -2184,10 +2184,10 @@  discard block
 block discarded – undo
2184 2184
 	 * @return int how many deleted
2185 2185
 	 * @throws \EE_Error
2186 2186
 	 */
2187
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2187
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2188 2188
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2189 2189
 		$relation_settings = $this->related_settings_for($model_name);
2190
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2190
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2191 2191
 	}
2192 2192
 
2193 2193
 
@@ -2204,17 +2204,17 @@  discard block
 block discarded – undo
2204 2204
 	 * @return int
2205 2205
 	 * @throws \EE_Error
2206 2206
 	 */
2207
-	public function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2207
+	public function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2208 2208
 		$related_model = $this->get_related_model_obj($model_name);
2209 2209
 		//we're just going to use the query params on the related model's normal get_all query,
2210 2210
 		//except add a condition to say to match the current mod
2211
-		if( ! isset($query_params['default_where_conditions'])){
2212
-			$query_params['default_where_conditions']='none';
2211
+		if ( ! isset($query_params['default_where_conditions'])) {
2212
+			$query_params['default_where_conditions'] = 'none';
2213 2213
 		}
2214 2214
 		$this_model_name = $this->get_this_model_name();
2215 2215
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2216
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2217
-		return $related_model->count($query_params,$field_to_count,$distinct);
2216
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2217
+		return $related_model->count($query_params, $field_to_count, $distinct);
2218 2218
 	}
2219 2219
 
2220 2220
 
@@ -2230,21 +2230,21 @@  discard block
 block discarded – undo
2230 2230
 	 * @return float
2231 2231
 	 * @throws \EE_Error
2232 2232
 	 */
2233
-	public function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2233
+	public function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2234 2234
 		$related_model = $this->get_related_model_obj($model_name);
2235
-		if( ! is_array( $query_params ) ){
2236
-			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' );
2235
+		if ( ! is_array($query_params)) {
2236
+			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');
2237 2237
 			$query_params = array();
2238 2238
 		}
2239 2239
 		//we're just going to use the query params on the related model's normal get_all query,
2240 2240
 		//except add a condition to say to match the current mod
2241
-		if( ! isset($query_params['default_where_conditions'])){
2242
-			$query_params['default_where_conditions']='none';
2241
+		if ( ! isset($query_params['default_where_conditions'])) {
2242
+			$query_params['default_where_conditions'] = 'none';
2243 2243
 		}
2244 2244
 		$this_model_name = $this->get_this_model_name();
2245 2245
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2246
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2247
-		return $related_model->sum($query_params,$field_to_sum);
2246
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2247
+		return $related_model->sum($query_params, $field_to_sum);
2248 2248
 	}
2249 2249
 
2250 2250
 
@@ -2258,12 +2258,12 @@  discard block
 block discarded – undo
2258 2258
 	 * @return EE_Base_Class
2259 2259
 	 * @throws \EE_Error
2260 2260
 	 */
2261
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2262
-		$query_params['limit']=1;
2263
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2264
-		if( $results ){
2261
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2262
+		$query_params['limit'] = 1;
2263
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2264
+		if ($results) {
2265 2265
 			return array_shift($results);
2266
-		}else{
2266
+		} else {
2267 2267
 			return null;
2268 2268
 		}
2269 2269
 
@@ -2273,8 +2273,8 @@  discard block
 block discarded – undo
2273 2273
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2274 2274
 	 * @return string
2275 2275
 	 */
2276
-	public function get_this_model_name(){
2277
-		return str_replace("EEM_","",get_class($this));
2276
+	public function get_this_model_name() {
2277
+		return str_replace("EEM_", "", get_class($this));
2278 2278
 	}
2279 2279
 
2280 2280
 	/**
@@ -2282,14 +2282,14 @@  discard block
 block discarded – undo
2282 2282
 	 * @return EE_Any_Foreign_Model_Name_Field
2283 2283
 	 * @throws EE_Error
2284 2284
 	 */
2285
-	public function get_field_containing_related_model_name(){
2286
-		foreach($this->field_settings(true) as $field){
2287
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2285
+	public function get_field_containing_related_model_name() {
2286
+		foreach ($this->field_settings(true) as $field) {
2287
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2288 2288
 				$field_with_model_name = $field;
2289 2289
 			}
2290 2290
 		}
2291
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2292
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2291
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2292
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2293 2293
 		}
2294 2294
 		return $field_with_model_name;
2295 2295
 	}
@@ -2310,19 +2310,19 @@  discard block
 block discarded – undo
2310 2310
 	 * @return int new primary key on main table that got inserted
2311 2311
 	 * @throws EE_Error
2312 2312
 	 */
2313
-	public function insert($field_n_values){
2313
+	public function insert($field_n_values) {
2314 2314
 		/**
2315 2315
 		 * Filters the fields and their values before inserting an item using the models
2316 2316
 		 * @param array $fields_n_values keys are the fields and values are their new values
2317 2317
 		 * @param EEM_Base $model the model used
2318 2318
 		 */
2319
-		$field_n_values = (array)apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2320
-		if($this->_satisfies_unique_indexes($field_n_values)){
2319
+		$field_n_values = (array) apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2320
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2321 2321
 			$main_table = $this->_get_main_table();
2322 2322
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2323
-			if( $new_id !== false ) {
2324
-				foreach($this->_get_other_tables() as $other_table){
2325
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2323
+			if ($new_id !== false) {
2324
+				foreach ($this->_get_other_tables() as $other_table) {
2325
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2326 2326
 				}
2327 2327
 			}
2328 2328
 			/**
@@ -2332,9 +2332,9 @@  discard block
 block discarded – undo
2332 2332
 			 * @param array $fields_n_values fields and their values
2333 2333
 			 * @param int|string the ID of the newly-inserted model object
2334 2334
 			 */
2335
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2335
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2336 2336
 			return $new_id;
2337
-		}else{
2337
+		} else {
2338 2338
 			return FALSE;
2339 2339
 		}
2340 2340
 	}
@@ -2349,10 +2349,10 @@  discard block
 block discarded – undo
2349 2349
 	 * @return boolean
2350 2350
 	 * @throws \EE_Error
2351 2351
 	 */
2352
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2353
-		foreach($this->unique_indexes() as $index_name => $index){
2352
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2353
+		foreach ($this->unique_indexes() as $index_name => $index) {
2354 2354
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2355
-			if($this->exists(array($uniqueness_where_params))){
2355
+			if ($this->exists(array($uniqueness_where_params))) {
2356 2356
 				EE_Error::add_error(
2357 2357
 					sprintf(
2358 2358
 						__(
@@ -2362,8 +2362,8 @@  discard block
 block discarded – undo
2362 2362
 						$action,
2363 2363
 						$this->_get_class_name(),
2364 2364
 						$index_name,
2365
-						implode( ",", $index->field_names() ),
2366
-						http_build_query( $uniqueness_where_params )
2365
+						implode(",", $index->field_names()),
2366
+						http_build_query($uniqueness_where_params)
2367 2367
 					),
2368 2368
 					__FILE__,
2369 2369
 					__FUNCTION__,
@@ -2389,37 +2389,37 @@  discard block
 block discarded – undo
2389 2389
 	 * @throws EE_Error
2390 2390
 	 * @return EE_Base_Class
2391 2391
 	 */
2392
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2393
-		if($obj_or_fields_array instanceof EE_Base_Class){
2392
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2393
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2394 2394
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2395
-		}elseif( is_array($obj_or_fields_array)){
2395
+		}elseif (is_array($obj_or_fields_array)) {
2396 2396
 			$fields_n_values = $obj_or_fields_array;
2397
-		}else{
2397
+		} else {
2398 2398
 			throw new EE_Error(
2399 2399
 				sprintf(
2400 2400
 					__(
2401 2401
 						"%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d",
2402 2402
 						"event_espresso"
2403 2403
 					),
2404
-					get_class( $this ),
2404
+					get_class($this),
2405 2405
 					$obj_or_fields_array
2406 2406
 				)
2407 2407
 			);
2408 2408
 		}
2409 2409
 		$query_params = array();
2410
-		if( $this->has_primary_key_field() &&
2411
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2412
-				isset($fields_n_values[$this->primary_key_name()])){
2410
+		if ($this->has_primary_key_field() &&
2411
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2412
+				isset($fields_n_values[$this->primary_key_name()])) {
2413 2413
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2414 2414
 		}
2415
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2415
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2416 2416
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2417 2417
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2418 2418
 		}
2419 2419
 		//if there is nothing to base this search on, then we shouldn't find anything
2420
-		if( empty( $query_params ) ){
2420
+		if (empty($query_params)) {
2421 2421
 			return array();
2422
-		}else{
2422
+		} else {
2423 2423
 			return $this->get_one($query_params);
2424 2424
 		}
2425 2425
 	}
@@ -2433,7 +2433,7 @@  discard block
 block discarded – undo
2433 2433
 	 * @return boolean
2434 2434
 	 * @throws \EE_Error
2435 2435
 	 */
2436
-	public function exists($query_params){
2436
+	public function exists($query_params) {
2437 2437
 		$query_params['limit'] = 1;
2438 2438
 		return $this->count($query_params) > 0;
2439 2439
 	}
@@ -2447,7 +2447,7 @@  discard block
 block discarded – undo
2447 2447
 	 * @return boolean
2448 2448
 	 * @throws \EE_Error
2449 2449
 	 */
2450
-	public function exists_by_ID($id){
2450
+	public function exists_by_ID($id) {
2451 2451
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2452 2452
 	}
2453 2453
 
@@ -2467,45 +2467,45 @@  discard block
 block discarded – undo
2467 2467
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2468 2468
 	 * @return int ID of new row inserted, or FALSE on failure
2469 2469
 	 */
2470
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2470
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2471 2471
 		global $wpdb;
2472 2472
 		$insertion_col_n_values = array();
2473 2473
 		$format_for_insertion = array();
2474 2474
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2475
-		foreach($fields_on_table as $field_name => $field_obj){
2475
+		foreach ($fields_on_table as $field_name => $field_obj) {
2476 2476
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2477
-			if($field_obj->is_auto_increment()){
2477
+			if ($field_obj->is_auto_increment()) {
2478 2478
 				continue;
2479 2479
 			}
2480 2480
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2481 2481
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2482
-			if( $prepared_value !== NULL ){
2483
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2482
+			if ($prepared_value !== NULL) {
2483
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2484 2484
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2485 2485
 			}
2486 2486
 		}
2487 2487
 
2488
-		if($table instanceof EE_Secondary_Table && $new_id){
2488
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2489 2489
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2490 2490
 			//so add the fk to the main table as a column
2491 2491
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2492
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2492
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2493 2493
 		}
2494 2494
 		//insert the new entry
2495
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2496
-		if( $result === false ) {
2495
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2496
+		if ($result === false) {
2497 2497
 			return false;
2498 2498
 		}
2499 2499
 		//ok, now what do we return for the ID of the newly-inserted thing?
2500
-		if($this->has_primary_key_field()){
2501
-			if($this->get_primary_key_field()->is_auto_increment()){
2500
+		if ($this->has_primary_key_field()) {
2501
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2502 2502
 				return $wpdb->insert_id;
2503
-			}else{
2503
+			} else {
2504 2504
 				//it's not an auto-increment primary key, so
2505 2505
 				//it must have been supplied
2506 2506
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2507 2507
 			}
2508
-		}else{
2508
+		} else {
2509 2509
 			//we can't return a  primary key because there is none. instead return
2510 2510
 			//a unique string indicating this model
2511 2511
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2524,15 +2524,15 @@  discard block
 block discarded – undo
2524 2524
 	 * @return mixed string|int|float depending on what the table column will be expecting
2525 2525
 	 * @throws \EE_Error
2526 2526
 	 */
2527
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2527
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2528 2528
 		//if this field doesn't allow nullable, don't allow it
2529
-		if( ! $field_obj->is_nullable() && (
2530
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2531
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2532
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2529
+		if ( ! $field_obj->is_nullable() && (
2530
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2531
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2532
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2533 2533
 		}
2534
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2535
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2534
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2535
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2536 2536
 	}
2537 2537
 
2538 2538
 
@@ -2544,9 +2544,9 @@  discard block
 block discarded – undo
2544 2544
 	 * @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
2545 2545
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2546 2546
 	 */
2547
-	private function _prepare_value_for_use_in_db($value, $field){
2548
-		if($field && $field instanceof EE_Model_Field_Base){
2549
-			switch( $this->_values_already_prepared_by_model_object ){
2547
+	private function _prepare_value_for_use_in_db($value, $field) {
2548
+		if ($field && $field instanceof EE_Model_Field_Base) {
2549
+			switch ($this->_values_already_prepared_by_model_object) {
2550 2550
 				/** @noinspection PhpMissingBreakStatementInspection */
2551 2551
 				case self::not_prepared_by_model_object:
2552 2552
 					$value = $field->prepare_for_set($value);
@@ -2557,7 +2557,7 @@  discard block
 block discarded – undo
2557 2557
 					//leave the value alone
2558 2558
 			}
2559 2559
 			return $value;
2560
-		}else{
2560
+		} else {
2561 2561
 			return $value;
2562 2562
 		}
2563 2563
 	}
@@ -2567,13 +2567,13 @@  discard block
 block discarded – undo
2567 2567
 	 * @return EE_Primary_Table
2568 2568
 	 * @throws EE_Error
2569 2569
 	 */
2570
-	protected function _get_main_table(){
2571
-		foreach($this->_tables as $table){
2572
-			if($table instanceof EE_Primary_Table){
2570
+	protected function _get_main_table() {
2571
+		foreach ($this->_tables as $table) {
2572
+			if ($table instanceof EE_Primary_Table) {
2573 2573
 				return $table;
2574 2574
 			}
2575 2575
 		}
2576
-		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)));
2576
+		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)));
2577 2577
 	}
2578 2578
 
2579 2579
 
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
 	 */
2597 2597
 	public function second_table() {
2598 2598
 		// grab second table from tables array
2599
-		$second_table = end( $this->_tables );
2599
+		$second_table = end($this->_tables);
2600 2600
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2601 2601
 	}
2602 2602
 
@@ -2609,8 +2609,8 @@  discard block
 block discarded – undo
2609 2609
 	 * @param string $table_alias
2610 2610
 	 * @return EE_Primary_Table | EE_Secondary_Table
2611 2611
 	 */
2612
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2613
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2612
+	public function get_table_obj_by_alias($table_alias = '') {
2613
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2614 2614
 	}
2615 2615
 
2616 2616
 
@@ -2619,10 +2619,10 @@  discard block
 block discarded – undo
2619 2619
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2620 2620
 	 * @return EE_Secondary_Table[]
2621 2621
 	 */
2622
-	protected function _get_other_tables(){
2623
-		$other_tables =array();
2624
-		foreach($this->_tables as $table_alias => $table){
2625
-			if($table instanceof EE_Secondary_Table){
2622
+	protected function _get_other_tables() {
2623
+		$other_tables = array();
2624
+		foreach ($this->_tables as $table_alias => $table) {
2625
+			if ($table instanceof EE_Secondary_Table) {
2626 2626
 				$other_tables[$table_alias] = $table;
2627 2627
 			}
2628 2628
 		}
@@ -2634,7 +2634,7 @@  discard block
 block discarded – undo
2634 2634
 	 * @param string $table_alias, array key in EEM_Base::_tables
2635 2635
 	 * @return EE_Model_Field_Base[]
2636 2636
 	 */
2637
-	public function _get_fields_for_table($table_alias){
2637
+	public function _get_fields_for_table($table_alias) {
2638 2638
 		return $this->_fields[$table_alias];
2639 2639
 	}
2640 2640
 
@@ -2650,19 +2650,19 @@  discard block
 block discarded – undo
2650 2650
 	 * @return EE_Model_Query_Info_Carrier
2651 2651
 	 * @throws \EE_Error
2652 2652
 	 */
2653
-	public function _extract_related_models_from_query($query_params){
2653
+	public function _extract_related_models_from_query($query_params) {
2654 2654
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2655
-		if ( array_key_exists( 0, $query_params ) ) {
2656
-			$this->_extract_related_models_from_sub_params_array_keys( $query_params[0], $query_info_carrier, 0 );
2655
+		if (array_key_exists(0, $query_params)) {
2656
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2657 2657
 		}
2658
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2659
-			if ( is_array( $query_params['group_by'] ) ) {
2658
+		if (array_key_exists('group_by', $query_params)) {
2659
+			if (is_array($query_params['group_by'])) {
2660 2660
 				$this->_extract_related_models_from_sub_params_array_values(
2661 2661
 					$query_params['group_by'],
2662 2662
 					$query_info_carrier,
2663 2663
 					'group_by'
2664 2664
 				);
2665
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2665
+			} elseif ( ! empty ($query_params['group_by'])) {
2666 2666
 				$this->_extract_related_model_info_from_query_param(
2667 2667
 					$query_params['group_by'],
2668 2668
 					$query_info_carrier,
@@ -2670,21 +2670,21 @@  discard block
 block discarded – undo
2670 2670
 				);
2671 2671
 			}
2672 2672
 		}
2673
-		if ( array_key_exists( 'having', $query_params ) ) {
2673
+		if (array_key_exists('having', $query_params)) {
2674 2674
 			$this->_extract_related_models_from_sub_params_array_keys(
2675 2675
 				$query_params[0],
2676 2676
 				$query_info_carrier,
2677 2677
 				'having'
2678 2678
 			);
2679 2679
 		}
2680
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2681
-			if ( is_array( $query_params['order_by'] ) ) {
2680
+		if (array_key_exists('order_by', $query_params)) {
2681
+			if (is_array($query_params['order_by'])) {
2682 2682
 				$this->_extract_related_models_from_sub_params_array_keys(
2683 2683
 					$query_params['order_by'],
2684 2684
 					$query_info_carrier,
2685 2685
 					'order_by'
2686 2686
 				);
2687
-			} elseif ( ! empty( $query_params['order_by'] ) ) {
2687
+			} elseif ( ! empty($query_params['order_by'])) {
2688 2688
 				$this->_extract_related_model_info_from_query_param(
2689 2689
 					$query_params['order_by'],
2690 2690
 					$query_info_carrier,
@@ -2692,7 +2692,7 @@  discard block
 block discarded – undo
2692 2692
 				);
2693 2693
 			}
2694 2694
 		}
2695
-		if ( array_key_exists( 'force_join', $query_params ) ) {
2695
+		if (array_key_exists('force_join', $query_params)) {
2696 2696
 			$this->_extract_related_models_from_sub_params_array_values(
2697 2697
 				$query_params['force_join'],
2698 2698
 				$query_info_carrier,
@@ -2710,34 +2710,34 @@  discard block
 block discarded – undo
2710 2710
 	 * @throws EE_Error
2711 2711
 	 * @return \EE_Model_Query_Info_Carrier
2712 2712
 	 */
2713
-	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){
2714
-		if (!empty($sub_query_params)){
2713
+	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) {
2714
+		if ( ! empty($sub_query_params)) {
2715 2715
 			$sub_query_params = (array) $sub_query_params;
2716
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2716
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2717 2717
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2718
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2718
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2719 2719
 
2720 2720
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2721 2721
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2722 2722
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2723 2723
 				//of array('Registration.TXN_ID'=>23)
2724 2724
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2725
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2726
-					if (! is_array($possibly_array_of_params)){
2725
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2726
+					if ( ! is_array($possibly_array_of_params)) {
2727 2727
 						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"),
2728
-							$param,$possibly_array_of_params));
2729
-					}else{
2730
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2728
+							$param, $possibly_array_of_params));
2729
+					} else {
2730
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2731 2731
 					}
2732
-				}elseif($query_param_type === 0 //ie WHERE
2732
+				}elseif ($query_param_type === 0 //ie WHERE
2733 2733
 						&& is_array($possibly_array_of_params)
2734 2734
 						&& isset($possibly_array_of_params[2])
2735
-						&& $possibly_array_of_params[2] == true){
2735
+						&& $possibly_array_of_params[2] == true) {
2736 2736
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2737 2737
 					//indicating that $possible_array_of_params[1] is actually a field name,
2738 2738
 					//from which we should extract query parameters!
2739
-					if( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1] ) ) {
2740
-						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)));
2739
+					if ( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1])) {
2740
+						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)));
2741 2741
 					}
2742 2742
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2743 2743
 				}
@@ -2756,14 +2756,14 @@  discard block
 block discarded – undo
2756 2756
 	 * @throws EE_Error
2757 2757
 	 * @return \EE_Model_Query_Info_Carrier
2758 2758
 	 */
2759
-	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){
2760
-		if (!empty($sub_query_params)){
2761
-			if(!is_array($sub_query_params)){
2762
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2759
+	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) {
2760
+		if ( ! empty($sub_query_params)) {
2761
+			if ( ! is_array($sub_query_params)) {
2762
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2763 2763
 			}
2764
-			foreach($sub_query_params as $param){
2764
+			foreach ($sub_query_params as $param) {
2765 2765
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2766
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2766
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2767 2767
 			}
2768 2768
 		}
2769 2769
 		return $model_query_info_carrier;
@@ -2782,8 +2782,8 @@  discard block
 block discarded – undo
2782 2782
 	 * @throws EE_Error
2783 2783
 	 * @return EE_Model_Query_Info_Carrier
2784 2784
 	 */
2785
-	public function _create_model_query_info_carrier($query_params){
2786
-		if ( ! is_array( $query_params ) ) {
2785
+	public function _create_model_query_info_carrier($query_params) {
2786
+		if ( ! is_array($query_params)) {
2787 2787
 			EE_Error::doing_it_wrong(
2788 2788
 				'EEM_Base::_create_model_query_info_carrier',
2789 2789
 				sprintf(
@@ -2791,16 +2791,16 @@  discard block
 block discarded – undo
2791 2791
 						'$query_params should be an array, you passed a variable of type %s',
2792 2792
 						'event_espresso'
2793 2793
 					),
2794
-					gettype( $query_params )
2794
+					gettype($query_params)
2795 2795
 				),
2796 2796
 				'4.6.0'
2797 2797
 			);
2798 2798
 			$query_params = array();
2799 2799
 		}
2800
-		$where_query_params = isset( $query_params[0] ) ? $query_params[0] : array();
2800
+		$where_query_params = isset($query_params[0]) ? $query_params[0] : array();
2801 2801
 		//first check if we should alter the query to account for caps or not
2802 2802
 		//because the caps might require us to do extra joins
2803
-		if ( isset( $query_params['caps'] ) && $query_params['caps'] !== 'none' ) {
2803
+		if (isset($query_params['caps']) && $query_params['caps'] !== 'none') {
2804 2804
 			$query_params[0] = $where_query_params = array_replace_recursive(
2805 2805
 				$where_query_params,
2806 2806
 				$this->caps_where_conditions(
@@ -2808,10 +2808,10 @@  discard block
 block discarded – undo
2808 2808
 				)
2809 2809
 			);
2810 2810
 		}
2811
-		$query_object = $this->_extract_related_models_from_query( $query_params );
2811
+		$query_object = $this->_extract_related_models_from_query($query_params);
2812 2812
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2813
-		foreach ( $where_query_params as $key => $value ) {
2814
-			if ( is_int( $key ) ) {
2813
+		foreach ($where_query_params as $key => $value) {
2814
+			if (is_int($key)) {
2815 2815
 				throw new EE_Error(
2816 2816
 					sprintf(
2817 2817
 						__(
@@ -2819,16 +2819,16 @@  discard block
 block discarded – undo
2819 2819
 							"event_espresso"
2820 2820
 						),
2821 2821
 						$key,
2822
-						var_export( $value, true ),
2823
-						var_export( $query_params, true ),
2824
-						get_class( $this )
2822
+						var_export($value, true),
2823
+						var_export($query_params, true),
2824
+						get_class($this)
2825 2825
 					)
2826 2826
 				);
2827 2827
 			}
2828 2828
 		}
2829 2829
 		if (
2830
-			array_key_exists( 'default_where_conditions', $query_params )
2831
-			&& ! empty( $query_params['default_where_conditions'] )
2830
+			array_key_exists('default_where_conditions', $query_params)
2831
+			&& ! empty($query_params['default_where_conditions'])
2832 2832
 		) {
2833 2833
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2834 2834
 		} else {
@@ -2842,13 +2842,13 @@  discard block
 block discarded – undo
2842 2842
 			),
2843 2843
 			$where_query_params
2844 2844
 		);
2845
-		$query_object->set_where_sql( $this->_construct_where_clause( $where_query_params ) );
2845
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2846 2846
 		// if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.
2847 2847
 		// So we need to setup a subquery and use that for the main join.
2848 2848
 		// Note for now this only works on the primary table for the model.
2849 2849
 		// So for instance, you could set the limit array like this:
2850 2850
 		// array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2851
-		if ( array_key_exists( 'on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] ) ) {
2851
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2852 2852
 			$query_object->set_main_model_join_sql(
2853 2853
 				$this->_construct_limit_join_select(
2854 2854
 					$query_params['on_join_limit'][0],
@@ -2857,40 +2857,40 @@  discard block
 block discarded – undo
2857 2857
 			);
2858 2858
 		}
2859 2859
 		//set limit
2860
-		if ( array_key_exists( 'limit', $query_params ) ) {
2861
-			if ( is_array( $query_params['limit'] ) ) {
2862
-				if ( ! isset( $query_params['limit'][0], $query_params['limit'][1] ) ) {
2860
+		if (array_key_exists('limit', $query_params)) {
2861
+			if (is_array($query_params['limit'])) {
2862
+				if ( ! isset($query_params['limit'][0], $query_params['limit'][1])) {
2863 2863
 					$e = sprintf(
2864 2864
 						__(
2865 2865
 							"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)",
2866 2866
 							"event_espresso"
2867 2867
 						),
2868
-						http_build_query( $query_params['limit'] )
2868
+						http_build_query($query_params['limit'])
2869 2869
 					);
2870
-					throw new EE_Error( $e . "|" . $e );
2870
+					throw new EE_Error($e."|".$e);
2871 2871
 				}
2872 2872
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2873
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'][0] . "," . $query_params['limit'][1] );
2874
-			} elseif ( ! empty ( $query_params['limit'] ) ) {
2875
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'] );
2873
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2874
+			} elseif ( ! empty ($query_params['limit'])) {
2875
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit']);
2876 2876
 			}
2877 2877
 		}
2878 2878
 		//set order by
2879
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2880
-			if ( is_array( $query_params['order_by'] ) ) {
2879
+		if (array_key_exists('order_by', $query_params)) {
2880
+			if (is_array($query_params['order_by'])) {
2881 2881
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2882 2882
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2883 2883
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2884
-				if ( array_key_exists( 'order', $query_params ) ) {
2884
+				if (array_key_exists('order', $query_params)) {
2885 2885
 					throw new EE_Error(
2886 2886
 						sprintf(
2887 2887
 							__(
2888 2888
 								"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 ",
2889 2889
 								"event_espresso"
2890 2890
 							),
2891
-							get_class( $this ),
2892
-							implode( ", ", array_keys( $query_params['order_by'] ) ),
2893
-							implode( ", ", $query_params['order_by'] ),
2891
+							get_class($this),
2892
+							implode(", ", array_keys($query_params['order_by'])),
2893
+							implode(", ", $query_params['order_by']),
2894 2894
 							$query_params['order']
2895 2895
 						)
2896 2896
 					);
@@ -2902,57 +2902,57 @@  discard block
 block discarded – undo
2902 2902
 				);
2903 2903
 				//assume it's an array of fields to order by
2904 2904
 				$order_array = array();
2905
-				foreach ( $query_params['order_by'] as $field_name_to_order_by => $order ) {
2906
-					$order = $this->_extract_order( $order );
2907
-					$order_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_order_by ) . SP . $order;
2905
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2906
+					$order = $this->_extract_order($order);
2907
+					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2908 2908
 				}
2909
-				$query_object->set_order_by_sql( " ORDER BY " . implode( ",", $order_array ) );
2910
-			} elseif ( ! empty ( $query_params['order_by'] ) ) {
2909
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2910
+			} elseif ( ! empty ($query_params['order_by'])) {
2911 2911
 				$this->_extract_related_model_info_from_query_param(
2912 2912
 					$query_params['order_by'],
2913 2913
 					$query_object,
2914 2914
 					'order',
2915 2915
 					$query_params['order_by']
2916 2916
 				);
2917
-				$order = isset( $query_params['order'] )
2918
-					? $this->_extract_order( $query_params['order'] )
2917
+				$order = isset($query_params['order'])
2918
+					? $this->_extract_order($query_params['order'])
2919 2919
 					: 'DESC';
2920 2920
 				$query_object->set_order_by_sql(
2921
-					" ORDER BY " . $this->_deduce_column_name_from_query_param( $query_params['order_by'] ) . SP . $order
2921
+					" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order
2922 2922
 				);
2923 2923
 			}
2924 2924
 		}
2925 2925
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2926
-		if ( ! array_key_exists( 'order_by', $query_params )
2927
-		     && array_key_exists( 'order', $query_params )
2928
-		     && ! empty( $query_params['order'] )
2926
+		if ( ! array_key_exists('order_by', $query_params)
2927
+		     && array_key_exists('order', $query_params)
2928
+		     && ! empty($query_params['order'])
2929 2929
 		) {
2930 2930
 			$pk_field = $this->get_primary_key_field();
2931
-			$order = $this->_extract_order( $query_params['order'] );
2932
-			$query_object->set_order_by_sql( " ORDER BY " . $pk_field->get_qualified_column() . SP . $order );
2931
+			$order = $this->_extract_order($query_params['order']);
2932
+			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2933 2933
 		}
2934 2934
 		//set group by
2935
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2936
-			if ( is_array( $query_params['group_by'] ) ) {
2935
+		if (array_key_exists('group_by', $query_params)) {
2936
+			if (is_array($query_params['group_by'])) {
2937 2937
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2938 2938
 				$group_by_array = array();
2939
-				foreach ( $query_params['group_by'] as $field_name_to_group_by ) {
2940
-					$group_by_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_group_by );
2939
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2940
+					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2941 2941
 				}
2942
-				$query_object->set_group_by_sql( " GROUP BY " . implode( ", ", $group_by_array ) );
2943
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2942
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2943
+			} elseif ( ! empty ($query_params['group_by'])) {
2944 2944
 				$query_object->set_group_by_sql(
2945
-					" GROUP BY " . $this->_deduce_column_name_from_query_param( $query_params['group_by'] )
2945
+					" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by'])
2946 2946
 				);
2947 2947
 			}
2948 2948
 		}
2949 2949
 		//set having
2950
-		if ( array_key_exists( 'having', $query_params ) && $query_params['having'] ) {
2951
-			$query_object->set_having_sql( $this->_construct_having_clause( $query_params['having'] ) );
2950
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2951
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2952 2952
 		}
2953 2953
 		//now, just verify they didn't pass anything wack
2954
-		foreach ( $query_params as $query_key => $query_value ) {
2955
-			if ( ! in_array( $query_key, $this->_allowed_query_params, true ) ) {
2954
+		foreach ($query_params as $query_key => $query_value) {
2955
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2956 2956
 				throw new EE_Error(
2957 2957
 					sprintf(
2958 2958
 						__(
@@ -2960,16 +2960,16 @@  discard block
 block discarded – undo
2960 2960
 							'event_espresso'
2961 2961
 						),
2962 2962
 						$query_key,
2963
-						get_class( $this ),
2963
+						get_class($this),
2964 2964
 //						print_r( $this->_allowed_query_params, TRUE )
2965
-						implode( ',', $this->_allowed_query_params )
2965
+						implode(',', $this->_allowed_query_params)
2966 2966
 					)
2967 2967
 				);
2968 2968
 			}
2969 2969
 		}
2970 2970
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2971
-		if ( empty( $main_model_join_sql ) ) {
2972
-			$query_object->set_main_model_join_sql( $this->_construct_internal_join() );
2971
+		if (empty($main_model_join_sql)) {
2972
+			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2973 2973
 		}
2974 2974
 		return $query_object;
2975 2975
 	}
@@ -2984,17 +2984,17 @@  discard block
 block discarded – undo
2984 2984
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2985 2985
 	 * @throws \EE_Error
2986 2986
 	 */
2987
-	public function caps_where_conditions( $context = self::caps_read ) {
2988
-		EEM_Base::verify_is_valid_cap_context( $context );
2987
+	public function caps_where_conditions($context = self::caps_read) {
2988
+		EEM_Base::verify_is_valid_cap_context($context);
2989 2989
 		$cap_where_conditions = array();
2990
-		$cap_restrictions = $this->caps_missing( $context );
2990
+		$cap_restrictions = $this->caps_missing($context);
2991 2991
 		/**
2992 2992
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2993 2993
 		 */
2994
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2995
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2994
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2995
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2996 2996
 		}
2997
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2997
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2998 2998
 	}
2999 2999
 
3000 3000
 	/**
@@ -3004,11 +3004,11 @@  discard block
 block discarded – undo
3004 3004
 	 * @return string either ASC, asc, DESC or desc
3005 3005
 	 * @throws EE_Error
3006 3006
 	 */
3007
-	private function _extract_order($should_be_order_string){
3008
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
3007
+	private function _extract_order($should_be_order_string) {
3008
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
3009 3009
 			return $should_be_order_string;
3010
-		}else{
3011
-			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));
3010
+		} else {
3011
+			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));
3012 3012
 		}
3013 3013
 	}
3014 3014
 
@@ -3026,7 +3026,7 @@  discard block
 block discarded – undo
3026 3026
 	 * @throws EE_Error
3027 3027
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
3028 3028
 	 */
3029
-	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()){
3029
+	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()) {
3030 3030
 		$allowed_used_default_where_conditions_values = array(
3031 3031
 				'all',
3032 3032
 				'this_model_only',
@@ -3034,17 +3034,17 @@  discard block
 block discarded – undo
3034 3034
 				'minimum',
3035 3035
 				'none'
3036 3036
 			);
3037
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
3038
-			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)));
3037
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
3038
+			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)));
3039 3039
 		}
3040 3040
 		$universal_query_params = array();
3041
-		if( $use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only' ){
3041
+		if ($use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only') {
3042 3042
 			$universal_query_params = $this->_get_default_where_conditions();
3043
-		} else if( $use_default_where_conditions === 'minimum' ) {
3043
+		} else if ($use_default_where_conditions === 'minimum') {
3044 3044
 			$universal_query_params = $this->_get_minimum_where_conditions();
3045 3045
 		}
3046
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
3047
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
3046
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
3047
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
3048 3048
 				$related_model = $this->get_related_model_obj($model_name);
3049 3049
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
3050 3050
 				$overrides = $this->_override_defaults_or_make_null_friendly(
@@ -3077,20 +3077,20 @@  discard block
 block discarded – undo
3077 3077
 	 * @return array like EEM_Base::get_all's $query_params[0]
3078 3078
 	 * @throws \EE_Error
3079 3079
 	 */
3080
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
3080
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
3081 3081
 		$null_friendly_where_conditions = array();
3082 3082
 		$none_overridden = true;
3083 3083
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
3084 3084
 
3085
-		foreach($default_where_conditions as $key => $val){
3086
-			if( isset($provided_where_conditions[$key])){
3085
+		foreach ($default_where_conditions as $key => $val) {
3086
+			if (isset($provided_where_conditions[$key])) {
3087 3087
 				$none_overridden = false;
3088
-			}else{
3088
+			} else {
3089 3089
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
3090 3090
 			}
3091 3091
 		}
3092
-		if( $none_overridden && $default_where_conditions){
3093
-			if($model->has_primary_key_field()){
3092
+		if ($none_overridden && $default_where_conditions) {
3093
+			if ($model->has_primary_key_field()) {
3094 3094
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
3095 3095
 			}/*else{
3096 3096
 				//@todo NO PK, use other defaults
@@ -3107,8 +3107,8 @@  discard block
 block discarded – undo
3107 3107
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3108 3108
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3109 3109
 	 */
3110
-	private function _get_default_where_conditions($model_relation_path = null){
3111
-		if ( $this->_ignore_where_strategy ){
3110
+	private function _get_default_where_conditions($model_relation_path = null) {
3111
+		if ($this->_ignore_where_strategy) {
3112 3112
 			return array();
3113 3113
 		}
3114 3114
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3122,8 +3122,8 @@  discard block
 block discarded – undo
3122 3122
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3123 3123
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3124 3124
 	 */
3125
-	protected function _get_minimum_where_conditions($model_relation_path = null){
3126
-		if ( $this->_ignore_where_strategy ){
3125
+	protected function _get_minimum_where_conditions($model_relation_path = null) {
3126
+		if ($this->_ignore_where_strategy) {
3127 3127
 			return array();
3128 3128
 		}
3129 3129
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3139,16 +3139,16 @@  discard block
 block discarded – undo
3139 3139
 	 * @return string
3140 3140
 	 * @throws \EE_Error
3141 3141
 	 */
3142
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
3142
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
3143 3143
 		$selects = $this->_get_columns_to_select_for_this_model();
3144
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
3144
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
3145 3145
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
3146
-			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model( $model_relation_chain );
3147
-			foreach ( $other_model_selects as $key => $value ) {
3146
+			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain);
3147
+			foreach ($other_model_selects as $key => $value) {
3148 3148
 				$selects[] = $value;
3149 3149
 			}
3150 3150
 		}
3151
-		return implode(", ",$selects);
3151
+		return implode(", ", $selects);
3152 3152
 	}
3153 3153
 
3154 3154
 	/**
@@ -3157,19 +3157,19 @@  discard block
 block discarded – undo
3157 3157
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
3158 3158
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
3159 3159
 	 */
3160
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
3160
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
3161 3161
 		$fields = $this->field_settings();
3162 3162
 		$selects = array();
3163 3163
 		$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());
3164
-		foreach($fields as $field_obj){
3165
-			$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()."'";
3164
+		foreach ($fields as $field_obj) {
3165
+			$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()."'";
3166 3166
 		}
3167 3167
 		//make sure we are also getting the PKs of each table
3168 3168
 		$tables = $this->get_tables();
3169
-		if(count($tables) > 1){
3170
-			foreach($tables as $table_obj){
3171
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
3172
-				if( ! in_array($qualified_pk_column,$selects)){
3169
+		if (count($tables) > 1) {
3170
+			foreach ($tables as $table_obj) {
3171
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
3172
+				if ( ! in_array($qualified_pk_column, $selects)) {
3173 3173
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
3174 3174
 				}
3175 3175
 			}
@@ -3199,65 +3199,65 @@  discard block
 block discarded – undo
3199 3199
 		$query_param_type,
3200 3200
 		$original_query_param = null
3201 3201
 	) {
3202
-		if( $original_query_param === null ){
3202
+		if ($original_query_param === null) {
3203 3203
 			$original_query_param = $query_param;
3204 3204
 		}
3205 3205
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
3206 3206
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
3207
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
3208
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
3207
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
3208
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
3209 3209
 		//check to see if we have a field on this model
3210 3210
 		$this_model_fields = $this->field_settings(true);
3211
-		if(array_key_exists($query_param,$this_model_fields)){
3212
-			if($allow_fields){
3211
+		if (array_key_exists($query_param, $this_model_fields)) {
3212
+			if ($allow_fields) {
3213 3213
 				return;
3214
-			}else{
3214
+			} else {
3215 3215
 				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"),
3216
-						$query_param,get_class($this),$query_param_type,$original_query_param));
3216
+						$query_param, get_class($this), $query_param_type, $original_query_param));
3217 3217
 			}
3218 3218
 		}
3219 3219
 		//check if this is a special logic query param
3220
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3221
-			if($allow_logic_query_params){
3220
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
3221
+			if ($allow_logic_query_params) {
3222 3222
 				return;
3223
-			}else{
3223
+			} else {
3224 3224
 				throw new EE_Error(
3225 3225
 					sprintf(
3226
-						__( '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' ),
3227
-						implode( '", "', $this->_logic_query_param_keys ),
3228
-						$query_param ,
3229
-						get_class( $this ),
3226
+						__('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'),
3227
+						implode('", "', $this->_logic_query_param_keys),
3228
+						$query_param,
3229
+						get_class($this),
3230 3230
 						'<br />',
3231
-						"\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
3231
+						"\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
3232 3232
 					)
3233 3233
 				);
3234 3234
 			}
3235 3235
 		}
3236 3236
 
3237 3237
 		//check if it's a custom selection
3238
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
3238
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
3239 3239
 			return;
3240 3240
 		}
3241 3241
 
3242 3242
 		//check if has a model name at the beginning
3243 3243
 		//and
3244 3244
 		//check if it's a field on a related model
3245
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
3246
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
3247
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3245
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
3246
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
3247
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3248 3248
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
3249
-				if($query_param === ''){
3249
+				if ($query_param === '') {
3250 3250
 					//nothing left to $query_param
3251 3251
 					//we should actually end in a field name, not a model like this!
3252 3252
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3253
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3254
-				}else{
3253
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
3254
+				} else {
3255 3255
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3256 3256
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3257 3257
 					return;
3258 3258
 				}
3259
-			}elseif($query_param === $valid_related_model_name){
3260
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3259
+			}elseif ($query_param === $valid_related_model_name) {
3260
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3261 3261
 				return;
3262 3262
 			}
3263 3263
 		}
@@ -3267,7 +3267,7 @@  discard block
 block discarded – undo
3267 3267
 		//and we previously confirmed it wasn't a logic query param or field on the current model
3268 3268
 		//it's wack, that's what it is
3269 3269
 		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"),
3270
-				$query_param,get_class($this),$query_param_type,$original_query_param));
3270
+				$query_param, get_class($this), $query_param_type, $original_query_param));
3271 3271
 
3272 3272
 	}
3273 3273
 
@@ -3286,26 +3286,26 @@  discard block
 block discarded – undo
3286 3286
 	 * @return void
3287 3287
 	 * @throws \EE_Error
3288 3288
 	 */
3289
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
3289
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
3290 3290
 		$relation_obj = $this->related_settings_for($model_name);
3291 3291
 
3292 3292
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
3293 3293
 		//check if the relation is HABTM, because then we're essentially doing two joins
3294 3294
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
3295
-		if($relation_obj instanceof EE_HABTM_Relation){
3295
+		if ($relation_obj instanceof EE_HABTM_Relation) {
3296 3296
 			$join_model_obj = $relation_obj->get_join_model();
3297 3297
 			//replace the model specified with the join model for this relation chain, whi
3298 3298
 			$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);
3299 3299
 			$new_query_info = new EE_Model_Query_Info_Carrier(
3300 3300
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
3301 3301
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
3302
-			$passed_in_query_info->merge( $new_query_info  );
3302
+			$passed_in_query_info->merge($new_query_info);
3303 3303
 		}
3304 3304
 		//now just join to the other table pointed to by the relation object, and add its data types
3305 3305
 		$new_query_info = new EE_Model_Query_Info_Carrier(
3306 3306
 				array($model_relation_chain=>$model_name),
3307 3307
 				$relation_obj->get_join_statement($model_relation_chain));
3308
-		$passed_in_query_info->merge( $new_query_info  );
3308
+		$passed_in_query_info->merge($new_query_info);
3309 3309
 	}
3310 3310
 
3311 3311
 
@@ -3317,11 +3317,11 @@  discard block
 block discarded – undo
3317 3317
 	 * @return string of SQL
3318 3318
 	 * @throws \EE_Error
3319 3319
 	 */
3320
-	private function _construct_where_clause($where_params){
3320
+	private function _construct_where_clause($where_params) {
3321 3321
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3322
-		if($SQL){
3323
-			return " WHERE ". $SQL;
3324
-		}else{
3322
+		if ($SQL) {
3323
+			return " WHERE ".$SQL;
3324
+		} else {
3325 3325
 			return '';
3326 3326
 		}
3327 3327
 	}
@@ -3336,11 +3336,11 @@  discard block
 block discarded – undo
3336 3336
 	 * @return string
3337 3337
 	 * @throws \EE_Error
3338 3338
 	 */
3339
-	private function _construct_having_clause($having_params){
3339
+	private function _construct_having_clause($having_params) {
3340 3340
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3341
-		if($SQL){
3342
-			return " HAVING ". $SQL;
3343
-		}else{
3341
+		if ($SQL) {
3342
+			return " HAVING ".$SQL;
3343
+		} else {
3344 3344
 			return '';
3345 3345
 		}
3346 3346
 
@@ -3354,16 +3354,16 @@  discard block
 block discarded – undo
3354 3354
 	 * @return EE_Model_Field_Base
3355 3355
 	 * @throws EE_Error
3356 3356
 	 */
3357
-	protected function _get_field_on_model($field_name,$model_name){
3357
+	protected function _get_field_on_model($field_name, $model_name) {
3358 3358
 		$model_class = 'EEM_'.$model_name;
3359 3359
 		$model_filepath = $model_class.".model.php";
3360
-		if ( is_readable($model_filepath)){
3360
+		if (is_readable($model_filepath)) {
3361 3361
 			require_once($model_filepath);
3362
-			$model_instance=call_user_func($model_name."::instance");
3362
+			$model_instance = call_user_func($model_name."::instance");
3363 3363
 			/* @var $model_instance EEM_Base */
3364 3364
 			return $model_instance->field_settings_for($field_name);
3365
-		}else{
3366
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3365
+		} else {
3366
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3367 3367
 		}
3368 3368
 	}
3369 3369
 
@@ -3376,41 +3376,41 @@  discard block
 block discarded – undo
3376 3376
 	 * @throws EE_Error
3377 3377
 	 * @return string of SQL
3378 3378
 	 */
3379
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3380
-		$where_clauses=array();
3381
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3382
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3383
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3384
-				switch($query_param){
3379
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3380
+		$where_clauses = array();
3381
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3382
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3383
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3384
+				switch ($query_param) {
3385 3385
 					case 'not':
3386 3386
 					case 'NOT':
3387
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3387
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3388 3388
 						break;
3389 3389
 					case 'and':
3390 3390
 					case 'AND':
3391
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3391
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3392 3392
 						break;
3393 3393
 					case 'or':
3394 3394
 					case 'OR':
3395
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3395
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3396 3396
 						break;
3397 3397
 				}
3398
-			}else{
3398
+			} else {
3399 3399
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3400 3400
 
3401 3401
 				//if it's not a normal field, maybe it's a custom selection?
3402
-				if( ! $field_obj){
3403
-					if(isset( $this->_custom_selections[$query_param][1])){
3402
+				if ( ! $field_obj) {
3403
+					if (isset($this->_custom_selections[$query_param][1])) {
3404 3404
 						$field_obj = $this->_custom_selections[$query_param][1];
3405
-					}else{
3406
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3405
+					} else {
3406
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3407 3407
 					}
3408 3408
 				}
3409 3409
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3410
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3410
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3411 3411
 			}
3412 3412
 		}
3413
-		return $where_clauses ? implode( $glue, $where_clauses ) : '';
3413
+		return $where_clauses ? implode($glue, $where_clauses) : '';
3414 3414
 	}
3415 3415
 
3416 3416
 
@@ -3421,18 +3421,18 @@  discard block
 block discarded – undo
3421 3421
 	 * @throws EE_Error
3422 3422
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3423 3423
 	 */
3424
-	private function _deduce_column_name_from_query_param($query_param){
3424
+	private function _deduce_column_name_from_query_param($query_param) {
3425 3425
 		$field = $this->_deduce_field_from_query_param($query_param);
3426 3426
 
3427
-		if( $field ){
3428
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3429
-			return $table_alias_prefix . $field->get_qualified_column();
3430
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3427
+		if ($field) {
3428
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3429
+			return $table_alias_prefix.$field->get_qualified_column();
3430
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3431 3431
 			//maybe it's custom selection item?
3432 3432
 			//if so, just use it as the "column name"
3433 3433
 			return $query_param;
3434
-		}else{
3435
-			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)));
3434
+		} else {
3435
+			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)));
3436 3436
 		}
3437 3437
 	}
3438 3438
 
@@ -3444,11 +3444,11 @@  discard block
 block discarded – undo
3444 3444
 	 * @param string $condition_query_param_key
3445 3445
 	 * @return string
3446 3446
 	 */
3447
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3447
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3448 3448
 		$pos_of_star = strpos($condition_query_param_key, '*');
3449
-		if($pos_of_star === FALSE){
3449
+		if ($pos_of_star === FALSE) {
3450 3450
 			return $condition_query_param_key;
3451
-		}else{
3451
+		} else {
3452 3452
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3453 3453
 			return $condition_query_param_sans_star;
3454 3454
 		}
@@ -3463,12 +3463,12 @@  discard block
 block discarded – undo
3463 3463
 	 * @throws EE_Error
3464 3464
 	 * @return string
3465 3465
 	 */
3466
-	private function _construct_op_and_value($op_and_value, $field_obj){
3467
-		if ( is_array( $op_and_value ) ) {
3468
-			$operator = isset( $op_and_value[0] ) ? $this->_prepare_operator_for_sql( $op_and_value[0] ) : null;
3469
-			if ( ! $operator ) {
3466
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3467
+		if (is_array($op_and_value)) {
3468
+			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3469
+			if ( ! $operator) {
3470 3470
 				$php_array_like_string = array();
3471
-				foreach ( $op_and_value as $key => $value ) {
3471
+				foreach ($op_and_value as $key => $value) {
3472 3472
 					$php_array_like_string[] = "$key=>$value";
3473 3473
 				}
3474 3474
 				throw new EE_Error(
@@ -3477,27 +3477,27 @@  discard block
 block discarded – undo
3477 3477
 							"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))",
3478 3478
 							"event_espresso"
3479 3479
 						),
3480
-						implode( ",", $php_array_like_string )
3480
+						implode(",", $php_array_like_string)
3481 3481
 					)
3482 3482
 				);
3483 3483
 			}
3484
-			$value = isset( $op_and_value[1] ) ? $op_and_value[1] : null;
3484
+			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3485 3485
 		} else {
3486 3486
 			$operator = '=';
3487 3487
 			$value = $op_and_value;
3488 3488
 		}
3489 3489
 		//check to see if the value is actually another field
3490
-		if ( is_array( $op_and_value ) && isset( $op_and_value[2] ) && $op_and_value[2] == true ) {
3491
-			return $operator . SP . $this->_deduce_column_name_from_query_param( $value );
3492
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3490
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3491
+			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3492
+		} elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3493 3493
 			//in this case, the value should be an array, or at least a comma-separated list
3494 3494
 			//it will need to handle a little differently
3495
-			$cleaned_value = $this->_construct_in_value( $value, $field_obj );
3495
+			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3496 3496
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3497
-			return $operator . SP . $cleaned_value;
3498
-		} elseif ( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3497
+			return $operator.SP.$cleaned_value;
3498
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3499 3499
 			//the value should be an array with count of two.
3500
-			if ( count( $value ) !== 2 ) {
3500
+			if (count($value) !== 2) {
3501 3501
 				throw new EE_Error(
3502 3502
 					sprintf(
3503 3503
 						__(
@@ -3508,10 +3508,10 @@  discard block
 block discarded – undo
3508 3508
 					)
3509 3509
 				);
3510 3510
 			}
3511
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3512
-			return $operator . SP . $cleaned_value;
3513
-		} elseif ( in_array( $operator, $this->_null_style_operators ) ) {
3514
-			if ( $value !== null ) {
3511
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3512
+			return $operator.SP.$cleaned_value;
3513
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3514
+			if ($value !== null) {
3515 3515
 				throw new EE_Error(
3516 3516
 					sprintf(
3517 3517
 						__(
@@ -3524,13 +3524,13 @@  discard block
 block discarded – undo
3524 3524
 				);
3525 3525
 			}
3526 3526
 			return $operator;
3527
-		} elseif ( $operator === 'LIKE' && ! is_array( $value ) ) {
3527
+		} elseif ($operator === 'LIKE' && ! is_array($value)) {
3528 3528
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3529 3529
 			//remove other junk. So just treat it as a string.
3530
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, '%s' );
3531
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3532
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, $field_obj );
3533
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3530
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3531
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3532
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3533
+		} elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3534 3534
 			throw new EE_Error(
3535 3535
 				sprintf(
3536 3536
 					__(
@@ -3541,7 +3541,7 @@  discard block
 block discarded – undo
3541 3541
 					$operator
3542 3542
 				)
3543 3543
 			);
3544
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3544
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3545 3545
 			throw new EE_Error(
3546 3546
 				sprintf(
3547 3547
 					__(
@@ -3559,7 +3559,7 @@  discard block
 block discarded – undo
3559 3559
 						"It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all",
3560 3560
 						"event_espresso"
3561 3561
 					),
3562
-					http_build_query( $op_and_value )
3562
+					http_build_query($op_and_value)
3563 3563
 				)
3564 3564
 			);
3565 3565
 		}
@@ -3575,12 +3575,12 @@  discard block
 block discarded – undo
3575 3575
 	 * @return string
3576 3576
 	 * @throws \EE_Error
3577 3577
 	 */
3578
-	public function _construct_between_value( $values, $field_obj ) {
3578
+	public function _construct_between_value($values, $field_obj) {
3579 3579
 		$cleaned_values = array();
3580
-		foreach ( $values as $value ) {
3581
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3580
+		foreach ($values as $value) {
3581
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3582 3582
 		}
3583
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3583
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3584 3584
 	}
3585 3585
 
3586 3586
 
@@ -3597,26 +3597,26 @@  discard block
 block discarded – undo
3597 3597
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3598 3598
 	 * @throws \EE_Error
3599 3599
 	 */
3600
-	public function _construct_in_value($values,  $field_obj){
3600
+	public function _construct_in_value($values, $field_obj) {
3601 3601
 		//check if the value is a CSV list
3602
-		if(is_string($values)){
3602
+		if (is_string($values)) {
3603 3603
 			//in which case, turn it into an array
3604
-			$values = explode(",",$values);
3604
+			$values = explode(",", $values);
3605 3605
 		}
3606 3606
 		$cleaned_values = array();
3607
-		foreach($values as $value){
3608
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3607
+		foreach ($values as $value) {
3608
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3609 3609
 		}
3610 3610
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3611 3611
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3612 3612
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3613
-		if(empty($cleaned_values)){
3613
+		if (empty($cleaned_values)) {
3614 3614
 			$all_fields = $this->field_settings();
3615 3615
 			$a_field = array_shift($all_fields);
3616 3616
 			$main_table = $this->_get_main_table();
3617 3617
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3618 3618
 		}
3619
-		return "(".implode(",",$cleaned_values).")";
3619
+		return "(".implode(",", $cleaned_values).")";
3620 3620
 	}
3621 3621
 
3622 3622
 
@@ -3628,16 +3628,16 @@  discard block
 block discarded – undo
3628 3628
 	 * @throws EE_Error
3629 3629
 	 * @return false|null|string
3630 3630
 	 */
3631
-	private function _wpdb_prepare_using_field($value,$field_obj){
3631
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3632 3632
 		/** @type WPDB $wpdb */
3633 3633
 		global $wpdb;
3634
-		if($field_obj instanceof EE_Model_Field_Base){
3635
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3636
-		}else{//$field_obj should really just be a data type
3637
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3638
-				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)));
3634
+		if ($field_obj instanceof EE_Model_Field_Base) {
3635
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3636
+		} else {//$field_obj should really just be a data type
3637
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3638
+				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)));
3639 3639
 			}
3640
-			return $wpdb->prepare($field_obj,$value);
3640
+			return $wpdb->prepare($field_obj, $value);
3641 3641
 		}
3642 3642
 	}
3643 3643
 
@@ -3649,27 +3649,27 @@  discard block
 block discarded – undo
3649 3649
 	 * @throws EE_Error
3650 3650
 	 * @return EE_Model_Field_Base
3651 3651
 	 */
3652
-	protected function _deduce_field_from_query_param($query_param_name){
3652
+	protected function _deduce_field_from_query_param($query_param_name) {
3653 3653
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3654 3654
 		//which will help us find the database table and column
3655 3655
 
3656
-		$query_param_parts = explode(".",$query_param_name);
3657
-		if(empty($query_param_parts)){
3658
-			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));
3656
+		$query_param_parts = explode(".", $query_param_name);
3657
+		if (empty($query_param_parts)) {
3658
+			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));
3659 3659
 		}
3660 3660
 		$number_of_parts = count($query_param_parts);
3661
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3662
-		if($number_of_parts === 1){
3661
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3662
+		if ($number_of_parts === 1) {
3663 3663
 			$field_name = $last_query_param_part;
3664 3664
 			$model_obj = $this;
3665
-		}else{// $number_of_parts >= 2
3665
+		} else {// $number_of_parts >= 2
3666 3666
 			//the last part is the column name, and there are only 2parts. therefore...
3667 3667
 			$field_name = $last_query_param_part;
3668
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3668
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3669 3669
 		}
3670
-		try{
3670
+		try {
3671 3671
 			return $model_obj->field_settings_for($field_name);
3672
-		}catch(EE_Error $e){
3672
+		} catch (EE_Error $e) {
3673 3673
 			return null;
3674 3674
 		}
3675 3675
 	}
@@ -3683,13 +3683,13 @@  discard block
 block discarded – undo
3683 3683
 	 * @throws EE_Error
3684 3684
 	 * @return string
3685 3685
 	 */
3686
-	public function _get_qualified_column_for_field($field_name){
3686
+	public function _get_qualified_column_for_field($field_name) {
3687 3687
 		$all_fields = $this->field_settings();
3688 3688
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3689
-		if($field){
3689
+		if ($field) {
3690 3690
 			return $field->get_qualified_column();
3691
-		}else{
3692
-			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)));
3691
+		} else {
3692
+			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)));
3693 3693
 		}
3694 3694
 	}
3695 3695
 
@@ -3703,17 +3703,17 @@  discard block
 block discarded – undo
3703 3703
 	 * @param  mixed|string $limit The limit for this select
3704 3704
 	 * @return string                The final select join element for the query.
3705 3705
 	 */
3706
-	public function _construct_limit_join_select( $table_alias, $limit ) {
3706
+	public function _construct_limit_join_select($table_alias, $limit) {
3707 3707
 		$SQL = '';
3708
-		foreach ( $this->_tables as $table_obj ) {
3709
-			if ( $table_obj instanceof EE_Primary_Table ) {
3708
+		foreach ($this->_tables as $table_obj) {
3709
+			if ($table_obj instanceof EE_Primary_Table) {
3710 3710
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3711
-					? $table_obj->get_select_join_limit( $limit )
3712
-					: SP . $table_obj->get_table_name() . " AS " . $table_obj->get_table_alias() . SP;
3713
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3711
+					? $table_obj->get_select_join_limit($limit)
3712
+					: SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3713
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3714 3714
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3715
-					? $table_obj->get_select_join_limit_join( $limit )
3716
-					: SP . $table_obj->get_join_sql( $table_alias ) . SP;
3715
+					? $table_obj->get_select_join_limit_join($limit)
3716
+					: SP.$table_obj->get_join_sql($table_alias).SP;
3717 3717
 			}
3718 3718
 		}
3719 3719
 		return $SQL;
@@ -3728,7 +3728,7 @@  discard block
 block discarded – undo
3728 3728
 	 * @return string SQL
3729 3729
 	 * @throws \EE_Error
3730 3730
 	 */
3731
-	public function _construct_internal_join(){
3731
+	public function _construct_internal_join() {
3732 3732
 		$SQL = $this->_get_main_table()->get_table_sql();
3733 3733
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3734 3734
 		return $SQL;
@@ -3749,17 +3749,17 @@  discard block
 block discarded – undo
3749 3749
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3750 3750
 	 * @return string
3751 3751
 	 */
3752
-	public function _construct_internal_join_to_table_with_alias($alias_prefixed){
3752
+	public function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3753 3753
 		$SQL = '';
3754 3754
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3755
-		foreach($this->_tables as $table_obj){
3756
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3757
-				if($alias_sans_prefix === $table_obj->get_table_alias()){
3755
+		foreach ($this->_tables as $table_obj) {
3756
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3757
+				if ($alias_sans_prefix === $table_obj->get_table_alias()) {
3758 3758
 					//so we're joining to this table, meaning the table is already in
3759 3759
 					//the FROM statement, BUT the primary table isn't. So we want
3760 3760
 					//to add the inverse join sql
3761 3761
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3762
-				}else{
3762
+				} else {
3763 3763
 					//just add a regular JOIN to this table from the primary table
3764 3764
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3765 3765
 				}
@@ -3773,9 +3773,9 @@  discard block
 block discarded – undo
3773 3773
 	 * 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)
3774 3774
 	 * @return array
3775 3775
 	 */
3776
-	public function _get_data_types(){
3776
+	public function _get_data_types() {
3777 3777
 		$data_types = array();
3778
-		foreach( $this->field_settings() as $field_obj){
3778
+		foreach ($this->field_settings() as $field_obj) {
3779 3779
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3780 3780
 			/** @var $field_obj EE_Model_Field_Base */
3781 3781
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3791,10 +3791,10 @@  discard block
 block discarded – undo
3791 3791
 	 * @throws EE_Error
3792 3792
 	 * @return EEM_Base
3793 3793
 	 */
3794
-	public function get_related_model_obj($model_name){
3794
+	public function get_related_model_obj($model_name) {
3795 3795
 		$model_classname = "EEM_".$model_name;
3796
-		if(!class_exists($model_classname)){
3797
-			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));
3796
+		if ( ! class_exists($model_classname)) {
3797
+			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));
3798 3798
 		}
3799 3799
 		return call_user_func($model_classname."::instance");
3800 3800
 	}
@@ -3804,7 +3804,7 @@  discard block
 block discarded – undo
3804 3804
 	 * Returns the array of EE_ModelRelations for this model.
3805 3805
 	 * @return EE_Model_Relation_Base[]
3806 3806
 	 */
3807
-	public function relation_settings(){
3807
+	public function relation_settings() {
3808 3808
 		return $this->_model_relations;
3809 3809
 	}
3810 3810
 
@@ -3814,10 +3814,10 @@  discard block
 block discarded – undo
3814 3814
 	 * (Eg, without an event, datetimes have little purpose.)
3815 3815
 	 * @return EE_Belongs_To_Relation[]
3816 3816
 	 */
3817
-	public function belongs_to_relations(){
3817
+	public function belongs_to_relations() {
3818 3818
 		$belongs_to_relations = array();
3819
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3820
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3819
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3820
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3821 3821
 				$belongs_to_relations[$model_name] = $relation_obj;
3822 3822
 			}
3823 3823
 		}
@@ -3832,15 +3832,15 @@  discard block
 block discarded – undo
3832 3832
 	 * @throws EE_Error
3833 3833
 	 * @return EE_Model_Relation_Base
3834 3834
 	 */
3835
-	public function related_settings_for($relation_name){
3836
-		$relatedModels=$this->relation_settings();
3837
-		if(!array_key_exists($relation_name,$relatedModels)){
3835
+	public function related_settings_for($relation_name) {
3836
+		$relatedModels = $this->relation_settings();
3837
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3838 3838
 			throw new EE_Error(
3839 3839
 				sprintf(
3840
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3840
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3841 3841
 					$relation_name,
3842 3842
 					$this->_get_class_name(),
3843
-					implode( ', ', array_keys( $relatedModels ))
3843
+					implode(', ', array_keys($relatedModels))
3844 3844
 				)
3845 3845
 			);
3846 3846
 		}
@@ -3855,10 +3855,10 @@  discard block
 block discarded – undo
3855 3855
 	 * @throws EE_Error
3856 3856
 	 * @return EE_Model_Field_Base
3857 3857
 	 */
3858
-	public function field_settings_for($fieldName){
3859
-		$fieldSettings=$this->field_settings(true);
3860
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3861
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3858
+	public function field_settings_for($fieldName) {
3859
+		$fieldSettings = $this->field_settings(true);
3860
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3861
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3862 3862
 		}
3863 3863
 		return $fieldSettings[$fieldName];
3864 3864
 	}
@@ -3868,11 +3868,11 @@  discard block
 block discarded – undo
3868 3868
 	 * @param string $fieldName a key in the model's _field_settings array
3869 3869
 	 * @return boolean
3870 3870
 	 */
3871
-	public function has_field($fieldName){
3871
+	public function has_field($fieldName) {
3872 3872
 		$fieldSettings = $this->field_settings(true);
3873
-		if( isset($fieldSettings[$fieldName])){
3873
+		if (isset($fieldSettings[$fieldName])) {
3874 3874
 			return true;
3875
-		}else{
3875
+		} else {
3876 3876
 			return false;
3877 3877
 		}
3878 3878
 	}
@@ -3882,11 +3882,11 @@  discard block
 block discarded – undo
3882 3882
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3883 3883
 	 * @return boolean
3884 3884
 	 */
3885
-	public function has_relation($relation_name){
3885
+	public function has_relation($relation_name) {
3886 3886
 		$relations = $this->relation_settings();
3887
-		if(isset($relations[$relation_name])){
3887
+		if (isset($relations[$relation_name])) {
3888 3888
 			return true;
3889
-		}else{
3889
+		} else {
3890 3890
 			return false;
3891 3891
 		}
3892 3892
 	}
@@ -3898,7 +3898,7 @@  discard block
 block discarded – undo
3898 3898
 	 * @param $field_obj
3899 3899
 	 * @return EE_Model_Field_Base
3900 3900
 	 */
3901
-	public function is_primary_key_field( $field_obj ){
3901
+	public function is_primary_key_field($field_obj) {
3902 3902
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3903 3903
 	}
3904 3904
 
@@ -3910,16 +3910,16 @@  discard block
 block discarded – undo
3910 3910
 	 * @return EE_Model_Field_Base
3911 3911
 	 * @throws EE_Error
3912 3912
 	 */
3913
-	public function get_primary_key_field(){
3914
-		if( $this->_primary_key_field === NULL ){
3915
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3916
-				if( $this->is_primary_key_field( $field_obj )){
3913
+	public function get_primary_key_field() {
3914
+		if ($this->_primary_key_field === NULL) {
3915
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3916
+				if ($this->is_primary_key_field($field_obj)) {
3917 3917
 					$this->_primary_key_field = $field_obj;
3918 3918
 					break;
3919 3919
 				}
3920 3920
 			}
3921
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3922
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3921
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3922
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3923 3923
 			}
3924 3924
 		}
3925 3925
 		return $this->_primary_key_field;
@@ -3932,12 +3932,12 @@  discard block
 block discarded – undo
3932 3932
 	 * Internally does some caching.
3933 3933
 	 * @return boolean
3934 3934
 	 */
3935
-	public function has_primary_key_field(){
3936
-		if($this->_has_primary_key_field === null){
3937
-			try{
3935
+	public function has_primary_key_field() {
3936
+		if ($this->_has_primary_key_field === null) {
3937
+			try {
3938 3938
 				$this->get_primary_key_field();
3939 3939
 				$this->_has_primary_key_field = true;
3940
-			}catch(EE_Error $e){
3940
+			} catch (EE_Error $e) {
3941 3941
 				$this->_has_primary_key_field = false;
3942 3942
 			}
3943 3943
 		}
@@ -3951,9 +3951,9 @@  discard block
 block discarded – undo
3951 3951
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3952 3952
 	 * @return EE_Model_Field_Base or null if none is found
3953 3953
 	 */
3954
-	public function get_a_field_of_type($field_class_name){
3955
-		foreach($this->field_settings() as $field){
3956
-			if( $field instanceof $field_class_name ){
3954
+	public function get_a_field_of_type($field_class_name) {
3955
+		foreach ($this->field_settings() as $field) {
3956
+			if ($field instanceof $field_class_name) {
3957 3957
 				return $field;
3958 3958
 			}
3959 3959
 		}
@@ -3967,22 +3967,22 @@  discard block
 block discarded – undo
3967 3967
 	 * @return EE_Foreign_Key_Field_Base
3968 3968
 	 * @throws EE_Error
3969 3969
 	 */
3970
-	public function get_foreign_key_to($model_name){
3971
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3972
-			foreach($this->field_settings() as $field){
3973
-				if(
3970
+	public function get_foreign_key_to($model_name) {
3971
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3972
+			foreach ($this->field_settings() as $field) {
3973
+				if (
3974 3974
 					$field instanceof EE_Foreign_Key_Field_Base
3975
-					&& in_array($model_name,$field->get_model_names_pointed_to() )
3975
+					&& in_array($model_name, $field->get_model_names_pointed_to())
3976 3976
 				) {
3977
-					$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3977
+					$this->_cache_foreign_key_to_fields[$model_name] = $field;
3978 3978
 					break;
3979 3979
 				}
3980 3980
 			}
3981
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3982
-				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)));
3981
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3982
+				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)));
3983 3983
 			}
3984 3984
 		}
3985
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3985
+		return $this->_cache_foreign_key_to_fields[$model_name];
3986 3986
 	}
3987 3987
 
3988 3988
 
@@ -3993,7 +3993,7 @@  discard block
 block discarded – undo
3993 3993
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3994 3994
 	 * @return EE_Table_Base
3995 3995
 	 */
3996
-	public function get_table_for_alias($table_alias){
3996
+	public function get_table_for_alias($table_alias) {
3997 3997
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3998 3998
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3999 3999
 	}
@@ -4006,25 +4006,25 @@  discard block
 block discarded – undo
4006 4006
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
4007 4007
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
4008 4008
 	 */
4009
-	public function field_settings($include_db_only_fields = false){
4010
-		if( $include_db_only_fields ){
4011
-			if( $this->_cached_fields === NULL ){
4009
+	public function field_settings($include_db_only_fields = false) {
4010
+		if ($include_db_only_fields) {
4011
+			if ($this->_cached_fields === NULL) {
4012 4012
 				$this->_cached_fields = array();
4013
-				foreach($this->_fields as $fields_corresponding_to_table){
4014
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
4015
-						$this->_cached_fields[$field_name]=$field_obj;
4013
+				foreach ($this->_fields as $fields_corresponding_to_table) {
4014
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
4015
+						$this->_cached_fields[$field_name] = $field_obj;
4016 4016
 					}
4017 4017
 				}
4018 4018
 			}
4019 4019
 			return $this->_cached_fields;
4020
-		}else{
4021
-			if( $this->_cached_fields_non_db_only === NULL ){
4020
+		} else {
4021
+			if ($this->_cached_fields_non_db_only === NULL) {
4022 4022
 				$this->_cached_fields_non_db_only = array();
4023
-				foreach($this->_fields as $fields_corresponding_to_table){
4024
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
4023
+				foreach ($this->_fields as $fields_corresponding_to_table) {
4024
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
4025 4025
 						/** @var $field_obj EE_Model_Field_Base */
4026
-						if( ! $field_obj->is_db_only_field() ){
4027
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
4026
+						if ( ! $field_obj->is_db_only_field()) {
4027
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
4028 4028
 						}
4029 4029
 					}
4030 4030
 				}
@@ -4043,60 +4043,60 @@  discard block
 block discarded – undo
4043 4043
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
4044 4044
 	 * @throws \EE_Error
4045 4045
 	 */
4046
-	protected function _create_objects( $rows = array() ) {
4047
-		$array_of_objects=array();
4048
-		if(empty($rows)){
4046
+	protected function _create_objects($rows = array()) {
4047
+		$array_of_objects = array();
4048
+		if (empty($rows)) {
4049 4049
 			return array();
4050 4050
 		}
4051 4051
 		$count_if_model_has_no_primary_key = 0;
4052 4052
 		$has_primary_key = $this->has_primary_key_field();
4053 4053
 		$primary_key_field = $has_primary_key ? $this->get_primary_key_field() : null;
4054
-		foreach ( (array)$rows as $row ) {
4055
-			if(empty($row)){
4054
+		foreach ((array) $rows as $row) {
4055
+			if (empty($row)) {
4056 4056
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
4057 4057
 				return array();
4058 4058
 			}
4059 4059
 			//check if we've already set this object in the results array,
4060 4060
 			//in which case there's no need to process it further (again)
4061
-			if( $has_primary_key ) {
4061
+			if ($has_primary_key) {
4062 4062
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
4063 4063
 					$row,
4064 4064
 					$primary_key_field->get_qualified_column(),
4065 4065
 					$primary_key_field->get_table_column()
4066 4066
 				);
4067
-				if( $table_pk_value && isset( $array_of_objects[ $table_pk_value ] ) ) {
4067
+				if ($table_pk_value && isset($array_of_objects[$table_pk_value])) {
4068 4068
 					continue;
4069 4069
 				}
4070 4070
 			}
4071 4071
 			$classInstance = $this->instantiate_class_from_array_or_object($row);
4072
-			if( ! $classInstance ) {
4072
+			if ( ! $classInstance) {
4073 4073
 				throw new EE_Error(
4074 4074
 					sprintf(
4075
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
4075
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
4076 4076
 						$this->get_this_model_name(),
4077
-						http_build_query( $row )
4077
+						http_build_query($row)
4078 4078
 					)
4079 4079
 				);
4080 4080
 			}
4081 4081
 			//set the timezone on the instantiated objects
4082
-			$classInstance->set_timezone( $this->_timezone );
4082
+			$classInstance->set_timezone($this->_timezone);
4083 4083
 			//make sure if there is any timezone setting present that we set the timezone for the object
4084 4084
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
4085
-			$array_of_objects[ $key ] = $classInstance;
4085
+			$array_of_objects[$key] = $classInstance;
4086 4086
 			//also, for all the relations of type BelongsTo, see if we can cache
4087 4087
 			//those related models
4088 4088
 			//(we could do this for other relations too, but if there are conditions
4089 4089
 			//that filtered out some fo the results, then we'd be caching an incomplete set
4090 4090
 			//so it requires a little more thought than just caching them immediately...)
4091
-			foreach($this->_model_relations as $modelName => $relation_obj){
4092
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
4091
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
4092
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
4093 4093
 					//check if this model's INFO is present. If so, cache it on the model
4094 4094
 					$other_model = $relation_obj->get_other_model();
4095 4095
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
4096 4096
 					//if we managed to make a model object from the results, cache it on the main model object
4097
-					if( $other_model_obj_maybe ){
4097
+					if ($other_model_obj_maybe) {
4098 4098
 						//set timezone on these other model objects if they are present
4099
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
4099
+						$other_model_obj_maybe->set_timezone($this->_timezone);
4100 4100
 						$classInstance->cache($modelName, $other_model_obj_maybe);
4101 4101
 					}
4102 4102
 				}
@@ -4117,12 +4117,12 @@  discard block
 block discarded – undo
4117 4117
 
4118 4118
 		$this_model_fields_and_values = array();
4119 4119
 		//setup the row using default values;
4120
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
4120
+		foreach ($this->field_settings() as $field_name => $field_obj) {
4121 4121
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
4122 4122
 		}
4123 4123
 
4124 4124
 		$className = $this->_get_class_name();
4125
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
4125
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
4126 4126
 
4127 4127
 		return $classInstance;
4128 4128
 	}
@@ -4135,45 +4135,45 @@  discard block
 block discarded – undo
4135 4135
 	 * @return EE_Base_Class
4136 4136
 	 * @throws \EE_Error
4137 4137
 	 */
4138
-	public function instantiate_class_from_array_or_object($cols_n_values){
4139
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
4140
-			$cols_n_values = get_object_vars( $cols_n_values );
4138
+	public function instantiate_class_from_array_or_object($cols_n_values) {
4139
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
4140
+			$cols_n_values = get_object_vars($cols_n_values);
4141 4141
 		}
4142 4142
 		$primary_key = NULL;
4143 4143
 		//make sure the array only has keys that are fields/columns on this model
4144
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4145
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
4146
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
4144
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4145
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
4146
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
4147 4147
 		}
4148
-		$className=$this->_get_class_name();
4148
+		$className = $this->_get_class_name();
4149 4149
 
4150 4150
 		//check we actually found results that we can use to build our model object
4151 4151
 		//if not, return null
4152
-		if( $this->has_primary_key_field()){
4153
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
4152
+		if ($this->has_primary_key_field()) {
4153
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
4154 4154
 				return NULL;
4155 4155
 			}
4156
-		}else if($this->unique_indexes()){
4156
+		} else if ($this->unique_indexes()) {
4157 4157
 			$first_column = reset($this_model_fields_n_values);
4158
-			if(empty($first_column)){
4158
+			if (empty($first_column)) {
4159 4159
 				return NULL;
4160 4160
 			}
4161 4161
 		}
4162 4162
 
4163 4163
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
4164
-		if ( $primary_key){
4165
-			$classInstance = $this->get_from_entity_map( $primary_key );
4166
-			if( ! $classInstance) {
4167
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4164
+		if ($primary_key) {
4165
+			$classInstance = $this->get_from_entity_map($primary_key);
4166
+			if ( ! $classInstance) {
4167
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4168 4168
 				// add this new object to the entity map
4169
-				$classInstance = $this->add_to_entity_map( $classInstance );
4169
+				$classInstance = $this->add_to_entity_map($classInstance);
4170 4170
 			}
4171
-		}else{
4172
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4171
+		} else {
4172
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4173 4173
 		}
4174 4174
 
4175 4175
 			//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.
4176
-		$this->set_timezone( $classInstance->get_timezone() );
4176
+		$this->set_timezone($classInstance->get_timezone());
4177 4177
 		return $classInstance;
4178 4178
 	}
4179 4179
 	/**
@@ -4181,8 +4181,8 @@  discard block
 block discarded – undo
4181 4181
 	 * @param int|string $id the ID of the model object
4182 4182
 	 * @return EE_Base_Class
4183 4183
 	 */
4184
-	public function get_from_entity_map( $id ){
4185
-		return isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ) ? $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] : NULL;
4184
+	public function get_from_entity_map($id) {
4185
+		return isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id]) ? $this->_entity_map[EEM_Base::$_model_query_blog_id][$id] : NULL;
4186 4186
 	}
4187 4187
 
4188 4188
 
@@ -4204,21 +4204,21 @@  discard block
 block discarded – undo
4204 4204
 	 * @throws EE_Error
4205 4205
 	 * @return \EE_Base_Class
4206 4206
 	 */
4207
-	public function add_to_entity_map( EE_Base_Class $object) {
4207
+	public function add_to_entity_map(EE_Base_Class $object) {
4208 4208
 		$className = $this->_get_class_name();
4209
-		if( ! $object instanceof $className ){
4210
-			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 ) );
4209
+		if ( ! $object instanceof $className) {
4210
+			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));
4211 4211
 		}
4212 4212
 		/** @var $object EE_Base_Class */
4213
-		if ( ! $object->ID() ){
4214
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
4213
+		if ( ! $object->ID()) {
4214
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
4215 4215
 		}
4216 4216
 		// double check it's not already there
4217
-		$classInstance = $this->get_from_entity_map( $object->ID() );
4218
-		if ( $classInstance ) {
4217
+		$classInstance = $this->get_from_entity_map($object->ID());
4218
+		if ($classInstance) {
4219 4219
 			return $classInstance;
4220 4220
 		} else {
4221
-			$this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $object->ID() ] = $object;
4221
+			$this->_entity_map[EEM_Base::$_model_query_blog_id][$object->ID()] = $object;
4222 4222
 			return $object;
4223 4223
 		}
4224 4224
 	}
@@ -4231,8 +4231,8 @@  discard block
 block discarded – undo
4231 4231
 	 * @param array $cols_n_values
4232 4232
 	 * @return array
4233 4233
 	 */
4234
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
4235
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4234
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4235
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4236 4236
 	}
4237 4237
 
4238 4238
 
@@ -4245,23 +4245,23 @@  discard block
 block discarded – undo
4245 4245
 	 * @param string $cols_n_values
4246 4246
 	 * @return array
4247 4247
 	 */
4248
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
4248
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4249 4249
 		$this_model_fields_n_values = array();
4250
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
4251
-			$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() );
4250
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
4251
+			$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());
4252 4252
 			//there is a primary key on this table and its not set. Use defaults for all its columns
4253
-			if( $table_pk_value === null && $table_obj->get_pk_column() ){
4254
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4255
-					if( ! $field_obj->is_db_only_field() ){
4253
+			if ($table_pk_value === null && $table_obj->get_pk_column()) {
4254
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4255
+					if ( ! $field_obj->is_db_only_field()) {
4256 4256
 						//prepare field as if its coming from db
4257
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
4258
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
4257
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
4258
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
4259 4259
 					}
4260 4260
 				}
4261
-			}else{
4261
+			} else {
4262 4262
 				//the table's rows existed. Use their values
4263
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4264
-					if( ! $field_obj->is_db_only_field() ){
4263
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4264
+					if ( ! $field_obj->is_db_only_field()) {
4265 4265
 						$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not(
4266 4266
 							$cols_n_values, $field_obj->get_qualified_column(),
4267 4267
 							$field_obj->get_table_column()
@@ -4281,15 +4281,15 @@  discard block
 block discarded – undo
4281 4281
 	 * @param $regular_column
4282 4282
 	 * @return null
4283 4283
 	 */
4284
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
4284
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
4285 4285
 		$value = null;
4286 4286
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
4287 4287
 		//does the field on the model relate to this column retrieved from the db?
4288 4288
 		//or is it a db-only field? (not relating to the model)
4289
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
4290
-			$value = $cols_n_values[ $qualified_column ];
4291
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4292
-			$value = $cols_n_values[ $regular_column ];
4289
+		if (isset($cols_n_values[$qualified_column])) {
4290
+			$value = $cols_n_values[$qualified_column];
4291
+		}elseif (isset($cols_n_values[$regular_column])) {
4292
+			$value = $cols_n_values[$regular_column];
4293 4293
 		}
4294 4294
 		return $value;
4295 4295
 	}
@@ -4305,25 +4305,25 @@  discard block
 block discarded – undo
4305 4305
 	 * @return EE_Base_Class
4306 4306
 	 * @throws \EE_Error
4307 4307
 	 */
4308
-	public function refresh_entity_map_from_db( $id ){
4309
-		$obj_in_map = $this->get_from_entity_map( $id );
4310
-		if( $obj_in_map ){
4308
+	public function refresh_entity_map_from_db($id) {
4309
+		$obj_in_map = $this->get_from_entity_map($id);
4310
+		if ($obj_in_map) {
4311 4311
 			$wpdb_results = $this->_get_all_wpdb_results(
4312
-				array( array( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 )
4312
+				array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1)
4313 4313
 			);
4314
-			if( $wpdb_results && is_array( $wpdb_results ) ){
4315
-				$one_row = reset( $wpdb_results );
4316
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
4317
-					$obj_in_map->set_from_db( $field_name, $db_value );
4314
+			if ($wpdb_results && is_array($wpdb_results)) {
4315
+				$one_row = reset($wpdb_results);
4316
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
4317
+					$obj_in_map->set_from_db($field_name, $db_value);
4318 4318
 				}
4319 4319
 				//clear the cache of related model objects
4320
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4321
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4320
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4321
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4322 4322
 				}
4323 4323
 			}
4324 4324
 			return $obj_in_map;
4325
-		}else{
4326
-			return $this->get_one_by_ID( $id );
4325
+		} else {
4326
+			return $this->get_one_by_ID($id);
4327 4327
 		}
4328 4328
 	}
4329 4329
 
@@ -4341,24 +4341,24 @@  discard block
 block discarded – undo
4341 4341
 	 * @return \EE_Base_Class
4342 4342
 	 * @throws \EE_Error
4343 4343
 	 */
4344
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
4345
-		$obj_in_map = $this->get_from_entity_map( $id );
4346
-		if( $obj_in_map ){
4347
-			if( $replacing_model_obj instanceof EE_Base_Class ){
4348
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
4349
-					$obj_in_map->set( $field_name, $value );
4344
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
4345
+		$obj_in_map = $this->get_from_entity_map($id);
4346
+		if ($obj_in_map) {
4347
+			if ($replacing_model_obj instanceof EE_Base_Class) {
4348
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
4349
+					$obj_in_map->set($field_name, $value);
4350 4350
 				}
4351 4351
 				//make the model object in the entity map's cache match the $replacing_model_obj
4352
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4353
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4354
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
4355
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
4352
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4353
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4354
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
4355
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
4356 4356
 					}
4357 4357
 				}
4358 4358
 			}
4359 4359
 			return $obj_in_map;
4360
-		}else{
4361
-			$this->add_to_entity_map( $replacing_model_obj );
4360
+		} else {
4361
+			$this->add_to_entity_map($replacing_model_obj);
4362 4362
 			return $replacing_model_obj;
4363 4363
 		}
4364 4364
 	}
@@ -4371,7 +4371,7 @@  discard block
 block discarded – undo
4371 4371
 	 * require_once($this->_getClassName().".class.php");
4372 4372
 	 * @return string
4373 4373
 	 */
4374
-	private function _get_class_name(){
4374
+	private function _get_class_name() {
4375 4375
 		return "EE_".$this->get_this_model_name();
4376 4376
 	}
4377 4377
 
@@ -4384,8 +4384,8 @@  discard block
 block discarded – undo
4384 4384
 	 * @param int $quantity
4385 4385
 	 * @return string
4386 4386
 	 */
4387
-	public function item_name($quantity = 1){
4388
-		return (int)$quantity === 1 ? $this->singular_item : $this->plural_item;
4387
+	public function item_name($quantity = 1) {
4388
+		return (int) $quantity === 1 ? $this->singular_item : $this->plural_item;
4389 4389
 	}
4390 4390
 
4391 4391
 
@@ -4412,13 +4412,13 @@  discard block
 block discarded – undo
4412 4412
 	 * @throws EE_Error
4413 4413
 	 * @return mixed whatever the plugin which calls add_filter decides
4414 4414
 	 */
4415
-	public function __call($methodName,$args){
4416
-		$className=get_class($this);
4417
-		$tagName="FHEE__{$className}__{$methodName}";
4418
-		if(!has_filter($tagName)){
4415
+	public function __call($methodName, $args) {
4416
+		$className = get_class($this);
4417
+		$tagName = "FHEE__{$className}__{$methodName}";
4418
+		if ( ! has_filter($tagName)) {
4419 4419
 			throw new EE_Error(
4420 4420
 				sprintf(
4421
-					__( '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' ),
4421
+					__('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'),
4422 4422
 					$methodName,
4423 4423
 					$className,
4424 4424
 					$tagName,
@@ -4427,7 +4427,7 @@  discard block
 block discarded – undo
4427 4427
 			);
4428 4428
 		}
4429 4429
 
4430
-		return apply_filters($tagName,null,$this,$args);
4430
+		return apply_filters($tagName, null, $this, $args);
4431 4431
 	}
4432 4432
 
4433 4433
 
@@ -4445,28 +4445,28 @@  discard block
 block discarded – undo
4445 4445
 	 * @throws EE_Error
4446 4446
 	 * @return EE_Base_Class
4447 4447
 	 */
4448
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4448
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4449 4449
 		$className = $this->_get_class_name();
4450
-		if ( $base_class_obj_or_id instanceof $className ) {
4450
+		if ($base_class_obj_or_id instanceof $className) {
4451 4451
 			$model_object = $base_class_obj_or_id;
4452 4452
 		} else {
4453 4453
 			$primary_key_field = $this->get_primary_key_field();
4454 4454
 			if (
4455 4455
 				$primary_key_field instanceof EE_Primary_Key_Int_Field
4456 4456
 				&& (
4457
-					is_int( $base_class_obj_or_id )
4458
-					|| is_string( $base_class_obj_or_id )
4457
+					is_int($base_class_obj_or_id)
4458
+					|| is_string($base_class_obj_or_id)
4459 4459
 				)
4460 4460
 			) {
4461 4461
 				// assume it's an ID.
4462 4462
 				// either a proper integer or a string representing an integer (eg "101" instead of 101)
4463
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4463
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4464 4464
 			} else if (
4465 4465
 				$primary_key_field instanceof EE_Primary_Key_String_Field
4466
-			    && is_string( $base_class_obj_or_id )
4466
+			    && is_string($base_class_obj_or_id)
4467 4467
 			) {
4468 4468
 				// assume its a string representation of the object
4469
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4469
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4470 4470
 			} else {
4471 4471
 				throw new EE_Error(
4472 4472
 					sprintf(
@@ -4476,12 +4476,12 @@  discard block
 block discarded – undo
4476 4476
 						),
4477 4477
 						$base_class_obj_or_id,
4478 4478
 						$this->_get_class_name(),
4479
-						print_r( $base_class_obj_or_id, true )
4479
+						print_r($base_class_obj_or_id, true)
4480 4480
 					)
4481 4481
 				);
4482 4482
 			}
4483 4483
 		}
4484
-		if ( $ensure_is_in_db && $model_object->ID() !== null ) {
4484
+		if ($ensure_is_in_db && $model_object->ID() !== null) {
4485 4485
 			$model_object->save();
4486 4486
 		}
4487 4487
 		return $model_object;
@@ -4497,19 +4497,19 @@  discard block
 block discarded – undo
4497 4497
 	 * @return int|string depending on the type of this model object's ID
4498 4498
 	 * @throws EE_Error
4499 4499
 	 */
4500
-	public function ensure_is_ID($base_class_obj_or_id){
4500
+	public function ensure_is_ID($base_class_obj_or_id) {
4501 4501
 		$className = $this->_get_class_name();
4502
-		if( $base_class_obj_or_id instanceof $className ){
4502
+		if ($base_class_obj_or_id instanceof $className) {
4503 4503
 			/** @var $base_class_obj_or_id EE_Base_Class */
4504 4504
 			$id = $base_class_obj_or_id->ID();
4505
-		}elseif(is_int($base_class_obj_or_id)){
4505
+		}elseif (is_int($base_class_obj_or_id)) {
4506 4506
 			//assume it's an ID
4507 4507
 			$id = $base_class_obj_or_id;
4508
-		}elseif(is_string($base_class_obj_or_id)){
4508
+		}elseif (is_string($base_class_obj_or_id)) {
4509 4509
 			//assume its a string representation of the object
4510 4510
 			$id = $base_class_obj_or_id;
4511
-		}else{
4512
-			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)));
4511
+		} else {
4512
+			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)));
4513 4513
 		}
4514 4514
 		return $id;
4515 4515
 	}
@@ -4532,14 +4532,14 @@  discard block
 block discarded – undo
4532 4532
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4533 4533
 	 * @return void
4534 4534
 	 */
4535
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4535
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4536 4536
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4537 4537
 	}
4538 4538
 	/**
4539 4539
 	 * Read comments for assume_values_already_prepared_by_model_object()
4540 4540
 	 * @return int
4541 4541
 	 */
4542
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4542
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4543 4543
 		return $this->_values_already_prepared_by_model_object;
4544 4544
 	}
4545 4545
 
@@ -4547,17 +4547,17 @@  discard block
 block discarded – undo
4547 4547
 	 * Gets all the indexes on this model
4548 4548
 	 * @return EE_Index[]
4549 4549
 	 */
4550
-	public function indexes(){
4550
+	public function indexes() {
4551 4551
 		return $this->_indexes;
4552 4552
 	}
4553 4553
 	/**
4554 4554
 	 * Gets all the Unique Indexes on this model
4555 4555
 	 * @return EE_Unique_Index[]
4556 4556
 	 */
4557
-	public function unique_indexes(){
4557
+	public function unique_indexes() {
4558 4558
 		$unique_indexes = array();
4559
-		foreach($this->_indexes as $name => $index){
4560
-			if($index instanceof EE_Unique_Index){
4559
+		foreach ($this->_indexes as $name => $index) {
4560
+			if ($index instanceof EE_Unique_Index) {
4561 4561
 				$unique_indexes [$name] = $index;
4562 4562
 			}
4563 4563
 		}
@@ -4575,13 +4575,13 @@  discard block
 block discarded – undo
4575 4575
 	 * @return EE_Model_Field_Base[] indexed by the field's name
4576 4576
 	 * @throws \EE_Error
4577 4577
 	 */
4578
-	public function get_combined_primary_key_fields(){
4579
-		foreach($this->indexes() as $index){
4580
-			if($index instanceof EE_Primary_Key_Index){
4578
+	public function get_combined_primary_key_fields() {
4579
+		foreach ($this->indexes() as $index) {
4580
+			if ($index instanceof EE_Primary_Key_Index) {
4581 4581
 				return $index->fields();
4582 4582
 			}
4583 4583
 		}
4584
-		return array( $this->primary_key_name() => $this->get_primary_key_field());
4584
+		return array($this->primary_key_name() => $this->get_primary_key_field());
4585 4585
 	}
4586 4586
 
4587 4587
 
@@ -4595,7 +4595,7 @@  discard block
 block discarded – undo
4595 4595
 	 * @return string
4596 4596
 	 * @throws \EE_Error
4597 4597
 	 */
4598
-	public function get_index_primary_key_string($cols_n_values){
4598
+	public function get_index_primary_key_string($cols_n_values) {
4599 4599
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4600 4600
 		return http_build_query($cols_n_values_for_primary_key_index);
4601 4601
 	}
@@ -4610,13 +4610,13 @@  discard block
 block discarded – undo
4610 4610
 	 * @return null|array
4611 4611
 	 * @throws \EE_Error
4612 4612
 	 */
4613
-	public function parse_index_primary_key_string( $index_primary_key_string) {
4613
+	public function parse_index_primary_key_string($index_primary_key_string) {
4614 4614
 		$key_fields = $this->get_combined_primary_key_fields();
4615 4615
 		//check all of them are in the $id
4616 4616
 		$key_vals_in_combined_pk = array();
4617
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4618
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4619
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4617
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4618
+		foreach ($key_fields as $key_field_name => $field_obj) {
4619
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4620 4620
 				return NULL;
4621 4621
 			}
4622 4622
 		}
@@ -4633,10 +4633,10 @@  discard block
 block discarded – undo
4633 4633
 	 * @return boolean
4634 4634
 	 * @throws \EE_Error
4635 4635
 	 */
4636
-	public function has_all_combined_primary_key_fields( $key_vals ) {
4637
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4638
-		foreach( $keys_it_should_have as $key ){
4639
-			if( ! isset( $key_vals[ $key ] ) ){
4636
+	public function has_all_combined_primary_key_fields($key_vals) {
4637
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4638
+		foreach ($keys_it_should_have as $key) {
4639
+			if ( ! isset($key_vals[$key])) {
4640 4640
 				return false;
4641 4641
 			}
4642 4642
 		}
@@ -4652,23 +4652,23 @@  discard block
 block discarded – undo
4652 4652
 	 * @throws EE_Error
4653 4653
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4654 4654
 	 */
4655
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4655
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4656 4656
 
4657
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4657
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4658 4658
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4659
-		}elseif(is_array($model_object_or_attributes_array)){
4659
+		}elseif (is_array($model_object_or_attributes_array)) {
4660 4660
 			$attributes_array = $model_object_or_attributes_array;
4661
-		}else{
4662
-			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));
4661
+		} else {
4662
+			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));
4663 4663
 		}
4664 4664
 		//even copies obviously won't have the same ID, so remove the primary key
4665 4665
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4666
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4666
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4667 4667
 			unset($attributes_array[$this->primary_key_name()]);
4668 4668
 		}
4669
-		if(isset($query_params[0])){
4670
-			$query_params[0] = array_merge($attributes_array,$query_params);
4671
-		}else{
4669
+		if (isset($query_params[0])) {
4670
+			$query_params[0] = array_merge($attributes_array, $query_params);
4671
+		} else {
4672 4672
 			$query_params[0] = $attributes_array;
4673 4673
 		}
4674 4674
 		return $this->get_all($query_params);
@@ -4684,16 +4684,16 @@  discard block
 block discarded – undo
4684 4684
 	 * @return EE_Base_Class
4685 4685
 	 * @throws \EE_Error
4686 4686
 	 */
4687
-	public function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4688
-		if( ! is_array( $query_params ) ){
4689
-			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' );
4687
+	public function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4688
+		if ( ! is_array($query_params)) {
4689
+			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');
4690 4690
 			$query_params = array();
4691 4691
 		}
4692 4692
 		$query_params['limit'] = 1;
4693
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4694
-		if(is_array($copies)){
4693
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4694
+		if (is_array($copies)) {
4695 4695
 			return array_shift($copies);
4696
-		}else{
4696
+		} else {
4697 4697
 			return null;
4698 4698
 		}
4699 4699
 	}
@@ -4709,10 +4709,10 @@  discard block
 block discarded – undo
4709 4709
 	 * @return int number of rows updated
4710 4710
 	 * @throws \EE_Error
4711 4711
 	 */
4712
-	public function update_by_ID($fields_n_values,$id){
4712
+	public function update_by_ID($fields_n_values, $id) {
4713 4713
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4714 4714
 			'default_where_conditions'=>'other_models_only',);
4715
-		return $this->update($fields_n_values,$query_params);
4715
+		return $this->update($fields_n_values, $query_params);
4716 4716
 	}
4717 4717
 
4718 4718
 
@@ -4723,12 +4723,12 @@  discard block
 block discarded – undo
4723 4723
 	 * @return string an operator which can be used in SQL
4724 4724
 	 * @throws EE_Error
4725 4725
 	 */
4726
-	private function _prepare_operator_for_sql($operator_supplied){
4726
+	private function _prepare_operator_for_sql($operator_supplied) {
4727 4727
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4728
-		if($sql_operator){
4728
+		if ($sql_operator) {
4729 4729
 			return $sql_operator;
4730
-		}else{
4731
-			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))));
4730
+		} else {
4731
+			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))));
4732 4732
 		}
4733 4733
 	}
4734 4734
 
@@ -4742,10 +4742,10 @@  discard block
 block discarded – undo
4742 4742
 	 * @return string[]
4743 4743
 	 * @throws \EE_Error
4744 4744
 	 */
4745
-	public function get_all_names($query_params = array()){
4745
+	public function get_all_names($query_params = array()) {
4746 4746
 		$objs = $this->get_all($query_params);
4747 4747
 		$names = array();
4748
-		foreach($objs as $obj){
4748
+		foreach ($objs as $obj) {
4749 4749
 			$names[$obj->ID()] = $obj->name();
4750 4750
 		}
4751 4751
 		return $names;
@@ -4764,11 +4764,11 @@  discard block
 block discarded – undo
4764 4764
 	 * @return array
4765 4765
 	 * @throws \EE_Error
4766 4766
 	 */
4767
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4768
-		if( ! $this->has_primary_key_field() ) {
4769
-			if( WP_DEBUG ) {
4767
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4768
+		if ( ! $this->has_primary_key_field()) {
4769
+			if (WP_DEBUG) {
4770 4770
 				EE_Error::add_error(
4771
-					__( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ),
4771
+					__('Trying to get IDs from a model than has no primary key', 'event_espresso'),
4772 4772
 					__FILE__,
4773 4773
 					__FUNCTION__,
4774 4774
 					__LINE__
@@ -4776,13 +4776,13 @@  discard block
 block discarded – undo
4776 4776
 			}
4777 4777
 		}
4778 4778
 		$IDs = array();
4779
-		foreach( $model_objects as $model_object ) {
4779
+		foreach ($model_objects as $model_object) {
4780 4780
 			$id = $model_object->ID();
4781
-			if( ! $id ) {
4782
-				if( $filter_out_empty_ids ) {
4781
+			if ( ! $id) {
4782
+				if ($filter_out_empty_ids) {
4783 4783
 					continue;
4784 4784
 				}
4785
-				if ( WP_DEBUG ) {
4785
+				if (WP_DEBUG) {
4786 4786
 					EE_Error::add_error(
4787 4787
 						__(
4788 4788
 							'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database',
@@ -4804,8 +4804,8 @@  discard block
 block discarded – undo
4804 4804
 	 * are no capabilities that relate to this model returns false
4805 4805
 	 * @return string|false
4806 4806
 	 */
4807
-	public function cap_slug(){
4808
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4807
+	public function cap_slug() {
4808
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4809 4809
 	}
4810 4810
 
4811 4811
 
@@ -4820,34 +4820,34 @@  discard block
 block discarded – undo
4820 4820
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4821 4821
 	 * @throws \EE_Error
4822 4822
 	 */
4823
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4824
-		EEM_Base::verify_is_valid_cap_context( $context );
4823
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4824
+		EEM_Base::verify_is_valid_cap_context($context);
4825 4825
 		//check if we ought to run the restriction generator first
4826
-		if(
4827
-			isset( $this->_cap_restriction_generators[ $context ] )
4828
-			&& $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base
4829
-			&& ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions()
4826
+		if (
4827
+			isset($this->_cap_restriction_generators[$context])
4828
+			&& $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base
4829
+			&& ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()
4830 4830
 		) {
4831
-			$this->_cap_restrictions[ $context ] = array_merge(
4832
-				$this->_cap_restrictions[ $context ],
4833
-				$this->_cap_restriction_generators[ $context ]->generate_restrictions()
4831
+			$this->_cap_restrictions[$context] = array_merge(
4832
+				$this->_cap_restrictions[$context],
4833
+				$this->_cap_restriction_generators[$context]->generate_restrictions()
4834 4834
 			);
4835 4835
 		}
4836 4836
 		//and make sure we've finalized the construction of each restriction
4837
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4838
-			if ( $where_conditions_obj instanceof EE_Default_Where_Conditions ) {
4839
-				$where_conditions_obj->_finalize_construct( $this );
4837
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4838
+			if ($where_conditions_obj instanceof EE_Default_Where_Conditions) {
4839
+				$where_conditions_obj->_finalize_construct($this);
4840 4840
 			}
4841 4841
 		}
4842 4842
 
4843
-		return $this->_cap_restrictions[ $context ];
4843
+		return $this->_cap_restrictions[$context];
4844 4844
 	}
4845 4845
 
4846 4846
 	/**
4847 4847
 	 * Indicating whether or not this model thinks its a wp core model
4848 4848
 	 * @return boolean
4849 4849
 	 */
4850
-	public function is_wp_core_model(){
4850
+	public function is_wp_core_model() {
4851 4851
 		return $this->_wp_core_model;
4852 4852
 	}
4853 4853
 
@@ -4861,12 +4861,12 @@  discard block
 block discarded – undo
4861 4861
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4862 4862
 	 * @throws \EE_Error
4863 4863
 	 */
4864
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4864
+	public function caps_missing($context = EEM_Base::caps_read) {
4865 4865
 		$missing_caps = array();
4866
-		$cap_restrictions = $this->cap_restrictions( $context );
4867
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4868
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4869
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4866
+		$cap_restrictions = $this->cap_restrictions($context);
4867
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4868
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4869
+				$missing_caps[$cap] = $restriction_if_no_cap;
4870 4870
 			}
4871 4871
 		}
4872 4872
 		return $missing_caps;
@@ -4878,7 +4878,7 @@  discard block
 block discarded – undo
4878 4878
 	 * one of 'read', 'edit', or 'delete'
4879 4879
 	 */
4880 4880
 	public function cap_contexts_to_cap_action_map() {
4881
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4881
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4882 4882
 	}
4883 4883
 
4884 4884
 
@@ -4889,19 +4889,19 @@  discard block
 block discarded – undo
4889 4889
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4890 4890
 	 * @throws \EE_Error
4891 4891
 	 */
4892
-	public function cap_action_for_context( $context ) {
4892
+	public function cap_action_for_context($context) {
4893 4893
 		$mapping = $this->cap_contexts_to_cap_action_map();
4894
-		if( isset( $mapping[ $context ] ) ) {
4895
-			return $mapping[ $context ];
4894
+		if (isset($mapping[$context])) {
4895
+			return $mapping[$context];
4896 4896
 		}
4897
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4897
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4898 4898
 			return $action;
4899 4899
 		}
4900 4900
 		throw new EE_Error(
4901 4901
 			sprintf(
4902
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4902
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4903 4903
 				$context,
4904
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4904
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4905 4905
 			)
4906 4906
 		);
4907 4907
 
@@ -4912,7 +4912,7 @@  discard block
 block discarded – undo
4912 4912
 	 * @return array
4913 4913
 	 */
4914 4914
 	static public function valid_cap_contexts() {
4915
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4915
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4916 4916
 			self::caps_read,
4917 4917
 			self::caps_read_admin,
4918 4918
 			self::caps_edit,
@@ -4928,17 +4928,17 @@  discard block
 block discarded – undo
4928 4928
 	 * @return bool
4929 4929
 	 * @throws \EE_Error
4930 4930
 	 */
4931
-	static public function verify_is_valid_cap_context( $context ) {
4931
+	static public function verify_is_valid_cap_context($context) {
4932 4932
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4933
-		if( in_array( $context, $valid_cap_contexts ) ) {
4933
+		if (in_array($context, $valid_cap_contexts)) {
4934 4934
 			return true;
4935
-		}else{
4935
+		} else {
4936 4936
 			throw new EE_Error(
4937 4937
 				sprintf(
4938
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4938
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4939 4939
 					$context,
4940
-					'EEM_Base' ,
4941
-					implode(',', $valid_cap_contexts )
4940
+					'EEM_Base',
4941
+					implode(',', $valid_cap_contexts)
4942 4942
 				)
4943 4943
 			);
4944 4944
 		}
Please login to merge, or discard this patch.
core/EE_PUE.core.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
 	public function __construct() {
18 18
 //		throw new EE_Error('error');
19 19
 
20
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__ );
20
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
21 21
 
22 22
 		//wp have no MONTH_IN_SECONDS constant.  So we approximate our own assuming all months are 4 weeks long.
23
-		if ( !defined('MONTH_IN_SECONDS' ) )
24
-			define( 'MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4 );
23
+		if ( ! defined('MONTH_IN_SECONDS'))
24
+			define('MONTH_IN_SECONDS', WEEK_IN_SECONDS * 4);
25 25
 
26
-		if(EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance){
26
+		if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
27 27
 			$this->_uxip_hooks();
28 28
 		}
29 29
 
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 		$ueip_has_notified = EE_Registry::instance()->CFG->core->ee_ueip_has_notified;
33 33
 
34 34
 		//has optin been selected for data collection?
35
-		$espresso_data_optin = !empty($ueip_optin) ? $ueip_optin : NULL;
35
+		$espresso_data_optin = ! empty($ueip_optin) ? $ueip_optin : NULL;
36 36
 
37
-		if ( empty($ueip_has_notified) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ) {
38
-			add_action('admin_notices', array( $this, 'espresso_data_collection_optin_notice' ), 10 );
39
-			add_action('admin_enqueue_scripts', array( $this, 'espresso_data_collection_enqueue_scripts' ), 10 );
40
-			add_action('wp_ajax_espresso_data_optin', array( $this, 'espresso_data_optin_ajax_handler' ), 10 );
37
+		if (empty($ueip_has_notified) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
38
+			add_action('admin_notices', array($this, 'espresso_data_collection_optin_notice'), 10);
39
+			add_action('admin_enqueue_scripts', array($this, 'espresso_data_collection_enqueue_scripts'), 10);
40
+			add_action('wp_ajax_espresso_data_optin', array($this, 'espresso_data_optin_ajax_handler'), 10);
41 41
 			update_option('ee_ueip_optin', 'yes');
42 42
 			$espresso_data_optin = 'yes';
43 43
 		}
@@ -46,80 +46,80 @@  discard block
 block discarded – undo
46 46
 		$extra_stats = array();
47 47
 
48 48
 		//only collect extra stats if the plugin user has opted in.
49
-		if ( !empty($espresso_data_optin) && $espresso_data_optin == 'yes' ) {
49
+		if ( ! empty($espresso_data_optin) && $espresso_data_optin == 'yes') {
50 50
 			//let's only setup extra data if transient has expired
51
-			if ( false === ( $transient = get_transient('ee_extra_data') ) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ) {
51
+			if (false === ($transient = get_transient('ee_extra_data')) && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
52 52
 
53 53
 				$current_site = is_multisite() ? get_current_site() : NULL;
54
-				$site_pre = ! is_main_site() && ! empty($current_site) ? trim( preg_replace('/\b\w\S\w\b/', '', $current_site->domain ), '.' ) . '_' : '';
54
+				$site_pre = ! is_main_site() && ! empty($current_site) ? trim(preg_replace('/\b\w\S\w\b/', '', $current_site->domain), '.').'_' : '';
55 55
 
56 56
 
57 57
 				//active gateways
58 58
 				$active_gateways = get_option('event_espresso_active_gateways');
59
-				if ( !empty($active_gateways ) ) {
60
-					foreach ( (array) $active_gateways as $gateway => $ignore ) {
61
-						$extra_stats[$site_pre . $gateway . '_gateway_active'] = 1;
59
+				if ( ! empty($active_gateways)) {
60
+					foreach ((array) $active_gateways as $gateway => $ignore) {
61
+						$extra_stats[$site_pre.$gateway.'_gateway_active'] = 1;
62 62
 					}
63 63
 				}
64 64
 
65
-				if ( is_multisite() && is_main_site() ) {
65
+				if (is_multisite() && is_main_site()) {
66 66
 					$extra_stats['is_multisite'] = true;
67 67
 				}
68 68
 
69 69
 				//what is the current active theme?
70 70
 				$active_theme = get_option('uxip_ee_active_theme');
71
-				if ( !empty( $active_theme ) )
72
-					$extra_stats[$site_pre . 'active_theme'] = $active_theme;
71
+				if ( ! empty($active_theme))
72
+					$extra_stats[$site_pre.'active_theme'] = $active_theme;
73 73
 
74 74
 				//event info regarding an all event count and all "active" event count
75 75
 				$all_events_count = get_option('uxip_ee4_all_events_count');
76
-				if ( !empty( $all_events_count ) )
77
-					$extra_stats[$site_pre . 'ee4_all_events_count'] = $all_events_count;
76
+				if ( ! empty($all_events_count))
77
+					$extra_stats[$site_pre.'ee4_all_events_count'] = $all_events_count;
78 78
 				$active_events_count = get_option('uxip_ee4_active_events_count');
79
-				if ( !empty( $active_events_count ) )
80
-					$extra_stats[$site_pre . 'ee4_active_events_count'] = $active_events_count;
79
+				if ( ! empty($active_events_count))
80
+					$extra_stats[$site_pre.'ee4_active_events_count'] = $active_events_count;
81 81
 
82 82
 				//datetime stuff
83 83
 				$dtt_count = get_option('uxip_ee_all_dtts_count');
84
-				if ( !empty( $dtt_count ) )
85
-					$extra_stats[$site_pre . 'all_dtts_count'] = $dtt_count;
84
+				if ( ! empty($dtt_count))
85
+					$extra_stats[$site_pre.'all_dtts_count'] = $dtt_count;
86 86
 
87 87
 				$dtt_sold = get_option('uxip_ee_dtt_sold');
88
-				if ( !empty( $dtt_sold ) )
89
-					$extra_stats[$site_pre . 'dtt_sold'] = $dtt_sold;
88
+				if ( ! empty($dtt_sold))
89
+					$extra_stats[$site_pre.'dtt_sold'] = $dtt_sold;
90 90
 
91 91
 				//ticket stuff
92 92
 				$all_tkt_count = get_option('uxip_ee_all_tkt_count');
93
-				if ( !empty( $all_tkt_count ) )
94
-					$extra_stats[$site_pre . 'all_tkt_count'] = $all_tkt_count;
93
+				if ( ! empty($all_tkt_count))
94
+					$extra_stats[$site_pre.'all_tkt_count'] = $all_tkt_count;
95 95
 
96 96
 				$free_tkt_count = get_option('uxip_ee_free_tkt_count');
97
-				if ( !empty( $free_tkt_count ) )
98
-					$extra_stats[$site_pre . 'free_tkt_count'] = $free_tkt_count;
97
+				if ( ! empty($free_tkt_count))
98
+					$extra_stats[$site_pre.'free_tkt_count'] = $free_tkt_count;
99 99
 
100 100
 				$paid_tkt_count = get_option('uxip_ee_paid_tkt_count');
101
-				if ( !empty( $paid_tkt_count ) )
102
-					$extra_stats[$site_pre . 'paid_tkt_count'] = $paid_tkt_count;
101
+				if ( ! empty($paid_tkt_count))
102
+					$extra_stats[$site_pre.'paid_tkt_count'] = $paid_tkt_count;
103 103
 
104
-				$tkt_sold = get_option('uxip_ee_tkt_sold' );
105
-				if ( !empty($tkt_sold) )
106
-					$extra_stats[$site_pre . 'tkt_sold'] = $tkt_sold;
104
+				$tkt_sold = get_option('uxip_ee_tkt_sold');
105
+				if ( ! empty($tkt_sold))
106
+					$extra_stats[$site_pre.'tkt_sold'] = $tkt_sold;
107 107
 
108 108
 				//phpversion checking
109 109
 				$extra_stats['phpversion'] = function_exists('phpversion') ? phpversion() : 'unknown';
110 110
 
111 111
 				//set transient
112
-				set_transient( 'ee_extra_data', $extra_stats, WEEK_IN_SECONDS );
112
+				set_transient('ee_extra_data', $extra_stats, WEEK_IN_SECONDS);
113 113
 			}
114 114
 		}
115 115
 
116 116
 
117 117
 
118 118
 		// PUE Auto Upgrades stuff
119
-		if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { //include the file
120
-			require_once(EE_THIRD_PARTY . 'pue/pue-client.php' );
119
+		if (is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) { //include the file
120
+			require_once(EE_THIRD_PARTY.'pue/pue-client.php');
121 121
 
122
-			$api_key = isset( EE_Registry::instance()->NET_CFG->core->site_license_key ) ? EE_Registry::instance()->NET_CFG->core->site_license_key : '';
122
+			$api_key = isset(EE_Registry::instance()->NET_CFG->core->site_license_key) ? EE_Registry::instance()->NET_CFG->core->site_license_key : '';
123 123
 			$host_server_url = 'https://eventespresso.com'; //this needs to be the host server where plugin update engine is installed. Note, if you leave this blank then it is assumed the WordPress repo will be used and we'll just check there.
124 124
 
125 125
 			//Note: PUE uses a simple preg_match to determine what type is currently installed based on version number.  So it's important that you use a key for the version type that is unique and not found in another key.
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 			//$plugin_slug['prerelease']['b'] = 'some-pre-release-slug';
132 132
 			//..WOULD work!
133 133
 			$plugin_slug = array(
134
-				'free' => array( 'decaf' => 'event-espresso-core-decaf' ),
135
-				'premium' => array( 'p' => 'event-espresso-core-reg' ),
136
-				'prerelease' => array( 'beta' => 'event-espresso-core-pr' )
134
+				'free' => array('decaf' => 'event-espresso-core-decaf'),
135
+				'premium' => array('p' => 'event-espresso-core-reg'),
136
+				'prerelease' => array('beta' => 'event-espresso-core-pr')
137 137
 				);
138 138
 
139 139
 
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 	 * @param bool $extra
164 164
 	 * @return string html.
165 165
 	 */
166
-	 public static function espresso_data_collection_optin_text( $extra = true ) {
167
-	 	if ( ! $extra ) {
168
-			 echo '<h2 class="ee-admin-settings-hdr" '. (!$extra ? 'id="UXIP_settings"' : '').'>'.__('User eXperience Improvement Program (UXIP)', 'event_espresso').EEH_Template::get_help_tab_link('organization_logo_info').'</h2>';
169
-			 echo sprintf( __('%sPlease help us make Event Espresso better and vote for your favorite features.%s The %sUser eXperience Improvement Program (UXIP)%s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary but it is enabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %sPlease see our %sPrivacy Policy%s for more information.', 'event_espresso'), '<p><em>', '</em></p>','<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">','</a>','<br><br>','<a href="http://eventespresso.com/about/privacy-policy/" target="_blank">','</a>' );
166
+	 public static function espresso_data_collection_optin_text($extra = true) {
167
+	 	if ( ! $extra) {
168
+			 echo '<h2 class="ee-admin-settings-hdr" '.( ! $extra ? 'id="UXIP_settings"' : '').'>'.__('User eXperience Improvement Program (UXIP)', 'event_espresso').EEH_Template::get_help_tab_link('organization_logo_info').'</h2>';
169
+			 echo sprintf(__('%sPlease help us make Event Espresso better and vote for your favorite features.%s The %sUser eXperience Improvement Program (UXIP)%s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary but it is enabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %sPlease see our %sPrivacy Policy%s for more information.', 'event_espresso'), '<p><em>', '</em></p>', '<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', '</a>', '<br><br>', '<a href="http://eventespresso.com/about/privacy-policy/" target="_blank">', '</a>');
170 170
 		} else {
171
-			$settings_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default'), admin_url( 'admin.php?page=espresso_general_settings') );
171
+			$settings_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default'), admin_url('admin.php?page=espresso_general_settings'));
172 172
 			$settings_url .= '#UXIP_settings';
173
-			echo sprintf( __( 'The Event Espresso UXIP feature is active on your site. For %smore info%s and to opt-out %sclick here%s.', 'event_espresso' ), '<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', '</a>', '<a href="' . $settings_url . '" target="_blank">', '</a>' );
173
+			echo sprintf(__('The Event Espresso UXIP feature is active on your site. For %smore info%s and to opt-out %sclick here%s.', 'event_espresso'), '<a href="http://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">', '</a>', '<a href="'.$settings_url.'" target="_blank">', '</a>');
174 174
 		}
175 175
 	}
176 176
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 
180 180
 	function espresso_data_collection_optin_notice() {
181 181
 		$ueip_has_notified = EE_Registry::instance()->CFG->core->ee_ueip_has_notified;
182
-		if ( $ueip_has_notified ) return;
182
+		if ($ueip_has_notified) return;
183 183
 		// $settings_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default'), admin_url( 'admin.php?page=espresso_general_settings') );
184 184
 		// $settings_url = $settings_url . '#UXIP_settings';
185 185
 		?>
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 	 * @return void
204 204
 	 */
205 205
 	function espresso_data_collection_enqueue_scripts() {
206
-		wp_register_script( 'ee-data-optin-js', EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE );
207
-		wp_register_style( 'ee-data-optin-css', EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css', array(), EVENT_ESPRESSO_VERSION );
206
+		wp_register_script('ee-data-optin-js', EE_GLOBAL_ASSETS_URL.'scripts/ee-data-optin.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
207
+		wp_register_style('ee-data-optin-css', EE_GLOBAL_ASSETS_URL.'css/ee-data-optin.css', array(), EVENT_ESPRESSO_VERSION);
208 208
 
209 209
 		wp_enqueue_script('ee-data-optin-js');
210 210
 		wp_enqueue_style('ee-data-optin-css');
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
 	function espresso_data_optin_ajax_handler() {
220 220
 
221 221
 		//verify nonce
222
-		if ( isset($_POST['nonce']) && !wp_verify_nonce($_POST['nonce'], 'ee-data-optin') ) exit();
222
+		if (isset($_POST['nonce']) && ! wp_verify_nonce($_POST['nonce'], 'ee-data-optin')) exit();
223 223
 
224 224
 		//made it here so let's save the selection
225 225
 		// $ueip_optin = isset( $_POST['selection'] ) ? $_POST['selection'] : 'no';
226 226
 
227 227
 		//update_option('ee_ueip_optin', $ueip_optin);
228 228
 		EE_Registry::instance()->CFG->core->ee_ueip_has_notified = 1;
229
-		EE_Registry::instance()->CFG->update_espresso_config( FALSE, FALSE );
229
+		EE_Registry::instance()->CFG->update_espresso_config(FALSE, FALSE);
230 230
 		exit();
231 231
 	}
232 232
 
@@ -239,22 +239,22 @@  discard block
 block discarded – undo
239 239
 	 */
240 240
 	public static function is_update_available($basename = '') {
241 241
 
242
-		$basename = ! empty( $basename ) ? $basename : EE_PLUGIN_BASENAME;
242
+		$basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
243 243
 
244 244
 		$update = false;
245 245
 
246
-		$folder = DS . dirname($basename); // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
246
+		$folder = DS.dirname($basename); // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
247 247
 
248 248
 		$plugins = get_plugins($folder);
249
-		$current = get_site_transient( 'update_plugins' );
249
+		$current = get_site_transient('update_plugins');
250 250
 
251
-		foreach ( (array) $plugins as $plugin_file => $plugin_data ) {
252
-			if ( isset( $current->response['plugin_file'] ) )
251
+		foreach ((array) $plugins as $plugin_file => $plugin_data) {
252
+			if (isset($current->response['plugin_file']))
253 253
 				$update = true;
254 254
 		}
255 255
 
256 256
 		//it's possible that there is an update but an invalid site-license-key is in use
257
-		if ( get_site_option('pue_json_error_' . $basename ) )
257
+		if (get_site_option('pue_json_error_'.$basename))
258 258
 			$update = true;
259 259
 
260 260
 		return $update;
@@ -272,9 +272,9 @@  discard block
 block discarded – undo
272 272
 	 * @return void
273 273
 	 */
274 274
 	public function _uxip_hooks() {
275
-		if ( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ) {
276
-			add_action('admin_init', array( $this, 'track_active_theme' ) );
277
-			add_action('admin_init', array( $this, 'track_event_info' ) );
275
+		if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
276
+			add_action('admin_init', array($this, 'track_active_theme'));
277
+			add_action('admin_init', array($this, 'track_event_info'));
278 278
 		}
279 279
 	}
280 280
 
@@ -283,66 +283,66 @@  discard block
 block discarded – undo
283 283
 
284 284
 	public function track_active_theme() {
285 285
 		//we only check this once a month.
286
-		if ( false === ( $transient = get_transient( 'ee_active_theme_check' ) ) ) {
286
+		if (false === ($transient = get_transient('ee_active_theme_check'))) {
287 287
 			$theme = wp_get_theme();
288
-			update_option('uxip_ee_active_theme', $theme->get('Name') );
289
-			set_transient('ee_active_theme_check', 1, MONTH_IN_SECONDS );
288
+			update_option('uxip_ee_active_theme', $theme->get('Name'));
289
+			set_transient('ee_active_theme_check', 1, MONTH_IN_SECONDS);
290 290
 		}
291 291
 	}
292 292
 
293 293
 
294 294
 	public function track_event_info() {
295 295
 		//we only check this once every couple weeks.
296
-		if ( false === ( $transient = get_transient( 'ee4_event_info_check') ) ) {
296
+		if (false === ($transient = get_transient('ee4_event_info_check'))) {
297 297
 			//first let's get the number for ALL events
298 298
 			/** @var EEM_Event $EVT */
299
-			$EVT = EE_Registry::instance()->load_model( 'Event');
299
+			$EVT = EE_Registry::instance()->load_model('Event');
300 300
 			$DTT = EE_Registry::instance()->load_model('Datetime');
301 301
 			$TKT = EE_Registry::instance()->load_model('Ticket');
302 302
 			$count = $EVT->count();
303
-			if ( $count > 0 )
303
+			if ($count > 0)
304 304
 				update_option('uxip_ee4_all_events_count', $count);
305 305
 
306 306
 			//next let's just get the number of ACTIVE events
307 307
 			$count_active = $EVT->get_active_events(array(), TRUE);
308
-			if ( $count_active > 0 )
308
+			if ($count_active > 0)
309 309
 				update_option('uxip_ee4_active_events_count', $count_active);
310 310
 
311 311
 			//datetimes!
312 312
 			$dtt_count = $DTT->count();
313
-			if ( $dtt_count > 0 )
314
-				update_option( 'uxip_ee_all_dtts_count', $dtt_count );
313
+			if ($dtt_count > 0)
314
+				update_option('uxip_ee_all_dtts_count', $dtt_count);
315 315
 
316 316
 
317 317
 			//dttsold
318 318
 			$dtt_sold = $DTT->sum(array(), 'DTT_sold');
319
-			if ( $dtt_sold > 0 )
320
-				update_option( 'uxip_ee_dtt_sold', $dtt_sold );
319
+			if ($dtt_sold > 0)
320
+				update_option('uxip_ee_dtt_sold', $dtt_sold);
321 321
 
322 322
 			//allticketcount
323 323
 			$all_tkt_count = $TKT->count();
324
-			if ( $all_tkt_count > 0 )
325
-				update_option( 'uxip_ee_all_tkt_count', $all_tkt_count );
324
+			if ($all_tkt_count > 0)
325
+				update_option('uxip_ee_all_tkt_count', $all_tkt_count);
326 326
 
327 327
 			//freetktcount
328
-			$_where = array( 'TKT_price' => 0 );
328
+			$_where = array('TKT_price' => 0);
329 329
 			$free_tkt_count = $TKT->count(array($_where));
330
-			if ( $free_tkt_count > 0 )
331
-				update_option( 'uxip_ee_free_tkt_count', $free_tkt_count );
330
+			if ($free_tkt_count > 0)
331
+				update_option('uxip_ee_free_tkt_count', $free_tkt_count);
332 332
 
333 333
 			//paidtktcount
334
-			$_where = array( 'TKT_price' => array('>', 0) );
335
-			$paid_tkt_count = $TKT->count( array( $_where ) );
336
-			if ( $paid_tkt_count > 0 )
337
-				update_option( 'uxip_ee_paid_tkt_count', $paid_tkt_count );
334
+			$_where = array('TKT_price' => array('>', 0));
335
+			$paid_tkt_count = $TKT->count(array($_where));
336
+			if ($paid_tkt_count > 0)
337
+				update_option('uxip_ee_paid_tkt_count', $paid_tkt_count);
338 338
 
339 339
 			//tktsold
340
-			$tkt_sold = $TKT->sum( array(), 'TKT_sold' );
341
-			if( $tkt_sold > 0 )
342
-				update_option( 'uxip_ee_tkt_sold', $tkt_sold );
340
+			$tkt_sold = $TKT->sum(array(), 'TKT_sold');
341
+			if ($tkt_sold > 0)
342
+				update_option('uxip_ee_tkt_sold', $tkt_sold);
343 343
 
344 344
 
345
-			set_transient( 'ee4_event_info_check', 1, WEEK_IN_SECONDS * 2 );
345
+			set_transient('ee4_event_info_check', 1, WEEK_IN_SECONDS * 2);
346 346
 		}
347 347
 	}
348 348
 
Please login to merge, or discard this patch.
core/interfaces/ResettableInterface.php 2 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -799,7 +799,6 @@
 block discarded – undo
799 799
 
800 800
 
801 801
 	/**
802
-
803 802
 	 *
804 803
 	 * 	 If the the first date starts at midnight on one day, and the next date ends at midnight on the
805 804
 	 * 	 very next day then this method will return true.
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EE_Line_Item_Filter_Collection
Please login to merge, or discard this patch.
core/interfaces/UnsettableInterface.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EE_Line_Item_Filter_Collection
Please login to merge, or discard this patch.
core/EE_Data_Migration_Manager.core.php 1 patch
Spacing   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * of this EE installation. Keys should be the name of the version the script upgraded to
79 79
 	 * @var EE_Data_Migration_Script_Base[]
80 80
 	 */
81
-	private $_data_migrations_ran =null;
81
+	private $_data_migrations_ran = null;
82 82
 	/**
83 83
 	 * The last ran script. It's nice to store this somewhere accessible, as its easiest
84 84
 	 * to know which was the last run by which is the newest wp option; but in most of the code
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public static function instance() {
124 124
 		// check if class object is instantiated
125
-		if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) {
125
+		if ( ! self::$_instance instanceof EE_Data_Migration_Manager) {
126 126
 			self::$_instance = new self();
127 127
 		}
128 128
 		return self::$_instance;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * all new usages of the singleton should be made with Classname::instance()) and returns it
133 133
 	 * @return EE_Data_Migration_Manager
134 134
 	 */
135
-	public static function reset(){
135
+	public static function reset() {
136 136
 		self::$_instance = NULL;
137 137
 		return self::instance();
138 138
 	}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	/**
143 143
 	 * constructor
144 144
 	 */
145
-	private function __construct(){
145
+	private function __construct() {
146 146
 		$this->stati_that_indicate_to_continue_migrations = array(
147 147
 			self::status_continue,
148 148
 			self::status_completed
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 		);
162 162
 		//make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class
163 163
 		//to be defined, because right now it doesn't get autoloaded on its own
164
-		EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE );
165
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE );
166
-		EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE );
167
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE );
168
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE );
164
+		EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE);
165
+		EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE);
166
+		EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE);
167
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE);
168
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE);
169 169
 	}
170 170
 
171 171
 
@@ -178,21 +178,21 @@  discard block
 block discarded – undo
178 178
 	 * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set)
179 179
 	 * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of that plugin (eg '4.1.0')
180 180
 	 */
181
-	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){
181
+	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) {
182 182
 		$plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name);
183 183
 		//check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style)
184
-		$parts = explode(".",$plugin_slug_and_version_string);
184
+		$parts = explode(".", $plugin_slug_and_version_string);
185 185
 
186
-		if(count($parts) == 4){
186
+		if (count($parts) == 4) {
187 187
 			//it's 4.2-style.eg Core.4.1.0
188
-			$plugin_slug = $parts[0];//eg Core
188
+			$plugin_slug = $parts[0]; //eg Core
189 189
 			$version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0
190
-		}else{
190
+		} else {
191 191
 			//it's 4.1-style: eg 4.1.0
192 192
 			$plugin_slug = 'Core';
193
-			$version_string = $plugin_slug_and_version_string;//eg 4.1.0
193
+			$version_string = $plugin_slug_and_version_string; //eg 4.1.0
194 194
 		}
195
-		return array($plugin_slug,$version_string);
195
+		return array($plugin_slug, $version_string);
196 196
 	}
197 197
 
198 198
 	/**
@@ -203,21 +203,21 @@  discard block
 block discarded – undo
203 203
 	 * @return EE_Data_Migration_Script_Base
204 204
 	 * @throws EE_Error
205 205
 	 */
206
-	private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){
206
+	private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) {
207 207
 		$data_migration_data = maybe_unserialize($dms_option_value);
208
-		if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){
208
+		if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) {
209 209
 			$class = new $data_migration_data['class'];
210
-			if($class instanceof EE_Data_Migration_Script_Base){
210
+			if ($class instanceof EE_Data_Migration_Script_Base) {
211 211
 				$class->instantiate_from_array_of_properties($data_migration_data);
212 212
 				return $class;
213
-			}else{
213
+			} else {
214 214
 				//huh, so its an object but not a data migration script?? that shouldn't happen
215 215
 				//just leave it as an array (which will probably just get ignored)
216
-				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class']));
216
+				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'), $data_migration_data['class']));
217 217
 			}
218
-		}else{
218
+		} else {
219 219
 			//so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists
220
-			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name));
220
+			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name));
221 221
 		}
222 222
 	}
223 223
 	/**
@@ -225,34 +225,34 @@  discard block
 block discarded – undo
225 225
 	 * the last ran which hasn't finished yet
226 226
 	 * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy arrays in there - which should probably be ignored)
227 227
 	 */
228
-	public function get_data_migrations_ran(){
229
-		if( ! $this->_data_migrations_ran ){
228
+	public function get_data_migrations_ran() {
229
+		if ( ! $this->_data_migrations_ran) {
230 230
 			//setup autoloaders for each of the scripts in there
231 231
 			$this->get_all_data_migration_scripts_available();
232
-			$data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
232
+			$data_migrations_options = $this->get_all_migration_script_options(); //get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
233 233
 
234 234
 			$data_migrations_ran = array();
235 235
 			//convert into data migration script classes where possible
236
-			foreach($data_migrations_options as $data_migration_option){
237
-				list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']);
236
+			foreach ($data_migrations_options as $data_migration_option) {
237
+				list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']);
238 238
 
239
-				try{
240
-					$class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']);
239
+				try {
240
+					$class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']);
241 241
 					$data_migrations_ran[$plugin_slug][$version_string] = $class;
242 242
 					//ok so far THIS is the 'last-ran-script'... unless we find another on next iteration
243 243
 					$this->_last_ran_script = $class;
244
-					if( ! $class->is_completed()){
244
+					if ( ! $class->is_completed()) {
245 245
 						//sometimes we also like to know which was the last incomplete script (or if there are any at all)
246 246
 						$this->_last_ran_incomplete_script = $class;
247 247
 					}
248
-				}catch(EE_Error $e){
248
+				} catch (EE_Error $e) {
249 249
 					//ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs
250 250
 					$data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']);
251 251
 				}
252 252
 			}
253 253
 			//so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays
254 254
 			$this->_data_migrations_ran = $data_migrations_ran;
255
-			 if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){
255
+			 if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) {
256 256
 				$this->_data_migrations_ran = array();
257 257
 			}
258 258
 		}
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * @param        $new_table
270 270
 	 * @return mixed string or int
271 271
 	 */
272
-	public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){
272
+	public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) {
273 273
 		$script = EE_Registry::instance()->load_dms($script_name);
274 274
 		$mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table);
275 275
 		return $mapping;
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	 * option returned in this array is the most-recently ran DMS option
281 281
 	 * @return array
282 282
 	 */
283
-	 public function get_all_migration_script_options(){
283
+	 public function get_all_migration_script_options() {
284 284
 		global $wpdb;
285
-		return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A);
285
+		return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC", ARRAY_A);
286 286
 	}
287 287
 
288 288
 	/**
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 	 * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the
291 291
 	 * folder name.
292 292
 	 */
293
-	public function get_data_migration_script_folders(){
294
-		return  apply_filters( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',array(EE_CORE.'data_migration_scripts') );
293
+	public function get_data_migration_script_folders() {
294
+		return  apply_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array(EE_CORE.'data_migration_scripts'));
295 295
 	}
296 296
 
297 297
 	/**
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 	 * }
304 304
 	 * @throws EE_Error
305 305
 	 */
306
-	public function script_migrates_to_version($migration_script_name){
306
+	public function script_migrates_to_version($migration_script_name) {
307 307
 		$dms_info = $this->parse_dms_classname($migration_script_name);
308 308
 		return array(
309
-			'slug'=> $dms_info[ 'slug' ],
310
-			'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ] );
309
+			'slug'=> $dms_info['slug'],
310
+			'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'] );
311 311
 	}
312 312
 
313 313
 	/**
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints)
317 317
 	 * @throws EE_Error
318 318
 	 */
319
-	public function parse_dms_classname($classname){
319
+	public function parse_dms_classname($classname) {
320 320
 		$matches = array();
321
-		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches);
322
-		if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){
323
-				throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"),$classname));
321
+		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches);
322
+		if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) {
323
+				throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"), $classname));
324 324
 		}
325
-		return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4]));
325
+		return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4]));
326 326
 	}
327 327
 	/**
328 328
 	 * Ensures that the option indicating the current DB version is set. This should only be
@@ -331,33 +331,33 @@  discard block
 block discarded – undo
331 331
 	 * to 4.1.x.
332 332
 	 * @return string of current db state
333 333
 	 */
334
-	public function ensure_current_database_state_is_set(){
335
-		$espresso_db_core_updates = get_option( 'espresso_db_update', array() );
334
+	public function ensure_current_database_state_is_set() {
335
+		$espresso_db_core_updates = get_option('espresso_db_update', array());
336 336
 		$db_state = get_option(EE_Data_Migration_Manager::current_database_state);
337
-		if( ! $db_state ){
337
+		if ( ! $db_state) {
338 338
 			//mark the DB as being in the state as the last version in there.
339 339
 			//this is done to trigger maintenance mode and do data migration scripts
340 340
 			//if the admin installed this version of EE over 3.1.x or 4.0.x
341 341
 			//otherwise, the normal maintenance mode code is fine
342 342
 			$previous_versions_installed = array_keys($espresso_db_core_updates);
343 343
 			$previous_version_installed = end($previous_versions_installed);
344
-			if(version_compare('4.1.0', $previous_version_installed)){
344
+			if (version_compare('4.1.0', $previous_version_installed)) {
345 345
 				//last installed version was less than 4.1
346 346
 				//so we want the data migrations to happen. SO, we're going to say the DB is at that state
347 347
 //				echo "4.1.0 is greater than $previous_version_installed! update the option";
348 348
 				$db_state = array('Core'=>$previous_version_installed);
349
-			}else{
349
+			} else {
350 350
 //					echo "4.1.0 is SMALLER than $previous_version_installed";
351 351
 					$db_state = array('Core'=>EVENT_ESPRESSO_VERSION);
352 352
 			}
353
-			update_option(EE_Data_Migration_Manager::current_database_state,$db_state);
353
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
354 354
 		}
355 355
 		//in 4.1, $db_state would have only been a simple string like '4.1.0',
356 356
 		//but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's
357 357
 		//db, and possibly other keys for other addons like 'Calendar','Permissions',etc
358
-		if( ! is_array($db_state)){
358
+		if ( ! is_array($db_state)) {
359 359
 			$db_state = array('Core'=>$db_state);
360
-			update_option(EE_Data_Migration_Manager::current_database_state,$db_state);
360
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
361 361
 		}
362 362
 		return $db_state;
363 363
 	}
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 * or they don't apply), returns an empty array
369 369
 	 * @return EE_Data_Migration_Script_Base[]
370 370
 	 */
371
-	public function check_for_applicable_data_migration_scripts(){
371
+	public function check_for_applicable_data_migration_scripts() {
372 372
 		//get the option describing what options have already run
373 373
 		$scripts_ran = $this->get_data_migrations_ran();
374 374
 		//$scripts_ran = array('4.1.0.core'=>array('monkey'=>null));
@@ -381,62 +381,62 @@  discard block
 block discarded – undo
381 381
 		$iteration = 0;
382 382
 		$next_database_state_to_consider = $current_database_state;
383 383
 		$theoretical_database_state = NULL;
384
-		do{
384
+		do {
385 385
 			//the next state after the currently-considered one will start off looking the same as the current, but we may make additions...
386 386
 			$theoretical_database_state = $next_database_state_to_consider;
387 387
 			//the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?)
388
-			foreach($script_class_and_filepaths_available as $classname => $filepath){
388
+			foreach ($script_class_and_filepaths_available as $classname => $filepath) {
389 389
 
390 390
 				$migrates_to_version = $this->script_migrates_to_version($classname);
391
-				$script_converts_plugin_slug = $migrates_to_version[ 'slug' ];
392
-				$script_converts_to_version = $migrates_to_version[ 'version' ];
391
+				$script_converts_plugin_slug = $migrates_to_version['slug'];
392
+				$script_converts_to_version = $migrates_to_version['version'];
393 393
 				//check if this version script is DONE or not; or if it's never been ran
394
-				if(		! $scripts_ran ||
394
+				if ( ! $scripts_ran ||
395 395
 						! isset($scripts_ran[$script_converts_plugin_slug]) ||
396
-						! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){
396
+						! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) {
397 397
 					//we haven't ran this conversion script before
398 398
 					//now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available
399 399
 					$script = new $classname;
400 400
 					/* @var $script EE_Data_Migration_Script_Base */
401 401
 					$can_migrate = $script->can_migrate_from_version($theoretical_database_state);
402
-					if($can_migrate){
402
+					if ($can_migrate) {
403 403
 						$script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
404 404
 						$migrates_to_version = $script->migrates_to_version();
405
-						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
405
+						$next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
406 406
 						unset($script_class_and_filepaths_available[$classname]);
407 407
 					}
408
-				} elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){
408
+				} elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) {
409 409
 					//this script has been ran, or at least started
410 410
 					$script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version];
411
-					if( $script->get_status() != self::status_completed){
411
+					if ($script->get_status() != self::status_completed) {
412 412
 						//this script is already underway... keep going with it
413 413
 						$script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
414 414
 						$migrates_to_version = $script->migrates_to_version();
415
-						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
415
+						$next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
416 416
 						unset($script_class_and_filepaths_available[$classname]);
417
-					}else{
417
+					} else {
418 418
 						//it must have a status that indicates it has finished, so we don't want to try and run it again
419 419
 					}
420
-				}else{
420
+				} else {
421 421
 					//it exists but it's not  a proper data migration script
422 422
 					//maybe the script got renamed? or was simply removed from EE?
423 423
 					//either way, its certainly not runnable!
424 424
 				}
425 425
 			}
426 426
 			$iteration++;
427
-		}while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6);
427
+		}while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6);
428 428
 		//ok we have all the scripts that should run, now let's make them into flat array
429 429
 		$scripts_that_should_run = array();
430
-		foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){
430
+		foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) {
431 431
 			ksort($scripts_at_priority);
432
-			foreach($scripts_at_priority as $scripts){
433
-				foreach($scripts as $script){
432
+			foreach ($scripts_at_priority as $scripts) {
433
+				foreach ($scripts as $script) {
434 434
 					$scripts_that_should_run[get_class($script)] = $script;
435 435
 				}
436 436
 			}
437 437
 		}
438 438
 
439
-		do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run );
439
+		do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run);
440 440
 		return $scripts_that_should_run;
441 441
 	}
442 442
 
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
 	 * @param bool $include_completed_scripts
451 451
 	 * @return EE_Data_Migration_Script_Base
452 452
 	 */
453
-	public function get_last_ran_script($include_completed_scripts = false){
453
+	public function get_last_ran_script($include_completed_scripts = false) {
454 454
 		//make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script
455
-		if( ! $this->_data_migrations_ran){
455
+		if ( ! $this->_data_migrations_ran) {
456 456
 			$this->get_data_migrations_ran();
457 457
 		}
458
-		if($include_completed_scripts){
458
+		if ($include_completed_scripts) {
459 459
 			return $this->_last_ran_script;
460
-		}else{
460
+		} else {
461 461
 			return $this->_last_ran_incomplete_script;
462 462
 		}
463 463
 	}
@@ -480,19 +480,19 @@  discard block
 block discarded – undo
480 480
 	 * 		@type string $message string describing what was done during this step
481 481
 	 * }
482 482
 	 */
483
-	public function migration_step( $step_size = 0 ){
483
+	public function migration_step($step_size = 0) {
484 484
 
485 485
 		//bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535
486
-		if ( class_exists( 'EE_CPT_Strategy' ) ) {
487
-			remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 );
486
+		if (class_exists('EE_CPT_Strategy')) {
487
+			remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5);
488 488
 		}
489 489
 
490
-		try{
490
+		try {
491 491
 			$currently_executing_script = $this->get_last_ran_script();
492
-			if( ! $currently_executing_script){
492
+			if ( ! $currently_executing_script) {
493 493
 				//Find the next script that needs to execute
494 494
 				$scripts = $this->check_for_applicable_data_migration_scripts();
495
-				if( ! $scripts ){
495
+				if ( ! $scripts) {
496 496
 					//huh, no more scripts to run... apparently we're done!
497 497
 					//but dont forget to make sure initial data is there
498 498
 					//we should be good to allow them to exit maintenance mode now
@@ -513,18 +513,18 @@  discard block
 block discarded – undo
513 513
 				//and add to the array/wp option showing the scripts ran
514 514
 //				$this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script;
515 515
 				$migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script));
516
-				$plugin_slug = $migrates_to[ 'slug' ];
517
-				$version = $migrates_to[ 'version' ];
516
+				$plugin_slug = $migrates_to['slug'];
517
+				$version = $migrates_to['version'];
518 518
 				$this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script;
519 519
 			}
520 520
 			$current_script_name = get_class($currently_executing_script);
521
-		}catch(Exception $e){
521
+		} catch (Exception $e) {
522 522
 			//an exception occurred while trying to get migration scripts
523 523
 
524
-			$message =  sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() );
524
+			$message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString());
525 525
 			//record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations
526 526
 			//but that's ok-- it's just an FYI to support that we couldn't even run any data migrations
527
-			$this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message));
527
+			$this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message));
528 528
 			return array(
529 529
 				'records_to_migrate'=>1,
530 530
 				'records_migrated'=>0,
@@ -534,16 +534,16 @@  discard block
 block discarded – undo
534 534
 			);
535 535
 		}
536 536
 		//ok so we definitely have a data migration script
537
-		try{
537
+		try {
538 538
 			//how big of a bite do we want to take? Allow users to easily override via their wp-config
539
-			if( ! absint( $step_size ) > 0 ){
540
-				$step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
539
+			if ( ! absint($step_size) > 0) {
540
+				$step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
541 541
 			}
542 542
 			//do what we came to do!
543 543
 			$currently_executing_script->migration_step($step_size);
544 544
 			//can we wrap it up and verify default data?
545 545
 			$init_dbs = false;
546
-			switch($currently_executing_script->get_status()){
546
+			switch ($currently_executing_script->get_status()) {
547 547
 				case EE_Data_Migration_Manager::status_continue:
548 548
 					$response_array = array(
549 549
 						'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
@@ -555,16 +555,16 @@  discard block
 block discarded – undo
555 555
 				case EE_Data_Migration_Manager::status_completed:
556 556
 					//ok so THAT script has completed
557 557
 					$this->update_current_database_state_to($this->script_migrates_to_version($current_script_name));
558
-					$response_array =  array(
558
+					$response_array = array(
559 559
 							'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
560 560
 							'records_migrated'=>$currently_executing_script->count_records_migrated(),
561 561
 							'status'=> EE_Data_Migration_Manager::status_completed,
562 562
 							'message'=>$currently_executing_script->get_feedback_message(),
563
-							'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name())
563
+							'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name())
564 564
 						);
565 565
 					//check if there are any more after this one.
566 566
 					$scripts_remaining = $this->check_for_applicable_data_migration_scripts();
567
-					if( ! $scripts_remaining ){
567
+					if ( ! $scripts_remaining) {
568 568
 						//we should be good to allow them to exit maintenance mode now
569 569
 						EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance));
570 570
 						////huh, no more scripts to run... apparently we're done!
@@ -578,39 +578,39 @@  discard block
 block discarded – undo
578 578
 						'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
579 579
 						'records_migrated'=>$currently_executing_script->count_records_migrated(),
580 580
 						'status'=> $currently_executing_script->get_status(),
581
-						'message'=>  sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())),
581
+						'message'=>  sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())),
582 582
 						'script'=>$currently_executing_script->pretty_name()
583 583
 					);
584 584
 					break;
585 585
 			}
586
-		}catch(Exception $e){
586
+		} catch (Exception $e) {
587 587
 			//ok so some exception was thrown which killed the data migration script
588 588
 			//double-check we have a real script
589
-			if($currently_executing_script instanceof EE_Data_Migration_Script_Base){
589
+			if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) {
590 590
 				$script_name = $currently_executing_script->pretty_name();
591 591
 				$currently_executing_script->set_broken();
592 592
 				$currently_executing_script->add_error($e->getMessage());
593
-			}else{
593
+			} else {
594 594
 				$script_name = __("Error getting Migration Script", "event_espresso");
595 595
 			}
596 596
 			$response_array = array(
597 597
 				'records_to_migrate'=>1,
598 598
 				'records_migrated'=>0,
599 599
 				'status'=>self::status_fatal_error,
600
-				'message'=>  sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()),
600
+				'message'=>  sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()),
601 601
 				'script'=>$script_name
602 602
 			);
603 603
 		}
604 604
 		$successful_save = $this->_save_migrations_ran();
605
-		if($successful_save !== TRUE){
605
+		if ($successful_save !== TRUE) {
606 606
 			//ok so the current wp option didn't save. that's tricky, because we'd like to update it
607 607
 			//and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION!
608 608
 			//however, if we throw an exception, and return that, then the next request
609 609
 			//won't have as much info in it, and it may be able to save
610
-			throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save));
610
+			throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"), $successful_save));
611 611
 		}
612 612
 		//if we're all done, initialize EE plugins' default data etc.
613
-		if( $init_dbs ) {
613
+		if ($init_dbs) {
614 614
 			$this->initialize_db_for_enqueued_ee_plugins();
615 615
 		}
616 616
 		return $response_array;
@@ -628,23 +628,23 @@  discard block
 block discarded – undo
628 628
 	 * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into errors, notifications, and successes
629 629
 	 * 'script'=>a pretty name of the script currently running
630 630
 	 */
631
-	public function response_to_migration_ajax_request(){
631
+	public function response_to_migration_ajax_request() {
632 632
 //		//start output buffer just to make sure we don't mess up the json
633 633
 		ob_start();
634
-		try{
634
+		try {
635 635
 			$response = $this->migration_step();
636
-		}catch(Exception $e){
636
+		} catch (Exception $e) {
637 637
 			$response = array(
638 638
 				'records_to_migrate'=>0,
639 639
 				'records_migrated'=>0,
640 640
 				'status'=> EE_Data_Migration_Manager::status_fatal_error,
641
-				'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()),
641
+				'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()),
642 642
 				'script'=>'Unknown');
643 643
 			$this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString());
644 644
 		}
645 645
 		$warnings_etc = @ob_get_contents();
646 646
 		ob_end_clean();
647
-		$response['message'] .=$warnings_etc;
647
+		$response['message'] .= $warnings_etc;
648 648
 		return $response;
649 649
 	}
650 650
 
@@ -657,14 +657,14 @@  discard block
 block discarded – undo
657 657
 	 * }
658 658
 	 * @return void
659 659
 	 */
660
-	public function update_current_database_state_to($slug_and_version = null){
661
-		if( ! $slug_and_version ){
660
+	public function update_current_database_state_to($slug_and_version = null) {
661
+		if ( ! $slug_and_version) {
662 662
 			//no version was provided, assume it should be at the current code version
663 663
 			$slug_and_version = array('slug' => 'Core', 'version' => espresso_version());
664 664
 		}
665 665
 		$current_database_state = get_option(self::current_database_state);
666
-		$current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ];
667
-		update_option(self::current_database_state,$current_database_state);
666
+		$current_database_state[$slug_and_version['slug']] = $slug_and_version['version'];
667
+		update_option(self::current_database_state, $current_database_state);
668 668
 	}
669 669
 
670 670
 	/**
@@ -675,20 +675,20 @@  discard block
 block discarded – undo
675 675
 	 * }
676 676
 	 * @return boolean
677 677
 	 */
678
-	public function database_needs_updating_to( $slug_and_version ) {
678
+	public function database_needs_updating_to($slug_and_version) {
679 679
 
680
-		$slug = $slug_and_version[ 'slug' ];
681
-		$version = $slug_and_version[ 'version' ];
680
+		$slug = $slug_and_version['slug'];
681
+		$version = $slug_and_version['version'];
682 682
 		$current_database_state = get_option(self::current_database_state);
683
-		if( ! isset( $current_database_state[ $slug ] ) ) {
683
+		if ( ! isset($current_database_state[$slug])) {
684 684
 			return true;
685
-		}else{
685
+		} else {
686 686
 			//just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes
687
-			$version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3);
688
-			$version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 );
687
+			$version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3);
688
+			$version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3);
689 689
 			$needs_updating = false;
690
-			foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) {
691
-				if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) {
690
+			foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) {
691
+				if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) {
692 692
 					$needs_updating = true;
693 693
 					break;
694 694
 				}
@@ -702,29 +702,29 @@  discard block
 block discarded – undo
702 702
 	 * in addons. Has the side effect of adding them for autoloading
703 703
 	 * @return array keys are expected classnames, values are their filepaths
704 704
 	 */
705
-	public function get_all_data_migration_scripts_available(){
706
-		if( ! $this->_data_migration_class_to_filepath_map){
705
+	public function get_all_data_migration_scripts_available() {
706
+		if ( ! $this->_data_migration_class_to_filepath_map) {
707 707
 			$this->_data_migration_class_to_filepath_map = array();
708
-			foreach($this->get_data_migration_script_folders() as $folder_path){
709
-				if($folder_path[count($folder_path-1)] != DS ){
710
-					$folder_path.= DS;
708
+			foreach ($this->get_data_migration_script_folders() as $folder_path) {
709
+				if ($folder_path[count($folder_path - 1)] != DS) {
710
+					$folder_path .= DS;
711 711
 				}
712
-				$files = glob( $folder_path. '*.dms.php' );
712
+				$files = glob($folder_path.'*.dms.php');
713 713
 
714
-				if ( empty( $files ) ) {
714
+				if (empty($files)) {
715 715
 					continue;
716 716
 				}
717 717
 
718
-				foreach($files as $file){
719
-					$pos_of_last_slash = strrpos($file,DS);
720
-					$classname = str_replace(".dms.php","", substr($file, $pos_of_last_slash+1));
721
-					$migrates_to = $this->script_migrates_to_version( $classname );
722
-					$slug = $migrates_to[ 'slug' ];
718
+				foreach ($files as $file) {
719
+					$pos_of_last_slash = strrpos($file, DS);
720
+					$classname = str_replace(".dms.php", "", substr($file, $pos_of_last_slash + 1));
721
+					$migrates_to = $this->script_migrates_to_version($classname);
722
+					$slug = $migrates_to['slug'];
723 723
 					//check that the slug as contained in the DMS is associated with
724 724
 					//the slug of an addon or core
725
-					if( $slug != 'Core' ){
726
-						if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) {
727
-							EE_Error::doing_it_wrong(__FUNCTION__, sprintf( __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ),$classname,$slug,implode(",", array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ), '4.3.0.alpha.019' );
725
+					if ($slug != 'Core') {
726
+						if ( ! EE_Registry::instance()->get_addon_by_name($slug)) {
727
+							EE_Error::doing_it_wrong(__FUNCTION__, sprintf(__('The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso'), $classname, $slug, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))), '4.3.0.alpha.019');
728 728
 						}
729 729
 					}
730 730
 					$this->_data_migration_class_to_filepath_map[$classname] = $file;
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 	 * from each addon, and check if they need updating,
745 745
 	 * @return boolean
746 746
 	 */
747
-	public function addons_need_updating(){
747
+	public function addons_need_updating() {
748 748
 		return false;
749 749
 	}
750 750
 	/**
@@ -753,25 +753,25 @@  discard block
 block discarded – undo
753 753
 	 * @param string $error_message
754 754
 	 * @throws EE_Error
755 755
 	 */
756
-	public function add_error_to_migrations_ran($error_message){
756
+	public function add_error_to_migrations_ran($error_message) {
757 757
 		//get last-ran migration script
758 758
 		global $wpdb;
759
-		$last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1",ARRAY_A);
759
+		$last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1", ARRAY_A);
760 760
 
761 761
 		$last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null;
762 762
 		//now, tread lightly because we're here because a FATAL non-catchable error
763 763
 		//was thrown last time when we were trying to run a data migration script
764 764
 		//so the fatal error could have happened while getting the migration script
765 765
 		//or doing running it...
766
-		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$last_migration_script_option['option_name']) : null;
766
+		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $last_migration_script_option['option_name']) : null;
767 767
 
768 768
 		//check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet
769 769
 		//because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done)
770
-		if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){
770
+		if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) {
771 771
 			//ok then just add this error to its list of errors
772 772
 			$last_ran_migration_script_properties['_errors'][] = $error_message;
773 773
 			$last_ran_migration_script_properties['_status'] = self::status_fatal_error;
774
-		}else{
774
+		} else {
775 775
 			//so we don't even know which script was last running
776 776
 			//use the data migration error stub, which is designed specifically for this type of thing
777 777
 			$general_migration_error = new EE_DMS_Unknown_1_0_0();
@@ -781,39 +781,39 @@  discard block
 block discarded – undo
781 781
 			$versions_migrated_to = 'Unknown.1.0.0';
782 782
 			//now just to make sure appears as last (in case the were previously a fatal error like this)
783 783
 			//delete the old one
784
-			delete_option( self::data_migration_script_option_prefix . $versions_migrated_to );
784
+			delete_option(self::data_migration_script_option_prefix.$versions_migrated_to);
785 785
 		}
786
-		update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties);
786
+		update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties);
787 787
 
788 788
 	}
789 789
 	/**
790 790
 	 * saves what data migrations have ran to the database
791 791
 	 * @return mixed TRUE if successfully saved migrations ran, string if an error occurred
792 792
 	 */
793
-	protected function _save_migrations_ran(){
794
-		if($this->_data_migrations_ran == null){
793
+	protected function _save_migrations_ran() {
794
+		if ($this->_data_migrations_ran == null) {
795 795
 			$this->get_data_migrations_ran();
796 796
 		}
797 797
 		//now, we don't want to save actual classes to the DB because that's messy
798 798
 		$successful_updates = true;
799
-		foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){
800
-			foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){
799
+		foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) {
800
+			foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) {
801 801
 	//			echo "saving migration script to $version_string<br>";
802 802
 				$plugin_slug_for_use_in_option_name = $plugin_slug.".";
803 803
 				$option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string;
804 804
 				$old_option_value = get_option($option_name);
805
-				if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){
805
+				if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) {
806 806
 					$script_array_for_saving = $array_or_migration_obj->properties_as_array();
807
-					if( $old_option_value != $script_array_for_saving){
808
-						$successful_updates = update_option($option_name,$script_array_for_saving);
807
+					if ($old_option_value != $script_array_for_saving) {
808
+						$successful_updates = update_option($option_name, $script_array_for_saving);
809 809
 					}
810
-				}else{//we don't know what this array-thing is. So just save it as-is
810
+				} else {//we don't know what this array-thing is. So just save it as-is
811 811
 	//				$array_of_migrations[$version_string] = $array_or_migration_obj;
812
-					if($old_option_value != $array_or_migration_obj){
813
-						$successful_updates = update_option($option_name,$array_or_migration_obj);
812
+					if ($old_option_value != $array_or_migration_obj) {
813
+						$successful_updates = update_option($option_name, $array_or_migration_obj);
814 814
 					}
815 815
 				}
816
-				if( ! $successful_updates ){
816
+				if ( ! $successful_updates) {
817 817
 					global $wpdb;
818 818
 					return $wpdb->last_error;
819 819
 				}
@@ -837,17 +837,17 @@  discard block
 block discarded – undo
837 837
 	 * @return EE_Data_Migration_Script_Base
838 838
 	 * @throws EE_Error
839 839
 	 */
840
-	function _instantiate_script_from_properties_array($properties_array){
841
-		if( ! isset($properties_array['class'])){
842
-			throw new EE_Error(sprintf(__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array)));
840
+	function _instantiate_script_from_properties_array($properties_array) {
841
+		if ( ! isset($properties_array['class'])) {
842
+			throw new EE_Error(sprintf(__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array)));
843 843
 		}
844 844
 		$class_name = $properties_array['class'];
845
-		if( ! class_exists($class_name)){
846
-			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name));
845
+		if ( ! class_exists($class_name)) {
846
+			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name));
847 847
 		}
848 848
 		$class = new $class_name;
849
-		if( ! $class instanceof EE_Data_Migration_Script_Base){
850
-			throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),$class_name,get_class($class)));
849
+		if ( ! $class instanceof EE_Data_Migration_Script_Base) {
850
+			throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"), $class_name, get_class($class)));
851 851
 		}
852 852
 		$class->instantiate_from_array_of_properties($properties_array);
853 853
 		return $class;
@@ -859,25 +859,25 @@  discard block
 block discarded – undo
859 859
 	 * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core'
860 860
 	 * @return string
861 861
 	 */
862
-	public function get_most_up_to_date_dms($plugin_slug = 'Core'){
862
+	public function get_most_up_to_date_dms($plugin_slug = 'Core') {
863 863
 		$class_to_filepath_map = $this->get_all_data_migration_scripts_available();
864 864
 		$most_up_to_date_dms_classname = NULL;
865
-		foreach($class_to_filepath_map as $classname => $filepath){
866
-			if($most_up_to_date_dms_classname === NULL){
865
+		foreach ($class_to_filepath_map as $classname => $filepath) {
866
+			if ($most_up_to_date_dms_classname === NULL) {
867 867
 				$migrates_to = $this->script_migrates_to_version($classname);
868
-				$this_plugin_slug = $migrates_to[ 'slug' ];
868
+				$this_plugin_slug = $migrates_to['slug'];
869 869
 //				$version_string = $migrates_to[ 'version' ];
870 870
 //				$details = $this->parse_dms_classname($classname);
871
-				if($this_plugin_slug == $plugin_slug){
871
+				if ($this_plugin_slug == $plugin_slug) {
872 872
 					//if it's for core, it wins
873 873
 					$most_up_to_date_dms_classname = $classname;
874 874
 				}
875 875
 				//if it wasn't for core, we must keep searching for one that is!
876 876
 				continue;
877
-			}else{
878
-				$champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname);
877
+			} else {
878
+				$champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname);
879 879
 				$contender_migrates_to = $this->script_migrates_to_version($classname);
880
-				if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){
880
+				if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) {
881 881
 					//so the contenders version is higher and its for Core
882 882
 					$most_up_to_date_dms_classname = $classname;
883 883
 				}
@@ -897,11 +897,11 @@  discard block
 block discarded – undo
897 897
 	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
898 898
 	 * @return EE_Data_Migration_Script_Base
899 899
 	 */
900
-	public function get_migration_ran( $version, $plugin_slug = 'Core' ) {
900
+	public function get_migration_ran($version, $plugin_slug = 'Core') {
901 901
 		$migrations_ran = $this->get_data_migrations_ran();
902
-		if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){
903
-			return $migrations_ran[ $plugin_slug ][ $version ];
904
-		}else{
902
+		if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) {
903
+			return $migrations_ran[$plugin_slug][$version];
904
+		} else {
905 905
 			return NULL;
906 906
 		}
907 907
 	}
@@ -913,20 +913,20 @@  discard block
 block discarded – undo
913 913
 	 * @return bool
914 914
 	 * @throws \EE_Error
915 915
 	 */
916
-	public function reattempt(){
916
+	public function reattempt() {
917 917
 		//find if the last-ran script was borked
918 918
 		//set it as being non-borked (we shouldn't ever get DMSs that we don't recognize)
919 919
 		//add an 'error' saying that we attempted to reset
920 920
 		//does it have a stage that was borked too? if so make it no longer borked
921 921
 		//add an 'error' saying we attempted to reset
922 922
 		$last_ran_script = $this->get_last_ran_script();
923
-		if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){
923
+		if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) {
924 924
 			//if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it)
925 925
 			$last_ran_script->set_completed();
926
-		}elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) {
926
+		}elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) {
927 927
 			$last_ran_script->reattempt();
928
-		}else{
929
-			throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script ) ) );
928
+		} else {
929
+			throw new EE_Error(sprintf(__('Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso'), print_r($last_ran_script)));
930 930
 		}
931 931
 		return $this->_save_migrations_ran();
932 932
 	}
@@ -936,19 +936,19 @@  discard block
 block discarded – undo
936 936
 	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
937 937
 	 * @return boolean
938 938
 	 */
939
-	public function migration_has_ran( $version, $plugin_slug = 'Core' ) {
940
-		return $this->get_migration_ran( $version, $plugin_slug ) !== NULL;
939
+	public function migration_has_ran($version, $plugin_slug = 'Core') {
940
+		return $this->get_migration_ran($version, $plugin_slug) !== NULL;
941 941
 	}
942 942
 	/**
943 943
 	 * Enqueues this ee plugin to have its data initialized
944 944
 	 * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value
945 945
 	 */
946
-	public function enqueue_db_initialization_for( $plugin_slug ) {
946
+	public function enqueue_db_initialization_for($plugin_slug) {
947 947
 		$queue = $this->get_db_initialization_queue();
948
-		if( ! in_array( $plugin_slug, $queue ) ) {
948
+		if ( ! in_array($plugin_slug, $queue)) {
949 949
 			$queue[] = $plugin_slug;
950 950
 		}
951
-		update_option( self::db_init_queue_option_name, $queue );
951
+		update_option(self::db_init_queue_option_name, $queue);
952 952
 	}
953 953
 	/**
954 954
 	 * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon
@@ -958,26 +958,26 @@  discard block
 block discarded – undo
958 958
 	public function initialize_db_for_enqueued_ee_plugins() {
959 959
 //		EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' );
960 960
 		$queue = $this->get_db_initialization_queue();
961
-		foreach( $queue as $plugin_slug ) {
962
-			$most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug );
963
-			if( ! $most_up_to_date_dms ) {
961
+		foreach ($queue as $plugin_slug) {
962
+			$most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug);
963
+			if ( ! $most_up_to_date_dms) {
964 964
 				//if there is NO DMS for this plugin, obviously there's no schema to verify anyways
965 965
 				$verify_db = false;
966
-			}else{
967
-				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms );
968
-				$verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to );
966
+			} else {
967
+				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms);
968
+				$verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to);
969 969
 			}
970
-			if( $plugin_slug == 'Core' ){
970
+			if ($plugin_slug == 'Core') {
971 971
 				EE_System::instance()->initialize_db_if_no_migrations_required(
972 972
 						false,
973 973
 						$verify_db
974 974
 					);
975
-			}else{
975
+			} else {
976 976
 				//just loop through the addons to make sure their database is setup
977
-				foreach( EE_Registry::instance()->addons as $addon ) {
978
-					if( $addon->name() == $plugin_slug ) {
977
+				foreach (EE_Registry::instance()->addons as $addon) {
978
+					if ($addon->name() == $plugin_slug) {
979 979
 
980
-						$addon->initialize_db_if_no_migrations_required( $verify_db );
980
+						$addon->initialize_db_if_no_migrations_required($verify_db);
981 981
 						break;
982 982
 					}
983 983
 				}
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 //		EEH_Debug_Tools::instance()->show_times();
988 988
 		//because we just initialized the DBs for the enqueued ee plugins
989 989
 		//we don't need to keep remembering which ones needed to be initialized
990
-		delete_option( self::db_init_queue_option_name );
990
+		delete_option(self::db_init_queue_option_name);
991 991
 	}
992 992
 
993 993
 	/**
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 	 * 'Core', or the return value of EE_Addon::name() for an addon
997 997
 	 * @return array
998 998
 	 */
999
-	public function get_db_initialization_queue(){
1000
-		return get_option ( self::db_init_queue_option_name, array() );
999
+	public function get_db_initialization_queue() {
1000
+		return get_option(self::db_init_queue_option_name, array());
1001 1001
 	}
1002 1002
 }
Please login to merge, or discard this patch.
core/EE_Registry.core.php 1 patch
Spacing   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 	 * @param  \EE_Dependency_Map $dependency_map
179 179
 	 * @return \EE_Registry instance
180 180
 	 */
181
-	public static function instance( \EE_Dependency_Map $dependency_map = null ) {
181
+	public static function instance(\EE_Dependency_Map $dependency_map = null) {
182 182
 		// check if class object is instantiated
183
-		if ( ! self::$_instance instanceof EE_Registry ) {
184
-			self::$_instance = new EE_Registry( $dependency_map );
183
+		if ( ! self::$_instance instanceof EE_Registry) {
184
+			self::$_instance = new EE_Registry($dependency_map);
185 185
 		}
186 186
 		return self::$_instance;
187 187
 	}
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 	 * @param  \EE_Dependency_Map $dependency_map
197 197
 	 * @return \EE_Registry
198 198
 	 */
199
-	protected function __construct( \EE_Dependency_Map $dependency_map ) {
199
+	protected function __construct(\EE_Dependency_Map $dependency_map) {
200 200
 		$this->_dependency_map = $dependency_map;
201
-		add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) );
201
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
202 202
 	}
203 203
 
204 204
 
@@ -225,19 +225,19 @@  discard block
 block discarded – undo
225 225
 		$this->modules = new StdClass();
226 226
 		$this->shortcodes = new StdClass();
227 227
 		$this->widgets = new StdClass();
228
-		$this->load_core( 'Base', array(), true );
228
+		$this->load_core('Base', array(), true);
229 229
 		// add our request and response objects to the cache
230
-		$request_loader = $this->_dependency_map->class_loader( 'EE_Request' );
230
+		$request_loader = $this->_dependency_map->class_loader('EE_Request');
231 231
 		$this->_set_cached_class(
232 232
 			$request_loader(),
233 233
 			'EE_Request'
234 234
 		);
235
-		$response_loader = $this->_dependency_map->class_loader( 'EE_Response' );
235
+		$response_loader = $this->_dependency_map->class_loader('EE_Response');
236 236
 		$this->_set_cached_class(
237 237
 			$response_loader(),
238 238
 			'EE_Response'
239 239
 		);
240
-		add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) );
240
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
241 241
 	}
242 242
 
243 243
 
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	public function init() {
252 252
 		// Get current page protocol
253
-		$protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://';
253
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
254 254
 		// Output admin-ajax.php URL with same protocol as current page
255
-		self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol );
256
-		self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false;
255
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
256
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
257 257
 	}
258 258
 
259 259
 
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
 	 * @return string
265 265
 	 */
266 266
 	public static function localize_i18n_js_strings() {
267
-		$i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
268
-		foreach ( $i18n_js_strings as $key => $value ) {
269
-			if ( is_scalar( $value ) ) {
270
-				$i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' );
267
+		$i18n_js_strings = (array) EE_Registry::$i18n_js_strings;
268
+		foreach ($i18n_js_strings as $key => $value) {
269
+			if (is_scalar($value)) {
270
+				$i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
271 271
 			}
272 272
 		}
273 273
 
274
-		return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */';
274
+		return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */';
275 275
 	}
276 276
 
277 277
 
@@ -279,15 +279,15 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * @param mixed string | EED_Module $module
281 281
 	 */
282
-	public function add_module( $module ) {
283
-		if ( $module instanceof EED_Module ) {
284
-			$module_class = get_class( $module );
282
+	public function add_module($module) {
283
+		if ($module instanceof EED_Module) {
284
+			$module_class = get_class($module);
285 285
 			$this->modules->{$module_class} = $module;
286 286
 		} else {
287
-			if ( ! class_exists( 'EE_Module_Request_Router' ) ) {
288
-				$this->load_core( 'Module_Request_Router' );
287
+			if ( ! class_exists('EE_Module_Request_Router')) {
288
+				$this->load_core('Module_Request_Router');
289 289
 			}
290
-			$this->modules->{$module} = EE_Module_Request_Router::module_factory( $module );
290
+			$this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
291 291
 		}
292 292
 	}
293 293
 
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 * @param string $module_name
298 298
 	 * @return mixed EED_Module | NULL
299 299
 	 */
300
-	public function get_module( $module_name = '' ) {
301
-		return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null;
300
+	public function get_module($module_name = '') {
301
+		return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null;
302 302
 	}
303 303
 
304 304
 
@@ -312,20 +312,20 @@  discard block
 block discarded – undo
312 312
 	 * @param bool $load_only
313 313
 	 * @return mixed
314 314
 	 */
315
-	public function load_core( $class_name, $arguments = array(), $load_only = false ) {
315
+	public function load_core($class_name, $arguments = array(), $load_only = false) {
316 316
 		$core_paths = apply_filters(
317 317
 			'FHEE__EE_Registry__load_core__core_paths',
318 318
 			array(
319 319
 				EE_CORE,
320 320
 				EE_ADMIN,
321 321
 				EE_CPTS,
322
-				EE_CORE . 'data_migration_scripts' . DS,
323
-				EE_CORE . 'request_stack' . DS,
324
-				EE_CORE . 'middleware' . DS,
322
+				EE_CORE.'data_migration_scripts'.DS,
323
+				EE_CORE.'request_stack'.DS,
324
+				EE_CORE.'middleware'.DS,
325 325
 			)
326 326
 		);
327 327
 		// retrieve instantiated class
328
-		return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only );
328
+		return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
329 329
 	}
330 330
 
331 331
 
@@ -339,15 +339,15 @@  discard block
 block discarded – undo
339 339
 	 * @param bool $load_only
340 340
 	 * @return mixed
341 341
 	 */
342
-	public function load_service( $class_name, $arguments = array(), $load_only = false ) {
342
+	public function load_service($class_name, $arguments = array(), $load_only = false) {
343 343
 		$service_paths = apply_filters(
344 344
 			'FHEE__EE_Registry__load_service__service_paths',
345 345
 			array(
346
-				EE_CORE . 'services' . DS,
346
+				EE_CORE.'services'.DS,
347 347
 			)
348 348
 		);
349 349
 		// retrieve instantiated class
350
-		return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only );
350
+		return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
351 351
 	}
352 352
 
353 353
 
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 	 * @param mixed $arguments
361 361
 	 * @return EE_Data_Migration_Script_Base
362 362
 	 */
363
-	public function load_dms( $class_name, $arguments = array() ) {
363
+	public function load_dms($class_name, $arguments = array()) {
364 364
 		// retrieve instantiated class
365
-		return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false );
365
+		return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
366 366
 	}
367 367
 
368 368
 
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
 	 * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
378 378
 	 * @return EE_Base_Class | bool
379 379
 	 */
380
-	public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) {
381
-		$paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array(
380
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) {
381
+		$paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
382 382
 			EE_CORE,
383 383
 			EE_CLASSES,
384 384
 			EE_BUSINESS
385
-		) );
385
+		));
386 386
 		// retrieve instantiated class
387
-		return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only );
387
+		return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
388 388
 	}
389 389
 
390 390
 
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 * @param bool $load_only
398 398
 	 * @return EEH_Base | bool
399 399
 	 */
400
-	public function load_helper( $class_name, $arguments = array(), $load_only = true ) {
400
+	public function load_helper($class_name, $arguments = array(), $load_only = true) {
401 401
 		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
402
-		$helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) );
402
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
403 403
 		// retrieve instantiated class
404
-		return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only );
404
+		return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
405 405
 	}
406 406
 
407 407
 
@@ -416,16 +416,16 @@  discard block
 block discarded – undo
416 416
 	 * @param bool $cache  whether to cache the object or not.
417 417
 	 * @return mixed
418 418
 	 */
419
-	public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) {
419
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) {
420 420
 		$paths = array(
421 421
 			EE_LIBRARIES,
422
-			EE_LIBRARIES . 'messages' . DS,
423
-			EE_LIBRARIES . 'shortcodes' . DS,
424
-			EE_LIBRARIES . 'qtips' . DS,
425
-			EE_LIBRARIES . 'payment_methods' . DS,
422
+			EE_LIBRARIES.'messages'.DS,
423
+			EE_LIBRARIES.'shortcodes'.DS,
424
+			EE_LIBRARIES.'qtips'.DS,
425
+			EE_LIBRARIES.'payment_methods'.DS,
426 426
 		);
427 427
 		// retrieve instantiated class
428
-		return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only );
428
+		return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
429 429
 	}
430 430
 
431 431
 
@@ -438,13 +438,13 @@  discard block
 block discarded – undo
438 438
 	 * @param bool $load_only
439 439
 	 * @return EEM_Base | bool
440 440
 	 */
441
-	public function load_model( $class_name, $arguments = array(), $load_only = false ) {
442
-		$paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array(
441
+	public function load_model($class_name, $arguments = array(), $load_only = false) {
442
+		$paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
443 443
 			EE_MODELS,
444 444
 			EE_CORE
445
-		) );
445
+		));
446 446
 		// retrieve instantiated class
447
-		return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only );
447
+		return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
448 448
 	}
449 449
 
450 450
 
@@ -457,15 +457,15 @@  discard block
 block discarded – undo
457 457
 	 * @param bool $load_only
458 458
 	 * @return mixed | bool
459 459
 	 */
460
-	public function load_model_class( $class_name, $arguments = array(), $load_only = true ) {
460
+	public function load_model_class($class_name, $arguments = array(), $load_only = true) {
461 461
 		$paths = array(
462
-			EE_MODELS . 'fields' . DS,
463
-			EE_MODELS . 'helpers' . DS,
464
-			EE_MODELS . 'relations' . DS,
465
-			EE_MODELS . 'strategies' . DS
462
+			EE_MODELS.'fields'.DS,
463
+			EE_MODELS.'helpers'.DS,
464
+			EE_MODELS.'relations'.DS,
465
+			EE_MODELS.'strategies'.DS
466 466
 		);
467 467
 		// retrieve instantiated class
468
-		return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only );
468
+		return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
469 469
 	}
470 470
 
471 471
 
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
476 476
 	 * @return boolean
477 477
 	 */
478
-	public function is_model_name( $model_name ) {
479
-		return isset( $this->models[ $model_name ] ) ? true : false;
478
+	public function is_model_name($model_name) {
479
+		return isset($this->models[$model_name]) ? true : false;
480 480
 	}
481 481
 
482 482
 
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 	 * @param bool $load_only
492 492
 	 * @return mixed
493 493
 	 */
494
-	public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) {
494
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) {
495 495
 		// retrieve instantiated class
496
-		return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only );
496
+		return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
497 497
 	}
498 498
 
499 499
 
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
 	 * @param bool $load_only
509 509
 	 * @return EE_Addon
510 510
 	 */
511
-	public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) {
511
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) {
512 512
 		// retrieve instantiated class
513
-		return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only );
513
+		return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
514 514
 	}
515 515
 
516 516
 
@@ -541,46 +541,46 @@  discard block
 block discarded – undo
541 541
 		$load_only = false
542 542
 	) {
543 543
 		// strip php file extension
544
-		$class_name = str_replace( '.php', '', trim( $class_name ) );
544
+		$class_name = str_replace('.php', '', trim($class_name));
545 545
 		// does the class have a prefix ?
546
-		if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) {
546
+		if ( ! empty($class_prefix) && $class_prefix != 'addon') {
547 547
 			// make sure $class_prefix is uppercase
548
-			$class_prefix = strtoupper( trim( $class_prefix ) );
548
+			$class_prefix = strtoupper(trim($class_prefix));
549 549
 			// add class prefix ONCE!!!
550
-			$class_name = $class_prefix . str_replace( $class_prefix, '', $class_name );
550
+			$class_name = $class_prefix.str_replace($class_prefix, '', $class_name);
551 551
 		}
552
-		$class_exists = class_exists( $class_name );
552
+		$class_exists = class_exists($class_name);
553 553
 		// if we're only loading the class and it already exists, then let's just return true immediately
554
-		if ( $load_only && $class_exists ) {
554
+		if ($load_only && $class_exists) {
555 555
 			return true;
556 556
 		}
557 557
 		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
558 558
 		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
559 559
 		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
560
-		if ( $this->_cache_on && $cache && ! $load_only ) {
560
+		if ($this->_cache_on && $cache && ! $load_only) {
561 561
 			// return object if it's already cached
562
-			$cached_class = $this->_get_cached_class( $class_name, $class_prefix );
563
-			if ( $cached_class !== null ) {
562
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix);
563
+			if ($cached_class !== null) {
564 564
 				return $cached_class;
565 565
 			}
566 566
 		}
567 567
 		// if the class doesn't already exist.. then we need to try and find the file and load it
568
-		if ( ! $class_exists ) {
568
+		if ( ! $class_exists) {
569 569
 			// get full path to file
570
-			$path = $this->_resolve_path( $class_name, $type, $file_paths );
570
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
571 571
 			// load the file
572
-			$loaded = $this->_require_file( $path, $class_name, $type, $file_paths );
572
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
573 573
 			// if loading failed, or we are only loading a file but NOT instantiating an object
574
-			if ( ! $loaded || $load_only ) {
574
+			if ( ! $loaded || $load_only) {
575 575
 				// return boolean if only loading, or null if an object was expected
576 576
 				return $load_only ? $loaded : null;
577 577
 			}
578 578
 		}
579 579
 		// instantiate the requested object
580
-		$class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db );
581
-		if ( $this->_cache_on && $cache ) {
580
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
581
+		if ($this->_cache_on && $cache) {
582 582
 			// save it for later... kinda like gum  { : $
583
-			$this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db );
583
+			$this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
584 584
 		}
585 585
 		$this->_cache_on = true;
586 586
 		return $class_obj;
@@ -603,21 +603,21 @@  discard block
 block discarded – undo
603 603
 	 * @param string $class_prefix
604 604
 	 * @return null|object
605 605
 	 */
606
-	protected function _get_cached_class( $class_name, $class_prefix = '' ) {
607
-		if ( isset( $this->_class_abbreviations[ $class_name ] ) ) {
608
-			$class_abbreviation = $this->_class_abbreviations[ $class_name ];
606
+	protected function _get_cached_class($class_name, $class_prefix = '') {
607
+		if (isset($this->_class_abbreviations[$class_name])) {
608
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
609 609
 		} else {
610 610
 			// have to specify something, but not anything that will conflict
611 611
 			$class_abbreviation = 'FANCY_BATMAN_PANTS';
612 612
 		}
613 613
 		// check if class has already been loaded, and return it if it has been
614
-		if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) {
614
+		if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) {
615 615
 			return $this->{$class_abbreviation};
616
-		} else if ( isset ( $this->{$class_name} ) ) {
616
+		} else if (isset ($this->{$class_name} )) {
617 617
 			return $this->{$class_name};
618
-		} else if ( isset ( $this->LIB->{$class_name} ) ) {
618
+		} else if (isset ($this->LIB->{$class_name} )) {
619 619
 			return $this->LIB->{$class_name};
620
-		} else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) {
620
+		} else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) {
621 621
 			return $this->addons->{$class_name};
622 622
 		}
623 623
 		return null;
@@ -638,20 +638,20 @@  discard block
 block discarded – undo
638 638
 	 * @param array $file_paths
639 639
 	 * @return string | bool
640 640
 	 */
641
-	protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) {
641
+	protected function _resolve_path($class_name, $type = '', $file_paths = array()) {
642 642
 		// make sure $file_paths is an array
643
-		$file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths );
643
+		$file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
644 644
 		// cycle thru paths
645
-		foreach ( $file_paths as $key => $file_path ) {
645
+		foreach ($file_paths as $key => $file_path) {
646 646
 			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
647
-			$file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES;
647
+			$file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
648 648
 			// prep file type
649
-			$type = ! empty( $type ) ? trim( $type, '.' ) . '.' : '';
649
+			$type = ! empty($type) ? trim($type, '.').'.' : '';
650 650
 			// build full file path
651
-			$file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php';
651
+			$file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php';
652 652
 			//does the file exist and can be read ?
653
-			if ( is_readable( $file_paths[ $key ] ) ) {
654
-				return $file_paths[ $key ];
653
+			if (is_readable($file_paths[$key])) {
654
+				return $file_paths[$key];
655 655
 			}
656 656
 		}
657 657
 		return false;
@@ -673,29 +673,29 @@  discard block
 block discarded – undo
673 673
 	 * @return boolean
674 674
 	 * @throws \EE_Error
675 675
 	 */
676
-	protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) {
676
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array()) {
677 677
 		// don't give up! you gotta...
678 678
 		try {
679 679
 			//does the file exist and can it be read ?
680
-			if ( ! $path ) {
680
+			if ( ! $path) {
681 681
 				// so sorry, can't find the file
682
-				throw new EE_Error (
682
+				throw new EE_Error(
683 683
 					sprintf(
684
-						__( 'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso' ),
685
-						trim( $type, '.' ),
684
+						__('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
685
+						trim($type, '.'),
686 686
 						$class_name,
687
-						'<br />' . implode( ',<br />', $file_paths )
687
+						'<br />'.implode(',<br />', $file_paths)
688 688
 					)
689 689
 				);
690 690
 			}
691 691
 			// get the file
692
-			require_once( $path );
692
+			require_once($path);
693 693
 			// if the class isn't already declared somewhere
694
-			if ( class_exists( $class_name, false ) === false ) {
694
+			if (class_exists($class_name, false) === false) {
695 695
 				// so sorry, not a class
696 696
 				throw new EE_Error(
697 697
 					sprintf(
698
-						__( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ),
698
+						__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
699 699
 						$type,
700 700
 						$path,
701 701
 						$class_name
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 				);
704 704
 			}
705 705
 
706
-		} catch ( EE_Error $e ) {
706
+		} catch (EE_Error $e) {
707 707
 			$e->get_error();
708 708
 			return false;
709 709
 		}
@@ -735,55 +735,55 @@  discard block
 block discarded – undo
735 735
 	 * @return null | object
736 736
 	 * @throws \EE_Error
737 737
 	 */
738
-	protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) {
738
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) {
739 739
 		$class_obj = null;
740 740
 		// don't give up! you gotta...
741 741
 		try {
742 742
 			// create reflection
743
-			$reflector = $this->get_ReflectionClass( $class_name );
743
+			$reflector = $this->get_ReflectionClass($class_name);
744 744
 			// make sure arguments are an array
745
-			$arguments = is_array( $arguments ) ? $arguments : array( $arguments );
745
+			$arguments = is_array($arguments) ? $arguments : array($arguments);
746 746
 			// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
747 747
 			// else wrap it in an additional array so that it doesn't get split into multiple parameters
748
-			$arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments )
748
+			$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
749 749
 				? $arguments
750
-				: array( $arguments );
750
+				: array($arguments);
751 751
 			// attempt to inject dependencies ?
752
-			if ( $this->_dependency_map->has( $class_name ) ) {
753
-				$arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments );
752
+			if ($this->_dependency_map->has($class_name)) {
753
+				$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
754 754
 			}
755 755
 			// instantiate the class and add to the LIB array for tracking
756 756
 			// EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db)
757
-			if ( $reflector->getConstructor() === null || $reflector->isAbstract() ) {
757
+			if ($reflector->getConstructor() === null || $reflector->isAbstract()) {
758 758
 				// no constructor = static methods only... nothing to instantiate, loading file was enough
759 759
 				//$instantiation_mode = "no constructor";
760 760
 				$class_obj = true;
761
-			} else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) {
761
+			} else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
762 762
 				//$instantiation_mode = "new_instance_from_db";
763
-				$class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments );
764
-			} else if ( method_exists( $class_name, 'new_instance' ) ) {
763
+				$class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
764
+			} else if (method_exists($class_name, 'new_instance')) {
765 765
 				//$instantiation_mode = "new_instance";
766
-				$class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments );
767
-			} else if ( method_exists( $class_name, 'instance' ) ) {
766
+				$class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
767
+			} else if (method_exists($class_name, 'instance')) {
768 768
 				//$instantiation_mode = "instance";
769
-				$class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments );
770
-			} else if ( $reflector->isInstantiable() ) {
769
+				$class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
770
+			} else if ($reflector->isInstantiable()) {
771 771
 				//$instantiation_mode = "isInstantiable";
772
-				$class_obj = $reflector->newInstanceArgs( $arguments );
772
+				$class_obj = $reflector->newInstanceArgs($arguments);
773 773
 			} else {
774 774
 				// heh ? something's not right !
775 775
 				//$instantiation_mode = 'none';
776 776
 				throw new EE_Error(
777 777
 					sprintf(
778
-						__( 'The %s file %s could not be instantiated.', 'event_espresso' ),
778
+						__('The %s file %s could not be instantiated.', 'event_espresso'),
779 779
 						$type,
780 780
 						$class_name
781 781
 					)
782 782
 				);
783 783
 			}
784
-		} catch ( Exception $e ) {
785
-			if ( ! $e instanceof EE_Error ) {
786
-				$e = new EE_Error( $e->getMessage() );
784
+		} catch (Exception $e) {
785
+			if ( ! $e instanceof EE_Error) {
786
+				$e = new EE_Error($e->getMessage());
787 787
 			}
788 788
 			$e->get_error();
789 789
 		}
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
 	 * @param array $array
798 798
 	 * @return bool
799 799
 	 */
800
-	protected function _array_is_numerically_and_sequentially_indexed( array $array ) {
801
-		return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true;
800
+	protected function _array_is_numerically_and_sequentially_indexed(array $array) {
801
+		return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
802 802
 	}
803 803
 
804 804
 
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 	 * @param string $class_name
814 814
 	 * @return ReflectionClass
815 815
 	 */
816
-	public function get_ReflectionClass( $class_name ) {
816
+	public function get_ReflectionClass($class_name) {
817 817
 		if (
818
-			! isset( $this->_reflectors[ $class_name ] )
819
-			|| ! $this->_reflectors[ $class_name ] instanceof ReflectionClass
818
+			! isset($this->_reflectors[$class_name])
819
+			|| ! $this->_reflectors[$class_name] instanceof ReflectionClass
820 820
 		) {
821
-			$this->_reflectors[ $class_name ] = new ReflectionClass( $class_name );
821
+			$this->_reflectors[$class_name] = new ReflectionClass($class_name);
822 822
 		}
823
-		return $this->_reflectors[ $class_name ];
823
+		return $this->_reflectors[$class_name];
824 824
 	}
825 825
 
826 826
 
@@ -845,45 +845,45 @@  discard block
 block discarded – undo
845 845
 	 * @param array $arguments
846 846
 	 * @return array
847 847
 	 */
848
-	protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) {
848
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) {
849 849
 		// let's examine the constructor
850 850
 		$constructor = $reflector->getConstructor();
851 851
 		// whu? huh? nothing?
852
-		if ( ! $constructor ) {
852
+		if ( ! $constructor) {
853 853
 			return $arguments;
854 854
 		}
855 855
 		// get constructor parameters
856 856
 		$params = $constructor->getParameters();
857 857
 		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
858
-		$argument_keys = array_keys( $arguments );
858
+		$argument_keys = array_keys($arguments);
859 859
 		// now loop thru all of the constructors expected parameters
860
-		foreach ( $params as $index => $param ) {
860
+		foreach ($params as $index => $param) {
861 861
 			// is this a dependency for a specific class ?
862 862
 			$param_class = $param->getClass() ? $param->getClass()->name : null;
863 863
 			if (
864 864
 				// param is not even a class
865
-				empty( $param_class )
865
+				empty($param_class)
866 866
 				// and something already exists in the incoming arguments for this param
867
-				&& isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] )
867
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
868 868
 			) {
869 869
 				// so let's skip this argument and move on to the next
870 870
 				continue;
871 871
 			} else if (
872 872
 				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
873
-				! empty( $param_class )
874
-				&& isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] )
875
-				&& $arguments[ $argument_keys[ $index ] ] instanceof $param_class
873
+				! empty($param_class)
874
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
875
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
876 876
 			) {
877 877
 				// skip this argument and move on to the next
878 878
 				continue;
879 879
 			} else if (
880 880
 				// parameter is type hinted as a class, and should be injected
881
-				! empty( $param_class )
882
-				&& $this->_dependency_map->has_dependency_for_class( $class_name, $param_class )
881
+				! empty($param_class)
882
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
883 883
 			) {
884
-				$arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index );
884
+				$arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
885 885
 			} else {
886
-				$arguments[ $index ] = $param->getDefaultValue();
886
+				$arguments[$index] = $param->getDefaultValue();
887 887
 			}
888 888
 
889 889
 		}
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 	 * @param mixed $index
901 901
 	 * @return array
902 902
 	 */
903
-	protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) {
903
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index) {
904 904
 		$dependency = null;
905 905
 		// should dependency be loaded from cache ?
906 906
 		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
@@ -910,30 +910,30 @@  discard block
 block discarded – undo
910 910
 			: false;
911 911
 		// we might have a dependency...
912 912
 		// let's MAYBE try and find it in our cache if that's what's been requested
913
-		$cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null;
913
+		$cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
914 914
 		// and grab it if it exists
915
-		if ( $cached_class instanceof $param_class ) {
915
+		if ($cached_class instanceof $param_class) {
916 916
 			$dependency = $cached_class;
917
-		} else if ( $param_class != $class_name ) {
917
+		} else if ($param_class != $class_name) {
918 918
 			// obtain the loader method from the dependency map
919
-			$loader = $this->_dependency_map->class_loader( $param_class );
919
+			$loader = $this->_dependency_map->class_loader($param_class);
920 920
 			// is loader a custom closure ?
921
-			if ( $loader instanceof Closure ) {
921
+			if ($loader instanceof Closure) {
922 922
 				$dependency = $loader();
923 923
 			} else {
924 924
 				// set the cache on property for the recursive loading call
925 925
 				$this->_cache_on = $cache_on;
926 926
 				// if not, then let's try and load it via the registry
927
-				$dependency = $this->{$loader}( $param_class );
927
+				$dependency = $this->{$loader}($param_class);
928 928
 			}
929 929
 		}
930 930
 		// did we successfully find the correct dependency ?
931
-		if ( $dependency instanceof $param_class ) {
931
+		if ($dependency instanceof $param_class) {
932 932
 			// then let's inject it into the incoming array of arguments at the correct location
933
-			if ( isset( $argument_keys[ $index ] ) ) {
934
-				$arguments[ $argument_keys[ $index ] ] = $dependency;
933
+			if (isset($argument_keys[$index])) {
934
+				$arguments[$argument_keys[$index]] = $dependency;
935 935
 			} else {
936
-				$arguments[ $index ] = $dependency;
936
+				$arguments[$index] = $dependency;
937 937
 			}
938 938
 		}
939 939
 		return $arguments;
@@ -958,16 +958,16 @@  discard block
 block discarded – undo
958 958
 	 * @param bool $from_db
959 959
 	 * @return void
960 960
 	 */
961
-	protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) {
961
+	protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) {
962 962
 		// return newly instantiated class
963
-		if ( isset( $this->_class_abbreviations[ $class_name ] ) ) {
964
-			$class_abbreviation = $this->_class_abbreviations[ $class_name ];
963
+		if (isset($this->_class_abbreviations[$class_name])) {
964
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
965 965
 			$this->{$class_abbreviation} = $class_obj;
966
-		} else if ( property_exists( $this, $class_name ) ) {
966
+		} else if (property_exists($this, $class_name)) {
967 967
 			$this->{$class_name} = $class_obj;
968
-		} else if ( $class_prefix == 'addon' ) {
968
+		} else if ($class_prefix == 'addon') {
969 969
 			$this->addons->{$class_name} = $class_obj;
970
-		} else if ( ! $from_db ) {
970
+		} else if ( ! $from_db) {
971 971
 			$this->LIB->{$class_name} = $class_obj;
972 972
 		}
973 973
 	}
@@ -984,12 +984,12 @@  discard block
 block discarded – undo
984 984
 	 * @param array  $arguments
985 985
 	 * @return object
986 986
 	 */
987
-	public static function factory( $classname, $arguments = array() ) {
988
-		$loader = self::instance()->_dependency_map->class_loader( $classname );
989
-		if ( $loader instanceof Closure ) {
990
-			return $loader( $arguments );
991
-		} else if ( method_exists( EE_Registry::instance(), $loader ) ) {
992
-			return EE_Registry::instance()->{$loader}( $classname, $arguments );
987
+	public static function factory($classname, $arguments = array()) {
988
+		$loader = self::instance()->_dependency_map->class_loader($classname);
989
+		if ($loader instanceof Closure) {
990
+			return $loader($arguments);
991
+		} else if (method_exists(EE_Registry::instance(), $loader)) {
992
+			return EE_Registry::instance()->{$loader}($classname, $arguments);
993 993
 		}
994 994
 		return null;
995 995
 	}
@@ -1002,9 +1002,9 @@  discard block
 block discarded – undo
1002 1002
 	 * @param string $name
1003 1003
 	 * @return EE_Addon
1004 1004
 	 */
1005
-	public function get_addon_by_name( $name ) {
1006
-		foreach ( $this->addons as $addon ) {
1007
-			if ( $addon->name() == $name ) {
1005
+	public function get_addon_by_name($name) {
1006
+		foreach ($this->addons as $addon) {
1007
+			if ($addon->name() == $name) {
1008 1008
 				return $addon;
1009 1009
 			}
1010 1010
 		}
@@ -1020,8 +1020,8 @@  discard block
 block discarded – undo
1020 1020
 	 */
1021 1021
 	public function get_addons_by_name() {
1022 1022
 		$addons = array();
1023
-		foreach ( $this->addons as $addon ) {
1024
-			$addons[ $addon->name() ] = $addon;
1023
+		foreach ($this->addons as $addon) {
1024
+			$addons[$addon->name()] = $addon;
1025 1025
 		}
1026 1026
 		return $addons;
1027 1027
 	}
@@ -1036,14 +1036,14 @@  discard block
 block discarded – undo
1036 1036
 	 * @return \EEM_Base
1037 1037
 	 * @throws \EE_Error
1038 1038
 	 */
1039
-	public function reset_model( $model_name ) {
1040
-		$model = $this->load_model( $model_name );
1041
-		$model_class_name = get_class( $model );
1039
+	public function reset_model($model_name) {
1040
+		$model = $this->load_model($model_name);
1041
+		$model_class_name = get_class($model);
1042 1042
 		//get that model reset it and make sure we nuke the old reference to it
1043
-		if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) {
1043
+		if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1044 1044
 			$this->LIB->{$model_class_name} = $model::reset();
1045 1045
 		} else {
1046
-			throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) );
1046
+			throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1047 1047
 		}
1048 1048
 		return $this->LIB->{$model_class_name};
1049 1049
 	}
@@ -1081,17 +1081,17 @@  discard block
 block discarded – undo
1081 1081
 	 *
1082 1082
 	 * @return EE_Registry
1083 1083
 	 */
1084
-	public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) {
1084
+	public static function reset($hard = false, $reinstantiate = true, $reset_models = true) {
1085 1085
 		$instance = self::instance();
1086 1086
 		$instance->_cache_on = true;
1087 1087
 		//handle of objects cached on LIB
1088
-		foreach ( $instance->LIB as $class_name => $class ) {
1089
-			if ( isset( $instance->LIB->{$class_name} ) ) {
1090
-				if ( $instance->LIB->{$class_name} instanceof EventEspresso\core\interfaces\ResettableInterface ) {
1088
+		foreach ($instance->LIB as $class_name => $class) {
1089
+			if (isset($instance->LIB->{$class_name} )) {
1090
+				if ($instance->LIB->{$class_name} instanceof EventEspresso\core\interfaces\ResettableInterface) {
1091 1091
 					$instance->LIB->{$class_name}->reset();
1092 1092
 				}
1093
-				if ( ! $instance->LIB->{$class_name} instanceof EventEspresso\core\interfaces\UnsettableInterface ) {
1094
-					unset( $instance->LIB->{$class_name} );
1093
+				if ( ! $instance->LIB->{$class_name} instanceof EventEspresso\core\interfaces\UnsettableInterface) {
1094
+					unset($instance->LIB->{$class_name} );
1095 1095
 				}
1096 1096
 			}
1097 1097
 		}
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 	 * @param $a
1117 1117
 	 * @param $b
1118 1118
 	 */
1119
-	final function __call( $a, $b ) {
1119
+	final function __call($a, $b) {
1120 1120
 	}
1121 1121
 
1122 1122
 
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 	/**
1125 1125
 	 * @param $a
1126 1126
 	 */
1127
-	final function __get( $a ) {
1127
+	final function __get($a) {
1128 1128
 	}
1129 1129
 
1130 1130
 
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 	 * @param $a
1134 1134
 	 * @param $b
1135 1135
 	 */
1136
-	final function __set( $a, $b ) {
1136
+	final function __set($a, $b) {
1137 1137
 	}
1138 1138
 
1139 1139
 
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 	/**
1142 1142
 	 * @param $a
1143 1143
 	 */
1144
-	final function __isset( $a ) {
1144
+	final function __isset($a) {
1145 1145
 	}
1146 1146
 
1147 1147
 
@@ -1149,7 +1149,7 @@  discard block
 block discarded – undo
1149 1149
 	/**
1150 1150
 	 * @param $a
1151 1151
 	 */
1152
-	final function __unset( $a ) {
1152
+	final function __unset($a) {
1153 1153
 	}
1154 1154
 
1155 1155
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 	 * @param $a
1197 1197
 	 * @param $b
1198 1198
 	 */
1199
-	final static function __callStatic( $a, $b ) {
1199
+	final static function __callStatic($a, $b) {
1200 1200
 	}
1201 1201
 
1202 1202
 	/**
@@ -1205,9 +1205,9 @@  discard block
 block discarded – undo
1205 1205
 	 */
1206 1206
 	public function cpt_models() {
1207 1207
 		$cpt_models = array();
1208
-		foreach( $this->non_abstract_db_models as $short_name => $classname ) {
1209
-			if( is_subclass_of(  $classname, 'EEM_CPT_Base' ) ) {
1210
-				$cpt_models[ $short_name ] = $classname;
1208
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1209
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1210
+				$cpt_models[$short_name] = $classname;
1211 1211
 			}
1212 1212
 		}
1213 1213
 		return $cpt_models;
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 1 patch
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public static function instance() {
42 42
 		// check if class object is instantiated
43
-		if (  ! self::$_instance instanceof EE_Admin ) {
43
+		if ( ! self::$_instance instanceof EE_Admin) {
44 44
 			self::$_instance = new self();
45 45
 		}
46 46
 		return self::$_instance;
@@ -67,30 +67,30 @@  discard block
 block discarded – undo
67 67
 		// define global EE_Admin constants
68 68
 		$this->_define_all_constants();
69 69
 		// set autoloaders for our admin page classes based on included path information
70
-		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN );
70
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
71 71
 		// admin hooks
72
-		add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 );
72
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
73 73
 		// load EE_Request_Handler early
74
-		add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' ));
75
-		add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' ));
74
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
75
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
76 76
 		// post shortcode tracking
77 77
 		add_action(
78 78
 			'AHEE__EE_System__initialize_last',
79
-			array( 'EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin' )
79
+			array('EventEspresso\core\admin\PostShortcodeTracking', 'set_hooks_admin')
80 80
 		);
81
-		add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 );
82
-		add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 );
83
-		add_action( 'admin_init', array( $this, 'admin_init' ), 100 );
84
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 );
85
-		add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 );
86
-		add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 );
87
-		add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 );
88
-		add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' ));
81
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
82
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
83
+		add_action('admin_init', array($this, 'admin_init'), 100);
84
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
85
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
86
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
87
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
88
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
89 89
 
90 90
 		//reset Environment config (we only do this on admin page loads);
91 91
 		EE_Registry::instance()->CFG->environment->recheck_values();
92 92
 
93
-		do_action( 'AHEE__EE_Admin__loaded' );
93
+		do_action('AHEE__EE_Admin__loaded');
94 94
 	}
95 95
 
96 96
 
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 	 * @return void
106 106
 	 */
107 107
 	private function _define_all_constants() {
108
-		if ( ! defined( 'EE_ADMIN_URL' ) ) {
109
-			define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' );
110
-			define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' );
111
-			define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS );
112
-			define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' );
113
-			define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' ) );
108
+		if ( ! defined('EE_ADMIN_URL')) {
109
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
110
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
111
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS);
112
+			define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
113
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
114 114
 		}
115 115
 	}
116 116
 
@@ -124,23 +124,23 @@  discard block
 block discarded – undo
124 124
 	 * @param 	string 	$plugin
125 125
 	 * @return 	array
126 126
 	 */
127
-	public function filter_plugin_actions( $links, $plugin ) {
127
+	public function filter_plugin_actions($links, $plugin) {
128 128
 		// set $main_file in stone
129 129
 		static $main_file;
130 130
 		// if $main_file is not set yet
131
-		if ( ! $main_file ) {
132
-			$main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE );
131
+		if ( ! $main_file) {
132
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
133 133
 		}
134
-		 if ( $plugin === $main_file ) {
134
+		 if ($plugin === $main_file) {
135 135
 		 	// compare current plugin to this one
136
-			if ( EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance ) {
137
-				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode.  Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>';
138
-				array_unshift( $links, $maintenance_link );
136
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
137
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode.  Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>';
138
+				array_unshift($links, $maintenance_link);
139 139
 			} else {
140
-				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>';
141
-				$events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>';
140
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>';
141
+				$events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>';
142 142
 				// add before other links
143
-				array_unshift( $links, $org_settings_link, $events_link );
143
+				array_unshift($links, $org_settings_link, $events_link);
144 144
 			}
145 145
 		}
146 146
 		return $links;
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	 *	@return void
156 156
 	 */
157 157
 	public function get_request() {
158
-		EE_Registry::instance()->load_core( 'Request_Handler' );
159
-		EE_Registry::instance()->load_core( 'CPT_Strategy' );
158
+		EE_Registry::instance()->load_core('Request_Handler');
159
+		EE_Registry::instance()->load_core('CPT_Strategy');
160 160
 	}
161 161
 
162 162
 
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 	 * @param array $admin_page_folder_names
169 169
 	 * @return array
170 170
 	 */
171
-	public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){
171
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) {
172 172
 		return array(
173
-			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
174
-			'about' => EE_ADMIN_PAGES . 'about' . DS,
175
-			'support' => EE_ADMIN_PAGES . 'support' . DS
173
+			'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS,
174
+			'about' => EE_ADMIN_PAGES.'about'.DS,
175
+			'support' => EE_ADMIN_PAGES.'support'.DS
176 176
 		);
177 177
 	}
178 178
 
@@ -186,31 +186,31 @@  discard block
 block discarded – undo
186 186
 	*/
187 187
 	public function init() {
188 188
 		//only enable most of the EE_Admin IF we're not in full maintenance mode
189
-		if ( EE_Maintenance_Mode::instance()->models_can_query() ){
189
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
190 190
 			//ok so we want to enable the entire admin
191
-			add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' ));
192
-			add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 );
193
-			add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 );
191
+			add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback'));
192
+			add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9);
193
+			add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9);
194 194
 			//at a glance dashboard widget
195
-			add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items' ), 10 );
195
+			add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
196 196
 			//filter for get_edit_post_link used on comments for custom post types
197
-			add_filter( 'get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 2 );
197
+			add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2);
198 198
 		}
199 199
 		// run the admin page factory but ONLY if we are doing an ee admin ajax request
200
-		if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) {
200
+		if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
201 201
 			try {
202 202
 				//this loads the controller for the admin pages which will setup routing etc
203
-				EE_Registry::instance()->load_core( 'Admin_Page_Loader' );
204
-			} catch ( EE_Error $e ) {
203
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
204
+			} catch (EE_Error $e) {
205 205
 				$e->get_error();
206 206
 			}
207 207
 		}
208
-		add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 );
208
+		add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
209 209
 		//make sure our CPTs and custom taxonomy metaboxes get shown for first time users
210
-		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 );
211
-		add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 );
210
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
211
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
212 212
 		//exclude EE critical pages from all nav menus and wp_list_pages
213
-		add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 );
213
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
214 214
 	}
215 215
 
216 216
 
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 	 * @param  object $post_type WP post type object
224 224
 	 * @return object            WP post type object
225 225
 	 */
226
-	public function remove_pages_from_nav_menu( $post_type ) {
226
+	public function remove_pages_from_nav_menu($post_type) {
227 227
 		//if this isn't the "pages" post type let's get out
228
-		if ( $post_type->name !== 'page' ) {
228
+		if ($post_type->name !== 'page') {
229 229
 			return $post_type;
230 230
 		}
231 231
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
@@ -245,28 +245,28 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	public function enable_hidden_ee_nav_menu_metaboxes() {
247 247
 		global $wp_meta_boxes, $pagenow;
248
-		if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) {
248
+		if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
249 249
 			return;
250 250
 		}
251 251
 		$user = wp_get_current_user();
252 252
 		//has this been done yet?
253
-		if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) {
253
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
254 254
 			return;
255 255
 		}
256 256
 
257
-		$hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID );
258
-		$initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) );
257
+		$hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID);
258
+		$initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page'));
259 259
 
260
-		if ( is_array( $hidden_meta_boxes ) ) {
261
-			foreach ( $hidden_meta_boxes as $key => $meta_box_id ) {
262
-				if ( in_array( $meta_box_id, $initial_meta_boxes ) ) {
263
-					unset( $hidden_meta_boxes[ $key ] );
260
+		if (is_array($hidden_meta_boxes)) {
261
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
262
+				if (in_array($meta_box_id, $initial_meta_boxes)) {
263
+					unset($hidden_meta_boxes[$key]);
264 264
 				}
265 265
 			}
266 266
 		}
267 267
 
268
-		update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
269
-		update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true );
268
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
269
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
270 270
 	}
271 271
 
272 272
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 * @return void
286 286
 	 */
287 287
 	public function register_custom_nav_menu_boxes() {
288
-		add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' );
288
+		add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core');
289 289
 	}
290 290
 
291 291
 
@@ -301,16 +301,16 @@  discard block
 block discarded – undo
301 301
 	 *
302 302
 	 * @return string  the (maybe) modified link
303 303
 	 */
304
-	public function modify_edit_post_link( $link, $id ) {
305
-		if ( ! $post = get_post( $id ) ){
304
+	public function modify_edit_post_link($link, $id) {
305
+		if ( ! $post = get_post($id)) {
306 306
 			return $link;
307 307
 		}
308
-		if ( $post->post_type === 'espresso_attendees' ) {
308
+		if ($post->post_type === 'espresso_attendees') {
309 309
 			$query_args = array(
310 310
 				'action' => 'edit_attendee',
311 311
 				'post' => $id
312 312
 			);
313
-			return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') );
313
+			return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations'));
314 314
 		}
315 315
 		return $link;
316 316
 	}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 		global $nav_menu_selected_id;
323 323
 
324 324
 		$db_fields = false;
325
-		$walker = new Walker_Nav_Menu_Checklist( $db_fields );
325
+		$walker = new Walker_Nav_Menu_Checklist($db_fields);
326 326
 		$current_tab = 'event-archives';
327 327
 
328 328
 		/*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
 		?>
342 342
 		<div id="posttype-extra-nav-menu-pages" class="posttypediv">
343 343
 			<ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
344
-				<li <?php echo ( 'event-archives' === $current_tab ? ' class="tabs"' : '' ); ?>>
345
-					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args)));} ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
346
-						<?php _e( 'Event Archive Pages', 'event_espresso' ); ?>
344
+				<li <?php echo ('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>>
345
+					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) {echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); } ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
346
+						<?php _e('Event Archive Pages', 'event_espresso'); ?>
347 347
 					</a>
348 348
 				</li>
349 349
 			<?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs.
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
  			<?php */ ?>
362 362
 
363 363
 			<div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
364
-			echo ( 'event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
364
+			echo ('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
365 365
 			?>">
366 366
 				<ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
367 367
 					<?php
368 368
 					$pages = $this->_get_extra_nav_menu_pages_items();
369 369
 					$args['walker'] = $walker;
370
-					echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args );
370
+					echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args);
371 371
 					?>
372 372
 				</ul>
373 373
 			</div><!-- /.tabs-panel -->
@@ -375,18 +375,18 @@  discard block
 block discarded – undo
375 375
 			<p class="button-controls">
376 376
 				<span class="list-controls">
377 377
 					<a href="<?php
378
-						echo esc_url( add_query_arg(
378
+						echo esc_url(add_query_arg(
379 379
 							array(
380 380
 								'extra-nav-menu-pages-tab' => 'event-archives',
381 381
 								'selectall' => 1,
382 382
 							),
383
-							remove_query_arg( $removed_args )
383
+							remove_query_arg($removed_args)
384 384
 						));
385 385
 					?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
386 386
 				</span>
387 387
 
388 388
 				<span class="add-to-menu">
389
-					<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" />
389
+					<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" />
390 390
 					<span class="spinner"></span>
391 391
 				</span>
392 392
 			</p>
@@ -407,10 +407,10 @@  discard block
 block discarded – undo
407 407
 	private function _get_extra_nav_menu_pages_items() {
408 408
 		$menuitems[] = array(
409 409
 			'title' => __('Event List', 'event_espresso'),
410
-			'url' => get_post_type_archive_link( 'espresso_events' ),
410
+			'url' => get_post_type_archive_link('espresso_events'),
411 411
 			'description' => __('Archive page for all events.', 'event_espresso')
412 412
 		);
413
-		return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems );
413
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
414 414
 	}
415 415
 
416 416
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * @param $menu_item_values
423 423
 	 * @return stdClass
424 424
 	 */
425
-	private function _setup_extra_nav_menu_pages_items( $menu_item_values ) {
425
+	private function _setup_extra_nav_menu_pages_items($menu_item_values) {
426 426
 		$menu_item = new stdClass();
427 427
 		$keys = array(
428 428
 			'ID' => 0,
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 			'xfn' => ''
443 443
 		);
444 444
 
445
-		foreach ( $keys as $key => $value) {
446
-			$menu_item->{$key} = isset( $menu_item_values[ $key]) ? $menu_item_values[ $key] : $value;
445
+		foreach ($keys as $key => $value) {
446
+			$menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
447 447
 		}
448 448
 		return $menu_item;
449 449
 	}
@@ -482,9 +482,9 @@  discard block
 block discarded – undo
482 482
 		 * - check if doing post processing of one of EE CPTs
483 483
 		 * - instantiate the corresponding EE CPT model for the post_type being processed.
484 484
 		 */
485
-		if ( isset( $_POST['action'], $_POST['post_type'] ) && $_POST['action'] === 'editpost' ) {
486
-			EE_Registry::instance()->load_core( 'Register_CPTs' );
487
-			EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] );
485
+		if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') {
486
+			EE_Registry::instance()->load_core('Register_CPTs');
487
+			EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
488 488
 		}
489 489
 
490 490
 
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 		 * 'options-reading.php' core WordPress admin settings page.  This is for user-proofing.
494 494
 		 */
495 495
 		global $pagenow;
496
-		if ( $pagenow === 'options-reading.php' ) {
497
-			add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) );
496
+		if ($pagenow === 'options-reading.php') {
497
+			add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
498 498
 		}
499 499
 
500 500
 	}
@@ -506,25 +506,25 @@  discard block
 block discarded – undo
506 506
 	 * @param string $output  Current output.
507 507
 	 * @return string
508 508
 	 */
509
-	public function modify_dropdown_pages( $output ) {
509
+	public function modify_dropdown_pages($output) {
510 510
 		//get critical pages
511 511
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
512 512
 
513 513
 		//split current output by line break for easier parsing.
514
-		$split_output = explode( "\n", $output );
514
+		$split_output = explode("\n", $output);
515 515
 
516 516
 		//loop through to remove any critical pages from the array.
517
-		foreach ( $critical_pages as $page_id ) {
518
-			$needle = 'value="' . $page_id . '"';
519
-			foreach( $split_output as $key => $haystack ) {
520
-				if( strpos( $haystack, $needle ) !== false ) {
521
-					unset( $split_output[$key] );
517
+		foreach ($critical_pages as $page_id) {
518
+			$needle = 'value="'.$page_id.'"';
519
+			foreach ($split_output as $key => $haystack) {
520
+				if (strpos($haystack, $needle) !== false) {
521
+					unset($split_output[$key]);
522 522
 				}
523 523
 			}
524 524
 		}
525 525
 
526 526
 		//replace output with the new contents
527
-		return implode( "\n", $split_output );
527
+		return implode("\n", $split_output);
528 528
 	}
529 529
 
530 530
 
@@ -538,36 +538,36 @@  discard block
 block discarded – undo
538 538
 	public function enqueue_admin_scripts() {
539 539
 		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
540 540
 		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script calls.
541
-		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
541
+		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
542 542
 		// register cookie script for future dependencies
543
-		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE );
543
+		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE);
544 544
 		// jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via:  add_filter( 'FHEE_load_jquery_validate', '__return_true' );
545
-		if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) {
545
+		if (apply_filters('FHEE_load_jquery_validate', FALSE)) {
546 546
 			// register jQuery Validate
547
-			wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE);
547
+			wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE);
548 548
 		}
549 549
 		//joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' );
550
-		if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) {
550
+		if (apply_filters('FHEE_load_joyride', FALSE)) {
551 551
 			//joyride style
552
-			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
553
-			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION );
554
-			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE );
552
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1');
553
+			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION);
554
+			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE);
555 555
 			//joyride JS
556
-			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE );
556
+			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE);
557 557
 			// wanna go for a joyride?
558 558
 			wp_enqueue_style('ee-joyride-css');
559 559
 			wp_enqueue_script('jquery-joyride');
560 560
 		}
561 561
 		//qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' );
562
-		if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) {
562
+		if (apply_filters('FHEE_load_qtip', FALSE)) {
563 563
 			EEH_Qtip_Loader::instance()->register_and_enqueue();
564 564
 		}
565 565
 		//accounting.js library
566 566
 		// @link http://josscrowcroft.github.io/accounting.js/
567
-		if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) {
568
-			wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE );
569
-			wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE );
570
-			wp_enqueue_script( 'ee-accounting' );
567
+		if (apply_filters('FHEE_load_accounting_js', FALSE)) {
568
+			wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE);
569
+			wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE);
570
+			wp_enqueue_script('ee-accounting');
571 571
 			// array of settings to get converted to JSON array via wp_localize_script
572 572
 			$currency_config = array(
573 573
 				'currency' => array(
@@ -614,11 +614,11 @@  discard block
 block discarded – undo
614 614
 	public function get_persistent_admin_notices() {
615 615
 		// http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30
616 616
 		$args = array(
617
-			'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '',
618
-			'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '',
617
+			'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '',
618
+			'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '',
619 619
 		);
620
-		$return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL );
621
-		echo EE_Error::get_persistent_admin_notices( $return_url );
620
+		$return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL);
621
+		echo EE_Error::get_persistent_admin_notices($return_url);
622 622
 	}
623 623
 
624 624
 
@@ -639,26 +639,26 @@  discard block
 block discarded – undo
639 639
 	 * @param $elements
640 640
 	 * @return array
641 641
 	 */
642
-	public function dashboard_glance_items( $elements ) {
642
+	public function dashboard_glance_items($elements) {
643 643
 		$events = EEM_Event::instance()->count();
644
-		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') );
645
-		$items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) );
644
+		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php'));
645
+		$items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
646 646
 		$items['events']['title'] = __('Click to view all Events', 'event_espresso');
647 647
 		$registrations = EEM_Registration::instance()->count(
648 648
 			array(
649 649
 				array(
650
-					'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete )
650
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)
651 651
 				)
652 652
 			)
653 653
 		);
654
-		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') );
655
-		$items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) );
654
+		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php'));
655
+		$items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations));
656 656
 		$items['registrations']['title'] = __('Click to view all registrations', 'event_espresso');
657 657
 
658
-		$items = apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items );
658
+		$items = apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
659 659
 
660
-		foreach ( $items as $type => $item_properties ) {
661
-			$elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] );
660
+		foreach ($items as $type => $item_properties) {
661
+			$elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']);
662 662
 		}
663 663
 		return $elements;
664 664
 	}
@@ -675,31 +675,31 @@  discard block
 block discarded – undo
675 675
 	 * @throws EE_Error
676 676
 	 * @return    string
677 677
 	 */
678
-	public function check_for_invalid_datetime_formats( $value, $option ) {
678
+	public function check_for_invalid_datetime_formats($value, $option) {
679 679
 		// check for date_format or time_format
680
-		switch ( $option ) {
680
+		switch ($option) {
681 681
 			case 'date_format' :
682
-				$date_time_format = $value . ' ' . get_option('time_format');
682
+				$date_time_format = $value.' '.get_option('time_format');
683 683
 				break;
684 684
 			case 'time_format' :
685
-				$date_time_format = get_option('date_format') . ' ' . $value;
685
+				$date_time_format = get_option('date_format').' '.$value;
686 686
 				break;
687 687
 			default :
688 688
 				$date_time_format = FALSE;
689 689
 		}
690 690
 		// do we have a date_time format to check ?
691
-		if ( $date_time_format ) {
692
-			$error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format );
691
+		if ($date_time_format) {
692
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
693 693
 
694
-			if ( is_array( $error_msg ) ) {
695
-				$msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format  ) . '</p><p><ul>';
694
+			if (is_array($error_msg)) {
695
+				$msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>';
696 696
 
697 697
 
698
-				foreach ( $error_msg as $error ) {
699
-					$msg .= '<li>' . $error . '</li>';
698
+				foreach ($error_msg as $error) {
699
+					$msg .= '<li>'.$error.'</li>';
700 700
 				}
701 701
 
702
-				$msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>';
702
+				$msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
703 703
 
704 704
 				// trigger WP settings error
705 705
 				add_settings_error(
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 				);
710 710
 
711 711
 				// set format to something valid
712
-				switch ( $option ) {
712
+				switch ($option) {
713 713
 					case 'date_format' :
714 714
 						$value = 'F j, Y';
715 715
 						break;
@@ -731,8 +731,8 @@  discard block
 block discarded – undo
731 731
 	 * @param $content
732 732
 	 * @return    string
733 733
 	 */
734
-	public function its_eSpresso( $content ) {
735
-		return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content );
734
+	public function its_eSpresso($content) {
735
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
736 736
 	}
737 737
 
738 738
 
@@ -745,9 +745,9 @@  discard block
 block discarded – undo
745 745
 	 */
746 746
 	public function espresso_admin_footer() {
747 747
 		return sprintf(
748
-			__( 'Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso' ),
748
+			__('Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso'),
749 749
 			'<a href="https://eventespresso.com/" title="',
750
-			'">' . EVENT_ESPRESSO_POWERED_BY . '</a>'
750
+			'">'.EVENT_ESPRESSO_POWERED_BY.'</a>'
751 751
 		);
752 752
 	}
753 753
 
@@ -767,12 +767,12 @@  discard block
 block discarded – undo
767 767
 	 * @param array $config
768 768
 	 * @return void
769 769
 	 */
770
-	public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) {
771
-		EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' );
772
-		if ( class_exists( 'EE_Register_Admin_Page' ) ) {
770
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array()) {
771
+		EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3');
772
+		if (class_exists('EE_Register_Admin_Page')) {
773 773
 			$config['page_path'] = $page_path;
774 774
 		}
775
-		EE_Register_Admin_Page::register( $page_basename, $config );
775
+		EE_Register_Admin_Page::register($page_basename, $config);
776 776
 
777 777
 	}
778 778
 
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 	 * @param  \WP_Post $post
786 786
 	 * @return void
787 787
 	 */
788
-	public static function parse_post_content_on_save( $post_ID, $post ) {
788
+	public static function parse_post_content_on_save($post_ID, $post) {
789 789
 		EE_Error::doing_it_wrong(
790 790
 			__METHOD__,
791 791
 			__(
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 			),
795 795
 			'4.8.41'
796 796
 		);
797
-		EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save( $post_ID, $post );
797
+		EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save($post_ID, $post);
798 798
 	}
799 799
 
800 800
 
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 	 * @param  $value
808 808
 	 * @return void
809 809
 	 */
810
-	public function reset_page_for_posts_on_change( $option, $old_value, $value ) {
810
+	public function reset_page_for_posts_on_change($option, $old_value, $value) {
811 811
 		EE_Error::doing_it_wrong(
812 812
 			__METHOD__,
813 813
 			__(
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 			),
817 817
 			'4.8.41'
818 818
 		);
819
-		EventEspresso\core\admin\PostShortcodeTracking::reset_page_for_posts_on_change( $option, $old_value, $value );
819
+		EventEspresso\core\admin\PostShortcodeTracking::reset_page_for_posts_on_change($option, $old_value, $value);
820 820
 	}
821 821
 
822 822
 }
Please login to merge, or discard this patch.
caffeinated/brewing_regular.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -3,10 +3,10 @@  discard block
 block discarded – undo
3 3
  * the purpose of this file is to simply contain any action/filter hook callbacks etc for specific aspects of EE related to caffeinated (regular) use.  Before putting any code in here, First be certain that it isn't better to define and use the hook in a specific caffeinated/whatever class or file.
4 4
  */
5 5
 // defined some new constants related to caffeinated folder
6
-define( 'EE_CAF_URL', EE_PLUGIN_DIR_URL . 'caffeinated/' );
7
-define( 'EE_CAF_CORE', EE_CAFF_PATH . 'core' . DS );
8
-define( 'EE_CAF_LIBRARIES', EE_CAF_CORE . 'libraries' . DS );
9
-define( 'EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH . 'payment_methods' . DS );
6
+define('EE_CAF_URL', EE_PLUGIN_DIR_URL.'caffeinated/');
7
+define('EE_CAF_CORE', EE_CAFF_PATH.'core'.DS);
8
+define('EE_CAF_LIBRARIES', EE_CAF_CORE.'libraries'.DS);
9
+define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH.'payment_methods'.DS);
10 10
 
11 11
 /**
12 12
  * EE_Brewing_Regular class.  Just a wrapper to help namespace activity for the functionality of this file.
@@ -21,23 +21,23 @@  discard block
 block discarded – undo
21 21
 	 * EE_Brewing_Regular constructor.
22 22
 	 */
23 23
 	public function __construct() {
24
-		if ( defined( 'EE_CAFF_PATH' )) {
24
+		if (defined('EE_CAFF_PATH')) {
25 25
 			// activation
26
-			add_action( 'AHEE__EEH_Activation__initialize_db_content', array( $this, 'initialize_caf_db_content' ));
26
+			add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content'));
27 27
 			// load caff init
28
-			add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'caffeinated_init' ));
28
+			add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init'));
29 29
 			// make it so the PDF receipt doesn't show our shameless plug
30
-			add_filter( 'FHEE_Invoice__send_invoice__shameless_plug', '__return_false' );
30
+			add_filter('FHEE_Invoice__send_invoice__shameless_plug', '__return_false');
31 31
 			// add caffeinated modules
32
-			add_filter( 'FHEE__EE_Config__register_modules__modules_to_register', array( $this, 'caffeinated_modules_to_register' ));
32
+			add_filter('FHEE__EE_Config__register_modules__modules_to_register', array($this, 'caffeinated_modules_to_register'));
33 33
 			// load caff scripts
34
-			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_caffeinated_scripts'), 10 );
34
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10);
35 35
 
36
-			add_filter( 'FHEE__EE_Registry__load_helper__helper_paths', array( $this, 'caf_helper_paths' ), 10 );
36
+			add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
37 37
 
38
-			add_filter( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', array( $this, 'caf_payment_methods' ) );
38
+			add_filter('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', array($this, 'caf_payment_methods'));
39 39
 			// caffeinated constructed
40
-			do_action( 'AHEE__EE_Brewing_Regular__construct__complete' );
40
+			do_action('AHEE__EE_Brewing_Regular__construct__complete');
41 41
 		}
42 42
 	}
43 43
 
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 * @param array  $paths original helper paths array
48 48
 	 * @return array             new array of paths
49 49
 	 */
50
-	public function caf_helper_paths( $paths ) {
51
-		$paths[] = EE_CAF_CORE . 'helpers' . DS;
50
+	public function caf_helper_paths($paths) {
51
+		$paths[] = EE_CAF_CORE.'helpers'.DS;
52 52
 		return $paths;
53 53
 	}
54 54
 
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
 	 * Right now, we ASSUME the only price types in the system are default ones
65 65
 	 * @global wpdb $wpdb
66 66
 	 */
67
-	function initialize_caf_db_content(){
67
+	function initialize_caf_db_content() {
68 68
 //		echo "initialize caf db content!";
69 69
 		global $wpdb;
70 70
 
71 71
 		//use same method of getting creator id as the version introducing the change
72
-		$default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id',get_current_user_id());
72
+		$default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
73 73
 
74 74
 		$price_type_table = $wpdb->prefix."esp_price_type";
75 75
 		$price_table = $wpdb->prefix."esp_price";
76 76
 
77
-		if ( EEH_Activation::table_exists( $price_type_table ) ) {
77
+		if (EEH_Activation::table_exists($price_type_table)) {
78 78
 
79
-			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';//include trashed price types
80
-			$tax_price_type_count = $wpdb->get_var( $SQL );
79
+			$SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table.' WHERE PBT_ID=4'; //include trashed price types
80
+			$tax_price_type_count = $wpdb->get_var($SQL);
81 81
 
82
-			if ( $tax_price_type_count <= 1) {
82
+			if ($tax_price_type_count <= 1) {
83 83
 				$wpdb->insert($price_type_table,
84 84
 					array(
85 85
 						'PRT_name'=>  __("Regional Tax", "event_espresso"),
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 						'PRT_wp_user' => $default_creator_id
91 91
 					),
92 92
 					array(
93
-						'%s',//PRT_name
94
-						'%d',//PBT_id
95
-						'%d',//PRT_is_percent
96
-						'%d',//PRT_order
97
-						'%d',//PRT_deleted
93
+						'%s', //PRT_name
94
+						'%d', //PBT_id
95
+						'%d', //PRT_is_percent
96
+						'%d', //PRT_order
97
+						'%d', //PRT_deleted
98 98
 						'%d', //PRT_wp_user
99 99
 					)
100 100
 				);
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
 						'PRT_wp_user' => $default_creator_id,
110 110
 					),
111 111
 					array(
112
-						'%s',//PRT_name
113
-						'%d',//PBT_id
114
-						'%d',//PRT_is_percent
115
-						'%d',//PRT_order
116
-						'%d',//PRT_deleted
112
+						'%s', //PRT_name
113
+						'%d', //PBT_id
114
+						'%d', //PRT_is_percent
115
+						'%d', //PRT_order
116
+						'%d', //PRT_deleted
117 117
 						'%d' //PRT_wp_user
118 118
 					)
119 119
 				);
120
-				if( $result ){
120
+				if ($result) {
121 121
 					$wpdb->insert($price_table,
122 122
 						array(
123 123
 							'PRT_ID'=>$wpdb->insert_id,
@@ -132,15 +132,15 @@  discard block
 block discarded – undo
132 132
 							'PRC_wp_user' => $default_creator_id
133 133
 						),
134 134
 						array(
135
-							'%d',//PRT_id
136
-							'%f',//PRC_amount
137
-							'%s',//PRC_name
138
-							'%s',//PRC_desc
139
-							'%d',//PRC_is_default
140
-							'%d',//PRC_overrides
141
-							'%d',//PRC_deleted
142
-							'%d',//PRC_order
143
-							'%d',//PRC_parent
135
+							'%d', //PRT_id
136
+							'%f', //PRC_amount
137
+							'%s', //PRC_name
138
+							'%s', //PRC_desc
139
+							'%d', //PRC_is_default
140
+							'%d', //PRC_overrides
141
+							'%d', //PRC_deleted
142
+							'%d', //PRC_order
143
+							'%d', //PRC_parent
144 144
 							'%d' //PRC_wp_user
145 145
 						)
146 146
 					);
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 	 *  	@param array $modules_to_register
158 158
 	 *  	@return array
159 159
 	 */
160
-	public function caffeinated_modules_to_register( $modules_to_register = array() ){
161
-		if ( is_readable( EE_CAFF_PATH . 'modules' )) {
162
-			$caffeinated_modules_to_register = glob( EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR );
163
-			if ( is_array( $caffeinated_modules_to_register ) && ! empty( $caffeinated_modules_to_register )) {
164
-				$modules_to_register = array_merge( $modules_to_register, $caffeinated_modules_to_register );
160
+	public function caffeinated_modules_to_register($modules_to_register = array()) {
161
+		if (is_readable(EE_CAFF_PATH.'modules')) {
162
+			$caffeinated_modules_to_register = glob(EE_CAFF_PATH.'modules'.DS.'*', GLOB_ONLYDIR);
163
+			if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
164
+				$modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
165 165
 			}
166 166
 		}
167 167
 		return $modules_to_register;
@@ -169,19 +169,19 @@  discard block
 block discarded – undo
169 169
 
170 170
 
171 171
 
172
-	public function caffeinated_init(){
172
+	public function caffeinated_init() {
173 173
 		// EE_Register_CPTs hooks
174
-		add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( $this, 'filter_taxonomies' ), 10 );
175
-		add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array( $this, 'filter_cpts' ), 10 );
176
-		add_filter('FHEE__EE_Admin__get_extra_nav_menu_pages_items', array( $this, 'nav_metabox_items' ), 10 );
177
-		EE_Registry::instance()->load_file( EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), FALSE );
174
+		add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array($this, 'filter_taxonomies'), 10);
175
+		add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array($this, 'filter_cpts'), 10);
176
+		add_filter('FHEE__EE_Admin__get_extra_nav_menu_pages_items', array($this, 'nav_metabox_items'), 10);
177
+		EE_Registry::instance()->load_file(EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), FALSE);
178 178
 		// caffeinated_init__complete hook
179
-		do_action( 'AHEE__EE_Brewing_Regular__caffeinated_init__complete' );
179
+		do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
180 180
 	}
181 181
 
182 182
 
183 183
 
184
-	public function enqueue_caffeinated_scripts(){
184
+	public function enqueue_caffeinated_scripts() {
185 185
 		// sound of crickets...
186 186
 	}
187 187
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @return array
195 195
 	 */
196 196
 
197
-	public function filter_taxonomies( $taxonomy_array ) {
197
+	public function filter_taxonomies($taxonomy_array) {
198 198
 		$taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = TRUE;
199 199
 		return $taxonomy_array;
200 200
 	}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @param $cpt_array
206 206
 	 * @return mixed
207 207
 	 */
208
-	public function filter_cpts( $cpt_array ) {
208
+	public function filter_cpts($cpt_array) {
209 209
 		$cpt_array['espresso_venues']['args']['show_in_nav_menus'] = TRUE;
210 210
 		return $cpt_array;
211 211
 	}
@@ -216,10 +216,10 @@  discard block
 block discarded – undo
216 216
 	 * @param $menu_items
217 217
 	 * @return array
218 218
 	 */
219
-	public function nav_metabox_items( $menu_items ) {
219
+	public function nav_metabox_items($menu_items) {
220 220
 		$menu_items[] = array(
221 221
 			'title' => __('Venue List', 'event_espresso'),
222
-			'url' => get_post_type_archive_link( 'espresso_venues' ),
222
+			'url' => get_post_type_archive_link('espresso_venues'),
223 223
 			'description' => __('Archive page for all venues.', 'event_espresso')
224 224
 			);
225 225
 		return $menu_items;
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 	 * @param array $payment_method_paths
231 231
 	 * @return array values are folder paths to payment method folders
232 232
 	 */
233
-	public function caf_payment_methods( $payment_method_paths ) {
234
-		$caf_payment_methods_paths = glob( EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR );
235
-		$payment_method_paths = array_merge( $payment_method_paths, $caf_payment_methods_paths );
233
+	public function caf_payment_methods($payment_method_paths) {
234
+		$caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS.'*', GLOB_ONLYDIR);
235
+		$payment_method_paths = array_merge($payment_method_paths, $caf_payment_methods_paths);
236 236
 		return $payment_method_paths;
237 237
 	}
238 238
 }
Please login to merge, or discard this patch.