Completed
Branch FET-9099-unit-test-factories (8a4437)
by
unknown
64:24 queued 54:33
created
libraries/form_sections/strategies/layout/EE_Template_Layout.strategy.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-class EE_Template_Layout extends EE_Div_Per_Section_Layout{
24
+class EE_Template_Layout extends EE_Div_Per_Section_Layout {
25 25
 
26 26
 	protected $_layout_template_file = NULL;
27 27
 	protected $_layout_begin_template_file = NULL;
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 	 * 		@type array 	$_template_args
43 43
 	 * 	}
44 44
 	 */
45
-	public function __construct( $template_options = array() ) {
45
+	public function __construct($template_options = array()) {
46 46
 		// loop thru incoming options
47
-		foreach( $template_options as $key => $value ) {
47
+		foreach ($template_options as $key => $value) {
48 48
 			// add underscore to $key to match property names
49
-			$_key = '_' . $key;
50
-			if ( property_exists( $this, $_key )) {
49
+			$_key = '_'.$key;
50
+			if (property_exists($this, $_key)) {
51 51
 					$this->{$_key} = $value;
52 52
 			}
53 53
 		}
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 	 * @return string
66 66
 	 */
67 67
 	public function layout_form() {
68
-		if ( $this->_layout_template_file ) {
69
-			EE_Registry::instance()->load_helper( 'Template' );
70
-			return EEH_Template::locate_template( $this->_layout_template_file, $this->template_args(), TRUE, TRUE );
68
+		if ($this->_layout_template_file) {
69
+			EE_Registry::instance()->load_helper('Template');
70
+			return EEH_Template::locate_template($this->_layout_template_file, $this->template_args(), TRUE, TRUE);
71 71
 		} else {
72 72
 			return parent::layout_form();
73 73
 		}
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 	 * @return string
81 81
 	 */
82 82
 	public function layout_form_begin() {
83
-		if($this->_layout_begin_template_file){
83
+		if ($this->_layout_begin_template_file) {
84 84
 			EE_Registry::instance()->load_helper('Template');
85
-			return EEH_Template::locate_template( $this->_layout_begin_template_file, $this->template_args(), TRUE, TRUE );
86
-		}else{
85
+			return EEH_Template::locate_template($this->_layout_begin_template_file, $this->template_args(), TRUE, TRUE);
86
+		} else {
87 87
 			return parent::layout_form_begin();
88 88
 		}
89 89
 	}
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	 * @param EE_Form_Input_Base $input
97 97
 	 * @return string
98 98
 	 */
99
-	public function layout_input( $input ) {
100
-		if($this->_input_template_file){
99
+	public function layout_input($input) {
100
+		if ($this->_input_template_file) {
101 101
 			EE_Registry::instance()->load_helper('Template');
102
-			return EEH_Template::locate_template( $this->_input_template_file, array( 'input' => $input ), TRUE, TRUE );
102
+			return EEH_Template::locate_template($this->_input_template_file, array('input' => $input), TRUE, TRUE);
103 103
 		}
104 104
 		return parent::layout_input($input);
105 105
 	}
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
 	 * @param EE_Form_Section_Proper $form_section
113 113
 	 * @return string
114 114
 	 */
115
-	public function layout_subsection( $form_section ) {
116
-		if($this->_subsection_template_file){
115
+	public function layout_subsection($form_section) {
116
+		if ($this->_subsection_template_file) {
117 117
 			EE_Registry::instance()->load_helper('Template');
118
-			return EEH_Template::locate_template( $this->_subsection_template_file, $this->template_args(), TRUE, TRUE );
118
+			return EEH_Template::locate_template($this->_subsection_template_file, $this->template_args(), TRUE, TRUE);
119 119
 		}
120
-		return parent::layout_subsection( $form_section );
120
+		return parent::layout_subsection($form_section);
121 121
 	}
122 122
 
123 123
 
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
 	 * @return string
128 128
 	 */
129 129
 	public function layout_form_end() {
130
-		if($this->_layout_end_template_file){
130
+		if ($this->_layout_end_template_file) {
131 131
 			EE_Registry::instance()->load_helper('Template');
132
-			return EEH_Template::locate_template( $this->_layout_end_template_file, $this->template_args(), TRUE, TRUE);
133
-		}else{
132
+			return EEH_Template::locate_template($this->_layout_end_template_file, $this->template_args(), TRUE, TRUE);
133
+		} else {
134 134
 			return parent::layout_form_end();
135 135
 		}
136 136
 	}
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	/**
141 141
 	 * @param array $template_args
142 142
 	 */
143
-	public function set_template_args( $template_args = array() ) {
143
+	public function set_template_args($template_args = array()) {
144 144
 		$this->_template_args = $template_args;
145 145
 	}
146 146
 
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 	/**
150 150
 	 * @param array $template_args
151 151
 	 */
152
-	public function add_template_args( $template_args = array() ) {
153
-		$this->_template_args = array_merge_recursive( $this->_template_args, $template_args );
152
+	public function add_template_args($template_args = array()) {
153
+		$this->_template_args = array_merge_recursive($this->_template_args, $template_args);
154 154
 	}
155 155
 
156 156
 
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
 	 * @return array
160 160
 	 */
161 161
 	public function template_args() {
162
-		foreach ( $this->form_section()->subsections() as $subsection_name => $subsection ) {
163
-			$subsection_name = self::prep_form_subsection_key_name( $subsection_name );
164
-			if ( strpos( $subsection_name, '[' ) !== FALSE ) {
165
-				$sub_name = explode( '[', $subsection_name );
166
-				$this->_template_args[ $sub_name[0] ][ rtrim( $sub_name[1], ']' ) ] = $this->layout_subsection( $subsection );
162
+		foreach ($this->form_section()->subsections() as $subsection_name => $subsection) {
163
+			$subsection_name = self::prep_form_subsection_key_name($subsection_name);
164
+			if (strpos($subsection_name, '[') !== FALSE) {
165
+				$sub_name = explode('[', $subsection_name);
166
+				$this->_template_args[$sub_name[0]][rtrim($sub_name[1], ']')] = $this->layout_subsection($subsection);
167 167
 			} else {
168
-				$this->_template_args[ $subsection_name ] = $this->layout_subsection( $subsection );
168
+				$this->_template_args[$subsection_name] = $this->layout_subsection($subsection);
169 169
 			}
170 170
 		}
171 171
 //		d( $this->_template_args );
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	 * @param string $subsection_name
182 182
 	 * @return string
183 183
 	 */
184
-	public static function prep_form_subsection_key_name( $subsection_name = '' ) {
185
-		$subsection_name = str_replace( array( '-', ' ' ), array( '', '_' ), $subsection_name );
186
-		return is_numeric( substr( $subsection_name, 0, 1 )) ? 'form_' . $subsection_name : $subsection_name;
184
+	public static function prep_form_subsection_key_name($subsection_name = '') {
185
+		$subsection_name = str_replace(array('-', ' '), array('', '_'), $subsection_name);
186
+		return is_numeric(substr($subsection_name, 0, 1)) ? 'form_'.$subsection_name : $subsection_name;
187 187
 	}
188 188
 
189 189
 
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 	 * @param string $subsection_name
196 196
 	 * @return string
197 197
 	 */
198
-	public static function get_subform_name( $subsection_name = '' ) {
199
-		return EE_Template_Layout::prep_form_subsection_key_name( $subsection_name );
198
+	public static function get_subform_name($subsection_name = '') {
199
+		return EE_Template_Layout::prep_form_subsection_key_name($subsection_name);
200 200
 	}
201 201
 
202 202
 
Please login to merge, or discard this patch.
core/admin/templates/admin_details_legend.template.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@
 block discarded – undo
8 8
 <div class="ee-list-table-legend-container">
9 9
 	<h3><?php _e('Legend', 'event_espresso'); ?></h3>
10 10
 	<dl class="alignleft ee-list-table-legend">
11
-		<?php foreach ( $items as $item => $details ) : ?>
12
-			<?php if ( $per_col < $count ) : ?>
11
+		<?php foreach ($items as $item => $details) : ?>
12
+			<?php if ($per_col < $count) : ?>
13 13
 				</dl>
14 14
 				<dl class="alignleft ee-list-table-legend">
15 15
 			<?php $count = 1; endif; ?>
16 16
 			<dt id="ee-legend-item-<?php echo $item; ?>">
17
-				<?php $class = ! empty( $details['class'] ) ? $details['class'] : 'ee-legend-img-container'; ?>
18
-				<?php if ( strpos( $details[ 'class' ], '<span' ) !== false ) {
17
+				<?php $class = ! empty($details['class']) ? $details['class'] : 'ee-legend-img-container'; ?>
18
+				<?php if (strpos($details['class'], '<span') !== false) {
19 19
 					echo $class;
20 20
 				} else { ?>
21 21
 				<span class="<?php echo $class; ?>">
22
-					<?php if ( ! empty( $details[ 'icon' ] ) ) : ?>
23
-						<img src="<?php echo $details[ 'icon' ]; ?>" class="ee-legend-icon" alt="<?php echo esc_attr( $details[ 'desc' ] ); ?>"/>
22
+					<?php if ( ! empty($details['icon'])) : ?>
23
+						<img src="<?php echo $details['icon']; ?>" class="ee-legend-icon" alt="<?php echo esc_attr($details['desc']); ?>"/>
24 24
 					<?php endif; ?>
25 25
 				</span>
26 26
 				<?php } ?>
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 1 patch
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
  * ------------------------------------------------------------------------
32 32
  */
33 33
 
34
-if ( ! class_exists( 'WP_List_Table' )) {
35
-    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
34
+if ( ! class_exists('WP_List_Table')) {
35
+    require_once(ABSPATH.'wp-admin/includes/class-wp-list-table.php');
36 36
 }
37 37
 
38 38
 abstract class EE_Admin_List_Table extends WP_List_Table {
@@ -243,16 +243,16 @@  discard block
 block discarded – undo
243 243
 	 * constructor
244 244
 	 * @param EE_Admin_Page object $admin_page we use this for obtaining everything we need in the list table.
245 245
 	 */
246
-	public function __construct( EE_Admin_Page $admin_page ) {
246
+	public function __construct(EE_Admin_Page $admin_page) {
247 247
 		$this->_admin_page = $admin_page;
248 248
 		$this->_req_data = $this->_admin_page->get_request_data();
249 249
 		$this->_view = $this->_admin_page->get_view();
250
-		$this->_views = empty( $this->_views ) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
250
+		$this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
251 251
 		$this->_current_page = $this->get_pagenum();
252
-		$this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
253
-		$this->_yes_no = array(  __('No', 'event_espresso'), __('Yes', 'event_espresso'));
252
+		$this->_screen = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view();
253
+		$this->_yes_no = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
254 254
 
255
-		$this->_per_page = $this->get_items_per_page( $this->_screen . '_per_page', 10 );
255
+		$this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10);
256 256
 
257 257
 		$this->_setup_data();
258 258
 		$this->_add_view_counts();
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 		$this->_set_properties();
263 263
 
264 264
 		//set primary column
265
-		add_filter( 'list_table_primary_column', array( $this, 'set_primary_column' ) );
265
+		add_filter('list_table_primary_column', array($this, 'set_primary_column'));
266 266
 
267 267
 		//set parent defaults
268 268
 		parent::__construct($this->_wp_list_args);
@@ -338,17 +338,17 @@  discard block
 block discarded – undo
338 338
 	 * @return html string
339 339
 	 */
340 340
 	protected function _get_hidden_fields() {
341
-		$action = isset( $this->_req_data['route'] ) ? $this->_req_data['route'] : '';
342
-		$action = empty( $action ) && isset( $this->_req_data['action'] ) ? $this->_req_data['action'] : $action;
341
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
342
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
343 343
 		//if action is STILL empty, then we set it to default
344
-		$action = empty( $action ) ? 'default' : $action;
345
-		$field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
346
-		$field .= '<input type="hidden" name="route" value="'. $action .'" />' . "\n";/**/
347
-		$field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
344
+		$action = empty($action) ? 'default' : $action;
345
+		$field = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n";
346
+		$field .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/
347
+		$field .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n";
348 348
 
349 349
 		$bulk_actions = $this->_get_bulk_actions();
350
-		foreach ( $bulk_actions as $bulk_action => $label ) {
351
-			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce  ( $bulk_action . '_nonce' ) . '" />' . "\n";
350
+		foreach ($bulk_actions as $bulk_action => $label) {
351
+			$field .= '<input type="hidden" name="'.$bulk_action.'_nonce" value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n";
352 352
 		}
353 353
 
354 354
 		return $field;
@@ -378,15 +378,15 @@  discard block
 block discarded – undo
378 378
 		 *
379 379
 		 * @var array
380 380
 		 */
381
-		$_sortable = apply_filters( "FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen );
381
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
382 382
 
383 383
 		$sortable = array();
384
-		foreach ( $_sortable as $id => $data ) {
385
-			if ( empty( $data ) )
384
+		foreach ($_sortable as $id => $data) {
385
+			if (empty($data))
386 386
 				continue;
387 387
 
388 388
 			//fix for offset errors with WP_List_Table default get_columninfo()
389
-			if ( is_array($data) ) {
389
+			if (is_array($data)) {
390 390
 				$_data[0] = key($data);
391 391
 				$_data[1] = isset($data[1]) ? $data[1] : false;
392 392
 			} else {
@@ -395,14 +395,14 @@  discard block
 block discarded – undo
395 395
 
396 396
 			$data = (array) $data;
397 397
 
398
-			if ( !isset( $data[1] ) )
398
+			if ( ! isset($data[1]))
399 399
 				$_data[1] = false;
400 400
 
401 401
 
402 402
 			$sortable[$id] = $_data;
403 403
 		}
404 404
 		$primary = $this->get_primary_column_name();
405
-		$this->_column_headers = array( $columns, $hidden, $sortable, $primary );
405
+		$this->_column_headers = array($columns, $hidden, $sortable, $primary);
406 406
 	}
407 407
 
408 408
 
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 	 * @return string
412 412
 	 */
413 413
 	protected function get_primary_column_name() {
414
-		foreach( class_parents( $this ) as $parent ) {
415
-			if ( method_exists( $parent, 'get_primary_column_name' ) && $parent == 'WP_List_Table' ) {
414
+		foreach (class_parents($this) as $parent) {
415
+			if (method_exists($parent, 'get_primary_column_name') && $parent == 'WP_List_Table') {
416 416
 				return parent::get_primary_column_name();
417 417
 			}
418 418
 		}
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
425 425
 	 * @return string
426 426
 	 */
427
-	protected function handle_row_actions( $item, $column_name, $primary ) {
428
-		foreach( class_parents( $this ) as $parent ) {
429
-			if ( method_exists( $parent, 'handle_row_actions' ) && $parent == 'WP_List_Table' ) {
430
-				return parent::handle_row_actions( $item, $column_name, $primary );
427
+	protected function handle_row_actions($item, $column_name, $primary) {
428
+		foreach (class_parents($this) as $parent) {
429
+			if (method_exists($parent, 'handle_row_actions') && $parent == 'WP_List_Table') {
430
+				return parent::handle_row_actions($item, $column_name, $primary);
431 431
 			}
432 432
 		}
433 433
 		return '';
@@ -445,11 +445,11 @@  discard block
 block discarded – undo
445 445
 	protected function _get_bulk_actions() {
446 446
 		$actions = array();
447 447
 		//the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table();
448
-		foreach ( $this->_views as $view => $args) {
449
-			if ( isset( $args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view )
448
+		foreach ($this->_views as $view => $args) {
449
+			if (isset($args['bulk_action']) && is_array($args['bulk_action']) && $this->_view == $view)
450 450
 				//each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user.
451
-				foreach ( $args['bulk_action'] as $route =>$label ) {
452
-					if ( $this->_admin_page->check_user_access( $route, true ) ) {
451
+				foreach ($args['bulk_action'] as $route =>$label) {
452
+					if ($this->_admin_page->check_user_access($route, true)) {
453 453
 						$actions[$route] = $label;
454 454
 					}
455 455
 				}
@@ -467,18 +467,18 @@  discard block
 block discarded – undo
467 467
 	 */
468 468
 	private function _filters() {
469 469
 		$classname = get_class($this);
470
-		$filters = apply_filters( "FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen );
470
+		$filters = apply_filters("FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this, $this->_screen);
471 471
 
472
-		if ( empty( $filters )) {
472
+		if (empty($filters)) {
473 473
 			return;
474 474
 		}
475
-		foreach ( $filters as $filter ) {
475
+		foreach ($filters as $filter) {
476 476
 			echo $filter;
477 477
 		}
478 478
 		//add filter button at end
479
-		echo '<input type="submit" class="button-secondary" value="' . __('Filter', 'event_espresso') . '" id="post-query-submit" />';
479
+		echo '<input type="submit" class="button-secondary" value="'.__('Filter', 'event_espresso').'" id="post-query-submit" />';
480 480
 		//add reset filters button at end
481
-		echo '<a class="button button-secondary"  href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters', 'event_espresso') . '</a>';
481
+		echo '<a class="button button-secondary"  href="'.$this->_admin_page->get_current_page_view_url().'" style="display:inline-block">'.__('Reset Filters', 'event_espresso').'</a>';
482 482
 	}
483 483
 
484 484
 
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
 	 * @param string $column_name
493 493
 	 * @return string
494 494
 	 */
495
-	public function set_primary_column( $column_name ) {
496
-		return ! empty( $this->_primary_column ) ? $this->_primary_column : $column_name;
495
+	public function set_primary_column($column_name) {
496
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
497 497
 	}
498 498
 
499 499
 
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 			array(
513 513
 				'total_items' => $total_items,
514 514
 				'per_page' => $this->_per_page,
515
-				'total_pages' => ceil($total_items / $this->_per_page )
515
+				'total_pages' => ceil($total_items / $this->_per_page)
516 516
 			)
517 517
 		);
518 518
 	}
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 	 *
529 529
 	 * @return string html content for the column
530 530
 	 */
531
-	public function column_default( $item, $column_name ) {
531
+	public function column_default($item, $column_name) {
532 532
 		/**
533 533
 		 * Dynamic hook allowing for adding additional column content in this list table.
534 534
 		 * Note that $this->screen->id is in the format
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 		 * hook prefix ("event-espresso") will be different.
539 539
 		 *
540 540
 		 */
541
-		do_action( 'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item, $this->_screen );
541
+		do_action('AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id, $item, $this->_screen);
542 542
 	}
543 543
 
544 544
 
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 		 *
555 555
 		 * @var array
556 556
 		 */
557
-		$columns = apply_filters( 'FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen );
557
+		$columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen);
558 558
 		return $columns;
559 559
 	}
560 560
 
@@ -566,18 +566,18 @@  discard block
 block discarded – undo
566 566
 		$views = $this->get_views();
567 567
 		$assembled_views = '';
568 568
 
569
-		if ( empty( $views )) {
569
+		if (empty($views)) {
570 570
 			return;
571 571
 		}
572 572
 		echo "<ul class='subsubsub'>\n";
573
-		foreach ( $views as $view ) {
574
-			$count = isset($view['count'] ) && !empty($view['count']) ? absint( $view['count'] )  : 0;
575
-			if ( isset( $view['slug'] ) && isset( $view['class'] ) && isset( $view['url'] ) && isset( $view['label']) ) {
576
-				$assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>';
573
+		foreach ($views as $view) {
574
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
575
+			if (isset($view['slug']) && isset($view['class']) && isset($view['url']) && isset($view['label'])) {
576
+				$assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>".'<a href="'.$view['url'].'">'.$view['label'].'</a> <span class="count">('.$count.')</span>';
577 577
 			}
578 578
 		}
579 579
 
580
-		echo is_array( $assembled_views) && ! empty( $assembled_views ) ? implode( " |</li>\n", $assembled_views ) . "</li>\n" : '';
580
+		echo is_array($assembled_views) && ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : '';
581 581
 		echo "</ul>";
582 582
 	}
583 583
 
@@ -590,10 +590,10 @@  discard block
 block discarded – undo
590 590
 	 *
591 591
 	 * @param object $item The current item
592 592
 	 */
593
-	public function single_row( $item ) {
594
-		$row_class = $this->_get_row_class( $item );
595
-		echo '<tr class="' . esc_attr( $row_class ) . '">';
596
-		$this->single_row_columns( $item );
593
+	public function single_row($item) {
594
+		$row_class = $this->_get_row_class($item);
595
+		echo '<tr class="'.esc_attr($row_class).'">';
596
+		$this->single_row_columns($item);
597 597
 		echo '</tr>';
598 598
 	}
599 599
 
@@ -604,13 +604,13 @@  discard block
 block discarded – undo
604 604
 	 * @param  object $item the current item
605 605
 	 * @return string
606 606
 	 */
607
-	protected function _get_row_class( $item ) {
607
+	protected function _get_row_class($item) {
608 608
 		static $row_class = '';
609
-		$row_class = ( $row_class == '' ? 'alternate' : '' );
609
+		$row_class = ($row_class == '' ? 'alternate' : '');
610 610
 
611 611
 		$new_row_class = $row_class;
612 612
 
613
-		if ( !empty($this->_ajax_sorting_callback) ) {
613
+		if ( ! empty($this->_ajax_sorting_callback)) {
614 614
 			$new_row_class .= ' rowsortable';
615 615
 		}
616 616
 
@@ -629,13 +629,13 @@  discard block
 block discarded – undo
629 629
 
630 630
 	public function get_hidden_columns() {
631 631
 		$user_id = get_current_user_id();
632
-		$has_default = get_user_option('default'. $this->screen->id . 'columnshidden', $user_id);
633
-		if ( empty( $has_default ) && !empty($this->_hidden_columns ) ) {
634
-			update_user_option($user_id, 'default'.$this->screen->id . 'columnshidden', TRUE);
635
-			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, TRUE );
632
+		$has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id);
633
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
634
+			update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', TRUE);
635
+			update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, TRUE);
636 636
 		}
637
-		$ref = 'manage' . $this->screen->id . 'columnshidden';
638
-		$saved_columns = (array) get_user_option( $ref, $user_id );
637
+		$ref = 'manage'.$this->screen->id.'columnshidden';
638
+		$saved_columns = (array) get_user_option($ref, $user_id);
639 639
 		return $saved_columns;
640 640
 	}
641 641
 
@@ -650,47 +650,47 @@  discard block
 block discarded – undo
650 650
 	 *
651 651
 	 * @param object $item The current item
652 652
 	 */
653
-	public function single_row_columns( $item ) {
654
-		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
653
+	public function single_row_columns($item) {
654
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
655 655
 
656 656
 		global $wp_version;
657
-		$use_hidden_class = version_compare( $wp_version, '4.3-RC', '>=' );
657
+		$use_hidden_class = version_compare($wp_version, '4.3-RC', '>=');
658 658
 
659
-		foreach ( $columns as $column_name => $column_display_name ) {
659
+		foreach ($columns as $column_name => $column_display_name) {
660 660
 
661 661
 			/**
662 662
 			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are
663 663
 			 * hidden or not instead of using "display:none;".  This bit of code provides backward compat.
664 664
 			 */
665
-			$hidden_class = $use_hidden_class && in_array( $column_name, $hidden ) ? ' hidden' : '';
666
-			$style = ! $use_hidden_class && in_array( $column_name, $hidden ) ? ' style="display:none;"' : '';
665
+			$hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
666
+			$style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
667 667
 
668
-			$classes = $column_name . ' column-' . $column_name.$hidden_class;
669
-			if ( $primary == $column_name ) {
668
+			$classes = $column_name.' column-'.$column_name.$hidden_class;
669
+			if ($primary == $column_name) {
670 670
 				$classes .= ' has-row-actions column-primary';
671 671
 			}
672 672
 
673
-			$data = ' data-colname="' . wp_strip_all_tags( $column_display_name ) . '"';
673
+			$data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"';
674 674
 
675 675
 			$class = "class='$classes'";
676 676
 
677 677
 			$attributes = "$class$style$data";
678 678
 
679
-			if ( 'cb' === $column_name ) {
679
+			if ('cb' === $column_name) {
680 680
 				echo '<th scope="row" class="check-column">';
681
-				echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb( $item ), $item, $this );
681
+				echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content', $this->column_cb($item), $item, $this);
682 682
 				echo '</th>';
683 683
 			}
684
-			elseif ( method_exists( $this, 'column_' . $column_name ) ) {
684
+			elseif (method_exists($this, 'column_'.$column_name)) {
685 685
 				echo "<td $attributes>";
686
-				echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content', call_user_func( array( $this, 'column_' . $column_name ), $item ), $item, $this );
687
-				echo $this->handle_row_actions( $item, $column_name, $primary );
686
+				echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content', call_user_func(array($this, 'column_'.$column_name), $item), $item, $this);
687
+				echo $this->handle_row_actions($item, $column_name, $primary);
688 688
 				echo "</td>";
689 689
 			}
690 690
 			else {
691 691
 				echo "<td $attributes>";
692
-				echo apply_filters( 'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default( $item, $column_name ), $item, $column_name, $this );
693
-				echo $this->handle_row_actions( $item, $column_name, $primary );
692
+				echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content', $this->column_default($item, $column_name), $item, $column_name, $this);
693
+				echo $this->handle_row_actions($item, $column_name, $primary);
694 694
 				echo "</td>";
695 695
 			}
696 696
 		}
@@ -698,19 +698,19 @@  discard block
 block discarded – undo
698 698
 
699 699
 
700 700
 
701
-	public function extra_tablenav( $which ) {
702
-		if ( $which == 'top' ) {
701
+	public function extra_tablenav($which) {
702
+		if ($which == 'top') {
703 703
 			$this->_filters();
704 704
 			echo $this->_get_hidden_fields();
705 705
 			echo '<br class="clear">';
706
-		}else{
706
+		} else {
707 707
 			echo '<div class="list-table-bottom-buttons alignleft actions">';
708
-			foreach($this->_bottom_buttons as $type => $action){
709
-				$route = isset( $action['route'] ) ? $action['route'] : '';
710
-				$extra_request = isset( $action['extra_request'] ) ? $action['extra_request'] : '';
708
+			foreach ($this->_bottom_buttons as $type => $action) {
709
+				$route = isset($action['route']) ? $action['route'] : '';
710
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
711 711
 				echo $this->_admin_page->get_action_link_or_button($route, $type, $extra_request);
712 712
 			}
713
-			do_action( 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen );
713
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
714 714
 			echo '</div>';
715 715
 		}
716 716
 		//echo $this->_entries_per_page_dropdown;
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
 	 *
761 761
 	 * @return string The assembled action elements container.
762 762
 	 */
763
-	protected function _action_string( $action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '' ) {
763
+	protected function _action_string($action_items, $item, $action_container = 'ul', $action_class = '', $action_id = '') {
764 764
 		$content = '';
765
-		$action_class = ! empty( $action_class ) ? ' class="' . $action_class . '"' : '';
766
-		$action_id = ! empty( $action_id ) ? ' id="' . $action_id . '"' : '';
767
-		$content .= ! empty( $action_container ) ? '<' . $action_container . $action_class . $action_id . '>' : '';
768
-		$content .= apply_filters( 'FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this );
769
-		$content .= ! empty( $container ) ? '</' . $container . '>' : '';
765
+		$action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : '';
766
+		$action_id = ! empty($action_id) ? ' id="'.$action_id.'"' : '';
767
+		$content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : '';
768
+		$content .= apply_filters('FHEE__EE_Admin_List_Table___action_string__action_items', $action_items, $item, $this);
769
+		$content .= ! empty($container) ? '</'.$container.'>' : '';
770 770
 		return $content;
771 771
 	}
772 772
 }
Please login to merge, or discard this patch.
payment_methods/Aim/help_tabs/payment_methods_overview_aim.help_tab.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 <?php _e('Adjust the settings for the Authorize.net AIM payment gateway.', 'event_espresso'); ?>
4 4
 </p>
5 5
 <p>
6
-<?php printf( __( 'See %1$shere%2$s for list of currencies supported by Authorize.net AIM.', 'event_espresso' ), "<a href='http://www.authorize.net/international/'  target='_blank'>","</a>" ); ?>
6
+<?php printf(__('See %1$shere%2$s for list of currencies supported by Authorize.net AIM.', 'event_espresso'), "<a href='http://www.authorize.net/international/'  target='_blank'>", "</a>"); ?>
7 7
 </p>
8 8
 <p><strong><?php _e('Authorize.net AIM Settings', 'event_espresso'); ?></strong></p>
9 9
 <ul>
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
 <?php _e('By logging into Authorize.net, you can change which payment fields are required by Authorize.net when processing payments. These settings affect both the Advanced Integration Method (AIM, this) and the Simple Integration Method (SIM, different). The payment method settings "Excluded Payment Form Fields" and "Required Payment Form Fields" allow you to change the billing form in Event Espresso to reflect your payment form settings in Authorize.net.', 'event_espresso'); ?>
29 29
 <br>
30 30
 <?php printf( 
31
-		__( 'To change your payment form settings in Authorize.net, %1$slog in to authorize.net%2$s, go to %3$sAccount then Payment Form%2$s, then %4$sForm Fields%2$s. It will look similar to %5$sthis%2$s. If you make a field required in Authorize.net, you should also make it required in Event Espresso. If it isn\'t required in Authorize.net, and you want to simplify the billing form in Event Espresso, you can exclude it from the Event Espresso Form too.'),
31
+		__('To change your payment form settings in Authorize.net, %1$slog in to authorize.net%2$s, go to %3$sAccount then Payment Form%2$s, then %4$sForm Fields%2$s. It will look similar to %5$sthis%2$s. If you make a field required in Authorize.net, you should also make it required in Event Espresso. If it isn\'t required in Authorize.net, and you want to simplify the billing form in Event Espresso, you can exclude it from the Event Espresso Form too.'),
32 32
 		'<a href="http://authorize.net" target="_blank">',
33 33
 		'</a>',
34 34
 		'<a href="https://monosnap.com/file/nebVteOkEXcdDIos88SojStWOifP23" target="_blank">',
35 35
 		'<a href="https://monosnap.com/file/WyxGJtev87TcDmdGBEZ2oi1xaBIQAm" target="_blank">',
36
-		'<a href="https://monosnap.com/image/DbCJNfEesWXeSNUs1wLIpGYODFw52m" target="_blank">');?>
36
+		'<a href="https://monosnap.com/image/DbCJNfEesWXeSNUs1wLIpGYODFw52m" target="_blank">'); ?>
37 37
 </li>
38 38
 <li>
39 39
 <strong><?php _e('Button Image URL', 'event_espresso'); ?></strong><br />
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 3 patches
Doc Comments   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	 * Returns the name of the field's name that points to the WP_User table
762 762
 	 *  on this model (or follows the _model_chain_to_wp_user and uses that model's
763 763
 	 * foreign key to the WP_User table)
764
-	 * @return string|boolean string on success, boolean false when there is no
764
+	 * @return string|false string on success, boolean false when there is no
765 765
 	 * foreign key to the WP_User table
766 766
 	 */
767 767
 	function wp_user_field_name() {
@@ -858,6 +858,7 @@  discard block
 block discarded – undo
858 858
 	 * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array.
859 859
 	 * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection
860 860
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
861
+	 * @param string $columns_to_select
861 862
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
862 863
 	 */
863 864
 	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
@@ -1200,7 +1201,7 @@  discard block
 block discarded – undo
1200 1201
 	 * @param bool   $pretty          Whether to return the pretty formats (true) or not (false).
1201 1202
 	 * @throws EE_Error   If the given field_name is not of the EE_Datetime_Field type.
1202 1203
 	 *
1203
-	 * @return array formats in an array with the date format first, and the time format last.
1204
+	 * @return string[] formats in an array with the date format first, and the time format last.
1204 1205
 	 */
1205 1206
 	public function get_formats_for( $field_name, $pretty = false ) {
1206 1207
 		$field_settings = $this->field_settings_for( $field_name );
@@ -1235,7 +1236,7 @@  discard block
 block discarded – undo
1235 1236
 	 *
1236 1237
 	 * @throws EE_Error   	If the given field_name is not of the EE_Datetime_Field type.
1237 1238
 	 *
1238
-	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1239
+	 * @return string|null  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1239 1240
 	 *                    	     exception is triggered.
1240 1241
 	 */
1241 1242
 	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
@@ -1535,7 +1536,7 @@  discard block
 block discarded – undo
1535 1536
 	 * not just have a flag field on it switched
1536 1537
 	 * Wrapper for EEM_Base::delete_permanently()
1537 1538
 	 * @param mixed $id
1538
-	 * @return boolean whether the row got deleted or not
1539
+	 * @return integer whether the row got deleted or not
1539 1540
 	 */
1540 1541
 	public function delete_permanently_by_ID( $id ) {
1541 1542
 		return $this->delete_permanently( 
@@ -1552,7 +1553,7 @@  discard block
 block discarded – undo
1552 1553
 	 * Deletes a single row from the DB given the model object's primary key value. (eg, EE_Attendee->ID()'s value).
1553 1554
 	 * Wrapper for EEM_Base::delete()
1554 1555
 	 * @param mixed $id
1555
-	 * @return boolean whether the row got deleted or not
1556
+	 * @return integer whether the row got deleted or not
1556 1557
 	 */
1557 1558
 	public function delete_by_ID( $id ){
1558 1559
 		return $this->delete( 
@@ -1926,7 +1927,7 @@  discard block
 block discarded – undo
1926 1927
 	/**
1927 1928
 	 * Verifies the EE addons' database is up-to-date and records that we've done it on
1928 1929
 	 * EEM_Base::$_db_verification_level
1929
-	 * @param $wpdb_method
1930
+	 * @param string $wpdb_method
1930 1931
 	 * @param $arguments_to_provide
1931 1932
 	 * @return string
1932 1933
 	 */
@@ -1994,7 +1995,6 @@  discard block
 block discarded – undo
1994 1995
 	 * 'hasAndBelongsToMany' relationships: checks that there isn't already an entry in the join table, and adds one.
1995 1996
 	 * If one of the model Objects has not yet been saved to the database, it is saved before adding the entry in the join table
1996 1997
 	 *
1997
-	 * @param EE_Base_Class/int $thisModelObject
1998 1998
 	 * @param EE_Base_Class/int $id_or_obj EE_base_Class or ID of other Model Object
1999 1999
 	 * @param string $relationName, key in EEM_Base::_relations
2000 2000
 	 * an attendee to a group, you also want to specify which role they will have in that group. So you would use this parameter to specify array('role-column-name'=>'role-id')
@@ -2016,8 +2016,8 @@  discard block
 block discarded – undo
2016 2016
 	 *
2017 2017
 	 * 'hasAndBelongsToMany' relationships:removes any existing entry in the join table between the two models.
2018 2018
 	 *
2019
-	 * @param EE_Base_Class/int $id_or_obj
2020
-	 * @param EE_Base_Class/int $other_model_id_or_obj EE_Base_Class or ID of other Model Object
2019
+	 * @param EE_CPT_Base $id_or_obj
2020
+	 * @param EE_Term_Taxonomy $other_model_id_or_obj EE_Base_Class or ID of other Model Object
2021 2021
 	 * @param string $relationName key in EEM_Base::_relations
2022 2022
 	 * @return boolean of success
2023 2023
 	 * @param array   $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
@@ -2093,7 +2093,7 @@  discard block
 block discarded – undo
2093 2093
 	/**
2094 2094
 	 * Instead of getting the related model objects, simply counts them. Ignores default_where_conditions by default,
2095 2095
 	 * unless otherwise specified in the $query_params
2096
-	 * @param int/EE_Base_Class $id_or_obj
2096
+	 * @param EE_Event $id_or_obj
2097 2097
 	 * @param string $model_name like 'Event', or 'Registration'
2098 2098
 	 * @param array $query_params like EEM_Base::get_all's
2099 2099
 	 * @param string $field_to_count name of field to count by. By default, uses primary key
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
 	/**
2483 2483
 	 * Finds all the fields that correspond to the given table
2484 2484
 	 * @param string $table_alias, array key in EEM_Base::_tables
2485
-	 * @return EE_Model_Field_Base[]
2485
+	 * @return EE_Model_Field_Base
2486 2486
 	 */
2487 2487
 	function _get_fields_for_table($table_alias){
2488 2488
 		return $this->_fields[$table_alias];
@@ -3569,8 +3569,8 @@  discard block
 block discarded – undo
3569 3569
 	/**
3570 3570
 	 * gets the field object of type 'primary_key' from the fieldsSettings attribute.
3571 3571
 	 * Eg, on EE_Answer that would be ANS_ID field object
3572
-	 * @param $field_obj
3573
-	 * @return EE_Model_Field_Base
3572
+	 * @param EE_Model_Field_Base $field_obj
3573
+	 * @return boolean
3574 3574
 	 */
3575 3575
 	public function is_primary_key_field( $field_obj ){
3576 3576
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
@@ -3664,7 +3664,7 @@  discard block
 block discarded – undo
3664 3664
 	 * Gets the actual table for the table alias
3665 3665
 	 * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe
3666 3666
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3667
-	 * @return EE_Table_Base
3667
+	 * @return string
3668 3668
 	 */
3669 3669
 	function get_table_for_alias($table_alias){
3670 3670
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
@@ -3791,7 +3791,7 @@  discard block
 block discarded – undo
3791 3791
 	 * The purpose of this method is to allow us to create a model object that is not in the db that holds default values.
3792 3792
 	 * A typical example of where this is used is when creating a new item and the initial load of a form.  We dont' necessarily want to test for if the object is present but just assume it is BUT load the defaults from the object (as set in the model_field!).
3793 3793
 	 *
3794
-	 * @return EE_Base_Class single EE_Base_Class object with default values for the properties.
3794
+	 * @return boolean single EE_Base_Class object with default values for the properties.
3795 3795
 	 */
3796 3796
 	public function create_default_object() {
3797 3797
 
@@ -3915,7 +3915,7 @@  discard block
 block discarded – undo
3915 3915
 	 * returns an array of their corresponding field names and database values
3916 3916
 	 *
3917 3917
 	 * @param string $cols_n_values
3918
-	 * @return array
3918
+	 * @return string
3919 3919
 	 */
3920 3920
 	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
3921 3921
 		$this_model_fields_n_values = array();
@@ -4176,7 +4176,7 @@  discard block
 block discarded – undo
4176 4176
 	}
4177 4177
 	/**
4178 4178
 	 * Read comments for assume_values_already_prepared_by_model_object()
4179
-	 * @return int
4179
+	 * @return boolean
4180 4180
 	 */
4181 4181
 	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4182 4182
 		return $this->_values_already_prepared_by_model_object;
Please login to merge, or discard this patch.
Spacing   +954 added lines, -954 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @since 				EE4
24 24
  *
25 25
  */
26
-abstract class EEM_Base extends EE_Base{
26
+abstract class EEM_Base extends EE_Base {
27 27
 
28 28
 	//admin posty
29 29
 	//basic -> grants access to mine -> if they don't have it, select none
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * Flag indicating whether this model has a primary key or not
236 236
 	 * @var boolean
237 237
 	 */
238
-	protected $_has_primary_key_field=null;
238
+	protected $_has_primary_key_field = null;
239 239
 
240 240
 	/**
241 241
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -297,19 +297,19 @@  discard block
 block discarded – undo
297 297
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
298 298
 	 * @var array
299 299
 	 */
300
-	protected $_between_style_operators = array( 'BETWEEN' );
300
+	protected $_between_style_operators = array('BETWEEN');
301 301
 
302 302
 	/**
303 303
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
304 304
 	 * @var array
305 305
 	 */
306
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
306
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
307 307
 
308 308
 	/**
309 309
 	 * Allowed values for $query_params['order'] for ordering in queries
310 310
 	 * @var array
311 311
 	 */
312
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
312
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
313 313
 
314 314
 	/**
315 315
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
324 324
 	 * @var array
325 325
 	 */
326
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
326
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
327 327
 
328 328
 	/**
329 329
 	 * All the data types that can be used in $wpdb->prepare statements.
330 330
 	 * @var array
331 331
 	 */
332
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
332
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
333 333
 
334 334
 	/**
335 335
 	 * 	EE_Registry Object
@@ -362,17 +362,17 @@  discard block
 block discarded – undo
362 362
 	/**
363 363
 	 * constant used to show EEM_Base has not yet verified the db on this http request
364 364
 	 */
365
-	const db_verified_none 		= 0;
365
+	const db_verified_none = 0;
366 366
 	/**
367 367
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
368 368
 	 * but not the addons' dbs
369 369
 	 */
370
-	const db_verified_core 		= 1;
370
+	const db_verified_core = 1;
371 371
 	/**
372 372
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
373 373
 	 * the EE core db too)
374 374
 	 */
375
-	const db_verified_addons 	= 2;
375
+	const db_verified_addons = 2;
376 376
 
377 377
 	/**
378 378
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
 	 * @param null $timezone
404 404
 	 * @throws \EE_Error
405 405
 	 */
406
-	protected function __construct( $timezone = NULL ){
406
+	protected function __construct($timezone = NULL) {
407 407
 		// check that the model has not been loaded too soon
408
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
409
-			throw new EE_Error (
408
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
409
+			throw new EE_Error(
410 410
 				sprintf(
411
-					__( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ),
412
-					get_class( $this )
411
+					__('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'),
412
+					get_class($this)
413 413
 				)
414 414
 			);
415 415
 		}
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
 		 * just use EE_Register_Model_Extension
420 420
 		 * @var EE_Table_Base[] $_tables
421 421
 		 */
422
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
423
-		foreach($this->_tables as $table_alias => $table_obj){
422
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
423
+		foreach ($this->_tables as $table_alias => $table_obj) {
424 424
 			/** @var $table_obj EE_Table_Base */
425 425
 			$table_obj->_construct_finalize_with_alias($table_alias);
426
-			if( $table_obj instanceof EE_Secondary_Table ){
426
+			if ($table_obj instanceof EE_Secondary_Table) {
427 427
 				/** @var $table_obj EE_Secondary_Table */
428 428
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
429 429
 			}
@@ -433,54 +433,54 @@  discard block
 block discarded – undo
433 433
 		 * EE_Register_Model_Extension
434 434
 		 * @param EE_Model_Field_Base[] $_fields
435 435
 		 */
436
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
436
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
437 437
 		$this->_invalidate_field_caches();
438
-		foreach($this->_fields as $table_alias => $fields_for_table){
439
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
440
-				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields)));
438
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
439
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
440
+				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields)));
441 441
 			}
442
-			foreach($fields_for_table as $field_name => $field_obj){
442
+			foreach ($fields_for_table as $field_name => $field_obj) {
443 443
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
444 444
 				//primary key field base has a slightly different _construct_finalize
445 445
 				/** @var $field_obj EE_Model_Field_Base */
446
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
446
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
447 447
 			}
448 448
 		}
449 449
 
450 450
 		// everything is related to Extra_Meta
451
-		if( get_class($this) != 'EEM_Extra_Meta'){
451
+		if (get_class($this) != 'EEM_Extra_Meta') {
452 452
 			//make extra meta related to everything, but don't block deleting things just
453 453
 			//because they have related extra meta info. For now just orphan those extra meta
454 454
 			//in the future we should automatically delete them
455
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
455
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
456 456
 		}
457 457
 		//and change logs
458
-		if( get_class( $this) !=  'EEM_Change_Log' ) {
459
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
458
+		if (get_class($this) != 'EEM_Change_Log') {
459
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
460 460
 		}
461 461
 		/**
462 462
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
463 463
 		 * EE_Register_Model_Extension
464 464
 		 * @param EE_Model_Relation_Base[] $_model_relations
465 465
 		 */
466
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
467
-		foreach($this->_model_relations as $model_name => $relation_obj){
466
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
467
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
468 468
 			/** @var $relation_obj EE_Model_Relation_Base */
469 469
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
470 470
 		}
471
-		foreach($this->_indexes as $index_name => $index_obj){
471
+		foreach ($this->_indexes as $index_name => $index_obj) {
472 472
 			/** @var $index_obj EE_Index */
473 473
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
474 474
 		}
475 475
 
476 476
 		$this->set_timezone($timezone);
477 477
 		//finalize default where condition strategy, or set default
478
-		if( ! $this->_default_where_conditions_strategy){
478
+		if ( ! $this->_default_where_conditions_strategy) {
479 479
 			//nothing was set during child constructor, so set default
480 480
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
481 481
 		}
482 482
 		$this->_default_where_conditions_strategy->_finalize_construct($this);
483
-		if( ! $this->_minimum_where_conditions_strategy){
483
+		if ( ! $this->_minimum_where_conditions_strategy) {
484 484
 			//nothing was set during child constructor, so set default
485 485
 			$this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions();
486 486
 		}
@@ -488,15 +488,15 @@  discard block
 block discarded – undo
488 488
 
489 489
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
490 490
 		//to indicate to NOT set it, set it to the logical default
491
-		if( $this->_caps_slug === null ) {
492
-			EE_Registry::instance()->load_helper( 'Inflector' );
493
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
491
+		if ($this->_caps_slug === null) {
492
+			EE_Registry::instance()->load_helper('Inflector');
493
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
494 494
 		}
495 495
 		//initialize the standard cap restriction generators if none were specified by the child constructor
496
-		if( $this->_cap_restriction_generators !== false ){
497
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
498
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
499
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
496
+		if ($this->_cap_restriction_generators !== false) {
497
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
498
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
499
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
500 500
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
501 501
 						new EE_Restriction_Generator_Protected(),
502 502
 						$cap_context,
@@ -506,23 +506,23 @@  discard block
 block discarded – undo
506 506
 			}
507 507
 		}
508 508
 		//if there are cap restriction generators, use them to make the default cap restrictions
509
-		if( $this->_cap_restriction_generators !== false ){
510
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
511
-				if( ! $generator_object ){
509
+		if ($this->_cap_restriction_generators !== false) {
510
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
511
+				if ( ! $generator_object) {
512 512
 					continue;
513 513
 				}
514
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
514
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
515 515
 					throw new EE_Error(
516 516
 						sprintf(
517
-							__( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ),
517
+							__('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'),
518 518
 							$context,
519 519
 							$this->get_this_model_name()
520 520
 						)
521 521
 					);
522 522
 				}
523
-				$action = $this->cap_action_for_context( $context );
524
-				if( ! $generator_object->construction_finalized() ){
525
-					$generator_object->_construct_finalize( $this, $action );
523
+				$action = $this->cap_action_for_context($context);
524
+				if ( ! $generator_object->construction_finalized()) {
525
+					$generator_object->_construct_finalize($this, $action);
526 526
 				}
527 527
 
528 528
 			}
@@ -536,11 +536,11 @@  discard block
 block discarded – undo
536 536
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
537 537
 	 * @return EE_Default_Where_Conditions[]
538 538
 	 */
539
-	protected function _generate_cap_restrictions( $context ){
540
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
541
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
542
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
543
-		}else{
539
+	protected function _generate_cap_restrictions($context) {
540
+		if (isset($this->_cap_restriction_generators[$context]) &&
541
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
542
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
543
+		} else {
544 544
 			return array();
545 545
 		}
546 546
 }
@@ -553,16 +553,16 @@  discard block
 block discarded – undo
553 553
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
554 554
 	 *		@return static (as in the concrete child class)
555 555
 	 */
556
-	public static function instance( $timezone = NULL ){
556
+	public static function instance($timezone = NULL) {
557 557
 
558 558
 		// check if instance of Espresso_model already exists
559 559
 		if ( ! static::$_instance instanceof static) {
560 560
 			// instantiate Espresso_model
561
-			static::$_instance = new static( $timezone );
561
+			static::$_instance = new static($timezone);
562 562
 		}
563 563
 
564 564
 		//we might have a timezone set, let set_timezone decide what to do with it
565
-		static::$_instance->set_timezone( $timezone );
565
+		static::$_instance->set_timezone($timezone);
566 566
 
567 567
 		// Espresso_model object
568 568
 		return static::$_instance;
@@ -575,11 +575,11 @@  discard block
 block discarded – undo
575 575
 	 * @param null | string $timezone
576 576
 	 * @return static
577 577
 	 */
578
-	public static function reset(  $timezone = NULL ){
579
-		if ( ! is_null( static::$_instance ) ) {
578
+	public static function reset($timezone = NULL) {
579
+		if ( ! is_null(static::$_instance)) {
580 580
 			static::$_instance = null;
581 581
 
582
-			return self::instance( $timezone );
582
+			return self::instance($timezone);
583 583
 		}
584 584
 		return null;
585 585
 	}
@@ -590,15 +590,15 @@  discard block
 block discarded – undo
590 590
 	 * @param  boolean $translated return localized strings or JUST the array.
591 591
 	 * @return array
592 592
 	 */
593
-	 public function status_array( $translated = FALSE ) {
594
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
593
+	 public function status_array($translated = FALSE) {
594
+	 	if ( ! array_key_exists('Status', $this->_model_relations))
595 595
 	 		return array();
596 596
 	 	$model_name = $this->get_this_model_name();
597
-	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
598
-	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
597
+	 	$status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
598
+	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
599 599
 	 	$status_array = array();
600
-	 	foreach ( $stati as $status ) {
601
-            $status_array[ $status->ID() ] = $status->get('STS_code');
600
+	 	foreach ($stati as $status) {
601
+            $status_array[$status->ID()] = $status->get('STS_code');
602 602
         }
603 603
         return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
604 604
     }
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 	 *			'order_by'=>array('ANS_value'=>'ASC')
740 740
 	 *		));
741 741
 	 */
742
-	function get_all($query_params = array()){
742
+	function get_all($query_params = array()) {
743 743
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
744 744
 	}
745 745
 
@@ -749,10 +749,10 @@  discard block
 block discarded – undo
749 749
 	 * @param array $query_params @see EEM_Base::get_all()
750 750
 	 * @return array like EEM_Base::get_all
751 751
 	 */
752
-	function alter_query_params_to_only_include_mine( $query_params = array() ) {
752
+	function alter_query_params_to_only_include_mine($query_params = array()) {
753 753
 		$wp_user_field_name = $this->wp_user_field_name();
754
-		if( $wp_user_field_name ){
755
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
754
+		if ($wp_user_field_name) {
755
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
756 756
 		}
757 757
 		return $query_params;
758 758
 	}
@@ -765,19 +765,19 @@  discard block
 block discarded – undo
765 765
 	 * foreign key to the WP_User table
766 766
 	 */
767 767
 	function wp_user_field_name() {
768
-		try{
769
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
770
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
771
-				$last_model_name = end( $models_to_follow_to_wp_users );
772
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
773
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
774
-			}else{
768
+		try {
769
+			if ( ! empty($this->_model_chain_to_wp_user)) {
770
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
771
+				$last_model_name = end($models_to_follow_to_wp_users);
772
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
773
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
774
+			} else {
775 775
 				$model_with_fk_to_wp_users = $this;
776 776
 				$model_chain_to_wp_user = '';
777 777
 			}
778
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
779
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
780
-		}catch( EE_Error $e ) {
778
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
779
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
780
+		} catch (EE_Error $e) {
781 781
 			return false;
782 782
 		}
783 783
 	}
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	 * (or transiently-related model)
792 792
 	 * @return string
793 793
 	 */
794
-	public function model_chain_to_wp_user(){
794
+	public function model_chain_to_wp_user() {
795 795
 		return $this->_model_chain_to_wp_user;
796 796
 	}
797 797
 
@@ -803,13 +803,13 @@  discard block
 block discarded – undo
803 803
 	 * @return boolean
804 804
 	 */
805 805
 	public function is_owned() {
806
-		if( $this->model_chain_to_wp_user() ){
806
+		if ($this->model_chain_to_wp_user()) {
807 807
 			return true;
808
-		}else{
809
-			try{
810
-				$this->get_foreign_key_to( 'WP_User' );
808
+		} else {
809
+			try {
810
+				$this->get_foreign_key_to('WP_User');
811 811
 				return true;
812
-			}catch( EE_Error $e ){
812
+			} catch (EE_Error $e) {
813 813
 				return false;
814 814
 			}
815 815
 		}
@@ -828,21 +828,21 @@  discard block
 block discarded – undo
828 828
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
829 829
 	 * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
830 830
 	 */
831
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
831
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
832 832
 		//remember the custom selections, if any
833
-		if(is_array($columns_to_select)){
833
+		if (is_array($columns_to_select)) {
834 834
 			$this->_custom_selections = $columns_to_select;
835
-		}elseif(is_string($columns_to_select)){
835
+		}elseif (is_string($columns_to_select)) {
836 836
 			$this->_custom_selections = array($this->_custom_selections);
837
-		}else{
837
+		} else {
838 838
 			$this->_custom_selections = array();
839 839
 		}
840 840
 
841 841
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
842 842
 		$select_expressions = $columns_to_select ? $this->_construct_select_from_input($columns_to_select) : $this->_construct_default_select_sql($model_query_info);
843
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
843
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
844 844
 //		echo "sql:$SQL";
845
-		$results =  $this->_do_wpdb_query( 'get_results', array($SQL, $output ) );// $wpdb->get_results($SQL, $output);
845
+		$results = $this->_do_wpdb_query('get_results', array($SQL, $output)); // $wpdb->get_results($SQL, $output);
846 846
 		return $results;
847 847
 	}
848 848
 
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
861 861
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
862 862
 	 */
863
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
863
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
864 864
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
865 865
 	}
866 866
 
@@ -872,12 +872,12 @@  discard block
 block discarded – undo
872 872
 	 * @throws EE_Error
873 873
 	 * @return string
874 874
 	 */
875
-	private function _construct_select_from_input($columns_to_select){
876
-		if(is_array($columns_to_select)){
875
+	private function _construct_select_from_input($columns_to_select) {
876
+		if (is_array($columns_to_select)) {
877 877
 			$select_sql_array = array();
878 878
 
879
-			foreach($columns_to_select as $alias => $selection_and_datatype){
880
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
879
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
880
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
881 881
 					throw new EE_Error(
882 882
 						sprintf(
883 883
 							__(
@@ -889,24 +889,24 @@  discard block
 block discarded – undo
889 889
 						)
890 890
 					);
891 891
 				}
892
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
892
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
893 893
 					throw new EE_Error(
894 894
 						sprintf(
895 895
 							__(
896 896
 								"Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)",
897 897
 								"event_espresso"
898 898
 							),
899
-							$selection_and_datatype[ 1 ],
900
-							$selection_and_datatype[ 0 ],
899
+							$selection_and_datatype[1],
900
+							$selection_and_datatype[0],
901 901
 							$alias,
902
-							implode( ",", $this->_valid_wpdb_data_types )
902
+							implode(",", $this->_valid_wpdb_data_types)
903 903
 						)
904 904
 					);
905 905
 				}
906 906
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
907 907
 			}
908
-			$columns_to_select_string = implode(", ",$select_sql_array);
909
-		}else{
908
+			$columns_to_select_string = implode(", ", $select_sql_array);
909
+		} else {
910 910
 			$columns_to_select_string = $columns_to_select;
911 911
 		}
912 912
 		return $columns_to_select_string;
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 	 * Convenient wrapper for getting the primary key field's name. Eg, on Registration, this would be 'REG_ID'
920 920
 	 * @return string
921 921
 	 */
922
-	function primary_key_name(){
922
+	function primary_key_name() {
923 923
 		return $this->get_primary_key_field()->get_name();
924 924
 	}
925 925
 
@@ -931,14 +931,14 @@  discard block
 block discarded – undo
931 931
 	 * @param mixed $id int or string, depending on the type of the model's primary key
932 932
 	 * @return EE_Base_Class
933 933
 	 */
934
-	function get_one_by_ID($id){
935
-		if( $this->get_from_entity_map( $id ) ){
936
-			return $this->get_from_entity_map( $id );
934
+	function get_one_by_ID($id) {
935
+		if ($this->get_from_entity_map($id)) {
936
+			return $this->get_from_entity_map($id);
937 937
 		}
938 938
 		return $this->get_one( 
939 939
 			$this->alter_query_params_to_restrict_by_ID( 
940 940
 				$id,
941
-				array( 'default_where_conditions' => 'minimum' )
941
+				array('default_where_conditions' => 'minimum')
942 942
 			) 
943 943
 		);
944 944
 	}
@@ -950,15 +950,15 @@  discard block
 block discarded – undo
950 950
 	 * @param array $query_params
951 951
 	 * @return array of normal query params, @see EEM_Base::get_all
952 952
 	 */
953
-	public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) {
954
-		if( ! isset( $query_params[ 0 ] ) ) {
955
-			$query_params[ 0 ] = array();
953
+	public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) {
954
+		if ( ! isset($query_params[0])) {
955
+			$query_params[0] = array();
956 956
 		}
957
-		if( $this->has_primary_key_field ( ) ) {
958
-			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
959
-		}else{
957
+		if ($this->has_primary_key_field( )) {
958
+			$query_params[0][$this->primary_key_name()] = $id;
959
+		} else {
960 960
 			//no primary key, so the $id must be from the get_index_primary_key_string()
961
-			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
961
+			$query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id));
962 962
 		}
963 963
 		return $query_params;
964 964
 	}
@@ -970,16 +970,16 @@  discard block
 block discarded – undo
970 970
 	 * @param array $query_params like EEM_Base's $query_params variable.
971 971
 	 * @return EE_Base_Class | NULL
972 972
 	 */
973
-	function get_one($query_params = array()){
974
-		if( ! is_array( $query_params ) ){
975
-			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
973
+	function get_one($query_params = array()) {
974
+		if ( ! is_array($query_params)) {
975
+			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
976 976
 			$query_params = array();
977 977
 		}
978 978
 		$query_params['limit'] = 1;
979 979
 		$items = $this->get_all($query_params);
980
-		if(empty($items)){
980
+		if (empty($items)) {
981 981
 			return null;
982
-		}else{
982
+		} else {
983 983
 			return array_shift($items);
984 984
 		}
985 985
 	}
@@ -1003,8 +1003,8 @@  discard block
 block discarded – undo
1003 1003
 	 *
1004 1004
 	 * @return EE_Base_Class[]|array
1005 1005
 	 */
1006
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1007
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
1006
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1007
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
1008 1008
 	}
1009 1009
 
1010 1010
 
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 	 *
1028 1028
 	 * @return EE_Base_Class[]|array
1029 1029
 	 */
1030
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1031
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1030
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1031
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1032 1032
 	}
1033 1033
 
1034 1034
 
@@ -1050,9 +1050,9 @@  discard block
 block discarded – undo
1050 1050
 	 *
1051 1051
 	 * @return EE_Base_Class|null|array()
1052 1052
 	 */
1053
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1054
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1055
-		return empty( $results ) ? null : reset( $results );
1053
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1054
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1055
+		return empty($results) ? null : reset($results);
1056 1056
 	}
1057 1057
 
1058 1058
 
@@ -1074,9 +1074,9 @@  discard block
 block discarded – undo
1074 1074
 	 *
1075 1075
 	 * @return EE_Base_Class|null|array()
1076 1076
 	 */
1077
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1078
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1079
-		return empty( $results ) ? null : reset( $results );
1077
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1078
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1079
+		return empty($results) ? null : reset($results);
1080 1080
 	}
1081 1081
 
1082 1082
 
@@ -1102,40 +1102,40 @@  discard block
 block discarded – undo
1102 1102
 	 * @return EE_Base_Class[]|array
1103 1103
 	 * @throws EE_Error
1104 1104
 	 */
1105
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1105
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1106 1106
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1107
-		if ( empty( $field_to_order_by ) ) {
1108
-			if ( $this->has_primary_key_field() ) {
1107
+		if (empty($field_to_order_by)) {
1108
+			if ($this->has_primary_key_field()) {
1109 1109
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1110 1110
 			} else {
1111 1111
 
1112
-				if ( WP_DEBUG ) {
1113
-					throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) );
1112
+				if (WP_DEBUG) {
1113
+					throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso'));
1114 1114
 				}
1115
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1115
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1116 1116
 				return array();
1117 1117
 			}
1118 1118
 		}
1119 1119
 
1120
-		if( ! is_array( $query_params ) ){
1121
-			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1120
+		if ( ! is_array($query_params)) {
1121
+			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1122 1122
 			$query_params = array();
1123 1123
 		}
1124 1124
 
1125 1125
 		//let's add the where query param for consecutive look up.
1126
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1126
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1127 1127
 		$query_params['limit'] = $limit;
1128 1128
 
1129 1129
 		//set direction
1130
-		$incoming_orderby = isset( $query_params['order_by'] ) ? $query_params['order_by'] : array();
1131
-		$query_params['order_by'] = $operand == '>' ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby : array( $field_to_order_by => 'DESC') + $incoming_orderby;
1130
+		$incoming_orderby = isset($query_params['order_by']) ? $query_params['order_by'] : array();
1131
+		$query_params['order_by'] = $operand == '>' ? array($field_to_order_by => 'ASC') + $incoming_orderby : array($field_to_order_by => 'DESC') + $incoming_orderby;
1132 1132
 
1133 1133
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1134
-		if ( empty( $columns_to_select ) ) {
1135
-			return $this->get_all( $query_params );
1134
+		if (empty($columns_to_select)) {
1135
+			return $this->get_all($query_params);
1136 1136
 		} else {
1137 1137
 			//getting just the fields
1138
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1138
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1139 1139
 		}
1140 1140
 	}
1141 1141
 
@@ -1146,18 +1146,18 @@  discard block
 block discarded – undo
1146 1146
 	 * This sets the _timezone property after model object has been instantiated.
1147 1147
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1148 1148
 	 */
1149
-	public function set_timezone( $timezone ) {
1150
-		if ( $timezone !== null ) {
1149
+	public function set_timezone($timezone) {
1150
+		if ($timezone !== null) {
1151 1151
 			$this->_timezone = $timezone;
1152 1152
 		}
1153 1153
 		//note we need to loop through relations and set the timezone on those objects as well.
1154
-		foreach ( $this->_model_relations as $relation ) {
1155
-			$relation->set_timezone( $timezone );
1154
+		foreach ($this->_model_relations as $relation) {
1155
+			$relation->set_timezone($timezone);
1156 1156
 		}
1157 1157
 		//and finally we do the same for any datetime fields
1158
-		foreach ( $this->_fields as $field ) {
1159
-			if ( $field instanceof EE_Datetime_Field ) {
1160
-				$field->set_timezone( $timezone );
1158
+		foreach ($this->_fields as $field) {
1159
+			if ($field instanceof EE_Datetime_Field) {
1160
+				$field->set_timezone($timezone);
1161 1161
 			}
1162 1162
 		}
1163 1163
 	}
@@ -1172,9 +1172,9 @@  discard block
 block discarded – undo
1172 1172
 	 */
1173 1173
 	public function get_timezone() {
1174 1174
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1175
-		if ( empty( $this->_timezone ) ) {
1176
-			foreach( $this->_fields as $field ) {
1177
-				if ( $field instanceof EE_Datetime_Field ) {
1175
+		if (empty($this->_timezone)) {
1176
+			foreach ($this->_fields as $field) {
1177
+				if ($field instanceof EE_Datetime_Field) {
1178 1178
 					$this->set_timezone($field->get_timezone());
1179 1179
 					break;
1180 1180
 				}
@@ -1182,9 +1182,9 @@  discard block
 block discarded – undo
1182 1182
 		}
1183 1183
 
1184 1184
 		//if timezone STILL empty then return the default timezone for the site.
1185
-		if ( empty( $this->_timezone ) ) {
1186
-			EE_Registry::instance()->load_helper( 'DTT_Helper' );
1187
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1185
+		if (empty($this->_timezone)) {
1186
+			EE_Registry::instance()->load_helper('DTT_Helper');
1187
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1188 1188
 		}
1189 1189
 		return $this->_timezone;
1190 1190
 	}
@@ -1202,19 +1202,19 @@  discard block
 block discarded – undo
1202 1202
 	 *
1203 1203
 	 * @return array formats in an array with the date format first, and the time format last.
1204 1204
 	 */
1205
-	public function get_formats_for( $field_name, $pretty = false ) {
1206
-		$field_settings = $this->field_settings_for( $field_name );
1205
+	public function get_formats_for($field_name, $pretty = false) {
1206
+		$field_settings = $this->field_settings_for($field_name);
1207 1207
 
1208 1208
 		//if not a valid EE_Datetime_Field then throw error
1209
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1210
-			throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) );
1209
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1210
+			throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name));
1211 1211
 		}
1212 1212
 
1213 1213
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1214 1214
 		//the field.
1215 1215
 		$this->_timezone = $field_settings->get_timezone();
1216 1216
 
1217
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1217
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1218 1218
 	}
1219 1219
 
1220 1220
 
@@ -1238,25 +1238,25 @@  discard block
 block discarded – undo
1238 1238
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1239 1239
 	 *                    	     exception is triggered.
1240 1240
 	 */
1241
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1242
-		$formats = $this->get_formats_for( $field_name );
1241
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1242
+		$formats = $this->get_formats_for($field_name);
1243 1243
 
1244
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1244
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1245 1245
 
1246
-		if ( $timestamp ) {
1247
-			return $DateTime->format( 'U' );
1246
+		if ($timestamp) {
1247
+			return $DateTime->format('U');
1248 1248
 		}
1249 1249
 
1250 1250
 		//not returning timestamp, so return formatted string in timezone.
1251
-		switch( $what ) {
1251
+		switch ($what) {
1252 1252
 			case 'time' :
1253
-				return $DateTime->format( $formats[1] );
1253
+				return $DateTime->format($formats[1]);
1254 1254
 				break;
1255 1255
 			case 'date' :
1256
-				return $DateTime->format( $formats[0] );
1256
+				return $DateTime->format($formats[0]);
1257 1257
 				break;
1258 1258
 			default :
1259
-				return $DateTime->format( implode( ' ', $formats ) );
1259
+				return $DateTime->format(implode(' ', $formats));
1260 1260
 				break;
1261 1261
 		}
1262 1262
 	}
@@ -1280,18 +1280,18 @@  discard block
 block discarded – undo
1280 1280
 	 *                           		'U', this is ignored.
1281 1281
 	 * @return DateTime
1282 1282
 	 */
1283
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1283
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1284 1284
 
1285 1285
 		//just using this to ensure the timezone is set correctly internally
1286
-		$this->get_formats_for( $field_name );
1286
+		$this->get_formats_for($field_name);
1287 1287
 
1288 1288
 		//load EEH_DTT_Helper
1289
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
1290
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1289
+		EE_Registry::instance()->load_helper('DTT_Helper');
1290
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1291 1291
 
1292
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1292
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1293 1293
 
1294
-		return $incomingDateTime->setTimeZone( new DateTimeZone( $this->_timezone ) );
1294
+		return $incomingDateTime->setTimeZone(new DateTimeZone($this->_timezone));
1295 1295
 	}
1296 1296
 
1297 1297
 
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1302 1302
 	 * @return EE_Table_Base[]
1303 1303
 	 */
1304
-	function get_tables(){
1304
+	function get_tables() {
1305 1305
 		return $this->_tables;
1306 1306
 	}
1307 1307
 
@@ -1335,9 +1335,9 @@  discard block
 block discarded – undo
1335 1335
 	 * be aware that model objects being used could get out-of-sync with the database
1336 1336
 	 * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad)
1337 1337
 	 */
1338
-	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1339
-		if( ! is_array( $query_params ) ){
1340
-			EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1338
+	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1339
+		if ( ! is_array($query_params)) {
1340
+			EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1341 1341
 			$query_params = array();
1342 1342
 		}
1343 1343
 		/**
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
 		 * @param array $fields_n_values the updated fields and their new values
1348 1348
 		 * @param array $query_params @see EEM_Base::get_all()
1349 1349
 		 */
1350
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1350
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1351 1351
 		/**
1352 1352
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1353 1353
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1355,10 +1355,10 @@  discard block
 block discarded – undo
1355 1355
 		 * @param EEM_Base $model the model being queried
1356 1356
 		 * @param array $query_params see EEM_Base::get_all()
1357 1357
 		 */
1358
-		$fields_n_values = apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1358
+		$fields_n_values = apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1359 1359
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1360 1360
 		//to do that, for each table, verify that it's PK isn't null.
1361
-		$tables= $this->get_tables();
1361
+		$tables = $this->get_tables();
1362 1362
 
1363 1363
 		//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1364 1364
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1368,29 +1368,29 @@  discard block
 block discarded – undo
1368 1368
 			//we want to make sure the default_where strategy is ignored
1369 1369
 			$this->_ignore_where_strategy = TRUE;
1370 1370
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1371
-			foreach( $wpdb_select_results as $wpdb_result ){
1371
+			foreach ($wpdb_select_results as $wpdb_result) {
1372 1372
 				// type cast stdClass as array
1373
-				$wpdb_result = (array)$wpdb_result;
1373
+				$wpdb_result = (array) $wpdb_result;
1374 1374
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1375
-				if( $this->has_primary_key_field() ){
1376
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1377
-				}else{
1375
+				if ($this->has_primary_key_field()) {
1376
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1377
+				} else {
1378 1378
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1379 1379
 					$main_table_pk_value = null;
1380 1380
 				}
1381 1381
 				//if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables
1382 1382
 				//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1383
-				if(count($tables) > 1){
1383
+				if (count($tables) > 1) {
1384 1384
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1385 1385
 					//in that table, and so we'll want to insert one
1386
-					foreach($tables as $table_obj){
1386
+					foreach ($tables as $table_obj) {
1387 1387
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1388 1388
 						//if there is no private key for this table on the results, it means there's no entry
1389 1389
 						//in this table, right? so insert a row in the current table, using any fields available
1390
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1390
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1391 1391
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1392 1392
 							//if we died here, report the error
1393
-							if( ! $success ) {
1393
+							if ( ! $success) {
1394 1394
 								return false;
1395 1395
 							}
1396 1396
 						}
@@ -1410,44 +1410,44 @@  discard block
 block discarded – undo
1410 1410
 		//if this wasn't called from a model object (to update itself)
1411 1411
 		//then we want to make sure we keep all the existing
1412 1412
 		//model objects in sync with the db
1413
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1414
-			if( $this->has_primary_key_field() ){
1415
-				$model_objs_affected_ids = $this->get_col( $query_params );
1416
-			}else{
1413
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1414
+			if ($this->has_primary_key_field()) {
1415
+				$model_objs_affected_ids = $this->get_col($query_params);
1416
+			} else {
1417 1417
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1418
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1418
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1419 1419
 				$model_objs_affected_ids = array();
1420
-				foreach( $models_affected_key_columns as $row ){
1421
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1422
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1420
+				foreach ($models_affected_key_columns as $row) {
1421
+					$combined_index_key = $this->get_index_primary_key_string($row);
1422
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1423 1423
 				}
1424 1424
 
1425 1425
 			}
1426 1426
 
1427
-			if( ! $model_objs_affected_ids ){
1427
+			if ( ! $model_objs_affected_ids) {
1428 1428
 				//wait wait wait- if nothing was affected let's stop here
1429 1429
 				return 0;
1430 1430
 			}
1431
-			foreach( $model_objs_affected_ids as $id ){
1432
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1433
-				if( $model_obj_in_entity_map ){
1434
-					foreach( $fields_n_values as $field => $new_value ){
1435
-						$model_obj_in_entity_map->set( $field, $new_value );
1431
+			foreach ($model_objs_affected_ids as $id) {
1432
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1433
+				if ($model_obj_in_entity_map) {
1434
+					foreach ($fields_n_values as $field => $new_value) {
1435
+						$model_obj_in_entity_map->set($field, $new_value);
1436 1436
 					}
1437 1437
 				}
1438 1438
 			}
1439 1439
 			//if there is a primary key on this model, we can now do a slight optimization
1440
-			if( $this->has_primary_key_field() ){
1440
+			if ($this->has_primary_key_field()) {
1441 1441
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1442 1442
 				$query_params = array(
1443
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1444
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1443
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1444
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1445 1445
 			}
1446 1446
 		}
1447 1447
 
1448
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1449
-		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1450
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1448
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1449
+		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1450
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1451 1451
 		/**
1452 1452
 		 * Action called after a model update call has been made.
1453 1453
 		 *
@@ -1456,8 +1456,8 @@  discard block
 block discarded – undo
1456 1456
 		 * @param array $query_params @see EEM_Base::get_all()
1457 1457
 		 * @param int $rows_affected
1458 1458
 		 */
1459
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1460
-		return $rows_affected;//how many supposedly got updated
1459
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1460
+		return $rows_affected; //how many supposedly got updated
1461 1461
 	}
1462 1462
 
1463 1463
 	/**
@@ -1469,22 +1469,22 @@  discard block
 block discarded – undo
1469 1469
 	 * @param string $field_to_select
1470 1470
 	 * @return array just like $wpdb->get_col()
1471 1471
 	 */
1472
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1472
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1473 1473
 
1474
-		if( $field_to_select ){
1475
-			$field = $this->field_settings_for( $field_to_select );
1476
-		}elseif( $this->has_primary_key_field ( ) ){
1474
+		if ($field_to_select) {
1475
+			$field = $this->field_settings_for($field_to_select);
1476
+		}elseif ($this->has_primary_key_field( )) {
1477 1477
 			$field = $this->get_primary_key_field();
1478
-		}else{
1478
+		} else {
1479 1479
 			//no primary key, just grab the first column
1480
-			$field = reset( $this->field_settings());
1480
+			$field = reset($this->field_settings());
1481 1481
 		}
1482 1482
 
1483 1483
 
1484 1484
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1485 1485
 		$select_expressions = $field->get_qualified_column();
1486
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1487
-		$results =  $this->_do_wpdb_query('get_col', array( $SQL ) );
1486
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1487
+		$results = $this->_do_wpdb_query('get_col', array($SQL));
1488 1488
 		return $results;
1489 1489
 	}
1490 1490
 
@@ -1494,12 +1494,12 @@  discard block
 block discarded – undo
1494 1494
 	 * @param string $field_to_select @see EEM_Base::get_col()
1495 1495
 	 * @return string
1496 1496
 	 */
1497
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1498
-		$query_params[ 'limit' ] = 1;
1499
-		$col = $this->get_col( $query_params, $field_to_select );
1500
-		if( ! empty( $col ) ) {
1501
-			return reset( $col );
1502
-		}else{
1497
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1498
+		$query_params['limit'] = 1;
1499
+		$col = $this->get_col($query_params, $field_to_select);
1500
+		if ( ! empty($col)) {
1501
+			return reset($col);
1502
+		} else {
1503 1503
 			return NULL;
1504 1504
 		}
1505 1505
 	}
@@ -1513,19 +1513,19 @@  discard block
 block discarded – undo
1513 1513
 	 * @param array $fields_n_values array keys are field names on this model, and values are what those fields should be updated to in the DB
1514 1514
 	 * @return string of SQL
1515 1515
 	 */
1516
-	function _construct_update_sql($fields_n_values){
1516
+	function _construct_update_sql($fields_n_values) {
1517 1517
 		/** @type WPDB $wpdb */
1518 1518
 		global $wpdb;
1519 1519
 		$cols_n_values = array();
1520
-		foreach($fields_n_values as $field_name => $value){
1520
+		foreach ($fields_n_values as $field_name => $value) {
1521 1521
 			$field_obj = $this->field_settings_for($field_name);
1522 1522
 			//if the value is NULL, we want to assign the value to that.
1523 1523
 			//wpdb->prepare doesn't really handle that properly
1524
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1525
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1524
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1525
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1526 1526
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1527 1527
 		}
1528
-		return implode(",",$cols_n_values);
1528
+		return implode(",", $cols_n_values);
1529 1529
 
1530 1530
 	}
1531 1531
 	
@@ -1537,10 +1537,10 @@  discard block
 block discarded – undo
1537 1537
 	 * @param mixed $id
1538 1538
 	 * @return boolean whether the row got deleted or not
1539 1539
 	 */
1540
-	public function delete_permanently_by_ID( $id ) {
1540
+	public function delete_permanently_by_ID($id) {
1541 1541
 		return $this->delete_permanently( 
1542 1542
 			array(
1543
-				array( $this->get_primary_key_field()->get_name() => $id ),
1543
+				array($this->get_primary_key_field()->get_name() => $id),
1544 1544
 				'limit' 	=> 1
1545 1545
 			) 
1546 1546
 		);
@@ -1554,10 +1554,10 @@  discard block
 block discarded – undo
1554 1554
 	 * @param mixed $id
1555 1555
 	 * @return boolean whether the row got deleted or not
1556 1556
 	 */
1557
-	public function delete_by_ID( $id ){
1557
+	public function delete_by_ID($id) {
1558 1558
 		return $this->delete( 
1559 1559
 			array(
1560
-				array( $this->get_primary_key_field()->get_name() => $id ),
1560
+				array($this->get_primary_key_field()->get_name() => $id),
1561 1561
 				'limit' 	=> 1
1562 1562
 			) 
1563 1563
 		);
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
 	 * @param boolean $allow_blocking
1572 1572
 	 * @return @see EEM_Base::delete_permanently
1573 1573
 	 */
1574
-	function delete($query_params,$allow_blocking = true){
1574
+	function delete($query_params, $allow_blocking = true) {
1575 1575
 		return $this->delete_permanently($query_params, $allow_blocking);
1576 1576
 	}
1577 1577
 
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1588 1588
 	 * @return int how many rows got deleted
1589 1589
 	 */
1590
-	function delete_permanently($query_params,$allow_blocking = true){
1590
+	function delete_permanently($query_params, $allow_blocking = true) {
1591 1591
 		/**
1592 1592
 		 * Action called just before performing a real deletion query. You can use the
1593 1593
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1596,34 +1596,34 @@  discard block
 block discarded – undo
1596 1596
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1597 1597
 		 * to block (prevent) this deletion
1598 1598
 		 */
1599
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1599
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1600 1600
 		//some MySQL databases may be running safe mode, which may restrict
1601 1601
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1602 1602
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1603 1603
 		//to delete them
1604 1604
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1605
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1606
-		if($deletion_where){
1605
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1606
+		if ($deletion_where) {
1607 1607
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1608 1608
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1609 1609
 			$table_aliases = array();
1610
-			foreach(array_keys($this->_tables) as $table_alias){
1610
+			foreach (array_keys($this->_tables) as $table_alias) {
1611 1611
 				$table_aliases[] = $table_alias;
1612 1612
 			}
1613
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1613
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1614 1614
 
1615 1615
 			//		/echo "delete sql:$SQL";
1616
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1617
-		}else{
1616
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1617
+		} else {
1618 1618
 			$rows_deleted = 0;
1619 1619
 		}
1620 1620
 
1621 1621
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1622
-		if( $this->has_primary_key_field() ){
1623
-			foreach($items_for_deletion as $item_for_deletion_row ){
1624
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1625
-				if( isset( $this->_entity_map[ $pk_value ] ) ){
1626
-					unset( $this->_entity_map[ $pk_value ] );
1622
+		if ($this->has_primary_key_field()) {
1623
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1624
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1625
+				if (isset($this->_entity_map[$pk_value])) {
1626
+					unset($this->_entity_map[$pk_value]);
1627 1627
 				}
1628 1628
 			}
1629 1629
 		}
@@ -1635,8 +1635,8 @@  discard block
 block discarded – undo
1635 1635
 		 * @param array $query_params @see EEM_Base::get_all()
1636 1636
 		 * @param int $rows_deleted
1637 1637
 		 */
1638
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1639
-		return $rows_deleted;//how many supposedly got deleted
1638
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1639
+		return $rows_deleted; //how many supposedly got deleted
1640 1640
 	}
1641 1641
 
1642 1642
 
@@ -1652,28 +1652,28 @@  discard block
 block discarded – undo
1652 1652
 	 * blocking its deletion before removing the relation between A and B
1653 1653
 	 * @return boolean
1654 1654
 	 */
1655
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1655
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1656 1656
 		//first, if $ignore_this_model_obj was supplied, get its model
1657
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1657
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1658 1658
 			$ignored_model = $ignore_this_model_obj->get_model();
1659
-		}else{
1659
+		} else {
1660 1660
 			$ignored_model = null;
1661 1661
 		}
1662 1662
 		//now check all the relations of $this_model_obj_or_id and see if there
1663 1663
 		//are any related model objects blocking it?
1664 1664
 		$is_blocked = false;
1665
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1666
-			if( $relation_obj->block_delete_if_related_models_exist()){
1665
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1666
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1667 1667
 				//if $ignore_this_model_obj was supplied, then for the query
1668 1668
 				//on that model needs to be told to ignore $ignore_this_model_obj
1669
-				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1670
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1671
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1672
-				}else{
1669
+				if ($ignored_model && $relation_name == $ignored_model->get_this_model_name()) {
1670
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1671
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1672
+				} else {
1673 1673
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1674 1674
 				}
1675 1675
 
1676
-				if($related_model_objects){
1676
+				if ($related_model_objects) {
1677 1677
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1678 1678
 					$is_blocked = true;
1679 1679
 				}
@@ -1693,65 +1693,65 @@  discard block
 block discarded – undo
1693 1693
 	 * @throws EE_Error
1694 1694
 	 * @return string    everything that comes after the WHERE statement.
1695 1695
 	 */
1696
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1697
-		if($this->has_primary_key_field()){
1696
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1697
+		if ($this->has_primary_key_field()) {
1698 1698
 			$primary_table = $this->_get_main_table();
1699 1699
 			$other_tables = $this->_get_other_tables();
1700 1700
 			$deletes = $query = array();
1701
-			foreach ( $objects_for_deletion as $delete_object ) {
1701
+			foreach ($objects_for_deletion as $delete_object) {
1702 1702
 				//before we mark this object for deletion,
1703 1703
 				//make sure there's no related objects blocking its deletion (if we're checking)
1704
-				if( $allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()]) ){
1704
+				if ($allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1705 1705
 					continue;
1706 1706
 				}
1707 1707
 
1708 1708
 				//primary table deletes
1709
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1709
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()]))
1710 1710
 					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1711 1711
 
1712 1712
 				//other tables
1713
-				if ( !empty( $other_tables ) ) {
1714
-					foreach ( $other_tables as $ot ) {
1713
+				if ( ! empty($other_tables)) {
1714
+					foreach ($other_tables as $ot) {
1715 1715
 
1716 1716
 						//first check if we've got the foreign key column here.
1717
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1717
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()]))
1718 1718
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1719 1719
 
1720 1720
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1721
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1721
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()]))
1722 1722
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1723 1723
 
1724 1724
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1725
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1725
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()]))
1726 1726
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1727 1727
 					}
1728 1728
 				}
1729 1729
 			}
1730 1730
 
1731 1731
 			//we should have deletes now, so let's just go through and setup the where statement
1732
-			foreach ( $deletes as $column => $values ) {
1732
+			foreach ($deletes as $column => $values) {
1733 1733
 				//make sure we have unique $values;
1734 1734
 				$values = array_unique($values);
1735
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1735
+				$query[] = $column.' IN('.implode(",", $values).')';
1736 1736
 			}
1737 1737
 
1738
-			return !empty($query) ? implode(' AND ', $query ) : '';
1739
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1738
+			return ! empty($query) ? implode(' AND ', $query) : '';
1739
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1740 1740
 			$ways_to_identify_a_row = array();
1741 1741
 			$fields = $this->get_combined_primary_key_fields();
1742 1742
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1743
-			foreach($objects_for_deletion as  $delete_object){
1743
+			foreach ($objects_for_deletion as  $delete_object) {
1744 1744
 				$values_for_each_cpk_for_a_row = array();
1745
-				foreach($fields as $cpk_field){
1745
+				foreach ($fields as $cpk_field) {
1746 1746
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1747 1747
 				}
1748
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1748
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1749 1749
 			}
1750
-			return implode(" OR ",$ways_to_identify_a_row);
1751
-		}else{
1750
+			return implode(" OR ", $ways_to_identify_a_row);
1751
+		} else {
1752 1752
 			//so there's no primary key and no combined key...
1753 1753
 			//sorry, can't help you
1754
-			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
1754
+			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this)));
1755 1755
 		}
1756 1756
 	}
1757 1757
 
@@ -1765,21 +1765,21 @@  discard block
 block discarded – undo
1765 1765
 	 * @param bool 	 $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
1766 1766
 	 * @return int
1767 1767
 	 */
1768
-	function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1768
+	function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1769 1769
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1770
-		if($field_to_count){
1770
+		if ($field_to_count) {
1771 1771
 			$field_obj = $this->field_settings_for($field_to_count);
1772 1772
 			$column_to_count = $field_obj->get_qualified_column();
1773
-		}elseif($this->has_primary_key_field ()){
1773
+		}elseif ($this->has_primary_key_field()) {
1774 1774
 			$pk_field_obj = $this->get_primary_key_field();
1775 1775
 			$column_to_count = $pk_field_obj->get_qualified_column();
1776
-		}else{//there's no primary key
1776
+		} else {//there's no primary key
1777 1777
 			$column_to_count = '*';
1778 1778
 		}
1779 1779
 
1780
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1781
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1782
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1780
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1781
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1782
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1783 1783
 	}
1784 1784
 
1785 1785
 	/**
@@ -1789,23 +1789,23 @@  discard block
 block discarded – undo
1789 1789
 	 * @param string $field_to_sum name of field (array key in $_fields array)
1790 1790
 	 * @return float
1791 1791
 	 */
1792
-	function sum($query_params, $field_to_sum = NULL){
1792
+	function sum($query_params, $field_to_sum = NULL) {
1793 1793
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1794 1794
 
1795
-		if($field_to_sum){
1795
+		if ($field_to_sum) {
1796 1796
 			$field_obj = $this->field_settings_for($field_to_sum);
1797 1797
 
1798
-		}else{
1798
+		} else {
1799 1799
 			$field_obj = $this->get_primary_key_field();
1800 1800
 		}
1801 1801
 		$column_to_count = $field_obj->get_qualified_column();
1802 1802
 
1803
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1804
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1805
-		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1806
-			return (float)$return_value;
1807
-		}else{//must be %f
1808
-			return (float)$return_value;
1803
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1804
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1805
+		if ($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s') {
1806
+			return (float) $return_value;
1807
+		} else {//must be %f
1808
+			return (float) $return_value;
1809 1809
 		}
1810 1810
 	}
1811 1811
 
@@ -1820,33 +1820,33 @@  discard block
 block discarded – undo
1820 1820
 	 * @global wpdb $wpdb
1821 1821
 	 * @return mixed
1822 1822
 	 */
1823
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1823
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1824 1824
 		//if we're in maintenance mode level 2, DON'T run any queries
1825 1825
 		//because level 2 indicates the database needs updating and
1826 1826
 		//is probably out of sync with the code
1827
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1827
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1828 1828
 			throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso")));
1829 1829
 		}
1830 1830
 		/** @type WPDB $wpdb */
1831 1831
 		global $wpdb;
1832
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1833
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1832
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1833
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1834 1834
 		}
1835
-		if( WP_DEBUG ){
1835
+		if (WP_DEBUG) {
1836 1836
 			$old_show_errors_value = $wpdb->show_errors;
1837
-			$wpdb->show_errors( FALSE );
1838
-		}
1839
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1840
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1841
-		if( WP_DEBUG ){
1842
-			$wpdb->show_errors( $old_show_errors_value );
1843
-			if( ! empty( $wpdb->last_error ) ){
1844
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1845
-			}elseif( $result === false ){
1846
-				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1837
+			$wpdb->show_errors(FALSE);
1838
+		}
1839
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1840
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1841
+		if (WP_DEBUG) {
1842
+			$wpdb->show_errors($old_show_errors_value);
1843
+			if ( ! empty($wpdb->last_error)) {
1844
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1845
+			}elseif ($result === false) {
1846
+				throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true)));
1847 1847
 			}
1848
-		}elseif( $result === false ) {
1849
-			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1848
+		}elseif ($result === false) {
1849
+			EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
1850 1850
 		}
1851 1851
 		return $result;
1852 1852
 	}
@@ -1862,23 +1862,23 @@  discard block
 block discarded – undo
1862 1862
 	 * @param array $arguments_to_provide
1863 1863
 	 * @return mixed
1864 1864
 	 */
1865
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1865
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1866 1866
 		/** @type WPDB $wpdb */
1867 1867
 		global $wpdb;
1868 1868
 		$wpdb->last_error = null;
1869
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1869
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1870 1870
 		// was there an error running the query?
1871
-		if ( ( $result === false || ! empty( $wpdb->last_error ) ) ) {
1872
-			switch ( EEM_Base::$_db_verification_level ) {
1871
+		if (($result === false || ! empty($wpdb->last_error))) {
1872
+			switch (EEM_Base::$_db_verification_level) {
1873 1873
 
1874 1874
 				case EEM_Base::db_verified_none :
1875 1875
 					// let's double-check core's DB
1876
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1876
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1877 1877
 					break;
1878 1878
 
1879 1879
 				case EEM_Base::db_verified_core :
1880 1880
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1881
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1881
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1882 1882
 					break;
1883 1883
 
1884 1884
 				case EEM_Base::db_verified_addons :
@@ -1886,11 +1886,11 @@  discard block
 block discarded – undo
1886 1886
 					return $result;
1887 1887
 					break;
1888 1888
 			}
1889
-			if ( ! empty( $error_message ) ) {
1890
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1891
-				trigger_error( $error_message );
1889
+			if ( ! empty($error_message)) {
1890
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1891
+				trigger_error($error_message);
1892 1892
 			}
1893
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1893
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1894 1894
 
1895 1895
 		}
1896 1896
 
@@ -1906,18 +1906,18 @@  discard block
 block discarded – undo
1906 1906
 	 * @param array $arguments_to_provide
1907 1907
 	 * @return string
1908 1908
 	 */
1909
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1909
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1910 1910
 		/** @type WPDB $wpdb */
1911 1911
 		global $wpdb;
1912 1912
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
1913 1913
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
1914 1914
 		$error_message = sprintf(
1915
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
1915
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
1916 1916
 			$wpdb->last_error,
1917 1917
 			$wpdb_method,
1918
-			json_encode( $arguments_to_provide )
1918
+			json_encode($arguments_to_provide)
1919 1919
 		);
1920
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
1920
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
1921 1921
 		return $error_message;
1922 1922
 	}
1923 1923
 
@@ -1930,16 +1930,16 @@  discard block
 block discarded – undo
1930 1930
 	 * @param $arguments_to_provide
1931 1931
 	 * @return string
1932 1932
 	 */
1933
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
1933
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
1934 1934
 		/** @type WPDB $wpdb */
1935 1935
 		global $wpdb;
1936 1936
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
1937 1937
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
1938 1938
 		$error_message = sprintf(
1939
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
1939
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
1940 1940
 			$wpdb->last_error,
1941 1941
 			$wpdb_method,
1942
-			json_encode( $arguments_to_provide )
1942
+			json_encode($arguments_to_provide)
1943 1943
 		);
1944 1944
 		EE_System::instance()->initialize_addons();
1945 1945
 		return $error_message;
@@ -1954,7 +1954,7 @@  discard block
 block discarded – undo
1954 1954
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
1955 1955
 	 * @return string
1956 1956
 	 */
1957
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
1957
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
1958 1958
 		return " FROM ".$model_query_info->get_full_join_sql().
1959 1959
 				$model_query_info->get_where_sql().
1960 1960
 				$model_query_info->get_group_by_sql().
@@ -1967,7 +1967,7 @@  discard block
 block discarded – undo
1967 1967
 	 * Set to easily debug the next X queries ran from this model.
1968 1968
 	 * @param int $count
1969 1969
 	 */
1970
-	function show_next_x_db_queries($count = 1){
1970
+	function show_next_x_db_queries($count = 1) {
1971 1971
 		$this->_show_next_x_db_queries = $count;
1972 1972
 	}
1973 1973
 
@@ -1976,8 +1976,8 @@  discard block
 block discarded – undo
1976 1976
 	/**
1977 1977
 	 * @param $sql_query
1978 1978
 	 */
1979
-	function show_db_query_if_previously_requested($sql_query){
1980
-		if($this->_show_next_x_db_queries > 0){
1979
+	function show_db_query_if_previously_requested($sql_query) {
1980
+		if ($this->_show_next_x_db_queries > 0) {
1981 1981
 			echo $sql_query;
1982 1982
 			$this->_show_next_x_db_queries--;
1983 1983
 		}
@@ -2001,9 +2001,9 @@  discard block
 block discarded – undo
2001 2001
 	 * @param array   $extra_join_model_fields_n_values This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2002 2002
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
2003 2003
 	 */
2004
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
2004
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
2005 2005
 		$relation_obj = $this->related_settings_for($relationName);
2006
-		return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2006
+		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2007 2007
 	}
2008 2008
 
2009 2009
 	/**
@@ -2022,9 +2022,9 @@  discard block
 block discarded – undo
2022 2022
 	 * @return boolean of success
2023 2023
 	 * @param array   $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2024 2024
 	 */
2025
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2025
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
2026 2026
 		$relation_obj = $this->related_settings_for($relationName);
2027
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
2027
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
2028 2028
 	}
2029 2029
 
2030 2030
 
@@ -2037,9 +2037,9 @@  discard block
 block discarded – undo
2037 2037
 	 * @param EE_Base_Class[] objects to which relations were removed
2038 2038
 	 * @return \EE_Base_Class[]
2039 2039
 	 */
2040
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
2040
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2041 2041
 		$relation_obj = $this->related_settings_for($relationName);
2042
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2042
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2043 2043
 	}
2044 2044
 
2045 2045
 
@@ -2052,10 +2052,10 @@  discard block
 block discarded – undo
2052 2052
 	 * @param array $query_params like EEM_Base::get_all
2053 2053
 	 * @return EE_Base_Class[]
2054 2054
 	 */
2055
-	function get_all_related($id_or_obj, $model_name, $query_params = null){
2055
+	function get_all_related($id_or_obj, $model_name, $query_params = null) {
2056 2056
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2057 2057
 		$relation_settings = $this->related_settings_for($model_name);
2058
-		return $relation_settings->get_all_related($model_obj,$query_params);
2058
+		return $relation_settings->get_all_related($model_obj, $query_params);
2059 2059
 	}
2060 2060
 
2061 2061
 	/**
@@ -2068,10 +2068,10 @@  discard block
 block discarded – undo
2068 2068
 	 * @param array $query_params
2069 2069
 	 * @return int how many deleted
2070 2070
 	 */
2071
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2071
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2072 2072
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2073 2073
 		$relation_settings = $this->related_settings_for($model_name);
2074
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2074
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2075 2075
 	}
2076 2076
 
2077 2077
 	/**
@@ -2084,10 +2084,10 @@  discard block
 block discarded – undo
2084 2084
 	 * @param array $query_params
2085 2085
 	 * @return int how many deleted
2086 2086
 	 */
2087
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2087
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2088 2088
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2089 2089
 		$relation_settings = $this->related_settings_for($model_name);
2090
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2090
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2091 2091
 	}
2092 2092
 
2093 2093
 	/**
@@ -2100,17 +2100,17 @@  discard block
 block discarded – undo
2100 2100
 	 * @param bool 	 $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
2101 2101
 	 * @return int
2102 2102
 	 */
2103
-	function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2103
+	function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2104 2104
 		$related_model = $this->get_related_model_obj($model_name);
2105 2105
 		//we're just going to use the query params on the related model's normal get_all query,
2106 2106
 		//except add a condition to say to match the current mod
2107
-		if( ! isset($query_params['default_where_conditions'])){
2108
-			$query_params['default_where_conditions']='none';
2107
+		if ( ! isset($query_params['default_where_conditions'])) {
2108
+			$query_params['default_where_conditions'] = 'none';
2109 2109
 		}
2110 2110
 		$this_model_name = $this->get_this_model_name();
2111 2111
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2112
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2113
-		return $related_model->count($query_params,$field_to_count,$distinct);
2112
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2113
+		return $related_model->count($query_params, $field_to_count, $distinct);
2114 2114
 	}
2115 2115
 
2116 2116
 
@@ -2124,21 +2124,21 @@  discard block
 block discarded – undo
2124 2124
 	 * @param string $field_to_sum name of field to count by. By default, uses primary key
2125 2125
 	 * @return float
2126 2126
 	 */
2127
-	function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2127
+	function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2128 2128
 		$related_model = $this->get_related_model_obj($model_name);
2129
-		if( ! is_array( $query_params ) ){
2130
-			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2129
+		if ( ! is_array($query_params)) {
2130
+			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2131 2131
 			$query_params = array();
2132 2132
 		}
2133 2133
 		//we're just going to use the query params on the related model's normal get_all query,
2134 2134
 		//except add a condition to say to match the current mod
2135
-		if( ! isset($query_params['default_where_conditions'])){
2136
-			$query_params['default_where_conditions']='none';
2135
+		if ( ! isset($query_params['default_where_conditions'])) {
2136
+			$query_params['default_where_conditions'] = 'none';
2137 2137
 		}
2138 2138
 		$this_model_name = $this->get_this_model_name();
2139 2139
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2140
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2141
-		return $related_model->sum($query_params,$field_to_sum);
2140
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2141
+		return $related_model->sum($query_params, $field_to_sum);
2142 2142
 	}
2143 2143
 
2144 2144
 
@@ -2150,12 +2150,12 @@  discard block
 block discarded – undo
2150 2150
 	 * @param array $query_params like EEM_Base::get_all's
2151 2151
 	 * @return EE_Base_Class
2152 2152
 	 */
2153
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2154
-		$query_params['limit']=1;
2155
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2156
-		if( $results ){
2153
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2154
+		$query_params['limit'] = 1;
2155
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2156
+		if ($results) {
2157 2157
 			return array_shift($results);
2158
-		}else{
2158
+		} else {
2159 2159
 			return null;
2160 2160
 		}
2161 2161
 
@@ -2165,8 +2165,8 @@  discard block
 block discarded – undo
2165 2165
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2166 2166
 	 * @return string
2167 2167
 	 */
2168
-	function get_this_model_name(){
2169
-		return str_replace("EEM_","",get_class($this));
2168
+	function get_this_model_name() {
2169
+		return str_replace("EEM_", "", get_class($this));
2170 2170
 	}
2171 2171
 
2172 2172
 	/**
@@ -2174,14 +2174,14 @@  discard block
 block discarded – undo
2174 2174
 	 * @return EE_Any_Foreign_Model_Name_Field
2175 2175
 	 * @throws EE_Error
2176 2176
 	 */
2177
-	public function get_field_containing_related_model_name(){
2178
-		foreach($this->field_settings(true) as $field){
2179
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2177
+	public function get_field_containing_related_model_name() {
2178
+		foreach ($this->field_settings(true) as $field) {
2179
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2180 2180
 				$field_with_model_name = $field;
2181 2181
 			}
2182 2182
 		}
2183
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2184
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2183
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2184
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2185 2185
 		}
2186 2186
 		return $field_with_model_name;
2187 2187
 	}
@@ -2202,19 +2202,19 @@  discard block
 block discarded – undo
2202 2202
 	 * @return int new primary key on main table that got inserted
2203 2203
 	 * @throws EE_Error
2204 2204
 	 */
2205
-	function insert($field_n_values){
2205
+	function insert($field_n_values) {
2206 2206
 		/**
2207 2207
 		 * Filters the fields and their values before inserting an item using the models
2208 2208
 		 * @param array $fields_n_values keys are the fields and values are their new values
2209 2209
 		 * @param EEM_Base $model the model used
2210 2210
 		 */
2211
-		$field_n_values = apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2212
-		if($this->_satisfies_unique_indexes($field_n_values)){
2211
+		$field_n_values = apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2212
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2213 2213
 			$main_table = $this->_get_main_table();
2214 2214
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2215
-			if( $new_id !== false ) {
2216
-				foreach($this->_get_other_tables() as $other_table){
2217
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2215
+			if ($new_id !== false) {
2216
+				foreach ($this->_get_other_tables() as $other_table) {
2217
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2218 2218
 				}
2219 2219
 			}
2220 2220
 			/**
@@ -2224,9 +2224,9 @@  discard block
 block discarded – undo
2224 2224
 			 * @param array $fields_n_values fields and their values
2225 2225
 			 * @param int|string the ID of the newly-inserted model object
2226 2226
 			 */
2227
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2227
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2228 2228
 			return $new_id;
2229
-		}else{
2229
+		} else {
2230 2230
 			return FALSE;
2231 2231
 		}
2232 2232
 	}
@@ -2239,11 +2239,11 @@  discard block
 block discarded – undo
2239 2239
 	 * @param string $action
2240 2240
 	 * @return boolean
2241 2241
 	 */
2242
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2243
-		foreach($this->unique_indexes() as $index_name => $index){
2242
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2243
+		foreach ($this->unique_indexes() as $index_name => $index) {
2244 2244
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2245
-			if($this->exists(array($uniqueness_where_params))){
2246
-				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"),$action,$this->_get_class_name(),$index_name,implode(",",$index->field_names()),http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__ );
2245
+			if ($this->exists(array($uniqueness_where_params))) {
2246
+				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"), $action, $this->_get_class_name(), $index_name, implode(",", $index->field_names()), http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__);
2247 2247
 				return false;
2248 2248
 			}
2249 2249
 		}
@@ -2264,28 +2264,28 @@  discard block
 block discarded – undo
2264 2264
 	 * @throws EE_Error
2265 2265
 	 * @return EE_Base_Class
2266 2266
 	 */
2267
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2268
-		if($obj_or_fields_array instanceof EE_Base_Class){
2267
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2268
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2269 2269
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2270
-		}elseif( is_array($obj_or_fields_array)){
2270
+		}elseif (is_array($obj_or_fields_array)) {
2271 2271
 			$fields_n_values = $obj_or_fields_array;
2272
-		}else{
2273
-			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
2272
+		} else {
2273
+			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"), get_class($this), $obj_or_fields_array));
2274 2274
 		}
2275 2275
 		$query_params = array();
2276
-		if( $this->has_primary_key_field() &&
2277
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2278
-				isset($fields_n_values[$this->primary_key_name()])){
2276
+		if ($this->has_primary_key_field() &&
2277
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2278
+				isset($fields_n_values[$this->primary_key_name()])) {
2279 2279
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2280 2280
 		}
2281
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2281
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2282 2282
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2283 2283
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2284 2284
 		}
2285 2285
 		//if there is nothing to base this search on, then we shouldn't find anything
2286
-		if( empty( $query_params ) ){
2286
+		if (empty($query_params)) {
2287 2287
 			return array();
2288
-		}else{
2288
+		} else {
2289 2289
 			return $this->get_one($query_params);
2290 2290
 		}
2291 2291
 	}
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
 	 * @param array $query_params
2296 2296
 	 * @return boolean
2297 2297
 	 */
2298
-	function exists($query_params){
2298
+	function exists($query_params) {
2299 2299
 		$query_params['limit'] = 1;
2300 2300
 		return $this->count($query_params) > 0;
2301 2301
 	}
@@ -2305,7 +2305,7 @@  discard block
 block discarded – undo
2305 2305
 	 * @param int|string $id
2306 2306
 	 * @return boolean
2307 2307
 	 */
2308
-	function exists_by_ID($id){
2308
+	function exists_by_ID($id) {
2309 2309
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2310 2310
 	}
2311 2311
 
@@ -2325,45 +2325,45 @@  discard block
 block discarded – undo
2325 2325
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2326 2326
 	 * @return int ID of new row inserted, or FALSE on failure
2327 2327
 	 */
2328
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2328
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2329 2329
 		global $wpdb;
2330 2330
 		$insertion_col_n_values = array();
2331 2331
 		$format_for_insertion = array();
2332 2332
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2333
-		foreach($fields_on_table as $field_name => $field_obj){
2333
+		foreach ($fields_on_table as $field_name => $field_obj) {
2334 2334
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2335
-			if($field_obj->is_auto_increment()){
2335
+			if ($field_obj->is_auto_increment()) {
2336 2336
 				continue;
2337 2337
 			}
2338 2338
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2339 2339
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2340
-			if( $prepared_value !== NULL ){
2341
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2340
+			if ($prepared_value !== NULL) {
2341
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2342 2342
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2343 2343
 			}
2344 2344
 		}
2345 2345
 
2346
-		if($table instanceof EE_Secondary_Table && $new_id){
2346
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2347 2347
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2348 2348
 			//so add the fk to the main table as a column
2349 2349
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2350
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2350
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2351 2351
 		}
2352 2352
 		//insert the new entry
2353
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2354
-		if( $result === false ) {
2353
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2354
+		if ($result === false) {
2355 2355
 			return false;
2356 2356
 		}
2357 2357
 		//ok, now what do we return for the ID of the newly-inserted thing?
2358
-		if($this->has_primary_key_field()){
2359
-			if($this->get_primary_key_field()->is_auto_increment()){
2358
+		if ($this->has_primary_key_field()) {
2359
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2360 2360
 				return $wpdb->insert_id;
2361
-			}else{
2361
+			} else {
2362 2362
 				//it's not an auto-increment primary key, so
2363 2363
 				//it must have been supplied
2364 2364
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2365 2365
 			}
2366
-		}else{
2366
+		} else {
2367 2367
 			//we can't return a  primary key because there is none. instead return
2368 2368
 			//a unique string indicating this model
2369 2369
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2378,15 +2378,15 @@  discard block
 block discarded – undo
2378 2378
 	 * @param array $fields_n_values
2379 2379
 	 * @return mixed string|int|float depending on what the table column will be expecting
2380 2380
 	 */
2381
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2381
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2382 2382
 		//if this field doesn't allow nullable, don't allow it
2383
-		if( ! $field_obj->is_nullable() && (
2384
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2385
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2386
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2383
+		if ( ! $field_obj->is_nullable() && (
2384
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2385
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2386
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2387 2387
 		}
2388
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2389
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2388
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2389
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2390 2390
 	}
2391 2391
 
2392 2392
 
@@ -2398,9 +2398,9 @@  discard block
 block discarded – undo
2398 2398
 	 * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection
2399 2399
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2400 2400
 	 */
2401
-	private function _prepare_value_for_use_in_db($value, $field){
2402
-		if($field && $field instanceof EE_Model_Field_Base){
2403
-			switch( $this->_values_already_prepared_by_model_object ){
2401
+	private function _prepare_value_for_use_in_db($value, $field) {
2402
+		if ($field && $field instanceof EE_Model_Field_Base) {
2403
+			switch ($this->_values_already_prepared_by_model_object) {
2404 2404
 				/** @noinspection PhpMissingBreakStatementInspection */
2405 2405
 				case self::not_prepared_by_model_object:
2406 2406
 					$value = $field->prepare_for_set($value);
@@ -2411,7 +2411,7 @@  discard block
 block discarded – undo
2411 2411
 					//leave the value alone
2412 2412
 			}
2413 2413
 			return $value;
2414
-		}else{
2414
+		} else {
2415 2415
 			return $value;
2416 2416
 		}
2417 2417
 	}
@@ -2421,13 +2421,13 @@  discard block
 block discarded – undo
2421 2421
 	 * @return EE_Primary_Table
2422 2422
 	 * @throws EE_Error
2423 2423
 	 */
2424
-	protected function _get_main_table(){
2425
-		foreach($this->_tables as $table){
2426
-			if($table instanceof EE_Primary_Table){
2424
+	protected function _get_main_table() {
2425
+		foreach ($this->_tables as $table) {
2426
+			if ($table instanceof EE_Primary_Table) {
2427 2427
 				return $table;
2428 2428
 			}
2429 2429
 		}
2430
-		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this)));
2430
+		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this)));
2431 2431
 	}
2432 2432
 
2433 2433
 	/**
@@ -2446,7 +2446,7 @@  discard block
 block discarded – undo
2446 2446
 	 */
2447 2447
 	public function second_table() {
2448 2448
 		// grab second table from tables array
2449
-		$second_table = end( $this->_tables );
2449
+		$second_table = end($this->_tables);
2450 2450
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2451 2451
 	}
2452 2452
 
@@ -2459,8 +2459,8 @@  discard block
 block discarded – undo
2459 2459
 	 * @param string $table_alias
2460 2460
 	 * @return EE_Primary_Table | EE_Secondary_Table
2461 2461
 	 */
2462
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2463
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2462
+	public function get_table_obj_by_alias($table_alias = '') {
2463
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2464 2464
 	}
2465 2465
 
2466 2466
 
@@ -2469,10 +2469,10 @@  discard block
 block discarded – undo
2469 2469
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2470 2470
 	 * @return EE_Secondary_Table[]
2471 2471
 	 */
2472
-	protected function _get_other_tables(){
2473
-		$other_tables =array();
2474
-		foreach($this->_tables as $table_alias => $table){
2475
-			if($table instanceof EE_Secondary_Table){
2472
+	protected function _get_other_tables() {
2473
+		$other_tables = array();
2474
+		foreach ($this->_tables as $table_alias => $table) {
2475
+			if ($table instanceof EE_Secondary_Table) {
2476 2476
 				$other_tables[$table_alias] = $table;
2477 2477
 			}
2478 2478
 		}
@@ -2484,7 +2484,7 @@  discard block
 block discarded – undo
2484 2484
 	 * @param string $table_alias, array key in EEM_Base::_tables
2485 2485
 	 * @return EE_Model_Field_Base[]
2486 2486
 	 */
2487
-	function _get_fields_for_table($table_alias){
2487
+	function _get_fields_for_table($table_alias) {
2488 2488
 		return $this->_fields[$table_alias];
2489 2489
 	}
2490 2490
 
@@ -2496,29 +2496,29 @@  discard block
 block discarded – undo
2496 2496
 	 * @param array $query_params like EEM_Base::get_all's $query_parameters['where']
2497 2497
 	 * @return EE_Model_Query_Info_Carrier
2498 2498
 	 */
2499
-	function _extract_related_models_from_query($query_params){
2499
+	function _extract_related_models_from_query($query_params) {
2500 2500
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2501
-		if(array_key_exists(0,$query_params)){
2502
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,0);
2503
-		}
2504
-		if(array_key_exists('group_by', $query_params)){
2505
-			if(is_array($query_params['group_by'])){
2506
-				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2507
-			}elseif( ! empty ( $query_params['group_by'] )){
2508
-				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2501
+		if (array_key_exists(0, $query_params)) {
2502
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2503
+		}
2504
+		if (array_key_exists('group_by', $query_params)) {
2505
+			if (is_array($query_params['group_by'])) {
2506
+				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'], $query_info_carrier, 'group_by');
2507
+			}elseif ( ! empty ($query_params['group_by'])) {
2508
+				$this->_extract_related_model_info_from_query_param($query_params['group_by'], $query_info_carrier, 'group_by');
2509 2509
 			}
2510 2510
 		}
2511
-		if(array_key_exists('having',$query_params)){
2512
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2511
+		if (array_key_exists('having', $query_params)) {
2512
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 'having');
2513 2513
 		}
2514
-		if(array_key_exists('order_by', $query_params)){
2515
-			if ( is_array( $query_params['order_by'] ) )
2516
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2517
-			elseif( ! empty( $query_params['order_by'] ))
2518
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2514
+		if (array_key_exists('order_by', $query_params)) {
2515
+			if (is_array($query_params['order_by']))
2516
+				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_info_carrier, 'order_by');
2517
+			elseif ( ! empty($query_params['order_by']))
2518
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_info_carrier, 'order_by');
2519 2519
 		}
2520
-		if(array_key_exists('force_join', $query_params)){
2521
-			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
2520
+		if (array_key_exists('force_join', $query_params)) {
2521
+			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'], $query_info_carrier, 'force_join');
2522 2522
 		}
2523 2523
 		return $query_info_carrier;
2524 2524
 	}
@@ -2531,34 +2531,34 @@  discard block
 block discarded – undo
2531 2531
 	 * @throws EE_Error
2532 2532
 	 * @return \EE_Model_Query_Info_Carrier
2533 2533
 	 */
2534
-	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2535
-		if (!empty($sub_query_params)){
2534
+	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2535
+		if ( ! empty($sub_query_params)) {
2536 2536
 			$sub_query_params = (array) $sub_query_params;
2537
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2537
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2538 2538
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2539
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2539
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2540 2540
 
2541 2541
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2542 2542
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2543 2543
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2544 2544
 				//of array('Registration.TXN_ID'=>23)
2545 2545
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2546
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2547
-					if (! is_array($possibly_array_of_params)){
2546
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2547
+					if ( ! is_array($possibly_array_of_params)) {
2548 2548
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2549
-							$param,$possibly_array_of_params));
2550
-					}else{
2551
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2549
+							$param, $possibly_array_of_params));
2550
+					} else {
2551
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2552 2552
 					}
2553
-				}elseif($query_param_type === 0 //ie WHERE
2553
+				}elseif ($query_param_type === 0 //ie WHERE
2554 2554
 						&& is_array($possibly_array_of_params)
2555 2555
 						&& isset($possibly_array_of_params[2])
2556
-						&& $possibly_array_of_params[2] == true){
2556
+						&& $possibly_array_of_params[2] == true) {
2557 2557
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2558 2558
 					//indicating that $possible_array_of_params[1] is actually a field name,
2559 2559
 					//from which we should extract query parameters!
2560
-					if(! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])){
2561
-						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params)));
2560
+					if ( ! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])) {
2561
+						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params)));
2562 2562
 					}
2563 2563
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2564 2564
 				}
@@ -2577,14 +2577,14 @@  discard block
 block discarded – undo
2577 2577
 	 * @throws EE_Error
2578 2578
 	 * @return \EE_Model_Query_Info_Carrier
2579 2579
 	 */
2580
-	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2581
-		if (!empty($sub_query_params)){
2582
-			if(!is_array($sub_query_params)){
2583
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2580
+	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2581
+		if ( ! empty($sub_query_params)) {
2582
+			if ( ! is_array($sub_query_params)) {
2583
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2584 2584
 			}
2585
-			foreach($sub_query_params as $param){
2585
+			foreach ($sub_query_params as $param) {
2586 2586
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2587
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2587
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2588 2588
 			}
2589 2589
 		}
2590 2590
 		return $model_query_info_carrier;
@@ -2603,81 +2603,81 @@  discard block
 block discarded – undo
2603 2603
 	 * @throws EE_Error
2604 2604
 	 * @return EE_Model_Query_Info_Carrier
2605 2605
 	 */
2606
-	function _create_model_query_info_carrier($query_params){
2607
-		if( ! is_array( $query_params ) ){
2608
-			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2606
+	function _create_model_query_info_carrier($query_params) {
2607
+		if ( ! is_array($query_params)) {
2608
+			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2609 2609
 			$query_params = array();
2610 2610
 		}
2611
-		if( isset( $query_params[0] ) ) {
2611
+		if (isset($query_params[0])) {
2612 2612
 			$where_query_params = $query_params[0];
2613
-		}else{
2613
+		} else {
2614 2614
 			$where_query_params = array();
2615 2615
 		}
2616 2616
 		//first check if we should alter the query to account for caps or not
2617 2617
 		//because the caps might require us to do extra joins
2618
-		if( isset( $query_params[ 'caps' ] ) && $query_params[ 'caps' ] != 'none' ) {
2619
-			$query_params[0] = $where_query_params = array_replace_recursive( $where_query_params, $this->caps_where_conditions( $query_params[ 'caps' ] ) );
2618
+		if (isset($query_params['caps']) && $query_params['caps'] != 'none') {
2619
+			$query_params[0] = $where_query_params = array_replace_recursive($where_query_params, $this->caps_where_conditions($query_params['caps']));
2620 2620
 		}
2621 2621
 		$query_object = $this->_extract_related_models_from_query($query_params);
2622 2622
 
2623 2623
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2624
-		foreach($where_query_params as $key => $value){
2625
-			if(is_int($key)){
2626
-				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"),$key, var_export( $value, true ), var_export( $query_params, true ), get_class($this)));
2624
+		foreach ($where_query_params as $key => $value) {
2625
+			if (is_int($key)) {
2626
+				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"), $key, var_export($value, true), var_export($query_params, true), get_class($this)));
2627 2627
 			}
2628 2628
 		}
2629
-		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2629
+		if (array_key_exists('default_where_conditions', $query_params) && ! empty($query_params['default_where_conditions'])) {
2630 2630
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2631
-		}else{
2631
+		} else {
2632 2632
 			$use_default_where_conditions = 'all';
2633 2633
 		}
2634
-		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
2635
-		$query_object->set_where_sql( $this->_construct_where_clause($where_query_params));
2634
+		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object, $use_default_where_conditions, $where_query_params), $where_query_params);
2635
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2636 2636
 
2637 2637
 
2638 2638
 		//if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.  So we need to setup a subquery and use that for the main join.  Note for now this only works on the primary table for the model.  So for instance, you could set the limit array like this:
2639 2639
 		//array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2640
-		if ( array_key_exists('on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] )) {
2641
-			$query_object->set_main_model_join_sql( $this->_construct_limit_join_select( $query_params['on_join_limit'][0], $query_params['on_join_limit'][1] ) );
2640
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2641
+			$query_object->set_main_model_join_sql($this->_construct_limit_join_select($query_params['on_join_limit'][0], $query_params['on_join_limit'][1]));
2642 2642
 		}
2643 2643
 
2644 2644
 
2645 2645
 		//set limit
2646
-		if(array_key_exists('limit',$query_params)){
2647
-			if(is_array($query_params['limit'])){
2648
-				if( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])){
2649
-					$e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"),  http_build_query($query_params['limit']));
2646
+		if (array_key_exists('limit', $query_params)) {
2647
+			if (is_array($query_params['limit'])) {
2648
+				if ( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])) {
2649
+					$e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"), http_build_query($query_params['limit']));
2650 2650
 					throw new EE_Error($e."|".$e);
2651 2651
 				}
2652 2652
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2653 2653
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2654
-			}elseif( ! empty ( $query_params['limit'] )){
2654
+			}elseif ( ! empty ($query_params['limit'])) {
2655 2655
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2656 2656
 			}
2657 2657
 		}
2658 2658
 		//set order by
2659
-		if(array_key_exists('order_by',$query_params)){
2660
-			if(is_array($query_params['order_by'])){
2659
+		if (array_key_exists('order_by', $query_params)) {
2660
+			if (is_array($query_params['order_by'])) {
2661 2661
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2662 2662
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2663 2663
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2664
-				if(array_key_exists('order', $query_params)){
2664
+				if (array_key_exists('order', $query_params)) {
2665 2665
 					throw new EE_Error(sprintf(__("In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ", "event_espresso"),
2666
-							get_class($this),implode(", ",array_keys($query_params['order_by'])),implode(", ",$query_params['order_by']),$query_params['order']));
2666
+							get_class($this), implode(", ", array_keys($query_params['order_by'])), implode(", ", $query_params['order_by']), $query_params['order']));
2667 2667
 				}
2668
-				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_object,'order_by');
2668
+				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_object, 'order_by');
2669 2669
 				//assume it's an array of fields to order by
2670 2670
 				$order_array = array();
2671
-				foreach($query_params['order_by'] as $field_name_to_order_by => $order){
2671
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2672 2672
 					$order = $this->_extract_order($order);
2673 2673
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2674 2674
 				}
2675
-				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2676
-			}elseif( ! empty ( $query_params['order_by'] )){
2677
-				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2678
-				if(isset($query_params['order'])){
2675
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2676
+			}elseif ( ! empty ($query_params['order_by'])) {
2677
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_object, 'order', $query_params['order_by']);
2678
+				if (isset($query_params['order'])) {
2679 2679
 					$order = $this->_extract_order($query_params['order']);
2680
-				}else{
2680
+				} else {
2681 2681
 					$order = 'DESC';
2682 2682
 				}
2683 2683
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2685,46 +2685,46 @@  discard block
 block discarded – undo
2685 2685
 		}
2686 2686
 
2687 2687
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2688
-		if( ! array_key_exists('order_by',$query_params) && array_key_exists('order',$query_params) && ! empty( $query_params['order'] )){
2688
+		if ( ! array_key_exists('order_by', $query_params) && array_key_exists('order', $query_params) && ! empty($query_params['order'])) {
2689 2689
 			$pk_field = $this->get_primary_key_field();
2690 2690
 			$order = $this->_extract_order($query_params['order']);
2691 2691
 			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2692 2692
 		}
2693 2693
 
2694 2694
 		//set group by
2695
-		if(array_key_exists('group_by',$query_params)){
2696
-			if(is_array($query_params['group_by'])){
2695
+		if (array_key_exists('group_by', $query_params)) {
2696
+			if (is_array($query_params['group_by'])) {
2697 2697
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2698 2698
 				$group_by_array = array();
2699
-				foreach($query_params['group_by'] as $field_name_to_group_by){
2699
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2700 2700
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2701 2701
 				}
2702
-				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2703
-			}elseif( ! empty ( $query_params['group_by'] )){
2702
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2703
+			}elseif ( ! empty ($query_params['group_by'])) {
2704 2704
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2705 2705
 			}
2706 2706
 		}
2707 2707
 		//set having
2708
-		if(array_key_exists('having',$query_params) && $query_params['having']){
2709
-			$query_object->set_having_sql( $this->_construct_having_clause($query_params['having']));
2708
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2709
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2710 2710
 		}
2711 2711
 
2712 2712
 		//now, just verify they didn't pass anything wack
2713
-		foreach($query_params as $query_key => $query_value){
2714
-			if( ! in_array($query_key,$this->_allowed_query_params,true)){
2713
+		foreach ($query_params as $query_key => $query_value) {
2714
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2715 2715
 				throw new EE_Error(
2716 2716
 					sprintf(
2717
-						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s",'event_espresso'),
2717
+						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s", 'event_espresso'),
2718 2718
 						$query_key,
2719 2719
 						get_class($this),
2720 2720
 //						print_r( $this->_allowed_query_params, TRUE )
2721
-						implode( ', ', $this->_allowed_query_params )
2721
+						implode(', ', $this->_allowed_query_params)
2722 2722
 					)
2723 2723
 				);
2724 2724
 			}
2725 2725
 		}
2726 2726
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2727
-		if ( empty( $main_model_join_sql ) )
2727
+		if (empty($main_model_join_sql))
2728 2728
 			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2729 2729
 		return $query_object;
2730 2730
 	}
@@ -2735,17 +2735,17 @@  discard block
 block discarded – undo
2735 2735
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
2736 2736
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2737 2737
 	 */
2738
-	public function caps_where_conditions( $context = self::caps_read ) {
2739
-		EEM_Base::verify_is_valid_cap_context( $context );
2738
+	public function caps_where_conditions($context = self::caps_read) {
2739
+		EEM_Base::verify_is_valid_cap_context($context);
2740 2740
 		$cap_where_conditions = array();
2741
-		$cap_restrictions = $this->caps_missing( $context );
2741
+		$cap_restrictions = $this->caps_missing($context);
2742 2742
 		/**
2743 2743
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2744 2744
 		 */
2745
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2746
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2745
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2746
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2747 2747
 		}
2748
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2748
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2749 2749
 	}
2750 2750
 
2751 2751
 	/**
@@ -2755,11 +2755,11 @@  discard block
 block discarded – undo
2755 2755
 	 * @return string either ASC, asc, DESC or desc
2756 2756
 	 * @throws EE_Error
2757 2757
 	 */
2758
-	private function _extract_order($should_be_order_string){
2759
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2758
+	private function _extract_order($should_be_order_string) {
2759
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2760 2760
 			return $should_be_order_string;
2761
-		}else{
2762
-			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2761
+		} else {
2762
+			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string));
2763 2763
 		}
2764 2764
 	}
2765 2765
 
@@ -2777,7 +2777,7 @@  discard block
 block discarded – undo
2777 2777
 	 * @throws EE_Error
2778 2778
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
2779 2779
 	 */
2780
-	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){
2780
+	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) {
2781 2781
 		$allowed_used_default_where_conditions_values = array(
2782 2782
 				'all',
2783 2783
 				'this_model_only', 
@@ -2785,19 +2785,19 @@  discard block
 block discarded – undo
2785 2785
 				'minimum',
2786 2786
 				'none'
2787 2787
 			);
2788
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
2789
-			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values)));
2788
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
2789
+			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values)));
2790 2790
 		}
2791
-		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2791
+		if (in_array($use_default_where_conditions, array('all', 'this_model_only'))) {
2792 2792
 			$universal_query_params = $this->_get_default_where_conditions();
2793
-		}elseif( in_array( $use_default_where_conditions, array( 'minimum' ) ) ) {
2793
+		}elseif (in_array($use_default_where_conditions, array('minimum'))) {
2794 2794
 			$universal_query_params = $this->_get_minimum_where_conditions();
2795
-		}else{
2795
+		} else {
2796 2796
 			$universal_query_params = array();
2797 2797
 		}
2798 2798
 
2799
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
2800
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
2799
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
2800
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
2801 2801
 				$related_model = $this->get_related_model_obj($model_name);
2802 2802
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2803 2803
 
@@ -2824,22 +2824,22 @@  discard block
 block discarded – undo
2824 2824
 	 * @param string $model_relation_path like 'Transaction.Payment.'
2825 2825
 	 * @return array like EEM_Base::get_all's $query_params[0]
2826 2826
 	 */
2827
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
2827
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
2828 2828
 		$null_friendly_where_conditions = array();
2829 2829
 		$none_overridden = true;
2830 2830
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
2831 2831
 
2832
-		foreach($default_where_conditions as $key => $val){
2833
-			if( isset($provided_where_conditions[$key])){
2832
+		foreach ($default_where_conditions as $key => $val) {
2833
+			if (isset($provided_where_conditions[$key])) {
2834 2834
 				$none_overridden = false;
2835
-			}else{
2835
+			} else {
2836 2836
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2837 2837
 			}
2838 2838
 		}
2839
-		if( $none_overridden && $default_where_conditions){
2840
-			if($model->has_primary_key_field()){
2839
+		if ($none_overridden && $default_where_conditions) {
2840
+			if ($model->has_primary_key_field()) {
2841 2841
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2842
-			}else{
2842
+			} else {
2843 2843
 				//@todo NO PK, use other defaults
2844 2844
 			}
2845 2845
 		}
@@ -2854,8 +2854,8 @@  discard block
 block discarded – undo
2854 2854
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2855 2855
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2856 2856
 	 */
2857
-	private function _get_default_where_conditions($model_relation_path = null){
2858
-		if ( $this->_ignore_where_strategy )
2857
+	private function _get_default_where_conditions($model_relation_path = null) {
2858
+		if ($this->_ignore_where_strategy)
2859 2859
 			return array();
2860 2860
 
2861 2861
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2869,8 +2869,8 @@  discard block
 block discarded – undo
2869 2869
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2870 2870
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2871 2871
 	 */
2872
-	protected function _get_minimum_where_conditions($model_relation_path = null){
2873
-		if ( $this->_ignore_where_strategy )
2872
+	protected function _get_minimum_where_conditions($model_relation_path = null) {
2873
+		if ($this->_ignore_where_strategy)
2874 2874
 			return array();
2875 2875
 
2876 2876
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2881,13 +2881,13 @@  discard block
 block discarded – undo
2881 2881
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2882 2882
 	 * @return string
2883 2883
 	 */
2884
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
2884
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
2885 2885
 		$selects = $this->_get_columns_to_select_for_this_model();
2886
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
2886
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
2887 2887
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
2888 2888
 			$selects = array_merge($selects, $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain));
2889 2889
 		}
2890
-		return implode(", ",$selects);
2890
+		return implode(", ", $selects);
2891 2891
 	}
2892 2892
 
2893 2893
 	/**
@@ -2896,19 +2896,19 @@  discard block
 block discarded – undo
2896 2896
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
2897 2897
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
2898 2898
 	 */
2899
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
2899
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
2900 2900
 		$fields = $this->field_settings();
2901 2901
 		$selects = array();
2902 2902
 		$table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name());
2903
-		foreach($fields as $field_obj){
2904
-			$selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
2903
+		foreach ($fields as $field_obj) {
2904
+			$selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
2905 2905
 		}
2906 2906
 		//make sure we are also getting the PKs of each table
2907 2907
 		$tables = $this->get_tables();
2908
-		if(count($tables) > 1){
2909
-			foreach($tables as $table_obj){
2910
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
2911
-				if( ! in_array($qualified_pk_column,$selects)){
2908
+		if (count($tables) > 1) {
2909
+			foreach ($tables as $table_obj) {
2910
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
2911
+				if ( ! in_array($qualified_pk_column, $selects)) {
2912 2912
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
2913 2913
 				}
2914 2914
 			}
@@ -2932,66 +2932,66 @@  discard block
 block discarded – undo
2932 2932
 	 * @throws EE_Error
2933 2933
 	 * @return void only modifies the EEM_Related_Model_Info_Carrier passed into it
2934 2934
 	 */
2935
-	private function _extract_related_model_info_from_query_param( $query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL ){
2936
-		if($original_query_param == NULL){
2935
+	private function _extract_related_model_info_from_query_param($query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL) {
2936
+		if ($original_query_param == NULL) {
2937 2937
 			$original_query_param = $query_param;
2938 2938
 		}
2939 2939
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
2940 2940
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
2941
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
2942
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
2941
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
2942
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
2943 2943
 		//check to see if we have a field on this model
2944 2944
 		$this_model_fields = $this->field_settings(true);
2945
-		if(array_key_exists($query_param,$this_model_fields)){
2946
-			if($allow_fields){
2945
+		if (array_key_exists($query_param, $this_model_fields)) {
2946
+			if ($allow_fields) {
2947 2947
 				return;
2948
-			}else{
2948
+			} else {
2949 2949
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
2950
-						$query_param,get_class($this),$query_param_type,$original_query_param));
2950
+						$query_param, get_class($this), $query_param_type, $original_query_param));
2951 2951
 			}
2952 2952
 		}
2953 2953
 		//check if this is a special logic query param
2954
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2955
-			if($allow_logic_query_params){
2954
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
2955
+			if ($allow_logic_query_params) {
2956 2956
 				return;
2957
-			}else{
2957
+			} else {
2958 2958
 				throw new EE_Error(
2959 2959
 					sprintf(
2960
-						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
2961
-						implode( '", "', $this->_logic_query_param_keys ),
2962
-						$query_param ,
2963
-						get_class( $this ),
2960
+						__('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'),
2961
+						implode('", "', $this->_logic_query_param_keys),
2962
+						$query_param,
2963
+						get_class($this),
2964 2964
 						'<br />',
2965
-						"\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param
2965
+						"\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param
2966 2966
 					)
2967 2967
 				);
2968 2968
 			}
2969 2969
 		}
2970 2970
 
2971 2971
 		//check if it's a custom selection
2972
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
2972
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
2973 2973
 			return;
2974 2974
 		}
2975 2975
 
2976 2976
 		//check if has a model name at the beginning
2977 2977
 		//and
2978 2978
 		//check if it's a field on a related model
2979
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
2980
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
2981
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2979
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
2980
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
2981
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2982 2982
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
2983
-				if($query_param == ''){
2983
+				if ($query_param == '') {
2984 2984
 					//nothing left to $query_param
2985 2985
 					//we should actually end in a field name, not a model like this!
2986 2986
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2987
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2988
-				}else{
2987
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
2988
+				} else {
2989 2989
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2990 2990
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2991 2991
 					return;
2992 2992
 				}
2993
-			}elseif($query_param == $valid_related_model_name){
2994
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2993
+			}elseif ($query_param == $valid_related_model_name) {
2994
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2995 2995
 				return;
2996 2996
 			}
2997 2997
 		}
@@ -3001,7 +3001,7 @@  discard block
 block discarded – undo
3001 3001
 		//and we previously confirmed it wasn't a logic query param or field on the current model
3002 3002
 		//it's wack, that's what it is
3003 3003
 		throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"),
3004
-				$query_param,get_class($this),$query_param_type,$original_query_param));
3004
+				$query_param, get_class($this), $query_param_type, $original_query_param));
3005 3005
 
3006 3006
 	}
3007 3007
 
@@ -3018,26 +3018,26 @@  discard block
 block discarded – undo
3018 3018
 	 * what models to prepend onto its default query params or in case it wants to rename tables (in case there are multiple joins to the same table)
3019 3019
 	 * @return void
3020 3020
 	 */
3021
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
3021
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
3022 3022
 		$relation_obj = $this->related_settings_for($model_name);
3023 3023
 
3024 3024
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
3025 3025
 		//check if the relation is HABTM, because then we're essentially doing two joins
3026 3026
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
3027
-		if($relation_obj instanceof EE_HABTM_Relation){
3027
+		if ($relation_obj instanceof EE_HABTM_Relation) {
3028 3028
 			$join_model_obj = $relation_obj->get_join_model();
3029 3029
 			//replace the model specified with the join model for this relation chain, whi
3030 3030
 			$relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain);
3031 3031
 			$new_query_info = new EE_Model_Query_Info_Carrier(
3032 3032
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
3033 3033
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
3034
-			$passed_in_query_info->merge( $new_query_info  );
3034
+			$passed_in_query_info->merge($new_query_info);
3035 3035
 		}
3036 3036
 		//now just join to the other table pointed to by the relation object, and add its data types
3037 3037
 		$new_query_info = new EE_Model_Query_Info_Carrier(
3038 3038
 				array($model_relation_chain=>$model_name),
3039 3039
 				$relation_obj->get_join_statement($model_relation_chain));
3040
-		$passed_in_query_info->merge( $new_query_info  );
3040
+		$passed_in_query_info->merge($new_query_info);
3041 3041
 	}
3042 3042
 
3043 3043
 
@@ -3046,11 +3046,11 @@  discard block
 block discarded – undo
3046 3046
 	 * @param array $where_params like EEM_Base::get_all
3047 3047
 	 * @return string of SQL
3048 3048
 	 */
3049
-	private function _construct_where_clause($where_params){
3049
+	private function _construct_where_clause($where_params) {
3050 3050
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3051
-		if($SQL){
3052
-			return " WHERE ". $SQL;
3053
-		}else{
3051
+		if ($SQL) {
3052
+			return " WHERE ".$SQL;
3053
+		} else {
3054 3054
 			return '';
3055 3055
 		}
3056 3056
 	}
@@ -3061,11 +3061,11 @@  discard block
 block discarded – undo
3061 3061
 	 * @param array $having_params
3062 3062
 	 * @return string
3063 3063
 	 */
3064
-	private function _construct_having_clause($having_params){
3064
+	private function _construct_having_clause($having_params) {
3065 3065
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3066
-		if($SQL){
3067
-			return " HAVING ". $SQL;
3068
-		}else{
3066
+		if ($SQL) {
3067
+			return " HAVING ".$SQL;
3068
+		} else {
3069 3069
 			return '';
3070 3070
 		}
3071 3071
 
@@ -3079,17 +3079,17 @@  discard block
 block discarded – undo
3079 3079
 	 * @return EE_Model_Field_Base
3080 3080
 	 * @throws EE_Error
3081 3081
 	 */
3082
-	protected function _get_field_on_model($field_name,$model_name){
3082
+	protected function _get_field_on_model($field_name, $model_name) {
3083 3083
 		$model_class = 'EEM_'.$model_name;
3084 3084
 		$model_filepath = $model_class.".model.php";
3085
-		EE_Registry::instance()->load_helper( 'File' );
3086
-		if ( is_readable($model_filepath)){
3085
+		EE_Registry::instance()->load_helper('File');
3086
+		if (is_readable($model_filepath)) {
3087 3087
 			require_once($model_filepath);
3088
-			$model_instance=call_user_func($model_name."::instance");
3088
+			$model_instance = call_user_func($model_name."::instance");
3089 3089
 			/* @var $model_instance EEM_Base */
3090 3090
 			return $model_instance->field_settings_for($field_name);
3091
-		}else{
3092
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3091
+		} else {
3092
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3093 3093
 		}
3094 3094
 	}
3095 3095
 
@@ -3102,43 +3102,43 @@  discard block
 block discarded – undo
3102 3102
 	 * @throws EE_Error
3103 3103
 	 * @return string of SQL
3104 3104
 	 */
3105
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3106
-		$where_clauses=array();
3107
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3108
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3109
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3110
-				switch($query_param){
3105
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3106
+		$where_clauses = array();
3107
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3108
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3109
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3110
+				switch ($query_param) {
3111 3111
 					case 'not':
3112 3112
 					case 'NOT':
3113
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3113
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3114 3114
 						break;
3115 3115
 					case 'and':
3116 3116
 					case 'AND':
3117
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3117
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3118 3118
 						break;
3119 3119
 					case 'or':
3120 3120
 					case 'OR':
3121
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3121
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3122 3122
 						break;
3123 3123
 				}
3124
-			}else{
3124
+			} else {
3125 3125
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3126 3126
 
3127 3127
 				//if it's not a normal field, maybe it's a custom selection?
3128
-				if( ! $field_obj){
3129
-					if(isset( $this->_custom_selections[$query_param][1])){
3128
+				if ( ! $field_obj) {
3129
+					if (isset($this->_custom_selections[$query_param][1])) {
3130 3130
 						$field_obj = $this->_custom_selections[$query_param][1];
3131
-					}else{
3132
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3131
+					} else {
3132
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3133 3133
 					}
3134 3134
 				}
3135 3135
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3136
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3136
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3137 3137
 			}
3138 3138
 		}
3139
-		if($where_clauses){
3140
-			$SQL = implode($glue,$where_clauses);
3141
-		}else{
3139
+		if ($where_clauses) {
3140
+			$SQL = implode($glue, $where_clauses);
3141
+		} else {
3142 3142
 			$SQL = '';
3143 3143
 		}
3144 3144
 		return $SQL;
@@ -3152,18 +3152,18 @@  discard block
 block discarded – undo
3152 3152
 	 * @throws EE_Error
3153 3153
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3154 3154
 	 */
3155
-	private function _deduce_column_name_from_query_param($query_param){
3155
+	private function _deduce_column_name_from_query_param($query_param) {
3156 3156
 		$field = $this->_deduce_field_from_query_param($query_param);
3157 3157
 
3158
-		if( $field ){
3159
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3160
-			return $table_alias_prefix . $field->get_qualified_column();
3161
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3158
+		if ($field) {
3159
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3160
+			return $table_alias_prefix.$field->get_qualified_column();
3161
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3162 3162
 			//maybe it's custom selection item?
3163 3163
 			//if so, just use it as the "column name"
3164 3164
 			return $query_param;
3165
-		}else{
3166
-			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3165
+		} else {
3166
+			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections)));
3167 3167
 		}
3168 3168
 	}
3169 3169
 
@@ -3175,11 +3175,11 @@  discard block
 block discarded – undo
3175 3175
 	 * @param string $condition_query_param_key
3176 3176
 	 * @return string
3177 3177
 	 */
3178
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3178
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3179 3179
 		$pos_of_star = strpos($condition_query_param_key, '*');
3180
-		if($pos_of_star === FALSE){
3180
+		if ($pos_of_star === FALSE) {
3181 3181
 			return $condition_query_param_key;
3182
-		}else{
3182
+		} else {
3183 3183
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3184 3184
 			return $condition_query_param_sans_star;
3185 3185
 		}
@@ -3194,54 +3194,54 @@  discard block
 block discarded – undo
3194 3194
 	 * @throws EE_Error
3195 3195
 	 * @return string
3196 3196
 	 */
3197
-	private function _construct_op_and_value($op_and_value, $field_obj){
3198
-		if(is_array( $op_and_value )){
3197
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3198
+		if (is_array($op_and_value)) {
3199 3199
 			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3200
-			if( ! $operator){
3200
+			if ( ! $operator) {
3201 3201
 				$php_array_like_string = array();
3202
-				foreach($op_and_value as $key => $value){
3202
+				foreach ($op_and_value as $key => $value) {
3203 3203
 					$php_array_like_string[] = "$key=>$value";
3204 3204
 				}
3205
-				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string)));
3205
+				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",", $php_array_like_string)));
3206 3206
 			}
3207 3207
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3208
-		}else{
3208
+		} else {
3209 3209
 			$operator = '=';
3210 3210
 			$value = $op_and_value;
3211 3211
 		}
3212 3212
 
3213 3213
 		//check to see if the value is actually another field
3214
-		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
3214
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3215 3215
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3216
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3216
+		}elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3217 3217
 			//in this case, the value should be an array, or at least a comma-separated list
3218 3218
 			//it will need to handle a little differently
3219 3219
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3220 3220
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3221 3221
 			return $operator.SP.$cleaned_value;
3222
-		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3222
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3223 3223
 			//the value should be an array with count of two.
3224
-			if ( count($value) !== 2 )
3225
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3226
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3224
+			if (count($value) !== 2)
3225
+				throw new EE_Error(sprintf(__("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN"));
3226
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3227 3227
 			return $operator.SP.$cleaned_value;
3228
-		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
3229
-			if($value != NULL){
3230
-				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
3228
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3229
+			if ($value != NULL) {
3230
+				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"), $value, $operator));
3231 3231
 			}
3232 3232
 			return $operator;
3233
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
3233
+		}elseif ($operator == 'LIKE' && ! is_array($value)) {
3234 3234
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3235 3235
 			//remove other junk. So just treat it as a string.
3236 3236
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3237
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3238
-			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
3239
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3240
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
3241
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3242
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
3243
-		}else{
3244
-			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
3237
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3238
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3239
+		}elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3240
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))", 'event_espresso'), $operator, $operator));
3241
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3242
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))", 'event_espresso'), $operator, $operator));
3243
+		} else {
3244
+			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value)));
3245 3245
 		}
3246 3246
 	}
3247 3247
 
@@ -3253,12 +3253,12 @@  discard block
 block discarded – undo
3253 3253
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be the datatype to be used when querying, eg '%s'
3254 3254
 	 * @return string
3255 3255
 	 */
3256
-	function _construct_between_value( $values, $field_obj ) {
3256
+	function _construct_between_value($values, $field_obj) {
3257 3257
 		$cleaned_values = array();
3258
-		foreach ( $values as $value ) {
3259
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3258
+		foreach ($values as $value) {
3259
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3260 3260
 		}
3261
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3261
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3262 3262
 	}
3263 3263
 
3264 3264
 
@@ -3274,26 +3274,26 @@  discard block
 block discarded – undo
3274 3274
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be a wpdb data type like '%s', or '%d'
3275 3275
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3276 3276
 	 */
3277
-	function _construct_in_value($values,  $field_obj){
3277
+	function _construct_in_value($values, $field_obj) {
3278 3278
 		//check if the value is a CSV list
3279
-		if(is_string($values)){
3279
+		if (is_string($values)) {
3280 3280
 			//in which case, turn it into an array
3281
-			$values = explode(",",$values);
3281
+			$values = explode(",", $values);
3282 3282
 		}
3283 3283
 		$cleaned_values = array();
3284
-		foreach($values as $value){
3285
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3284
+		foreach ($values as $value) {
3285
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3286 3286
 		}
3287 3287
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3288 3288
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3289 3289
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3290
-		if(empty($cleaned_values)){
3290
+		if (empty($cleaned_values)) {
3291 3291
 			$all_fields = $this->field_settings();
3292 3292
 			$a_field = array_shift($all_fields);
3293 3293
 			$main_table = $this->_get_main_table();
3294 3294
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3295 3295
 		}
3296
-		return "(".implode(",",$cleaned_values).")";
3296
+		return "(".implode(",", $cleaned_values).")";
3297 3297
 	}
3298 3298
 
3299 3299
 
@@ -3305,16 +3305,16 @@  discard block
 block discarded – undo
3305 3305
 	 * @throws EE_Error
3306 3306
 	 * @return false|null|string
3307 3307
 	 */
3308
-	private function _wpdb_prepare_using_field($value,$field_obj){
3308
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3309 3309
 		/** @type WPDB $wpdb */
3310 3310
 		global $wpdb;
3311
-		if($field_obj instanceof EE_Model_Field_Base){
3312
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3313
-		}else{//$field_obj should really just be a data type
3314
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3315
-				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3311
+		if ($field_obj instanceof EE_Model_Field_Base) {
3312
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3313
+		} else {//$field_obj should really just be a data type
3314
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3315
+				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types)));
3316 3316
 			}
3317
-			return $wpdb->prepare($field_obj,$value);
3317
+			return $wpdb->prepare($field_obj, $value);
3318 3318
 		}
3319 3319
 	}
3320 3320
 
@@ -3326,27 +3326,27 @@  discard block
 block discarded – undo
3326 3326
 	 * @throws EE_Error
3327 3327
 	 * @return EE_Model_Field_Base
3328 3328
 	 */
3329
-	protected function _deduce_field_from_query_param($query_param_name){
3329
+	protected function _deduce_field_from_query_param($query_param_name) {
3330 3330
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3331 3331
 		//which will help us find the database table and column
3332 3332
 
3333
-		$query_param_parts = explode(".",$query_param_name);
3334
-		if(empty($query_param_parts)){
3335
-			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name));
3333
+		$query_param_parts = explode(".", $query_param_name);
3334
+		if (empty($query_param_parts)) {
3335
+			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name));
3336 3336
 		}
3337 3337
 		$number_of_parts = count($query_param_parts);
3338
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3339
-		if($number_of_parts == 1){
3338
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3339
+		if ($number_of_parts == 1) {
3340 3340
 			$field_name = $last_query_param_part;
3341 3341
 			$model_obj = $this;
3342
-		}else{// $number_of_parts >= 2
3342
+		} else {// $number_of_parts >= 2
3343 3343
 			//the last part is the column name, and there are only 2parts. therefore...
3344 3344
 			$field_name = $last_query_param_part;
3345
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3345
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3346 3346
 		}
3347
-		try{
3347
+		try {
3348 3348
 			return $model_obj->field_settings_for($field_name);
3349
-		}catch(EE_Error $e){
3349
+		} catch (EE_Error $e) {
3350 3350
 			return null;
3351 3351
 		}
3352 3352
 	}
@@ -3360,13 +3360,13 @@  discard block
 block discarded – undo
3360 3360
 	 * @throws EE_Error
3361 3361
 	 * @return string
3362 3362
 	 */
3363
-	function _get_qualified_column_for_field($field_name){
3363
+	function _get_qualified_column_for_field($field_name) {
3364 3364
 		$all_fields = $this->field_settings();
3365 3365
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3366
-		if($field){
3366
+		if ($field) {
3367 3367
 			return $field->get_qualified_column();
3368
-		}else{
3369
-			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3368
+		} else {
3369
+			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this)));
3370 3370
 		}
3371 3371
 	}
3372 3372
 
@@ -3380,14 +3380,14 @@  discard block
 block discarded – undo
3380 3380
 	 * @param  mixed|string $limit The limit for this select
3381 3381
 	 * @return string 				The final select join element for the query.
3382 3382
 	 */
3383
-	function _construct_limit_join_select( $table_alias, $limit ) {
3383
+	function _construct_limit_join_select($table_alias, $limit) {
3384 3384
 		$SQL = '';
3385 3385
 
3386
-		foreach ( $this->_tables as $table_obj ) {
3387
-			if ( $table_obj instanceof EE_Primary_Table ) {
3388
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit( $limit ) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3389
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3390
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP . $table_obj->get_join_sql( $table_alias ).SP;
3386
+		foreach ($this->_tables as $table_obj) {
3387
+			if ($table_obj instanceof EE_Primary_Table) {
3388
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit($limit) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3389
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3390
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP.$table_obj->get_join_sql($table_alias).SP;
3391 3391
 			}
3392 3392
 		}
3393 3393
 		return $SQL;
@@ -3400,7 +3400,7 @@  discard block
 block discarded – undo
3400 3400
 	 * Eg "wp_post AS Event" or "wp_post AS Event INNER JOIN wp_postmeta Event_Meta ON Event.ID = Event_Meta.post_id"
3401 3401
 	 * @return string SQL
3402 3402
 	 */
3403
-	function _construct_internal_join(){
3403
+	function _construct_internal_join() {
3404 3404
 		$SQL = $this->_get_main_table()->get_table_sql();
3405 3405
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3406 3406
 		return $SQL;
@@ -3421,17 +3421,17 @@  discard block
 block discarded – undo
3421 3421
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3422 3422
 	 * @return string
3423 3423
 	 */
3424
-	function _construct_internal_join_to_table_with_alias($alias_prefixed){
3424
+	function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3425 3425
 		$SQL = '';
3426 3426
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3427
-		foreach($this->_tables as $table_obj){
3428
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3429
-				if($alias_sans_prefix == $table_obj->get_table_alias()){
3427
+		foreach ($this->_tables as $table_obj) {
3428
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3429
+				if ($alias_sans_prefix == $table_obj->get_table_alias()) {
3430 3430
 					//so we're joining to this table, meaning the table is already in
3431 3431
 					//the FROM statement, BUT the primary table isn't. So we want
3432 3432
 					//to add the inverse join sql
3433 3433
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3434
-				}else{
3434
+				} else {
3435 3435
 					//just add a regular JOIN to this table from the primary table
3436 3436
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3437 3437
 				}
@@ -3445,9 +3445,9 @@  discard block
 block discarded – undo
3445 3445
 	 * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc)
3446 3446
 	 * @return array
3447 3447
 	 */
3448
-	function _get_data_types(){
3448
+	function _get_data_types() {
3449 3449
 		$data_types = array();
3450
-		foreach(array_values($this->field_settings()) as $field_obj){
3450
+		foreach (array_values($this->field_settings()) as $field_obj) {
3451 3451
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3452 3452
 			/** @var $field_obj EE_Model_Field_Base */
3453 3453
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3463,11 +3463,11 @@  discard block
 block discarded – undo
3463 3463
 	 * @throws EE_Error
3464 3464
 	 * @return EEM_Base
3465 3465
 	 */
3466
-	function get_related_model_obj($model_name){
3466
+	function get_related_model_obj($model_name) {
3467 3467
 
3468
-		$model_classname = strpos( $model_name, 'EEM_' ) === 0 ? $model_name : 'EEM_' . $model_name;
3469
-		if(!class_exists($model_classname)){
3470
-			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname));
3468
+		$model_classname = strpos($model_name, 'EEM_') === 0 ? $model_name : 'EEM_'.$model_name;
3469
+		if ( ! class_exists($model_classname)) {
3470
+			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname));
3471 3471
 		}
3472 3472
 		$model_obj = call_user_func($model_classname."::instance");
3473 3473
 		return $model_obj;
@@ -3478,7 +3478,7 @@  discard block
 block discarded – undo
3478 3478
 	 * Returns the array of EE_ModelRelations for this model.
3479 3479
 	 * @return EE_Model_Relation_Base[]
3480 3480
 	 */
3481
-	public function relation_settings(){
3481
+	public function relation_settings() {
3482 3482
 		return $this->_model_relations;
3483 3483
 	}
3484 3484
 
@@ -3488,10 +3488,10 @@  discard block
 block discarded – undo
3488 3488
 	 * (Eg, without an event, datetimes have little purpose.)
3489 3489
 	 * @return EE_Belongs_To_Relation[]
3490 3490
 	 */
3491
-	public function belongs_to_relations(){
3491
+	public function belongs_to_relations() {
3492 3492
 		$belongs_to_relations = array();
3493
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3494
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3493
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3494
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3495 3495
 				$belongs_to_relations[$model_name] = $relation_obj;
3496 3496
 			}
3497 3497
 		}
@@ -3506,15 +3506,15 @@  discard block
 block discarded – undo
3506 3506
 	 * @throws EE_Error
3507 3507
 	 * @return EE_Model_Relation_Base
3508 3508
 	 */
3509
-	public function related_settings_for($relation_name){
3510
-		$relatedModels=$this->relation_settings();
3511
-		if(!array_key_exists($relation_name,$relatedModels)){
3509
+	public function related_settings_for($relation_name) {
3510
+		$relatedModels = $this->relation_settings();
3511
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3512 3512
 			throw new EE_Error(
3513 3513
 				sprintf(
3514
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3514
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3515 3515
 					$relation_name,
3516 3516
 					$this->_get_class_name(),
3517
-					implode( ', ', array_keys( $relatedModels ))
3517
+					implode(', ', array_keys($relatedModels))
3518 3518
 				)
3519 3519
 			);
3520 3520
 		}
@@ -3529,10 +3529,10 @@  discard block
 block discarded – undo
3529 3529
 	 * @throws EE_Error
3530 3530
 	 * @return EE_Model_Field_Base
3531 3531
 	 */
3532
-	public function field_settings_for($fieldName){
3533
-		$fieldSettings=$this->field_settings(true);
3534
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3535
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3532
+	public function field_settings_for($fieldName) {
3533
+		$fieldSettings = $this->field_settings(true);
3534
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3535
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3536 3536
 		}
3537 3537
 		return $fieldSettings[$fieldName];
3538 3538
 	}
@@ -3542,11 +3542,11 @@  discard block
 block discarded – undo
3542 3542
 	 * @param string $fieldName a key in the model's _field_settings array
3543 3543
 	 * @return boolean
3544 3544
 	 */
3545
-	public function has_field($fieldName){
3545
+	public function has_field($fieldName) {
3546 3546
 		$fieldSettings = $this->field_settings(true);
3547
-		if( isset($fieldSettings[$fieldName])){
3547
+		if (isset($fieldSettings[$fieldName])) {
3548 3548
 			return true;
3549
-		}else{
3549
+		} else {
3550 3550
 			return false;
3551 3551
 		}
3552 3552
 	}
@@ -3556,11 +3556,11 @@  discard block
 block discarded – undo
3556 3556
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3557 3557
 	 * @return boolean
3558 3558
 	 */
3559
-	public function has_relation($relation_name){
3559
+	public function has_relation($relation_name) {
3560 3560
 		$relations = $this->relation_settings();
3561
-		if(isset($relations[$relation_name])){
3561
+		if (isset($relations[$relation_name])) {
3562 3562
 			return true;
3563
-		}else{
3563
+		} else {
3564 3564
 			return false;
3565 3565
 		}
3566 3566
 	}
@@ -3572,7 +3572,7 @@  discard block
 block discarded – undo
3572 3572
 	 * @param $field_obj
3573 3573
 	 * @return EE_Model_Field_Base
3574 3574
 	 */
3575
-	public function is_primary_key_field( $field_obj ){
3575
+	public function is_primary_key_field($field_obj) {
3576 3576
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3577 3577
 	}
3578 3578
 
@@ -3584,16 +3584,16 @@  discard block
 block discarded – undo
3584 3584
 	 * @return EE_Model_Field_Base
3585 3585
 	 * @throws EE_Error
3586 3586
 	 */
3587
-	public function get_primary_key_field(){
3588
-		if( $this->_primary_key_field === NULL ){
3589
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3590
-				if( $this->is_primary_key_field( $field_obj )){
3587
+	public function get_primary_key_field() {
3588
+		if ($this->_primary_key_field === NULL) {
3589
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3590
+				if ($this->is_primary_key_field($field_obj)) {
3591 3591
 					$this->_primary_key_field = $field_obj;
3592 3592
 					break;
3593 3593
 				}
3594 3594
 			}
3595
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3596
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3595
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3596
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3597 3597
 			}
3598 3598
 		}
3599 3599
 		return $this->_primary_key_field;
@@ -3606,12 +3606,12 @@  discard block
 block discarded – undo
3606 3606
 	 * Internally does some caching.
3607 3607
 	 * @return boolean
3608 3608
 	 */
3609
-	public function has_primary_key_field(){
3610
-		if($this->_has_primary_key_field === null){
3611
-			try{
3609
+	public function has_primary_key_field() {
3610
+		if ($this->_has_primary_key_field === null) {
3611
+			try {
3612 3612
 				$this->get_primary_key_field();
3613 3613
 				$this->_has_primary_key_field = true;
3614
-			}catch(EE_Error $e){
3614
+			} catch (EE_Error $e) {
3615 3615
 				$this->_has_primary_key_field = false;
3616 3616
 			}
3617 3617
 		}
@@ -3625,9 +3625,9 @@  discard block
 block discarded – undo
3625 3625
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3626 3626
 	 * @return EE_Model_Field_Base or null if none is found
3627 3627
 	 */
3628
-	public function get_a_field_of_type($field_class_name){
3629
-		foreach($this->field_settings() as $field){
3630
-			if( $field instanceof $field_class_name ){
3628
+	public function get_a_field_of_type($field_class_name) {
3629
+		foreach ($this->field_settings() as $field) {
3630
+			if ($field instanceof $field_class_name) {
3631 3631
 				return $field;
3632 3632
 			}
3633 3633
 		}
@@ -3641,21 +3641,21 @@  discard block
 block discarded – undo
3641 3641
 	 * @return EE_Foreign_Key_Field_Base
3642 3642
 	 * @throws EE_Error
3643 3643
 	 */
3644
-	public function get_foreign_key_to($model_name){
3645
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3646
-			foreach($this->field_settings() as $field){
3644
+	public function get_foreign_key_to($model_name) {
3645
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3646
+			foreach ($this->field_settings() as $field) {
3647 3647
 //				if(is_subclass_of($field, 'EE_Foreign_Key_Field_Base')){
3648
-				if( $field instanceof EE_Foreign_Key_Field_Base ){
3649
-					if (in_array($model_name,$field->get_model_names_pointed_to() ) ) {
3650
-						$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3648
+				if ($field instanceof EE_Foreign_Key_Field_Base) {
3649
+					if (in_array($model_name, $field->get_model_names_pointed_to())) {
3650
+						$this->_cache_foreign_key_to_fields[$model_name] = $field;
3651 3651
 					}
3652 3652
 				}
3653 3653
 			}
3654
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3655
-				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this)));
3654
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3655
+				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this)));
3656 3656
 			}
3657 3657
 		}
3658
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3658
+		return $this->_cache_foreign_key_to_fields[$model_name];
3659 3659
 	}
3660 3660
 
3661 3661
 
@@ -3666,7 +3666,7 @@  discard block
 block discarded – undo
3666 3666
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3667 3667
 	 * @return EE_Table_Base
3668 3668
 	 */
3669
-	function get_table_for_alias($table_alias){
3669
+	function get_table_for_alias($table_alias) {
3670 3670
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3671 3671
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3672 3672
 	}
@@ -3679,25 +3679,25 @@  discard block
 block discarded – undo
3679 3679
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
3680 3680
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
3681 3681
 	 */
3682
-	public function field_settings($include_db_only_fields = false){
3683
-		if( $include_db_only_fields ){
3684
-			if( $this->_cached_fields === NULL ){
3682
+	public function field_settings($include_db_only_fields = false) {
3683
+		if ($include_db_only_fields) {
3684
+			if ($this->_cached_fields === NULL) {
3685 3685
 				$this->_cached_fields = array();
3686
-				foreach($this->_fields as $fields_corresponding_to_table){
3687
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3688
-						$this->_cached_fields[$field_name]=$field_obj;
3686
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3687
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3688
+						$this->_cached_fields[$field_name] = $field_obj;
3689 3689
 					}
3690 3690
 				}
3691 3691
 			}
3692 3692
 			return $this->_cached_fields;
3693
-		}else{
3694
-			if( $this->_cached_fields_non_db_only === NULL ){
3693
+		} else {
3694
+			if ($this->_cached_fields_non_db_only === NULL) {
3695 3695
 				$this->_cached_fields_non_db_only = array();
3696
-				foreach($this->_fields as $fields_corresponding_to_table){
3697
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3696
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3697
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3698 3698
 						/** @var $field_obj EE_Model_Field_Base */
3699
-						if( ! $field_obj->is_db_only_field() ){
3700
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
3699
+						if ( ! $field_obj->is_db_only_field()) {
3700
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
3701 3701
 						}
3702 3702
 					}
3703 3703
 				}
@@ -3716,67 +3716,67 @@  discard block
 block discarded – undo
3716 3716
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3717 3717
 	 * @throws \EE_Error
3718 3718
 	 */
3719
-	protected function _create_objects( $rows = array() ) {
3720
-		$array_of_objects=array();
3721
-		if(empty($rows)){
3719
+	protected function _create_objects($rows = array()) {
3720
+		$array_of_objects = array();
3721
+		if (empty($rows)) {
3722 3722
 			return array();
3723 3723
 		}
3724 3724
 		$count_if_model_has_no_primary_key = 0;
3725 3725
 		$has_primary_key = $this->has_primary_key_field();
3726
-		if( $has_primary_key ) {
3726
+		if ($has_primary_key) {
3727 3727
 			$primary_key_field = $this->get_primary_key_field();
3728 3728
 		} else {
3729 3729
 			$primary_key_field = null;
3730 3730
 		}
3731
-		foreach ( $rows as $row ) {
3732
-			if(empty($row)){
3731
+		foreach ($rows as $row) {
3732
+			if (empty($row)) {
3733 3733
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3734 3734
 				return array();
3735 3735
 			}
3736 3736
 			//check if we've already set this object in the results array,
3737 3737
 			//in which case there's no need to process it further (again)
3738
-			if( $has_primary_key ) {
3738
+			if ($has_primary_key) {
3739 3739
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
3740 3740
 					$row,
3741 3741
 					$primary_key_field->get_qualified_column(),
3742 3742
 					$primary_key_field->get_table_column()
3743 3743
 				);
3744
-				if( $table_pk_value &&
3745
-					isset( $array_of_objects[ $table_pk_value ] ) ) {
3744
+				if ($table_pk_value &&
3745
+					isset($array_of_objects[$table_pk_value])) {
3746 3746
 					continue;
3747 3747
 				}
3748 3748
 			}
3749
-			$classInstance=$this->instantiate_class_from_array_or_object($row);
3750
-			if( ! $classInstance ) {
3749
+			$classInstance = $this->instantiate_class_from_array_or_object($row);
3750
+			if ( ! $classInstance) {
3751 3751
 				throw new EE_Error(
3752 3752
 					sprintf(
3753
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
3753
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
3754 3754
 						$this->get_this_model_name(),
3755
-						http_build_query( $row )
3755
+						http_build_query($row)
3756 3756
 					)
3757 3757
 				);
3758 3758
 			}
3759 3759
 			//set the timezone on the instantiated objects
3760
-			$classInstance->set_timezone( $this->_timezone );
3760
+			$classInstance->set_timezone($this->_timezone);
3761 3761
 			//make sure if there is any timezone setting present that we set the timezone for the object
3762 3762
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
3763
-			$array_of_objects[ $key ] = $classInstance;
3763
+			$array_of_objects[$key] = $classInstance;
3764 3764
 			//also, for all the relations of type BelongsTo, see if we can cache
3765 3765
 			//those related models
3766 3766
 			//(we could do this for other relations too, but if there are conditions
3767 3767
 			//that filtered out some fo the results, then we'd be caching an incomplete set
3768 3768
 			//so it requires a little more thought than just caching them immediately...)
3769
-			foreach($this->_model_relations as $modelName => $relation_obj){
3770
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
3769
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
3770
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
3771 3771
 					//check if this model's INFO is present. If so, cache it on the model
3772 3772
 					$other_model = $relation_obj->get_other_model();
3773 3773
 
3774 3774
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
3775 3775
 
3776 3776
 					//if we managed to make a model object from the results, cache it on the main model object
3777
-					if( $other_model_obj_maybe ){
3777
+					if ($other_model_obj_maybe) {
3778 3778
 						//set timezone on these other model objects if they are present
3779
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
3779
+						$other_model_obj_maybe->set_timezone($this->_timezone);
3780 3780
 						$classInstance->cache($modelName, $other_model_obj_maybe);
3781 3781
 					}
3782 3782
 				}
@@ -3797,12 +3797,12 @@  discard block
 block discarded – undo
3797 3797
 
3798 3798
 		$this_model_fields_and_values = array();
3799 3799
 		//setup the row using default values;
3800
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
3800
+		foreach ($this->field_settings() as $field_name => $field_obj) {
3801 3801
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
3802 3802
 		}
3803 3803
 
3804 3804
 		$className = $this->_get_class_name();
3805
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
3805
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
3806 3806
 
3807 3807
 		return $classInstance;
3808 3808
 	}
@@ -3815,40 +3815,40 @@  discard block
 block discarded – undo
3815 3815
 	 * or an stdClass where each property is the name of a column,
3816 3816
 	 * @return EE_Base_Class
3817 3817
 	 */
3818
-	public function instantiate_class_from_array_or_object($cols_n_values){
3819
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
3820
-			$cols_n_values = get_object_vars( $cols_n_values );
3818
+	public function instantiate_class_from_array_or_object($cols_n_values) {
3819
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
3820
+			$cols_n_values = get_object_vars($cols_n_values);
3821 3821
 		}
3822 3822
 		$primary_key = NULL;
3823 3823
 		//make sure the array only has keys that are fields/columns on this model
3824
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3825
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
3826
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
3824
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3825
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
3826
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
3827 3827
 		}
3828
-		$className=$this->_get_class_name();
3828
+		$className = $this->_get_class_name();
3829 3829
 
3830 3830
 		//check we actually found results that we can use to build our model object
3831 3831
 		//if not, return null
3832
-		if( $this->has_primary_key_field()){
3833
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3832
+		if ($this->has_primary_key_field()) {
3833
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
3834 3834
 				return NULL;
3835 3835
 			}
3836 3836
 		}
3837 3837
 
3838 3838
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
3839
-		if ( $primary_key){
3840
-			$classInstance = $this->get_from_entity_map( $primary_key );
3841
-			if( ! $classInstance) {
3842
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3839
+		if ($primary_key) {
3840
+			$classInstance = $this->get_from_entity_map($primary_key);
3841
+			if ( ! $classInstance) {
3842
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3843 3843
 				// add this new object to the entity map
3844
-				$classInstance = $this->add_to_entity_map( $classInstance );
3844
+				$classInstance = $this->add_to_entity_map($classInstance);
3845 3845
 			}
3846
-		}else{
3847
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3846
+		} else {
3847
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3848 3848
 		}
3849 3849
 
3850 3850
 			//it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example).  In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property.
3851
-		$this->set_timezone( $classInstance->get_timezone() );
3851
+		$this->set_timezone($classInstance->get_timezone());
3852 3852
 		return $classInstance;
3853 3853
 	}
3854 3854
 	/**
@@ -3856,8 +3856,8 @@  discard block
 block discarded – undo
3856 3856
 	 * @param int|string $id the ID of the model object
3857 3857
 	 * @return EE_Base_Class
3858 3858
 	 */
3859
-	public function get_from_entity_map( $id ){
3860
-		return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL;
3859
+	public function get_from_entity_map($id) {
3860
+		return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL;
3861 3861
 	}
3862 3862
 
3863 3863
 
@@ -3876,21 +3876,21 @@  discard block
 block discarded – undo
3876 3876
 	 * @throws EE_Error
3877 3877
 	 * @return \EE_Base_Class
3878 3878
 	 */
3879
-	public function add_to_entity_map( EE_Base_Class $object) {
3879
+	public function add_to_entity_map(EE_Base_Class $object) {
3880 3880
 		$className = $this->_get_class_name();
3881
-		if( ! $object instanceof $className ){
3882
-			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) );
3881
+		if ( ! $object instanceof $className) {
3882
+			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className));
3883 3883
 		}
3884 3884
 		/** @var $object EE_Base_Class */
3885
-		if ( ! $object->ID() ){
3886
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
3885
+		if ( ! $object->ID()) {
3886
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
3887 3887
 		}
3888 3888
 		// double check it's not already there
3889
-		$classInstance = $this->get_from_entity_map( $object->ID() );
3890
-		if ( $classInstance ) {
3889
+		$classInstance = $this->get_from_entity_map($object->ID());
3890
+		if ($classInstance) {
3891 3891
 			return $classInstance;
3892 3892
 		} else {
3893
-			$this->_entity_map[ $object->ID() ] = $object;
3893
+			$this->_entity_map[$object->ID()] = $object;
3894 3894
 			return $object;
3895 3895
 		}
3896 3896
 	}
@@ -3903,8 +3903,8 @@  discard block
 block discarded – undo
3903 3903
 	 * @param array $cols_n_values
3904 3904
 	 * @return array
3905 3905
 	 */
3906
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
3907
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3906
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3907
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3908 3908
 	}
3909 3909
 
3910 3910
 
@@ -3917,40 +3917,40 @@  discard block
 block discarded – undo
3917 3917
 	 * @param string $cols_n_values
3918 3918
 	 * @return array
3919 3919
 	 */
3920
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
3920
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3921 3921
 		$this_model_fields_n_values = array();
3922
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
3923
-			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() );
3922
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
3923
+			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column());
3924 3924
 			//there is a primary key on this table and its not set. Use defaults for all its columns
3925
-			if( $table_obj->get_pk_column() && $table_pk_value === NULL ){
3926
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3927
-					if( ! $field_obj->is_db_only_field() ){
3925
+			if ($table_obj->get_pk_column() && $table_pk_value === NULL) {
3926
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3927
+					if ( ! $field_obj->is_db_only_field()) {
3928 3928
 						//prepare field as if its coming from db
3929
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
3930
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
3929
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
3930
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
3931 3931
 					}
3932 3932
 				}
3933
-			}else{
3933
+			} else {
3934 3934
 				//the table's rows existed. Use their values
3935
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3936
-					if( ! $field_obj->is_db_only_field() )
3937
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3935
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3936
+					if ( ! $field_obj->is_db_only_field())
3937
+					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column());
3938 3938
 				}
3939 3939
 			}
3940 3940
 		}
3941 3941
 		return $this_model_fields_n_values;
3942 3942
 	}
3943 3943
 
3944
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
3944
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
3945 3945
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
3946 3946
 		//does the field on the model relate to this column retrieved from the db?
3947 3947
 		//or is it a db-only field? (not relating to the model)
3948
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
3949
-			$value = $cols_n_values[ $qualified_column ];
3948
+		if (isset($cols_n_values[$qualified_column])) {
3949
+			$value = $cols_n_values[$qualified_column];
3950 3950
 
3951
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3952
-			$value = $cols_n_values[ $regular_column ];
3953
-		}else{
3951
+		}elseif (isset($cols_n_values[$regular_column])) {
3952
+			$value = $cols_n_values[$regular_column];
3953
+		} else {
3954 3954
 			$value = NULL;
3955 3955
 		}
3956 3956
 
@@ -3968,23 +3968,23 @@  discard block
 block discarded – undo
3968 3968
 	 * @param int|string $id
3969 3969
 	 * @return EE_Base_Class
3970 3970
 	 */
3971
-	public function refresh_entity_map_from_db( $id ){
3972
-		$obj_in_map = $this->get_from_entity_map( $id );
3973
-		if( $obj_in_map ){
3974
-			$wpdb_results = $this->_get_all_wpdb_results( array( array ( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) );
3975
-			if( $wpdb_results && is_array( $wpdb_results ) ){
3976
-				$one_row = reset( $wpdb_results );
3977
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
3978
-					$obj_in_map->set_from_db( $field_name, $db_value );
3971
+	public function refresh_entity_map_from_db($id) {
3972
+		$obj_in_map = $this->get_from_entity_map($id);
3973
+		if ($obj_in_map) {
3974
+			$wpdb_results = $this->_get_all_wpdb_results(array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1));
3975
+			if ($wpdb_results && is_array($wpdb_results)) {
3976
+				$one_row = reset($wpdb_results);
3977
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
3978
+					$obj_in_map->set_from_db($field_name, $db_value);
3979 3979
 				}
3980 3980
 				//clear the cache of related model objects
3981
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3982
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3981
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3982
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3983 3983
 				}
3984 3984
 			}
3985 3985
 			return $obj_in_map;
3986
-		}else{
3987
-			return $this->get_one_by_ID( $id );
3986
+		} else {
3987
+			return $this->get_one_by_ID($id);
3988 3988
 		}
3989 3989
 	}
3990 3990
 
@@ -4002,24 +4002,24 @@  discard block
 block discarded – undo
4002 4002
 	 * @param EE_Base_Class $replacing_model_obj
4003 4003
 	 * @return \EE_Base_Class
4004 4004
 	 */
4005
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
4006
-		$obj_in_map = $this->get_from_entity_map( $id );
4007
-		if( $obj_in_map ){
4008
-			if( $replacing_model_obj instanceof EE_Base_Class ){
4009
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
4010
-					$obj_in_map->set( $field_name, $value );
4005
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
4006
+		$obj_in_map = $this->get_from_entity_map($id);
4007
+		if ($obj_in_map) {
4008
+			if ($replacing_model_obj instanceof EE_Base_Class) {
4009
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
4010
+					$obj_in_map->set($field_name, $value);
4011 4011
 				}
4012 4012
 				//make the model object in the entity map's cache match the $replacing_model_obj
4013
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4014
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4015
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
4016
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
4013
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4014
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4015
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
4016
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
4017 4017
 					}
4018 4018
 				}
4019 4019
 			}
4020 4020
 			return $obj_in_map;
4021
-		}else{
4022
-			$this->add_to_entity_map( $replacing_model_obj );
4021
+		} else {
4022
+			$this->add_to_entity_map($replacing_model_obj);
4023 4023
 			return $replacing_model_obj;
4024 4024
 		}
4025 4025
 	}
@@ -4032,7 +4032,7 @@  discard block
 block discarded – undo
4032 4032
 	 * require_once($this->_getClassName().".class.php");
4033 4033
 	 * @return string
4034 4034
 	 */
4035
-	private function _get_class_name(){
4035
+	private function _get_class_name() {
4036 4036
 		return "EE_".$this->get_this_model_name();
4037 4037
 	}
4038 4038
 
@@ -4045,10 +4045,10 @@  discard block
 block discarded – undo
4045 4045
 	 * @param int $quantity
4046 4046
 	 * @return string
4047 4047
 	 */
4048
-	public function item_name($quantity = 1){
4049
-		if($quantity == 1){
4048
+	public function item_name($quantity = 1) {
4049
+		if ($quantity == 1) {
4050 4050
 			return $this->singular_item;
4051
-		}else{
4051
+		} else {
4052 4052
 			return $this->plural_item;
4053 4053
 		}
4054 4054
 	}
@@ -4077,13 +4077,13 @@  discard block
 block discarded – undo
4077 4077
 	 * @throws EE_Error
4078 4078
 	 * @return mixed whatever the plugin which calls add_filter decides
4079 4079
 	 */
4080
-	public function __call($methodName,$args){
4081
-		$className=get_class($this);
4082
-		$tagName="FHEE__{$className}__{$methodName}";
4083
-		if(!has_filter($tagName)){
4080
+	public function __call($methodName, $args) {
4081
+		$className = get_class($this);
4082
+		$tagName = "FHEE__{$className}__{$methodName}";
4083
+		if ( ! has_filter($tagName)) {
4084 4084
 			throw new EE_Error(
4085 4085
 				sprintf(
4086
-					__( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ),
4086
+					__('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'),
4087 4087
 					$methodName,
4088 4088
 					$className,
4089 4089
 					$tagName,
@@ -4092,7 +4092,7 @@  discard block
 block discarded – undo
4092 4092
 			);
4093 4093
 		}
4094 4094
 
4095
-		return apply_filters($tagName,null,$this,$args);
4095
+		return apply_filters($tagName, null, $this, $args);
4096 4096
 	}
4097 4097
 
4098 4098
 
@@ -4105,22 +4105,22 @@  discard block
 block discarded – undo
4105 4105
 	 * @throws EE_Error
4106 4106
 	 * @return EE_Base_Class
4107 4107
 	 */
4108
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4108
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4109 4109
 		$className = $this->_get_class_name();
4110 4110
 		$primary_key_field = $this->get_primary_key_field();
4111
-		if( $base_class_obj_or_id instanceof $className ){
4111
+		if ($base_class_obj_or_id instanceof $className) {
4112 4112
 			$model_object = $base_class_obj_or_id;
4113
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4114
-				is_int( $base_class_obj_or_id ) ||
4115
-				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4113
+		}elseif ($primary_key_field instanceof EE_Primary_Key_Int_Field && (
4114
+				is_int($base_class_obj_or_id) ||
4115
+				is_string($base_class_obj_or_id) )) {//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4116 4116
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4117
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4117
+		}elseif ($primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id)) {
4118 4118
 			//assume its a string representation of the object
4119 4119
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4120
-		}else{
4121
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4120
+		} else {
4121
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4122 4122
 		}
4123
-		if( $model_object->ID() == NULL && $ensure_is_in_db){
4123
+		if ($model_object->ID() == NULL && $ensure_is_in_db) {
4124 4124
 			$model_object->save();
4125 4125
 		}
4126 4126
 		return $model_object;
@@ -4136,19 +4136,19 @@  discard block
 block discarded – undo
4136 4136
 	 * @return int|string depending on the type of this model object's ID
4137 4137
 	 * @throws EE_Error
4138 4138
 	 */
4139
-	public function ensure_is_ID($base_class_obj_or_id){
4139
+	public function ensure_is_ID($base_class_obj_or_id) {
4140 4140
 		$className = $this->_get_class_name();
4141
-		if( $base_class_obj_or_id instanceof $className ){
4141
+		if ($base_class_obj_or_id instanceof $className) {
4142 4142
 			/** @var $base_class_obj_or_id EE_Base_Class */
4143 4143
 			$id = $base_class_obj_or_id->ID();
4144
-		}elseif(is_int($base_class_obj_or_id)){
4144
+		}elseif (is_int($base_class_obj_or_id)) {
4145 4145
 			//assume it's an ID
4146 4146
 			$id = $base_class_obj_or_id;
4147
-		}elseif(is_string($base_class_obj_or_id)){
4147
+		}elseif (is_string($base_class_obj_or_id)) {
4148 4148
 			//assume its a string representation of the object
4149 4149
 			$id = $base_class_obj_or_id;
4150
-		}else{
4151
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4150
+		} else {
4151
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4152 4152
 		}
4153 4153
 		return $id;
4154 4154
 	}
@@ -4171,14 +4171,14 @@  discard block
 block discarded – undo
4171 4171
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4172 4172
 	 * @return void
4173 4173
 	 */
4174
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4174
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4175 4175
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4176 4176
 	}
4177 4177
 	/**
4178 4178
 	 * Read comments for assume_values_already_prepared_by_model_object()
4179 4179
 	 * @return int
4180 4180
 	 */
4181
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4181
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4182 4182
 		return $this->_values_already_prepared_by_model_object;
4183 4183
 	}
4184 4184
 
@@ -4186,17 +4186,17 @@  discard block
 block discarded – undo
4186 4186
 	 * Gets all the indexes on this model
4187 4187
 	 * @return EE_Index[]
4188 4188
 	 */
4189
-	public function indexes(){
4189
+	public function indexes() {
4190 4190
 		return $this->_indexes;
4191 4191
 	}
4192 4192
 	/**
4193 4193
 	 * Gets all the Unique Indexes on this model
4194 4194
 	 * @return EE_Unique_Index[]
4195 4195
 	 */
4196
-	public function unique_indexes(){
4196
+	public function unique_indexes() {
4197 4197
 		$unique_indexes = array();
4198
-		foreach($this->_indexes as $name => $index){
4199
-			if($index instanceof EE_Unique_Index){
4198
+		foreach ($this->_indexes as $name => $index) {
4199
+			if ($index instanceof EE_Unique_Index) {
4200 4200
 				$unique_indexes [$name] = $index;
4201 4201
 			}
4202 4202
 		}
@@ -4209,9 +4209,9 @@  discard block
 block discarded – undo
4209 4209
 	 * on a primary index
4210 4210
 	 * @return EE_Model_Field_Base[]
4211 4211
 	 */
4212
-	public function get_combined_primary_key_fields(){
4213
-		foreach($this->indexes() as $index){
4214
-			if($index instanceof EE_Primary_Key_Index){
4212
+	public function get_combined_primary_key_fields() {
4213
+		foreach ($this->indexes() as $index) {
4214
+			if ($index instanceof EE_Primary_Key_Index) {
4215 4215
 				return $index->fields();
4216 4216
 			}
4217 4217
 		}
@@ -4224,7 +4224,7 @@  discard block
 block discarded – undo
4224 4224
 	 * @param array $cols_n_values keys are field names, values are their values
4225 4225
 	 * @return string
4226 4226
 	 */
4227
-	public function get_index_primary_key_string($cols_n_values){
4227
+	public function get_index_primary_key_string($cols_n_values) {
4228 4228
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4229 4229
 		return http_build_query($cols_n_values_for_primary_key_index);
4230 4230
 	}
@@ -4236,13 +4236,13 @@  discard block
 block discarded – undo
4236 4236
 	 * @param string $index_primary_key_string
4237 4237
 	 * @return null|array
4238 4238
 	 */
4239
-	function parse_index_primary_key_string( $index_primary_key_string) {
4239
+	function parse_index_primary_key_string($index_primary_key_string) {
4240 4240
 		$key_fields = $this->get_combined_primary_key_fields();
4241 4241
 		//check all of them are in the $id
4242 4242
 		$key_vals_in_combined_pk = array();
4243
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4244
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4245
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4243
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4244
+		foreach ($key_fields as $key_field_name => $field_obj) {
4245
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4246 4246
 				return NULL;
4247 4247
 			}
4248 4248
 		}
@@ -4255,10 +4255,10 @@  discard block
 block discarded – undo
4255 4255
 	 * @param array $key_vals
4256 4256
 	 * @return boolean
4257 4257
 	 */
4258
-	function has_all_combined_primary_key_fields( $key_vals ) {
4259
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4260
-		foreach( $keys_it_should_have as $key ){
4261
-			if( ! isset( $key_vals[ $key ] ) ){
4258
+	function has_all_combined_primary_key_fields($key_vals) {
4259
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4260
+		foreach ($keys_it_should_have as $key) {
4261
+			if ( ! isset($key_vals[$key])) {
4262 4262
 				return false;
4263 4263
 			}
4264 4264
 		}
@@ -4274,23 +4274,23 @@  discard block
 block discarded – undo
4274 4274
 	 * @throws EE_Error
4275 4275
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4276 4276
 	 */
4277
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4277
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4278 4278
 
4279
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4279
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4280 4280
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4281
-		}elseif(is_array($model_object_or_attributes_array)){
4281
+		}elseif (is_array($model_object_or_attributes_array)) {
4282 4282
 			$attributes_array = $model_object_or_attributes_array;
4283
-		}else{
4284
-			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4283
+		} else {
4284
+			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array));
4285 4285
 		}
4286 4286
 		//even copies obviously won't have the same ID, so remove the primary key
4287 4287
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4288
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4288
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4289 4289
 			unset($attributes_array[$this->primary_key_name()]);
4290 4290
 		}
4291
-		if(isset($query_params[0])){
4292
-			$query_params[0] = array_merge($attributes_array,$query_params);
4293
-		}else{
4291
+		if (isset($query_params[0])) {
4292
+			$query_params[0] = array_merge($attributes_array, $query_params);
4293
+		} else {
4294 4294
 			$query_params[0] = $attributes_array;
4295 4295
 		}
4296 4296
 		return $this->get_all($query_params);
@@ -4304,16 +4304,16 @@  discard block
 block discarded – undo
4304 4304
 	 * @param array $query_params
4305 4305
 	 * @return EE_Base_Class
4306 4306
 	 */
4307
-	function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4308
-		if( ! is_array( $query_params ) ){
4309
-			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
4307
+	function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4308
+		if ( ! is_array($query_params)) {
4309
+			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
4310 4310
 			$query_params = array();
4311 4311
 		}
4312 4312
 		$query_params['limit'] = 1;
4313
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4314
-		if(is_array($copies)){
4313
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4314
+		if (is_array($copies)) {
4315 4315
 			return array_shift($copies);
4316
-		}else{
4316
+		} else {
4317 4317
 			return null;
4318 4318
 		}
4319 4319
 	}
@@ -4327,10 +4327,10 @@  discard block
 block discarded – undo
4327 4327
 	 * @param int|string $id the value of the primary key to update
4328 4328
 	 * @return int number of rows updated
4329 4329
 	 */
4330
-	public function update_by_ID($fields_n_values,$id){
4330
+	public function update_by_ID($fields_n_values, $id) {
4331 4331
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4332 4332
 			'default_where_conditions'=>'other_models_only',);
4333
-		return $this->update($fields_n_values,$query_params);
4333
+		return $this->update($fields_n_values, $query_params);
4334 4334
 	}
4335 4335
 
4336 4336
 
@@ -4341,12 +4341,12 @@  discard block
 block discarded – undo
4341 4341
 	 * @return string an operator which can be used in SQL
4342 4342
 	 * @throws EE_Error
4343 4343
 	 */
4344
-	private function _prepare_operator_for_sql($operator_supplied){
4344
+	private function _prepare_operator_for_sql($operator_supplied) {
4345 4345
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4346
-		if($sql_operator){
4346
+		if ($sql_operator) {
4347 4347
 			return $sql_operator;
4348
-		}else{
4349
-			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4348
+		} else {
4349
+			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators))));
4350 4350
 		}
4351 4351
 	}
4352 4352
 
@@ -4356,10 +4356,10 @@  discard block
 block discarded – undo
4356 4356
 	 * @param array $query_params like get_all's
4357 4357
 	 * @return string[]
4358 4358
 	 */
4359
-	public function get_all_names($query_params = array()){
4359
+	public function get_all_names($query_params = array()) {
4360 4360
 		$objs = $this->get_all($query_params);
4361 4361
 		$names = array();
4362
-		foreach($objs as $obj){
4362
+		foreach ($objs as $obj) {
4363 4363
 			$names[$obj->ID()] = $obj->name();
4364 4364
 		}
4365 4365
 		return $names;
@@ -4374,22 +4374,22 @@  discard block
 block discarded – undo
4374 4374
 	 * @param boolean $filter_out_empty_ids if a model object has an ID of '' or 0, don't bother including it in the returned array
4375 4375
 	 * @return array
4376 4376
 	 */
4377
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4378
-		if( ! $this->has_primary_key_field() ) {
4379
-			if( WP_DEBUG ) {
4380
-				EE_Error::add_error( __( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
4377
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4378
+		if ( ! $this->has_primary_key_field()) {
4379
+			if (WP_DEBUG) {
4380
+				EE_Error::add_error(__('Trying to get IDs from a model than has no primary key', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
4381 4381
 				return array();
4382 4382
 			}
4383 4383
 		}
4384 4384
 		$IDs = array();
4385
-		foreach( $model_objects as $model_object ) {
4385
+		foreach ($model_objects as $model_object) {
4386 4386
 			$id = $model_object->ID();
4387
-			if( ! $id ) {
4388
-				if( $filter_out_empty_ids ) {
4387
+			if ( ! $id) {
4388
+				if ($filter_out_empty_ids) {
4389 4389
 					continue;
4390 4390
 				}
4391
-				if( WP_DEBUG ) {
4392
-					EE_Error::add_error(__( 'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
4391
+				if (WP_DEBUG) {
4392
+					EE_Error::add_error(__('Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
4393 4393
 				}
4394 4394
 			}
4395 4395
 			$IDs[] = $id;
@@ -4402,8 +4402,8 @@  discard block
 block discarded – undo
4402 4402
 	 * are no capabilities that relate to this model returns false
4403 4403
 	 * @return string|false
4404 4404
 	 */
4405
-	public function cap_slug(){
4406
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4405
+	public function cap_slug() {
4406
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4407 4407
 	}
4408 4408
 
4409 4409
 	/**
@@ -4415,27 +4415,27 @@  discard block
 block discarded – undo
4415 4415
 	 * @param string $context
4416 4416
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4417 4417
 	 */
4418
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4419
-		EEM_Base::verify_is_valid_cap_context( $context );
4418
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4419
+		EEM_Base::verify_is_valid_cap_context($context);
4420 4420
 		//check if we ought to run the restriction generator first
4421
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
4422
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base &&
4423
-				! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions() ) {
4424
-			$this->_cap_restrictions[ $context ] = array_merge( $this->_cap_restrictions[ $context ],  $this->_cap_restriction_generators[ $context ]->generate_restrictions() );
4421
+		if (isset($this->_cap_restriction_generators[$context]) &&
4422
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base &&
4423
+				! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()) {
4424
+			$this->_cap_restrictions[$context] = array_merge($this->_cap_restrictions[$context], $this->_cap_restriction_generators[$context]->generate_restrictions());
4425 4425
 		}
4426 4426
 		//and make sure we've finalized the construction of each restriction
4427
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4428
-			$where_conditions_obj->_finalize_construct( $this );
4427
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4428
+			$where_conditions_obj->_finalize_construct($this);
4429 4429
 		}
4430 4430
 
4431
-		return $this->_cap_restrictions[ $context ];
4431
+		return $this->_cap_restrictions[$context];
4432 4432
 	}
4433 4433
 
4434 4434
 	/**
4435 4435
 	 * Indicating whether or not this model thinks its a wp core model
4436 4436
 	 * @return boolean
4437 4437
 	 */
4438
-	public function is_wp_core_model(){
4438
+	public function is_wp_core_model() {
4439 4439
 		return $this->_wp_core_model;
4440 4440
 	}
4441 4441
 
@@ -4445,12 +4445,12 @@  discard block
 block discarded – undo
4445 4445
 	 * @param string $context one of EEM_Base::caps_ constants
4446 4446
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4447 4447
 	 */
4448
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4448
+	public function caps_missing($context = EEM_Base::caps_read) {
4449 4449
 		$missing_caps = array();
4450
-		$cap_restrictions = $this->cap_restrictions( $context );
4451
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4452
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4453
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4450
+		$cap_restrictions = $this->cap_restrictions($context);
4451
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4452
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4453
+				$missing_caps[$cap] = $restriction_if_no_cap;
4454 4454
 			}
4455 4455
 		}
4456 4456
 		return $missing_caps;
@@ -4462,7 +4462,7 @@  discard block
 block discarded – undo
4462 4462
 	 * one of 'read', 'edit', or 'delete'
4463 4463
 	 */
4464 4464
 	public function cap_contexts_to_cap_action_map() {
4465
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4465
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4466 4466
 	}
4467 4467
 
4468 4468
 
@@ -4473,19 +4473,19 @@  discard block
 block discarded – undo
4473 4473
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4474 4474
 	 * @throws \EE_Error
4475 4475
 	 */
4476
-	public function cap_action_for_context( $context ) {
4476
+	public function cap_action_for_context($context) {
4477 4477
 		$mapping = $this->cap_contexts_to_cap_action_map();
4478
-		if( isset( $mapping[ $context ] ) ) {
4479
-			return $mapping[ $context ];
4478
+		if (isset($mapping[$context])) {
4479
+			return $mapping[$context];
4480 4480
 		}
4481
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4481
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4482 4482
 			return $action;
4483 4483
 		}
4484 4484
 		throw new EE_Error(
4485 4485
 			sprintf(
4486
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4486
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4487 4487
 				$context,
4488
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4488
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4489 4489
 			)
4490 4490
 		);
4491 4491
 
@@ -4496,7 +4496,7 @@  discard block
 block discarded – undo
4496 4496
 	 * @return array
4497 4497
 	 */
4498 4498
 	static public function valid_cap_contexts() {
4499
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4499
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4500 4500
 			self::caps_read,
4501 4501
 			self::caps_read_admin,
4502 4502
 			self::caps_edit,
@@ -4512,17 +4512,17 @@  discard block
 block discarded – undo
4512 4512
 	 * @return bool
4513 4513
 	 * @throws \EE_Error
4514 4514
 	 */
4515
-	static public function verify_is_valid_cap_context( $context ) {
4515
+	static public function verify_is_valid_cap_context($context) {
4516 4516
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4517
-		if( in_array( $context, $valid_cap_contexts ) ) {
4517
+		if (in_array($context, $valid_cap_contexts)) {
4518 4518
 			return true;
4519
-		}else{
4519
+		} else {
4520 4520
 			throw new EE_Error(
4521 4521
 				sprintf(
4522
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4522
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4523 4523
 					$context,
4524
-					'EEM_Base' ,
4525
-					implode(',', $valid_cap_contexts )
4524
+					'EEM_Base',
4525
+					implode(',', $valid_cap_contexts)
4526 4526
 				)
4527 4527
 			);
4528 4528
 		}
Please login to merge, or discard this patch.
Braces   +131 added lines, -120 removed lines patch added patch discarded remove patch
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
541 541
 				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
542 542
 			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
543
-		}else{
543
+		} else{
544 544
 			return array();
545 545
 		}
546 546
 }
@@ -591,8 +591,9 @@  discard block
 block discarded – undo
591 591
 	 * @return array
592 592
 	 */
593 593
 	 public function status_array( $translated = FALSE ) {
594
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
595
-	 		return array();
594
+	 	if ( !array_key_exists('Status', $this->_model_relations ) ) {
595
+	 		 		return array();
596
+	 	}
596 597
 	 	$model_name = $this->get_this_model_name();
597 598
 	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
598 599
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
@@ -771,13 +772,13 @@  discard block
 block discarded – undo
771 772
 				$last_model_name = end( $models_to_follow_to_wp_users );
772 773
 				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
773 774
 				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
774
-			}else{
775
+			} else{
775 776
 				$model_with_fk_to_wp_users = $this;
776 777
 				$model_chain_to_wp_user = '';
777 778
 			}
778 779
 			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
779 780
 			return $model_chain_to_wp_user . $wp_user_field->get_name();
780
-		}catch( EE_Error $e ) {
781
+		} catch( EE_Error $e ) {
781 782
 			return false;
782 783
 		}
783 784
 	}
@@ -805,11 +806,11 @@  discard block
 block discarded – undo
805 806
 	public function is_owned() {
806 807
 		if( $this->model_chain_to_wp_user() ){
807 808
 			return true;
808
-		}else{
809
+		} else{
809 810
 			try{
810 811
 				$this->get_foreign_key_to( 'WP_User' );
811 812
 				return true;
812
-			}catch( EE_Error $e ){
813
+			} catch( EE_Error $e ){
813 814
 				return false;
814 815
 			}
815 816
 		}
@@ -832,9 +833,9 @@  discard block
 block discarded – undo
832 833
 		//remember the custom selections, if any
833 834
 		if(is_array($columns_to_select)){
834 835
 			$this->_custom_selections = $columns_to_select;
835
-		}elseif(is_string($columns_to_select)){
836
+		} elseif(is_string($columns_to_select)){
836 837
 			$this->_custom_selections = array($this->_custom_selections);
837
-		}else{
838
+		} else{
838 839
 			$this->_custom_selections = array();
839 840
 		}
840 841
 
@@ -906,7 +907,7 @@  discard block
 block discarded – undo
906 907
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
907 908
 			}
908 909
 			$columns_to_select_string = implode(", ",$select_sql_array);
909
-		}else{
910
+		} else{
910 911
 			$columns_to_select_string = $columns_to_select;
911 912
 		}
912 913
 		return $columns_to_select_string;
@@ -956,7 +957,7 @@  discard block
 block discarded – undo
956 957
 		}
957 958
 		if( $this->has_primary_key_field ( ) ) {
958 959
 			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
959
-		}else{
960
+		} else{
960 961
 			//no primary key, so the $id must be from the get_index_primary_key_string()
961 962
 			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
962 963
 		}
@@ -979,7 +980,7 @@  discard block
 block discarded – undo
979 980
 		$items = $this->get_all($query_params);
980 981
 		if(empty($items)){
981 982
 			return null;
982
-		}else{
983
+		} else{
983 984
 			return array_shift($items);
984 985
 		}
985 986
 	}
@@ -1374,7 +1375,7 @@  discard block
 block discarded – undo
1374 1375
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1375 1376
 				if( $this->has_primary_key_field() ){
1376 1377
 					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1377
-				}else{
1378
+				} else{
1378 1379
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1379 1380
 					$main_table_pk_value = null;
1380 1381
 				}
@@ -1413,7 +1414,7 @@  discard block
 block discarded – undo
1413 1414
 		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1414 1415
 			if( $this->has_primary_key_field() ){
1415 1416
 				$model_objs_affected_ids = $this->get_col( $query_params );
1416
-			}else{
1417
+			} else{
1417 1418
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1418 1419
 				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1419 1420
 				$model_objs_affected_ids = array();
@@ -1473,9 +1474,9 @@  discard block
 block discarded – undo
1473 1474
 
1474 1475
 		if( $field_to_select ){
1475 1476
 			$field = $this->field_settings_for( $field_to_select );
1476
-		}elseif( $this->has_primary_key_field ( ) ){
1477
+		} elseif( $this->has_primary_key_field ( ) ){
1477 1478
 			$field = $this->get_primary_key_field();
1478
-		}else{
1479
+		} else{
1479 1480
 			//no primary key, just grab the first column
1480 1481
 			$field = reset( $this->field_settings());
1481 1482
 		}
@@ -1499,7 +1500,7 @@  discard block
 block discarded – undo
1499 1500
 		$col = $this->get_col( $query_params, $field_to_select );
1500 1501
 		if( ! empty( $col ) ) {
1501 1502
 			return reset( $col );
1502
-		}else{
1503
+		} else{
1503 1504
 			return NULL;
1504 1505
 		}
1505 1506
 	}
@@ -1614,7 +1615,7 @@  discard block
 block discarded – undo
1614 1615
 
1615 1616
 			//		/echo "delete sql:$SQL";
1616 1617
 			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1617
-		}else{
1618
+		} else{
1618 1619
 			$rows_deleted = 0;
1619 1620
 		}
1620 1621
 
@@ -1656,7 +1657,7 @@  discard block
 block discarded – undo
1656 1657
 		//first, if $ignore_this_model_obj was supplied, get its model
1657 1658
 		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1658 1659
 			$ignored_model = $ignore_this_model_obj->get_model();
1659
-		}else{
1660
+		} else{
1660 1661
 			$ignored_model = null;
1661 1662
 		}
1662 1663
 		//now check all the relations of $this_model_obj_or_id and see if there
@@ -1669,7 +1670,7 @@  discard block
 block discarded – undo
1669 1670
 				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1670 1671
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1671 1672
 					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1672
-				}else{
1673
+				} else{
1673 1674
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1674 1675
 				}
1675 1676
 
@@ -1706,24 +1707,28 @@  discard block
 block discarded – undo
1706 1707
 				}
1707 1708
 
1708 1709
 				//primary table deletes
1709
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1710
-					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1710
+				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) ) {
1711
+									$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1712
+				}
1711 1713
 
1712 1714
 				//other tables
1713 1715
 				if ( !empty( $other_tables ) ) {
1714 1716
 					foreach ( $other_tables as $ot ) {
1715 1717
 
1716 1718
 						//first check if we've got the foreign key column here.
1717
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1718
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1719
+						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) ) {
1720
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1721
+						}
1719 1722
 
1720 1723
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1721
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1722
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1724
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) ) {
1725
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1726
+						}
1723 1727
 
1724 1728
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1725
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1726
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1729
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) ) {
1730
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1731
+						}
1727 1732
 					}
1728 1733
 				}
1729 1734
 			}
@@ -1736,7 +1741,7 @@  discard block
 block discarded – undo
1736 1741
 			}
1737 1742
 
1738 1743
 			return !empty($query) ? implode(' AND ', $query ) : '';
1739
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1744
+		} elseif(count($this->get_combined_primary_key_fields()) > 1){
1740 1745
 			$ways_to_identify_a_row = array();
1741 1746
 			$fields = $this->get_combined_primary_key_fields();
1742 1747
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
@@ -1748,7 +1753,7 @@  discard block
 block discarded – undo
1748 1753
 				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1749 1754
 			}
1750 1755
 			return implode(" OR ",$ways_to_identify_a_row);
1751
-		}else{
1756
+		} else{
1752 1757
 			//so there's no primary key and no combined key...
1753 1758
 			//sorry, can't help you
1754 1759
 			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
@@ -1770,10 +1775,10 @@  discard block
 block discarded – undo
1770 1775
 		if($field_to_count){
1771 1776
 			$field_obj = $this->field_settings_for($field_to_count);
1772 1777
 			$column_to_count = $field_obj->get_qualified_column();
1773
-		}elseif($this->has_primary_key_field ()){
1778
+		} elseif($this->has_primary_key_field ()){
1774 1779
 			$pk_field_obj = $this->get_primary_key_field();
1775 1780
 			$column_to_count = $pk_field_obj->get_qualified_column();
1776
-		}else{//there's no primary key
1781
+		} else{//there's no primary key
1777 1782
 			$column_to_count = '*';
1778 1783
 		}
1779 1784
 
@@ -1795,7 +1800,7 @@  discard block
 block discarded – undo
1795 1800
 		if($field_to_sum){
1796 1801
 			$field_obj = $this->field_settings_for($field_to_sum);
1797 1802
 
1798
-		}else{
1803
+		} else{
1799 1804
 			$field_obj = $this->get_primary_key_field();
1800 1805
 		}
1801 1806
 		$column_to_count = $field_obj->get_qualified_column();
@@ -1804,7 +1809,7 @@  discard block
 block discarded – undo
1804 1809
 		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1805 1810
 		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1806 1811
 			return (float)$return_value;
1807
-		}else{//must be %f
1812
+		} else{//must be %f
1808 1813
 			return (float)$return_value;
1809 1814
 		}
1810 1815
 	}
@@ -1842,10 +1847,10 @@  discard block
 block discarded – undo
1842 1847
 			$wpdb->show_errors( $old_show_errors_value );
1843 1848
 			if( ! empty( $wpdb->last_error ) ){
1844 1849
 				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1845
-			}elseif( $result === false ){
1850
+			} elseif( $result === false ){
1846 1851
 				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1847 1852
 			}
1848
-		}elseif( $result === false ) {
1853
+		} elseif( $result === false ) {
1849 1854
 			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1850 1855
 		}
1851 1856
 		return $result;
@@ -2155,7 +2160,7 @@  discard block
 block discarded – undo
2155 2160
 		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2156 2161
 		if( $results ){
2157 2162
 			return array_shift($results);
2158
-		}else{
2163
+		} else{
2159 2164
 			return null;
2160 2165
 		}
2161 2166
 
@@ -2226,7 +2231,7 @@  discard block
 block discarded – undo
2226 2231
 			 */
2227 2232
 			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2228 2233
 			return $new_id;
2229
-		}else{
2234
+		} else{
2230 2235
 			return FALSE;
2231 2236
 		}
2232 2237
 	}
@@ -2267,9 +2272,9 @@  discard block
 block discarded – undo
2267 2272
 	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2268 2273
 		if($obj_or_fields_array instanceof EE_Base_Class){
2269 2274
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2270
-		}elseif( is_array($obj_or_fields_array)){
2275
+		} elseif( is_array($obj_or_fields_array)){
2271 2276
 			$fields_n_values = $obj_or_fields_array;
2272
-		}else{
2277
+		} else{
2273 2278
 			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
2274 2279
 		}
2275 2280
 		$query_params = array();
@@ -2285,7 +2290,7 @@  discard block
 block discarded – undo
2285 2290
 		//if there is nothing to base this search on, then we shouldn't find anything
2286 2291
 		if( empty( $query_params ) ){
2287 2292
 			return array();
2288
-		}else{
2293
+		} else{
2289 2294
 			return $this->get_one($query_params);
2290 2295
 		}
2291 2296
 	}
@@ -2358,12 +2363,12 @@  discard block
 block discarded – undo
2358 2363
 		if($this->has_primary_key_field()){
2359 2364
 			if($this->get_primary_key_field()->is_auto_increment()){
2360 2365
 				return $wpdb->insert_id;
2361
-			}else{
2366
+			} else{
2362 2367
 				//it's not an auto-increment primary key, so
2363 2368
 				//it must have been supplied
2364 2369
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2365 2370
 			}
2366
-		}else{
2371
+		} else{
2367 2372
 			//we can't return a  primary key because there is none. instead return
2368 2373
 			//a unique string indicating this model
2369 2374
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2411,7 +2416,7 @@  discard block
 block discarded – undo
2411 2416
 					//leave the value alone
2412 2417
 			}
2413 2418
 			return $value;
2414
-		}else{
2419
+		} else{
2415 2420
 			return $value;
2416 2421
 		}
2417 2422
 	}
@@ -2504,7 +2509,7 @@  discard block
 block discarded – undo
2504 2509
 		if(array_key_exists('group_by', $query_params)){
2505 2510
 			if(is_array($query_params['group_by'])){
2506 2511
 				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2507
-			}elseif( ! empty ( $query_params['group_by'] )){
2512
+			} elseif( ! empty ( $query_params['group_by'] )){
2508 2513
 				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2509 2514
 			}
2510 2515
 		}
@@ -2512,10 +2517,11 @@  discard block
 block discarded – undo
2512 2517
 			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2513 2518
 		}
2514 2519
 		if(array_key_exists('order_by', $query_params)){
2515
-			if ( is_array( $query_params['order_by'] ) )
2516
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2517
-			elseif( ! empty( $query_params['order_by'] ))
2518
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2520
+			if ( is_array( $query_params['order_by'] ) ) {
2521
+							$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2522
+			} elseif( ! empty( $query_params['order_by'] )) {
2523
+							$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2524
+			}
2519 2525
 		}
2520 2526
 		if(array_key_exists('force_join', $query_params)){
2521 2527
 			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
@@ -2547,10 +2553,10 @@  discard block
 block discarded – undo
2547 2553
 					if (! is_array($possibly_array_of_params)){
2548 2554
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2549 2555
 							$param,$possibly_array_of_params));
2550
-					}else{
2556
+					} else{
2551 2557
 						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2552 2558
 					}
2553
-				}elseif($query_param_type === 0 //ie WHERE
2559
+				} elseif($query_param_type === 0 //ie WHERE
2554 2560
 						&& is_array($possibly_array_of_params)
2555 2561
 						&& isset($possibly_array_of_params[2])
2556 2562
 						&& $possibly_array_of_params[2] == true){
@@ -2610,7 +2616,7 @@  discard block
 block discarded – undo
2610 2616
 		}
2611 2617
 		if( isset( $query_params[0] ) ) {
2612 2618
 			$where_query_params = $query_params[0];
2613
-		}else{
2619
+		} else{
2614 2620
 			$where_query_params = array();
2615 2621
 		}
2616 2622
 		//first check if we should alter the query to account for caps or not
@@ -2628,7 +2634,7 @@  discard block
 block discarded – undo
2628 2634
 		}
2629 2635
 		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2630 2636
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2631
-		}else{
2637
+		} else{
2632 2638
 			$use_default_where_conditions = 'all';
2633 2639
 		}
2634 2640
 		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
@@ -2651,7 +2657,7 @@  discard block
 block discarded – undo
2651 2657
 				}
2652 2658
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2653 2659
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2654
-			}elseif( ! empty ( $query_params['limit'] )){
2660
+			} elseif( ! empty ( $query_params['limit'] )){
2655 2661
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2656 2662
 			}
2657 2663
 		}
@@ -2673,11 +2679,11 @@  discard block
 block discarded – undo
2673 2679
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2674 2680
 				}
2675 2681
 				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2676
-			}elseif( ! empty ( $query_params['order_by'] )){
2682
+			} elseif( ! empty ( $query_params['order_by'] )){
2677 2683
 				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2678 2684
 				if(isset($query_params['order'])){
2679 2685
 					$order = $this->_extract_order($query_params['order']);
2680
-				}else{
2686
+				} else{
2681 2687
 					$order = 'DESC';
2682 2688
 				}
2683 2689
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2700,7 +2706,7 @@  discard block
 block discarded – undo
2700 2706
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2701 2707
 				}
2702 2708
 				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2703
-			}elseif( ! empty ( $query_params['group_by'] )){
2709
+			} elseif( ! empty ( $query_params['group_by'] )){
2704 2710
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2705 2711
 			}
2706 2712
 		}
@@ -2724,8 +2730,9 @@  discard block
 block discarded – undo
2724 2730
 			}
2725 2731
 		}
2726 2732
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2727
-		if ( empty( $main_model_join_sql ) )
2728
-			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2733
+		if ( empty( $main_model_join_sql ) ) {
2734
+					$query_object->set_main_model_join_sql($this->_construct_internal_join());
2735
+		}
2729 2736
 		return $query_object;
2730 2737
 	}
2731 2738
 
@@ -2758,7 +2765,7 @@  discard block
 block discarded – undo
2758 2765
 	private function _extract_order($should_be_order_string){
2759 2766
 		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2760 2767
 			return $should_be_order_string;
2761
-		}else{
2768
+		} else{
2762 2769
 			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2763 2770
 		}
2764 2771
 	}
@@ -2790,9 +2797,9 @@  discard block
 block discarded – undo
2790 2797
 		}
2791 2798
 		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2792 2799
 			$universal_query_params = $this->_get_default_where_conditions();
2793
-		}elseif( in_array( $use_default_where_conditions, array( 'minimum' ) ) ) {
2800
+		} elseif( in_array( $use_default_where_conditions, array( 'minimum' ) ) ) {
2794 2801
 			$universal_query_params = $this->_get_minimum_where_conditions();
2795
-		}else{
2802
+		} else{
2796 2803
 			$universal_query_params = array();
2797 2804
 		}
2798 2805
 
@@ -2832,14 +2839,14 @@  discard block
 block discarded – undo
2832 2839
 		foreach($default_where_conditions as $key => $val){
2833 2840
 			if( isset($provided_where_conditions[$key])){
2834 2841
 				$none_overridden = false;
2835
-			}else{
2842
+			} else{
2836 2843
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2837 2844
 			}
2838 2845
 		}
2839 2846
 		if( $none_overridden && $default_where_conditions){
2840 2847
 			if($model->has_primary_key_field()){
2841 2848
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2842
-			}else{
2849
+			} else{
2843 2850
 				//@todo NO PK, use other defaults
2844 2851
 			}
2845 2852
 		}
@@ -2855,8 +2862,9 @@  discard block
 block discarded – undo
2855 2862
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2856 2863
 	 */
2857 2864
 	private function _get_default_where_conditions($model_relation_path = null){
2858
-		if ( $this->_ignore_where_strategy )
2859
-			return array();
2865
+		if ( $this->_ignore_where_strategy ) {
2866
+					return array();
2867
+		}
2860 2868
 
2861 2869
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
2862 2870
 	}
@@ -2870,8 +2878,9 @@  discard block
 block discarded – undo
2870 2878
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2871 2879
 	 */
2872 2880
 	protected function _get_minimum_where_conditions($model_relation_path = null){
2873
-		if ( $this->_ignore_where_strategy )
2874
-			return array();
2881
+		if ( $this->_ignore_where_strategy ) {
2882
+					return array();
2883
+		}
2875 2884
 
2876 2885
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
2877 2886
 	}
@@ -2945,7 +2954,7 @@  discard block
 block discarded – undo
2945 2954
 		if(array_key_exists($query_param,$this_model_fields)){
2946 2955
 			if($allow_fields){
2947 2956
 				return;
2948
-			}else{
2957
+			} else{
2949 2958
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
2950 2959
 						$query_param,get_class($this),$query_param_type,$original_query_param));
2951 2960
 			}
@@ -2954,7 +2963,7 @@  discard block
 block discarded – undo
2954 2963
 		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2955 2964
 			if($allow_logic_query_params){
2956 2965
 				return;
2957
-			}else{
2966
+			} else{
2958 2967
 				throw new EE_Error(
2959 2968
 					sprintf(
2960 2969
 						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
@@ -2985,12 +2994,12 @@  discard block
 block discarded – undo
2985 2994
 					//we should actually end in a field name, not a model like this!
2986 2995
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2987 2996
 					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2988
-				}else{
2997
+				} else{
2989 2998
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2990 2999
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2991 3000
 					return;
2992 3001
 				}
2993
-			}elseif($query_param == $valid_related_model_name){
3002
+			} elseif($query_param == $valid_related_model_name){
2994 3003
 				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2995 3004
 				return;
2996 3005
 			}
@@ -3050,7 +3059,7 @@  discard block
 block discarded – undo
3050 3059
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3051 3060
 		if($SQL){
3052 3061
 			return " WHERE ". $SQL;
3053
-		}else{
3062
+		} else{
3054 3063
 			return '';
3055 3064
 		}
3056 3065
 	}
@@ -3065,7 +3074,7 @@  discard block
 block discarded – undo
3065 3074
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3066 3075
 		if($SQL){
3067 3076
 			return " HAVING ". $SQL;
3068
-		}else{
3077
+		} else{
3069 3078
 			return '';
3070 3079
 		}
3071 3080
 
@@ -3088,7 +3097,7 @@  discard block
 block discarded – undo
3088 3097
 			$model_instance=call_user_func($model_name."::instance");
3089 3098
 			/* @var $model_instance EEM_Base */
3090 3099
 			return $model_instance->field_settings_for($field_name);
3091
-		}else{
3100
+		} else{
3092 3101
 			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3093 3102
 		}
3094 3103
 	}
@@ -3121,14 +3130,14 @@  discard block
 block discarded – undo
3121 3130
 						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3122 3131
 						break;
3123 3132
 				}
3124
-			}else{
3133
+			} else{
3125 3134
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3126 3135
 
3127 3136
 				//if it's not a normal field, maybe it's a custom selection?
3128 3137
 				if( ! $field_obj){
3129 3138
 					if(isset( $this->_custom_selections[$query_param][1])){
3130 3139
 						$field_obj = $this->_custom_selections[$query_param][1];
3131
-					}else{
3140
+					} else{
3132 3141
 						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3133 3142
 					}
3134 3143
 				}
@@ -3138,7 +3147,7 @@  discard block
 block discarded – undo
3138 3147
 		}
3139 3148
 		if($where_clauses){
3140 3149
 			$SQL = implode($glue,$where_clauses);
3141
-		}else{
3150
+		} else{
3142 3151
 			$SQL = '';
3143 3152
 		}
3144 3153
 		return $SQL;
@@ -3158,11 +3167,11 @@  discard block
 block discarded – undo
3158 3167
 		if( $field ){
3159 3168
 			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3160 3169
 			return $table_alias_prefix . $field->get_qualified_column();
3161
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3170
+		} elseif(array_key_exists($query_param,$this->_custom_selections)){
3162 3171
 			//maybe it's custom selection item?
3163 3172
 			//if so, just use it as the "column name"
3164 3173
 			return $query_param;
3165
-		}else{
3174
+		} else{
3166 3175
 			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3167 3176
 		}
3168 3177
 	}
@@ -3179,7 +3188,7 @@  discard block
 block discarded – undo
3179 3188
 		$pos_of_star = strpos($condition_query_param_key, '*');
3180 3189
 		if($pos_of_star === FALSE){
3181 3190
 			return $condition_query_param_key;
3182
-		}else{
3191
+		} else{
3183 3192
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3184 3193
 			return $condition_query_param_sans_star;
3185 3194
 		}
@@ -3205,7 +3214,7 @@  discard block
 block discarded – undo
3205 3214
 				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string)));
3206 3215
 			}
3207 3216
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3208
-		}else{
3217
+		} else{
3209 3218
 			$operator = '=';
3210 3219
 			$value = $op_and_value;
3211 3220
 		}
@@ -3213,7 +3222,7 @@  discard block
 block discarded – undo
3213 3222
 		//check to see if the value is actually another field
3214 3223
 		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
3215 3224
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3216
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3225
+		} elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3217 3226
 			//in this case, the value should be an array, or at least a comma-separated list
3218 3227
 			//it will need to handle a little differently
3219 3228
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
@@ -3221,8 +3230,9 @@  discard block
 block discarded – undo
3221 3230
 			return $operator.SP.$cleaned_value;
3222 3231
 		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3223 3232
 			//the value should be an array with count of two.
3224
-			if ( count($value) !== 2 )
3225
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3233
+			if ( count($value) !== 2 ) {
3234
+							throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3235
+			}
3226 3236
 			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3227 3237
 			return $operator.SP.$cleaned_value;
3228 3238
 		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
@@ -3230,17 +3240,17 @@  discard block
 block discarded – undo
3230 3240
 				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
3231 3241
 			}
3232 3242
 			return $operator;
3233
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
3243
+		} elseif( $operator == 'LIKE' && ! is_array($value)){
3234 3244
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3235 3245
 			//remove other junk. So just treat it as a string.
3236 3246
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3237
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3247
+		} elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3238 3248
 			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
3239
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3249
+		} elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3240 3250
 			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
3241
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3251
+		} elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3242 3252
 			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
3243
-		}else{
3253
+		} else{
3244 3254
 			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
3245 3255
 		}
3246 3256
 	}
@@ -3310,7 +3320,7 @@  discard block
 block discarded – undo
3310 3320
 		global $wpdb;
3311 3321
 		if($field_obj instanceof EE_Model_Field_Base){
3312 3322
 			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3313
-		}else{//$field_obj should really just be a data type
3323
+		} else{//$field_obj should really just be a data type
3314 3324
 			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3315 3325
 				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3316 3326
 			}
@@ -3339,14 +3349,14 @@  discard block
 block discarded – undo
3339 3349
 		if($number_of_parts == 1){
3340 3350
 			$field_name = $last_query_param_part;
3341 3351
 			$model_obj = $this;
3342
-		}else{// $number_of_parts >= 2
3352
+		} else{// $number_of_parts >= 2
3343 3353
 			//the last part is the column name, and there are only 2parts. therefore...
3344 3354
 			$field_name = $last_query_param_part;
3345 3355
 			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3346 3356
 		}
3347 3357
 		try{
3348 3358
 			return $model_obj->field_settings_for($field_name);
3349
-		}catch(EE_Error $e){
3359
+		} catch(EE_Error $e){
3350 3360
 			return null;
3351 3361
 		}
3352 3362
 	}
@@ -3365,7 +3375,7 @@  discard block
 block discarded – undo
3365 3375
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3366 3376
 		if($field){
3367 3377
 			return $field->get_qualified_column();
3368
-		}else{
3378
+		} else{
3369 3379
 			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3370 3380
 		}
3371 3381
 	}
@@ -3431,7 +3441,7 @@  discard block
 block discarded – undo
3431 3441
 					//the FROM statement, BUT the primary table isn't. So we want
3432 3442
 					//to add the inverse join sql
3433 3443
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3434
-				}else{
3444
+				} else{
3435 3445
 					//just add a regular JOIN to this table from the primary table
3436 3446
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3437 3447
 				}
@@ -3546,7 +3556,7 @@  discard block
 block discarded – undo
3546 3556
 		$fieldSettings = $this->field_settings(true);
3547 3557
 		if( isset($fieldSettings[$fieldName])){
3548 3558
 			return true;
3549
-		}else{
3559
+		} else{
3550 3560
 			return false;
3551 3561
 		}
3552 3562
 	}
@@ -3560,7 +3570,7 @@  discard block
 block discarded – undo
3560 3570
 		$relations = $this->relation_settings();
3561 3571
 		if(isset($relations[$relation_name])){
3562 3572
 			return true;
3563
-		}else{
3573
+		} else{
3564 3574
 			return false;
3565 3575
 		}
3566 3576
 	}
@@ -3611,7 +3621,7 @@  discard block
 block discarded – undo
3611 3621
 			try{
3612 3622
 				$this->get_primary_key_field();
3613 3623
 				$this->_has_primary_key_field = true;
3614
-			}catch(EE_Error $e){
3624
+			} catch(EE_Error $e){
3615 3625
 				$this->_has_primary_key_field = false;
3616 3626
 			}
3617 3627
 		}
@@ -3690,7 +3700,7 @@  discard block
 block discarded – undo
3690 3700
 				}
3691 3701
 			}
3692 3702
 			return $this->_cached_fields;
3693
-		}else{
3703
+		} else{
3694 3704
 			if( $this->_cached_fields_non_db_only === NULL ){
3695 3705
 				$this->_cached_fields_non_db_only = array();
3696 3706
 				foreach($this->_fields as $fields_corresponding_to_table){
@@ -3843,7 +3853,7 @@  discard block
 block discarded – undo
3843 3853
 				// add this new object to the entity map
3844 3854
 				$classInstance = $this->add_to_entity_map( $classInstance );
3845 3855
 			}
3846
-		}else{
3856
+		} else{
3847 3857
 			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3848 3858
 		}
3849 3859
 
@@ -3930,11 +3940,12 @@  discard block
 block discarded – undo
3930 3940
 						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
3931 3941
 					}
3932 3942
 				}
3933
-			}else{
3943
+			} else{
3934 3944
 				//the table's rows existed. Use their values
3935 3945
 				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3936
-					if( ! $field_obj->is_db_only_field() )
3937
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3946
+					if( ! $field_obj->is_db_only_field() ) {
3947
+										$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3948
+					}
3938 3949
 				}
3939 3950
 			}
3940 3951
 		}
@@ -3948,9 +3959,9 @@  discard block
 block discarded – undo
3948 3959
 		if( isset( $cols_n_values[ $qualified_column ] ) ){
3949 3960
 			$value = $cols_n_values[ $qualified_column ];
3950 3961
 
3951
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3962
+		} elseif( isset( $cols_n_values[ $regular_column ] ) ){
3952 3963
 			$value = $cols_n_values[ $regular_column ];
3953
-		}else{
3964
+		} else{
3954 3965
 			$value = NULL;
3955 3966
 		}
3956 3967
 
@@ -3983,7 +3994,7 @@  discard block
 block discarded – undo
3983 3994
 				}
3984 3995
 			}
3985 3996
 			return $obj_in_map;
3986
-		}else{
3997
+		} else{
3987 3998
 			return $this->get_one_by_ID( $id );
3988 3999
 		}
3989 4000
 	}
@@ -4018,7 +4029,7 @@  discard block
 block discarded – undo
4018 4029
 				}
4019 4030
 			}
4020 4031
 			return $obj_in_map;
4021
-		}else{
4032
+		} else{
4022 4033
 			$this->add_to_entity_map( $replacing_model_obj );
4023 4034
 			return $replacing_model_obj;
4024 4035
 		}
@@ -4048,7 +4059,7 @@  discard block
 block discarded – undo
4048 4059
 	public function item_name($quantity = 1){
4049 4060
 		if($quantity == 1){
4050 4061
 			return $this->singular_item;
4051
-		}else{
4062
+		} else{
4052 4063
 			return $this->plural_item;
4053 4064
 		}
4054 4065
 	}
@@ -4110,14 +4121,14 @@  discard block
 block discarded – undo
4110 4121
 		$primary_key_field = $this->get_primary_key_field();
4111 4122
 		if( $base_class_obj_or_id instanceof $className ){
4112 4123
 			$model_object = $base_class_obj_or_id;
4113
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4124
+		} elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4114 4125
 				is_int( $base_class_obj_or_id ) ||
4115 4126
 				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4116 4127
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4117
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4128
+		} elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4118 4129
 			//assume its a string representation of the object
4119 4130
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4120
-		}else{
4131
+		} else{
4121 4132
 			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4122 4133
 		}
4123 4134
 		if( $model_object->ID() == NULL && $ensure_is_in_db){
@@ -4141,13 +4152,13 @@  discard block
 block discarded – undo
4141 4152
 		if( $base_class_obj_or_id instanceof $className ){
4142 4153
 			/** @var $base_class_obj_or_id EE_Base_Class */
4143 4154
 			$id = $base_class_obj_or_id->ID();
4144
-		}elseif(is_int($base_class_obj_or_id)){
4155
+		} elseif(is_int($base_class_obj_or_id)){
4145 4156
 			//assume it's an ID
4146 4157
 			$id = $base_class_obj_or_id;
4147
-		}elseif(is_string($base_class_obj_or_id)){
4158
+		} elseif(is_string($base_class_obj_or_id)){
4148 4159
 			//assume its a string representation of the object
4149 4160
 			$id = $base_class_obj_or_id;
4150
-		}else{
4161
+		} else{
4151 4162
 			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4152 4163
 		}
4153 4164
 		return $id;
@@ -4278,9 +4289,9 @@  discard block
 block discarded – undo
4278 4289
 
4279 4290
 		if($model_object_or_attributes_array instanceof EE_Base_Class){
4280 4291
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4281
-		}elseif(is_array($model_object_or_attributes_array)){
4292
+		} elseif(is_array($model_object_or_attributes_array)){
4282 4293
 			$attributes_array = $model_object_or_attributes_array;
4283
-		}else{
4294
+		} else{
4284 4295
 			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4285 4296
 		}
4286 4297
 		//even copies obviously won't have the same ID, so remove the primary key
@@ -4290,7 +4301,7 @@  discard block
 block discarded – undo
4290 4301
 		}
4291 4302
 		if(isset($query_params[0])){
4292 4303
 			$query_params[0] = array_merge($attributes_array,$query_params);
4293
-		}else{
4304
+		} else{
4294 4305
 			$query_params[0] = $attributes_array;
4295 4306
 		}
4296 4307
 		return $this->get_all($query_params);
@@ -4313,7 +4324,7 @@  discard block
 block discarded – undo
4313 4324
 		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4314 4325
 		if(is_array($copies)){
4315 4326
 			return array_shift($copies);
4316
-		}else{
4327
+		} else{
4317 4328
 			return null;
4318 4329
 		}
4319 4330
 	}
@@ -4345,7 +4356,7 @@  discard block
 block discarded – undo
4345 4356
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4346 4357
 		if($sql_operator){
4347 4358
 			return $sql_operator;
4348
-		}else{
4359
+		} else{
4349 4360
 			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4350 4361
 		}
4351 4362
 	}
@@ -4516,7 +4527,7 @@  discard block
 block discarded – undo
4516 4527
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4517 4528
 		if( in_array( $context, $valid_cap_contexts ) ) {
4518 4529
 			return true;
4519
-		}else{
4530
+		} else{
4520 4531
 			throw new EE_Error(
4521 4532
 				sprintf(
4522 4533
 					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Spacing   +398 added lines, -398 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public static function instance() {
130 130
 		// check if class object is instantiated, and instantiated properly
131
-		if ( ! self::$_instance instanceof EE_Config ) {
131
+		if ( ! self::$_instance instanceof EE_Config) {
132 132
 			self::$_instance = new self();
133 133
 		}
134 134
 		return self::$_instance;
@@ -145,22 +145,22 @@  discard block
 block discarded – undo
145 145
 	 * not be ready to instantiate EE_Config currently (eg if the site was put into maintenance mode)
146 146
 	 * @return EE_Config
147 147
 	 */
148
-	public static function reset( $hard_reset = FALSE, $reinstantiate = TRUE ){
149
-		if ( $hard_reset ) {
148
+	public static function reset($hard_reset = FALSE, $reinstantiate = TRUE) {
149
+		if ($hard_reset) {
150 150
 			self::$_instance->_config_option_names = array();
151 151
 			self::$_instance->_initialize_config();
152 152
 			self::$_instance->update_espresso_config();
153 153
 		}
154
-		if( self::$_instance instanceof EE_Config ){
154
+		if (self::$_instance instanceof EE_Config) {
155 155
 			self::$_instance->shutdown();
156 156
 		}
157 157
 		self::$_instance = NULL;
158 158
 		//we don't need to reset the static properties imo because those should
159 159
 		//only change when a module is added or removed. Currently we don't
160 160
 		//support removing a module during a request when it previously existed
161
-		if( $reinstantiate ){
161
+		if ($reinstantiate) {
162 162
 			return self::instance();
163
-		}else{
163
+		} else {
164 164
 			return NULL;
165 165
 		}
166 166
 	}
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 * @return \EE_Config
175 175
 	 */
176 176
 	private function __construct() {
177
-		do_action( 'AHEE__EE_Config__construct__begin',$this );
178
-		$this->_config_option_names = get_option( 'ee_config_option_names', array() );
177
+		do_action('AHEE__EE_Config__construct__begin', $this);
178
+		$this->_config_option_names = get_option('ee_config_option_names', array());
179 179
 		// setup empty config classes
180 180
 		$this->_initialize_config();
181 181
 		// load existing EE site settings
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
 		// confirm everything loaded correctly and set filtered defaults if not
184 184
 		$this->_verify_config();
185 185
 		//  register shortcodes and modules
186
-		add_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_and_modules' ), 999 );
186
+		add_action('AHEE__EE_System__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_and_modules'), 999);
187 187
 		//  initialize shortcodes and modules
188
-		add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' ));
188
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
189 189
 		// register widgets
190
-		add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 );
190
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
191 191
 		// shutdown
192
-		add_action( 'shutdown', array( $this, 'shutdown' ), 10 );
192
+		add_action('shutdown', array($this, 'shutdown'), 10);
193 193
 		// construct__end hook
194
-		do_action( 'AHEE__EE_Config__construct__end',$this );
194
+		do_action('AHEE__EE_Config__construct__end', $this);
195 195
 		// hardcoded hack
196 196
 		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
197 197
 	}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @return string current theme set.
205 205
 	 */
206 206
 	public static function get_current_theme() {
207
-		return isset( self::$_instance->template_settings->current_espresso_theme ) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
207
+		return isset(self::$_instance->template_settings->current_espresso_theme) ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
208 208
 	}
209 209
 
210 210
 
@@ -238,27 +238,27 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	private function _load_core_config() {
240 240
 		// load_core_config__start hook
241
-		do_action( 'AHEE__EE_Config___load_core_config__start', $this );
241
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
242 242
 		$espresso_config = $this->get_espresso_config();
243
-		foreach ( $espresso_config as $config => $settings ) {
243
+		foreach ($espresso_config as $config => $settings) {
244 244
 			// load_core_config__start hook
245
-			$settings = apply_filters( 'FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this );
246
-			if ( is_object( $settings ) && property_exists( $this, $config ) ) {
247
-				$this->{$config} = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings );
245
+			$settings = apply_filters('FHEE__EE_Config___load_core_config__config_settings', $settings, $config, $this);
246
+			if (is_object($settings) && property_exists($this, $config)) {
247
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
248 248
 				//call configs populate method to ensure any defaults are set for empty values.
249
-				if ( method_exists( $settings, 'populate' ) ) {
249
+				if (method_exists($settings, 'populate')) {
250 250
 					$this->{$config}->populate();
251 251
 				}
252
-				if ( method_exists( $settings, 'do_hooks' ) ) {
252
+				if (method_exists($settings, 'do_hooks')) {
253 253
 					$this->{$config}->do_hooks();
254 254
 				}
255 255
 			}
256 256
 		}
257
-		if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', FALSE ) ) {
257
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', FALSE)) {
258 258
 			$this->update_espresso_config();
259 259
 		}
260 260
 		// load_core_config__end hook
261
-		do_action( 'AHEE__EE_Config___load_core_config__end', $this );
261
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
262 262
 	}
263 263
 
264 264
 
@@ -272,40 +272,40 @@  discard block
 block discarded – undo
272 272
 	protected function _verify_config() {
273 273
 
274 274
 		$this->core = $this->core instanceof EE_Core_Config
275
-			? $this->core  : new EE_Core_Config();
276
-		$this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core );
275
+			? $this->core : new EE_Core_Config();
276
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
277 277
 
278 278
 		$this->organization = $this->organization instanceof EE_Organization_Config
279
-			? $this->organization  : new EE_Organization_Config();
280
-		$this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization );
279
+			? $this->organization : new EE_Organization_Config();
280
+		$this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', $this->organization);
281 281
 
282 282
 		$this->currency = $this->currency instanceof EE_Currency_Config
283 283
 			? $this->currency : new EE_Currency_Config();
284
-		$this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency );
284
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
285 285
 
286 286
 		$this->registration = $this->registration instanceof EE_Registration_Config
287 287
 			? $this->registration : new EE_Registration_Config();
288
-		$this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration );
288
+		$this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', $this->registration);
289 289
 
290 290
 		$this->admin = $this->admin instanceof EE_Admin_Config
291 291
 			? $this->admin : new EE_Admin_Config();
292
-		$this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin );
292
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
293 293
 
294 294
 		$this->template_settings = $this->template_settings instanceof EE_Template_Config
295 295
 			? $this->template_settings : new EE_Template_Config();
296
-		$this->template_settings = apply_filters( 'FHEE__EE_Config___initialize_config__template_settings', $this->template_settings );
296
+		$this->template_settings = apply_filters('FHEE__EE_Config___initialize_config__template_settings', $this->template_settings);
297 297
 
298 298
 		$this->map_settings = $this->map_settings instanceof EE_Map_Config
299 299
 			? $this->map_settings : new EE_Map_Config();
300
-		$this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings );
300
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', $this->map_settings);
301 301
 
302 302
 		$this->environment = $this->environment instanceof EE_Environment_Config
303 303
 			? $this->environment : new EE_Environment_Config();
304
-		$this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment );
304
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', $this->environment);
305 305
 
306 306
 		$this->gateway = $this->gateway instanceof EE_Gateway_Config
307 307
 			? $this->gateway : new EE_Gateway_Config();
308
-		$this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway );
308
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
309 309
 
310 310
 	}
311 311
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 */
320 320
 	public function get_espresso_config() {
321 321
 		// grab espresso configuration
322
-		return apply_filters( 'FHEE__EE_Config__get_espresso_config__CFG', get_option( 'ee_config', array() ));
322
+		return apply_filters('FHEE__EE_Config__get_espresso_config__CFG', get_option('ee_config', array()));
323 323
 	}
324 324
 
325 325
 
@@ -332,12 +332,12 @@  discard block
 block discarded – undo
332 332
 	 * @param        $old_value
333 333
 	 * @param        $value
334 334
 	 */
335
-	public function double_check_config_comparison( $option = '', $old_value, $value ) {
335
+	public function double_check_config_comparison($option = '', $old_value, $value) {
336 336
 		// make sure we're checking the ee config
337
-		if ( $option == 'ee_config' ) {
337
+		if ($option == 'ee_config') {
338 338
 			// run a loose comparison of the old value against the new value for type and properties,
339 339
 			// but NOT exact instance like WP update_option does
340
-			if ( $value != $old_value ) {
340
+			if ($value != $old_value) {
341 341
 				// if they are NOT the same, then remove the hook,
342 342
 				// which means the subsequent update results will be based solely on the update query results
343 343
 				// the reason we do this is because, as stated above,
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				// the string it sees in the db looks the same as the new one it has been passed!!!
353 353
 				// This results in the query returning an "affected rows" value of ZERO,
354 354
 				// which gets returned immediately by WP update_option and looks like an error.
355
-				remove_action( 'update_option', array( $this, 'check_config_updated' ));
355
+				remove_action('update_option', array($this, 'check_config_updated'));
356 356
 			}
357 357
 		}
358 358
 	}
@@ -367,11 +367,11 @@  discard block
 block discarded – undo
367 367
 	 */
368 368
 	protected function  _reset_espresso_addon_config() {
369 369
 		$this->_config_option_names = array();
370
-		foreach( $this->addons as $addon_name => $addon_config_obj ) {
371
-			$addon_config_obj = maybe_unserialize( $addon_config_obj );
372
-			$config_class = get_class( $addon_config_obj );
373
-			if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) {
374
-				$this->update_config( 'addons', $addon_name, $addon_config_obj, FALSE );
370
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
371
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
372
+			$config_class = get_class($addon_config_obj);
373
+			if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) {
374
+				$this->update_config('addons', $addon_name, $addon_config_obj, FALSE);
375 375
 			}
376 376
 			$this->addons->{$addon_name} = NULL;
377 377
 		}
@@ -387,17 +387,17 @@  discard block
 block discarded – undo
387 387
 	 * @param   bool $add_error
388 388
 	 * @return   bool
389 389
 	 */
390
-	public function  update_espresso_config( $add_success = FALSE, $add_error = TRUE ) {
390
+	public function  update_espresso_config($add_success = FALSE, $add_error = TRUE) {
391 391
 		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
392 392
 		//$clone = clone( self::$_instance );
393 393
 		//self::$_instance = NULL;
394
-		do_action( 'AHEE__EE_Config__update_espresso_config__begin',$this );
394
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
395 395
 		$this->_reset_espresso_addon_config();
396 396
 		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
397 397
 		// but BEFORE the actual update occurs
398
-		add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 );
398
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
399 399
 		// now update "ee_config"
400
-		$saved = update_option( 'ee_config', $this );
400
+		$saved = update_option('ee_config', $this);
401 401
 		// if not saved... check if the hook we just added still exists;
402 402
 		// if it does, it means one of two things:
403 403
 		// 		that update_option bailed at the ( $value === $old_value ) conditional,
@@ -408,25 +408,25 @@  discard block
 block discarded – undo
408 408
 		// but just means no update occurred, so don't display an error to the user.
409 409
 		// BUT... if update_option returns FALSE, AND the hook is missing,
410 410
 		// then it means that something truly went wrong
411
-		$saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' )) : $saved;
411
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
412 412
 		// remove our action since we don't want it in the system anymore
413
-		remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 );
414
-		do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved );
413
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
414
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
415 415
 		//self::$_instance = $clone;
416 416
 		//unset( $clone );
417 417
 		// if config remains the same or was updated successfully
418
-		if ( $saved ) {
419
-			if ( $add_success ) {
418
+		if ($saved) {
419
+			if ($add_success) {
420 420
 				EE_Error::add_success(
421
-					__( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ),
421
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
422 422
 					__FILE__, __FUNCTION__, __LINE__
423 423
 				);
424 424
 			}
425 425
 			return TRUE;
426 426
 		} else {
427
-			if ( $add_error ) {
427
+			if ($add_error) {
428 428
 				EE_Error::add_error(
429
-					__( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ),
429
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
430 430
 					__FILE__, __FUNCTION__, __LINE__
431 431
 				);
432 432
 			}
@@ -452,20 +452,20 @@  discard block
 block discarded – undo
452 452
 		$name = '',
453 453
 		$config_class = '',
454 454
 		$config_obj = NULL,
455
-		$tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ),
455
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
456 456
 		$display_errors = TRUE
457 457
 	) {
458 458
 		try {
459
-			foreach ( $tests_to_run as $test ) {
460
-				switch ( $test ) {
459
+			foreach ($tests_to_run as $test) {
460
+				switch ($test) {
461 461
 
462 462
 					// TEST #1 : check that section was set
463 463
 					case 1 :
464
-						if ( empty( $section ) ) {
465
-							if ( $display_errors ) {
464
+						if (empty($section)) {
465
+							if ($display_errors) {
466 466
 								throw new EE_Error(
467 467
 									sprintf(
468
-										__( 'No configuration section has been provided while attempting to save "%s".', 'event_espresso' ),
468
+										__('No configuration section has been provided while attempting to save "%s".', 'event_espresso'),
469 469
 										$config_class
470 470
 									)
471 471
 								);
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 
477 477
 					// TEST #2 : check that settings section exists
478 478
 					case 2 :
479
-						if ( ! isset( $this->{$section} ) ) {
480
-							if ( $display_errors ) {
479
+						if ( ! isset($this->{$section} )) {
480
+							if ($display_errors) {
481 481
 								throw new EE_Error(
482
-									sprintf( __( 'The "%s" configuration section does not exist.', 'event_espresso' ),
483
-											 $section )
482
+									sprintf(__('The "%s" configuration section does not exist.', 'event_espresso'),
483
+											 $section)
484 484
 								);
485 485
 							}
486 486
 							return false;
@@ -490,12 +490,12 @@  discard block
 block discarded – undo
490 490
 					// TEST #3 : check that section is the proper format
491 491
 					case 3 :
492 492
 						if (
493
-							! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass )
493
+							! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
494 494
 						) {
495
-							if ( $display_errors ) {
495
+							if ($display_errors) {
496 496
 								throw new EE_Error(
497 497
 									sprintf(
498
-										__( 'The "%s" configuration settings have not been formatted correctly.', 'event_espresso' ),
498
+										__('The "%s" configuration settings have not been formatted correctly.', 'event_espresso'),
499 499
 										$section
500 500
 									)
501 501
 								);
@@ -506,10 +506,10 @@  discard block
 block discarded – undo
506 506
 
507 507
 					// TEST #4 : check that config section name has been set
508 508
 					case 4 :
509
-						if ( empty( $name ) ) {
510
-							if ( $display_errors ) {
509
+						if (empty($name)) {
510
+							if ($display_errors) {
511 511
 								throw new EE_Error(
512
-									__( 'No name has been provided for the specific configuration section.', 'event_espresso' )
512
+									__('No name has been provided for the specific configuration section.', 'event_espresso')
513 513
 								);
514 514
 							}
515 515
 							return false;
@@ -518,10 +518,10 @@  discard block
 block discarded – undo
518 518
 
519 519
 					// TEST #5 : check that a config class name has been set
520 520
 					case 5 :
521
-						if ( empty( $config_class ) ) {
522
-							if ( $display_errors ) {
521
+						if (empty($config_class)) {
522
+							if ($display_errors) {
523 523
 								throw new EE_Error(
524
-									__( 'No class name has been provided for the specific configuration section.', 'event_espresso' )
524
+									__('No class name has been provided for the specific configuration section.', 'event_espresso')
525 525
 								);
526 526
 							}
527 527
 							return false;
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
 
531 531
 					// TEST #6 : verify config class is accessible
532 532
 					case 6 :
533
-						if ( ! class_exists( $config_class ) ) {
534
-							if ( $display_errors ) {
533
+						if ( ! class_exists($config_class)) {
534
+							if ($display_errors) {
535 535
 								throw new EE_Error(
536 536
 									sprintf(
537
-										__( 'The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso' ),
537
+										__('The "%s" class does not exist. Please ensure that an autoloader has been set for it.', 'event_espresso'),
538 538
 										$config_class
539 539
 									)
540 540
 								);
@@ -545,11 +545,11 @@  discard block
 block discarded – undo
545 545
 
546 546
 					// TEST #7 : check that config has even been set
547 547
 					case 7 :
548
-						if ( ! isset( $this->{$section}->{$name} ) ) {
549
-							if ( $display_errors ) {
548
+						if ( ! isset($this->{$section}->{$name} )) {
549
+							if ($display_errors) {
550 550
 								throw new EE_Error(
551 551
 									sprintf(
552
-										__( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ),
552
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
553 553
 										$section,
554 554
 										$name
555 555
 									)
@@ -558,17 +558,17 @@  discard block
 block discarded – undo
558 558
 							return false;
559 559
 						} else {
560 560
 							// and make sure it's not serialized
561
-							$this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} );
561
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name} );
562 562
 						}
563 563
 						break;
564 564
 
565 565
 					// TEST #8 : check that config is the requested type
566 566
 					case 8 :
567
-						if ( ! $this->{$section}->{$name} instanceof $config_class ) {
568
-							if ( $display_errors ) {
567
+						if ( ! $this->{$section}->{$name} instanceof $config_class) {
568
+							if ($display_errors) {
569 569
 								throw new EE_Error(
570 570
 									sprintf(
571
-										__( 'The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso' ),
571
+										__('The configuration for "%1$s->%2$s" is not of the "%3$s" class.', 'event_espresso'),
572 572
 										$section,
573 573
 										$name,
574 574
 										$config_class
@@ -581,12 +581,12 @@  discard block
 block discarded – undo
581 581
 
582 582
 					// TEST #9 : verify config object
583 583
 					case 9 :
584
-						if ( ! $config_obj instanceof EE_Config_Base ) {
585
-							if ( $display_errors ) {
584
+						if ( ! $config_obj instanceof EE_Config_Base) {
585
+							if ($display_errors) {
586 586
 								throw new EE_Error(
587 587
 									sprintf(
588
-										__( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ),
589
-										print_r( $config_obj, true )
588
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
589
+										print_r($config_obj, true)
590 590
 									)
591 591
 								);
592 592
 							}
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 				}
598 598
 			}
599 599
 
600
-		} catch( EE_Error $e ) {
600
+		} catch (EE_Error $e) {
601 601
 			$e->get_error();
602 602
 		}
603 603
 		// you have successfully run the gauntlet
@@ -614,8 +614,8 @@  discard block
 block discarded – undo
614 614
 	 * @param        string          $name
615 615
 	 * @return        string
616 616
 	 */
617
-	private function _generate_config_option_name( $section = '', $name = '' ) {
618
-		return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) );
617
+	private function _generate_config_option_name($section = '', $name = '') {
618
+		return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
619 619
 	}
620 620
 
621 621
 
@@ -629,10 +629,10 @@  discard block
 block discarded – undo
629 629
 	 * @param 	string $name
630 630
 	 * @return 	string
631 631
 	 */
632
-	private function _set_config_class( $config_class = '', $name = '' ) {
633
-		return ! empty( $config_class )
632
+	private function _set_config_class($config_class = '', $name = '') {
633
+		return ! empty($config_class)
634 634
 			? $config_class
635
-			: str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config';
635
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
636 636
 	}
637 637
 
638 638
 
@@ -646,34 +646,34 @@  discard block
 block discarded – undo
646 646
 	 * @param 	EE_Config_Base $config_obj
647 647
 	 * @return 	EE_Config_Base
648 648
 	 */
649
-	public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) {
649
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) {
650 650
 		// ensure config class is set to something
651
-		$config_class = $this->_set_config_class( $config_class, $name );
651
+		$config_class = $this->_set_config_class($config_class, $name);
652 652
 		// run tests 1-4, 6, and 7 to verify all config params are set and valid
653
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ))) {
653
+		if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
654 654
 			return null;
655 655
 		}
656
-		$config_option_name = $this->_generate_config_option_name( $section, $name );
656
+		$config_option_name = $this->_generate_config_option_name($section, $name);
657 657
 		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
658
-		if ( ! isset( $this->_config_option_names[ $config_option_name ] )) {
659
-			$this->_config_option_names[ $config_option_name ] = $config_class;
658
+		if ( ! isset($this->_config_option_names[$config_option_name])) {
659
+			$this->_config_option_names[$config_option_name] = $config_class;
660 660
 		}
661 661
 		// verify the incoming config object but suppress errors
662
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false )) {
662
+		if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
663 663
 			$config_obj = new $config_class();
664 664
 		}
665
-		if ( get_option( $config_option_name ) ) {
666
-			update_option( $config_option_name, $config_obj );
665
+		if (get_option($config_option_name)) {
666
+			update_option($config_option_name, $config_obj);
667 667
 			$this->{$section}->{$name} = $config_obj;
668 668
 			return $this->{$section}->{$name};
669 669
 		} else {
670 670
 			// create a wp-option for this config
671
-			if ( add_option( $config_option_name, $config_obj, '', 'no' )) {
672
-				$this->{$section}->{$name} = maybe_unserialize( $config_obj );
671
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
672
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
673 673
 				return $this->{$section}->{$name};
674 674
 			} else {
675 675
 				EE_Error::add_error(
676
-					sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ),
676
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
677 677
 					__FILE__, __FUNCTION__, __LINE__
678 678
 				);
679 679
 				return null;
@@ -694,37 +694,37 @@  discard block
 block discarded – undo
694 694
 	 * @param 	bool 					$throw_errors
695 695
 	 * @return 	bool
696 696
 	 */
697
-	public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) {
698
-		$config_obj = maybe_unserialize( $config_obj );
697
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) {
698
+		$config_obj = maybe_unserialize($config_obj);
699 699
 		// get class name of the incoming object
700
-		$config_class = get_class( $config_obj );
700
+		$config_class = get_class($config_obj);
701 701
 		// run tests 1-5 and 9 to verify config
702
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 1, 2, 3, 4, 7, 9 ))) {
702
+		if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(1, 2, 3, 4, 7, 9))) {
703 703
 			return false;
704 704
 		}
705
-		$config_option_name = $this->_generate_config_option_name( $section, $name );
705
+		$config_option_name = $this->_generate_config_option_name($section, $name);
706 706
 		// check if config object has been added to db by seeing if config option name is in $this->_config_option_names array
707
-		if ( ! isset( $this->_config_option_names[ $config_option_name ] )) {
707
+		if ( ! isset($this->_config_option_names[$config_option_name])) {
708 708
 			// save new config to db
709
-			return $this->set_config( $section, $name, $config_class, $config_obj );
709
+			return $this->set_config($section, $name, $config_class, $config_obj);
710 710
 		} else {
711 711
 			// first check if the record already exists
712
-			$existing_config = get_option( $config_option_name );
713
-			$config_obj = serialize( $config_obj );
712
+			$existing_config = get_option($config_option_name);
713
+			$config_obj = serialize($config_obj);
714 714
 			// just return if db record is already up to date
715
-			if ( $existing_config == $config_obj ) {
715
+			if ($existing_config == $config_obj) {
716 716
 				$this->{$section}->{$name} = $config_obj;
717 717
 				return true;
718
-			} else if ( update_option( $config_option_name, $config_obj )) {
718
+			} else if (update_option($config_option_name, $config_obj)) {
719 719
 				// update wp-option for this config class
720 720
 				$this->{$section}->{$name} = $config_obj;
721 721
 				return true;
722
-			} elseif ( $throw_errors ) {
722
+			} elseif ($throw_errors) {
723 723
 				EE_Error::add_error(
724 724
 					sprintf(
725
-						__( 'The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso' ),
725
+						__('The "%1$s" object stored at"%2$s" was not successfully updated in the database.', 'event_espresso'),
726 726
 						$config_class,
727
-						'EE_Config->' . $section . '->' . $name
727
+						'EE_Config->'.$section.'->'.$name
728 728
 					),
729 729
 					__FILE__, __FUNCTION__, __LINE__
730 730
 				);
@@ -744,34 +744,34 @@  discard block
 block discarded – undo
744 744
 	 * @param 	string 	$config_class
745 745
 	 * @return 	mixed EE_Config_Base | NULL
746 746
 	 */
747
-	public function get_config( $section = '', $name = '', $config_class = '' ) {
747
+	public function get_config($section = '', $name = '', $config_class = '') {
748 748
 		// ensure config class is set to something
749
-		$config_class = $this->_set_config_class( $config_class, $name );
749
+		$config_class = $this->_set_config_class($config_class, $name);
750 750
 		// run tests 1-4, 6 and 7 to verify that all params have been set
751
-		if ( ! $this->_verify_config_params( $section, $name, $config_class, NULL, array( 1, 2, 3, 4, 5, 6 ))) {
751
+		if ( ! $this->_verify_config_params($section, $name, $config_class, NULL, array(1, 2, 3, 4, 5, 6))) {
752 752
 			return NULL;
753 753
 		}
754 754
 		// now test if the requested config object exists, but suppress errors
755
-		if ( $this->_verify_config_params( $section, $name, $config_class, NULL, array( 7, 8 ), FALSE )) {
755
+		if ($this->_verify_config_params($section, $name, $config_class, NULL, array(7, 8), FALSE)) {
756 756
 			// config already exists, so pass it back
757 757
 			return $this->{$section}->{$name};
758 758
 		}
759 759
 		// load config option from db if it exists
760
-		$config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name ));
760
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
761 761
 		// verify the newly retrieved config object, but suppress errors
762
-		if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), FALSE )) {
762
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), FALSE)) {
763 763
 			// config is good, so set it and pass it back
764 764
 			$this->{$section}->{$name} = $config_obj;
765 765
 			return $this->{$section}->{$name};
766 766
 		}
767 767
 		// oops! $config_obj is not already set and does not exist in the db, so create a new one
768
-		$config_obj =$this->set_config( $section, $name, $config_class );
768
+		$config_obj = $this->set_config($section, $name, $config_class);
769 769
 		// verify the newly created config object
770
-		if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ))) {
770
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
771 771
 			return $this->{$section}->{$name};
772 772
 		} else {
773 773
 			EE_Error::add_error(
774
-				sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ),
774
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
775 775
 				__FILE__, __FUNCTION__, __LINE__
776 776
 			);
777 777
 		}
@@ -786,9 +786,9 @@  discard block
 block discarded – undo
786 786
 	 * @param 	string 	$config_option_name
787 787
 	 * @return 	mixed EE_Config_Base | FALSE
788 788
 	 */
789
-	public function get_config_option( $config_option_name = '' ) {
789
+	public function get_config_option($config_option_name = '') {
790 790
 		// retrieve the wp-option for this config class.
791
-		return maybe_unserialize( get_option( $config_option_name ));
791
+		return maybe_unserialize(get_option($config_option_name));
792 792
 	}
793 793
 
794 794
 
@@ -801,45 +801,45 @@  discard block
 block discarded – undo
801 801
 	 * @param $page_for_posts
802 802
 	 * @return    void
803 803
 	 */
804
-	public function update_post_shortcodes( $page_for_posts = '' ) {
804
+	public function update_post_shortcodes($page_for_posts = '') {
805 805
 		// make sure page_for_posts is set
806
-		$page_for_posts = ! empty( $page_for_posts ) ? $page_for_posts : EE_Config::get_page_for_posts();
806
+		$page_for_posts = ! empty($page_for_posts) ? $page_for_posts : EE_Config::get_page_for_posts();
807 807
 		// critical page shortcodes that we do NOT want added to the Posts page (blog)
808 808
 		$critical_shortcodes = $this->core->get_critical_pages_shortcodes_array();
809 809
 		// allow others to mess stuff up :D
810
-		do_action( 'AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts );
810
+		do_action('AHEE__EE_Config__update_post_shortcodes', $this->core->post_shortcodes, $page_for_posts);
811 811
 		// verify that post_shortcodes is set
812
-		$this->core->post_shortcodes = isset( $this->core->post_shortcodes ) && is_array( $this->core->post_shortcodes ) ? $this->core->post_shortcodes : array();
812
+		$this->core->post_shortcodes = isset($this->core->post_shortcodes) && is_array($this->core->post_shortcodes) ? $this->core->post_shortcodes : array();
813 813
 		// cycle thru post_shortcodes
814
-		foreach( $this->core->post_shortcodes as $post_name => $shortcodes ){
814
+		foreach ($this->core->post_shortcodes as $post_name => $shortcodes) {
815 815
 			// are there any shortcodes to track ?
816
-			if ( ! empty( $shortcodes )) {
816
+			if ( ! empty($shortcodes)) {
817 817
 				// loop thru list of tracked shortcodes
818
-				foreach( $shortcodes as $shortcode => $post_id ) {
818
+				foreach ($shortcodes as $shortcode => $post_id) {
819 819
 					// if shortcode is for a critical page, BUT this is NOT the corresponding critical page for that shortcode
820
-					if ( isset( $critical_shortcodes[ $post_id ] ) && $post_name == $page_for_posts ) {
820
+					if (isset($critical_shortcodes[$post_id]) && $post_name == $page_for_posts) {
821 821
 						// then remove this shortcode, because we don't want critical page shortcodes like ESPRESSO_TXN_PAGE running on the "Posts Page" (blog)
822
-						unset( $this->core->post_shortcodes[ $post_name ][ $shortcode ] );
822
+						unset($this->core->post_shortcodes[$post_name][$shortcode]);
823 823
 					}
824 824
 					// skip the posts page, because we want all shortcodes registered for it
825
-					if ( $post_name == $page_for_posts ) {
825
+					if ($post_name == $page_for_posts) {
826 826
 						continue;
827 827
 					}
828 828
 					// make sure post still exists
829
-					$post = get_post( $post_id );
830
-					if ( $post ) {
829
+					$post = get_post($post_id);
830
+					if ($post) {
831 831
 						// check that the post name matches what we have saved
832
-						if ( $post->post_name == $post_name ) {
832
+						if ($post->post_name == $post_name) {
833 833
 							// if so, then break before hitting the unset below
834 834
 							continue;
835 835
 						}
836 836
 					}
837 837
 					// we don't like missing posts around here >:(
838
-					unset( $this->core->post_shortcodes[ $post_name ] );
838
+					unset($this->core->post_shortcodes[$post_name]);
839 839
 				}
840 840
 			} else {
841 841
 				// you got no shortcodes to keep track of !
842
-				unset( $this->core->post_shortcodes[ $post_name ] );
842
+				unset($this->core->post_shortcodes[$post_name]);
843 843
 			}
844 844
 		}
845 845
 		//only show errors
@@ -858,14 +858,14 @@  discard block
 block discarded – undo
858 858
 	 *  @return 	string
859 859
 	 */
860 860
 	public static function get_page_for_posts() {
861
-		$page_for_posts = get_option( 'page_for_posts' );
862
-		if ( ! $page_for_posts ) {
861
+		$page_for_posts = get_option('page_for_posts');
862
+		if ( ! $page_for_posts) {
863 863
 			return 'posts';
864 864
 		}
865 865
 		/** @type WPDB $wpdb */
866 866
 		global $wpdb;
867 867
 		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
868
-		return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts ));
868
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
869 869
 	}
870 870
 
871 871
 
@@ -881,11 +881,11 @@  discard block
 block discarded – undo
881 881
 	 *  @return 	void
882 882
 	 */
883 883
 	public function register_shortcodes_and_modules() {
884
-		if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) {
884
+		if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) {
885 885
 			return;
886 886
 		}
887 887
 		// allow shortcodes to register with WP and to set hooks for the rest of the system
888
-		EE_Registry::instance()->shortcodes =$this->_register_shortcodes();
888
+		EE_Registry::instance()->shortcodes = $this->_register_shortcodes();
889 889
 		// allow modules to set hooks for the rest of the system
890 890
 		EE_Registry::instance()->modules = $this->_register_modules();
891 891
 	}
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 	 *  @return 	void
900 900
 	 */
901 901
 	public function initialize_shortcodes_and_modules() {
902
-		if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) {
902
+		if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) {
903 903
 			return;
904 904
 		}
905 905
 		// allow shortcodes to set hooks for the rest of the system
@@ -918,26 +918,26 @@  discard block
 block discarded – undo
918 918
 	 * 	@return void
919 919
 	 */
920 920
 	public function widgets_init() {
921
-		if ( EE_Maintenance_Mode::disable_frontend_for_maintenance() ) {
921
+		if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) {
922 922
 			return;
923 923
 		}
924 924
 		//only init widgets on admin pages when not in complete maintenance, and
925 925
 		//on frontend when not in any maintenance mode
926
-		if (( is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance)  || ! EE_Maintenance_Mode::instance()->level() ) {
926
+		if ((is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level()) {
927 927
 			// grab list of installed widgets
928
-			$widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR );
928
+			$widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
929 929
 			// filter list of modules to register
930
-			$widgets_to_register = apply_filters( 'FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register );
930
+			$widgets_to_register = apply_filters('FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register);
931 931
 
932
-			if ( ! empty( $widgets_to_register ) ) {
932
+			if ( ! empty($widgets_to_register)) {
933 933
 				// cycle thru widget folders
934
-				foreach ( $widgets_to_register as $widget_path ) {
934
+				foreach ($widgets_to_register as $widget_path) {
935 935
 					// add to list of installed widget modules
936
-					EE_Config::register_ee_widget( $widget_path );
936
+					EE_Config::register_ee_widget($widget_path);
937 937
 				}
938 938
 			}
939 939
 			// filter list of installed modules
940
-			EE_Registry::instance()->widgets = apply_filters( 'FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets );
940
+			EE_Registry::instance()->widgets = apply_filters('FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets);
941 941
 		}
942 942
 	}
943 943
 
@@ -950,54 +950,54 @@  discard block
 block discarded – undo
950 950
 	 *  @param 	string 	$widget_path - full path up to and including widget folder
951 951
 	 *  @return 	void
952 952
 	 */
953
-	public static function register_ee_widget( $widget_path = NULL ) {
954
-		do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path );
953
+	public static function register_ee_widget($widget_path = NULL) {
954
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
955 955
 		$widget_ext = '.widget.php';
956 956
 		// make all separators match
957
-		$widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS );
957
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
958 958
 		// does the file path INCLUDE the actual file name as part of the path ?
959
-		if ( strpos( $widget_path, $widget_ext ) !== FALSE ) {
959
+		if (strpos($widget_path, $widget_ext) !== FALSE) {
960 960
 			// grab and shortcode file name from directory name and break apart at dots
961
-			$file_name = explode( '.', basename( $widget_path ));
961
+			$file_name = explode('.', basename($widget_path));
962 962
 			// take first segment from file name pieces and remove class prefix if it exists
963
-			$widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0];
963
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
964 964
 			// sanitize shortcode directory name
965
-			$widget = sanitize_key( $widget );
965
+			$widget = sanitize_key($widget);
966 966
 			// now we need to rebuild the shortcode path
967
-			$widget_path = explode( DS, $widget_path );
967
+			$widget_path = explode(DS, $widget_path);
968 968
 			// remove last segment
969
-			array_pop( $widget_path );
969
+			array_pop($widget_path);
970 970
 			// glue it back together
971
-			$widget_path = implode( DS, $widget_path );
971
+			$widget_path = implode(DS, $widget_path);
972 972
 		} else {
973 973
 			// grab and sanitize widget directory name
974
-			$widget = sanitize_key( basename( $widget_path ));
974
+			$widget = sanitize_key(basename($widget_path));
975 975
 		}
976 976
 		// create classname from widget directory name
977
-		$widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget )));
977
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
978 978
 		// add class prefix
979
-		$widget_class = 'EEW_' . $widget;
979
+		$widget_class = 'EEW_'.$widget;
980 980
 		// does the widget exist ?
981
-		if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext )) {
981
+		if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
982 982
 			$msg = sprintf(
983
-				__( 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso' ),
983
+				__('The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'),
984 984
 				$widget_class,
985
-				$widget_path . DS . $widget_class . $widget_ext
985
+				$widget_path.DS.$widget_class.$widget_ext
986 986
 			);
987
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
987
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
988 988
 			return;
989 989
 		}
990 990
 		// load the widget class file
991
-		require_once( $widget_path . DS . $widget_class . $widget_ext );
991
+		require_once($widget_path.DS.$widget_class.$widget_ext);
992 992
 		// verify that class exists
993
-		if ( ! class_exists( $widget_class )) {
994
-			$msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class );
995
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
993
+		if ( ! class_exists($widget_class)) {
994
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
995
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
996 996
 			return;
997 997
 		}
998
-		register_widget( $widget_class );
998
+		register_widget($widget_class);
999 999
 		// add to array of registered widgets
1000
-		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1000
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
1001 1001
 	}
1002 1002
 
1003 1003
 
@@ -1010,18 +1010,18 @@  discard block
 block discarded – undo
1010 1010
 	 */
1011 1011
 	private function _register_shortcodes() {
1012 1012
 		// grab list of installed shortcodes
1013
-		$shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR );
1013
+		$shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR);
1014 1014
 		// filter list of modules to register
1015
-		$shortcodes_to_register = apply_filters( 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register );
1016
-		if ( ! empty( $shortcodes_to_register ) ) {
1015
+		$shortcodes_to_register = apply_filters('FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register);
1016
+		if ( ! empty($shortcodes_to_register)) {
1017 1017
 			// cycle thru shortcode folders
1018
-			foreach ( $shortcodes_to_register as $shortcode_path ) {
1018
+			foreach ($shortcodes_to_register as $shortcode_path) {
1019 1019
 				// add to list of installed shortcode modules
1020
-				EE_Config::register_shortcode( $shortcode_path );
1020
+				EE_Config::register_shortcode($shortcode_path);
1021 1021
 			}
1022 1022
 		}
1023 1023
 		// filter list of installed modules
1024
-		return apply_filters( 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes );
1024
+		return apply_filters('FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes);
1025 1025
 	}
1026 1026
 
1027 1027
 
@@ -1033,56 +1033,56 @@  discard block
 block discarded – undo
1033 1033
 	 *  @param 	string 		$shortcode_path - full path up to and including shortcode folder
1034 1034
 	 *  @return 	bool
1035 1035
 	 */
1036
-	public static function register_shortcode( $shortcode_path = NULL ) {
1037
-		do_action( 'AHEE__EE_Config__register_shortcode__begin',$shortcode_path );
1036
+	public static function register_shortcode($shortcode_path = NULL) {
1037
+		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
1038 1038
 		$shortcode_ext = '.shortcode.php';
1039 1039
 		// make all separators match
1040
-		$shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path );
1040
+		$shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
1041 1041
 		// does the file path INCLUDE the actual file name as part of the path ?
1042
-		if ( strpos( $shortcode_path, $shortcode_ext ) !== FALSE ) {
1042
+		if (strpos($shortcode_path, $shortcode_ext) !== FALSE) {
1043 1043
 			// grab shortcode file name from directory name and break apart at dots
1044
-			$shortcode_file = explode( '.', basename( $shortcode_path ));
1044
+			$shortcode_file = explode('.', basename($shortcode_path));
1045 1045
 			// take first segment from file name pieces and remove class prefix if it exists
1046
-			$shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 ? substr( $shortcode_file[0], 4 ) : $shortcode_file[0];
1046
+			$shortcode = strpos($shortcode_file[0], 'EES_') === 0 ? substr($shortcode_file[0], 4) : $shortcode_file[0];
1047 1047
 			// sanitize shortcode directory name
1048
-			$shortcode = sanitize_key( $shortcode );
1048
+			$shortcode = sanitize_key($shortcode);
1049 1049
 			// now we need to rebuild the shortcode path
1050
-			$shortcode_path = explode( DS, $shortcode_path );
1050
+			$shortcode_path = explode(DS, $shortcode_path);
1051 1051
 			// remove last segment
1052
-			array_pop( $shortcode_path );
1052
+			array_pop($shortcode_path);
1053 1053
 			// glue it back together
1054
-			$shortcode_path = implode( DS, $shortcode_path ) . DS;
1054
+			$shortcode_path = implode(DS, $shortcode_path).DS;
1055 1055
 		} else {
1056 1056
 			// we need to generate the filename based off of the folder name
1057 1057
 			// grab and sanitize shortcode directory name
1058
-			$shortcode = sanitize_key( basename( $shortcode_path ));
1059
-			$shortcode_path = rtrim( $shortcode_path, DS ) . DS;
1058
+			$shortcode = sanitize_key(basename($shortcode_path));
1059
+			$shortcode_path = rtrim($shortcode_path, DS).DS;
1060 1060
 		}
1061 1061
 		// create classname from shortcode directory or file name
1062
-		$shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode )));
1062
+		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
1063 1063
 		// add class prefix
1064
-		$shortcode_class = 'EES_' . $shortcode;
1064
+		$shortcode_class = 'EES_'.$shortcode;
1065 1065
 		// does the shortcode exist ?
1066
-		if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext )) {
1066
+		if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) {
1067 1067
 			$msg = sprintf(
1068
-				__( 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso' ),
1068
+				__('The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso'),
1069 1069
 				$shortcode_class,
1070
-				$shortcode_path . DS . $shortcode_class . $shortcode_ext
1070
+				$shortcode_path.DS.$shortcode_class.$shortcode_ext
1071 1071
 			);
1072
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1072
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1073 1073
 			return FALSE;
1074 1074
 		}
1075 1075
 		// load the shortcode class file
1076
-		require_once( $shortcode_path . $shortcode_class . $shortcode_ext );
1076
+		require_once($shortcode_path.$shortcode_class.$shortcode_ext);
1077 1077
 		// verify that class exists
1078
-		if ( ! class_exists( $shortcode_class )) {
1079
-			$msg = sprintf( __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), $shortcode_class );
1080
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1078
+		if ( ! class_exists($shortcode_class)) {
1079
+			$msg = sprintf(__('The requested %s shortcode class does not exist.', 'event_espresso'), $shortcode_class);
1080
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1081 1081
 			return FALSE;
1082 1082
 		}
1083
-		$shortcode = strtoupper( $shortcode );
1083
+		$shortcode = strtoupper($shortcode);
1084 1084
 		// add to array of registered shortcodes
1085
-		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1085
+		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext;
1086 1086
 		return TRUE;
1087 1087
 	}
1088 1088
 
@@ -1097,23 +1097,23 @@  discard block
 block discarded – undo
1097 1097
 	 */
1098 1098
 	private function _register_modules() {
1099 1099
 		// grab list of installed modules
1100
-		$modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR );
1100
+		$modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1101 1101
 		// filter list of modules to register
1102
-		$modules_to_register = apply_filters( 'FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register );
1102
+		$modules_to_register = apply_filters('FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register);
1103 1103
 
1104 1104
 
1105
-		if ( ! empty( $modules_to_register ) ) {
1105
+		if ( ! empty($modules_to_register)) {
1106 1106
 			// loop through folders
1107
-			foreach ( $modules_to_register as $module_path ) {
1107
+			foreach ($modules_to_register as $module_path) {
1108 1108
 				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1109
-				if ( $module_path != EE_MODULES . 'zzz-copy-this-module-template' && $module_path != EE_MODULES . 'gateways' ) {
1109
+				if ($module_path != EE_MODULES.'zzz-copy-this-module-template' && $module_path != EE_MODULES.'gateways') {
1110 1110
 					// add to list of installed modules
1111
-					EE_Config::register_module( $module_path );
1111
+					EE_Config::register_module($module_path);
1112 1112
 				}
1113 1113
 			}
1114 1114
 		}
1115 1115
 		// filter list of installed modules
1116
-		return apply_filters( 'FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules );
1116
+		return apply_filters('FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules);
1117 1117
 	}
1118 1118
 
1119 1119
 
@@ -1126,39 +1126,39 @@  discard block
 block discarded – undo
1126 1126
 	 *  @param 	string 		$module_path - full path up to and including module folder
1127 1127
 	 *  @return 	bool
1128 1128
 	 */
1129
-	public static function register_module( $module_path = NULL ) {
1130
-		do_action( 'AHEE__EE_Config__register_module__begin', $module_path );
1129
+	public static function register_module($module_path = NULL) {
1130
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1131 1131
 		$module_ext = '.module.php';
1132 1132
 		// make all separators match
1133
-		$module_path = str_replace( array( '\\', '/' ), DS, $module_path );
1133
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1134 1134
 		// does the file path INCLUDE the actual file name as part of the path ?
1135
-		if ( strpos( $module_path, $module_ext ) !== FALSE ) {
1135
+		if (strpos($module_path, $module_ext) !== FALSE) {
1136 1136
 			// grab and shortcode file name from directory name and break apart at dots
1137
-			$module_file = explode( '.', basename( $module_path ));
1137
+			$module_file = explode('.', basename($module_path));
1138 1138
 			// now we need to rebuild the shortcode path
1139
-			$module_path = explode( DS, $module_path );
1139
+			$module_path = explode(DS, $module_path);
1140 1140
 			// remove last segment
1141
-			array_pop( $module_path );
1141
+			array_pop($module_path);
1142 1142
 			// glue it back together
1143
-			$module_path = implode( DS, $module_path ) . DS;
1143
+			$module_path = implode(DS, $module_path).DS;
1144 1144
 			// take first segment from file name pieces and sanitize it
1145
-			$module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] );
1145
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1146 1146
 			// ensure class prefix is added
1147
-			$module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module;
1147
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1148 1148
 		} else {
1149 1149
 			// we need to generate the filename based off of the folder name
1150 1150
 			// grab and sanitize module name
1151
-			$module = strtolower( basename( $module_path ));
1152
-			$module = preg_replace( '/[^a-z0-9_\-]/', '', $module);
1151
+			$module = strtolower(basename($module_path));
1152
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1153 1153
 			// like trailingslashit()
1154
-			$module_path = rtrim( $module_path, DS ) . DS;
1154
+			$module_path = rtrim($module_path, DS).DS;
1155 1155
 			// create classname from module directory name
1156
-			$module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module )));
1156
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1157 1157
 			// add class prefix
1158
-			$module_class = 'EED_' . $module;
1158
+			$module_class = 'EED_'.$module;
1159 1159
 		}
1160 1160
 		// does the module exist ?
1161
-		if ( ! is_readable( $module_path . DS . $module_class . $module_ext )) {
1161
+		if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1162 1162
 			EE_Error::add_error(
1163 1163
 				sprintf(
1164 1164
 					__(
@@ -1174,16 +1174,16 @@  discard block
 block discarded – undo
1174 1174
 			return FALSE;
1175 1175
 		}
1176 1176
 		// load the module class file
1177
-		require_once( $module_path . $module_class . $module_ext );
1177
+		require_once($module_path.$module_class.$module_ext);
1178 1178
 		// verify that class exists
1179
-		if ( ! class_exists( $module_class )) {
1180
-			$msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class );
1181
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1179
+		if ( ! class_exists($module_class)) {
1180
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1181
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1182 1182
 			return FALSE;
1183 1183
 		}
1184 1184
 		// add to array of registered modules
1185
-		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1186
-		do_action( 'AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} );
1185
+		EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1186
+		do_action('AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} );
1187 1187
 		return TRUE;
1188 1188
 	}
1189 1189
 
@@ -1197,23 +1197,23 @@  discard block
 block discarded – undo
1197 1197
 	 */
1198 1198
 	private function _initialize_shortcodes() {
1199 1199
 		// cycle thru shortcode folders
1200
-		foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) {
1200
+		foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1201 1201
 			// add class prefix
1202
-			$shortcode_class = 'EES_' . $shortcode;
1202
+			$shortcode_class = 'EES_'.$shortcode;
1203 1203
 			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1204 1204
 			// which set hooks ?
1205
-			if ( is_admin() ) {
1205
+			if (is_admin()) {
1206 1206
 				// fire immediately
1207
-				call_user_func( array( $shortcode_class, 'set_hooks_admin' ));
1207
+				call_user_func(array($shortcode_class, 'set_hooks_admin'));
1208 1208
 			} else {
1209 1209
 				// delay until other systems are online
1210
-				add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $shortcode_class,'set_hooks' ));
1210
+				add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($shortcode_class, 'set_hooks'));
1211 1211
 				// convert classname to UPPERCASE and create WP shortcode.
1212
-				$shortcode_tag = strtoupper( $shortcode );
1212
+				$shortcode_tag = strtoupper($shortcode);
1213 1213
 				// but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor'
1214
-				if ( ! shortcode_exists( $shortcode_tag )) {
1214
+				if ( ! shortcode_exists($shortcode_tag)) {
1215 1215
 					// NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes()
1216
-					add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' ));
1216
+					add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
1217 1217
 				}
1218 1218
 			}
1219 1219
 		}
@@ -1230,15 +1230,15 @@  discard block
 block discarded – undo
1230 1230
 	 */
1231 1231
 	private function _initialize_modules() {
1232 1232
 		// cycle thru shortcode folders
1233
-		foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) {
1233
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1234 1234
 			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1235 1235
 			// which set hooks ?
1236
-			if ( is_admin() ) {
1236
+			if (is_admin()) {
1237 1237
 				// fire immediately
1238
-				call_user_func( array( $module_class, 'set_hooks_admin' ));
1238
+				call_user_func(array($module_class, 'set_hooks_admin'));
1239 1239
 			} else {
1240 1240
 				// delay until other systems are online
1241
-				add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $module_class,'set_hooks' ));
1241
+				add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($module_class, 'set_hooks'));
1242 1242
 			}
1243 1243
 		}
1244 1244
 	}
@@ -1256,26 +1256,26 @@  discard block
 block discarded – undo
1256 1256
 	 *  @param 	string 		$key - url param key indicating a route is being called
1257 1257
 	 *  @return 	bool
1258 1258
 	 */
1259
-	public static function register_route( $route = NULL, $module = NULL, $method_name = NULL, $key = 'ee' ) {
1260
-		do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name );
1261
-		$module = str_replace( 'EED_', '', $module );
1262
-		$module_class = 'EED_' . $module;
1263
-		if ( ! isset( EE_Registry::instance()->modules->{$module_class} )) {
1264
-			$msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module );
1265
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1259
+	public static function register_route($route = NULL, $module = NULL, $method_name = NULL, $key = 'ee') {
1260
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1261
+		$module = str_replace('EED_', '', $module);
1262
+		$module_class = 'EED_'.$module;
1263
+		if ( ! isset(EE_Registry::instance()->modules->{$module_class} )) {
1264
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1265
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1266 1266
 			return FALSE;
1267 1267
 		}
1268
-		if ( empty( $route )) {
1269
-			$msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route );
1270
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1268
+		if (empty($route)) {
1269
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1270
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1271 1271
 			return FALSE;
1272 1272
 		}
1273
-		if ( ! method_exists ( 'EED_' . $module, $method_name )) {
1274
-			$msg = sprintf( __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), $route );
1275
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1273
+		if ( ! method_exists('EED_'.$module, $method_name)) {
1274
+			$msg = sprintf(__('A valid class method for the %s route has not been supplied.', 'event_espresso'), $route);
1275
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1276 1276
 			return FALSE;
1277 1277
 		}
1278
-		EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name );
1278
+		EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1279 1279
 		return TRUE;
1280 1280
 	}
1281 1281
 
@@ -1289,11 +1289,11 @@  discard block
 block discarded – undo
1289 1289
 	 *  @param 	string 		$key - url param key indicating a route is being called
1290 1290
 	 *  @return 	string
1291 1291
 	 */
1292
-	public static function get_route( $route = NULL, $key = 'ee' ) {
1293
-		do_action( 'AHEE__EE_Config__get_route__begin',$route );
1294
-		$route = apply_filters( 'FHEE__EE_Config__get_route',$route );
1295
-		if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] )) {
1296
-			return EE_Config::$_module_route_map[ $key ][ $route ];
1292
+	public static function get_route($route = NULL, $key = 'ee') {
1293
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1294
+		$route = apply_filters('FHEE__EE_Config__get_route', $route);
1295
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1296
+			return EE_Config::$_module_route_map[$key][$route];
1297 1297
 		}
1298 1298
 		return NULL;
1299 1299
 	}
@@ -1322,35 +1322,35 @@  discard block
 block discarded – undo
1322 1322
 	 * @param    string 		$key - url param key indicating a route is being called
1323 1323
 	 * @return    bool
1324 1324
 	 */
1325
-	public static function register_forward( $route = NULL, $status = 0, $forward = NULL, $key = 'ee' ) {
1326
-		do_action( 'AHEE__EE_Config__register_forward',$route,$status,$forward );
1327
-		if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) ||  empty( $route )) {
1328
-			$msg = sprintf( __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), $route );
1329
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1325
+	public static function register_forward($route = NULL, $status = 0, $forward = NULL, $key = 'ee') {
1326
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1327
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1328
+			$msg = sprintf(__('The module route %s for this forward has not been registered.', 'event_espresso'), $route);
1329
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1330 1330
 			return FALSE;
1331 1331
 		}
1332
-		if ( empty( $forward )) {
1333
-			$msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route );
1334
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1332
+		if (empty($forward)) {
1333
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1335 1335
 			return FALSE;
1336 1336
 		}
1337
-		if ( is_array( $forward )) {
1338
-			if ( ! isset( $forward[1] )) {
1339
-				$msg = sprintf( __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), $route );
1340
-				EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1337
+		if (is_array($forward)) {
1338
+			if ( ! isset($forward[1])) {
1339
+				$msg = sprintf(__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), $route);
1340
+				EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1341 1341
 				return FALSE;
1342 1342
 			}
1343
-			if ( ! method_exists( $forward[0], $forward[1] )) {
1344
-				$msg = sprintf( __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward[1], $route );
1345
-				EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1343
+			if ( ! method_exists($forward[0], $forward[1])) {
1344
+				$msg = sprintf(__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward[1], $route);
1345
+				EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1346 1346
 				return FALSE;
1347 1347
 			}
1348
-		} else if ( ! function_exists( $forward )) {
1349
-			$msg = sprintf( __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward, $route );
1350
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1348
+		} else if ( ! function_exists($forward)) {
1349
+			$msg = sprintf(__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward, $route);
1350
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1351 1351
 			return FALSE;
1352 1352
 		}
1353
-		EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward;
1353
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1354 1354
 		return TRUE;
1355 1355
 	}
1356 1356
 
@@ -1365,10 +1365,10 @@  discard block
 block discarded – undo
1365 1365
 	 *  @param    string 		$key - url param key indicating a route is being called
1366 1366
 	 *  @return 	string
1367 1367
 	 */
1368
-	public static function get_forward( $route = NULL, $status = 0, $key = 'ee' ) {
1369
-		do_action( 'AHEE__EE_Config__get_forward__begin',$route,$status );
1370
-		if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] )) {
1371
-			return apply_filters( 'FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], $route,$status );
1368
+	public static function get_forward($route = NULL, $status = 0, $key = 'ee') {
1369
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1370
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1371
+			return apply_filters('FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[$key][$route][$status], $route, $status);
1372 1372
 		}
1373 1373
 		return NULL;
1374 1374
 	}
@@ -1385,19 +1385,19 @@  discard block
 block discarded – undo
1385 1385
 	 * @param    string 		$key - url param key indicating a route is being called
1386 1386
 	 * @return    bool
1387 1387
 	 */
1388
-	public static function register_view( $route = NULL, $status = 0, $view = NULL, $key = 'ee' ) {
1389
-		do_action( 'AHEE__EE_Config__register_view__begin',$route,$status,$view );
1390
-		if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) ||  empty( $route )) {
1391
-			$msg = sprintf( __( 'The module route %s for this view has not been registered.', 'event_espresso' ), $route );
1392
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1388
+	public static function register_view($route = NULL, $status = 0, $view = NULL, $key = 'ee') {
1389
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1390
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1391
+			$msg = sprintf(__('The module route %s for this view has not been registered.', 'event_espresso'), $route);
1392
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1393 1393
 			return FALSE;
1394 1394
 		}
1395
-		if ( ! is_readable( $view )) {
1396
-			$msg = sprintf( __( 'The %s view file could not be found or is not readable due to file permissions.', 'event_espresso' ), $view );
1397
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1395
+		if ( ! is_readable($view)) {
1396
+			$msg = sprintf(__('The %s view file could not be found or is not readable due to file permissions.', 'event_espresso'), $view);
1397
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1398 1398
 			return FALSE;
1399 1399
 		}
1400
-		EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view;
1400
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1401 1401
 		return TRUE;
1402 1402
 	}
1403 1403
 
@@ -1414,10 +1414,10 @@  discard block
 block discarded – undo
1414 1414
 	 *  @param    string 		$key - url param key indicating a route is being called
1415 1415
 	 *  @return 	string
1416 1416
 	 */
1417
-	public static function get_view( $route = NULL, $status = 0, $key = 'ee' ) {
1418
-		do_action( 'AHEE__EE_Config__get_view__begin',$route,$status );
1419
-		if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] )) {
1420
-			return apply_filters( 'FHEE__EE_Config__get_view', EE_Config::$_module_view_map[ $key ][ $route ][ $status ], $route,$status );
1417
+	public static function get_view($route = NULL, $status = 0, $key = 'ee') {
1418
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1419
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1420
+			return apply_filters('FHEE__EE_Config__get_view', EE_Config::$_module_view_map[$key][$route][$status], $route, $status);
1421 1421
 		}
1422 1422
 		return NULL;
1423 1423
 	}
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 
1426 1426
 
1427 1427
 	public function shutdown() {
1428
-		update_option( 'ee_config_option_names', $this->_config_option_names );
1428
+		update_option('ee_config_option_names', $this->_config_option_names);
1429 1429
 	}
1430 1430
 
1431 1431
 
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
  * magic functions in use, except we'll allow them to magically set and get stuff...
1442 1442
  * basically, they should just be well-defined stdClasses
1443 1443
  */
1444
-class EE_Config_Base{
1444
+class EE_Config_Base {
1445 1445
 
1446 1446
 	/**
1447 1447
 	 * Utility function for escaping the value of a property and returning.
@@ -1450,13 +1450,13 @@  discard block
 block discarded – undo
1450 1450
 	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1451 1451
 	 * @throws \EE_Error
1452 1452
 	 */
1453
-	public function get_pretty( $property ) {
1454
-		if ( ! property_exists( $this, $property ) ) {
1455
-			throw new EE_Error( sprintf( __('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso' ), get_class( $this ), $property ) );
1453
+	public function get_pretty($property) {
1454
+		if ( ! property_exists($this, $property)) {
1455
+			throw new EE_Error(sprintf(__('%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', 'event_espresso'), get_class($this), $property));
1456 1456
 		}
1457 1457
 		//just handling escaping of strings for now.
1458
-		if ( is_string( $this->{$property} ) ) {
1459
-			return stripslashes( $this->{$property} );
1458
+		if (is_string($this->{$property} )) {
1459
+			return stripslashes($this->{$property} );
1460 1460
 		}
1461 1461
 		return $this->{$property};
1462 1462
 	}
@@ -1465,19 +1465,19 @@  discard block
 block discarded – undo
1465 1465
 
1466 1466
 	public function populate() {
1467 1467
 		//grab defaults via a new instance of this class.
1468
-		$class_name = get_class( $this );
1468
+		$class_name = get_class($this);
1469 1469
 		$defaults = new $class_name;
1470 1470
 
1471 1471
 		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1472 1472
 		//default from our $defaults object.
1473
-		foreach ( get_object_vars( $defaults ) as $property => $value ) {
1474
-			if ( is_null( $this->{$property} ) ) {
1473
+		foreach (get_object_vars($defaults) as $property => $value) {
1474
+			if (is_null($this->{$property} )) {
1475 1475
 				$this->{$property} = $value;
1476 1476
 			}
1477 1477
 		}
1478 1478
 
1479 1479
 		//cleanup
1480
-		unset( $defaults );
1480
+		unset($defaults);
1481 1481
 	}
1482 1482
 
1483 1483
 
@@ -1569,12 +1569,12 @@  discard block
 block discarded – undo
1569 1569
 	 */
1570 1570
 	public function __construct() {
1571 1571
 		$current_network_main_site = is_multisite() ? get_current_site() : NULL;
1572
-		$current_main_site_id = !empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1;
1572
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1573 1573
 		// set default organization settings
1574 1574
 		$this->current_blog_id = get_current_blog_id();
1575 1575
 		$this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id;
1576
-		$this->ee_ueip_optin = is_main_site() ? get_option( 'ee_ueip_optin', TRUE ) : get_blog_option( $current_main_site_id, 'ee_ueip_optin', TRUE );
1577
-		$this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', FALSE ) : TRUE;
1576
+		$this->ee_ueip_optin = is_main_site() ? get_option('ee_ueip_optin', TRUE) : get_blog_option($current_main_site_id, 'ee_ueip_optin', TRUE);
1577
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', FALSE) : TRUE;
1578 1578
 		$this->post_shortcodes = array();
1579 1579
 		$this->module_route_map = array();
1580 1580
 		$this->module_forward_map = array();
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
 		$this->event_cpt_slug = __('events', 'event_espresso');
1594 1594
 
1595 1595
 		//ueip constant check
1596
-		if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) {
1596
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1597 1597
 			$this->ee_ueip_optin = FALSE;
1598 1598
 			$this->ee_ueip_has_notified = TRUE;
1599 1599
 		}
@@ -1633,8 +1633,8 @@  discard block
 block discarded – undo
1633 1633
 	 *  @return 	string
1634 1634
 	 */
1635 1635
 	public function reg_page_url() {
1636
-		if ( ! $this->reg_page_url ) {
1637
-			$this->reg_page_url = get_permalink( $this->reg_page_id ) . '#checkout';
1636
+		if ( ! $this->reg_page_url) {
1637
+			$this->reg_page_url = get_permalink($this->reg_page_id).'#checkout';
1638 1638
 		}
1639 1639
 		return $this->reg_page_url;
1640 1640
 	}
@@ -1647,12 +1647,12 @@  discard block
 block discarded – undo
1647 1647
 	 *  @return 	string
1648 1648
 	 */
1649 1649
 	public function txn_page_url($query_args = array()) {
1650
-		if ( ! $this->txn_page_url ) {
1651
-			$this->txn_page_url = get_permalink( $this->txn_page_id );
1650
+		if ( ! $this->txn_page_url) {
1651
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1652 1652
 		}
1653
-		if($query_args){
1654
-			return add_query_arg($query_args,$this->txn_page_url);
1655
-		}else{
1653
+		if ($query_args) {
1654
+			return add_query_arg($query_args, $this->txn_page_url);
1655
+		} else {
1656 1656
 			return $this->txn_page_url;
1657 1657
 		}
1658 1658
 	}
@@ -1664,12 +1664,12 @@  discard block
 block discarded – undo
1664 1664
 	 *  @return 	string
1665 1665
 	 */
1666 1666
 	public function thank_you_page_url($query_args = array()) {
1667
-		if ( ! $this->thank_you_page_url ) {
1668
-			$this->thank_you_page_url = get_permalink( $this->thank_you_page_id );
1667
+		if ( ! $this->thank_you_page_url) {
1668
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1669 1669
 		}
1670
-		if($query_args){
1671
-			return add_query_arg($query_args,$this->thank_you_page_url);
1672
-		}else{
1670
+		if ($query_args) {
1671
+			return add_query_arg($query_args, $this->thank_you_page_url);
1672
+		} else {
1673 1673
 			return $this->thank_you_page_url;
1674 1674
 		}
1675 1675
 	}
@@ -1680,8 +1680,8 @@  discard block
 block discarded – undo
1680 1680
 	 *  @return 	string
1681 1681
 	 */
1682 1682
 	public function cancel_page_url() {
1683
-		if ( ! $this->cancel_page_url ) {
1684
-			$this->cancel_page_url = get_permalink( $this->cancel_page_id );
1683
+		if ( ! $this->cancel_page_url) {
1684
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1685 1685
 		}
1686 1686
 		return $this->cancel_page_url;
1687 1687
 	}
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
 		//reset all url properties
1710 1710
 		$this->_reset_urls();
1711 1711
 		//return what to save to db
1712
-		return array_keys( get_object_vars( $this ) );
1712
+		return array_keys(get_object_vars($this));
1713 1713
 	}
1714 1714
 
1715 1715
 }
@@ -1941,39 +1941,39 @@  discard block
 block discarded – undo
1941 1941
 	 * @param null $CNT_ISO
1942 1942
 	 * @return \EE_Currency_Config
1943 1943
 	 */
1944
-	public function __construct( $CNT_ISO = NULL ) {
1944
+	public function __construct($CNT_ISO = NULL) {
1945 1945
 
1946 1946
 		// get country code from organization settings or use default
1947
-		$ORG_CNT = isset( EE_Registry::instance()->CFG->organization ) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL;
1947
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization) && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ? EE_Registry::instance()->CFG->organization->CNT_ISO : NULL;
1948 1948
 		// but override if requested
1949
-		$CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT;
1950
-		EE_Registry::instance()->load_helper( 'Activation' );
1949
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
1950
+		EE_Registry::instance()->load_helper('Activation');
1951 1951
 		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
1952
-		if ( ! empty( $CNT_ISO ) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists( EE_Registry::instance()->load_model( 'Country' )->table() ) ) {
1952
+		if ( ! empty($CNT_ISO) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists(EE_Registry::instance()->load_model('Country')->table())) {
1953 1953
 			// retrieve the country settings from the db, just in case they have been customized
1954
-			$country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO );
1955
-			if ( $country instanceof EE_Country ) {
1956
-				$this->code = $country->currency_code(); 	// currency code: USD, CAD, EUR
1957
-				$this->name = $country->currency_name_single();	// Dollar
1958
-				$this->plural = $country->currency_name_plural(); 	// Dollars
1959
-				$this->sign =  $country->currency_sign(); 			// currency sign: $
1960
-				$this->sign_b4 = $country->currency_sign_before(); 		// currency sign before or after: $TRUE  or  FALSE$
1961
-				$this->dec_plc = $country->currency_decimal_places();	// decimal places: 2 = 0.00  3 = 0.000
1962
-				$this->dec_mrk = $country->currency_decimal_mark();	// decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1963
-				$this->thsnds = $country->currency_thousands_separator();	// thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1954
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
1955
+			if ($country instanceof EE_Country) {
1956
+				$this->code = $country->currency_code(); // currency code: USD, CAD, EUR
1957
+				$this->name = $country->currency_name_single(); // Dollar
1958
+				$this->plural = $country->currency_name_plural(); // Dollars
1959
+				$this->sign = $country->currency_sign(); // currency sign: $
1960
+				$this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE  or  FALSE$
1961
+				$this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
1962
+				$this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1963
+				$this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1964 1964
 			}
1965 1965
 		}
1966 1966
 		// fallback to hardcoded defaults, in case the above failed
1967
-		if ( empty( $this->code )) {
1967
+		if (empty($this->code)) {
1968 1968
 			// set default currency settings
1969
-			$this->code = 'USD'; 	// currency code: USD, CAD, EUR
1970
-			$this->name = __( 'Dollar', 'event_espresso' ); 	// Dollar
1971
-			$this->plural = __( 'Dollars', 'event_espresso' ); 	// Dollars
1972
-			$this->sign =  '$'; 	// currency sign: $
1973
-			$this->sign_b4 = TRUE; 	// currency sign before or after: $TRUE  or  FALSE$
1974
-			$this->dec_plc = 2; 	// decimal places: 2 = 0.00  3 = 0.000
1975
-			$this->dec_mrk = '.'; 	// decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1976
-			$this->thsnds = ','; 	// thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1969
+			$this->code = 'USD'; // currency code: USD, CAD, EUR
1970
+			$this->name = __('Dollar', 'event_espresso'); // Dollar
1971
+			$this->plural = __('Dollars', 'event_espresso'); // Dollars
1972
+			$this->sign = '$'; // currency sign: $
1973
+			$this->sign_b4 = TRUE; // currency sign before or after: $TRUE  or  FALSE$
1974
+			$this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
1975
+			$this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1976
+			$this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1977 1977
 		}
1978 1978
 	}
1979 1979
 }
@@ -2113,7 +2113,7 @@  discard block
 block discarded – undo
2113 2113
 	 * @since 4.8.8.rc.019
2114 2114
 	 */
2115 2115
 	public function do_hooks() {
2116
-		add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' ));
2116
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2117 2117
 	}
2118 2118
 
2119 2119
 
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
 	 * @return void
2122 2122
 	 */
2123 2123
 	public function set_default_reg_status_on_EEM_Event() {
2124
-		EEM_Event::set_default_reg_status( $this->default_STS_ID );
2124
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2125 2125
 	}
2126 2126
 
2127 2127
 
@@ -2226,10 +2226,10 @@  discard block
 block discarded – undo
2226 2226
 	 * @param bool $reset
2227 2227
 	 * @return string
2228 2228
 	 */
2229
-	public function log_file_name( $reset = FALSE ) {
2230
-		if ( empty( $this->log_file_name ) || $reset ) {
2231
-			$this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', TRUE ))) . '.txt';
2232
-			EE_Config::instance()->update_espresso_config( FALSE, FALSE );
2229
+	public function log_file_name($reset = FALSE) {
2230
+		if (empty($this->log_file_name) || $reset) {
2231
+			$this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', TRUE))).'.txt';
2232
+			EE_Config::instance()->update_espresso_config(FALSE, FALSE);
2233 2233
 		}
2234 2234
 		return $this->log_file_name;
2235 2235
 	}
@@ -2241,10 +2241,10 @@  discard block
 block discarded – undo
2241 2241
 	 * @param bool $reset
2242 2242
 	 * @return string
2243 2243
 	 */
2244
-	public function debug_file_name( $reset = FALSE ) {
2245
-		if ( empty( $this->debug_file_name ) || $reset ) {
2246
-			$this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', TRUE ))) . '.txt';
2247
-			EE_Config::instance()->update_espresso_config( FALSE, FALSE );
2244
+	public function debug_file_name($reset = FALSE) {
2245
+		if (empty($this->debug_file_name) || $reset) {
2246
+			$this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', TRUE))).'.txt';
2247
+			EE_Config::instance()->update_espresso_config(FALSE, FALSE);
2248 2248
 		}
2249 2249
 		return $this->debug_file_name;
2250 2250
 	}
@@ -2417,21 +2417,21 @@  discard block
 block discarded – undo
2417 2417
 		// set default map settings
2418 2418
 		$this->use_google_maps = TRUE;
2419 2419
 		// for event details pages (reg page)
2420
-		$this->event_details_map_width = 585; 			// ee_map_width_single
2421
-		$this->event_details_map_height = 362; 			// ee_map_height_single
2422
-		$this->event_details_map_zoom = 14; 			// ee_map_zoom_single
2423
-		$this->event_details_display_nav = TRUE; 			// ee_map_nav_display_single
2424
-		$this->event_details_nav_size = FALSE; 			// ee_map_nav_size_single
2425
-		$this->event_details_control_type = 'default'; 		// ee_map_type_control_single
2426
-		$this->event_details_map_align = 'center'; 			// ee_map_align_single
2420
+		$this->event_details_map_width = 585; // ee_map_width_single
2421
+		$this->event_details_map_height = 362; // ee_map_height_single
2422
+		$this->event_details_map_zoom = 14; // ee_map_zoom_single
2423
+		$this->event_details_display_nav = TRUE; // ee_map_nav_display_single
2424
+		$this->event_details_nav_size = FALSE; // ee_map_nav_size_single
2425
+		$this->event_details_control_type = 'default'; // ee_map_type_control_single
2426
+		$this->event_details_map_align = 'center'; // ee_map_align_single
2427 2427
 		// for event list pages
2428
-		$this->event_list_map_width = 300; 			// ee_map_width
2429
-		$this->event_list_map_height = 185; 		// ee_map_height
2430
-		$this->event_list_map_zoom = 12; 			// ee_map_zoom
2431
-		$this->event_list_display_nav = FALSE; 		// ee_map_nav_display
2432
-		$this->event_list_nav_size = TRUE; 			// ee_map_nav_size
2433
-		$this->event_list_control_type = 'dropdown'; 		// ee_map_type_control
2434
-		$this->event_list_map_align = 'center'; 			// ee_map_align
2428
+		$this->event_list_map_width = 300; // ee_map_width
2429
+		$this->event_list_map_height = 185; // ee_map_height
2430
+		$this->event_list_map_zoom = 12; // ee_map_zoom
2431
+		$this->event_list_display_nav = FALSE; // ee_map_nav_display
2432
+		$this->event_list_nav_size = TRUE; // ee_map_nav_size
2433
+		$this->event_list_control_type = 'dropdown'; // ee_map_type_control
2434
+		$this->event_list_map_align = 'center'; // ee_map_align
2435 2435
 	}
2436 2436
 
2437 2437
 }
@@ -2442,7 +2442,7 @@  discard block
 block discarded – undo
2442 2442
 /**
2443 2443
  * stores Events_Archive settings
2444 2444
  */
2445
-class EE_Events_Archive_Config extends EE_Config_Base{
2445
+class EE_Events_Archive_Config extends EE_Config_Base {
2446 2446
 
2447 2447
 	public $display_status_banner;
2448 2448
 	public $display_description;
@@ -2461,7 +2461,7 @@  discard block
 block discarded – undo
2461 2461
 	/**
2462 2462
 	 *	class constructor
2463 2463
 	 */
2464
-	public function __construct(){
2464
+	public function __construct() {
2465 2465
 		$this->display_status_banner = 0;
2466 2466
 		$this->display_description = 1;
2467 2467
 		$this->display_ticket_selector = 0;
@@ -2481,7 +2481,7 @@  discard block
 block discarded – undo
2481 2481
 /**
2482 2482
  * Stores Event_Single_Config settings
2483 2483
  */
2484
-class EE_Event_Single_Config extends EE_Config_Base{
2484
+class EE_Event_Single_Config extends EE_Config_Base {
2485 2485
 
2486 2486
 	public $display_status_banner_single;
2487 2487
 	public $display_venue;
@@ -2510,7 +2510,7 @@  discard block
 block discarded – undo
2510 2510
 /**
2511 2511
  * Stores Ticket_Selector_Config settings
2512 2512
  */
2513
-class EE_Ticket_Selector_Config extends EE_Config_Base{
2513
+class EE_Ticket_Selector_Config extends EE_Config_Base {
2514 2514
 	public $show_ticket_sale_columns;
2515 2515
 	public $show_ticket_details;
2516 2516
 	public $show_expired_tickets;
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
 	 * @return void
2565 2565
 	 */
2566 2566
 	protected function _set_php_values() {
2567
-		$this->php->max_input_vars = ini_get( 'max_input_vars' );
2567
+		$this->php->max_input_vars = ini_get('max_input_vars');
2568 2568
 		$this->php->version = phpversion();
2569 2569
 	}
2570 2570
 
@@ -2583,8 +2583,8 @@  discard block
 block discarded – undo
2583 2583
 	 *         @type string $msg 		Any message to be displayed.
2584 2584
 	 * }
2585 2585
 	 */
2586
-	public function max_input_vars_limit_check( $input_count = 0 ) {
2587
-		if ( ( $input_count >= $this->php->max_input_vars ) && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >=9 ) ) {
2586
+	public function max_input_vars_limit_check($input_count = 0) {
2587
+		if (($input_count >= $this->php->max_input_vars) && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)) {
2588 2588
 			return  __('The number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.', 'event_espresso');
2589 2589
 		} else {
2590 2590
 			return '';
@@ -2620,7 +2620,7 @@  discard block
 block discarded – undo
2620 2620
  * stores payment gateway info
2621 2621
  * @deprecated
2622 2622
  */
2623
-class EE_Gateway_Config extends EE_Config_Base{
2623
+class EE_Gateway_Config extends EE_Config_Base {
2624 2624
 
2625 2625
 	/**
2626 2626
 	 * Array with keys that are payment gateways slugs, and values are arrays
@@ -2642,9 +2642,9 @@  discard block
 block discarded – undo
2642 2642
 	 *	class constructor
2643 2643
 	 * @deprecated
2644 2644
 	 */
2645
-	public function __construct(){
2645
+	public function __construct() {
2646 2646
 		$this->payment_settings = array();
2647
-		$this->active_gateways = array( 'Invoice' => FALSE );
2647
+		$this->active_gateways = array('Invoice' => FALSE);
2648 2648
 	}
2649 2649
 }
2650 2650
 
Please login to merge, or discard this patch.
modules/single_page_checkout/inc/EE_Checkout.class.php 1 patch
Spacing   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 		$this->reg_page_base_url = EE_Registry::instance()->CFG->core->reg_page_url();
243 243
 		$this->thank_you_page_url = EE_Registry::instance()->CFG->core->thank_you_page_url();
244 244
 		$this->cancel_page_url = EE_Registry::instance()->CFG->core->cancel_page_url();
245
-		$this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', TRUE );
245
+		$this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', TRUE);
246 246
 		$this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->ajax;
247
-		$this->reg_cache_where_params = array( 'order_by' => array( 'REG_count' => 'ASC' ));
247
+		$this->reg_cache_where_params = array('order_by' => array('REG_count' => 'ASC'));
248 248
 	}
249 249
 
250 250
 
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 	 * @return array
255 255
 	 */
256 256
 	public function any_reg_status_updated() {
257
-		foreach ( $this->reg_status_updated as $reg_status ) {
258
-			if ( $reg_status ) {
257
+		foreach ($this->reg_status_updated as $reg_status) {
258
+			if ($reg_status) {
259 259
 				return true;
260 260
 			}
261 261
 		}
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	 * @param $REG_ID
269 269
 	 * @return array
270 270
 	 */
271
-	public function reg_status_updated( $REG_ID ) {
272
-		return isset( $this->reg_status_updated[ $REG_ID ] ) ? $this->reg_status_updated[ $REG_ID ] : false;
271
+	public function reg_status_updated($REG_ID) {
272
+		return isset($this->reg_status_updated[$REG_ID]) ? $this->reg_status_updated[$REG_ID] : false;
273 273
 	}
274 274
 
275 275
 
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 	 * @param $REG_ID
279 279
 	 * @param $reg_status
280 280
 	 */
281
-	public function set_reg_status_updated( $REG_ID, $reg_status ) {
282
-		$this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN );
281
+	public function set_reg_status_updated($REG_ID, $reg_status) {
282
+		$this->reg_status_updated[$REG_ID] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN);
283 283
 	}
284 284
 
285 285
 
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 * can ONLY be set by the  Finalize_Registration reg step
301 301
 	 */
302 302
 	public function set_exit_spco() {
303
-		if ( $this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) {
303
+		if ($this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
304 304
 			$this->exit_spco = true;
305 305
 		}
306 306
 	}
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	public function reset_for_current_request() {
319 319
 		$this->process_form_submission = FALSE;
320
-		$this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', true );
320
+		$this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true);
321 321
 		$this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->front_ajax;
322 322
 		$this->continue_reg = true;
323 323
 		$this->redirect = false;
324 324
 		// don't reset the cached redirect form if we're about to be asked to display it !!!
325
-		if ( EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ) !== 'redirect_form' ) {
325
+		if (EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step') !== 'redirect_form') {
326 326
 			$this->redirect_form = '';
327 327
 		}
328 328
 		$this->redirect_url = '';
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param EE_SPCO_Reg_Step $reg_step_obj
340 340
 	 * @return    void
341 341
 	 */
342
-	public function add_reg_step( EE_SPCO_Reg_Step $reg_step_obj ) {
343
-		$this->reg_steps[ $reg_step_obj->slug()  ] = $reg_step_obj;
342
+	public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj) {
343
+		$this->reg_steps[$reg_step_obj->slug()] = $reg_step_obj;
344 344
 	}
345 345
 
346 346
 
@@ -356,22 +356,22 @@  discard block
 block discarded – undo
356 356
 	 * @param string $reg_step_slug
357 357
 	 * @return    void
358 358
 	 */
359
-	public function skip_reg_step( $reg_step_slug = '' ) {
360
-		$step_to_skip = $this->find_reg_step( $reg_step_slug );
361
-		if ( $step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step() ) {
362
-			$step_to_skip->set_is_current_step( false );
359
+	public function skip_reg_step($reg_step_slug = '') {
360
+		$step_to_skip = $this->find_reg_step($reg_step_slug);
361
+		if ($step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step()) {
362
+			$step_to_skip->set_is_current_step(false);
363 363
 			$step_to_skip->set_completed();
364 364
 			// advance to the next step
365
-			$this->set_current_step( $this->next_step->slug() );
365
+			$this->set_current_step($this->next_step->slug());
366 366
 			// also reset the step param in the request in case any other code references that directly
367
-			EE_Registry::instance()->REQ->set( 'step', $this->current_step->slug() );
367
+			EE_Registry::instance()->REQ->set('step', $this->current_step->slug());
368 368
 			// since we are skipping a step and setting the current step to be what was previously the next step,
369 369
 			// we need to check that the next step is now correct, and not still set to the current step.
370
-			if ( $this->current_step->slug() == $this->next_step->slug() ) {
370
+			if ($this->current_step->slug() == $this->next_step->slug()) {
371 371
 				// correctly setup the next step
372 372
 				$this->set_next_step();
373 373
 			}
374
-			$this->set_reg_step_initiated( $this->current_step );
374
+			$this->set_reg_step_initiated($this->current_step);
375 375
 		}
376 376
 	}
377 377
 
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
 	 * @param bool   $reset whether to reset reg steps after removal
386 386
 	 * @throws EE_Error
387 387
 	 */
388
-	public function remove_reg_step( $reg_step_slug = '', $reset = true ) {
389
-		unset( $this->reg_steps[ $reg_step_slug  ] );
390
-		if ( $this->transaction instanceof EE_Transaction ) {
388
+	public function remove_reg_step($reg_step_slug = '', $reset = true) {
389
+		unset($this->reg_steps[$reg_step_slug]);
390
+		if ($this->transaction instanceof EE_Transaction) {
391 391
 			/** @type EE_Transaction_Processor $transaction_processor */
392
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
392
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
393 393
 			// now remove reg step from TXN and save
394
-			$transaction_processor->remove_reg_step( $this->transaction, $reg_step_slug );
394
+			$transaction_processor->remove_reg_step($this->transaction, $reg_step_slug);
395 395
 			$this->transaction->save();
396 396
 		}
397
-		if ( $reset ) {
397
+		if ($reset) {
398 398
 			$this->reset_reg_steps();
399 399
 		}
400 400
 	}
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 	 * @param int    $order
410 410
 	 * @return    void
411 411
 	 */
412
-	public function set_reg_step_order( $reg_step_slug = '', $order = 100 ) {
413
-		if ( isset( $this->reg_steps[ $reg_step_slug  ] )) {
414
-			$this->reg_steps[ $reg_step_slug ]->set_order( $order );
412
+	public function set_reg_step_order($reg_step_slug = '', $order = 100) {
413
+		if (isset($this->reg_steps[$reg_step_slug])) {
414
+			$this->reg_steps[$reg_step_slug]->set_order($order);
415 415
 		}
416 416
 	}
417 417
 
@@ -424,25 +424,25 @@  discard block
 block discarded – undo
424 424
 	 * @param string $current_step
425 425
 	 * @return    void
426 426
 	 */
427
-	public function set_current_step( $current_step ) {
427
+	public function set_current_step($current_step) {
428 428
 		// grab what step we're on
429
-		$this->current_step = isset( $this->reg_steps[ $current_step ] ) ? $this->reg_steps[ $current_step ] : reset( $this->reg_steps );
429
+		$this->current_step = isset($this->reg_steps[$current_step]) ? $this->reg_steps[$current_step] : reset($this->reg_steps);
430 430
 		// verify instance
431
-		if ( $this->current_step instanceof EE_SPCO_Reg_Step ) {
431
+		if ($this->current_step instanceof EE_SPCO_Reg_Step) {
432 432
 			// we don't want to repeat completed steps if this is the first time through SPCO
433
-			if ( $this->continue_reg && $this->current_step->completed() && ! $this->revisit ) {
433
+			if ($this->continue_reg && $this->current_step->completed() && ! $this->revisit) {
434 434
 				// so advance to the next step
435 435
 				$this->set_next_step();
436
-				if ( $this->next_step instanceof EE_SPCO_Reg_Step ) {
436
+				if ($this->next_step instanceof EE_SPCO_Reg_Step) {
437 437
 					// and attempt to set it as the current step
438
-					$this->set_current_step( $this->next_step->slug() );
438
+					$this->set_current_step($this->next_step->slug());
439 439
 				}
440 440
 				return;
441 441
 			}
442
-			$this->current_step->set_is_current_step( TRUE );
442
+			$this->current_step->set_is_current_step(TRUE);
443 443
 		} else {
444 444
 			EE_Error::add_error(
445
-				__( 'The current step could not be set.', 'event_espresso' ),
445
+				__('The current step could not be set.', 'event_espresso'),
446 446
 				__FILE__, __FUNCTION__, __LINE__
447 447
 			);
448 448
 		}
@@ -459,20 +459,20 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	public function set_next_step() {
461 461
 		// set pointer to start of array
462
-		reset( $this->reg_steps );
462
+		reset($this->reg_steps);
463 463
 		// if there is more than one step
464
-		if ( count( $this->reg_steps ) > 1 ) {
464
+		if (count($this->reg_steps) > 1) {
465 465
 			// advance to the current step and set pointer
466
-			while ( key( $this->reg_steps ) != $this->current_step->slug() && key( $this->reg_steps ) != '' ) {
467
-				next( $this->reg_steps );
466
+			while (key($this->reg_steps) != $this->current_step->slug() && key($this->reg_steps) != '') {
467
+				next($this->reg_steps);
468 468
 			}
469 469
 		}
470 470
 		// advance one more spot ( if it exists )
471
-		$this->next_step = next( $this->reg_steps );
471
+		$this->next_step = next($this->reg_steps);
472 472
 		// verify instance
473
-		$this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step  : NULL;
473
+		$this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL;
474 474
 		// then back to current step to reset
475
-		prev( $this->reg_steps );
475
+		prev($this->reg_steps);
476 476
 	}
477 477
 
478 478
 
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
 	 *  @return 	EE_SPCO_Reg_Step | null
487 487
 	 */
488 488
 	public function get_next_reg_step() {
489
-		$next = next( $this->reg_steps );
490
-		prev( $this->reg_steps );
489
+		$next = next($this->reg_steps);
490
+		prev($this->reg_steps);
491 491
 		return $next instanceof EE_SPCO_Reg_Step ? $next : null;
492 492
 	}
493 493
 
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 	 *  @return 	EE_SPCO_Reg_Step | null
503 503
 	 */
504 504
 	public function get_prev_reg_step() {
505
-		$prev = prev( $this->reg_steps );
506
-		next( $this->reg_steps );
505
+		$prev = prev($this->reg_steps);
506
+		next($this->reg_steps);
507 507
 		return $prev instanceof EE_SPCO_Reg_Step ? $prev : null;
508 508
 	}
509 509
 
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
 	 * @return void
517 517
 	 */
518 518
 	public function sort_reg_steps() {
519
-		$reg_step_sorting_callback = apply_filters( 'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback' );
520
-		uasort( $this->reg_steps, array( $this, $reg_step_sorting_callback ));
519
+		$reg_step_sorting_callback = apply_filters('FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback');
520
+		uasort($this->reg_steps, array($this, $reg_step_sorting_callback));
521 521
 	}
522 522
 
523 523
 
@@ -530,19 +530,19 @@  discard block
 block discarded – undo
530 530
 	 * @param string $reg_step_slug
531 531
 	 * @return EE_SPCO_Reg_Step|null
532 532
 	 */
533
-	public function find_reg_step( $reg_step_slug = '' ) {
534
-		if ( ! empty( $reg_step_slug ) ) {
533
+	public function find_reg_step($reg_step_slug = '') {
534
+		if ( ! empty($reg_step_slug)) {
535 535
 			// copy reg step array
536 536
 			$reg_steps = $this->reg_steps;
537 537
 			// set pointer to start of array
538
-			reset( $reg_steps );
538
+			reset($reg_steps);
539 539
 			// if there is more than one step
540
-			if ( count( $reg_steps ) > 1 ) {
540
+			if (count($reg_steps) > 1) {
541 541
 				// advance to the current step and set pointer
542
-				while ( key( $reg_steps ) != $reg_step_slug && key( $reg_steps ) != '' ) {
543
-					next( $reg_steps );
542
+				while (key($reg_steps) != $reg_step_slug && key($reg_steps) != '') {
543
+					next($reg_steps);
544 544
 				}
545
-				return current( $reg_steps );
545
+				return current($reg_steps);
546 546
 			}
547 547
 		}
548 548
 		return null;
@@ -558,17 +558,17 @@  discard block
 block discarded – undo
558 558
 	 * @param EE_SPCO_Reg_Step $reg_step_B
559 559
 	 * @return array()
560 560
 	 */
561
-	public function reg_step_sorting_callback( EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B ) {
561
+	public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B) {
562 562
 		// send finalize_registration step to the end of the array
563
-		if ( $reg_step_A->slug() == 'finalize_registration' ) {
563
+		if ($reg_step_A->slug() == 'finalize_registration') {
564 564
 			return 1;
565
-		} else if ( $reg_step_B->slug() == 'finalize_registration' ) {
565
+		} else if ($reg_step_B->slug() == 'finalize_registration') {
566 566
 			return -1;
567 567
 		}
568
-		if ( $reg_step_A->order() == $reg_step_B->order() ) {
568
+		if ($reg_step_A->order() == $reg_step_B->order()) {
569 569
 			return 0;
570 570
 		}
571
-		return ( $reg_step_A->order() > $reg_step_B->order() ) ? 1 : -1;
571
+		return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1;
572 572
 	}
573 573
 
574 574
 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 	 * @access 	public
580 580
 	 * @param 	EE_SPCO_Reg_Step $reg_step
581 581
 	 */
582
-	public function set_reg_step_initiated( EE_SPCO_Reg_Step $reg_step ) {
582
+	public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step) {
583 583
 		// call set_reg_step_initiated ???
584 584
 		if (
585 585
 			// first time visiting SPCO ?
@@ -588,13 +588,13 @@  discard block
 block discarded – undo
588 588
 			&& $this->action === 'display_spco_reg_step'
589 589
 		) {
590 590
 			/** @type EE_Transaction_Processor $transaction_processor */
591
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
591
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
592 592
 			// set the start time for this reg step
593
-			if ( ! $transaction_processor->set_reg_step_initiated( $this->transaction, $reg_step->slug() ) ) {
594
-				if ( WP_DEBUG ) {
593
+			if ( ! $transaction_processor->set_reg_step_initiated($this->transaction, $reg_step->slug())) {
594
+				if (WP_DEBUG) {
595 595
 					EE_Error::add_error(
596 596
 						sprintf(
597
-							__( 'The "%1$s" registration step was not initialized properly.', 'event_espresso' ),
597
+							__('The "%1$s" registration step was not initialized properly.', 'event_espresso'),
598 598
 							$reg_step->name()
599 599
 						),
600 600
 						__FILE__, __FUNCTION__, __LINE__
@@ -613,10 +613,10 @@  discard block
 block discarded – undo
613 613
 	 * 	@return 	void
614 614
 	 */
615 615
 	public function set_reg_step_JSON_info() {
616
-		EE_Registry::$i18n_js_strings[ 'reg_steps' ] = array();
616
+		EE_Registry::$i18n_js_strings['reg_steps'] = array();
617 617
 		// pass basic reg step data to JS
618
-		foreach ( $this->reg_steps as $reg_step ) {
619
-			EE_Registry::$i18n_js_strings[ 'reg_steps' ][] = $reg_step->slug();
618
+		foreach ($this->reg_steps as $reg_step) {
619
+			EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug();
620 620
 		}
621 621
 		// reset reg step html
622 622
 //		$this->json_response->set_reg_step_html( '' );
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	 */
633 633
 	public function reset_reg_steps() {
634 634
 		$this->sort_reg_steps();
635
-		$this->set_current_step( EE_Registry::instance()->REQ->get( 'step' ));
635
+		$this->set_current_step(EE_Registry::instance()->REQ->get('step'));
636 636
 		$this->set_next_step();
637 637
 		// the text that appears on the reg step form submit button
638 638
 		$this->current_step->set_submit_button_text();
@@ -649,9 +649,9 @@  discard block
 block discarded – undo
649 649
 	 */
650 650
 	public function get_registration_time_limit() {
651 651
 
652
-		$registration_time_limit = (float)( EE_Registry::instance()	->SSN->expiration() - time() );
652
+		$registration_time_limit = (float) (EE_Registry::instance()	->SSN->expiration() - time());
653 653
 		$time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s';
654
-		$registration_time_limit = gmdate( $time_limit_format, $registration_time_limit );
654
+		$registration_time_limit = gmdate($time_limit_format, $registration_time_limit);
655 655
 		return apply_filters(
656 656
 			'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit',
657 657
 			$registration_time_limit
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 		//		overpaid TXN
672 672
 		//		free TXN ( total = 0.00 )
673 673
 		// then payment required is TRUE
674
-		return ! ( $this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free() ) ? TRUE : FALSE;
674
+		return ! ($this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free()) ? TRUE : FALSE;
675 675
 	}
676 676
 
677 677
 
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
 	 */
685 685
 	public function initialize_txn_reg_steps_array() {
686 686
 		$txn_reg_steps_array = array();
687
-		foreach ( $this->reg_steps as $reg_step ) {
688
-			$txn_reg_steps_array[ $reg_step->slug() ] = FALSE;
687
+		foreach ($this->reg_steps as $reg_step) {
688
+			$txn_reg_steps_array[$reg_step->slug()] = FALSE;
689 689
 		}
690 690
 		return $txn_reg_steps_array;
691 691
 	}
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
 	public function update_txn_reg_steps_array() {
702 702
 		$updated = FALSE;
703 703
 		/** @type EE_Transaction_Processor $transaction_processor */
704
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
705
-		foreach ( $this->reg_steps as $reg_step ) {
706
-			if ( $reg_step->completed() ) {
707
-				$updated = $transaction_processor->set_reg_step_completed( $this->transaction, $reg_step->slug() ) ? TRUE : $updated;
704
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
705
+		foreach ($this->reg_steps as $reg_step) {
706
+			if ($reg_step->completed()) {
707
+				$updated = $transaction_processor->set_reg_step_completed($this->transaction, $reg_step->slug()) ? TRUE : $updated;
708 708
 			}
709 709
 		}
710
-		if ( $updated ) {
710
+		if ($updated) {
711 711
 			$this->transaction->save();
712 712
 		}
713 713
 		return $updated;
@@ -722,14 +722,14 @@  discard block
 block discarded – undo
722 722
 	 * 	@return 	void
723 723
 	 */
724 724
 	public function stash_transaction_and_checkout() {
725
-		if ( ! $this->revisit ) {
725
+		if ( ! $this->revisit) {
726 726
 			$this->update_txn_reg_steps_array();
727 727
 		}
728 728
 		$this->track_transaction_and_registration_status_updates();
729 729
 		// save all data to the db, but suppress errors
730 730
 		//$this->save_all_data( FALSE );
731 731
 		// cache the checkout in the session
732
-		EE_Registry::instance()->SSN->set_checkout( $this );
732
+		EE_Registry::instance()->SSN->set_checkout($this);
733 733
 	}
734 734
 
735 735
 
@@ -745,21 +745,21 @@  discard block
 block discarded – undo
745 745
 	 */
746 746
 	public function track_transaction_and_registration_status_updates() {
747 747
 		// verify the transaction
748
-		if ( $this->transaction instanceof EE_Transaction ) {
748
+		if ($this->transaction instanceof EE_Transaction) {
749 749
 			/** @type EE_Transaction_Payments $transaction_payments */
750
-			$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
750
+			$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
751 751
 			/** @type EE_Transaction_Processor $transaction_processor */
752
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
752
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
753 753
 			// has there been a TXN status change during this checkout?
754
-			if ( $transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated() ) {
754
+			if ($transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated()) {
755 755
 				$this->txn_status_updated = true;
756 756
 			}
757 757
 			/** @type EE_Registration_Processor $registration_processor */
758
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
758
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
759 759
 			// grab the saved registrations from the transaction
760
-			foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) {
761
-				if ( $registration_processor->reg_status_updated( $registration->ID() ) ) {
762
-					$this->set_reg_status_updated( $registration->ID(), true );
760
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
761
+				if ($registration_processor->reg_status_updated($registration->ID())) {
762
+					$this->set_reg_status_updated($registration->ID(), true);
763 763
 				}
764 764
 			}
765 765
 		}
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
 	 * @param 	EE_Registration 	$registration
782 782
 	 * 	@return 	bool
783 783
 	 */
784
-	public function visit_allows_processing_of_this_registration( EE_Registration $registration ) {
785
-		return ! $this->revisit || $this->primary_revisit || ( $this->revisit && $this->reg_url_link == $registration->reg_url_link() ) ? TRUE : FALSE;
784
+	public function visit_allows_processing_of_this_registration(EE_Registration $registration) {
785
+		return ! $this->revisit || $this->primary_revisit || ($this->revisit && $this->reg_url_link == $registration->reg_url_link()) ? TRUE : FALSE;
786 786
 	}
787 787
 
788 788
 
@@ -807,18 +807,18 @@  discard block
 block discarded – undo
807 807
 	 * @param bool $show_errors
808 808
 	 * @return bool
809 809
 	 */
810
-	public function save_all_data( $show_errors = TRUE ) {
810
+	public function save_all_data($show_errors = TRUE) {
811 811
 		// verify the transaction
812
-		if ( $this->transaction instanceof EE_Transaction ) {
812
+		if ($this->transaction instanceof EE_Transaction) {
813 813
 			// save to ensure that TXN has ID
814 814
 			$this->transaction->save();
815 815
 			// grab the saved registrations from the transaction
816
-			foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as  $registration ) {
817
-				$this->_save_registration( $registration, $show_errors );
816
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as  $registration) {
817
+				$this->_save_registration($registration, $show_errors);
818 818
 			}
819 819
 		} else {
820
-			if ( $show_errors ) {
821
-				EE_Error::add_error( __( 'A valid Transaction was not found when attempting to save your registration information.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
820
+			if ($show_errors) {
821
+				EE_Error::add_error(__('A valid Transaction was not found when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
822 822
 			}
823 823
 			return FALSE;
824 824
 		}
@@ -833,32 +833,32 @@  discard block
 block discarded – undo
833 833
 	 * @param bool $show_errors
834 834
 	 * @return void
835 835
 	 */
836
-	private function _save_registration( $registration, $show_errors = TRUE  ) {
836
+	private function _save_registration($registration, $show_errors = TRUE) {
837 837
 		// verify object
838
-		if ( $registration instanceof EE_Registration ) {
838
+		if ($registration instanceof EE_Registration) {
839 839
 			// should this registration be processed during this visit ?
840
-			if ( $this->visit_allows_processing_of_this_registration( $registration ) ) {
840
+			if ($this->visit_allows_processing_of_this_registration($registration)) {
841 841
 				//set TXN ID
842
-				if ( ! $registration->transaction_ID() ) {
843
-					$registration->set_transaction_id( $this->transaction->ID() );
842
+				if ( ! $registration->transaction_ID()) {
843
+					$registration->set_transaction_id($this->transaction->ID());
844 844
 				}
845 845
 				// verify and save the attendee
846
-				$this->_save_registration_attendee( $registration, $show_errors );
846
+				$this->_save_registration_attendee($registration, $show_errors);
847 847
 				// save answers to reg form questions
848
-				$this->_save_registration_answers( $registration, $show_errors );
848
+				$this->_save_registration_answers($registration, $show_errors);
849 849
 				// save changes
850 850
 				$registration->save();
851 851
 				// update txn cache
852
-				if ( ! $this->transaction->update_cache_after_object_save( 'Registration', $registration )) {
853
-					if ( $show_errors ) {
854
-						EE_Error::add_error( __( 'The newly saved Registration object could not be cached on the Transaction.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
852
+				if ( ! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
853
+					if ($show_errors) {
854
+						EE_Error::add_error(__('The newly saved Registration object could not be cached on the Transaction.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
855 855
 					}
856 856
 				}
857 857
 			}
858 858
 		} else {
859
-			if ( $show_errors ) {
859
+			if ($show_errors) {
860 860
 				EE_Error::add_error(
861
-					__( 'An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso' ),
861
+					__('An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso'),
862 862
 					__FILE__, __FUNCTION__, __LINE__
863 863
 				);
864 864
 			}
@@ -874,26 +874,26 @@  discard block
 block discarded – undo
874 874
 	 * @param bool $show_errors
875 875
 	 * @return void
876 876
 	 */
877
-	private function _save_registration_attendee( $registration, $show_errors = TRUE ) {
878
-		if ( $registration->attendee() instanceof EE_Attendee ) {
877
+	private function _save_registration_attendee($registration, $show_errors = TRUE) {
878
+		if ($registration->attendee() instanceof EE_Attendee) {
879 879
 			// save so that ATT has ID
880 880
 			$registration->attendee()->save();
881
-			if ( ! $registration->update_cache_after_object_save( 'Attendee', $registration->attendee() )) {
882
-				if ( $show_errors ) {
881
+			if ( ! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
882
+				if ($show_errors) {
883 883
 					EE_Error::add_error(
884
-						__( 'The newly saved Attendee object could not be cached on the registration.', 'event_espresso' ),
884
+						__('The newly saved Attendee object could not be cached on the registration.', 'event_espresso'),
885 885
 						__FILE__, __FUNCTION__, __LINE__
886 886
 					);
887 887
 				}
888 888
 			}
889 889
 		} else {
890
-			if ( $show_errors ) {
890
+			if ($show_errors) {
891 891
 				ob_start();
892
-				var_dump( $registration->attendee() );
892
+				var_dump($registration->attendee());
893 893
 				EE_Error::add_error(
894 894
 					sprintf(
895 895
 						'%1$s||%1$s $attendee = %2$s',
896
-						__( 'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso' ),
896
+						__('Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso'),
897 897
 						ob_get_clean()
898 898
 					),
899 899
 					__FILE__, __FUNCTION__, __LINE__
@@ -911,25 +911,25 @@  discard block
 block discarded – undo
911 911
 	 * @param bool $show_errors
912 912
 	 * @return void
913 913
 	 */
914
-	private function _save_registration_answers( $registration, $show_errors = TRUE ) {
914
+	private function _save_registration_answers($registration, $show_errors = TRUE) {
915 915
 		// now save the answers
916
-		foreach ( $registration->answers() as $cache_key => $answer ) {
916
+		foreach ($registration->answers() as $cache_key => $answer) {
917 917
 			// verify object
918
-			if ( $answer instanceof EE_Answer ) {
919
-				$answer->set_registration( $registration->ID() );
918
+			if ($answer instanceof EE_Answer) {
919
+				$answer->set_registration($registration->ID());
920 920
 				$answer->save();
921
-				if ( ! $registration->update_cache_after_object_save( 'Answer', $answer, $cache_key )) {
922
-					if ( $show_errors ) {
921
+				if ( ! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
922
+					if ($show_errors) {
923 923
 						EE_Error::add_error(
924
-							__( 'The newly saved Answer object could not be cached on the registration.', 'event_espresso' ),
924
+							__('The newly saved Answer object could not be cached on the registration.', 'event_espresso'),
925 925
 							__FILE__, __FUNCTION__, __LINE__
926 926
 						);
927 927
 					}
928 928
 				}
929 929
 			} else {
930
-				if ( $show_errors ) {
930
+				if ($show_errors) {
931 931
 					EE_Error::add_error(
932
-						__( 'An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso' ),
932
+						__('An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso'),
933 933
 						__FILE__, __FUNCTION__, __LINE__
934 934
 					);
935 935
 				}
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 	 * @param bool $from_db
948 948
 	 * @return bool
949 949
 	 */
950
-	public function refresh_all_entities( $from_db = false ) {
950
+	public function refresh_all_entities($from_db = false) {
951 951
 		$from_db = $this->current_step->is_final_step() || $this->action == 'process_gateway_response' ? true : $from_db;
952 952
 		//$this->log(
953 953
 		//	__CLASS__, __FUNCTION__, __LINE__,
@@ -968,11 +968,11 @@  discard block
 block discarded – undo
968 968
 	 */
969 969
 	protected function refresh_from_db() {
970 970
 		// verify the transaction
971
-		if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) {
971
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
972 972
 			// pull fresh TXN data from the db
973
-			$this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db( $this->transaction->ID() );
973
+			$this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID());
974 974
 			// update EE_Checkout's cached primary_attendee object
975
-			$this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db( $this->transaction );
975
+			$this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction);
976 976
 			// update EE_Checkout's cached payment object
977 977
 			$payment = $this->transaction->last_payment();
978 978
 			$this->payment = $payment instanceof EE_Payment ? $payment : $this->payment;
@@ -980,15 +980,15 @@  discard block
 block discarded – undo
980 980
 			$payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null;
981 981
 			$this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method : $this->payment_method;
982 982
 			//now refresh the cart, based on the TXN
983
-			$this->cart = EE_Cart::get_cart_from_txn( $this->transaction );
983
+			$this->cart = EE_Cart::get_cart_from_txn($this->transaction);
984 984
 			// verify and update the cart because inaccurate totals are not so much fun
985
-			if ( $this->cart instanceof EE_Cart ) {
985
+			if ($this->cart instanceof EE_Cart) {
986 986
 				$this->cart->get_grand_total()->recalculate_total_including_taxes();
987 987
 			} else {
988
-				$this->cart = EE_Registry::instance()->load_core( 'Cart' );
988
+				$this->cart = EE_Registry::instance()->load_core('Cart');
989 989
 			}
990 990
 		} else {
991
-			EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
991
+			EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
992 992
 			return FALSE;
993 993
 		}
994 994
 		return TRUE;
@@ -1002,24 +1002,24 @@  discard block
 block discarded – undo
1002 1002
 	 * @param   EE_Transaction $transaction
1003 1003
 	 * @return  EE_Attendee | null
1004 1004
 	 */
1005
-	protected function _refresh_primary_attendee_obj_from_db( EE_Transaction $transaction ) {
1005
+	protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction) {
1006 1006
 
1007 1007
 		$primary_attendee_obj = null;
1008 1008
 		// grab the saved registrations from the transaction
1009
-		foreach ( $transaction->registrations( $this->reg_cache_where_params, true ) as $registration ) {
1009
+		foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) {
1010 1010
 			// verify object
1011
-			if ( $registration instanceof EE_Registration ) {
1011
+			if ($registration instanceof EE_Registration) {
1012 1012
 				$attendee = $registration->attendee();
1013 1013
 				// verify object
1014
-				if ( $attendee instanceof EE_Attendee  ) {
1014
+				if ($attendee instanceof EE_Attendee) {
1015 1015
 					// maybe cache primary_attendee_obj ?
1016
-					if ( $registration->is_primary_registrant() ) {
1016
+					if ($registration->is_primary_registrant()) {
1017 1017
 						$primary_attendee_obj = $attendee;
1018 1018
 					}
1019 1019
 				}
1020 1020
 			} else {
1021 1021
 				EE_Error::add_error(
1022
-						__( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ),
1022
+						__('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'),
1023 1023
 						__FILE__, __FUNCTION__, __LINE__
1024 1024
 				);
1025 1025
 			}
@@ -1039,43 +1039,43 @@  discard block
 block discarded – undo
1039 1039
 	 */
1040 1040
 	protected function refresh_entity_map() {
1041 1041
 		// verify the transaction
1042
-		if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) {
1042
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1043 1043
 			// never cache payment info
1044
-			$this->transaction->clear_cache( 'Payment' );
1044
+			$this->transaction->clear_cache('Payment');
1045 1045
 			/** @type EE_Transaction_Processor $transaction_processor */
1046
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1046
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1047 1047
 			// is the Payment Options Reg Step completed ?
1048
-			if ( $transaction_processor->reg_step_completed( $this->transaction, 'payment_options' ) ) {
1048
+			if ($transaction_processor->reg_step_completed($this->transaction, 'payment_options')) {
1049 1049
 				// then check for payments and update TXN accordingly
1050 1050
 				/** @type EE_Transaction_Payments $transaction_payments */
1051
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1052
-				$transaction_payments->calculate_total_payments_and_update_status( $this->transaction );
1051
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1052
+				$transaction_payments->calculate_total_payments_and_update_status($this->transaction);
1053 1053
 			}
1054 1054
 			// grab the saved registrations from the transaction
1055
-			foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $reg_cache_ID => $registration ) {
1056
-				$this->_refresh_registration( $reg_cache_ID, $registration );
1055
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration) {
1056
+				$this->_refresh_registration($reg_cache_ID, $registration);
1057 1057
 			}
1058 1058
 			// make sure our cached TXN is added to the model entity mapper
1059
-			$this->transaction = $this->transaction->get_model()->refresh_entity_map_with( $this->transaction->ID(), $this->transaction );
1059
+			$this->transaction = $this->transaction->get_model()->refresh_entity_map_with($this->transaction->ID(), $this->transaction);
1060 1060
 
1061 1061
 		} else {
1062
-			EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
1062
+			EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1063 1063
 			return FALSE;
1064 1064
 		}
1065 1065
 		// verify and update the cart because inaccurate totals are not so much fun
1066
-		if ( $this->cart instanceof EE_Cart ) {
1066
+		if ($this->cart instanceof EE_Cart) {
1067 1067
 			$grand_total = $this->cart->get_grand_total();
1068
-			if ( $grand_total instanceof EE_Line_Item && $grand_total->ID() ) {
1068
+			if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) {
1069 1069
 				$grand_total->recalculate_total_including_taxes();
1070 1070
 				$grand_total = $grand_total->get_model()->refresh_entity_map_with(
1071 1071
 					$this->cart->get_grand_total()->ID(),
1072 1072
 					$this->cart->get_grand_total()
1073 1073
 				);
1074 1074
 			}
1075
-			if ( $grand_total instanceof EE_Line_Item ) {
1076
-				$this->cart = EE_Cart::instance( $grand_total );
1075
+			if ($grand_total instanceof EE_Line_Item) {
1076
+				$this->cart = EE_Cart::instance($grand_total);
1077 1077
 			} else {
1078
-				EE_Error::add_error( __( 'A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1078
+				EE_Error::add_error(__('A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1079 1079
 				return false;
1080 1080
 			}
1081 1081
 		}
@@ -1091,19 +1091,19 @@  discard block
 block discarded – undo
1091 1091
 	 * @param 	EE_Registration 	$registration
1092 1092
 	 * @return void
1093 1093
 	 */
1094
-	protected function _refresh_registration( $reg_cache_ID, $registration ) {
1094
+	protected function _refresh_registration($reg_cache_ID, $registration) {
1095 1095
 
1096 1096
 		// verify object
1097
-		if ( $registration instanceof EE_Registration ) {
1097
+		if ($registration instanceof EE_Registration) {
1098 1098
 			// update the entity mapper attendee
1099
-			$this->_refresh_registration_attendee( $registration );
1099
+			$this->_refresh_registration_attendee($registration);
1100 1100
 			// update the entity mapper answers for reg form questions
1101
-			$this->_refresh_registration_answers( $registration );
1101
+			$this->_refresh_registration_answers($registration);
1102 1102
 			// make sure the cached registration is added to the model entity mapper
1103
-			$registration->get_model()->refresh_entity_map_with( $reg_cache_ID, $registration );
1103
+			$registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration);
1104 1104
 		} else {
1105 1105
 			EE_Error::add_error(
1106
-				__( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ),
1106
+				__('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'),
1107 1107
 				__FILE__, __FUNCTION__, __LINE__
1108 1108
 			);
1109 1109
 		}
@@ -1117,15 +1117,15 @@  discard block
 block discarded – undo
1117 1117
 	 * @param 	EE_Registration 	$registration
1118 1118
 	 * @return void
1119 1119
 	 */
1120
-	protected function _refresh_registration_attendee( $registration ) {
1120
+	protected function _refresh_registration_attendee($registration) {
1121 1121
 
1122 1122
 		$attendee = $registration->attendee();
1123 1123
 		// verify object
1124
-		if ( $attendee instanceof EE_Attendee && $attendee->ID() ) {
1124
+		if ($attendee instanceof EE_Attendee && $attendee->ID()) {
1125 1125
 			// make sure the cached attendee is added to the model entity mapper
1126
-			$registration->attendee()->get_model()->refresh_entity_map_with( $attendee->ID(), $attendee );
1126
+			$registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee);
1127 1127
 			// maybe cache primary_attendee_obj ?
1128
-			if ( $registration->is_primary_registrant() ) {
1128
+			if ($registration->is_primary_registrant()) {
1129 1129
 				$this->primary_attendee_obj = $attendee;
1130 1130
 			}
1131 1131
 		}
@@ -1139,19 +1139,19 @@  discard block
 block discarded – undo
1139 1139
 	 * @param 	EE_Registration 	$registration
1140 1140
 	 * @return void
1141 1141
 	 */
1142
-	protected function _refresh_registration_answers( $registration ) {
1142
+	protected function _refresh_registration_answers($registration) {
1143 1143
 
1144 1144
 		// now update the answers
1145
-		foreach ( $registration->answers() as $cache_key => $answer ) {
1145
+		foreach ($registration->answers() as $cache_key => $answer) {
1146 1146
 			// verify object
1147
-			if ( $answer instanceof EE_Answer ) {
1148
-				if ( $answer->ID() ) {
1147
+			if ($answer instanceof EE_Answer) {
1148
+				if ($answer->ID()) {
1149 1149
 					// make sure the cached answer is added to the model entity mapper
1150
-					$answer->get_model()->refresh_entity_map_with( $answer->ID(), $answer );
1150
+					$answer->get_model()->refresh_entity_map_with($answer->ID(), $answer);
1151 1151
 				}
1152 1152
 			} else {
1153 1153
 				EE_Error::add_error(
1154
-					__( 'An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso' ),
1154
+					__('An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso'),
1155 1155
 					__FILE__, __FUNCTION__, __LINE__
1156 1156
 				);
1157 1157
 			}
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 	 * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object
1167 1167
 	 */
1168 1168
 	function __wakeup() {
1169
-		foreach ( $this->reg_steps as $reg_step ) {
1169
+		foreach ($this->reg_steps as $reg_step) {
1170 1170
 			$reg_step->checkout = $this;
1171 1171
 		}
1172 1172
 	}
@@ -1182,11 +1182,11 @@  discard block
 block discarded – undo
1182 1182
 	 * @param array $info
1183 1183
 	 * @param bool $display_request
1184 1184
 	 */
1185
-	function log( $class = '', $func = '', $line = '', $info = array(), $display_request = false ) {
1186
-		if ( WP_DEBUG && false ) {
1187
-			$debug_data = get_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array() );
1185
+	function log($class = '', $func = '', $line = '', $info = array(), $display_request = false) {
1186
+		if (WP_DEBUG && false) {
1187
+			$debug_data = get_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), array());
1188 1188
 			$default_data = array(
1189
-				$class 		=> $func . '() : ' . $line,
1189
+				$class 		=> $func.'() : '.$line,
1190 1190
 				'request->step' 		=> $this->step,
1191 1191
 				'request->action' 	=> $this->action,
1192 1192
 				'current_step->slug' => $this->current_step instanceof EE_SPCO_Reg_Step ?
@@ -1198,24 +1198,24 @@  discard block
 block discarded – undo
1198 1198
 				'reg_url_link' => $this->reg_url_link,
1199 1199
 				'REQ' => $display_request ? $_REQUEST : '',
1200 1200
 			);
1201
-			if ( $this->transaction instanceof EE_Transaction ) {
1202
-				$default_data[ 'TXN_status' ] 		= $this->transaction->status_ID();
1203
-				$default_data[ 'TXN_reg_steps' ] 	= $this->transaction->reg_steps();
1204
-				foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $REG_ID => $registration ) {
1205
-					$default_data[ 'registrations' ][ $REG_ID ] = $registration->status_ID();
1201
+			if ($this->transaction instanceof EE_Transaction) {
1202
+				$default_data['TXN_status'] = $this->transaction->status_ID();
1203
+				$default_data['TXN_reg_steps'] = $this->transaction->reg_steps();
1204
+				foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) {
1205
+					$default_data['registrations'][$REG_ID] = $registration->status_ID();
1206 1206
 				}
1207
-				if ( $this->transaction->ID() ) {
1208
-					$TXN_ID = 'EE_Transaction: ' . $this->transaction->ID();
1207
+				if ($this->transaction->ID()) {
1208
+					$TXN_ID = 'EE_Transaction: '.$this->transaction->ID();
1209 1209
 					// don't serialize objects
1210
-					$info = $this->_strip_objects( $info );
1211
-					if ( ! isset( $debug_data[ $TXN_ID ] ) ) {
1212
-						$debug_data[ $TXN_ID ] = array();
1210
+					$info = $this->_strip_objects($info);
1211
+					if ( ! isset($debug_data[$TXN_ID])) {
1212
+						$debug_data[$TXN_ID] = array();
1213 1213
 					}
1214
-					$debug_data[ $TXN_ID ][ microtime() ] = array_merge(
1214
+					$debug_data[$TXN_ID][microtime()] = array_merge(
1215 1215
 						$default_data,
1216 1216
 						$info
1217 1217
 					);
1218
-					update_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data );
1218
+					update_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), $debug_data);
1219 1219
 				}
1220 1220
 			}
1221 1221
 		}
@@ -1228,23 +1228,23 @@  discard block
 block discarded – undo
1228 1228
 	 * @param array $info
1229 1229
 	 * @return array
1230 1230
 	 */
1231
-	function _strip_objects( $info = array() ) {
1232
-		foreach ( $info as $key => $value ) {
1233
-			if ( is_array( $value )) {
1234
-				$info[ $key ] = $this->_strip_objects( $value );
1235
-			} else if ( is_object( $value ) ) {
1236
-				$object_class = get_class( $value );
1237
-				$info[ $object_class ] = array();
1238
-				$info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : 0;
1239
-				if ( method_exists( $value, 'status' ) ) {
1240
-					$info[ $object_class ][ 'status' ] = $value->status();
1241
-				} else if ( method_exists( $value, 'status_ID' ) ) {
1242
-					$info[ $object_class ][ 'status' ] = $value->status_ID();
1231
+	function _strip_objects($info = array()) {
1232
+		foreach ($info as $key => $value) {
1233
+			if (is_array($value)) {
1234
+				$info[$key] = $this->_strip_objects($value);
1235
+			} else if (is_object($value)) {
1236
+				$object_class = get_class($value);
1237
+				$info[$object_class] = array();
1238
+				$info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1239
+				if (method_exists($value, 'status')) {
1240
+					$info[$object_class]['status'] = $value->status();
1241
+				} else if (method_exists($value, 'status_ID')) {
1242
+					$info[$object_class]['status'] = $value->status_ID();
1243 1243
 				}
1244
-				unset( $info[ $key ] );
1244
+				unset($info[$key]);
1245 1245
 			}
1246 1246
 		}
1247
-		return (array)$info;
1247
+		return (array) $info;
1248 1248
 	}
1249 1249
 
1250 1250
 
Please login to merge, or discard this patch.