Completed
Branch BUG-9730-spco-txn-lock (dea66c)
by
unknown
170:32 queued 154:08
created
core/libraries/form_sections/inputs/EE_Form_Input_Base.input.php 2 patches
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage
9 9
  * @author				Mike Nelson
10 10
  */
11
-abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{
11
+abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable {
12 12
 
13 13
 	/**
14 14
 	 * the input's name attribute
@@ -143,54 +143,54 @@  discard block
 block discarded – undo
143 143
 	 *  @type EE_Validation_Strategy_Base[]  $validation_strategies
144 144
 	 * }
145 145
 	 */
146
-	public function __construct( $input_args = array() ){
147
-		$input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this );
146
+	public function __construct($input_args = array()) {
147
+		$input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this);
148 148
 		// the following properties must be cast as arrays
149
-		if ( isset( $input_args['validation_strategies'] ) ) {
150
-			foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) {
151
-				if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
152
-					$this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy;
149
+		if (isset($input_args['validation_strategies'])) {
150
+			foreach ((array) $input_args['validation_strategies'] as $validation_strategy) {
151
+				if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
152
+					$this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy;
153 153
 				}
154 154
 			}
155
-			unset( $input_args['validation_strategies'] );
155
+			unset($input_args['validation_strategies']);
156 156
 		}
157 157
 		// loop thru incoming options
158
-		foreach( $input_args as $key => $value ) {
158
+		foreach ($input_args as $key => $value) {
159 159
 			// add underscore to $key to match property names
160
-			$_key = '_' . $key;
161
-			if ( property_exists( $this, $_key )) {
160
+			$_key = '_'.$key;
161
+			if (property_exists($this, $_key)) {
162 162
 				$this->{$_key} = $value;
163 163
 			}
164 164
 		}
165 165
 		// ensure that "required" is set correctly
166 166
 		$this->set_required(
167
-			$this->_required, isset( $input_args[ 'required_validation_error_message' ] )
168
-				? $input_args[ 'required_validation_error_message' ]
167
+			$this->_required, isset($input_args['required_validation_error_message'])
168
+				? $input_args['required_validation_error_message']
169 169
 				: null
170 170
 		);
171 171
 
172 172
 		//$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE;
173 173
 
174 174
 		$this->_display_strategy->_construct_finalize($this);
175
-		foreach( $this->_validation_strategies as $validation_strategy ){
175
+		foreach ($this->_validation_strategies as $validation_strategy) {
176 176
 			$validation_strategy->_construct_finalize($this);
177 177
 		}
178 178
 
179
-		if( ! $this->_normalization_strategy){
179
+		if ( ! $this->_normalization_strategy) {
180 180
 			$this->_normalization_strategy = new EE_Text_Normalization();
181 181
 		}
182 182
 		$this->_normalization_strategy->_construct_finalize($this);
183 183
 
184 184
 		//at least we can use the normalization strategy to populate the default
185
-		if( isset( $input_args[ 'default' ] ) ) {
186
-			$this->set_default( $input_args[ 'default' ] );
185
+		if (isset($input_args['default'])) {
186
+			$this->set_default($input_args['default']);
187 187
 		}
188 188
 
189
-		if( ! $this->_sensitive_data_removal_strategy){
189
+		if ( ! $this->_sensitive_data_removal_strategy) {
190 190
 			$this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal();
191 191
 		}
192 192
 		$this->_sensitive_data_removal_strategy->_construct_finalize($this);
193
-		parent::__construct( $input_args );
193
+		parent::__construct($input_args);
194 194
 	}
195 195
 
196 196
 
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @throws \EE_Error
203 203
 	 */
204
-	protected function _set_default_html_name_if_empty(){
205
-		if( ! $this->_html_name){
204
+	protected function _set_default_html_name_if_empty() {
205
+		if ( ! $this->_html_name) {
206 206
 			$this->_html_name = $this->name();
207
-			if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){
208
-				$this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]";
207
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
208
+				$this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]";
209 209
 			}
210 210
 		}
211 211
 	}
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 	public function _construct_finalize($parent_form_section, $name) {
221 221
 		parent::_construct_finalize($parent_form_section, $name);
222 222
 		$this->_set_default_html_name_if_empty();
223
-		if( ! $this->_html_label && ! $this->_html_label_text){
224
-			$this->_html_label_text = ucwords( str_replace("_"," ",$name));
223
+		if ( ! $this->_html_label && ! $this->_html_label_text) {
224
+			$this->_html_label_text = ucwords(str_replace("_", " ", $name));
225 225
 		}
226
-		do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name );
226
+		do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name);
227 227
 	}
228 228
 
229 229
 	 /**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	  * @return EE_Display_Strategy_Base
232 232
 	  * @throws EE_Error
233 233
 	  */
234
-	protected function _get_display_strategy(){
235
-		if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){
234
+	protected function _get_display_strategy() {
235
+		if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) {
236 236
 			throw new EE_Error(
237 237
 				sprintf(
238 238
 					__(
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 					$this->html_id()
244 244
 				)
245 245
 			);
246
-		}else{
246
+		} else {
247 247
 			return $this->_display_strategy;
248 248
 		}
249 249
 	}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * Sets the display strategy.
252 252
 	 * @param EE_Display_Strategy_Base $strategy
253 253
 	 */
254
-	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){
254
+	protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) {
255 255
 		$this->_display_strategy = $strategy;
256 256
 	}
257 257
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * Sets the sanitization strategy
260 260
 	 * @param EE_Normalization_Strategy_Base $strategy
261 261
 	 */
262
-	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){
262
+	protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) {
263 263
 		$this->_normalization_strategy = $strategy;
264 264
 	}
265 265
 
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 	 * Gets the display strategy for this input
286 286
 	 * @return EE_Display_Strategy_Base
287 287
 	 */
288
-	public function get_display_strategy(){
288
+	public function get_display_strategy() {
289 289
 		return $this->_display_strategy;
290 290
 	}
291 291
 	/**
292 292
 	 * Overwrites the display strategy
293 293
 	 * @param EE_Display_Strategy_Base $display_strategy
294 294
 	 */
295
-	public function set_display_strategy($display_strategy){
295
+	public function set_display_strategy($display_strategy) {
296 296
 		$this->_display_strategy = $display_strategy;
297 297
 		$this->_display_strategy->_construct_finalize($this);
298 298
 	}
@@ -300,14 +300,14 @@  discard block
 block discarded – undo
300 300
 	 * Gets the normalization strategy set on this input
301 301
 	 * @return EE_Normalization_Strategy_Base
302 302
 	 */
303
-	public function get_normalization_strategy(){
303
+	public function get_normalization_strategy() {
304 304
 		return $this->_normalization_strategy;
305 305
 	}
306 306
 	/**
307 307
 	 * Overwrites the normalization strategy
308 308
 	 * @param EE_Normalization_Strategy_Base $normalization_strategy
309 309
 	 */
310
-	public function set_normalization_strategy($normalization_strategy){
310
+	public function set_normalization_strategy($normalization_strategy) {
311 311
 		$this->_normalization_strategy = $normalization_strategy;
312 312
 		$this->_normalization_strategy->_construct_finalize($this);
313 313
 	}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * Returns all teh validation strategies which apply to this field, numerically indexed
317 317
 	 * @return EE_Validation_Strategy_Base[]
318 318
 	 */
319
-	public function get_validation_strategies(){
319
+	public function get_validation_strategies() {
320 320
 		return $this->_validation_strategies;
321 321
 	}
322 322
 
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
 	 * @param EE_Validation_Strategy_Base $validation_strategy
328 328
 	 * @return void
329 329
 	 */
330
-	protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){
331
-		$validation_strategy->_construct_finalize( $this );
330
+	protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
331
+		$validation_strategy->_construct_finalize($this);
332 332
 		$this->_validation_strategies[] = $validation_strategy;
333 333
 	}
334 334
 
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param EE_Validation_Strategy_Base $validation_strategy
340 340
 	 * @return void
341 341
 	 */
342
-	public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) {
343
-		$this->_add_validation_strategy( $validation_strategy );
342
+	public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) {
343
+		$this->_add_validation_strategy($validation_strategy);
344 344
 	}
345 345
 
346 346
 
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @param string $validation_strategy_classname
352 352
 	 */
353
-	public function remove_validation_strategy( $validation_strategy_classname ) {
354
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
355
-			if(
353
+	public function remove_validation_strategy($validation_strategy_classname) {
354
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
355
+			if (
356 356
 				$validation_strategy instanceof $validation_strategy_classname
357
-				|| is_subclass_of( $validation_strategy, $validation_strategy_classname )
357
+				|| is_subclass_of($validation_strategy, $validation_strategy_classname)
358 358
 			) {
359
-				unset( $this->_validation_strategies[ $key ] );
359
+				unset($this->_validation_strategies[$key]);
360 360
 			}
361 361
 		}
362 362
 	}
@@ -369,12 +369,12 @@  discard block
 block discarded – undo
369 369
 	 * @param array $validation_strategy_classnames
370 370
 	 * @return bool
371 371
 	 */
372
-	public function has_validation_strategy( $validation_strategy_classnames ) {
373
-		$validation_strategy_classnames = is_array( $validation_strategy_classnames )
372
+	public function has_validation_strategy($validation_strategy_classnames) {
373
+		$validation_strategy_classnames = is_array($validation_strategy_classnames)
374 374
 			? $validation_strategy_classnames
375
-			: array( $validation_strategy_classnames );
376
-		foreach( $this->_validation_strategies as $key => $validation_strategy ){
377
-			if( in_array( $key, $validation_strategy_classnames ) ) {
375
+			: array($validation_strategy_classnames);
376
+		foreach ($this->_validation_strategies as $key => $validation_strategy) {
377
+			if (in_array($key, $validation_strategy_classnames)) {
378 378
 				return true;
379 379
 			}
380 380
 		}
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 	 * to the parent form's layout strategy
389 389
 	 * @return string
390 390
 	 */
391
-	public function get_html_and_js(){
391
+	public function get_html_and_js() {
392 392
 		return $this->_parent_section->get_html_for_input($this);
393 393
 	}
394 394
 
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 	 * @return string
403 403
 	 * @throws \EE_Error
404 404
 	 */
405
-	public function get_html_for_input(){
405
+	public function get_html_for_input() {
406 406
 		return  $this->_get_display_strategy()->display();
407 407
 	}
408 408
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * @return string
413 413
 	 */
414 414
 	public function html_other_attributes() {
415
-		return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : '';
415
+		return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : '';
416 416
 	}
417 417
 
418 418
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 	/**
421 421
 	 * @param string $html_other_attributes
422 422
 	 */
423
-	public function set_html_other_attributes( $html_other_attributes ) {
423
+	public function set_html_other_attributes($html_other_attributes) {
424 424
 		$this->_html_other_attributes = $html_other_attributes;
425 425
 	}
426 426
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 	 * according to the form section's layout strategy
430 430
 	 * @return string
431 431
 	 */
432
-	public function get_html_for_label(){
432
+	public function get_html_for_label() {
433 433
 		return $this->_parent_section->get_layout_strategy()->display_label($this);
434 434
 	}
435 435
 	/**
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * according to the form section's layout strategy
438 438
 	 * @return string
439 439
 	 */
440
-	public function get_html_for_errors(){
440
+	public function get_html_for_errors() {
441 441
 		return $this->_parent_section->get_layout_strategy()->display_errors($this);
442 442
 	}
443 443
 	/**
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 * according to the form section's layout strategy
446 446
 	 * @return string
447 447
 	 */
448
-	public function get_html_for_help(){
448
+	public function get_html_for_help() {
449 449
 		return $this->_parent_section->get_layout_strategy()->display_help_text($this);
450 450
 	}
451 451
 	/**
@@ -454,18 +454,18 @@  discard block
 block discarded – undo
454 454
 	 * @return boolean
455 455
 	 */
456 456
 	protected function _validate() {
457
-		foreach($this->_validation_strategies as $validation_strategy){
458
-			if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
459
-				try{
457
+		foreach ($this->_validation_strategies as $validation_strategy) {
458
+			if ($validation_strategy instanceof EE_Validation_Strategy_Base) {
459
+				try {
460 460
 					$validation_strategy->validate($this->normalized_value());
461
-				}catch(EE_Validation_Error $e){
461
+				} catch (EE_Validation_Error $e) {
462 462
 					$this->add_validation_error($e);
463 463
 				}
464 464
 			}
465 465
 		}
466
-		if( $this->get_validation_errors()){
466
+		if ($this->get_validation_errors()) {
467 467
 			return false;
468
-		}else{
468
+		} else {
469 469
 			return true;
470 470
 		}
471 471
 	}
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 	 * @param string $value
479 479
 	 * @return null|string
480 480
 	 */
481
-	private function _sanitize($value){
482
-		return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field
481
+	private function _sanitize($value) {
482
+		return $value !== NULL ? stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field
483 483
 	}
484 484
 
485 485
 
@@ -493,24 +493,24 @@  discard block
 block discarded – undo
493 493
 	 * @return boolean whether or not there was an error
494 494
 	 * @throws \EE_Error
495 495
 	 */
496
-	protected function _normalize( $req_data ) {
496
+	protected function _normalize($req_data) {
497 497
 		//any existing validation errors don't apply so clear them
498 498
 		$this->_validation_errors = array();
499 499
 		try {
500
-			$raw_input = $this->find_form_data_for_this_section( $req_data );
500
+			$raw_input = $this->find_form_data_for_this_section($req_data);
501 501
 			//super simple sanitization for now
502
-			if ( is_array( $raw_input )) {
502
+			if (is_array($raw_input)) {
503 503
 				$this->_raw_value = array();
504
-				foreach( $raw_input as $key => $value ) {
505
-					$this->_raw_value[ $key ] = $this->_sanitize( $value );
504
+				foreach ($raw_input as $key => $value) {
505
+					$this->_raw_value[$key] = $this->_sanitize($value);
506 506
 				}
507 507
 			} else {
508
-				$this->_raw_value = $this->_sanitize( $raw_input );
508
+				$this->_raw_value = $this->_sanitize($raw_input);
509 509
 			}
510 510
 			//we want ot mostly leave the input alone in case we need to re-display it to the user
511
-			$this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() );
512
-		} catch ( EE_Validation_Error $e ) {
513
-			$this->add_validation_error( $e );
511
+			$this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value());
512
+		} catch (EE_Validation_Error $e) {
513
+			$this->add_validation_error($e);
514 514
 		}
515 515
 	}
516 516
 
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	/**
520 520
 	 * @return string
521 521
 	 */
522
-	public function html_name(){
522
+	public function html_name() {
523 523
 		return $this->_html_name;
524 524
 	}
525 525
 
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
 	/**
529 529
 	 * @return string
530 530
 	 */
531
-	public function html_label_id(){
532
-		return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl';
531
+	public function html_label_id() {
532
+		return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl';
533 533
 	}
534 534
 
535 535
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	/**
538 538
 	 * @return string
539 539
 	 */
540
-	public function html_label_class(){
540
+	public function html_label_class() {
541 541
 		return $this->_html_label_class;
542 542
 	}
543 543
 
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	/**
547 547
 	 * @return string
548 548
 	 */
549
-	public function html_label_style(){
549
+	public function html_label_style() {
550 550
 		return $this->_html_label_style;
551 551
 	}
552 552
 
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 	/**
556 556
 	 * @return string
557 557
 	 */
558
-	public function html_label_text(){
558
+	public function html_label_text() {
559 559
 		return $this->_html_label_text;
560 560
 	}
561 561
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 	/**
565 565
 	 * @return string
566 566
 	 */
567
-	public function html_help_text(){
567
+	public function html_help_text() {
568 568
 		return $this->_html_help_text;
569 569
 	}
570 570
 
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 	/**
574 574
 	 * @return string
575 575
 	 */
576
-	public function html_help_class(){
576
+	public function html_help_class() {
577 577
 		return $this->_html_help_class;
578 578
 	}
579 579
 
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 	/**
583 583
 	 * @return string
584 584
 	 */
585
-	public function html_help_style(){
585
+	public function html_help_style() {
586 586
 		return $this->_html_style;
587 587
 	}
588 588
 	/**
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 	 * in which case, we would have stored the malicious content to our database.
596 596
 	 * @return string
597 597
 	 */
598
-	public function raw_value(){
598
+	public function raw_value() {
599 599
 		return $this->_raw_value;
600 600
 	}
601 601
 	/**
@@ -603,15 +603,15 @@  discard block
 block discarded – undo
603 603
 	 * it escapes all html entities
604 604
 	 * @return string
605 605
 	 */
606
-	public function raw_value_in_form(){
607
-		return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8');
606
+	public function raw_value_in_form() {
607
+		return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8');
608 608
 	}
609 609
 	/**
610 610
 	 * returns the value after it's been sanitized, and then converted into it's proper type
611 611
 	 * in PHP. Eg, a string, an int, an array,
612 612
 	 * @return mixed
613 613
 	 */
614
-	public function normalized_value(){
614
+	public function normalized_value() {
615 615
 		return $this->_normalized_value;
616 616
 	}
617 617
 
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 	 * the best thing to display
622 622
 	 * @return string
623 623
 	 */
624
-	public function pretty_value(){
624
+	public function pretty_value() {
625 625
 		return $this->_normalized_value;
626 626
 	}
627 627
 	/**
@@ -640,19 +640,19 @@  discard block
 block discarded – undo
640 640
 		  }</code>
641 641
 	 * @return array
642 642
 	 */
643
-	public function get_jquery_validation_rules(){
643
+	public function get_jquery_validation_rules() {
644 644
 		$jquery_validation_js = array();
645 645
 		$jquery_validation_rules = array();
646
-		foreach($this->get_validation_strategies() as $validation_strategy){
646
+		foreach ($this->get_validation_strategies() as $validation_strategy) {
647 647
 			$jquery_validation_rules = array_replace_recursive(
648 648
 				$jquery_validation_rules,
649 649
 				$validation_strategy->get_jquery_validation_rule_array()
650 650
 			);
651 651
 		}
652 652
 
653
-		if(! empty($jquery_validation_rules)){
654
-			foreach( $this->get_display_strategy()->get_html_input_ids( true ) as $html_id_with_pound_sign ) {
655
-				$jquery_validation_js[ $html_id_with_pound_sign ] = $jquery_validation_rules;
653
+		if ( ! empty($jquery_validation_rules)) {
654
+			foreach ($this->get_display_strategy()->get_html_input_ids(true) as $html_id_with_pound_sign) {
655
+				$jquery_validation_js[$html_id_with_pound_sign] = $jquery_validation_rules;
656 656
 			}
657 657
 		}
658 658
 		return $jquery_validation_js;
@@ -664,9 +664,9 @@  discard block
 block discarded – undo
664 664
 	 * @param mixed $value
665 665
 	 * @return void
666 666
 	 */
667
-	public function set_default($value){
667
+	public function set_default($value) {
668 668
 		$this->_normalized_value = $value;
669
-		$this->_raw_value = $this->_normalization_strategy->unnormalize( $value );
669
+		$this->_raw_value = $this->_normalization_strategy->unnormalize($value);
670 670
 	}
671 671
 
672 672
 	/**
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 	 * @param string $label
675 675
 	 * @return void
676 676
 	 */
677
-	public function set_html_label_text($label){
677
+	public function set_html_label_text($label) {
678 678
 		$this->_html_label_text = $label;
679 679
 	}
680 680
 
@@ -688,13 +688,13 @@  discard block
 block discarded – undo
688 688
 	 * @param boolean $required boolean
689 689
 	 * @param null    $required_text
690 690
 	 */
691
-	public function set_required($required = true, $required_text = NULL ){
692
-		$required = filter_var( $required, FILTER_VALIDATE_BOOLEAN  );
691
+	public function set_required($required = true, $required_text = NULL) {
692
+		$required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
693 693
 		//whether $required is a string or a boolean, we want to add a required validation strategy
694
-		if ( $required ) {
695
-			$this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) );
694
+		if ($required) {
695
+			$this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text));
696 696
 		} else {
697
-			unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] );
697
+			unset($this->_validation_strategies['EE_Required_Validation_Strategy']);
698 698
 		}
699 699
 		$this->_required = $required;
700 700
 	}
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	 * Returns whether or not this field is required
703 703
 	 * @return boolean
704 704
 	 */
705
-	public function required(){
705
+	public function required() {
706 706
 		return $this->_required;
707 707
 	}
708 708
 
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	/**
712 712
 	 * @param string $required_css_class
713 713
 	 */
714
-	public function set_required_css_class( $required_css_class ) {
714
+	public function set_required_css_class($required_css_class) {
715 715
 		$this->_required_css_class = $required_css_class;
716 716
 	}
717 717
 
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 	 * Sets the help text, in case
731 731
 	 * @param string $text
732 732
 	 */
733
-	public function set_html_help_text($text){
733
+	public function set_html_help_text($text) {
734 734
 		$this->_html_help_text = $text;
735 735
 	}
736 736
 	/**
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 	public function clean_sensitive_data() {
743 743
 		//if we do ANY kind of sensitive data removal on this, then just clear out the raw value
744 744
 		//if we need more logic than this we'll make a strategy for it
745
-		if( $this->_sensitive_data_removal_strategy &&
746
-				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){
745
+		if ($this->_sensitive_data_removal_strategy &&
746
+				! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) {
747 747
 			$this->_raw_value = NULL;
748 748
 		}
749 749
 		//and clean the normalized value according to the appropriate strategy
@@ -759,10 +759,10 @@  discard block
 block discarded – undo
759 759
 	 * @param string $button_size
760 760
 	 * @param string $other_attributes
761 761
 	 */
762
-	public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) {
762
+	public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') {
763 763
 		$button_css_attributes = 'button';
764 764
 		$button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary';
765
-		switch ( $button_size ) {
765
+		switch ($button_size) {
766 766
 			case 'xs' :
767 767
 			case 'extra-small' :
768 768
 				$button_css_attributes .= ' button-xs';
@@ -783,8 +783,8 @@  discard block
 block discarded – undo
783 783
 			default :
784 784
 				$button_css_attributes .= '';
785 785
 		}
786
-		$this->_button_css_attributes .= ! empty( $other_attributes )
787
-			? $button_css_attributes . ' ' . $other_attributes
786
+		$this->_button_css_attributes .= ! empty($other_attributes)
787
+			? $button_css_attributes.' '.$other_attributes
788 788
 			: $button_css_attributes;
789 789
 	}
790 790
 
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
 	 * @return string
795 795
 	 */
796 796
 	public function button_css_attributes() {
797
-		if ( empty( $this->_button_css_attributes )) {
797
+		if (empty($this->_button_css_attributes)) {
798 798
 			$this->set_button_css_attributes();
799 799
 		}
800 800
 		return $this->_button_css_attributes;
@@ -816,26 +816,26 @@  discard block
 block discarded – undo
816 816
 	 * @return mixed whatever the raw value of this form section is in the request data
817 817
 	 * @throws \EE_Error
818 818
 	 */
819
-	public function find_form_data_for_this_section( $req_data ){
819
+	public function find_form_data_for_this_section($req_data) {
820 820
 		// break up the html name by "[]"
821
-		if ( strpos( $this->html_name(), '[' ) !== FALSE ) {
822
-			$before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') );
821
+		if (strpos($this->html_name(), '[') !== FALSE) {
822
+			$before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '['));
823 823
 		} else {
824 824
 			$before_any_brackets = $this->html_name();
825 825
 		}
826 826
 		// grab all of the segments
827
-		preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches);
828
-		if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){
829
-			$name_parts = $matches[ 1 ];
827
+		preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches);
828
+		if (isset($matches[1]) && is_array($matches[1])) {
829
+			$name_parts = $matches[1];
830 830
 			array_unshift($name_parts, $before_any_brackets);
831
-		}else{
832
-			$name_parts = array( $before_any_brackets );
831
+		} else {
832
+			$name_parts = array($before_any_brackets);
833 833
 		}
834 834
 		// now get the value for the input
835 835
 		$value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data);
836 836
 		// check if this thing's name is at the TOP level of the request data
837
-		if( $value === null && isset( $req_data[ $this->name() ] ) ){
838
-			$value = $req_data[ $this->name() ];
837
+		if ($value === null && isset($req_data[$this->name()])) {
838
+			$value = $req_data[$this->name()];
839 839
 		}
840 840
 		return $value;
841 841
 	}
@@ -848,18 +848,18 @@  discard block
 block discarded – undo
848 848
 	 * @param array $req_data
849 849
 	 * @return array | NULL
850 850
 	 */
851
-	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){
852
-		$first_part_to_consider = array_shift( $html_name_parts );
853
-		if( isset( $req_data[ $first_part_to_consider ] ) ){
854
-			if( empty($html_name_parts ) ){
855
-				return $req_data[ $first_part_to_consider ];
856
-			}else{
851
+	public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) {
852
+		$first_part_to_consider = array_shift($html_name_parts);
853
+		if (isset($req_data[$first_part_to_consider])) {
854
+			if (empty($html_name_parts)) {
855
+				return $req_data[$first_part_to_consider];
856
+			} else {
857 857
 				return $this->_find_form_data_for_this_section_using_name_parts(
858 858
 					$html_name_parts,
859
-					$req_data[ $first_part_to_consider ]
859
+					$req_data[$first_part_to_consider]
860 860
 				);
861 861
 			}
862
-		}else{
862
+		} else {
863 863
 			return NULL;
864 864
 		}
865 865
 	}
@@ -873,14 +873,14 @@  discard block
 block discarded – undo
873 873
 	 * @return boolean
874 874
 	 * @throws \EE_Error
875 875
 	 */
876
-	public function form_data_present_in($req_data = NULL){
877
-		if( $req_data === NULL ){
876
+	public function form_data_present_in($req_data = NULL) {
877
+		if ($req_data === NULL) {
878 878
 			$req_data = $_POST;
879 879
 		}
880
-		$checked_value = $this->find_form_data_for_this_section( $req_data );
881
-		if( $checked_value !== null ){
880
+		$checked_value = $this->find_form_data_for_this_section($req_data);
881
+		if ($checked_value !== null) {
882 882
 			return TRUE;
883
-		}else{
883
+		} else {
884 884
 			return FALSE;
885 885
 		}
886 886
 	}
Please login to merge, or discard this patch.
Braces   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 					$this->html_id()
244 244
 				)
245 245
 			);
246
-		}else{
246
+		} else{
247 247
 			return $this->_display_strategy;
248 248
 		}
249 249
 	}
@@ -458,14 +458,14 @@  discard block
 block discarded – undo
458 458
 			if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) {
459 459
 				try{
460 460
 					$validation_strategy->validate($this->normalized_value());
461
-				}catch(EE_Validation_Error $e){
461
+				} catch(EE_Validation_Error $e){
462 462
 					$this->add_validation_error($e);
463 463
 				}
464 464
 			}
465 465
 		}
466 466
 		if( $this->get_validation_errors()){
467 467
 			return false;
468
-		}else{
468
+		} else{
469 469
 			return true;
470 470
 		}
471 471
 	}
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 		if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){
829 829
 			$name_parts = $matches[ 1 ];
830 830
 			array_unshift($name_parts, $before_any_brackets);
831
-		}else{
831
+		} else{
832 832
 			$name_parts = array( $before_any_brackets );
833 833
 		}
834 834
 		// now get the value for the input
@@ -853,13 +853,13 @@  discard block
 block discarded – undo
853 853
 		if( isset( $req_data[ $first_part_to_consider ] ) ){
854 854
 			if( empty($html_name_parts ) ){
855 855
 				return $req_data[ $first_part_to_consider ];
856
-			}else{
856
+			} else{
857 857
 				return $this->_find_form_data_for_this_section_using_name_parts(
858 858
 					$html_name_parts,
859 859
 					$req_data[ $first_part_to_consider ]
860 860
 				);
861 861
 			}
862
-		}else{
862
+		} else{
863 863
 			return NULL;
864 864
 		}
865 865
 	}
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 		$checked_value = $this->find_form_data_for_this_section( $req_data );
881 881
 		if( $checked_value !== null ){
882 882
 			return TRUE;
883
-		}else{
883
+		} else{
884 884
 			return FALSE;
885 885
 		}
886 886
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 1 patch
Spacing   +967 added lines, -967 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
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * Flag indicating whether this model has a primary key or not
244 244
 	 * @var boolean
245 245
 	 */
246
-	protected $_has_primary_key_field=null;
246
+	protected $_has_primary_key_field = null;
247 247
 
248 248
 	/**
249 249
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -305,19 +305,19 @@  discard block
 block discarded – undo
305 305
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
306 306
 	 * @var array
307 307
 	 */
308
-	protected $_between_style_operators = array( 'BETWEEN' );
308
+	protected $_between_style_operators = array('BETWEEN');
309 309
 
310 310
 	/**
311 311
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
312 312
 	 * @var array
313 313
 	 */
314
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
314
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
315 315
 
316 316
 	/**
317 317
 	 * Allowed values for $query_params['order'] for ordering in queries
318 318
 	 * @var array
319 319
 	 */
320
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
320
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
321 321
 
322 322
 	/**
323 323
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
332 332
 	 * @var array
333 333
 	 */
334
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
334
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
335 335
 
336 336
 	/**
337 337
 	 * All the data types that can be used in $wpdb->prepare statements.
338 338
 	 * @var array
339 339
 	 */
340
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
340
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
341 341
 
342 342
 	/**
343 343
 	 * 	EE_Registry Object
@@ -370,17 +370,17 @@  discard block
 block discarded – undo
370 370
 	/**
371 371
 	 * constant used to show EEM_Base has not yet verified the db on this http request
372 372
 	 */
373
-	const db_verified_none 		= 0;
373
+	const db_verified_none = 0;
374 374
 	/**
375 375
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
376 376
 	 * but not the addons' dbs
377 377
 	 */
378
-	const db_verified_core 		= 1;
378
+	const db_verified_core = 1;
379 379
 	/**
380 380
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
381 381
 	 * the EE core db too)
382 382
 	 */
383
-	const db_verified_addons 	= 2;
383
+	const db_verified_addons = 2;
384 384
 
385 385
 	/**
386 386
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 	 * @param null $timezone
412 412
 	 * @throws \EE_Error
413 413
 	 */
414
-	protected function __construct( $timezone = NULL ){
414
+	protected function __construct($timezone = NULL) {
415 415
 		// check that the model has not been loaded too soon
416
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
417
-			throw new EE_Error (
416
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
417
+			throw new EE_Error(
418 418
 				sprintf(
419
-					__( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ),
420
-					get_class( $this )
419
+					__('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'),
420
+					get_class($this)
421 421
 				)
422 422
 			);
423 423
 		}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 		/**
426 426
 		 * Set blogid for models to current blog. However we ONLY do this if $_model_query_blog_id is not already set.
427 427
 		 */
428
-		if ( empty( EEM_Base::$_model_query_blog_id ) ) {
428
+		if (empty(EEM_Base::$_model_query_blog_id)) {
429 429
 			EEM_Base::set_model_query_blog_id();
430 430
 		}
431 431
 
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 		 * just use EE_Register_Model_Extension
435 435
 		 * @var EE_Table_Base[] $_tables
436 436
 		 */
437
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
438
-		foreach($this->_tables as $table_alias => $table_obj){
437
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
438
+		foreach ($this->_tables as $table_alias => $table_obj) {
439 439
 			/** @var $table_obj EE_Table_Base */
440 440
 			$table_obj->_construct_finalize_with_alias($table_alias);
441
-			if( $table_obj instanceof EE_Secondary_Table ){
441
+			if ($table_obj instanceof EE_Secondary_Table) {
442 442
 				/** @var $table_obj EE_Secondary_Table */
443 443
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
444 444
 			}
@@ -448,54 +448,54 @@  discard block
 block discarded – undo
448 448
 		 * EE_Register_Model_Extension
449 449
 		 * @param EE_Model_Field_Base[] $_fields
450 450
 		 */
451
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
451
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
452 452
 		$this->_invalidate_field_caches();
453
-		foreach($this->_fields as $table_alias => $fields_for_table){
454
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
455
-				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields)));
453
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
454
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
455
+				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields)));
456 456
 			}
457
-			foreach($fields_for_table as $field_name => $field_obj){
457
+			foreach ($fields_for_table as $field_name => $field_obj) {
458 458
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
459 459
 				//primary key field base has a slightly different _construct_finalize
460 460
 				/** @var $field_obj EE_Model_Field_Base */
461
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
461
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
462 462
 			}
463 463
 		}
464 464
 
465 465
 		// everything is related to Extra_Meta
466
-		if( get_class($this) !== 'EEM_Extra_Meta'){
466
+		if (get_class($this) !== 'EEM_Extra_Meta') {
467 467
 			//make extra meta related to everything, but don't block deleting things just
468 468
 			//because they have related extra meta info. For now just orphan those extra meta
469 469
 			//in the future we should automatically delete them
470
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
470
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
471 471
 		}
472 472
 		//and change logs
473
-		if( get_class( $this) !==  'EEM_Change_Log' ) {
474
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
473
+		if (get_class($this) !== 'EEM_Change_Log') {
474
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
475 475
 		}
476 476
 		/**
477 477
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
478 478
 		 * EE_Register_Model_Extension
479 479
 		 * @param EE_Model_Relation_Base[] $_model_relations
480 480
 		 */
481
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
482
-		foreach($this->_model_relations as $model_name => $relation_obj){
481
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
482
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
483 483
 			/** @var $relation_obj EE_Model_Relation_Base */
484 484
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
485 485
 		}
486
-		foreach($this->_indexes as $index_name => $index_obj){
486
+		foreach ($this->_indexes as $index_name => $index_obj) {
487 487
 			/** @var $index_obj EE_Index */
488 488
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
489 489
 		}
490 490
 
491 491
 		$this->set_timezone($timezone);
492 492
 		//finalize default where condition strategy, or set default
493
-		if( ! $this->_default_where_conditions_strategy){
493
+		if ( ! $this->_default_where_conditions_strategy) {
494 494
 			//nothing was set during child constructor, so set default
495 495
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
496 496
 		}
497 497
 		$this->_default_where_conditions_strategy->_finalize_construct($this);
498
-		if( ! $this->_minimum_where_conditions_strategy){
498
+		if ( ! $this->_minimum_where_conditions_strategy) {
499 499
 			//nothing was set during child constructor, so set default
500 500
 			$this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions();
501 501
 		}
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
 
504 504
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
505 505
 		//to indicate to NOT set it, set it to the logical default
506
-		if( $this->_caps_slug === null ) {
507
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
506
+		if ($this->_caps_slug === null) {
507
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
508 508
 		}
509 509
 		//initialize the standard cap restriction generators if none were specified by the child constructor
510
-		if( $this->_cap_restriction_generators !== false ){
511
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
512
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
513
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
510
+		if ($this->_cap_restriction_generators !== false) {
511
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
512
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
513
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
514 514
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
515 515
 						new EE_Restriction_Generator_Protected(),
516 516
 						$cap_context,
@@ -520,23 +520,23 @@  discard block
 block discarded – undo
520 520
 			}
521 521
 		}
522 522
 		//if there are cap restriction generators, use them to make the default cap restrictions
523
-		if( $this->_cap_restriction_generators !== false ){
524
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
525
-				if( ! $generator_object ){
523
+		if ($this->_cap_restriction_generators !== false) {
524
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
525
+				if ( ! $generator_object) {
526 526
 					continue;
527 527
 				}
528
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
528
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
529 529
 					throw new EE_Error(
530 530
 						sprintf(
531
-							__( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ),
531
+							__('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'),
532 532
 							$context,
533 533
 							$this->get_this_model_name()
534 534
 						)
535 535
 					);
536 536
 				}
537
-				$action = $this->cap_action_for_context( $context );
538
-				if( ! $generator_object->construction_finalized() ){
539
-					$generator_object->_construct_finalize( $this, $action );
537
+				$action = $this->cap_action_for_context($context);
538
+				if ( ! $generator_object->construction_finalized()) {
539
+					$generator_object->_construct_finalize($this, $action);
540 540
 				}
541 541
 
542 542
 			}
@@ -550,11 +550,11 @@  discard block
 block discarded – undo
550 550
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
551 551
 	 * @return EE_Default_Where_Conditions[]
552 552
 	 */
553
-	protected function _generate_cap_restrictions( $context ){
554
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
555
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
556
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
557
-		}else{
553
+	protected function _generate_cap_restrictions($context) {
554
+		if (isset($this->_cap_restriction_generators[$context]) &&
555
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
556
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
557
+		} else {
558 558
 			return array();
559 559
 		}
560 560
 	}
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 * @param int $blog_id  If provided then will set the blog_id for the models to this id.  If not provided then the
567 567
 	 *                      value for get_current_blog_id() will be used.
568 568
 	 */
569
-	public static function set_model_query_blog_id( $blog_id = 0 ) {
569
+	public static function set_model_query_blog_id($blog_id = 0) {
570 570
 		EEM_Base::$_model_query_blog_id = $blog_id > 0 ? (int) $blog_id : get_current_blog_id();
571 571
 	}
572 572
 
@@ -591,16 +591,16 @@  discard block
 block discarded – undo
591 591
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
592 592
 	 *		@return static (as in the concrete child class)
593 593
 	 */
594
-	public static function instance( $timezone = NULL ){
594
+	public static function instance($timezone = NULL) {
595 595
 
596 596
 		// check if instance of Espresso_model already exists
597 597
 		if ( ! static::$_instance instanceof static) {
598 598
 			// instantiate Espresso_model
599
-			static::$_instance = new static( $timezone );
599
+			static::$_instance = new static($timezone);
600 600
 		}
601 601
 
602 602
 		//we might have a timezone set, let set_timezone decide what to do with it
603
-		static::$_instance->set_timezone( $timezone );
603
+		static::$_instance->set_timezone($timezone);
604 604
 
605 605
 		// Espresso_model object
606 606
 		return static::$_instance;
@@ -613,11 +613,11 @@  discard block
 block discarded – undo
613 613
 	 * @param null | string $timezone
614 614
 	 * @return static
615 615
 	 */
616
-	public static function reset(  $timezone = NULL ){
617
-		if ( ! is_null( static::$_instance ) ) {
616
+	public static function reset($timezone = NULL) {
617
+		if ( ! is_null(static::$_instance)) {
618 618
 			static::$_instance = null;
619 619
 
620
-			return self::instance( $timezone );
620
+			return self::instance($timezone);
621 621
 		}
622 622
 		return null;
623 623
 	}
@@ -631,19 +631,19 @@  discard block
 block discarded – undo
631 631
 	 * @return array
632 632
 	 * @throws \EE_Error
633 633
 	 */
634
-	 public function status_array( $translated = FALSE ) {
635
-		 if ( ! array_key_exists( 'Status', $this->_model_relations ) ) {
634
+	 public function status_array($translated = FALSE) {
635
+		 if ( ! array_key_exists('Status', $this->_model_relations)) {
636 636
 			 return array();
637 637
 		 }
638 638
 		 $model_name = $this->get_this_model_name();
639
-		 $status_type = str_replace( ' ', '_', strtolower( str_replace( '_', ' ', $model_name ) ) );
640
-		 $stati = EEM_Status::instance()->get_all( array( array( 'STS_type' => $status_type ) ) );
639
+		 $status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
640
+		 $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
641 641
 		 $status_array = array();
642
-		 foreach ( $stati as $status ) {
643
-			 $status_array[ $status->ID() ] = $status->get( 'STS_code' );
642
+		 foreach ($stati as $status) {
643
+			 $status_array[$status->ID()] = $status->get('STS_code');
644 644
 		 }
645 645
 		 return $translated
646
-			 ? EEM_Status::instance()->localized_status( $status_array, false, 'sentence' )
646
+			 ? EEM_Status::instance()->localized_status($status_array, false, 'sentence')
647 647
 			 : $status_array;
648 648
 	 }
649 649
 
@@ -776,10 +776,10 @@  discard block
 block discarded – undo
776 776
 	 *		));
777 777
 	 * @throws \EE_Error
778 778
 	 */
779
-	public function get_all($query_params = array()){
780
-		if( isset( $query_params[ 'limit' ] )
781
-			&& ! isset( $query_params[ 'group_by' ] ) ) {
782
-			$query_params[ 'group_by' ] = array_keys( $this->get_combined_primary_key_fields() );
779
+	public function get_all($query_params = array()) {
780
+		if (isset($query_params['limit'])
781
+			&& ! isset($query_params['group_by'])) {
782
+			$query_params['group_by'] = array_keys($this->get_combined_primary_key_fields());
783 783
 		}
784 784
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
785 785
 	}
@@ -790,10 +790,10 @@  discard block
 block discarded – undo
790 790
 	 * @param array $query_params @see EEM_Base::get_all()
791 791
 	 * @return array like EEM_Base::get_all
792 792
 	 */
793
-	public function alter_query_params_to_only_include_mine( $query_params = array() ) {
793
+	public function alter_query_params_to_only_include_mine($query_params = array()) {
794 794
 		$wp_user_field_name = $this->wp_user_field_name();
795
-		if( $wp_user_field_name ){
796
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
795
+		if ($wp_user_field_name) {
796
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
797 797
 		}
798 798
 		return $query_params;
799 799
 	}
@@ -806,19 +806,19 @@  discard block
 block discarded – undo
806 806
 	 * foreign key to the WP_User table
807 807
 	 */
808 808
 	public function wp_user_field_name() {
809
-		try{
810
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
811
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
812
-				$last_model_name = end( $models_to_follow_to_wp_users );
813
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
814
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
815
-			}else{
809
+		try {
810
+			if ( ! empty($this->_model_chain_to_wp_user)) {
811
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
812
+				$last_model_name = end($models_to_follow_to_wp_users);
813
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
814
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
815
+			} else {
816 816
 				$model_with_fk_to_wp_users = $this;
817 817
 				$model_chain_to_wp_user = '';
818 818
 			}
819
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
820
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
821
-		}catch( EE_Error $e ) {
819
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
820
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
821
+		} catch (EE_Error $e) {
822 822
 			return false;
823 823
 		}
824 824
 	}
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 	 * (or transiently-related model)
833 833
 	 * @return string
834 834
 	 */
835
-	public function model_chain_to_wp_user(){
835
+	public function model_chain_to_wp_user() {
836 836
 		return $this->_model_chain_to_wp_user;
837 837
 	}
838 838
 
@@ -844,13 +844,13 @@  discard block
 block discarded – undo
844 844
 	 * @return boolean
845 845
 	 */
846 846
 	public function is_owned() {
847
-		if( $this->model_chain_to_wp_user() ){
847
+		if ($this->model_chain_to_wp_user()) {
848 848
 			return true;
849
-		}else{
850
-			try{
851
-				$this->get_foreign_key_to( 'WP_User' );
849
+		} else {
850
+			try {
851
+				$this->get_foreign_key_to('WP_User');
852 852
 				return true;
853
-			}catch( EE_Error $e ){
853
+			} catch (EE_Error $e) {
854 854
 				return false;
855 855
 			}
856 856
 		}
@@ -872,17 +872,17 @@  discard block
 block discarded – undo
872 872
 	 * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
873 873
 	 * @throws \EE_Error
874 874
 	 */
875
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
875
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
876 876
 		// remember the custom selections, if any, and type cast as array
877 877
 		// (unless $columns_to_select is an object, then just set as an empty array)
878 878
 		// Note: (array) 'some string' === array( 'some string' )
879
-		$this->_custom_selections = ! is_object( $columns_to_select ) ? (array) $columns_to_select : array();
880
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
879
+		$this->_custom_selections = ! is_object($columns_to_select) ? (array) $columns_to_select : array();
880
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
881 881
 		$select_expressions = $columns_to_select !== null
882
-			? $this->_construct_select_from_input( $columns_to_select )
883
-			: $this->_construct_default_select_sql( $model_query_info );
884
-		$SQL = "SELECT $select_expressions " . $this->_construct_2nd_half_of_select_query( $model_query_info );
885
-		return $this->_do_wpdb_query( 'get_results', array( $SQL, $output ) );
882
+			? $this->_construct_select_from_input($columns_to_select)
883
+			: $this->_construct_default_select_sql($model_query_info);
884
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
885
+		return $this->_do_wpdb_query('get_results', array($SQL, $output));
886 886
 	}
887 887
 
888 888
 	/**
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
901 901
 	 * @throws \EE_Error
902 902
 	 */
903
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
903
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
904 904
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
905 905
 	}
906 906
 
@@ -912,12 +912,12 @@  discard block
 block discarded – undo
912 912
 	 * @throws EE_Error
913 913
 	 * @return string
914 914
 	 */
915
-	private function _construct_select_from_input($columns_to_select){
916
-		if(is_array($columns_to_select)){
915
+	private function _construct_select_from_input($columns_to_select) {
916
+		if (is_array($columns_to_select)) {
917 917
 			$select_sql_array = array();
918 918
 
919
-			foreach($columns_to_select as $alias => $selection_and_datatype){
920
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
919
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
920
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
921 921
 					throw new EE_Error(
922 922
 						sprintf(
923 923
 							__(
@@ -929,24 +929,24 @@  discard block
 block discarded – undo
929 929
 						)
930 930
 					);
931 931
 				}
932
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
932
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
933 933
 					throw new EE_Error(
934 934
 						sprintf(
935 935
 							__(
936 936
 								"Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)",
937 937
 								"event_espresso"
938 938
 							),
939
-							$selection_and_datatype[ 1 ],
940
-							$selection_and_datatype[ 0 ],
939
+							$selection_and_datatype[1],
940
+							$selection_and_datatype[0],
941 941
 							$alias,
942
-							implode( ",", $this->_valid_wpdb_data_types )
942
+							implode(",", $this->_valid_wpdb_data_types)
943 943
 						)
944 944
 					);
945 945
 				}
946 946
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
947 947
 			}
948
-			$columns_to_select_string = implode(", ",$select_sql_array);
949
-		}else{
948
+			$columns_to_select_string = implode(", ", $select_sql_array);
949
+		} else {
950 950
 			$columns_to_select_string = $columns_to_select;
951 951
 		}
952 952
 		return $columns_to_select_string;
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
 	 * @return string
962 962
 	 * @throws \EE_Error
963 963
 	 */
964
-	public function primary_key_name(){
964
+	public function primary_key_name() {
965 965
 		return $this->get_primary_key_field()->get_name();
966 966
 	}
967 967
 
@@ -973,14 +973,14 @@  discard block
 block discarded – undo
973 973
 	 * @param mixed $id int or string, depending on the type of the model's primary key
974 974
 	 * @return EE_Base_Class
975 975
 	 */
976
-	public function get_one_by_ID($id){
977
-		if( $this->get_from_entity_map( $id ) ){
978
-			return $this->get_from_entity_map( $id );
976
+	public function get_one_by_ID($id) {
977
+		if ($this->get_from_entity_map($id)) {
978
+			return $this->get_from_entity_map($id);
979 979
 		}
980 980
 		return $this->get_one(
981 981
 			$this->alter_query_params_to_restrict_by_ID(
982 982
 				$id,
983
-				array( 'default_where_conditions' => 'minimum' )
983
+				array('default_where_conditions' => 'minimum')
984 984
 			)
985 985
 		);
986 986
 	}
@@ -996,15 +996,15 @@  discard block
 block discarded – undo
996 996
 	 * @return array of normal query params, @see EEM_Base::get_all
997 997
 	 * @throws \EE_Error
998 998
 	 */
999
-	public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) {
1000
-		if( ! isset( $query_params[ 0 ] ) ) {
1001
-			$query_params[ 0 ] = array();
999
+	public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) {
1000
+		if ( ! isset($query_params[0])) {
1001
+			$query_params[0] = array();
1002 1002
 		}
1003
-		if( $this->has_primary_key_field ( ) ) {
1004
-			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
1005
-		}else{
1003
+		if ($this->has_primary_key_field( )) {
1004
+			$query_params[0][$this->primary_key_name()] = $id;
1005
+		} else {
1006 1006
 			//no primary key, so the $id must be from the get_index_primary_key_string()
1007
-			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
1007
+			$query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id));
1008 1008
 		}
1009 1009
 		return $query_params;
1010 1010
 	}
@@ -1019,16 +1019,16 @@  discard block
 block discarded – undo
1019 1019
 	 * @return EE_Base_Class | NULL
1020 1020
 	 * @throws \EE_Error
1021 1021
 	 */
1022
-	public function get_one($query_params = array()){
1023
-		if( ! is_array( $query_params ) ){
1024
-			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' );
1022
+	public function get_one($query_params = array()) {
1023
+		if ( ! is_array($query_params)) {
1024
+			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1025 1025
 			$query_params = array();
1026 1026
 		}
1027 1027
 		$query_params['limit'] = 1;
1028 1028
 		$items = $this->get_all($query_params);
1029
-		if(empty($items)){
1029
+		if (empty($items)) {
1030 1030
 			return null;
1031
-		}else{
1031
+		} else {
1032 1032
 			return array_shift($items);
1033 1033
 		}
1034 1034
 	}
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
 	 * @return EE_Base_Class[]|array
1052 1052
 	 * @throws \EE_Error
1053 1053
 	 */
1054
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1055
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
1054
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1055
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
1056 1056
 	}
1057 1057
 
1058 1058
 
@@ -1073,8 +1073,8 @@  discard block
 block discarded – undo
1073 1073
 	 * @return EE_Base_Class[]|array
1074 1074
 	 * @throws \EE_Error
1075 1075
 	 */
1076
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1077
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1076
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1077
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1078 1078
 	}
1079 1079
 
1080 1080
 
@@ -1095,9 +1095,9 @@  discard block
 block discarded – undo
1095 1095
 	 * @return EE_Base_Class|null|array()
1096 1096
 	 * @throws \EE_Error
1097 1097
 	 */
1098
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1099
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1100
-		return empty( $results ) ? null : reset( $results );
1098
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1099
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1100
+		return empty($results) ? null : reset($results);
1101 1101
 	}
1102 1102
 
1103 1103
 
@@ -1119,9 +1119,9 @@  discard block
 block discarded – undo
1119 1119
  * @return EE_Base_Class|null|array()
1120 1120
 	 * @throws EE_Error
1121 1121
 	 */
1122
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1123
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1124
-		return empty( $results ) ? null : reset( $results );
1122
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1123
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1124
+		return empty($results) ? null : reset($results);
1125 1125
 	}
1126 1126
 
1127 1127
 
@@ -1142,42 +1142,42 @@  discard block
 block discarded – undo
1142 1142
 	 * @return EE_Base_Class[]|array
1143 1143
 	 * @throws EE_Error
1144 1144
 	 */
1145
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1145
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1146 1146
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1147
-		if ( empty( $field_to_order_by ) ) {
1148
-			if ( $this->has_primary_key_field() ) {
1147
+		if (empty($field_to_order_by)) {
1148
+			if ($this->has_primary_key_field()) {
1149 1149
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1150 1150
 			} else {
1151 1151
 
1152
-				if ( WP_DEBUG ) {
1153
-					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' ) );
1152
+				if (WP_DEBUG) {
1153
+					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'));
1154 1154
 				}
1155
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1155
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1156 1156
 				return array();
1157 1157
 			}
1158 1158
 		}
1159 1159
 
1160
-		if( ! is_array( $query_params ) ){
1161
-			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' );
1160
+		if ( ! is_array($query_params)) {
1161
+			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');
1162 1162
 			$query_params = array();
1163 1163
 		}
1164 1164
 
1165 1165
 		//let's add the where query param for consecutive look up.
1166
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1166
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1167 1167
 		$query_params['limit'] = $limit;
1168 1168
 
1169 1169
 		//set direction
1170
-		$incoming_orderby = isset( $query_params['order_by'] ) ? (array)$query_params['order_by'] : array();
1170
+		$incoming_orderby = isset($query_params['order_by']) ? (array) $query_params['order_by'] : array();
1171 1171
 		$query_params['order_by'] = $operand === '>'
1172
-			? array( $field_to_order_by => 'ASC' ) + $incoming_orderby
1173
-			: array( $field_to_order_by => 'DESC') + $incoming_orderby;
1172
+			? array($field_to_order_by => 'ASC') + $incoming_orderby
1173
+			: array($field_to_order_by => 'DESC') + $incoming_orderby;
1174 1174
 
1175 1175
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1176
-		if ( empty( $columns_to_select ) ) {
1177
-			return $this->get_all( $query_params );
1176
+		if (empty($columns_to_select)) {
1177
+			return $this->get_all($query_params);
1178 1178
 		} else {
1179 1179
 			//getting just the fields
1180
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1180
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1181 1181
 		}
1182 1182
 	}
1183 1183
 
@@ -1188,18 +1188,18 @@  discard block
 block discarded – undo
1188 1188
 	 * This sets the _timezone property after model object has been instantiated.
1189 1189
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1190 1190
 	 */
1191
-	public function set_timezone( $timezone ) {
1192
-		if ( $timezone !== null ) {
1191
+	public function set_timezone($timezone) {
1192
+		if ($timezone !== null) {
1193 1193
 			$this->_timezone = $timezone;
1194 1194
 		}
1195 1195
 		//note we need to loop through relations and set the timezone on those objects as well.
1196
-		foreach ( $this->_model_relations as $relation ) {
1197
-			$relation->set_timezone( $timezone );
1196
+		foreach ($this->_model_relations as $relation) {
1197
+			$relation->set_timezone($timezone);
1198 1198
 		}
1199 1199
 		//and finally we do the same for any datetime fields
1200
-		foreach ( $this->_fields as $field ) {
1201
-			if ( $field instanceof EE_Datetime_Field ) {
1202
-				$field->set_timezone( $timezone );
1200
+		foreach ($this->_fields as $field) {
1201
+			if ($field instanceof EE_Datetime_Field) {
1202
+				$field->set_timezone($timezone);
1203 1203
 			}
1204 1204
 		}
1205 1205
 	}
@@ -1214,9 +1214,9 @@  discard block
 block discarded – undo
1214 1214
 	 */
1215 1215
 	public function get_timezone() {
1216 1216
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1217
-		if ( empty( $this->_timezone ) ) {
1218
-			foreach( $this->_fields as $field ) {
1219
-				if ( $field instanceof EE_Datetime_Field ) {
1217
+		if (empty($this->_timezone)) {
1218
+			foreach ($this->_fields as $field) {
1219
+				if ($field instanceof EE_Datetime_Field) {
1220 1220
 					$this->set_timezone($field->get_timezone());
1221 1221
 					break;
1222 1222
 				}
@@ -1224,8 +1224,8 @@  discard block
 block discarded – undo
1224 1224
 		}
1225 1225
 
1226 1226
 		//if timezone STILL empty then return the default timezone for the site.
1227
-		if ( empty( $this->_timezone ) ) {
1228
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1227
+		if (empty($this->_timezone)) {
1228
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1229 1229
 		}
1230 1230
 		return $this->_timezone;
1231 1231
 	}
@@ -1243,19 +1243,19 @@  discard block
 block discarded – undo
1243 1243
 	 *
1244 1244
 	 * @return array formats in an array with the date format first, and the time format last.
1245 1245
 	 */
1246
-	public function get_formats_for( $field_name, $pretty = false ) {
1247
-		$field_settings = $this->field_settings_for( $field_name );
1246
+	public function get_formats_for($field_name, $pretty = false) {
1247
+		$field_settings = $this->field_settings_for($field_name);
1248 1248
 
1249 1249
 		//if not a valid EE_Datetime_Field then throw error
1250
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1251
-			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 ) );
1250
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1251
+			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));
1252 1252
 		}
1253 1253
 
1254 1254
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1255 1255
 		//the field.
1256 1256
 		$this->_timezone = $field_settings->get_timezone();
1257 1257
 
1258
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1258
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1259 1259
 	}
1260 1260
 
1261 1261
 
@@ -1279,25 +1279,25 @@  discard block
 block discarded – undo
1279 1279
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1280 1280
 	 *                    	     exception is triggered.
1281 1281
 	 */
1282
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1283
-		$formats = $this->get_formats_for( $field_name );
1282
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1283
+		$formats = $this->get_formats_for($field_name);
1284 1284
 
1285
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1285
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1286 1286
 
1287
-		if ( $timestamp ) {
1288
-			return $DateTime->format( 'U' );
1287
+		if ($timestamp) {
1288
+			return $DateTime->format('U');
1289 1289
 		}
1290 1290
 
1291 1291
 		//not returning timestamp, so return formatted string in timezone.
1292
-		switch( $what ) {
1292
+		switch ($what) {
1293 1293
 			case 'time' :
1294
-				return $DateTime->format( $formats[1] );
1294
+				return $DateTime->format($formats[1]);
1295 1295
 				break;
1296 1296
 			case 'date' :
1297
-				return $DateTime->format( $formats[0] );
1297
+				return $DateTime->format($formats[0]);
1298 1298
 				break;
1299 1299
 			default :
1300
-				return $DateTime->format( implode( ' ', $formats ) );
1300
+				return $DateTime->format(implode(' ', $formats));
1301 1301
 				break;
1302 1302
 		}
1303 1303
 	}
@@ -1319,17 +1319,17 @@  discard block
 block discarded – undo
1319 1319
 	 * @return DateTime
1320 1320
 	 * @throws \EE_Error
1321 1321
 	 */
1322
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1322
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1323 1323
 
1324 1324
 		//just using this to ensure the timezone is set correctly internally
1325
-		$this->get_formats_for( $field_name );
1325
+		$this->get_formats_for($field_name);
1326 1326
 
1327 1327
 		//load EEH_DTT_Helper
1328
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1328
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1329 1329
 
1330
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1330
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1331 1331
 
1332
-		return $incomingDateTime->setTimezone( new DateTimeZone( $this->_timezone ) );
1332
+		return $incomingDateTime->setTimezone(new DateTimeZone($this->_timezone));
1333 1333
 	}
1334 1334
 
1335 1335
 
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1340 1340
 	 * @return EE_Table_Base[]
1341 1341
 	 */
1342
-	public function get_tables(){
1342
+	public function get_tables() {
1343 1343
 		return $this->_tables;
1344 1344
 	}
1345 1345
 
@@ -1375,9 +1375,9 @@  discard block
 block discarded – undo
1375 1375
 	 * @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)
1376 1376
 	 * @throws \EE_Error
1377 1377
 	 */
1378
-	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1379
-		if( ! is_array( $query_params ) ){
1380
-			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' );
1378
+	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1379
+		if ( ! is_array($query_params)) {
1380
+			EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1381 1381
 			$query_params = array();
1382 1382
 		}
1383 1383
 		/**
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
 		 * @param array $fields_n_values the updated fields and their new values
1388 1388
 		 * @param array $query_params @see EEM_Base::get_all()
1389 1389
 		 */
1390
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1390
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1391 1391
 		/**
1392 1392
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1393 1393
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1395,10 +1395,10 @@  discard block
 block discarded – undo
1395 1395
 		 * @param EEM_Base $model the model being queried
1396 1396
 		 * @param array $query_params see EEM_Base::get_all()
1397 1397
 		 */
1398
-		$fields_n_values = (array)apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1398
+		$fields_n_values = (array) apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1399 1399
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1400 1400
 		//to do that, for each table, verify that it's PK isn't null.
1401
-		$tables= $this->get_tables();
1401
+		$tables = $this->get_tables();
1402 1402
 
1403 1403
 		//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
1404 1404
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1408,29 +1408,29 @@  discard block
 block discarded – undo
1408 1408
 			//we want to make sure the default_where strategy is ignored
1409 1409
 			$this->_ignore_where_strategy = TRUE;
1410 1410
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1411
-			foreach( $wpdb_select_results as $wpdb_result ){
1411
+			foreach ($wpdb_select_results as $wpdb_result) {
1412 1412
 				// type cast stdClass as array
1413
-				$wpdb_result = (array)$wpdb_result;
1413
+				$wpdb_result = (array) $wpdb_result;
1414 1414
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1415
-				if( $this->has_primary_key_field() ){
1416
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1417
-				}else{
1415
+				if ($this->has_primary_key_field()) {
1416
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1417
+				} else {
1418 1418
 					//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)
1419 1419
 					$main_table_pk_value = null;
1420 1420
 				}
1421 1421
 				//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
1422 1422
 				//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
1423
-				if(count($tables) > 1){
1423
+				if (count($tables) > 1) {
1424 1424
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1425 1425
 					//in that table, and so we'll want to insert one
1426
-					foreach($tables as $table_obj){
1426
+					foreach ($tables as $table_obj) {
1427 1427
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1428 1428
 						//if there is no private key for this table on the results, it means there's no entry
1429 1429
 						//in this table, right? so insert a row in the current table, using any fields available
1430
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1430
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1431 1431
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1432 1432
 							//if we died here, report the error
1433
-							if( ! $success ) {
1433
+							if ( ! $success) {
1434 1434
 								return false;
1435 1435
 							}
1436 1436
 						}
@@ -1450,44 +1450,44 @@  discard block
 block discarded – undo
1450 1450
 		//if this wasn't called from a model object (to update itself)
1451 1451
 		//then we want to make sure we keep all the existing
1452 1452
 		//model objects in sync with the db
1453
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1454
-			if( $this->has_primary_key_field() ){
1455
-				$model_objs_affected_ids = $this->get_col( $query_params );
1456
-			}else{
1453
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1454
+			if ($this->has_primary_key_field()) {
1455
+				$model_objs_affected_ids = $this->get_col($query_params);
1456
+			} else {
1457 1457
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1458
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1458
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1459 1459
 				$model_objs_affected_ids = array();
1460
-				foreach( $models_affected_key_columns as $row ){
1461
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1462
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1460
+				foreach ($models_affected_key_columns as $row) {
1461
+					$combined_index_key = $this->get_index_primary_key_string($row);
1462
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1463 1463
 				}
1464 1464
 
1465 1465
 			}
1466 1466
 
1467
-			if( ! $model_objs_affected_ids ){
1467
+			if ( ! $model_objs_affected_ids) {
1468 1468
 				//wait wait wait- if nothing was affected let's stop here
1469 1469
 				return 0;
1470 1470
 			}
1471
-			foreach( $model_objs_affected_ids as $id ){
1472
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1473
-				if( $model_obj_in_entity_map ){
1474
-					foreach( $fields_n_values as $field => $new_value ){
1475
-						$model_obj_in_entity_map->set( $field, $new_value );
1471
+			foreach ($model_objs_affected_ids as $id) {
1472
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1473
+				if ($model_obj_in_entity_map) {
1474
+					foreach ($fields_n_values as $field => $new_value) {
1475
+						$model_obj_in_entity_map->set($field, $new_value);
1476 1476
 					}
1477 1477
 				}
1478 1478
 			}
1479 1479
 			//if there is a primary key on this model, we can now do a slight optimization
1480
-			if( $this->has_primary_key_field() ){
1480
+			if ($this->has_primary_key_field()) {
1481 1481
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1482 1482
 				$query_params = array(
1483
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1484
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1483
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1484
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1485 1485
 			}
1486 1486
 		}
1487 1487
 
1488
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1489
-		$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.
1490
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1488
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1489
+		$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.
1490
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1491 1491
 		/**
1492 1492
 		 * Action called after a model update call has been made.
1493 1493
 		 *
@@ -1496,8 +1496,8 @@  discard block
 block discarded – undo
1496 1496
 		 * @param array $query_params @see EEM_Base::get_all()
1497 1497
 		 * @param int $rows_affected
1498 1498
 		 */
1499
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1500
-		return $rows_affected;//how many supposedly got updated
1499
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1500
+		return $rows_affected; //how many supposedly got updated
1501 1501
 	}
1502 1502
 
1503 1503
 
@@ -1513,22 +1513,22 @@  discard block
 block discarded – undo
1513 1513
 	 * @return array just like $wpdb->get_col()
1514 1514
 	 * @throws \EE_Error
1515 1515
 	 */
1516
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1516
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1517 1517
 
1518
-		if( $field_to_select ){
1519
-			$field = $this->field_settings_for( $field_to_select );
1520
-		}elseif( $this->has_primary_key_field ( ) ){
1518
+		if ($field_to_select) {
1519
+			$field = $this->field_settings_for($field_to_select);
1520
+		}elseif ($this->has_primary_key_field( )) {
1521 1521
 			$field = $this->get_primary_key_field();
1522
-		}else{
1522
+		} else {
1523 1523
 			//no primary key, just grab the first column
1524
-			$field = reset( $this->field_settings());
1524
+			$field = reset($this->field_settings());
1525 1525
 		}
1526 1526
 
1527 1527
 
1528 1528
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1529 1529
 		$select_expressions = $field->get_qualified_column();
1530
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1531
-		return $this->_do_wpdb_query('get_col', array( $SQL ) );
1530
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1531
+		return $this->_do_wpdb_query('get_col', array($SQL));
1532 1532
 	}
1533 1533
 
1534 1534
 
@@ -1541,12 +1541,12 @@  discard block
 block discarded – undo
1541 1541
 	 * @return string
1542 1542
 	 * @throws \EE_Error
1543 1543
 	 */
1544
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1545
-		$query_params[ 'limit' ] = 1;
1546
-		$col = $this->get_col( $query_params, $field_to_select );
1547
-		if( ! empty( $col ) ) {
1548
-			return reset( $col );
1549
-		}else{
1544
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1545
+		$query_params['limit'] = 1;
1546
+		$col = $this->get_col($query_params, $field_to_select);
1547
+		if ( ! empty($col)) {
1548
+			return reset($col);
1549
+		} else {
1550 1550
 			return NULL;
1551 1551
 		}
1552 1552
 	}
@@ -1562,19 +1562,19 @@  discard block
 block discarded – undo
1562 1562
 	 * @return string of SQL
1563 1563
 	 * @throws \EE_Error
1564 1564
 	 */
1565
-	public function _construct_update_sql($fields_n_values){
1565
+	public function _construct_update_sql($fields_n_values) {
1566 1566
 		/** @type WPDB $wpdb */
1567 1567
 		global $wpdb;
1568 1568
 		$cols_n_values = array();
1569
-		foreach($fields_n_values as $field_name => $value){
1569
+		foreach ($fields_n_values as $field_name => $value) {
1570 1570
 			$field_obj = $this->field_settings_for($field_name);
1571 1571
 			//if the value is NULL, we want to assign the value to that.
1572 1572
 			//wpdb->prepare doesn't really handle that properly
1573
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1574
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1573
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1574
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1575 1575
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1576 1576
 		}
1577
-		return implode(",",$cols_n_values);
1577
+		return implode(",", $cols_n_values);
1578 1578
 
1579 1579
 	}
1580 1580
 
@@ -1590,10 +1590,10 @@  discard block
 block discarded – undo
1590 1590
 	 * @return boolean whether the row got deleted or not
1591 1591
 	 * @throws \EE_Error
1592 1592
 	 */
1593
-	public function delete_permanently_by_ID( $id ) {
1593
+	public function delete_permanently_by_ID($id) {
1594 1594
 		return $this->delete_permanently(
1595 1595
 			array(
1596
-				array( $this->get_primary_key_field()->get_name() => $id ),
1596
+				array($this->get_primary_key_field()->get_name() => $id),
1597 1597
 				'limit' 	=> 1
1598 1598
 			)
1599 1599
 		);
@@ -1609,10 +1609,10 @@  discard block
 block discarded – undo
1609 1609
 	 * @return boolean whether the row got deleted or not
1610 1610
 	 * @throws \EE_Error
1611 1611
 	 */
1612
-	public function delete_by_ID( $id ){
1612
+	public function delete_by_ID($id) {
1613 1613
 		return $this->delete(
1614 1614
 			array(
1615
-				array( $this->get_primary_key_field()->get_name() => $id ),
1615
+				array($this->get_primary_key_field()->get_name() => $id),
1616 1616
 				'limit' 	=> 1
1617 1617
 			)
1618 1618
 		);
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 	 * @return int how many rows got deleted
1632 1632
 	 * @throws \EE_Error
1633 1633
 	 */
1634
-	public function delete($query_params,$allow_blocking = true){
1634
+	public function delete($query_params, $allow_blocking = true) {
1635 1635
 		return $this->delete_permanently($query_params, $allow_blocking);
1636 1636
 	}
1637 1637
 
@@ -1649,7 +1649,7 @@  discard block
 block discarded – undo
1649 1649
 	 * @return int how many rows got deleted
1650 1650
 	 * @throws \EE_Error
1651 1651
 	 */
1652
-	public function delete_permanently($query_params,$allow_blocking = true){
1652
+	public function delete_permanently($query_params, $allow_blocking = true) {
1653 1653
 		/**
1654 1654
 		 * Action called just before performing a real deletion query. You can use the
1655 1655
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1658,31 +1658,31 @@  discard block
 block discarded – undo
1658 1658
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1659 1659
 		 * to block (prevent) this deletion
1660 1660
 		 */
1661
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1661
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1662 1662
 		//some MySQL databases may be running safe mode, which may restrict
1663 1663
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1664 1664
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1665 1665
 		//to delete them
1666 1666
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1667
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1668
-		if($deletion_where){
1667
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1668
+		if ($deletion_where) {
1669 1669
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1670 1670
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1671
-			$table_aliases = array_keys( $this->_tables );
1672
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1671
+			$table_aliases = array_keys($this->_tables);
1672
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1673 1673
 
1674 1674
 			//		/echo "delete sql:$SQL";
1675
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1676
-		}else{
1675
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1676
+		} else {
1677 1677
 			$rows_deleted = 0;
1678 1678
 		}
1679 1679
 
1680 1680
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1681
-		if( $this->has_primary_key_field() ){
1682
-			foreach($items_for_deletion as $item_for_deletion_row ){
1683
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1684
-				if( isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] ) ){
1685
-					unset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $pk_value ] );
1681
+		if ($this->has_primary_key_field()) {
1682
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1683
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1684
+				if (isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value])) {
1685
+					unset($this->_entity_map[EEM_Base::$_model_query_blog_id][$pk_value]);
1686 1686
 				}
1687 1687
 			}
1688 1688
 		}
@@ -1694,8 +1694,8 @@  discard block
 block discarded – undo
1694 1694
 		 * @param array $query_params @see EEM_Base::get_all()
1695 1695
 		 * @param int $rows_deleted
1696 1696
 		 */
1697
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1698
-		return $rows_deleted;//how many supposedly got deleted
1697
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1698
+		return $rows_deleted; //how many supposedly got deleted
1699 1699
 	}
1700 1700
 
1701 1701
 
@@ -1713,28 +1713,28 @@  discard block
 block discarded – undo
1713 1713
 	 * @return boolean
1714 1714
 	 * @throws \EE_Error
1715 1715
 	 */
1716
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1716
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1717 1717
 		//first, if $ignore_this_model_obj was supplied, get its model
1718
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1718
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1719 1719
 			$ignored_model = $ignore_this_model_obj->get_model();
1720
-		}else{
1720
+		} else {
1721 1721
 			$ignored_model = null;
1722 1722
 		}
1723 1723
 		//now check all the relations of $this_model_obj_or_id and see if there
1724 1724
 		//are any related model objects blocking it?
1725 1725
 		$is_blocked = false;
1726
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1727
-			if( $relation_obj->block_delete_if_related_models_exist()){
1726
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1727
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1728 1728
 				//if $ignore_this_model_obj was supplied, then for the query
1729 1729
 				//on that model needs to be told to ignore $ignore_this_model_obj
1730
-				if($ignored_model && $relation_name === $ignored_model->get_this_model_name()){
1731
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1732
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1733
-				}else{
1730
+				if ($ignored_model && $relation_name === $ignored_model->get_this_model_name()) {
1731
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1732
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1733
+				} else {
1734 1734
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1735 1735
 				}
1736 1736
 
1737
-				if($related_model_objects){
1737
+				if ($related_model_objects) {
1738 1738
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1739 1739
 					$is_blocked = true;
1740 1740
 				}
@@ -1754,71 +1754,71 @@  discard block
 block discarded – undo
1754 1754
 	 * @throws EE_Error
1755 1755
 	 * @return string    everything that comes after the WHERE statement.
1756 1756
 	 */
1757
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1758
-		if($this->has_primary_key_field()){
1757
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1758
+		if ($this->has_primary_key_field()) {
1759 1759
 			$primary_table = $this->_get_main_table();
1760 1760
 			$other_tables = $this->_get_other_tables();
1761 1761
 			$deletes = $query = array();
1762
-			foreach ( $objects_for_deletion as $delete_object ) {
1762
+			foreach ($objects_for_deletion as $delete_object) {
1763 1763
 				//before we mark this object for deletion,
1764 1764
 				//make sure there's no related objects blocking its deletion (if we're checking)
1765 1765
 				if (
1766 1766
 					$allow_blocking
1767 1767
 				    && $this->delete_is_blocked_by_related_models(
1768
-						$delete_object[ $primary_table->get_fully_qualified_pk_column() ]
1768
+						$delete_object[$primary_table->get_fully_qualified_pk_column()]
1769 1769
 					)
1770 1770
 				) {
1771 1771
 					continue;
1772 1772
 				}
1773 1773
 				//primary table deletes
1774
-				if ( isset( $delete_object[ $primary_table->get_fully_qualified_pk_column() ] ) ) {
1775
-					$deletes[ $primary_table->get_fully_qualified_pk_column() ][] = $delete_object[ $primary_table->get_fully_qualified_pk_column() ];
1774
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1775
+					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1776 1776
 				}
1777 1777
 				//other tables
1778
-				if ( ! empty( $other_tables ) ) {
1779
-					foreach ( $other_tables as $ot ) {
1778
+				if ( ! empty($other_tables)) {
1779
+					foreach ($other_tables as $ot) {
1780 1780
 						//first check if we've got the foreign key column here.
1781
-						if ( isset( $delete_object[ $ot->get_fully_qualified_fk_column() ] ) ) {
1782
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_fk_column() ];
1781
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) {
1782
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1783 1783
 						}
1784 1784
 						// wait! it's entirely possible that we'll have a the primary key
1785 1785
 						// for this table in here, if it's a foreign key for one of the other secondary tables
1786
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_column() ] ) ) {
1787
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1786
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) {
1787
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1788 1788
 						}
1789 1789
 						// finally, it is possible that the fk for this table is found
1790 1790
 						// in the fully qualified pk column for the fk table, so let's see if that's there!
1791
-						if ( isset( $delete_object[ $ot->get_fully_qualified_pk_on_fk_table() ] ) ) {
1792
-							$deletes[ $ot->get_fully_qualified_pk_column() ][] = $delete_object[ $ot->get_fully_qualified_pk_column() ];
1791
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) {
1792
+							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1793 1793
 						}
1794 1794
 					}
1795 1795
 				}
1796 1796
 			}
1797 1797
 
1798 1798
 			//we should have deletes now, so let's just go through and setup the where statement
1799
-			foreach ( $deletes as $column => $values ) {
1799
+			foreach ($deletes as $column => $values) {
1800 1800
 				//make sure we have unique $values;
1801 1801
 				$values = array_unique($values);
1802
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1802
+				$query[] = $column.' IN('.implode(",", $values).')';
1803 1803
 			}
1804 1804
 
1805
-			return !empty($query) ? implode(' AND ', $query ) : '';
1806
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1805
+			return ! empty($query) ? implode(' AND ', $query) : '';
1806
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1807 1807
 			$ways_to_identify_a_row = array();
1808 1808
 			$fields = $this->get_combined_primary_key_fields();
1809 1809
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1810
-			foreach($objects_for_deletion as  $delete_object){
1810
+			foreach ($objects_for_deletion as  $delete_object) {
1811 1811
 				$values_for_each_cpk_for_a_row = array();
1812
-				foreach($fields as $cpk_field){
1812
+				foreach ($fields as $cpk_field) {
1813 1813
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1814 1814
 				}
1815
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1815
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1816 1816
 			}
1817
-			return implode(" OR ",$ways_to_identify_a_row);
1818
-		}else{
1817
+			return implode(" OR ", $ways_to_identify_a_row);
1818
+		} else {
1819 1819
 			//so there's no primary key and no combined key...
1820 1820
 			//sorry, can't help you
1821
-			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)));
1821
+			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)));
1822 1822
 		}
1823 1823
 	}
1824 1824
 
@@ -1834,21 +1834,21 @@  discard block
 block discarded – undo
1834 1834
 	 * @return int
1835 1835
 	 * @throws \EE_Error
1836 1836
 	 */
1837
-	public function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1837
+	public function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1838 1838
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1839
-		if($field_to_count){
1839
+		if ($field_to_count) {
1840 1840
 			$field_obj = $this->field_settings_for($field_to_count);
1841 1841
 			$column_to_count = $field_obj->get_qualified_column();
1842
-		}elseif($this->has_primary_key_field ()){
1842
+		}elseif ($this->has_primary_key_field()) {
1843 1843
 			$pk_field_obj = $this->get_primary_key_field();
1844 1844
 			$column_to_count = $pk_field_obj->get_qualified_column();
1845
-		}else{//there's no primary key
1845
+		} else {//there's no primary key
1846 1846
 			$column_to_count = '*';
1847 1847
 		}
1848 1848
 
1849
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1850
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1851
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1849
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1850
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1851
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1852 1852
 	}
1853 1853
 
1854 1854
 
@@ -1861,24 +1861,24 @@  discard block
 block discarded – undo
1861 1861
 	 * @return float
1862 1862
 	 * @throws \EE_Error
1863 1863
 	 */
1864
-	public function sum($query_params, $field_to_sum = NULL){
1864
+	public function sum($query_params, $field_to_sum = NULL) {
1865 1865
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1866 1866
 
1867
-		if($field_to_sum){
1867
+		if ($field_to_sum) {
1868 1868
 			$field_obj = $this->field_settings_for($field_to_sum);
1869 1869
 
1870
-		}else{
1870
+		} else {
1871 1871
 			$field_obj = $this->get_primary_key_field();
1872 1872
 		}
1873 1873
 		$column_to_count = $field_obj->get_qualified_column();
1874 1874
 
1875
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1876
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1875
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1876
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1877 1877
 		$data_type = $field_obj->get_wpdb_data_type();
1878
-		if( $data_type === '%d' || $data_type === '%s' ){
1879
-			return (float)$return_value;
1880
-		}else{//must be %f
1881
-			return (float)$return_value;
1878
+		if ($data_type === '%d' || $data_type === '%s') {
1879
+			return (float) $return_value;
1880
+		} else {//must be %f
1881
+			return (float) $return_value;
1882 1882
 		}
1883 1883
 	}
1884 1884
 
@@ -1893,33 +1893,33 @@  discard block
 block discarded – undo
1893 1893
 	 * @global wpdb $wpdb
1894 1894
 	 * @return mixed
1895 1895
 	 */
1896
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1896
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1897 1897
 		//if we're in maintenance mode level 2, DON'T run any queries
1898 1898
 		//because level 2 indicates the database needs updating and
1899 1899
 		//is probably out of sync with the code
1900
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1900
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1901 1901
 			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")));
1902 1902
 		}
1903 1903
 		/** @type WPDB $wpdb */
1904 1904
 		global $wpdb;
1905
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1906
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1905
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1906
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1907 1907
 		}
1908
-		if( WP_DEBUG ){
1908
+		if (WP_DEBUG) {
1909 1909
 			$old_show_errors_value = $wpdb->show_errors;
1910
-			$wpdb->show_errors( FALSE );
1911
-		}
1912
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1913
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1914
-		if( WP_DEBUG ){
1915
-			$wpdb->show_errors( $old_show_errors_value );
1916
-			if( ! empty( $wpdb->last_error ) ){
1917
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1918
-			}elseif( $result === false ){
1919
-				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 ) ) );
1910
+			$wpdb->show_errors(FALSE);
1911
+		}
1912
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1913
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1914
+		if (WP_DEBUG) {
1915
+			$wpdb->show_errors($old_show_errors_value);
1916
+			if ( ! empty($wpdb->last_error)) {
1917
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1918
+			}elseif ($result === false) {
1919
+				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)));
1920 1920
 			}
1921
-		}elseif( $result === false ) {
1922
-			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1921
+		}elseif ($result === false) {
1922
+			EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
1923 1923
 		}
1924 1924
 		return $result;
1925 1925
 	}
@@ -1935,26 +1935,26 @@  discard block
 block discarded – undo
1935 1935
 	 * @param array $arguments_to_provide
1936 1936
 	 * @return mixed
1937 1937
 	 */
1938
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1938
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1939 1939
 		/** @type WPDB $wpdb */
1940 1940
 		global $wpdb;
1941 1941
 		$wpdb->last_error = null;
1942
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1942
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1943 1943
 		// was there an error running the query? but we don't care on new activations
1944 1944
 		// (we're going to setup the DB anyway on new activations)
1945
-		if ( ( $result === false || ! empty( $wpdb->last_error ) )
1945
+		if (($result === false || ! empty($wpdb->last_error))
1946 1946
 			&& EE_System::instance()->detect_req_type() !== EE_System::req_type_new_activation
1947 1947
 		) {
1948
-			switch ( EEM_Base::$_db_verification_level ) {
1948
+			switch (EEM_Base::$_db_verification_level) {
1949 1949
 
1950 1950
 				case EEM_Base::db_verified_none :
1951 1951
 					// let's double-check core's DB
1952
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1952
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1953 1953
 					break;
1954 1954
 
1955 1955
 				case EEM_Base::db_verified_core :
1956 1956
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1957
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1957
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1958 1958
 					break;
1959 1959
 
1960 1960
 				case EEM_Base::db_verified_addons :
@@ -1962,11 +1962,11 @@  discard block
 block discarded – undo
1962 1962
 					return $result;
1963 1963
 					break;
1964 1964
 			}
1965
-			if ( ! empty( $error_message ) ) {
1966
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1967
-				trigger_error( $error_message );
1965
+			if ( ! empty($error_message)) {
1966
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1967
+				trigger_error($error_message);
1968 1968
 			}
1969
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1969
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1970 1970
 
1971 1971
 		}
1972 1972
 
@@ -1982,18 +1982,18 @@  discard block
 block discarded – undo
1982 1982
 	 * @param array $arguments_to_provide
1983 1983
 	 * @return string
1984 1984
 	 */
1985
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1985
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1986 1986
 		/** @type WPDB $wpdb */
1987 1987
 		global $wpdb;
1988 1988
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
1989 1989
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
1990 1990
 		$error_message = sprintf(
1991
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
1991
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
1992 1992
 			$wpdb->last_error,
1993 1993
 			$wpdb_method,
1994
-			json_encode( $arguments_to_provide )
1994
+			json_encode($arguments_to_provide)
1995 1995
 		);
1996
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
1996
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
1997 1997
 		return $error_message;
1998 1998
 	}
1999 1999
 
@@ -2006,16 +2006,16 @@  discard block
 block discarded – undo
2006 2006
 	 * @param $arguments_to_provide
2007 2007
 	 * @return string
2008 2008
 	 */
2009
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
2009
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
2010 2010
 		/** @type WPDB $wpdb */
2011 2011
 		global $wpdb;
2012 2012
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
2013 2013
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
2014 2014
 		$error_message = sprintf(
2015
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
2015
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
2016 2016
 			$wpdb->last_error,
2017 2017
 			$wpdb_method,
2018
-			json_encode( $arguments_to_provide )
2018
+			json_encode($arguments_to_provide)
2019 2019
 		);
2020 2020
 		EE_System::instance()->initialize_addons();
2021 2021
 		return $error_message;
@@ -2030,7 +2030,7 @@  discard block
 block discarded – undo
2030 2030
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2031 2031
 	 * @return string
2032 2032
 	 */
2033
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
2033
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
2034 2034
 		return " FROM ".$model_query_info->get_full_join_sql().
2035 2035
 				$model_query_info->get_where_sql().
2036 2036
 				$model_query_info->get_group_by_sql().
@@ -2043,7 +2043,7 @@  discard block
 block discarded – undo
2043 2043
 	 * Set to easily debug the next X queries ran from this model.
2044 2044
 	 * @param int $count
2045 2045
 	 */
2046
-	public function show_next_x_db_queries($count = 1){
2046
+	public function show_next_x_db_queries($count = 1) {
2047 2047
 		$this->_show_next_x_db_queries = $count;
2048 2048
 	}
2049 2049
 
@@ -2052,8 +2052,8 @@  discard block
 block discarded – undo
2052 2052
 	/**
2053 2053
 	 * @param $sql_query
2054 2054
 	 */
2055
-	public function show_db_query_if_previously_requested($sql_query){
2056
-		if($this->_show_next_x_db_queries > 0){
2055
+	public function show_db_query_if_previously_requested($sql_query) {
2056
+		if ($this->_show_next_x_db_queries > 0) {
2057 2057
 			echo $sql_query;
2058 2058
 			$this->_show_next_x_db_queries--;
2059 2059
 		}
@@ -2077,9 +2077,9 @@  discard block
 block discarded – undo
2077 2077
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
2078 2078
 	 * @throws \EE_Error
2079 2079
 	 */
2080
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
2080
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
2081 2081
 		$relation_obj = $this->related_settings_for($relationName);
2082
-		return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2082
+		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2083 2083
 	}
2084 2084
 
2085 2085
 
@@ -2098,9 +2098,9 @@  discard block
 block discarded – undo
2098 2098
 	 * @throws \EE_Error
2099 2099
 	 * @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.
2100 2100
 	 */
2101
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2101
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
2102 2102
 		$relation_obj = $this->related_settings_for($relationName);
2103
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
2103
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
2104 2104
 	}
2105 2105
 
2106 2106
 
@@ -2113,9 +2113,9 @@  discard block
 block discarded – undo
2113 2113
 	 * @return \EE_Base_Class[]
2114 2114
 	 * @throws \EE_Error
2115 2115
 	 */
2116
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
2116
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2117 2117
 		$relation_obj = $this->related_settings_for($relationName);
2118
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2118
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2119 2119
 	}
2120 2120
 
2121 2121
 
@@ -2131,10 +2131,10 @@  discard block
 block discarded – undo
2131 2131
 	 * @return EE_Base_Class[]
2132 2132
 	 * @throws \EE_Error
2133 2133
 	 */
2134
-	public function get_all_related($id_or_obj, $model_name, $query_params = null){
2134
+	public function get_all_related($id_or_obj, $model_name, $query_params = null) {
2135 2135
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2136 2136
 		$relation_settings = $this->related_settings_for($model_name);
2137
-		return $relation_settings->get_all_related($model_obj,$query_params);
2137
+		return $relation_settings->get_all_related($model_obj, $query_params);
2138 2138
 	}
2139 2139
 
2140 2140
 
@@ -2151,10 +2151,10 @@  discard block
 block discarded – undo
2151 2151
 	 * @return int how many deleted
2152 2152
 	 * @throws \EE_Error
2153 2153
 	 */
2154
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2154
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2155 2155
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2156 2156
 		$relation_settings = $this->related_settings_for($model_name);
2157
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2157
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2158 2158
 	}
2159 2159
 
2160 2160
 
@@ -2171,10 +2171,10 @@  discard block
 block discarded – undo
2171 2171
 	 * @return int how many deleted
2172 2172
 	 * @throws \EE_Error
2173 2173
 	 */
2174
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2174
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2175 2175
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2176 2176
 		$relation_settings = $this->related_settings_for($model_name);
2177
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2177
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2178 2178
 	}
2179 2179
 
2180 2180
 
@@ -2191,17 +2191,17 @@  discard block
 block discarded – undo
2191 2191
 	 * @return int
2192 2192
 	 * @throws \EE_Error
2193 2193
 	 */
2194
-	public function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2194
+	public function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2195 2195
 		$related_model = $this->get_related_model_obj($model_name);
2196 2196
 		//we're just going to use the query params on the related model's normal get_all query,
2197 2197
 		//except add a condition to say to match the current mod
2198
-		if( ! isset($query_params['default_where_conditions'])){
2199
-			$query_params['default_where_conditions']='none';
2198
+		if ( ! isset($query_params['default_where_conditions'])) {
2199
+			$query_params['default_where_conditions'] = 'none';
2200 2200
 		}
2201 2201
 		$this_model_name = $this->get_this_model_name();
2202 2202
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2203
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2204
-		return $related_model->count($query_params,$field_to_count,$distinct);
2203
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2204
+		return $related_model->count($query_params, $field_to_count, $distinct);
2205 2205
 	}
2206 2206
 
2207 2207
 
@@ -2217,21 +2217,21 @@  discard block
 block discarded – undo
2217 2217
 	 * @return float
2218 2218
 	 * @throws \EE_Error
2219 2219
 	 */
2220
-	public function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2220
+	public function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2221 2221
 		$related_model = $this->get_related_model_obj($model_name);
2222
-		if( ! is_array( $query_params ) ){
2223
-			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' );
2222
+		if ( ! is_array($query_params)) {
2223
+			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');
2224 2224
 			$query_params = array();
2225 2225
 		}
2226 2226
 		//we're just going to use the query params on the related model's normal get_all query,
2227 2227
 		//except add a condition to say to match the current mod
2228
-		if( ! isset($query_params['default_where_conditions'])){
2229
-			$query_params['default_where_conditions']='none';
2228
+		if ( ! isset($query_params['default_where_conditions'])) {
2229
+			$query_params['default_where_conditions'] = 'none';
2230 2230
 		}
2231 2231
 		$this_model_name = $this->get_this_model_name();
2232 2232
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2233
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2234
-		return $related_model->sum($query_params,$field_to_sum);
2233
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2234
+		return $related_model->sum($query_params, $field_to_sum);
2235 2235
 	}
2236 2236
 
2237 2237
 
@@ -2245,12 +2245,12 @@  discard block
 block discarded – undo
2245 2245
 	 * @return EE_Base_Class
2246 2246
 	 * @throws \EE_Error
2247 2247
 	 */
2248
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2249
-		$query_params['limit']=1;
2250
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2251
-		if( $results ){
2248
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2249
+		$query_params['limit'] = 1;
2250
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2251
+		if ($results) {
2252 2252
 			return array_shift($results);
2253
-		}else{
2253
+		} else {
2254 2254
 			return null;
2255 2255
 		}
2256 2256
 
@@ -2260,8 +2260,8 @@  discard block
 block discarded – undo
2260 2260
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2261 2261
 	 * @return string
2262 2262
 	 */
2263
-	public function get_this_model_name(){
2264
-		return str_replace("EEM_","",get_class($this));
2263
+	public function get_this_model_name() {
2264
+		return str_replace("EEM_", "", get_class($this));
2265 2265
 	}
2266 2266
 
2267 2267
 	/**
@@ -2269,14 +2269,14 @@  discard block
 block discarded – undo
2269 2269
 	 * @return EE_Any_Foreign_Model_Name_Field
2270 2270
 	 * @throws EE_Error
2271 2271
 	 */
2272
-	public function get_field_containing_related_model_name(){
2273
-		foreach($this->field_settings(true) as $field){
2274
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2272
+	public function get_field_containing_related_model_name() {
2273
+		foreach ($this->field_settings(true) as $field) {
2274
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2275 2275
 				$field_with_model_name = $field;
2276 2276
 			}
2277 2277
 		}
2278
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2279
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2278
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2279
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2280 2280
 		}
2281 2281
 		return $field_with_model_name;
2282 2282
 	}
@@ -2297,19 +2297,19 @@  discard block
 block discarded – undo
2297 2297
 	 * @return int new primary key on main table that got inserted
2298 2298
 	 * @throws EE_Error
2299 2299
 	 */
2300
-	public function insert($field_n_values){
2300
+	public function insert($field_n_values) {
2301 2301
 		/**
2302 2302
 		 * Filters the fields and their values before inserting an item using the models
2303 2303
 		 * @param array $fields_n_values keys are the fields and values are their new values
2304 2304
 		 * @param EEM_Base $model the model used
2305 2305
 		 */
2306
-		$field_n_values = (array)apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2307
-		if($this->_satisfies_unique_indexes($field_n_values)){
2306
+		$field_n_values = (array) apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2307
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2308 2308
 			$main_table = $this->_get_main_table();
2309 2309
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2310
-			if( $new_id !== false ) {
2311
-				foreach($this->_get_other_tables() as $other_table){
2312
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2310
+			if ($new_id !== false) {
2311
+				foreach ($this->_get_other_tables() as $other_table) {
2312
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2313 2313
 				}
2314 2314
 			}
2315 2315
 			/**
@@ -2319,9 +2319,9 @@  discard block
 block discarded – undo
2319 2319
 			 * @param array $fields_n_values fields and their values
2320 2320
 			 * @param int|string the ID of the newly-inserted model object
2321 2321
 			 */
2322
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2322
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2323 2323
 			return $new_id;
2324
-		}else{
2324
+		} else {
2325 2325
 			return FALSE;
2326 2326
 		}
2327 2327
 	}
@@ -2336,10 +2336,10 @@  discard block
 block discarded – undo
2336 2336
 	 * @return boolean
2337 2337
 	 * @throws \EE_Error
2338 2338
 	 */
2339
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2340
-		foreach($this->unique_indexes() as $index_name => $index){
2339
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2340
+		foreach ($this->unique_indexes() as $index_name => $index) {
2341 2341
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2342
-			if($this->exists(array($uniqueness_where_params))){
2342
+			if ($this->exists(array($uniqueness_where_params))) {
2343 2343
 				EE_Error::add_error(
2344 2344
 					sprintf(
2345 2345
 						__(
@@ -2349,8 +2349,8 @@  discard block
 block discarded – undo
2349 2349
 						$action,
2350 2350
 						$this->_get_class_name(),
2351 2351
 						$index_name,
2352
-						implode( ",", $index->field_names() ),
2353
-						http_build_query( $uniqueness_where_params )
2352
+						implode(",", $index->field_names()),
2353
+						http_build_query($uniqueness_where_params)
2354 2354
 					),
2355 2355
 					__FILE__,
2356 2356
 					__FUNCTION__,
@@ -2376,37 +2376,37 @@  discard block
 block discarded – undo
2376 2376
 	 * @throws EE_Error
2377 2377
 	 * @return EE_Base_Class
2378 2378
 	 */
2379
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2380
-		if($obj_or_fields_array instanceof EE_Base_Class){
2379
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2380
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2381 2381
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2382
-		}elseif( is_array($obj_or_fields_array)){
2382
+		}elseif (is_array($obj_or_fields_array)) {
2383 2383
 			$fields_n_values = $obj_or_fields_array;
2384
-		}else{
2384
+		} else {
2385 2385
 			throw new EE_Error(
2386 2386
 				sprintf(
2387 2387
 					__(
2388 2388
 						"%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d",
2389 2389
 						"event_espresso"
2390 2390
 					),
2391
-					get_class( $this ),
2391
+					get_class($this),
2392 2392
 					$obj_or_fields_array
2393 2393
 				)
2394 2394
 			);
2395 2395
 		}
2396 2396
 		$query_params = array();
2397
-		if( $this->has_primary_key_field() &&
2398
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2399
-				isset($fields_n_values[$this->primary_key_name()])){
2397
+		if ($this->has_primary_key_field() &&
2398
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2399
+				isset($fields_n_values[$this->primary_key_name()])) {
2400 2400
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2401 2401
 		}
2402
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2402
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2403 2403
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2404 2404
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2405 2405
 		}
2406 2406
 		//if there is nothing to base this search on, then we shouldn't find anything
2407
-		if( empty( $query_params ) ){
2407
+		if (empty($query_params)) {
2408 2408
 			return array();
2409
-		}else{
2409
+		} else {
2410 2410
 			return $this->get_one($query_params);
2411 2411
 		}
2412 2412
 	}
@@ -2420,7 +2420,7 @@  discard block
 block discarded – undo
2420 2420
 	 * @return boolean
2421 2421
 	 * @throws \EE_Error
2422 2422
 	 */
2423
-	public function exists($query_params){
2423
+	public function exists($query_params) {
2424 2424
 		$query_params['limit'] = 1;
2425 2425
 		return $this->count($query_params) > 0;
2426 2426
 	}
@@ -2434,7 +2434,7 @@  discard block
 block discarded – undo
2434 2434
 	 * @return boolean
2435 2435
 	 * @throws \EE_Error
2436 2436
 	 */
2437
-	public function exists_by_ID($id){
2437
+	public function exists_by_ID($id) {
2438 2438
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2439 2439
 	}
2440 2440
 
@@ -2454,45 +2454,45 @@  discard block
 block discarded – undo
2454 2454
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2455 2455
 	 * @return int ID of new row inserted, or FALSE on failure
2456 2456
 	 */
2457
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2457
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2458 2458
 		global $wpdb;
2459 2459
 		$insertion_col_n_values = array();
2460 2460
 		$format_for_insertion = array();
2461 2461
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2462
-		foreach($fields_on_table as $field_name => $field_obj){
2462
+		foreach ($fields_on_table as $field_name => $field_obj) {
2463 2463
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2464
-			if($field_obj->is_auto_increment()){
2464
+			if ($field_obj->is_auto_increment()) {
2465 2465
 				continue;
2466 2466
 			}
2467 2467
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2468 2468
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2469
-			if( $prepared_value !== NULL ){
2470
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2469
+			if ($prepared_value !== NULL) {
2470
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2471 2471
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2472 2472
 			}
2473 2473
 		}
2474 2474
 
2475
-		if($table instanceof EE_Secondary_Table && $new_id){
2475
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2476 2476
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2477 2477
 			//so add the fk to the main table as a column
2478 2478
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2479
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2479
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2480 2480
 		}
2481 2481
 		//insert the new entry
2482
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2483
-		if( $result === false ) {
2482
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2483
+		if ($result === false) {
2484 2484
 			return false;
2485 2485
 		}
2486 2486
 		//ok, now what do we return for the ID of the newly-inserted thing?
2487
-		if($this->has_primary_key_field()){
2488
-			if($this->get_primary_key_field()->is_auto_increment()){
2487
+		if ($this->has_primary_key_field()) {
2488
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2489 2489
 				return $wpdb->insert_id;
2490
-			}else{
2490
+			} else {
2491 2491
 				//it's not an auto-increment primary key, so
2492 2492
 				//it must have been supplied
2493 2493
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2494 2494
 			}
2495
-		}else{
2495
+		} else {
2496 2496
 			//we can't return a  primary key because there is none. instead return
2497 2497
 			//a unique string indicating this model
2498 2498
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2511,15 +2511,15 @@  discard block
 block discarded – undo
2511 2511
 	 * @return mixed string|int|float depending on what the table column will be expecting
2512 2512
 	 * @throws \EE_Error
2513 2513
 	 */
2514
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2514
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2515 2515
 		//if this field doesn't allow nullable, don't allow it
2516
-		if( ! $field_obj->is_nullable() && (
2517
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2518
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2519
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2516
+		if ( ! $field_obj->is_nullable() && (
2517
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2518
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2519
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2520 2520
 		}
2521
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2522
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2521
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2522
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2523 2523
 	}
2524 2524
 
2525 2525
 
@@ -2531,9 +2531,9 @@  discard block
 block discarded – undo
2531 2531
 	 * @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
2532 2532
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2533 2533
 	 */
2534
-	private function _prepare_value_for_use_in_db($value, $field){
2535
-		if($field && $field instanceof EE_Model_Field_Base){
2536
-			switch( $this->_values_already_prepared_by_model_object ){
2534
+	private function _prepare_value_for_use_in_db($value, $field) {
2535
+		if ($field && $field instanceof EE_Model_Field_Base) {
2536
+			switch ($this->_values_already_prepared_by_model_object) {
2537 2537
 				/** @noinspection PhpMissingBreakStatementInspection */
2538 2538
 				case self::not_prepared_by_model_object:
2539 2539
 					$value = $field->prepare_for_set($value);
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
 					//leave the value alone
2545 2545
 			}
2546 2546
 			return $value;
2547
-		}else{
2547
+		} else {
2548 2548
 			return $value;
2549 2549
 		}
2550 2550
 	}
@@ -2554,13 +2554,13 @@  discard block
 block discarded – undo
2554 2554
 	 * @return EE_Primary_Table
2555 2555
 	 * @throws EE_Error
2556 2556
 	 */
2557
-	protected function _get_main_table(){
2558
-		foreach($this->_tables as $table){
2559
-			if($table instanceof EE_Primary_Table){
2557
+	protected function _get_main_table() {
2558
+		foreach ($this->_tables as $table) {
2559
+			if ($table instanceof EE_Primary_Table) {
2560 2560
 				return $table;
2561 2561
 			}
2562 2562
 		}
2563
-		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)));
2563
+		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)));
2564 2564
 	}
2565 2565
 
2566 2566
 
@@ -2583,7 +2583,7 @@  discard block
 block discarded – undo
2583 2583
 	 */
2584 2584
 	public function second_table() {
2585 2585
 		// grab second table from tables array
2586
-		$second_table = end( $this->_tables );
2586
+		$second_table = end($this->_tables);
2587 2587
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2588 2588
 	}
2589 2589
 
@@ -2596,8 +2596,8 @@  discard block
 block discarded – undo
2596 2596
 	 * @param string $table_alias
2597 2597
 	 * @return EE_Primary_Table | EE_Secondary_Table
2598 2598
 	 */
2599
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2600
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2599
+	public function get_table_obj_by_alias($table_alias = '') {
2600
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2601 2601
 	}
2602 2602
 
2603 2603
 
@@ -2606,10 +2606,10 @@  discard block
 block discarded – undo
2606 2606
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2607 2607
 	 * @return EE_Secondary_Table[]
2608 2608
 	 */
2609
-	protected function _get_other_tables(){
2610
-		$other_tables =array();
2611
-		foreach($this->_tables as $table_alias => $table){
2612
-			if($table instanceof EE_Secondary_Table){
2609
+	protected function _get_other_tables() {
2610
+		$other_tables = array();
2611
+		foreach ($this->_tables as $table_alias => $table) {
2612
+			if ($table instanceof EE_Secondary_Table) {
2613 2613
 				$other_tables[$table_alias] = $table;
2614 2614
 			}
2615 2615
 		}
@@ -2621,7 +2621,7 @@  discard block
 block discarded – undo
2621 2621
 	 * @param string $table_alias, array key in EEM_Base::_tables
2622 2622
 	 * @return EE_Model_Field_Base[]
2623 2623
 	 */
2624
-	public function _get_fields_for_table($table_alias){
2624
+	public function _get_fields_for_table($table_alias) {
2625 2625
 		return $this->_fields[$table_alias];
2626 2626
 	}
2627 2627
 
@@ -2637,19 +2637,19 @@  discard block
 block discarded – undo
2637 2637
 	 * @return EE_Model_Query_Info_Carrier
2638 2638
 	 * @throws \EE_Error
2639 2639
 	 */
2640
-	public function _extract_related_models_from_query($query_params){
2640
+	public function _extract_related_models_from_query($query_params) {
2641 2641
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2642
-		if ( array_key_exists( 0, $query_params ) ) {
2643
-			$this->_extract_related_models_from_sub_params_array_keys( $query_params[0], $query_info_carrier, 0 );
2642
+		if (array_key_exists(0, $query_params)) {
2643
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2644 2644
 		}
2645
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2646
-			if ( is_array( $query_params['group_by'] ) ) {
2645
+		if (array_key_exists('group_by', $query_params)) {
2646
+			if (is_array($query_params['group_by'])) {
2647 2647
 				$this->_extract_related_models_from_sub_params_array_values(
2648 2648
 					$query_params['group_by'],
2649 2649
 					$query_info_carrier,
2650 2650
 					'group_by'
2651 2651
 				);
2652
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2652
+			} elseif ( ! empty ($query_params['group_by'])) {
2653 2653
 				$this->_extract_related_model_info_from_query_param(
2654 2654
 					$query_params['group_by'],
2655 2655
 					$query_info_carrier,
@@ -2657,21 +2657,21 @@  discard block
 block discarded – undo
2657 2657
 				);
2658 2658
 			}
2659 2659
 		}
2660
-		if ( array_key_exists( 'having', $query_params ) ) {
2660
+		if (array_key_exists('having', $query_params)) {
2661 2661
 			$this->_extract_related_models_from_sub_params_array_keys(
2662 2662
 				$query_params[0],
2663 2663
 				$query_info_carrier,
2664 2664
 				'having'
2665 2665
 			);
2666 2666
 		}
2667
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2668
-			if ( is_array( $query_params['order_by'] ) ) {
2667
+		if (array_key_exists('order_by', $query_params)) {
2668
+			if (is_array($query_params['order_by'])) {
2669 2669
 				$this->_extract_related_models_from_sub_params_array_keys(
2670 2670
 					$query_params['order_by'],
2671 2671
 					$query_info_carrier,
2672 2672
 					'order_by'
2673 2673
 				);
2674
-			} elseif ( ! empty( $query_params['order_by'] ) ) {
2674
+			} elseif ( ! empty($query_params['order_by'])) {
2675 2675
 				$this->_extract_related_model_info_from_query_param(
2676 2676
 					$query_params['order_by'],
2677 2677
 					$query_info_carrier,
@@ -2679,7 +2679,7 @@  discard block
 block discarded – undo
2679 2679
 				);
2680 2680
 			}
2681 2681
 		}
2682
-		if ( array_key_exists( 'force_join', $query_params ) ) {
2682
+		if (array_key_exists('force_join', $query_params)) {
2683 2683
 			$this->_extract_related_models_from_sub_params_array_values(
2684 2684
 				$query_params['force_join'],
2685 2685
 				$query_info_carrier,
@@ -2697,34 +2697,34 @@  discard block
 block discarded – undo
2697 2697
 	 * @throws EE_Error
2698 2698
 	 * @return \EE_Model_Query_Info_Carrier
2699 2699
 	 */
2700
-	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){
2701
-		if (!empty($sub_query_params)){
2700
+	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) {
2701
+		if ( ! empty($sub_query_params)) {
2702 2702
 			$sub_query_params = (array) $sub_query_params;
2703
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2703
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2704 2704
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2705
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2705
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2706 2706
 
2707 2707
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2708 2708
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2709 2709
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2710 2710
 				//of array('Registration.TXN_ID'=>23)
2711 2711
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2712
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2713
-					if (! is_array($possibly_array_of_params)){
2712
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2713
+					if ( ! is_array($possibly_array_of_params)) {
2714 2714
 						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"),
2715
-							$param,$possibly_array_of_params));
2716
-					}else{
2717
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2715
+							$param, $possibly_array_of_params));
2716
+					} else {
2717
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2718 2718
 					}
2719
-				}elseif($query_param_type === 0 //ie WHERE
2719
+				}elseif ($query_param_type === 0 //ie WHERE
2720 2720
 						&& is_array($possibly_array_of_params)
2721 2721
 						&& isset($possibly_array_of_params[2])
2722
-						&& $possibly_array_of_params[2] == true){
2722
+						&& $possibly_array_of_params[2] == true) {
2723 2723
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2724 2724
 					//indicating that $possible_array_of_params[1] is actually a field name,
2725 2725
 					//from which we should extract query parameters!
2726
-					if( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1] ) ) {
2727
-						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)));
2726
+					if ( ! isset($possibly_array_of_params[0], $possibly_array_of_params[1])) {
2727
+						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)));
2728 2728
 					}
2729 2729
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2730 2730
 				}
@@ -2743,14 +2743,14 @@  discard block
 block discarded – undo
2743 2743
 	 * @throws EE_Error
2744 2744
 	 * @return \EE_Model_Query_Info_Carrier
2745 2745
 	 */
2746
-	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){
2747
-		if (!empty($sub_query_params)){
2748
-			if(!is_array($sub_query_params)){
2749
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2746
+	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) {
2747
+		if ( ! empty($sub_query_params)) {
2748
+			if ( ! is_array($sub_query_params)) {
2749
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2750 2750
 			}
2751
-			foreach($sub_query_params as $param){
2751
+			foreach ($sub_query_params as $param) {
2752 2752
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2753
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2753
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2754 2754
 			}
2755 2755
 		}
2756 2756
 		return $model_query_info_carrier;
@@ -2769,8 +2769,8 @@  discard block
 block discarded – undo
2769 2769
 	 * @throws EE_Error
2770 2770
 	 * @return EE_Model_Query_Info_Carrier
2771 2771
 	 */
2772
-	public function _create_model_query_info_carrier($query_params){
2773
-		if ( ! is_array( $query_params ) ) {
2772
+	public function _create_model_query_info_carrier($query_params) {
2773
+		if ( ! is_array($query_params)) {
2774 2774
 			EE_Error::doing_it_wrong(
2775 2775
 				'EEM_Base::_create_model_query_info_carrier',
2776 2776
 				sprintf(
@@ -2778,16 +2778,16 @@  discard block
 block discarded – undo
2778 2778
 						'$query_params should be an array, you passed a variable of type %s',
2779 2779
 						'event_espresso'
2780 2780
 					),
2781
-					gettype( $query_params )
2781
+					gettype($query_params)
2782 2782
 				),
2783 2783
 				'4.6.0'
2784 2784
 			);
2785 2785
 			$query_params = array();
2786 2786
 		}
2787
-		$where_query_params = isset( $query_params[0] ) ? $query_params[0] : array();
2787
+		$where_query_params = isset($query_params[0]) ? $query_params[0] : array();
2788 2788
 		//first check if we should alter the query to account for caps or not
2789 2789
 		//because the caps might require us to do extra joins
2790
-		if ( isset( $query_params['caps'] ) && $query_params['caps'] !== 'none' ) {
2790
+		if (isset($query_params['caps']) && $query_params['caps'] !== 'none') {
2791 2791
 			$query_params[0] = $where_query_params = array_replace_recursive(
2792 2792
 				$where_query_params,
2793 2793
 				$this->caps_where_conditions(
@@ -2795,10 +2795,10 @@  discard block
 block discarded – undo
2795 2795
 				)
2796 2796
 			);
2797 2797
 		}
2798
-		$query_object = $this->_extract_related_models_from_query( $query_params );
2798
+		$query_object = $this->_extract_related_models_from_query($query_params);
2799 2799
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2800
-		foreach ( $where_query_params as $key => $value ) {
2801
-			if ( is_int( $key ) ) {
2800
+		foreach ($where_query_params as $key => $value) {
2801
+			if (is_int($key)) {
2802 2802
 				throw new EE_Error(
2803 2803
 					sprintf(
2804 2804
 						__(
@@ -2806,16 +2806,16 @@  discard block
 block discarded – undo
2806 2806
 							"event_espresso"
2807 2807
 						),
2808 2808
 						$key,
2809
-						var_export( $value, true ),
2810
-						var_export( $query_params, true ),
2811
-						get_class( $this )
2809
+						var_export($value, true),
2810
+						var_export($query_params, true),
2811
+						get_class($this)
2812 2812
 					)
2813 2813
 				);
2814 2814
 			}
2815 2815
 		}
2816 2816
 		if (
2817
-			array_key_exists( 'default_where_conditions', $query_params )
2818
-			&& ! empty( $query_params['default_where_conditions'] )
2817
+			array_key_exists('default_where_conditions', $query_params)
2818
+			&& ! empty($query_params['default_where_conditions'])
2819 2819
 		) {
2820 2820
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2821 2821
 		} else {
@@ -2829,13 +2829,13 @@  discard block
 block discarded – undo
2829 2829
 			),
2830 2830
 			$where_query_params
2831 2831
 		);
2832
-		$query_object->set_where_sql( $this->_construct_where_clause( $where_query_params ) );
2832
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2833 2833
 		// if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.
2834 2834
 		// So we need to setup a subquery and use that for the main join.
2835 2835
 		// Note for now this only works on the primary table for the model.
2836 2836
 		// So for instance, you could set the limit array like this:
2837 2837
 		// array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2838
-		if ( array_key_exists( 'on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] ) ) {
2838
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2839 2839
 			$query_object->set_main_model_join_sql(
2840 2840
 				$this->_construct_limit_join_select(
2841 2841
 					$query_params['on_join_limit'][0],
@@ -2844,40 +2844,40 @@  discard block
 block discarded – undo
2844 2844
 			);
2845 2845
 		}
2846 2846
 		//set limit
2847
-		if ( array_key_exists( 'limit', $query_params ) ) {
2848
-			if ( is_array( $query_params['limit'] ) ) {
2849
-				if ( ! isset( $query_params['limit'][0], $query_params['limit'][1] ) ) {
2847
+		if (array_key_exists('limit', $query_params)) {
2848
+			if (is_array($query_params['limit'])) {
2849
+				if ( ! isset($query_params['limit'][0], $query_params['limit'][1])) {
2850 2850
 					$e = sprintf(
2851 2851
 						__(
2852 2852
 							"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)",
2853 2853
 							"event_espresso"
2854 2854
 						),
2855
-						http_build_query( $query_params['limit'] )
2855
+						http_build_query($query_params['limit'])
2856 2856
 					);
2857
-					throw new EE_Error( $e . "|" . $e );
2857
+					throw new EE_Error($e."|".$e);
2858 2858
 				}
2859 2859
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2860
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'][0] . "," . $query_params['limit'][1] );
2861
-			} elseif ( ! empty ( $query_params['limit'] ) ) {
2862
-				$query_object->set_limit_sql( " LIMIT " . $query_params['limit'] );
2860
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2861
+			} elseif ( ! empty ($query_params['limit'])) {
2862
+				$query_object->set_limit_sql(" LIMIT ".$query_params['limit']);
2863 2863
 			}
2864 2864
 		}
2865 2865
 		//set order by
2866
-		if ( array_key_exists( 'order_by', $query_params ) ) {
2867
-			if ( is_array( $query_params['order_by'] ) ) {
2866
+		if (array_key_exists('order_by', $query_params)) {
2867
+			if (is_array($query_params['order_by'])) {
2868 2868
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2869 2869
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2870 2870
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2871
-				if ( array_key_exists( 'order', $query_params ) ) {
2871
+				if (array_key_exists('order', $query_params)) {
2872 2872
 					throw new EE_Error(
2873 2873
 						sprintf(
2874 2874
 							__(
2875 2875
 								"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 ",
2876 2876
 								"event_espresso"
2877 2877
 							),
2878
-							get_class( $this ),
2879
-							implode( ", ", array_keys( $query_params['order_by'] ) ),
2880
-							implode( ", ", $query_params['order_by'] ),
2878
+							get_class($this),
2879
+							implode(", ", array_keys($query_params['order_by'])),
2880
+							implode(", ", $query_params['order_by']),
2881 2881
 							$query_params['order']
2882 2882
 						)
2883 2883
 					);
@@ -2889,57 +2889,57 @@  discard block
 block discarded – undo
2889 2889
 				);
2890 2890
 				//assume it's an array of fields to order by
2891 2891
 				$order_array = array();
2892
-				foreach ( $query_params['order_by'] as $field_name_to_order_by => $order ) {
2893
-					$order = $this->_extract_order( $order );
2894
-					$order_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_order_by ) . SP . $order;
2892
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2893
+					$order = $this->_extract_order($order);
2894
+					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2895 2895
 				}
2896
-				$query_object->set_order_by_sql( " ORDER BY " . implode( ",", $order_array ) );
2897
-			} elseif ( ! empty ( $query_params['order_by'] ) ) {
2896
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2897
+			} elseif ( ! empty ($query_params['order_by'])) {
2898 2898
 				$this->_extract_related_model_info_from_query_param(
2899 2899
 					$query_params['order_by'],
2900 2900
 					$query_object,
2901 2901
 					'order',
2902 2902
 					$query_params['order_by']
2903 2903
 				);
2904
-				$order = isset( $query_params['order'] )
2905
-					? $this->_extract_order( $query_params['order'] )
2904
+				$order = isset($query_params['order'])
2905
+					? $this->_extract_order($query_params['order'])
2906 2906
 					: 'DESC';
2907 2907
 				$query_object->set_order_by_sql(
2908
-					" ORDER BY " . $this->_deduce_column_name_from_query_param( $query_params['order_by'] ) . SP . $order
2908
+					" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order
2909 2909
 				);
2910 2910
 			}
2911 2911
 		}
2912 2912
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2913
-		if ( ! array_key_exists( 'order_by', $query_params )
2914
-		     && array_key_exists( 'order', $query_params )
2915
-		     && ! empty( $query_params['order'] )
2913
+		if ( ! array_key_exists('order_by', $query_params)
2914
+		     && array_key_exists('order', $query_params)
2915
+		     && ! empty($query_params['order'])
2916 2916
 		) {
2917 2917
 			$pk_field = $this->get_primary_key_field();
2918
-			$order = $this->_extract_order( $query_params['order'] );
2919
-			$query_object->set_order_by_sql( " ORDER BY " . $pk_field->get_qualified_column() . SP . $order );
2918
+			$order = $this->_extract_order($query_params['order']);
2919
+			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2920 2920
 		}
2921 2921
 		//set group by
2922
-		if ( array_key_exists( 'group_by', $query_params ) ) {
2923
-			if ( is_array( $query_params['group_by'] ) ) {
2922
+		if (array_key_exists('group_by', $query_params)) {
2923
+			if (is_array($query_params['group_by'])) {
2924 2924
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2925 2925
 				$group_by_array = array();
2926
-				foreach ( $query_params['group_by'] as $field_name_to_group_by ) {
2927
-					$group_by_array[] = $this->_deduce_column_name_from_query_param( $field_name_to_group_by );
2926
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2927
+					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2928 2928
 				}
2929
-				$query_object->set_group_by_sql( " GROUP BY " . implode( ", ", $group_by_array ) );
2930
-			} elseif ( ! empty ( $query_params['group_by'] ) ) {
2929
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2930
+			} elseif ( ! empty ($query_params['group_by'])) {
2931 2931
 				$query_object->set_group_by_sql(
2932
-					" GROUP BY " . $this->_deduce_column_name_from_query_param( $query_params['group_by'] )
2932
+					" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by'])
2933 2933
 				);
2934 2934
 			}
2935 2935
 		}
2936 2936
 		//set having
2937
-		if ( array_key_exists( 'having', $query_params ) && $query_params['having'] ) {
2938
-			$query_object->set_having_sql( $this->_construct_having_clause( $query_params['having'] ) );
2937
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2938
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2939 2939
 		}
2940 2940
 		//now, just verify they didn't pass anything wack
2941
-		foreach ( $query_params as $query_key => $query_value ) {
2942
-			if ( ! in_array( $query_key, $this->_allowed_query_params, true ) ) {
2941
+		foreach ($query_params as $query_key => $query_value) {
2942
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2943 2943
 				throw new EE_Error(
2944 2944
 					sprintf(
2945 2945
 						__(
@@ -2947,16 +2947,16 @@  discard block
 block discarded – undo
2947 2947
 							'event_espresso'
2948 2948
 						),
2949 2949
 						$query_key,
2950
-						get_class( $this ),
2950
+						get_class($this),
2951 2951
 //						print_r( $this->_allowed_query_params, TRUE )
2952
-						implode( ',', $this->_allowed_query_params )
2952
+						implode(',', $this->_allowed_query_params)
2953 2953
 					)
2954 2954
 				);
2955 2955
 			}
2956 2956
 		}
2957 2957
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2958
-		if ( empty( $main_model_join_sql ) ) {
2959
-			$query_object->set_main_model_join_sql( $this->_construct_internal_join() );
2958
+		if (empty($main_model_join_sql)) {
2959
+			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2960 2960
 		}
2961 2961
 		return $query_object;
2962 2962
 	}
@@ -2971,17 +2971,17 @@  discard block
 block discarded – undo
2971 2971
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2972 2972
 	 * @throws \EE_Error
2973 2973
 	 */
2974
-	public function caps_where_conditions( $context = self::caps_read ) {
2975
-		EEM_Base::verify_is_valid_cap_context( $context );
2974
+	public function caps_where_conditions($context = self::caps_read) {
2975
+		EEM_Base::verify_is_valid_cap_context($context);
2976 2976
 		$cap_where_conditions = array();
2977
-		$cap_restrictions = $this->caps_missing( $context );
2977
+		$cap_restrictions = $this->caps_missing($context);
2978 2978
 		/**
2979 2979
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2980 2980
 		 */
2981
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2982
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2981
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2982
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2983 2983
 		}
2984
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2984
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2985 2985
 	}
2986 2986
 
2987 2987
 	/**
@@ -2991,11 +2991,11 @@  discard block
 block discarded – undo
2991 2991
 	 * @return string either ASC, asc, DESC or desc
2992 2992
 	 * @throws EE_Error
2993 2993
 	 */
2994
-	private function _extract_order($should_be_order_string){
2995
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2994
+	private function _extract_order($should_be_order_string) {
2995
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2996 2996
 			return $should_be_order_string;
2997
-		}else{
2998
-			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));
2997
+		} else {
2998
+			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));
2999 2999
 		}
3000 3000
 	}
3001 3001
 
@@ -3013,7 +3013,7 @@  discard block
 block discarded – undo
3013 3013
 	 * @throws EE_Error
3014 3014
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
3015 3015
 	 */
3016
-	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()){
3016
+	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()) {
3017 3017
 		$allowed_used_default_where_conditions_values = array(
3018 3018
 				'all',
3019 3019
 				'this_model_only',
@@ -3021,17 +3021,17 @@  discard block
 block discarded – undo
3021 3021
 				'minimum',
3022 3022
 				'none'
3023 3023
 			);
3024
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
3025
-			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)));
3024
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
3025
+			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)));
3026 3026
 		}
3027 3027
 		$universal_query_params = array();
3028
-		if( $use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only' ){
3028
+		if ($use_default_where_conditions === 'all' || $use_default_where_conditions === 'this_model_only') {
3029 3029
 			$universal_query_params = $this->_get_default_where_conditions();
3030
-		} else if( $use_default_where_conditions === 'minimum' ) {
3030
+		} else if ($use_default_where_conditions === 'minimum') {
3031 3031
 			$universal_query_params = $this->_get_minimum_where_conditions();
3032 3032
 		}
3033
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
3034
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
3033
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
3034
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
3035 3035
 				$related_model = $this->get_related_model_obj($model_name);
3036 3036
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
3037 3037
 				$overrides = $this->_override_defaults_or_make_null_friendly(
@@ -3064,20 +3064,20 @@  discard block
 block discarded – undo
3064 3064
 	 * @return array like EEM_Base::get_all's $query_params[0]
3065 3065
 	 * @throws \EE_Error
3066 3066
 	 */
3067
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
3067
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
3068 3068
 		$null_friendly_where_conditions = array();
3069 3069
 		$none_overridden = true;
3070 3070
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
3071 3071
 
3072
-		foreach($default_where_conditions as $key => $val){
3073
-			if( isset($provided_where_conditions[$key])){
3072
+		foreach ($default_where_conditions as $key => $val) {
3073
+			if (isset($provided_where_conditions[$key])) {
3074 3074
 				$none_overridden = false;
3075
-			}else{
3075
+			} else {
3076 3076
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
3077 3077
 			}
3078 3078
 		}
3079
-		if( $none_overridden && $default_where_conditions){
3080
-			if($model->has_primary_key_field()){
3079
+		if ($none_overridden && $default_where_conditions) {
3080
+			if ($model->has_primary_key_field()) {
3081 3081
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
3082 3082
 			}/*else{
3083 3083
 				//@todo NO PK, use other defaults
@@ -3094,8 +3094,8 @@  discard block
 block discarded – undo
3094 3094
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3095 3095
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3096 3096
 	 */
3097
-	private function _get_default_where_conditions($model_relation_path = null){
3098
-		if ( $this->_ignore_where_strategy ){
3097
+	private function _get_default_where_conditions($model_relation_path = null) {
3098
+		if ($this->_ignore_where_strategy) {
3099 3099
 			return array();
3100 3100
 		}
3101 3101
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3109,8 +3109,8 @@  discard block
 block discarded – undo
3109 3109
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
3110 3110
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
3111 3111
 	 */
3112
-	protected function _get_minimum_where_conditions($model_relation_path = null){
3113
-		if ( $this->_ignore_where_strategy ){
3112
+	protected function _get_minimum_where_conditions($model_relation_path = null) {
3113
+		if ($this->_ignore_where_strategy) {
3114 3114
 			return array();
3115 3115
 		}
3116 3116
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -3126,16 +3126,16 @@  discard block
 block discarded – undo
3126 3126
 	 * @return string
3127 3127
 	 * @throws \EE_Error
3128 3128
 	 */
3129
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
3129
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
3130 3130
 		$selects = $this->_get_columns_to_select_for_this_model();
3131
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
3131
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
3132 3132
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
3133
-			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model( $model_relation_chain );
3134
-			foreach ( $other_model_selects as $key => $value ) {
3133
+			$other_model_selects = $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain);
3134
+			foreach ($other_model_selects as $key => $value) {
3135 3135
 				$selects[] = $value;
3136 3136
 			}
3137 3137
 		}
3138
-		return implode(", ",$selects);
3138
+		return implode(", ", $selects);
3139 3139
 	}
3140 3140
 
3141 3141
 	/**
@@ -3144,19 +3144,19 @@  discard block
 block discarded – undo
3144 3144
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
3145 3145
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
3146 3146
 	 */
3147
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
3147
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
3148 3148
 		$fields = $this->field_settings();
3149 3149
 		$selects = array();
3150 3150
 		$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());
3151
-		foreach($fields as $field_obj){
3152
-			$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()."'";
3151
+		foreach ($fields as $field_obj) {
3152
+			$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()."'";
3153 3153
 		}
3154 3154
 		//make sure we are also getting the PKs of each table
3155 3155
 		$tables = $this->get_tables();
3156
-		if(count($tables) > 1){
3157
-			foreach($tables as $table_obj){
3158
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
3159
-				if( ! in_array($qualified_pk_column,$selects)){
3156
+		if (count($tables) > 1) {
3157
+			foreach ($tables as $table_obj) {
3158
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
3159
+				if ( ! in_array($qualified_pk_column, $selects)) {
3160 3160
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
3161 3161
 				}
3162 3162
 			}
@@ -3186,65 +3186,65 @@  discard block
 block discarded – undo
3186 3186
 		$query_param_type,
3187 3187
 		$original_query_param = null
3188 3188
 	) {
3189
-		if( $original_query_param === null ){
3189
+		if ($original_query_param === null) {
3190 3190
 			$original_query_param = $query_param;
3191 3191
 		}
3192 3192
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
3193 3193
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
3194
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
3195
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
3194
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
3195
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
3196 3196
 		//check to see if we have a field on this model
3197 3197
 		$this_model_fields = $this->field_settings(true);
3198
-		if(array_key_exists($query_param,$this_model_fields)){
3199
-			if($allow_fields){
3198
+		if (array_key_exists($query_param, $this_model_fields)) {
3199
+			if ($allow_fields) {
3200 3200
 				return;
3201
-			}else{
3201
+			} else {
3202 3202
 				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"),
3203
-						$query_param,get_class($this),$query_param_type,$original_query_param));
3203
+						$query_param, get_class($this), $query_param_type, $original_query_param));
3204 3204
 			}
3205 3205
 		}
3206 3206
 		//check if this is a special logic query param
3207
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3208
-			if($allow_logic_query_params){
3207
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
3208
+			if ($allow_logic_query_params) {
3209 3209
 				return;
3210
-			}else{
3210
+			} else {
3211 3211
 				throw new EE_Error(
3212 3212
 					sprintf(
3213
-						__( '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' ),
3214
-						implode( '", "', $this->_logic_query_param_keys ),
3215
-						$query_param ,
3216
-						get_class( $this ),
3213
+						__('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'),
3214
+						implode('", "', $this->_logic_query_param_keys),
3215
+						$query_param,
3216
+						get_class($this),
3217 3217
 						'<br />',
3218
-						"\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
3218
+						"\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
3219 3219
 					)
3220 3220
 				);
3221 3221
 			}
3222 3222
 		}
3223 3223
 
3224 3224
 		//check if it's a custom selection
3225
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
3225
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
3226 3226
 			return;
3227 3227
 		}
3228 3228
 
3229 3229
 		//check if has a model name at the beginning
3230 3230
 		//and
3231 3231
 		//check if it's a field on a related model
3232
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
3233
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
3234
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3232
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
3233
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
3234
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3235 3235
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
3236
-				if($query_param === ''){
3236
+				if ($query_param === '') {
3237 3237
 					//nothing left to $query_param
3238 3238
 					//we should actually end in a field name, not a model like this!
3239 3239
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3240
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3241
-				}else{
3240
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
3241
+				} else {
3242 3242
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3243 3243
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3244 3244
 					return;
3245 3245
 				}
3246
-			}elseif($query_param === $valid_related_model_name){
3247
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3246
+			}elseif ($query_param === $valid_related_model_name) {
3247
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3248 3248
 				return;
3249 3249
 			}
3250 3250
 		}
@@ -3254,7 +3254,7 @@  discard block
 block discarded – undo
3254 3254
 		//and we previously confirmed it wasn't a logic query param or field on the current model
3255 3255
 		//it's wack, that's what it is
3256 3256
 		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"),
3257
-				$query_param,get_class($this),$query_param_type,$original_query_param));
3257
+				$query_param, get_class($this), $query_param_type, $original_query_param));
3258 3258
 
3259 3259
 	}
3260 3260
 
@@ -3273,26 +3273,26 @@  discard block
 block discarded – undo
3273 3273
 	 * @return void
3274 3274
 	 * @throws \EE_Error
3275 3275
 	 */
3276
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
3276
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
3277 3277
 		$relation_obj = $this->related_settings_for($model_name);
3278 3278
 
3279 3279
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
3280 3280
 		//check if the relation is HABTM, because then we're essentially doing two joins
3281 3281
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
3282
-		if($relation_obj instanceof EE_HABTM_Relation){
3282
+		if ($relation_obj instanceof EE_HABTM_Relation) {
3283 3283
 			$join_model_obj = $relation_obj->get_join_model();
3284 3284
 			//replace the model specified with the join model for this relation chain, whi
3285 3285
 			$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);
3286 3286
 			$new_query_info = new EE_Model_Query_Info_Carrier(
3287 3287
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
3288 3288
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
3289
-			$passed_in_query_info->merge( $new_query_info  );
3289
+			$passed_in_query_info->merge($new_query_info);
3290 3290
 		}
3291 3291
 		//now just join to the other table pointed to by the relation object, and add its data types
3292 3292
 		$new_query_info = new EE_Model_Query_Info_Carrier(
3293 3293
 				array($model_relation_chain=>$model_name),
3294 3294
 				$relation_obj->get_join_statement($model_relation_chain));
3295
-		$passed_in_query_info->merge( $new_query_info  );
3295
+		$passed_in_query_info->merge($new_query_info);
3296 3296
 	}
3297 3297
 
3298 3298
 
@@ -3304,11 +3304,11 @@  discard block
 block discarded – undo
3304 3304
 	 * @return string of SQL
3305 3305
 	 * @throws \EE_Error
3306 3306
 	 */
3307
-	private function _construct_where_clause($where_params){
3307
+	private function _construct_where_clause($where_params) {
3308 3308
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3309
-		if($SQL){
3310
-			return " WHERE ". $SQL;
3311
-		}else{
3309
+		if ($SQL) {
3310
+			return " WHERE ".$SQL;
3311
+		} else {
3312 3312
 			return '';
3313 3313
 		}
3314 3314
 	}
@@ -3323,11 +3323,11 @@  discard block
 block discarded – undo
3323 3323
 	 * @return string
3324 3324
 	 * @throws \EE_Error
3325 3325
 	 */
3326
-	private function _construct_having_clause($having_params){
3326
+	private function _construct_having_clause($having_params) {
3327 3327
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3328
-		if($SQL){
3329
-			return " HAVING ". $SQL;
3330
-		}else{
3328
+		if ($SQL) {
3329
+			return " HAVING ".$SQL;
3330
+		} else {
3331 3331
 			return '';
3332 3332
 		}
3333 3333
 
@@ -3341,16 +3341,16 @@  discard block
 block discarded – undo
3341 3341
 	 * @return EE_Model_Field_Base
3342 3342
 	 * @throws EE_Error
3343 3343
 	 */
3344
-	protected function _get_field_on_model($field_name,$model_name){
3344
+	protected function _get_field_on_model($field_name, $model_name) {
3345 3345
 		$model_class = 'EEM_'.$model_name;
3346 3346
 		$model_filepath = $model_class.".model.php";
3347
-		if ( is_readable($model_filepath)){
3347
+		if (is_readable($model_filepath)) {
3348 3348
 			require_once($model_filepath);
3349
-			$model_instance=call_user_func($model_name."::instance");
3349
+			$model_instance = call_user_func($model_name."::instance");
3350 3350
 			/* @var $model_instance EEM_Base */
3351 3351
 			return $model_instance->field_settings_for($field_name);
3352
-		}else{
3353
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3352
+		} else {
3353
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3354 3354
 		}
3355 3355
 	}
3356 3356
 
@@ -3363,41 +3363,41 @@  discard block
 block discarded – undo
3363 3363
 	 * @throws EE_Error
3364 3364
 	 * @return string of SQL
3365 3365
 	 */
3366
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3367
-		$where_clauses=array();
3368
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3369
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3370
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3371
-				switch($query_param){
3366
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3367
+		$where_clauses = array();
3368
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3369
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3370
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3371
+				switch ($query_param) {
3372 3372
 					case 'not':
3373 3373
 					case 'NOT':
3374
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3374
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3375 3375
 						break;
3376 3376
 					case 'and':
3377 3377
 					case 'AND':
3378
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3378
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3379 3379
 						break;
3380 3380
 					case 'or':
3381 3381
 					case 'OR':
3382
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3382
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3383 3383
 						break;
3384 3384
 				}
3385
-			}else{
3385
+			} else {
3386 3386
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3387 3387
 
3388 3388
 				//if it's not a normal field, maybe it's a custom selection?
3389
-				if( ! $field_obj){
3390
-					if(isset( $this->_custom_selections[$query_param][1])){
3389
+				if ( ! $field_obj) {
3390
+					if (isset($this->_custom_selections[$query_param][1])) {
3391 3391
 						$field_obj = $this->_custom_selections[$query_param][1];
3392
-					}else{
3393
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3392
+					} else {
3393
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3394 3394
 					}
3395 3395
 				}
3396 3396
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3397
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3397
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3398 3398
 			}
3399 3399
 		}
3400
-		return $where_clauses ? implode( $glue, $where_clauses ) : '';
3400
+		return $where_clauses ? implode($glue, $where_clauses) : '';
3401 3401
 	}
3402 3402
 
3403 3403
 
@@ -3408,18 +3408,18 @@  discard block
 block discarded – undo
3408 3408
 	 * @throws EE_Error
3409 3409
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3410 3410
 	 */
3411
-	private function _deduce_column_name_from_query_param($query_param){
3411
+	private function _deduce_column_name_from_query_param($query_param) {
3412 3412
 		$field = $this->_deduce_field_from_query_param($query_param);
3413 3413
 
3414
-		if( $field ){
3415
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3416
-			return $table_alias_prefix . $field->get_qualified_column();
3417
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3414
+		if ($field) {
3415
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3416
+			return $table_alias_prefix.$field->get_qualified_column();
3417
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3418 3418
 			//maybe it's custom selection item?
3419 3419
 			//if so, just use it as the "column name"
3420 3420
 			return $query_param;
3421
-		}else{
3422
-			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)));
3421
+		} else {
3422
+			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)));
3423 3423
 		}
3424 3424
 	}
3425 3425
 
@@ -3431,11 +3431,11 @@  discard block
 block discarded – undo
3431 3431
 	 * @param string $condition_query_param_key
3432 3432
 	 * @return string
3433 3433
 	 */
3434
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3434
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3435 3435
 		$pos_of_star = strpos($condition_query_param_key, '*');
3436
-		if($pos_of_star === FALSE){
3436
+		if ($pos_of_star === FALSE) {
3437 3437
 			return $condition_query_param_key;
3438
-		}else{
3438
+		} else {
3439 3439
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3440 3440
 			return $condition_query_param_sans_star;
3441 3441
 		}
@@ -3450,12 +3450,12 @@  discard block
 block discarded – undo
3450 3450
 	 * @throws EE_Error
3451 3451
 	 * @return string
3452 3452
 	 */
3453
-	private function _construct_op_and_value($op_and_value, $field_obj){
3454
-		if ( is_array( $op_and_value ) ) {
3455
-			$operator = isset( $op_and_value[0] ) ? $this->_prepare_operator_for_sql( $op_and_value[0] ) : null;
3456
-			if ( ! $operator ) {
3453
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3454
+		if (is_array($op_and_value)) {
3455
+			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3456
+			if ( ! $operator) {
3457 3457
 				$php_array_like_string = array();
3458
-				foreach ( $op_and_value as $key => $value ) {
3458
+				foreach ($op_and_value as $key => $value) {
3459 3459
 					$php_array_like_string[] = "$key=>$value";
3460 3460
 				}
3461 3461
 				throw new EE_Error(
@@ -3464,27 +3464,27 @@  discard block
 block discarded – undo
3464 3464
 							"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))",
3465 3465
 							"event_espresso"
3466 3466
 						),
3467
-						implode( ",", $php_array_like_string )
3467
+						implode(",", $php_array_like_string)
3468 3468
 					)
3469 3469
 				);
3470 3470
 			}
3471
-			$value = isset( $op_and_value[1] ) ? $op_and_value[1] : null;
3471
+			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3472 3472
 		} else {
3473 3473
 			$operator = '=';
3474 3474
 			$value = $op_and_value;
3475 3475
 		}
3476 3476
 		//check to see if the value is actually another field
3477
-		if ( is_array( $op_and_value ) && isset( $op_and_value[2] ) && $op_and_value[2] == true ) {
3478
-			return $operator . SP . $this->_deduce_column_name_from_query_param( $value );
3479
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3477
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3478
+			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3479
+		} elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3480 3480
 			//in this case, the value should be an array, or at least a comma-separated list
3481 3481
 			//it will need to handle a little differently
3482
-			$cleaned_value = $this->_construct_in_value( $value, $field_obj );
3482
+			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3483 3483
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3484
-			return $operator . SP . $cleaned_value;
3485
-		} elseif ( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3484
+			return $operator.SP.$cleaned_value;
3485
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3486 3486
 			//the value should be an array with count of two.
3487
-			if ( count( $value ) !== 2 ) {
3487
+			if (count($value) !== 2) {
3488 3488
 				throw new EE_Error(
3489 3489
 					sprintf(
3490 3490
 						__(
@@ -3495,10 +3495,10 @@  discard block
 block discarded – undo
3495 3495
 					)
3496 3496
 				);
3497 3497
 			}
3498
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3499
-			return $operator . SP . $cleaned_value;
3500
-		} elseif ( in_array( $operator, $this->_null_style_operators ) ) {
3501
-			if ( $value !== null ) {
3498
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3499
+			return $operator.SP.$cleaned_value;
3500
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3501
+			if ($value !== null) {
3502 3502
 				throw new EE_Error(
3503 3503
 					sprintf(
3504 3504
 						__(
@@ -3511,13 +3511,13 @@  discard block
 block discarded – undo
3511 3511
 				);
3512 3512
 			}
3513 3513
 			return $operator;
3514
-		} elseif ( $operator === 'LIKE' && ! is_array( $value ) ) {
3514
+		} elseif ($operator === 'LIKE' && ! is_array($value)) {
3515 3515
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3516 3516
 			//remove other junk. So just treat it as a string.
3517
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, '%s' );
3518
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3519
-			return $operator . SP . $this->_wpdb_prepare_using_field( $value, $field_obj );
3520
-		} elseif ( in_array( $operator, $this->_in_style_operators ) && ! is_array( $value ) ) {
3517
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3518
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3519
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3520
+		} elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3521 3521
 			throw new EE_Error(
3522 3522
 				sprintf(
3523 3523
 					__(
@@ -3528,7 +3528,7 @@  discard block
 block discarded – undo
3528 3528
 					$operator
3529 3529
 				)
3530 3530
 			);
3531
-		} elseif ( ! in_array( $operator, $this->_in_style_operators ) && is_array( $value ) ) {
3531
+		} elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3532 3532
 			throw new EE_Error(
3533 3533
 				sprintf(
3534 3534
 					__(
@@ -3546,7 +3546,7 @@  discard block
 block discarded – undo
3546 3546
 						"It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all",
3547 3547
 						"event_espresso"
3548 3548
 					),
3549
-					http_build_query( $op_and_value )
3549
+					http_build_query($op_and_value)
3550 3550
 				)
3551 3551
 			);
3552 3552
 		}
@@ -3562,12 +3562,12 @@  discard block
 block discarded – undo
3562 3562
 	 * @return string
3563 3563
 	 * @throws \EE_Error
3564 3564
 	 */
3565
-	public function _construct_between_value( $values, $field_obj ) {
3565
+	public function _construct_between_value($values, $field_obj) {
3566 3566
 		$cleaned_values = array();
3567
-		foreach ( $values as $value ) {
3568
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3567
+		foreach ($values as $value) {
3568
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3569 3569
 		}
3570
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3570
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3571 3571
 	}
3572 3572
 
3573 3573
 
@@ -3584,26 +3584,26 @@  discard block
 block discarded – undo
3584 3584
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3585 3585
 	 * @throws \EE_Error
3586 3586
 	 */
3587
-	public function _construct_in_value($values,  $field_obj){
3587
+	public function _construct_in_value($values, $field_obj) {
3588 3588
 		//check if the value is a CSV list
3589
-		if(is_string($values)){
3589
+		if (is_string($values)) {
3590 3590
 			//in which case, turn it into an array
3591
-			$values = explode(",",$values);
3591
+			$values = explode(",", $values);
3592 3592
 		}
3593 3593
 		$cleaned_values = array();
3594
-		foreach($values as $value){
3595
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3594
+		foreach ($values as $value) {
3595
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3596 3596
 		}
3597 3597
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3598 3598
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3599 3599
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3600
-		if(empty($cleaned_values)){
3600
+		if (empty($cleaned_values)) {
3601 3601
 			$all_fields = $this->field_settings();
3602 3602
 			$a_field = array_shift($all_fields);
3603 3603
 			$main_table = $this->_get_main_table();
3604 3604
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3605 3605
 		}
3606
-		return "(".implode(",",$cleaned_values).")";
3606
+		return "(".implode(",", $cleaned_values).")";
3607 3607
 	}
3608 3608
 
3609 3609
 
@@ -3615,16 +3615,16 @@  discard block
 block discarded – undo
3615 3615
 	 * @throws EE_Error
3616 3616
 	 * @return false|null|string
3617 3617
 	 */
3618
-	private function _wpdb_prepare_using_field($value,$field_obj){
3618
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3619 3619
 		/** @type WPDB $wpdb */
3620 3620
 		global $wpdb;
3621
-		if($field_obj instanceof EE_Model_Field_Base){
3622
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3623
-		}else{//$field_obj should really just be a data type
3624
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3625
-				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)));
3621
+		if ($field_obj instanceof EE_Model_Field_Base) {
3622
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3623
+		} else {//$field_obj should really just be a data type
3624
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3625
+				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)));
3626 3626
 			}
3627
-			return $wpdb->prepare($field_obj,$value);
3627
+			return $wpdb->prepare($field_obj, $value);
3628 3628
 		}
3629 3629
 	}
3630 3630
 
@@ -3636,27 +3636,27 @@  discard block
 block discarded – undo
3636 3636
 	 * @throws EE_Error
3637 3637
 	 * @return EE_Model_Field_Base
3638 3638
 	 */
3639
-	protected function _deduce_field_from_query_param($query_param_name){
3639
+	protected function _deduce_field_from_query_param($query_param_name) {
3640 3640
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3641 3641
 		//which will help us find the database table and column
3642 3642
 
3643
-		$query_param_parts = explode(".",$query_param_name);
3644
-		if(empty($query_param_parts)){
3645
-			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));
3643
+		$query_param_parts = explode(".", $query_param_name);
3644
+		if (empty($query_param_parts)) {
3645
+			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));
3646 3646
 		}
3647 3647
 		$number_of_parts = count($query_param_parts);
3648
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3649
-		if($number_of_parts === 1){
3648
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3649
+		if ($number_of_parts === 1) {
3650 3650
 			$field_name = $last_query_param_part;
3651 3651
 			$model_obj = $this;
3652
-		}else{// $number_of_parts >= 2
3652
+		} else {// $number_of_parts >= 2
3653 3653
 			//the last part is the column name, and there are only 2parts. therefore...
3654 3654
 			$field_name = $last_query_param_part;
3655
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3655
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3656 3656
 		}
3657
-		try{
3657
+		try {
3658 3658
 			return $model_obj->field_settings_for($field_name);
3659
-		}catch(EE_Error $e){
3659
+		} catch (EE_Error $e) {
3660 3660
 			return null;
3661 3661
 		}
3662 3662
 	}
@@ -3670,13 +3670,13 @@  discard block
 block discarded – undo
3670 3670
 	 * @throws EE_Error
3671 3671
 	 * @return string
3672 3672
 	 */
3673
-	public function _get_qualified_column_for_field($field_name){
3673
+	public function _get_qualified_column_for_field($field_name) {
3674 3674
 		$all_fields = $this->field_settings();
3675 3675
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3676
-		if($field){
3676
+		if ($field) {
3677 3677
 			return $field->get_qualified_column();
3678
-		}else{
3679
-			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)));
3678
+		} else {
3679
+			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)));
3680 3680
 		}
3681 3681
 	}
3682 3682
 
@@ -3690,17 +3690,17 @@  discard block
 block discarded – undo
3690 3690
 	 * @param  mixed|string $limit The limit for this select
3691 3691
 	 * @return string                The final select join element for the query.
3692 3692
 	 */
3693
-	public function _construct_limit_join_select( $table_alias, $limit ) {
3693
+	public function _construct_limit_join_select($table_alias, $limit) {
3694 3694
 		$SQL = '';
3695
-		foreach ( $this->_tables as $table_obj ) {
3696
-			if ( $table_obj instanceof EE_Primary_Table ) {
3695
+		foreach ($this->_tables as $table_obj) {
3696
+			if ($table_obj instanceof EE_Primary_Table) {
3697 3697
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3698
-					? $table_obj->get_select_join_limit( $limit )
3699
-					: SP . $table_obj->get_table_name() . " AS " . $table_obj->get_table_alias() . SP;
3700
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3698
+					? $table_obj->get_select_join_limit($limit)
3699
+					: SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3700
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3701 3701
 				$SQL .= $table_alias === $table_obj->get_table_alias()
3702
-					? $table_obj->get_select_join_limit_join( $limit )
3703
-					: SP . $table_obj->get_join_sql( $table_alias ) . SP;
3702
+					? $table_obj->get_select_join_limit_join($limit)
3703
+					: SP.$table_obj->get_join_sql($table_alias).SP;
3704 3704
 			}
3705 3705
 		}
3706 3706
 		return $SQL;
@@ -3715,7 +3715,7 @@  discard block
 block discarded – undo
3715 3715
 	 * @return string SQL
3716 3716
 	 * @throws \EE_Error
3717 3717
 	 */
3718
-	public function _construct_internal_join(){
3718
+	public function _construct_internal_join() {
3719 3719
 		$SQL = $this->_get_main_table()->get_table_sql();
3720 3720
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3721 3721
 		return $SQL;
@@ -3736,17 +3736,17 @@  discard block
 block discarded – undo
3736 3736
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3737 3737
 	 * @return string
3738 3738
 	 */
3739
-	public function _construct_internal_join_to_table_with_alias($alias_prefixed){
3739
+	public function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3740 3740
 		$SQL = '';
3741 3741
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3742
-		foreach($this->_tables as $table_obj){
3743
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3744
-				if($alias_sans_prefix === $table_obj->get_table_alias()){
3742
+		foreach ($this->_tables as $table_obj) {
3743
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3744
+				if ($alias_sans_prefix === $table_obj->get_table_alias()) {
3745 3745
 					//so we're joining to this table, meaning the table is already in
3746 3746
 					//the FROM statement, BUT the primary table isn't. So we want
3747 3747
 					//to add the inverse join sql
3748 3748
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3749
-				}else{
3749
+				} else {
3750 3750
 					//just add a regular JOIN to this table from the primary table
3751 3751
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3752 3752
 				}
@@ -3760,9 +3760,9 @@  discard block
 block discarded – undo
3760 3760
 	 * 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)
3761 3761
 	 * @return array
3762 3762
 	 */
3763
-	public function _get_data_types(){
3763
+	public function _get_data_types() {
3764 3764
 		$data_types = array();
3765
-		foreach( $this->field_settings() as $field_obj){
3765
+		foreach ($this->field_settings() as $field_obj) {
3766 3766
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3767 3767
 			/** @var $field_obj EE_Model_Field_Base */
3768 3768
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3778,10 +3778,10 @@  discard block
 block discarded – undo
3778 3778
 	 * @throws EE_Error
3779 3779
 	 * @return EEM_Base
3780 3780
 	 */
3781
-	public function get_related_model_obj($model_name){
3781
+	public function get_related_model_obj($model_name) {
3782 3782
 		$model_classname = "EEM_".$model_name;
3783
-		if(!class_exists($model_classname)){
3784
-			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));
3783
+		if ( ! class_exists($model_classname)) {
3784
+			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));
3785 3785
 		}
3786 3786
 		return call_user_func($model_classname."::instance");
3787 3787
 	}
@@ -3791,7 +3791,7 @@  discard block
 block discarded – undo
3791 3791
 	 * Returns the array of EE_ModelRelations for this model.
3792 3792
 	 * @return EE_Model_Relation_Base[]
3793 3793
 	 */
3794
-	public function relation_settings(){
3794
+	public function relation_settings() {
3795 3795
 		return $this->_model_relations;
3796 3796
 	}
3797 3797
 
@@ -3801,10 +3801,10 @@  discard block
 block discarded – undo
3801 3801
 	 * (Eg, without an event, datetimes have little purpose.)
3802 3802
 	 * @return EE_Belongs_To_Relation[]
3803 3803
 	 */
3804
-	public function belongs_to_relations(){
3804
+	public function belongs_to_relations() {
3805 3805
 		$belongs_to_relations = array();
3806
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3807
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3806
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3807
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3808 3808
 				$belongs_to_relations[$model_name] = $relation_obj;
3809 3809
 			}
3810 3810
 		}
@@ -3819,15 +3819,15 @@  discard block
 block discarded – undo
3819 3819
 	 * @throws EE_Error
3820 3820
 	 * @return EE_Model_Relation_Base
3821 3821
 	 */
3822
-	public function related_settings_for($relation_name){
3823
-		$relatedModels=$this->relation_settings();
3824
-		if(!array_key_exists($relation_name,$relatedModels)){
3822
+	public function related_settings_for($relation_name) {
3823
+		$relatedModels = $this->relation_settings();
3824
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3825 3825
 			throw new EE_Error(
3826 3826
 				sprintf(
3827
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3827
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3828 3828
 					$relation_name,
3829 3829
 					$this->_get_class_name(),
3830
-					implode( ', ', array_keys( $relatedModels ))
3830
+					implode(', ', array_keys($relatedModels))
3831 3831
 				)
3832 3832
 			);
3833 3833
 		}
@@ -3842,10 +3842,10 @@  discard block
 block discarded – undo
3842 3842
 	 * @throws EE_Error
3843 3843
 	 * @return EE_Model_Field_Base
3844 3844
 	 */
3845
-	public function field_settings_for($fieldName){
3846
-		$fieldSettings=$this->field_settings(true);
3847
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3848
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3845
+	public function field_settings_for($fieldName) {
3846
+		$fieldSettings = $this->field_settings(true);
3847
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3848
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3849 3849
 		}
3850 3850
 		return $fieldSettings[$fieldName];
3851 3851
 	}
@@ -3855,11 +3855,11 @@  discard block
 block discarded – undo
3855 3855
 	 * @param string $fieldName a key in the model's _field_settings array
3856 3856
 	 * @return boolean
3857 3857
 	 */
3858
-	public function has_field($fieldName){
3858
+	public function has_field($fieldName) {
3859 3859
 		$fieldSettings = $this->field_settings(true);
3860
-		if( isset($fieldSettings[$fieldName])){
3860
+		if (isset($fieldSettings[$fieldName])) {
3861 3861
 			return true;
3862
-		}else{
3862
+		} else {
3863 3863
 			return false;
3864 3864
 		}
3865 3865
 	}
@@ -3869,11 +3869,11 @@  discard block
 block discarded – undo
3869 3869
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3870 3870
 	 * @return boolean
3871 3871
 	 */
3872
-	public function has_relation($relation_name){
3872
+	public function has_relation($relation_name) {
3873 3873
 		$relations = $this->relation_settings();
3874
-		if(isset($relations[$relation_name])){
3874
+		if (isset($relations[$relation_name])) {
3875 3875
 			return true;
3876
-		}else{
3876
+		} else {
3877 3877
 			return false;
3878 3878
 		}
3879 3879
 	}
@@ -3885,7 +3885,7 @@  discard block
 block discarded – undo
3885 3885
 	 * @param $field_obj
3886 3886
 	 * @return EE_Model_Field_Base
3887 3887
 	 */
3888
-	public function is_primary_key_field( $field_obj ){
3888
+	public function is_primary_key_field($field_obj) {
3889 3889
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3890 3890
 	}
3891 3891
 
@@ -3897,16 +3897,16 @@  discard block
 block discarded – undo
3897 3897
 	 * @return EE_Model_Field_Base
3898 3898
 	 * @throws EE_Error
3899 3899
 	 */
3900
-	public function get_primary_key_field(){
3901
-		if( $this->_primary_key_field === NULL ){
3902
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3903
-				if( $this->is_primary_key_field( $field_obj )){
3900
+	public function get_primary_key_field() {
3901
+		if ($this->_primary_key_field === NULL) {
3902
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3903
+				if ($this->is_primary_key_field($field_obj)) {
3904 3904
 					$this->_primary_key_field = $field_obj;
3905 3905
 					break;
3906 3906
 				}
3907 3907
 			}
3908
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3909
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3908
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3909
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3910 3910
 			}
3911 3911
 		}
3912 3912
 		return $this->_primary_key_field;
@@ -3919,12 +3919,12 @@  discard block
 block discarded – undo
3919 3919
 	 * Internally does some caching.
3920 3920
 	 * @return boolean
3921 3921
 	 */
3922
-	public function has_primary_key_field(){
3923
-		if($this->_has_primary_key_field === null){
3924
-			try{
3922
+	public function has_primary_key_field() {
3923
+		if ($this->_has_primary_key_field === null) {
3924
+			try {
3925 3925
 				$this->get_primary_key_field();
3926 3926
 				$this->_has_primary_key_field = true;
3927
-			}catch(EE_Error $e){
3927
+			} catch (EE_Error $e) {
3928 3928
 				$this->_has_primary_key_field = false;
3929 3929
 			}
3930 3930
 		}
@@ -3938,9 +3938,9 @@  discard block
 block discarded – undo
3938 3938
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3939 3939
 	 * @return EE_Model_Field_Base or null if none is found
3940 3940
 	 */
3941
-	public function get_a_field_of_type($field_class_name){
3942
-		foreach($this->field_settings() as $field){
3943
-			if( $field instanceof $field_class_name ){
3941
+	public function get_a_field_of_type($field_class_name) {
3942
+		foreach ($this->field_settings() as $field) {
3943
+			if ($field instanceof $field_class_name) {
3944 3944
 				return $field;
3945 3945
 			}
3946 3946
 		}
@@ -3954,22 +3954,22 @@  discard block
 block discarded – undo
3954 3954
 	 * @return EE_Foreign_Key_Field_Base
3955 3955
 	 * @throws EE_Error
3956 3956
 	 */
3957
-	public function get_foreign_key_to($model_name){
3958
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3959
-			foreach($this->field_settings() as $field){
3960
-				if(
3957
+	public function get_foreign_key_to($model_name) {
3958
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3959
+			foreach ($this->field_settings() as $field) {
3960
+				if (
3961 3961
 					$field instanceof EE_Foreign_Key_Field_Base
3962
-					&& in_array($model_name,$field->get_model_names_pointed_to() )
3962
+					&& in_array($model_name, $field->get_model_names_pointed_to())
3963 3963
 				) {
3964
-					$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3964
+					$this->_cache_foreign_key_to_fields[$model_name] = $field;
3965 3965
 					break;
3966 3966
 				}
3967 3967
 			}
3968
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3969
-				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)));
3968
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3969
+				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)));
3970 3970
 			}
3971 3971
 		}
3972
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3972
+		return $this->_cache_foreign_key_to_fields[$model_name];
3973 3973
 	}
3974 3974
 
3975 3975
 
@@ -3980,7 +3980,7 @@  discard block
 block discarded – undo
3980 3980
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3981 3981
 	 * @return EE_Table_Base
3982 3982
 	 */
3983
-	public function get_table_for_alias($table_alias){
3983
+	public function get_table_for_alias($table_alias) {
3984 3984
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3985 3985
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3986 3986
 	}
@@ -3993,25 +3993,25 @@  discard block
 block discarded – undo
3993 3993
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
3994 3994
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
3995 3995
 	 */
3996
-	public function field_settings($include_db_only_fields = false){
3997
-		if( $include_db_only_fields ){
3998
-			if( $this->_cached_fields === NULL ){
3996
+	public function field_settings($include_db_only_fields = false) {
3997
+		if ($include_db_only_fields) {
3998
+			if ($this->_cached_fields === NULL) {
3999 3999
 				$this->_cached_fields = array();
4000
-				foreach($this->_fields as $fields_corresponding_to_table){
4001
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
4002
-						$this->_cached_fields[$field_name]=$field_obj;
4000
+				foreach ($this->_fields as $fields_corresponding_to_table) {
4001
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
4002
+						$this->_cached_fields[$field_name] = $field_obj;
4003 4003
 					}
4004 4004
 				}
4005 4005
 			}
4006 4006
 			return $this->_cached_fields;
4007
-		}else{
4008
-			if( $this->_cached_fields_non_db_only === NULL ){
4007
+		} else {
4008
+			if ($this->_cached_fields_non_db_only === NULL) {
4009 4009
 				$this->_cached_fields_non_db_only = array();
4010
-				foreach($this->_fields as $fields_corresponding_to_table){
4011
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
4010
+				foreach ($this->_fields as $fields_corresponding_to_table) {
4011
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
4012 4012
 						/** @var $field_obj EE_Model_Field_Base */
4013
-						if( ! $field_obj->is_db_only_field() ){
4014
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
4013
+						if ( ! $field_obj->is_db_only_field()) {
4014
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
4015 4015
 						}
4016 4016
 					}
4017 4017
 				}
@@ -4030,60 +4030,60 @@  discard block
 block discarded – undo
4030 4030
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
4031 4031
 	 * @throws \EE_Error
4032 4032
 	 */
4033
-	protected function _create_objects( $rows = array() ) {
4034
-		$array_of_objects=array();
4035
-		if(empty($rows)){
4033
+	protected function _create_objects($rows = array()) {
4034
+		$array_of_objects = array();
4035
+		if (empty($rows)) {
4036 4036
 			return array();
4037 4037
 		}
4038 4038
 		$count_if_model_has_no_primary_key = 0;
4039 4039
 		$has_primary_key = $this->has_primary_key_field();
4040 4040
 		$primary_key_field = $has_primary_key ? $this->get_primary_key_field() : null;
4041
-		foreach ( (array)$rows as $row ) {
4042
-			if(empty($row)){
4041
+		foreach ((array) $rows as $row) {
4042
+			if (empty($row)) {
4043 4043
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
4044 4044
 				return array();
4045 4045
 			}
4046 4046
 			//check if we've already set this object in the results array,
4047 4047
 			//in which case there's no need to process it further (again)
4048
-			if( $has_primary_key ) {
4048
+			if ($has_primary_key) {
4049 4049
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
4050 4050
 					$row,
4051 4051
 					$primary_key_field->get_qualified_column(),
4052 4052
 					$primary_key_field->get_table_column()
4053 4053
 				);
4054
-				if( $table_pk_value && isset( $array_of_objects[ $table_pk_value ] ) ) {
4054
+				if ($table_pk_value && isset($array_of_objects[$table_pk_value])) {
4055 4055
 					continue;
4056 4056
 				}
4057 4057
 			}
4058 4058
 			$classInstance = $this->instantiate_class_from_array_or_object($row);
4059
-			if( ! $classInstance ) {
4059
+			if ( ! $classInstance) {
4060 4060
 				throw new EE_Error(
4061 4061
 					sprintf(
4062
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
4062
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
4063 4063
 						$this->get_this_model_name(),
4064
-						http_build_query( $row )
4064
+						http_build_query($row)
4065 4065
 					)
4066 4066
 				);
4067 4067
 			}
4068 4068
 			//set the timezone on the instantiated objects
4069
-			$classInstance->set_timezone( $this->_timezone );
4069
+			$classInstance->set_timezone($this->_timezone);
4070 4070
 			//make sure if there is any timezone setting present that we set the timezone for the object
4071 4071
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
4072
-			$array_of_objects[ $key ] = $classInstance;
4072
+			$array_of_objects[$key] = $classInstance;
4073 4073
 			//also, for all the relations of type BelongsTo, see if we can cache
4074 4074
 			//those related models
4075 4075
 			//(we could do this for other relations too, but if there are conditions
4076 4076
 			//that filtered out some fo the results, then we'd be caching an incomplete set
4077 4077
 			//so it requires a little more thought than just caching them immediately...)
4078
-			foreach($this->_model_relations as $modelName => $relation_obj){
4079
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
4078
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
4079
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
4080 4080
 					//check if this model's INFO is present. If so, cache it on the model
4081 4081
 					$other_model = $relation_obj->get_other_model();
4082 4082
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
4083 4083
 					//if we managed to make a model object from the results, cache it on the main model object
4084
-					if( $other_model_obj_maybe ){
4084
+					if ($other_model_obj_maybe) {
4085 4085
 						//set timezone on these other model objects if they are present
4086
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
4086
+						$other_model_obj_maybe->set_timezone($this->_timezone);
4087 4087
 						$classInstance->cache($modelName, $other_model_obj_maybe);
4088 4088
 					}
4089 4089
 				}
@@ -4104,12 +4104,12 @@  discard block
 block discarded – undo
4104 4104
 
4105 4105
 		$this_model_fields_and_values = array();
4106 4106
 		//setup the row using default values;
4107
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
4107
+		foreach ($this->field_settings() as $field_name => $field_obj) {
4108 4108
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
4109 4109
 		}
4110 4110
 
4111 4111
 		$className = $this->_get_class_name();
4112
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
4112
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
4113 4113
 
4114 4114
 		return $classInstance;
4115 4115
 	}
@@ -4122,45 +4122,45 @@  discard block
 block discarded – undo
4122 4122
 	 * @return EE_Base_Class
4123 4123
 	 * @throws \EE_Error
4124 4124
 	 */
4125
-	public function instantiate_class_from_array_or_object($cols_n_values){
4126
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
4127
-			$cols_n_values = get_object_vars( $cols_n_values );
4125
+	public function instantiate_class_from_array_or_object($cols_n_values) {
4126
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
4127
+			$cols_n_values = get_object_vars($cols_n_values);
4128 4128
 		}
4129 4129
 		$primary_key = NULL;
4130 4130
 		//make sure the array only has keys that are fields/columns on this model
4131
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4132
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
4133
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
4131
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4132
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
4133
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
4134 4134
 		}
4135
-		$className=$this->_get_class_name();
4135
+		$className = $this->_get_class_name();
4136 4136
 
4137 4137
 		//check we actually found results that we can use to build our model object
4138 4138
 		//if not, return null
4139
-		if( $this->has_primary_key_field()){
4140
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
4139
+		if ($this->has_primary_key_field()) {
4140
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
4141 4141
 				return NULL;
4142 4142
 			}
4143
-		}else if($this->unique_indexes()){
4143
+		} else if ($this->unique_indexes()) {
4144 4144
 			$first_column = reset($this_model_fields_n_values);
4145
-			if(empty($first_column)){
4145
+			if (empty($first_column)) {
4146 4146
 				return NULL;
4147 4147
 			}
4148 4148
 		}
4149 4149
 
4150 4150
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
4151
-		if ( $primary_key){
4152
-			$classInstance = $this->get_from_entity_map( $primary_key );
4153
-			if( ! $classInstance) {
4154
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4151
+		if ($primary_key) {
4152
+			$classInstance = $this->get_from_entity_map($primary_key);
4153
+			if ( ! $classInstance) {
4154
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4155 4155
 				// add this new object to the entity map
4156
-				$classInstance = $this->add_to_entity_map( $classInstance );
4156
+				$classInstance = $this->add_to_entity_map($classInstance);
4157 4157
 			}
4158
-		}else{
4159
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
4158
+		} else {
4159
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
4160 4160
 		}
4161 4161
 
4162 4162
 			//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.
4163
-		$this->set_timezone( $classInstance->get_timezone() );
4163
+		$this->set_timezone($classInstance->get_timezone());
4164 4164
 		return $classInstance;
4165 4165
 	}
4166 4166
 	/**
@@ -4168,8 +4168,8 @@  discard block
 block discarded – undo
4168 4168
 	 * @param int|string $id the ID of the model object
4169 4169
 	 * @return EE_Base_Class
4170 4170
 	 */
4171
-	public function get_from_entity_map( $id ){
4172
-		return isset( $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] ) ? $this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $id ] : NULL;
4171
+	public function get_from_entity_map($id) {
4172
+		return isset($this->_entity_map[EEM_Base::$_model_query_blog_id][$id]) ? $this->_entity_map[EEM_Base::$_model_query_blog_id][$id] : NULL;
4173 4173
 	}
4174 4174
 
4175 4175
 
@@ -4191,21 +4191,21 @@  discard block
 block discarded – undo
4191 4191
 	 * @throws EE_Error
4192 4192
 	 * @return \EE_Base_Class
4193 4193
 	 */
4194
-	public function add_to_entity_map( EE_Base_Class $object) {
4194
+	public function add_to_entity_map(EE_Base_Class $object) {
4195 4195
 		$className = $this->_get_class_name();
4196
-		if( ! $object instanceof $className ){
4197
-			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 ) );
4196
+		if ( ! $object instanceof $className) {
4197
+			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));
4198 4198
 		}
4199 4199
 		/** @var $object EE_Base_Class */
4200
-		if ( ! $object->ID() ){
4201
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
4200
+		if ( ! $object->ID()) {
4201
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
4202 4202
 		}
4203 4203
 		// double check it's not already there
4204
-		$classInstance = $this->get_from_entity_map( $object->ID() );
4205
-		if ( $classInstance ) {
4204
+		$classInstance = $this->get_from_entity_map($object->ID());
4205
+		if ($classInstance) {
4206 4206
 			return $classInstance;
4207 4207
 		} else {
4208
-			$this->_entity_map[ EEM_Base::$_model_query_blog_id ][ $object->ID() ] = $object;
4208
+			$this->_entity_map[EEM_Base::$_model_query_blog_id][$object->ID()] = $object;
4209 4209
 			return $object;
4210 4210
 		}
4211 4211
 	}
@@ -4218,8 +4218,8 @@  discard block
 block discarded – undo
4218 4218
 	 * @param array $cols_n_values
4219 4219
 	 * @return array
4220 4220
 	 */
4221
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
4222
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
4221
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4222
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
4223 4223
 	}
4224 4224
 
4225 4225
 
@@ -4232,23 +4232,23 @@  discard block
 block discarded – undo
4232 4232
 	 * @param string $cols_n_values
4233 4233
 	 * @return array
4234 4234
 	 */
4235
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
4235
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
4236 4236
 		$this_model_fields_n_values = array();
4237
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
4238
-			$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() );
4237
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
4238
+			$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());
4239 4239
 			//there is a primary key on this table and its not set. Use defaults for all its columns
4240
-			if( $table_pk_value === null && $table_obj->get_pk_column() ){
4241
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4242
-					if( ! $field_obj->is_db_only_field() ){
4240
+			if ($table_pk_value === null && $table_obj->get_pk_column()) {
4241
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4242
+					if ( ! $field_obj->is_db_only_field()) {
4243 4243
 						//prepare field as if its coming from db
4244
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
4245
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
4244
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
4245
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
4246 4246
 					}
4247 4247
 				}
4248
-			}else{
4248
+			} else {
4249 4249
 				//the table's rows existed. Use their values
4250
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4251
-					if( ! $field_obj->is_db_only_field() ){
4250
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4251
+					if ( ! $field_obj->is_db_only_field()) {
4252 4252
 						$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not(
4253 4253
 							$cols_n_values, $field_obj->get_qualified_column(),
4254 4254
 							$field_obj->get_table_column()
@@ -4268,15 +4268,15 @@  discard block
 block discarded – undo
4268 4268
 	 * @param $regular_column
4269 4269
 	 * @return null
4270 4270
 	 */
4271
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
4271
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
4272 4272
 		$value = null;
4273 4273
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
4274 4274
 		//does the field on the model relate to this column retrieved from the db?
4275 4275
 		//or is it a db-only field? (not relating to the model)
4276
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
4277
-			$value = $cols_n_values[ $qualified_column ];
4278
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4279
-			$value = $cols_n_values[ $regular_column ];
4276
+		if (isset($cols_n_values[$qualified_column])) {
4277
+			$value = $cols_n_values[$qualified_column];
4278
+		}elseif (isset($cols_n_values[$regular_column])) {
4279
+			$value = $cols_n_values[$regular_column];
4280 4280
 		}
4281 4281
 		return $value;
4282 4282
 	}
@@ -4292,25 +4292,25 @@  discard block
 block discarded – undo
4292 4292
 	 * @return EE_Base_Class
4293 4293
 	 * @throws \EE_Error
4294 4294
 	 */
4295
-	public function refresh_entity_map_from_db( $id ){
4296
-		$obj_in_map = $this->get_from_entity_map( $id );
4297
-		if( $obj_in_map ){
4295
+	public function refresh_entity_map_from_db($id) {
4296
+		$obj_in_map = $this->get_from_entity_map($id);
4297
+		if ($obj_in_map) {
4298 4298
 			$wpdb_results = $this->_get_all_wpdb_results(
4299
-				array( array( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 )
4299
+				array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1)
4300 4300
 			);
4301
-			if( $wpdb_results && is_array( $wpdb_results ) ){
4302
-				$one_row = reset( $wpdb_results );
4303
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
4304
-					$obj_in_map->set_from_db( $field_name, $db_value );
4301
+			if ($wpdb_results && is_array($wpdb_results)) {
4302
+				$one_row = reset($wpdb_results);
4303
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
4304
+					$obj_in_map->set_from_db($field_name, $db_value);
4305 4305
 				}
4306 4306
 				//clear the cache of related model objects
4307
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4308
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4307
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4308
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4309 4309
 				}
4310 4310
 			}
4311 4311
 			return $obj_in_map;
4312
-		}else{
4313
-			return $this->get_one_by_ID( $id );
4312
+		} else {
4313
+			return $this->get_one_by_ID($id);
4314 4314
 		}
4315 4315
 	}
4316 4316
 
@@ -4328,24 +4328,24 @@  discard block
 block discarded – undo
4328 4328
 	 * @return \EE_Base_Class
4329 4329
 	 * @throws \EE_Error
4330 4330
 	 */
4331
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
4332
-		$obj_in_map = $this->get_from_entity_map( $id );
4333
-		if( $obj_in_map ){
4334
-			if( $replacing_model_obj instanceof EE_Base_Class ){
4335
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
4336
-					$obj_in_map->set( $field_name, $value );
4331
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
4332
+		$obj_in_map = $this->get_from_entity_map($id);
4333
+		if ($obj_in_map) {
4334
+			if ($replacing_model_obj instanceof EE_Base_Class) {
4335
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
4336
+					$obj_in_map->set($field_name, $value);
4337 4337
 				}
4338 4338
 				//make the model object in the entity map's cache match the $replacing_model_obj
4339
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4340
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4341
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
4342
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
4339
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4340
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4341
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
4342
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
4343 4343
 					}
4344 4344
 				}
4345 4345
 			}
4346 4346
 			return $obj_in_map;
4347
-		}else{
4348
-			$this->add_to_entity_map( $replacing_model_obj );
4347
+		} else {
4348
+			$this->add_to_entity_map($replacing_model_obj);
4349 4349
 			return $replacing_model_obj;
4350 4350
 		}
4351 4351
 	}
@@ -4358,7 +4358,7 @@  discard block
 block discarded – undo
4358 4358
 	 * require_once($this->_getClassName().".class.php");
4359 4359
 	 * @return string
4360 4360
 	 */
4361
-	private function _get_class_name(){
4361
+	private function _get_class_name() {
4362 4362
 		return "EE_".$this->get_this_model_name();
4363 4363
 	}
4364 4364
 
@@ -4371,8 +4371,8 @@  discard block
 block discarded – undo
4371 4371
 	 * @param int $quantity
4372 4372
 	 * @return string
4373 4373
 	 */
4374
-	public function item_name($quantity = 1){
4375
-		return (int)$quantity === 1 ? $this->singular_item : $this->plural_item;
4374
+	public function item_name($quantity = 1) {
4375
+		return (int) $quantity === 1 ? $this->singular_item : $this->plural_item;
4376 4376
 	}
4377 4377
 
4378 4378
 
@@ -4399,13 +4399,13 @@  discard block
 block discarded – undo
4399 4399
 	 * @throws EE_Error
4400 4400
 	 * @return mixed whatever the plugin which calls add_filter decides
4401 4401
 	 */
4402
-	public function __call($methodName,$args){
4403
-		$className=get_class($this);
4404
-		$tagName="FHEE__{$className}__{$methodName}";
4405
-		if(!has_filter($tagName)){
4402
+	public function __call($methodName, $args) {
4403
+		$className = get_class($this);
4404
+		$tagName = "FHEE__{$className}__{$methodName}";
4405
+		if ( ! has_filter($tagName)) {
4406 4406
 			throw new EE_Error(
4407 4407
 				sprintf(
4408
-					__( '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' ),
4408
+					__('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'),
4409 4409
 					$methodName,
4410 4410
 					$className,
4411 4411
 					$tagName,
@@ -4414,7 +4414,7 @@  discard block
 block discarded – undo
4414 4414
 			);
4415 4415
 		}
4416 4416
 
4417
-		return apply_filters($tagName,null,$this,$args);
4417
+		return apply_filters($tagName, null, $this, $args);
4418 4418
 	}
4419 4419
 
4420 4420
 
@@ -4432,28 +4432,28 @@  discard block
 block discarded – undo
4432 4432
 	 * @throws EE_Error
4433 4433
 	 * @return EE_Base_Class
4434 4434
 	 */
4435
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4435
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4436 4436
 		$className = $this->_get_class_name();
4437
-		if ( $base_class_obj_or_id instanceof $className ) {
4437
+		if ($base_class_obj_or_id instanceof $className) {
4438 4438
 			$model_object = $base_class_obj_or_id;
4439 4439
 		} else {
4440 4440
 			$primary_key_field = $this->get_primary_key_field();
4441 4441
 			if (
4442 4442
 				$primary_key_field instanceof EE_Primary_Key_Int_Field
4443 4443
 				&& (
4444
-					is_int( $base_class_obj_or_id )
4445
-					|| is_string( $base_class_obj_or_id )
4444
+					is_int($base_class_obj_or_id)
4445
+					|| is_string($base_class_obj_or_id)
4446 4446
 				)
4447 4447
 			) {
4448 4448
 				// assume it's an ID.
4449 4449
 				// either a proper integer or a string representing an integer (eg "101" instead of 101)
4450
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4450
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4451 4451
 			} else if (
4452 4452
 				$primary_key_field instanceof EE_Primary_Key_String_Field
4453
-			    && is_string( $base_class_obj_or_id )
4453
+			    && is_string($base_class_obj_or_id)
4454 4454
 			) {
4455 4455
 				// assume its a string representation of the object
4456
-				$model_object = $this->get_one_by_ID( $base_class_obj_or_id );
4456
+				$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4457 4457
 			} else {
4458 4458
 				throw new EE_Error(
4459 4459
 					sprintf(
@@ -4463,12 +4463,12 @@  discard block
 block discarded – undo
4463 4463
 						),
4464 4464
 						$base_class_obj_or_id,
4465 4465
 						$this->_get_class_name(),
4466
-						print_r( $base_class_obj_or_id, true )
4466
+						print_r($base_class_obj_or_id, true)
4467 4467
 					)
4468 4468
 				);
4469 4469
 			}
4470 4470
 		}
4471
-		if ( $ensure_is_in_db && $model_object->ID() !== null ) {
4471
+		if ($ensure_is_in_db && $model_object->ID() !== null) {
4472 4472
 			$model_object->save();
4473 4473
 		}
4474 4474
 		return $model_object;
@@ -4484,19 +4484,19 @@  discard block
 block discarded – undo
4484 4484
 	 * @return int|string depending on the type of this model object's ID
4485 4485
 	 * @throws EE_Error
4486 4486
 	 */
4487
-	public function ensure_is_ID($base_class_obj_or_id){
4487
+	public function ensure_is_ID($base_class_obj_or_id) {
4488 4488
 		$className = $this->_get_class_name();
4489
-		if( $base_class_obj_or_id instanceof $className ){
4489
+		if ($base_class_obj_or_id instanceof $className) {
4490 4490
 			/** @var $base_class_obj_or_id EE_Base_Class */
4491 4491
 			$id = $base_class_obj_or_id->ID();
4492
-		}elseif(is_int($base_class_obj_or_id)){
4492
+		}elseif (is_int($base_class_obj_or_id)) {
4493 4493
 			//assume it's an ID
4494 4494
 			$id = $base_class_obj_or_id;
4495
-		}elseif(is_string($base_class_obj_or_id)){
4495
+		}elseif (is_string($base_class_obj_or_id)) {
4496 4496
 			//assume its a string representation of the object
4497 4497
 			$id = $base_class_obj_or_id;
4498
-		}else{
4499
-			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)));
4498
+		} else {
4499
+			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)));
4500 4500
 		}
4501 4501
 		return $id;
4502 4502
 	}
@@ -4519,14 +4519,14 @@  discard block
 block discarded – undo
4519 4519
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4520 4520
 	 * @return void
4521 4521
 	 */
4522
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4522
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4523 4523
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4524 4524
 	}
4525 4525
 	/**
4526 4526
 	 * Read comments for assume_values_already_prepared_by_model_object()
4527 4527
 	 * @return int
4528 4528
 	 */
4529
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4529
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4530 4530
 		return $this->_values_already_prepared_by_model_object;
4531 4531
 	}
4532 4532
 
@@ -4534,17 +4534,17 @@  discard block
 block discarded – undo
4534 4534
 	 * Gets all the indexes on this model
4535 4535
 	 * @return EE_Index[]
4536 4536
 	 */
4537
-	public function indexes(){
4537
+	public function indexes() {
4538 4538
 		return $this->_indexes;
4539 4539
 	}
4540 4540
 	/**
4541 4541
 	 * Gets all the Unique Indexes on this model
4542 4542
 	 * @return EE_Unique_Index[]
4543 4543
 	 */
4544
-	public function unique_indexes(){
4544
+	public function unique_indexes() {
4545 4545
 		$unique_indexes = array();
4546
-		foreach($this->_indexes as $name => $index){
4547
-			if($index instanceof EE_Unique_Index){
4546
+		foreach ($this->_indexes as $name => $index) {
4547
+			if ($index instanceof EE_Unique_Index) {
4548 4548
 				$unique_indexes [$name] = $index;
4549 4549
 			}
4550 4550
 		}
@@ -4562,13 +4562,13 @@  discard block
 block discarded – undo
4562 4562
 	 * @return EE_Model_Field_Base[] indexed by the field's name
4563 4563
 	 * @throws \EE_Error
4564 4564
 	 */
4565
-	public function get_combined_primary_key_fields(){
4566
-		foreach($this->indexes() as $index){
4567
-			if($index instanceof EE_Primary_Key_Index){
4565
+	public function get_combined_primary_key_fields() {
4566
+		foreach ($this->indexes() as $index) {
4567
+			if ($index instanceof EE_Primary_Key_Index) {
4568 4568
 				return $index->fields();
4569 4569
 			}
4570 4570
 		}
4571
-		return array( $this->primary_key_name() => $this->get_primary_key_field());
4571
+		return array($this->primary_key_name() => $this->get_primary_key_field());
4572 4572
 	}
4573 4573
 	
4574 4574
 
@@ -4582,7 +4582,7 @@  discard block
 block discarded – undo
4582 4582
 	 * @return string
4583 4583
 	 * @throws \EE_Error
4584 4584
 	 */
4585
-	public function get_index_primary_key_string($cols_n_values){
4585
+	public function get_index_primary_key_string($cols_n_values) {
4586 4586
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4587 4587
 		return http_build_query($cols_n_values_for_primary_key_index);
4588 4588
 	}
@@ -4597,13 +4597,13 @@  discard block
 block discarded – undo
4597 4597
 	 * @return null|array
4598 4598
 	 * @throws \EE_Error
4599 4599
 	 */
4600
-	public function parse_index_primary_key_string( $index_primary_key_string) {
4600
+	public function parse_index_primary_key_string($index_primary_key_string) {
4601 4601
 		$key_fields = $this->get_combined_primary_key_fields();
4602 4602
 		//check all of them are in the $id
4603 4603
 		$key_vals_in_combined_pk = array();
4604
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4605
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4606
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4604
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4605
+		foreach ($key_fields as $key_field_name => $field_obj) {
4606
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4607 4607
 				return NULL;
4608 4608
 			}
4609 4609
 		}
@@ -4620,10 +4620,10 @@  discard block
 block discarded – undo
4620 4620
 	 * @return boolean
4621 4621
 	 * @throws \EE_Error
4622 4622
 	 */
4623
-	public function has_all_combined_primary_key_fields( $key_vals ) {
4624
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4625
-		foreach( $keys_it_should_have as $key ){
4626
-			if( ! isset( $key_vals[ $key ] ) ){
4623
+	public function has_all_combined_primary_key_fields($key_vals) {
4624
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4625
+		foreach ($keys_it_should_have as $key) {
4626
+			if ( ! isset($key_vals[$key])) {
4627 4627
 				return false;
4628 4628
 			}
4629 4629
 		}
@@ -4639,23 +4639,23 @@  discard block
 block discarded – undo
4639 4639
 	 * @throws EE_Error
4640 4640
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4641 4641
 	 */
4642
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4642
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4643 4643
 
4644
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4644
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4645 4645
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4646
-		}elseif(is_array($model_object_or_attributes_array)){
4646
+		}elseif (is_array($model_object_or_attributes_array)) {
4647 4647
 			$attributes_array = $model_object_or_attributes_array;
4648
-		}else{
4649
-			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));
4648
+		} else {
4649
+			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));
4650 4650
 		}
4651 4651
 		//even copies obviously won't have the same ID, so remove the primary key
4652 4652
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4653
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4653
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4654 4654
 			unset($attributes_array[$this->primary_key_name()]);
4655 4655
 		}
4656
-		if(isset($query_params[0])){
4657
-			$query_params[0] = array_merge($attributes_array,$query_params);
4658
-		}else{
4656
+		if (isset($query_params[0])) {
4657
+			$query_params[0] = array_merge($attributes_array, $query_params);
4658
+		} else {
4659 4659
 			$query_params[0] = $attributes_array;
4660 4660
 		}
4661 4661
 		return $this->get_all($query_params);
@@ -4671,16 +4671,16 @@  discard block
 block discarded – undo
4671 4671
 	 * @return EE_Base_Class
4672 4672
 	 * @throws \EE_Error
4673 4673
 	 */
4674
-	public function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4675
-		if( ! is_array( $query_params ) ){
4676
-			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' );
4674
+	public function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4675
+		if ( ! is_array($query_params)) {
4676
+			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');
4677 4677
 			$query_params = array();
4678 4678
 		}
4679 4679
 		$query_params['limit'] = 1;
4680
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4681
-		if(is_array($copies)){
4680
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4681
+		if (is_array($copies)) {
4682 4682
 			return array_shift($copies);
4683
-		}else{
4683
+		} else {
4684 4684
 			return null;
4685 4685
 		}
4686 4686
 	}
@@ -4696,10 +4696,10 @@  discard block
 block discarded – undo
4696 4696
 	 * @return int number of rows updated
4697 4697
 	 * @throws \EE_Error
4698 4698
 	 */
4699
-	public function update_by_ID($fields_n_values,$id){
4699
+	public function update_by_ID($fields_n_values, $id) {
4700 4700
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4701 4701
 			'default_where_conditions'=>'other_models_only',);
4702
-		return $this->update($fields_n_values,$query_params);
4702
+		return $this->update($fields_n_values, $query_params);
4703 4703
 	}
4704 4704
 
4705 4705
 
@@ -4710,12 +4710,12 @@  discard block
 block discarded – undo
4710 4710
 	 * @return string an operator which can be used in SQL
4711 4711
 	 * @throws EE_Error
4712 4712
 	 */
4713
-	private function _prepare_operator_for_sql($operator_supplied){
4713
+	private function _prepare_operator_for_sql($operator_supplied) {
4714 4714
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4715
-		if($sql_operator){
4715
+		if ($sql_operator) {
4716 4716
 			return $sql_operator;
4717
-		}else{
4718
-			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))));
4717
+		} else {
4718
+			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))));
4719 4719
 		}
4720 4720
 	}
4721 4721
 
@@ -4729,10 +4729,10 @@  discard block
 block discarded – undo
4729 4729
 	 * @return string[]
4730 4730
 	 * @throws \EE_Error
4731 4731
 	 */
4732
-	public function get_all_names($query_params = array()){
4732
+	public function get_all_names($query_params = array()) {
4733 4733
 		$objs = $this->get_all($query_params);
4734 4734
 		$names = array();
4735
-		foreach($objs as $obj){
4735
+		foreach ($objs as $obj) {
4736 4736
 			$names[$obj->ID()] = $obj->name();
4737 4737
 		}
4738 4738
 		return $names;
@@ -4751,11 +4751,11 @@  discard block
 block discarded – undo
4751 4751
 	 * @return array
4752 4752
 	 * @throws \EE_Error
4753 4753
 	 */
4754
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4755
-		if( ! $this->has_primary_key_field() ) {
4756
-			if( WP_DEBUG ) {
4754
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4755
+		if ( ! $this->has_primary_key_field()) {
4756
+			if (WP_DEBUG) {
4757 4757
 				EE_Error::add_error(
4758
-					__( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ),
4758
+					__('Trying to get IDs from a model than has no primary key', 'event_espresso'),
4759 4759
 					__FILE__,
4760 4760
 					__FUNCTION__,
4761 4761
 					__LINE__
@@ -4763,13 +4763,13 @@  discard block
 block discarded – undo
4763 4763
 			}
4764 4764
 		}
4765 4765
 		$IDs = array();
4766
-		foreach( $model_objects as $model_object ) {
4766
+		foreach ($model_objects as $model_object) {
4767 4767
 			$id = $model_object->ID();
4768
-			if( ! $id ) {
4769
-				if( $filter_out_empty_ids ) {
4768
+			if ( ! $id) {
4769
+				if ($filter_out_empty_ids) {
4770 4770
 					continue;
4771 4771
 				}
4772
-				if ( WP_DEBUG ) {
4772
+				if (WP_DEBUG) {
4773 4773
 					EE_Error::add_error(
4774 4774
 						__(
4775 4775
 							'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database',
@@ -4791,8 +4791,8 @@  discard block
 block discarded – undo
4791 4791
 	 * are no capabilities that relate to this model returns false
4792 4792
 	 * @return string|false
4793 4793
 	 */
4794
-	public function cap_slug(){
4795
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4794
+	public function cap_slug() {
4795
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4796 4796
 	}
4797 4797
 
4798 4798
 
@@ -4807,34 +4807,34 @@  discard block
 block discarded – undo
4807 4807
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4808 4808
 	 * @throws \EE_Error
4809 4809
 	 */
4810
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4811
-		EEM_Base::verify_is_valid_cap_context( $context );
4810
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4811
+		EEM_Base::verify_is_valid_cap_context($context);
4812 4812
 		//check if we ought to run the restriction generator first
4813
-		if(
4814
-			isset( $this->_cap_restriction_generators[ $context ] )
4815
-			&& $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base
4816
-			&& ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions()
4813
+		if (
4814
+			isset($this->_cap_restriction_generators[$context])
4815
+			&& $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base
4816
+			&& ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()
4817 4817
 		) {
4818
-			$this->_cap_restrictions[ $context ] = array_merge(
4819
-				$this->_cap_restrictions[ $context ],
4820
-				$this->_cap_restriction_generators[ $context ]->generate_restrictions()
4818
+			$this->_cap_restrictions[$context] = array_merge(
4819
+				$this->_cap_restrictions[$context],
4820
+				$this->_cap_restriction_generators[$context]->generate_restrictions()
4821 4821
 			);
4822 4822
 		}
4823 4823
 		//and make sure we've finalized the construction of each restriction
4824
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4825
-			if ( $where_conditions_obj instanceof EE_Default_Where_Conditions ) {
4826
-				$where_conditions_obj->_finalize_construct( $this );
4824
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4825
+			if ($where_conditions_obj instanceof EE_Default_Where_Conditions) {
4826
+				$where_conditions_obj->_finalize_construct($this);
4827 4827
 			}
4828 4828
 		}
4829 4829
 
4830
-		return $this->_cap_restrictions[ $context ];
4830
+		return $this->_cap_restrictions[$context];
4831 4831
 	}
4832 4832
 
4833 4833
 	/**
4834 4834
 	 * Indicating whether or not this model thinks its a wp core model
4835 4835
 	 * @return boolean
4836 4836
 	 */
4837
-	public function is_wp_core_model(){
4837
+	public function is_wp_core_model() {
4838 4838
 		return $this->_wp_core_model;
4839 4839
 	}
4840 4840
 
@@ -4848,12 +4848,12 @@  discard block
 block discarded – undo
4848 4848
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4849 4849
 	 * @throws \EE_Error
4850 4850
 	 */
4851
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4851
+	public function caps_missing($context = EEM_Base::caps_read) {
4852 4852
 		$missing_caps = array();
4853
-		$cap_restrictions = $this->cap_restrictions( $context );
4854
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4855
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4856
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4853
+		$cap_restrictions = $this->cap_restrictions($context);
4854
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4855
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4856
+				$missing_caps[$cap] = $restriction_if_no_cap;
4857 4857
 			}
4858 4858
 		}
4859 4859
 		return $missing_caps;
@@ -4865,7 +4865,7 @@  discard block
 block discarded – undo
4865 4865
 	 * one of 'read', 'edit', or 'delete'
4866 4866
 	 */
4867 4867
 	public function cap_contexts_to_cap_action_map() {
4868
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4868
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4869 4869
 	}
4870 4870
 
4871 4871
 
@@ -4876,19 +4876,19 @@  discard block
 block discarded – undo
4876 4876
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4877 4877
 	 * @throws \EE_Error
4878 4878
 	 */
4879
-	public function cap_action_for_context( $context ) {
4879
+	public function cap_action_for_context($context) {
4880 4880
 		$mapping = $this->cap_contexts_to_cap_action_map();
4881
-		if( isset( $mapping[ $context ] ) ) {
4882
-			return $mapping[ $context ];
4881
+		if (isset($mapping[$context])) {
4882
+			return $mapping[$context];
4883 4883
 		}
4884
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4884
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4885 4885
 			return $action;
4886 4886
 		}
4887 4887
 		throw new EE_Error(
4888 4888
 			sprintf(
4889
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4889
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4890 4890
 				$context,
4891
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4891
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4892 4892
 			)
4893 4893
 		);
4894 4894
 
@@ -4899,7 +4899,7 @@  discard block
 block discarded – undo
4899 4899
 	 * @return array
4900 4900
 	 */
4901 4901
 	static public function valid_cap_contexts() {
4902
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4902
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4903 4903
 			self::caps_read,
4904 4904
 			self::caps_read_admin,
4905 4905
 			self::caps_edit,
@@ -4915,17 +4915,17 @@  discard block
 block discarded – undo
4915 4915
 	 * @return bool
4916 4916
 	 * @throws \EE_Error
4917 4917
 	 */
4918
-	static public function verify_is_valid_cap_context( $context ) {
4918
+	static public function verify_is_valid_cap_context($context) {
4919 4919
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4920
-		if( in_array( $context, $valid_cap_contexts ) ) {
4920
+		if (in_array($context, $valid_cap_contexts)) {
4921 4921
 			return true;
4922
-		}else{
4922
+		} else {
4923 4923
 			throw new EE_Error(
4924 4924
 				sprintf(
4925
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4925
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4926 4926
 					$context,
4927
-					'EEM_Base' ,
4928
-					implode(',', $valid_cap_contexts )
4927
+					'EEM_Base',
4928
+					implode(',', $valid_cap_contexts)
4929 4929
 				)
4930 4930
 			);
4931 4931
 		}
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Table_Base.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * Base class for defining the tables that comprise models. This is used to store information
5 5
  * about the table\s alias, private key, etc.
6 6
  */
7
-abstract class EE_Table_Base{
7
+abstract class EE_Table_Base {
8 8
 
9 9
 	/**
10 10
 	 * This holds the table_name without the table prefix.
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	 * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install,
42 42
 	 *					or whether each site on a multisite install has a copy of this table
43 43
 	 */
44
-	function __construct($table_name, $pk_column, $global = false ){
44
+	function __construct($table_name, $pk_column, $global = false) {
45 45
 		$this->_global = $global;
46 46
 		$prefix = $this->get_table_prefix();
47 47
 		//if they added the prefix, let's remove it because we delay adding the prefix until right when its needed.
48
-		if ( strpos( $table_name, $prefix ) === 0 ) {
49
-			$table_name = ltrim( $table_name, $prefix );
48
+		if (strpos($table_name, $prefix) === 0) {
49
+			$table_name = ltrim($table_name, $prefix);
50 50
 		}
51 51
 		$this->_table_name = $table_name;
52 52
 		$this->_pk_column = $pk_column;
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	public function get_table_prefix() {
65 65
 		global $wpdb;
66 66
 
67
-		if ( $this->_global ) {
67
+		if ($this->_global) {
68 68
 			$prefix = $wpdb->base_prefix;
69 69
 		} else {
70
-			$prefix = $wpdb->get_blog_prefix( EEM_Base::get_model_query_blog_id() );
70
+			$prefix = $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id());
71 71
 		}
72 72
 		return $prefix;
73 73
 	}
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param string $table_alias
80 80
 	 */
81
-	function _construct_finalize_with_alias($table_alias){
81
+	function _construct_finalize_with_alias($table_alias) {
82 82
 		$this->_table_alias = $table_alias;
83 83
 	}
84 84
 
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * Returns the fully qualified table name for the database (includes the table prefix current for the blog).
88 88
 	 * @return string
89 89
 	 */
90
-	function get_table_name(){
91
-		return $this->get_table_prefix() . $this->_table_name;
90
+	function get_table_name() {
91
+		return $this->get_table_prefix().$this->_table_name;
92 92
 	}
93 93
 
94 94
 
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	 * @return string
101 101
 	 * @throws EE_Error
102 102
 	 */
103
-	function get_table_alias(){
104
-		if( ! $this->_table_alias){
103
+	function get_table_alias() {
104
+		if ( ! $this->_table_alias) {
105 105
 			throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?");
106 106
 		}
107 107
 		return $this->_table_alias;
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return string name of column of PK
115 115
 	 */
116
-	function get_pk_column(){
116
+	function get_pk_column() {
117 117
 		return $this->_pk_column;
118 118
 	}
119 119
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	 * returns a string with the table alias, a period, and the private key's column.
124 124
 	 * @return string
125 125
 	 */
126
-	function get_fully_qualified_pk_column(){
127
-		$sql =  $this->get_table_alias().".".$this->get_pk_column();
126
+	function get_fully_qualified_pk_column() {
127
+		$sql = $this->get_table_alias().".".$this->get_pk_column();
128 128
 		return $sql;
129 129
 	}
130 130
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 	 * returns the special sql for a inner select with a limit.
134 134
 	 * @return string    SQL select
135 135
 	 */
136
-	public function get_select_join_limit( $limit ) {
137
-		$limit = is_array( $limit ) ? 'LIMIT ' . implode(',', array_map( 'intval', $limit ) ) : 'LIMIT ' . (int) $limit;
138
-		$SQL = SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias;
136
+	public function get_select_join_limit($limit) {
137
+		$limit = is_array($limit) ? 'LIMIT '.implode(',', array_map('intval', $limit)) : 'LIMIT '.(int) $limit;
138
+		$SQL = SP.'(SELECT * FROM '.$this->_table_name.SP.$limit.') AS '.$this->_table_alias;
139 139
 		return $SQL;
140 140
 	}
141 141
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Generator.lib.php 1 patch
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); }
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
 
3 3
 /**
4 4
  * This class is used for generating EE_Message objects with given info.
@@ -116,17 +116,17 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return EE_Messages_Queue  The new queue for holding generated EE_Message objects.
118 118
 	 */
119
-	public function generate( $save = true ) {
119
+	public function generate($save = true) {
120 120
 		//iterate through the messages in the queue, generate, and add to new queue.
121 121
 		$this->_generation_queue->get_message_repository()->rewind();
122
-		while ( $this->_generation_queue->get_message_repository()->valid() ) {
122
+		while ($this->_generation_queue->get_message_repository()->valid()) {
123 123
 			//reset "current" properties
124 124
 			$this->_reset_current_properties();
125 125
 
126 126
 			/** @type EE_Message $msg */
127 127
 			$msg = $this->_generation_queue->get_message_repository()->current();
128 128
 
129
-			if ( $this->_verify() ) {
129
+			if ($this->_verify()) {
130 130
 				//let's get generating!
131 131
 				$this->_generate();
132 132
 			}
@@ -138,26 +138,26 @@  discard block
 block discarded – undo
138 138
 			$this->_generation_queue->get_message_repository()->next();
139 139
 			$next_msg = $this->_generation_queue->get_message_repository()->current();
140 140
 			//restore pointer to current item
141
-			$this->_generation_queue->get_message_repository()->set_current( $msg );
141
+			$this->_generation_queue->get_message_repository()->set_current($msg);
142 142
 
143 143
 			//if there are error messages then let's set the status and the error message.
144
-			if ( $this->_error_msg ) {
144
+			if ($this->_error_msg) {
145 145
 				//if the status is already debug only, then let's leave it at that.
146
-				if ( $msg->STS_ID() !== EEM_Message::status_debug_only ) {
147
-					$msg->set_STS_ID( EEM_Message::status_failed );
146
+				if ($msg->STS_ID() !== EEM_Message::status_debug_only) {
147
+					$msg->set_STS_ID(EEM_Message::status_failed);
148 148
 				}
149 149
 				$msg->set_error_message(
150
-					__( 'Message failed to generate for the following reasons: ' )
150
+					__('Message failed to generate for the following reasons: ')
151 151
 					. "\n"
152
-					. implode( "\n", $this->_error_msg )
152
+					. implode("\n", $this->_error_msg)
153 153
 				);
154
-				$msg->set_modified( time() );
154
+				$msg->set_modified(time());
155 155
 			} else {
156 156
 				//remove from db
157 157
 				$this->_generation_queue->get_message_repository()->delete();
158 158
 			}
159 159
 			//next item
160
-			$this->_generation_queue->get_message_repository()->set_current( $next_msg );
160
+			$this->_generation_queue->get_message_repository()->set_current($next_msg);
161 161
 		}
162 162
 
163 163
 		//generation queue is ALWAYS saved to record any errors in the generation process.
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		 * so a EE_Extra_Meta entry could be created and attached to the EE_Message.  In those cases the save flag is
171 171
 		 * irrelevant.
172 172
 		 */
173
-		if ( $save ) {
173
+		if ($save) {
174 174
 			$this->_ready_queue->save();
175 175
 		}
176 176
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	protected function _reset_current_properties() {
189 189
 		$this->_verified = false;
190 190
 		//make sure any _data value in the current message type is reset
191
-		if ( $this->_current_message_type instanceof EE_message_type ) {
191
+		if ($this->_current_message_type instanceof EE_message_type) {
192 192
 			$this->_current_message_type->reset_data();
193 193
 		}
194 194
 		$this->_current_messenger = $this->_current_message_type = $this->_current_data_handler = null;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	protected function _generate() {
209 209
 		//double check verification has run and that everything is ready to work with (saves us having to validate everything again).
210
-		if ( ! $this->_verified ) {
210
+		if ( ! $this->_verified) {
211 211
 			return false; //get out because we don't have a valid setup to work with.
212 212
 		}
213 213
 
@@ -217,34 +217,34 @@  discard block
 block discarded – undo
217 217
 				$this->_current_data_handler,
218 218
 				$this->_generation_queue->get_message_repository()->current()->context()
219 219
 			);
220
-		} catch ( EE_Error $e ) {
220
+		} catch (EE_Error $e) {
221 221
 			$this->_error_msg[] = $e->getMessage();
222 222
 			return false;
223 223
 		}
224 224
 
225 225
 
226 226
 		//if no addressees then get out because there is nothing to generation (possible bad data).
227
-		if ( ! $this->_valid_addressees( $addressees ) ) {
228
-			$this->_generation_queue->get_message_repository()->current()->set_STS_ID( EEM_Message::status_debug_only );
229
-			$this->_error_msg[] = __( 'This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects.  There were no attendees prepared by the data handler.
230
-			  Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso' );
227
+		if ( ! $this->_valid_addressees($addressees)) {
228
+			$this->_generation_queue->get_message_repository()->current()->set_STS_ID(EEM_Message::status_debug_only);
229
+			$this->_error_msg[] = __('This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects.  There were no attendees prepared by the data handler.
230
+			  Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso');
231 231
 			return false;
232 232
 		}
233 233
 
234 234
 		$message_template_group = $this->_get_message_template_group();
235 235
 
236 236
 		//in the unlikely event there is no EE_Message_Template_Group available, get out!
237
-		if ( ! $message_template_group instanceof EE_Message_Template_Group ) {
238
-			$this->_error_msg[] = __( 'Unable to get the Message Templates for the Message being generated.  No message template group accessible.', 'event_espresso' );
237
+		if ( ! $message_template_group instanceof EE_Message_Template_Group) {
238
+			$this->_error_msg[] = __('Unable to get the Message Templates for the Message being generated.  No message template group accessible.', 'event_espresso');
239 239
 			return false;
240 240
 		}
241 241
 
242 242
 		//get formatted templates for using to parse and setup EE_Message objects.
243
-		$templates = $this->_get_templates( $message_template_group );
243
+		$templates = $this->_get_templates($message_template_group);
244 244
 
245 245
 
246 246
 		//setup new EE_Message objects (and add to _ready_queue)
247
-		return $this->_assemble_messages( $addressees, $templates, $message_template_group );
247
+		return $this->_assemble_messages($addressees, $templates, $message_template_group);
248 248
 	}
249 249
 
250 250
 
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
 		//so let's use that.
263 263
 		$GRP_ID = $this->_generation_queue->get_message_repository()->current()->GRP_ID();
264 264
 
265
-		if ( $GRP_ID ) {
265
+		if ($GRP_ID) {
266 266
 			//attempt to retrieve from repo first
267
-			$GRP = $this->_template_collection->get_by_ID( $GRP_ID );
268
-			if ( $GRP instanceof EE_Message_Template_Group ) {
269
-				return $GRP;  //got it!
267
+			$GRP = $this->_template_collection->get_by_ID($GRP_ID);
268
+			if ($GRP instanceof EE_Message_Template_Group) {
269
+				return $GRP; //got it!
270 270
 			}
271 271
 
272 272
 			//nope don't have it yet.  Get from DB then add to repo
273
-			$GRP = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
274
-			if ( $GRP instanceof EE_Message_Template_Group ) {
275
-				$this->_template_collection->add( $GRP );
273
+			$GRP = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
274
+			if ($GRP instanceof EE_Message_Template_Group) {
275
+				$this->_template_collection->add($GRP);
276 276
 			}
277 277
 			return $GRP;
278 278
 		}
@@ -291,41 +291,41 @@  discard block
 block discarded – undo
291 291
 		//in vanilla EE we're assuming there's only one event.
292 292
 		//However, if there are multiple events then we'll just use the default templates instead of different
293 293
 		// templates per event (which could create problems).
294
-		if ( count( $this->_current_data_handler->events ) === 1 ) {
295
-			foreach ( $this->_current_data_handler->events as $event ) {
294
+		if (count($this->_current_data_handler->events) === 1) {
295
+			foreach ($this->_current_data_handler->events as $event) {
296 296
 				$EVT_ID = $event['ID'];
297 297
 			}
298 298
 		}
299 299
 
300 300
 		//before going any further, let's see if its in the queue
301
-		$GRP = $this->_template_collection->get_by_key( $this->_template_collection->get_key( $this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID ) );
301
+		$GRP = $this->_template_collection->get_by_key($this->_template_collection->get_key($this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID));
302 302
 
303
-		if ( $GRP instanceof EE_Message_Template_Group ) {
303
+		if ($GRP instanceof EE_Message_Template_Group) {
304 304
 			return $GRP;
305 305
 		}
306 306
 
307 307
 		//nope still no GRP?
308 308
 		//first we get the global template in case it has an override set.
309
-		$global_template_qa = array_merge( array( 'MTP_is_global' => true ), $template_qa );
310
-		$global_GRP = EEM_Message_Template_Group::instance()->get_one( array( $global_template_qa ) );
309
+		$global_template_qa = array_merge(array('MTP_is_global' => true), $template_qa);
310
+		$global_GRP = EEM_Message_Template_Group::instance()->get_one(array($global_template_qa));
311 311
 
312 312
 		//if this is an override, then we just return it.
313
-		if ( $global_GRP instanceof EE_Message_Template_Group && $global_GRP->get( 'MTP_is_override' ) ) {
314
-			$this->_template_collection->add( $global_GRP, $EVT_ID );
313
+		if ($global_GRP instanceof EE_Message_Template_Group && $global_GRP->get('MTP_is_override')) {
314
+			$this->_template_collection->add($global_GRP, $EVT_ID);
315 315
 			return $global_GRP;
316 316
 		}
317 317
 
318 318
 		//STILL here? Okay that means we want to see if there is event specific group and if there is we return it,
319 319
 		//otherwise we return the global group we retrieved.
320
-		if ( $EVT_ID ) {
320
+		if ($EVT_ID) {
321 321
 			$template_qa['Event.EVT_ID'] = $EVT_ID;
322 322
 		}
323 323
 
324
-		$GRP = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) );
324
+		$GRP = EEM_Message_Template_Group::instance()->get_one(array($template_qa));
325 325
 		$GRP = $GRP instanceof EE_Message_Template_Group ? $GRP : $global_GRP;
326 326
 
327
-		if ( $GRP instanceof EE_Message_Template_Group ) {
328
-			$this->_template_collection->add( $GRP, $EVT_ID );
327
+		if ($GRP instanceof EE_Message_Template_Group) {
328
+			$this->_template_collection->add($GRP, $EVT_ID);
329 329
 			return $GRP;
330 330
 		}
331 331
 
@@ -349,15 +349,15 @@  discard block
 block discarded – undo
349 349
 	 *                      )
350 350
 	 *                  )
351 351
 	 */
352
-	protected function _get_templates( EE_Message_Template_Group $message_template_group ) {
352
+	protected function _get_templates(EE_Message_Template_Group $message_template_group) {
353 353
 		$templates = array();
354 354
 		$context_templates = $message_template_group->context_templates();
355
-		foreach ( $context_templates as $context => $template_fields ) {
356
-			foreach ( $template_fields as $template_field => $template_obj ) {
357
-				if ( ! $template_obj instanceof EE_Message_Template ) {
355
+		foreach ($context_templates as $context => $template_fields) {
356
+			foreach ($template_fields as $template_field => $template_obj) {
357
+				if ( ! $template_obj instanceof EE_Message_Template) {
358 358
 					continue;
359 359
 				}
360
-				$templates[ $template_field ][ $context ] = $template_obj->get( 'MTP_content' );
360
+				$templates[$template_field][$context] = $template_obj->get('MTP_content');
361 361
 			}
362 362
 		}
363 363
 		return $templates;
@@ -379,20 +379,20 @@  discard block
 block discarded – undo
379 379
 	 *                get added to the queue with EEM_Message::status_idle, unsuccessfully generated messages will get added
380 380
 	 *                to the queue as EEM_Message::status_failed.  Very rarely should "false" be returned from this method.
381 381
 	 */
382
-	protected function _assemble_messages( $addressees, $templates, EE_Message_Template_Group $message_template_group ) {
382
+	protected function _assemble_messages($addressees, $templates, EE_Message_Template_Group $message_template_group) {
383 383
 
384 384
 		//if templates are empty then get out because we can't generate anything.
385
-		if ( ! $templates ) {
385
+		if ( ! $templates) {
386 386
 			return false;
387 387
 		}
388 388
 
389 389
 		//We use this as the counter for generated messages because don't forget we may be executing this inside of a
390 390
 		//generation_queue.  So _ready_queue may have generated EE_Message objects already.
391 391
 		$generated_count = 0;
392
-		foreach ( $addressees as $context => $recipients ) {
393
-			foreach ( $recipients as $recipient ) {
394
-				$message = $this->_setup_message_object( $context, $recipient, $templates, $message_template_group );
395
-				if ( $message instanceof EE_Message ) {
392
+		foreach ($addressees as $context => $recipients) {
393
+			foreach ($recipients as $recipient) {
394
+				$message = $this->_setup_message_object($context, $recipient, $templates, $message_template_group);
395
+				if ($message instanceof EE_Message) {
396 396
 					$this->_ready_queue->add(
397 397
 						$message,
398 398
 						array(),
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 				}
404 404
 
405 405
 				//if the current MSG being generated is for a test send then we'll only use ONE message in the generation.
406
-				if ( $this->_generation_queue->get_message_repository()->is_test_send() ) {
406
+				if ($this->_generation_queue->get_message_repository()->is_test_send()) {
407 407
 					break 2;
408 408
 				}
409 409
 			}
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	) {
433 433
 		//stuff we already know
434 434
 		$transaction_id = $recipient->txn instanceof EE_Transaction ? $recipient->txn->ID() : 0;
435
-		$transaction_id = empty( $transaction_id ) && $this->_current_data_handler->txn instanceof EE_Transaction
435
+		$transaction_id = empty($transaction_id) && $this->_current_data_handler->txn instanceof EE_Transaction
436 436
 			? $this->_current_data_handler->txn->ID()
437 437
 			: $transaction_id;
438 438
 		$message_fields = array(
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 
446 446
 		//recipient id and type should be on the EE_Messages_Addressee object but if this is empty, let's try to grab the
447 447
 		//info from the att_obj found in the EE_Messages_Addressee object.
448
-		if ( empty( $recipient->recipient_id ) || empty( $recipient->recipient_type ) ) {
448
+		if (empty($recipient->recipient_id) || empty($recipient->recipient_type)) {
449 449
 			$message_fields['MSG_recipient_ID'] = $recipient->att_obj instanceof EE_Attendee
450 450
 				? $recipient->att_obj->ID()
451 451
 				: 0;
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 			$message_fields['MSG_recipient_ID'] = $recipient->recipient_id;
455 455
 			$message_fields['MSG_recipient_type'] = $recipient->recipient_type;
456 456
 		}
457
-		$message = EE_Message_Factory::create( $message_fields );
457
+		$message = EE_Message_Factory::create($message_fields);
458 458
 
459 459
 		//grab valid shortcodes for shortcode parser
460 460
 		$mt_shortcodes = $this->_current_message_type->get_valid_shortcodes();
@@ -462,43 +462,43 @@  discard block
 block discarded – undo
462 462
 
463 463
 		//if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because that means this
464 464
 		//context is turned off) EXCEPT if we're previewing
465
-		if ( empty( $templates['to'][ $context ] )
465
+		if (empty($templates['to'][$context])
466 466
 		     && ! $this->_generation_queue->get_message_repository()->is_preview()
467
-		     && ! $this->_current_messenger->allow_empty_to_field() ) {
467
+		     && ! $this->_current_messenger->allow_empty_to_field()) {
468 468
 			//we silently exit here and do NOT record a fail because the message is "turned off" by having no "to" field.
469 469
 			return false;
470 470
 		}
471 471
 		$error_msg = array();
472
-		foreach ( $templates as $field => $field_context ) {
472
+		foreach ($templates as $field => $field_context) {
473 473
 			$error_msg = array();
474 474
 			//let's setup the valid shortcodes for the incoming context.
475
-			$valid_shortcodes = $mt_shortcodes[ $context ];
475
+			$valid_shortcodes = $mt_shortcodes[$context];
476 476
 			//merge in valid shortcodes for the field.
477
-			$shortcodes = isset($m_shortcodes[ $field ]) ? $m_shortcodes[ $field ] : $valid_shortcodes;
478
-			if ( isset( $templates[ $field ][ $context ] ) ) {
477
+			$shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes;
478
+			if (isset($templates[$field][$context])) {
479 479
 				//prefix field.
480
-				$column_name = 'MSG_' . $field;
480
+				$column_name = 'MSG_'.$field;
481 481
 				try {
482 482
 					$content = $this->_shortcode_parser->parse_message_template(
483
-						$templates[ $field ][ $context ],
483
+						$templates[$field][$context],
484 484
 						$recipient,
485 485
 						$shortcodes,
486 486
 						$this->_current_message_type,
487 487
 						$this->_current_messenger,
488 488
 						$message );
489
-					$message->set_field_or_extra_meta( $column_name, $content );
490
-				} catch ( EE_Error $e ) {
491
-					$error_msg[] = sprintf( __( 'There was a problem generating the content for the field %s: %s', 'event_espresso' ), $field, $e->getMessage() );
492
-					$message->set_STS_ID( EEM_Message::status_failed );
489
+					$message->set_field_or_extra_meta($column_name, $content);
490
+				} catch (EE_Error $e) {
491
+					$error_msg[] = sprintf(__('There was a problem generating the content for the field %s: %s', 'event_espresso'), $field, $e->getMessage());
492
+					$message->set_STS_ID(EEM_Message::status_failed);
493 493
 				}
494 494
 			}
495 495
 		}
496 496
 
497
-		if ( $message->STS_ID() === EEM_Message::status_failed ) {
498
-			$error_msg = __( 'There were problems generating this message:', 'event_espresso' ) . "\n" . implode( "\n", $error_msg );
499
-			$message->set_error_message( $error_msg );
497
+		if ($message->STS_ID() === EEM_Message::status_failed) {
498
+			$error_msg = __('There were problems generating this message:', 'event_espresso')."\n".implode("\n", $error_msg);
499
+			$message->set_error_message($error_msg);
500 500
 		} else {
501
-			$message->set_STS_ID( EEM_Message::status_idle );
501
+			$message->set_STS_ID(EEM_Message::status_idle);
502 502
 		}
503 503
 		return $message;
504 504
 	}
@@ -532,14 +532,14 @@  discard block
 block discarded – undo
532 532
 	 * @param array $addressees  Keys correspond to contexts for the message type and values are EE_Messages_Addressee[]
533 533
 	 * @return bool
534 534
 	 */
535
-	protected function _valid_addressees( $addressees ) {
536
-		if ( ! $addressees || ! is_array( $addressees ) ) {
535
+	protected function _valid_addressees($addressees) {
536
+		if ( ! $addressees || ! is_array($addressees)) {
537 537
 			return false;
538 538
 		}
539 539
 
540
-		foreach( $addressees as $addressee_array ) {
541
-			foreach ( $addressee_array as $addressee ) {
542
-				if ( ! $addressee instanceof EE_Messages_Addressee ) {
540
+		foreach ($addressees as $addressee_array) {
541
+			foreach ($addressee_array as $addressee) {
542
+				if ( ! $addressee instanceof EE_Messages_Addressee) {
543 543
 					return false;
544 544
 				}
545 545
 			}
@@ -560,19 +560,19 @@  discard block
 block discarded – undo
560 560
 	protected function _validate_messenger_and_message_type() {
561 561
 
562 562
 		//first are there any existing error messages?  If so then return.
563
-		if ( $this->_error_msg ) {
563
+		if ($this->_error_msg) {
564 564
 			return false;
565 565
 		}
566 566
 		/** @type EE_Message $message */
567 567
 		$message = $this->_generation_queue->get_message_repository()->current();
568 568
 		try {
569
-			$this->_current_messenger = $message->valid_messenger( true ) ? $message->messenger_object() : null;
570
-		} catch ( Exception $e ) {
569
+			$this->_current_messenger = $message->valid_messenger(true) ? $message->messenger_object() : null;
570
+		} catch (Exception $e) {
571 571
 			$this->_error_msg[] = $e->getMessage();
572 572
 		}
573 573
 		try {
574
-			$this->_current_message_type = $message->valid_message_type( true ) ? $message->message_type_object() : null;
575
-		} catch ( Exception $e ) {
574
+			$this->_current_message_type = $message->valid_message_type(true) ? $message->message_type_object() : null;
575
+		} catch (Exception $e) {
576 576
 			$this->_error_msg[] = $e->getMessage();
577 577
 		}
578 578
 
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 			     ! $this->_generation_queue->get_message_repository()->is_preview()
585 585
 			     && $this->_generation_queue->get_message_repository()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' )
586 586
 		) {
587
-			$this->_error_msg[] = __( 'There is no generation data for this message. Unable to generate.' );
587
+			$this->_error_msg[] = __('There is no generation data for this message. Unable to generate.');
588 588
 		}
589 589
 
590
-		return empty( $this->_error_msg );
590
+		return empty($this->_error_msg);
591 591
 	}
592 592
 
593 593
 
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 
605 605
 		//First, are there any existing error messages?  If so, return because if there were errors elsewhere this can't
606 606
 		//be used anyways.
607
-		if ( $this->_error_msg ) {
607
+		if ($this->_error_msg) {
608 608
 			return false;
609 609
 		}
610 610
 
@@ -613,29 +613,29 @@  discard block
 block discarded – undo
613 613
 		/** @type EE_Messages_incoming_data $data_handler_class_name - well not really... just the class name actually */
614 614
 		$data_handler_class_name = $this->_generation_queue->get_message_repository()->get_data_handler()
615 615
 			? $this->_generation_queue->get_message_repository()->get_data_handler()
616
-			: 'EE_Messages_' .  $this->_current_message_type->get_data_handler( $generation_data ) . '_incoming_data';
616
+			: 'EE_Messages_'.$this->_current_message_type->get_data_handler($generation_data).'_incoming_data';
617 617
 
618 618
 		//If this EE_Message is for a preview, then let's switch out to the preview data handler.
619
-		if ( $this->_generation_queue->get_message_repository()->is_preview() ) {
620
-			$data_handler_class_name  = 'EE_Messages_Preview_incoming_data';
619
+		if ($this->_generation_queue->get_message_repository()->is_preview()) {
620
+			$data_handler_class_name = 'EE_Messages_Preview_incoming_data';
621 621
 		}
622 622
 
623 623
 		//First get the class name for the data handler (and also verifies it exists.
624
-		if ( ! class_exists( $data_handler_class_name ) ) {
624
+		if ( ! class_exists($data_handler_class_name)) {
625 625
 			$this->_error_msg[] = sprintf(
626
-				__( 'The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes.  Looking for %s.', 'event_espresso' ),
626
+				__('The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes.  Looking for %s.', 'event_espresso'),
627 627
 				$data_handler_class_name
628 628
 			);
629 629
 			return false;
630 630
 		}
631 631
 
632 632
 		//convert generation_data for data_handler_instantiation.
633
-		$generation_data = $data_handler_class_name::convert_data_from_persistent_storage( $generation_data );
633
+		$generation_data = $data_handler_class_name::convert_data_from_persistent_storage($generation_data);
634 634
 
635 635
 		//note, this may set error messages as well.
636
-		$this->_set_data_handler( $generation_data, $data_handler_class_name );
636
+		$this->_set_data_handler($generation_data, $data_handler_class_name);
637 637
 
638
-		return empty( $this->_error_msg );
638
+		return empty($this->_error_msg);
639 639
 	}
640 640
 
641 641
 
@@ -652,16 +652,16 @@  discard block
 block discarded – undo
652 652
 	 *
653 653
 	 * @return void.
654 654
 	 */
655
-	protected function _set_data_handler( $generating_data, $data_handler_class_name ) {
655
+	protected function _set_data_handler($generating_data, $data_handler_class_name) {
656 656
 		//valid classname for the data handler.  Now let's setup the key for the data handler repository to see if there
657 657
 		//is already a ready data handler in the repository.
658
-		$this->_current_data_handler = $this->_data_handler_collection->get_by_key( $this->_data_handler_collection->get_key( $data_handler_class_name, $generating_data ) );
659
-		if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data ) {
658
+		$this->_current_data_handler = $this->_data_handler_collection->get_by_key($this->_data_handler_collection->get_key($data_handler_class_name, $generating_data));
659
+		if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data) {
660 660
 			//no saved data_handler in the repo so let's set one up and add it to the repo.
661 661
 			try {
662
-				$this->_current_data_handler = new $data_handler_class_name( $generating_data );
663
-				$this->_data_handler_collection->add( $this->_current_data_handler, $generating_data );
664
-			} catch( EE_Error $e ) {
662
+				$this->_current_data_handler = new $data_handler_class_name($generating_data);
663
+				$this->_data_handler_collection->add($this->_current_data_handler, $generating_data);
664
+			} catch (EE_Error $e) {
665 665
 				$this->_error_msg[] = $e->get_error();
666 666
 			}
667 667
 		}
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
 	 * @param bool                   $preview Indicate whether this is being used for a preview or not.
682 682
 	 * @return mixed Prepped data for persisting to the queue.  false is returned if unable to prep data.
683 683
 	 */
684
-	protected function _prepare_data_for_queue( EE_Message_To_Generate $message_to_generate, $preview ) {
684
+	protected function _prepare_data_for_queue(EE_Message_To_Generate $message_to_generate, $preview) {
685 685
 		/** @type EE_Messages_incoming_data $data_handler - well not really... just the class name actually */
686
-		$data_handler = $message_to_generate->get_data_handler_class_name( $preview );
687
-		if ( ! $message_to_generate->valid() ) {
686
+		$data_handler = $message_to_generate->get_data_handler_class_name($preview);
687
+		if ( ! $message_to_generate->valid()) {
688 688
 			return false; //unable to get the data because the info in the EE_Message_To_Generate class is invalid.
689 689
 		}
690
-		return $data_handler::convert_data_for_persistent_storage( $message_to_generate->data() );
690
+		return $data_handler::convert_data_for_persistent_storage($message_to_generate->data());
691 691
 	}
692 692
 
693 693
 
@@ -700,26 +700,26 @@  discard block
 block discarded – undo
700 700
 	 * @param EE_Message_To_Generate $message_to_generate
701 701
 	 * @param bool                   $test_send Whether this is just a test send or not.  Typically used for previews.
702 702
 	 */
703
-	public function create_and_add_message_to_queue( EE_Message_To_Generate $message_to_generate, $test_send = false ) {
703
+	public function create_and_add_message_to_queue(EE_Message_To_Generate $message_to_generate, $test_send = false) {
704 704
 		//prep data
705
-		$data = $this->_prepare_data_for_queue( $message_to_generate, $message_to_generate->preview() );
705
+		$data = $this->_prepare_data_for_queue($message_to_generate, $message_to_generate->preview());
706 706
 
707 707
 		$message = $message_to_generate->get_EE_Message();
708 708
 
709 709
 		//is there a GRP_ID in the request?
710
-		if ( $GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID' ) ) {
711
-			$message->set_GRP_ID( $GRP_ID );
710
+		if ($GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID')) {
711
+			$message->set_GRP_ID($GRP_ID);
712 712
 		}
713 713
 
714
-		if ( $data === false ) {
715
-			$message->set_STS_ID( EEM_Message::status_failed );
716
-			$message->set_error_message( __( 'Unable to prepare data for persistence to the database.', 'event_espresso' ) );
714
+		if ($data === false) {
715
+			$message->set_STS_ID(EEM_Message::status_failed);
716
+			$message->set_error_message(__('Unable to prepare data for persistence to the database.', 'event_espresso'));
717 717
 		} else {
718 718
 			//make sure that the data handler is cached on the message as well
719 719
 			$data['data_handler_class_name'] = $message_to_generate->get_data_handler_class_name();
720 720
 		}
721 721
 
722
-		$this->_generation_queue->add( $message, $data, $message_to_generate->preview(), $test_send );
722
+		$this->_generation_queue->add($message, $data, $message_to_generate->preview(), $test_send);
723 723
 	}
724 724
 
725 725
 
Please login to merge, or discard this patch.
core/EE_System.core.php 1 patch
Spacing   +267 added lines, -267 removed lines patch added patch discarded remove patch
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 	 * @param  \EE_Registry        $Registry
89 89
 	 * @return \EE_System
90 90
 	 */
91
-	public static function instance( EE_Registry $Registry = null ) {
91
+	public static function instance(EE_Registry $Registry = null) {
92 92
 		// check if class object is instantiated
93
-		if ( ! self::$_instance instanceof EE_System ) {
94
-			self::$_instance = new self( $Registry );
93
+		if ( ! self::$_instance instanceof EE_System) {
94
+			self::$_instance = new self($Registry);
95 95
 		}
96 96
 		return self::$_instance;
97 97
 	}
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 * resets the instance and returns it
102 102
 	 * @return EE_System
103 103
 	 */
104
-	public static function reset(){
104
+	public static function reset() {
105 105
 		self::$_instance->_req_type = NULL;
106 106
 
107 107
 		//make sure none of the old hooks are left hanging around
108
-		remove_all_actions( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' );
108
+		remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
109 109
 
110 110
 		//we need to reset the migration manager in order for it to detect DMSs properly
111 111
 		EE_Data_Migration_Manager::reset();
@@ -125,28 +125,28 @@  discard block
 block discarded – undo
125 125
 	 * @access private
126 126
 	 * @param  \EE_Registry        $Registry
127 127
 	 */
128
-	private function __construct( EE_Registry $Registry ) {
128
+	private function __construct(EE_Registry $Registry) {
129 129
 		$this->registry = $Registry;
130
-		do_action( 'AHEE__EE_System__construct__begin', $this );
130
+		do_action('AHEE__EE_System__construct__begin', $this);
131 131
 		// allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
132
-		add_action( 'AHEE__EE_Bootstrap__load_espresso_addons', array( $this, 'load_espresso_addons' ) );
132
+		add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons'));
133 133
 		// when an ee addon is activated, we want to call the core hook(s) again
134 134
 		// because the newly-activated addon didn't get a chance to run at all
135
-		add_action( 'activate_plugin', array( $this, 'load_espresso_addons' ), 1 );
135
+		add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
136 136
 		// detect whether install or upgrade
137
-		add_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array( $this, 'detect_activations_or_upgrades' ), 3 );
137
+		add_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), 3);
138 138
 		// load EE_Config, EE_Textdomain, etc
139
-		add_action( 'AHEE__EE_Bootstrap__load_core_configuration', array( $this, 'load_core_configuration' ), 5 );
139
+		add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5);
140 140
 		// load EE_Config, EE_Textdomain, etc
141
-		add_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array( $this, 'register_shortcodes_modules_and_widgets' ), 7 );
141
+		add_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', array($this, 'register_shortcodes_modules_and_widgets'), 7);
142 142
 		// you wanna get going? I wanna get going... let's get going!
143
-		add_action( 'AHEE__EE_Bootstrap__brew_espresso', array( $this, 'brew_espresso' ), 9 );
143
+		add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9);
144 144
 		//other housekeeping
145 145
 		//exclude EE critical pages from wp_list_pages
146
-		add_filter( 'wp_list_pages_excludes', array( $this, 'remove_pages_from_wp_list_pages' ), 10 );
146
+		add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10);
147 147
 		// ALL EE Addons should use the following hook point to attach their initial setup too
148 148
 		// it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
149
-		do_action( 'AHEE__EE_System__construct__complete', $this );
149
+		do_action('AHEE__EE_System__construct__complete', $this);
150 150
 	}
151 151
 
152 152
 
@@ -166,30 +166,30 @@  discard block
 block discarded – undo
166 166
 	public function load_espresso_addons() {
167 167
 		// set autoloaders for all of the classes implementing EEI_Plugin_API
168 168
 		// which provide helpers for EE plugin authors to more easily register certain components with EE.
169
-		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'plugin_api' );
169
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api');
170 170
 		//load and setup EE_Capabilities
171
-		$this->registry->load_core( 'Capabilities' );
171
+		$this->registry->load_core('Capabilities');
172 172
 		//caps need to be initialized on every request so that capability maps are set.
173 173
 		//@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
174 174
 		$this->registry->CAP->init_caps();
175
-		do_action( 'AHEE__EE_System__load_espresso_addons' );
175
+		do_action('AHEE__EE_System__load_espresso_addons');
176 176
 		//if the WP API basic auth plugin isn't already loaded, load it now.
177 177
 		//We want it for mobile apps. Just include the entire plugin
178 178
 		//also, don't load the basic auth when a plugin is getting activated, because
179 179
 		//it could be the basic auth plugin, and it doesn't check if its methods are already defined
180 180
 		//and causes a fatal error
181
-		if( !function_exists( 'json_basic_auth_handler' )
182
-			&& ! function_exists( 'json_basic_auth_error' )
181
+		if ( ! function_exists('json_basic_auth_handler')
182
+			&& ! function_exists('json_basic_auth_error')
183 183
 			&& ! (
184
-				isset( $_GET[ 'action'] )
185
-				&& in_array( $_GET[ 'action' ], array( 'activate', 'activate-selected' ) )
184
+				isset($_GET['action'])
185
+				&& in_array($_GET['action'], array('activate', 'activate-selected'))
186 186
 			)
187 187
 			&& ! (
188
-				isset( $_GET['activate' ] )
189
-				&& $_GET['activate' ] === 'true'
188
+				isset($_GET['activate'])
189
+				&& $_GET['activate'] === 'true'
190 190
 			)
191 191
 		) {
192
-			include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
192
+			include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php';
193 193
 		}
194 194
 	}
195 195
 
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 	 * @access public
206 206
 	 * @return void
207 207
 	 */
208
-	public function detect_activations_or_upgrades(){
208
+	public function detect_activations_or_upgrades() {
209 209
 		//first off: let's make sure to handle core
210 210
 		$this->detect_if_activation_or_upgrade();
211
-		foreach($this->registry->addons as $addon){
211
+		foreach ($this->registry->addons as $addon) {
212 212
 			//detect teh request type for that addon
213 213
 			$addon->detect_activation_or_upgrade();
214 214
 		}
@@ -229,41 +229,41 @@  discard block
 block discarded – undo
229 229
 		do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
230 230
 
231 231
 		// load M-Mode class
232
-		$this->registry->load_core( 'Maintenance_Mode' );
232
+		$this->registry->load_core('Maintenance_Mode');
233 233
 		// check if db has been updated, or if its a brand-new installation
234 234
 
235 235
 		$espresso_db_update = $this->fix_espresso_db_upgrade_option();
236
-		$request_type =  $this->detect_req_type($espresso_db_update);
236
+		$request_type = $this->detect_req_type($espresso_db_update);
237 237
 		//EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
238 238
 
239
-		switch($request_type){
239
+		switch ($request_type) {
240 240
 			case EE_System::req_type_new_activation:
241
-				do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__new_activation' );
242
-				$this->_handle_core_version_change( $espresso_db_update );
241
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
242
+				$this->_handle_core_version_change($espresso_db_update);
243 243
 				break;
244 244
 			case EE_System::req_type_reactivation:
245
-				do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__reactivation' );
246
-				$this->_handle_core_version_change( $espresso_db_update );
245
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
246
+				$this->_handle_core_version_change($espresso_db_update);
247 247
 				break;
248 248
 			case EE_System::req_type_upgrade:
249
-				do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__upgrade' );
249
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
250 250
 				//migrations may be required now that we've upgraded
251 251
 				EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
252
-				$this->_handle_core_version_change( $espresso_db_update );
252
+				$this->_handle_core_version_change($espresso_db_update);
253 253
 //				echo "done upgrade";die;
254 254
 				break;
255 255
 			case EE_System::req_type_downgrade:
256
-				do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__downgrade' );
256
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
257 257
 				//its possible migrations are no longer required
258 258
 				EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
259
-				$this->_handle_core_version_change( $espresso_db_update );
259
+				$this->_handle_core_version_change($espresso_db_update);
260 260
 				break;
261 261
 			case EE_System::req_type_normal:
262 262
 			default:
263 263
 //				$this->_maybe_redirect_to_ee_about();
264 264
 				break;
265 265
 		}
266
-		do_action( 'AHEE__EE_System__detect_if_activation_or_upgrade__complete' );
266
+		do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
267 267
 	}
268 268
 
269 269
 	/**
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
 	 * initializing the database later during the request
272 272
 	 * @param array $espresso_db_update
273 273
 	 */
274
-	protected function _handle_core_version_change( $espresso_db_update ){
275
-		$this->update_list_of_installed_versions( $espresso_db_update );
274
+	protected function _handle_core_version_change($espresso_db_update) {
275
+		$this->update_list_of_installed_versions($espresso_db_update);
276 276
 		//get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
277
-		add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ));
277
+		add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required'));
278 278
 	}
279 279
 
280 280
 
@@ -289,44 +289,44 @@  discard block
 block discarded – undo
289 289
 	 * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table
290 290
 	 * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
291 291
 	 */
292
-	private function fix_espresso_db_upgrade_option($espresso_db_update = null){
293
-		do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update );
294
-		if( ! $espresso_db_update){
295
-			$espresso_db_update = get_option( 'espresso_db_update' );
292
+	private function fix_espresso_db_upgrade_option($espresso_db_update = null) {
293
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
294
+		if ( ! $espresso_db_update) {
295
+			$espresso_db_update = get_option('espresso_db_update');
296 296
 		}
297 297
 		// check that option is an array
298
-		if( ! is_array( $espresso_db_update )) {
298
+		if ( ! is_array($espresso_db_update)) {
299 299
 			// if option is FALSE, then it never existed
300
-			if ( $espresso_db_update === FALSE ) {
300
+			if ($espresso_db_update === FALSE) {
301 301
 				// make $espresso_db_update an array and save option with autoload OFF
302
-				$espresso_db_update =  array();
303
-				add_option( 'espresso_db_update', $espresso_db_update, '', 'no' );
302
+				$espresso_db_update = array();
303
+				add_option('espresso_db_update', $espresso_db_update, '', 'no');
304 304
 			} else {
305 305
 				// option is NOT FALSE but also is NOT an array, so make it an array and save it
306
-				$espresso_db_update =  array( $espresso_db_update=>array() );
307
-				update_option( 'espresso_db_update', $espresso_db_update );
306
+				$espresso_db_update = array($espresso_db_update=>array());
307
+				update_option('espresso_db_update', $espresso_db_update);
308 308
 			}
309
-		}else{
309
+		} else {
310 310
 			$corrected_db_update = array();
311 311
 			//if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
312
-			foreach($espresso_db_update as $should_be_version_string => $should_be_array){
313
-				if(is_int($should_be_version_string) && ! is_array($should_be_array)){
312
+			foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
313
+				if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
314 314
 					//the key is an int, and the value IS NOT an array
315 315
 					//so it must be numerically-indexed, where values are versions installed...
316 316
 					//fix it!
317 317
 					$version_string = $should_be_array;
318 318
 					$corrected_db_update[$version_string] = array('unknown-date');
319
-				}else{
319
+				} else {
320 320
 					//ok it checks out
321 321
 					$corrected_db_update[$should_be_version_string] = $should_be_array;
322 322
 				}
323 323
 			}
324 324
 			$espresso_db_update = $corrected_db_update;
325
-			update_option( 'espresso_db_update', $espresso_db_update );
325
+			update_option('espresso_db_update', $espresso_db_update);
326 326
 
327 327
 		}
328 328
 
329
-		do_action( 'FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update );
329
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
330 330
 		return $espresso_db_update;
331 331
 	}
332 332
 
@@ -346,34 +346,34 @@  discard block
 block discarded – undo
346 346
 	 * so we prefer to only do it when necessary
347 347
 	 * @return void
348 348
 	 */
349
-	public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){
349
+	public function initialize_db_if_no_migrations_required($initialize_addons_too = FALSE, $verify_schema = true) {
350 350
 		$request_type = $this->detect_req_type();
351 351
 		//only initialize system if we're not in maintenance mode.
352
-		if( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){
353
-			update_option( 'ee_flush_rewrite_rules', TRUE );
352
+		if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
353
+			update_option('ee_flush_rewrite_rules', TRUE);
354 354
 
355
-			if( $verify_schema ) {
355
+			if ($verify_schema) {
356 356
 				EEH_Activation::initialize_db_and_folders();
357 357
 			}
358 358
 			EEH_Activation::initialize_db_content();
359 359
 			EEH_Activation::system_initialization();
360
-			if( $initialize_addons_too ) {
360
+			if ($initialize_addons_too) {
361 361
 				$this->initialize_addons();
362 362
 			}
363
-		}else{
364
-			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( 'Core' );
363
+		} else {
364
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
365 365
 		}
366
-		if ( $request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade ) {
367
-			add_action( 'AHEE__EE_System__load_CPTs_and_session__start', array( $this, 'redirect_to_about_ee' ), 9 );
366
+		if ($request_type == EE_System::req_type_new_activation || $request_type == EE_System::req_type_reactivation || $request_type == EE_System::req_type_upgrade) {
367
+			add_action('AHEE__EE_System__load_CPTs_and_session__start', array($this, 'redirect_to_about_ee'), 9);
368 368
 		}
369 369
 	}
370 370
 
371 371
 	/**
372 372
 	 * Initializes the db for all registered addons
373 373
 	 */
374
-	public function initialize_addons(){
374
+	public function initialize_addons() {
375 375
 		//foreach registered addon, make sure its db is up-to-date too
376
-		foreach($this->registry->addons as $addon){
376
+		foreach ($this->registry->addons as $addon) {
377 377
 			$addon->initialize_db_if_no_migrations_required();
378 378
 		}
379 379
 	}
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
 	 * @param 	string 	$current_version_to_add 	version to be added to the version history
386 386
 	 * @return 	boolean success as to whether or not this option was changed
387 387
 	 */
388
-	public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) {
389
-		if( ! $version_history ) {
388
+	public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) {
389
+		if ( ! $version_history) {
390 390
 			$version_history = $this->fix_espresso_db_upgrade_option($version_history);
391 391
 		}
392
-		if( $current_version_to_add == NULL){
392
+		if ($current_version_to_add == NULL) {
393 393
 			$current_version_to_add = espresso_version();
394 394
 		}
395
-		$version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() );
395
+		$version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
396 396
 		// re-save
397
-		return update_option( 'espresso_db_update', $version_history );
397
+		return update_option('espresso_db_update', $version_history);
398 398
 	}
399 399
 
400 400
 
@@ -411,10 +411,10 @@  discard block
 block discarded – undo
411 411
 	 *                            but still know if this is a new install or not
412 412
 	 * @return int one of the constants on EE_System::req_type_
413 413
 	 */
414
-	public function detect_req_type( $espresso_db_update = NULL ){
415
-		if ( $this->_req_type === NULL ){
416
-			$espresso_db_update = ! empty( $espresso_db_update ) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option();
417
-			$this->_req_type = $this->detect_req_type_given_activation_history( $espresso_db_update, 'ee_espresso_activation', espresso_version() );
414
+	public function detect_req_type($espresso_db_update = NULL) {
415
+		if ($this->_req_type === NULL) {
416
+			$espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update : $this->fix_espresso_db_upgrade_option();
417
+			$this->_req_type = $this->detect_req_type_given_activation_history($espresso_db_update, 'ee_espresso_activation', espresso_version());
418 418
 		}
419 419
 		return $this->_req_type;
420 420
 	}
@@ -430,39 +430,39 @@  discard block
 block discarded – undo
430 430
 	 * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version())
431 431
 	 * @return int one of the constants on EE_System::req_type_*
432 432
 	 */
433
-	public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){
434
-		$version_is_higher = self::_new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to );
435
-		if( $activation_history_for_addon ){
433
+	public static function detect_req_type_given_activation_history($activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to) {
434
+		$version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
435
+		if ($activation_history_for_addon) {
436 436
 			//it exists, so this isn't a completely new install
437 437
 			//check if this version already in that list of previously installed versions
438
-			if ( ! isset( $activation_history_for_addon[ $version_to_upgrade_to ] )) {
438
+			if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) {
439 439
 				//it a version we haven't seen before
440
-				if( $version_is_higher === 1 ){
440
+				if ($version_is_higher === 1) {
441 441
 					$req_type = EE_System::req_type_upgrade;
442
-				}else{
442
+				} else {
443 443
 					$req_type = EE_System::req_type_downgrade;
444 444
 				}
445
-				delete_option( $activation_indicator_option_name );
445
+				delete_option($activation_indicator_option_name);
446 446
 			} else {
447 447
 				// its not an update. maybe a reactivation?
448
-				if( get_option( $activation_indicator_option_name, FALSE ) ){
449
-					if ( $version_is_higher === -1 ){
448
+				if (get_option($activation_indicator_option_name, FALSE)) {
449
+					if ($version_is_higher === -1) {
450 450
 						$req_type = EE_System::req_type_downgrade;
451
-					}elseif( $version_is_higher === 0 ){
451
+					}elseif ($version_is_higher === 0) {
452 452
 						//we've seen this version before, but it's an activation. must be a reactivation
453 453
 						$req_type = EE_System::req_type_reactivation;
454
-					}else{//$version_is_higher === 1
454
+					} else {//$version_is_higher === 1
455 455
 						$req_type = EE_System::req_type_upgrade;
456 456
 					}
457
-					delete_option( $activation_indicator_option_name );
457
+					delete_option($activation_indicator_option_name);
458 458
 				} else {
459 459
 					//we've seen this version before and the activation indicate doesn't show it was just activated
460
-					if ( $version_is_higher === -1 ){
460
+					if ($version_is_higher === -1) {
461 461
 						$req_type = EE_System::req_type_downgrade;
462
-					}elseif( $version_is_higher === 0 ){
462
+					}elseif ($version_is_higher === 0) {
463 463
 						//we've seen this version before and it's not an activation. its normal request
464 464
 						$req_type = EE_System::req_type_normal;
465
-					}else{//$version_is_higher === 1
465
+					} else {//$version_is_higher === 1
466 466
 						$req_type = EE_System::req_type_upgrade;
467 467
 					}
468 468
 				}
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 		} else {
471 471
 			//brand new install
472 472
 			$req_type = EE_System::req_type_new_activation;
473
-			delete_option( $activation_indicator_option_name );
473
+			delete_option($activation_indicator_option_name);
474 474
 		}
475 475
 		return $req_type;
476 476
 	}
@@ -488,30 +488,30 @@  discard block
 block discarded – undo
488 488
 	 *		0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
489 489
 	 *		1 if $version_to_upgrade_to is HIGHER (upgrade) ;
490 490
 	 */
491
-	protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){
491
+	protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) {
492 492
 		//find the most recently-activated version
493 493
 		$most_recently_active_version_activation = '1970-01-01 00:00:00';
494 494
 		$most_recently_active_version = '0.0.0.dev.000';
495
-		if( is_array( $activation_history_for_addon ) ){
496
-			foreach( $activation_history_for_addon as $version => $times_activated ){
495
+		if (is_array($activation_history_for_addon)) {
496
+			foreach ($activation_history_for_addon as $version => $times_activated) {
497 497
 				//check there is a record of when this version was activated. Otherwise,
498 498
 				//mark it as unknown
499
-				if( ! $times_activated ){
500
-					$times_activated = array( 'unknown-date');
499
+				if ( ! $times_activated) {
500
+					$times_activated = array('unknown-date');
501 501
 				}
502
-				if( is_string( $times_activated ) ){
503
-					$times_activated = array( $times_activated );
502
+				if (is_string($times_activated)) {
503
+					$times_activated = array($times_activated);
504 504
 				}
505
-				foreach( $times_activated as $an_activation ){
506
-					if( $an_activation != 'unknown-date' &&
507
-							$an_activation > $most_recently_active_version_activation  ){
505
+				foreach ($times_activated as $an_activation) {
506
+					if ($an_activation != 'unknown-date' &&
507
+							$an_activation > $most_recently_active_version_activation) {
508 508
 						$most_recently_active_version = $version;
509 509
 						$most_recently_active_version_activation = $an_activation == 'unknown-date' ? '1970-01-01 00:00:00' : $an_activation;
510 510
 					}
511 511
 				}
512 512
 			}
513 513
 		}
514
-		return version_compare( $version_to_upgrade_to, $most_recently_active_version );
514
+		return version_compare($version_to_upgrade_to, $most_recently_active_version);
515 515
 	}
516 516
 
517 517
 
@@ -521,24 +521,24 @@  discard block
 block discarded – undo
521 521
 	 * @return void
522 522
 	 */
523 523
 	public function redirect_to_about_ee() {
524
-		$notices = EE_Error::get_notices( FALSE );
524
+		$notices = EE_Error::get_notices(FALSE);
525 525
 		//if current user is an admin and it's not an ajax request
526 526
 		if (
527
-			$this->registry->CAP->current_user_can( 'manage_options', 'espresso_about_default' )
528
-			&& ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
529
-			&& ! isset( $notices[ 'errors' ] )
527
+			$this->registry->CAP->current_user_can('manage_options', 'espresso_about_default')
528
+			&& ! (defined('DOING_AJAX') && DOING_AJAX)
529
+			&& ! isset($notices['errors'])
530 530
 		) {
531
-			$query_params =  array( 'page' => 'espresso_about' );
531
+			$query_params = array('page' => 'espresso_about');
532 532
 
533
-			if ( EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation ) {
533
+			if (EE_System::instance()->detect_req_type() == EE_System::req_type_new_activation) {
534 534
 			    $query_params['new_activation'] = TRUE;
535 535
 			}
536 536
 
537
-			if ( EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation ) {
537
+			if (EE_System::instance()->detect_req_type() == EE_System::req_type_reactivation) {
538 538
 			    $query_params['reactivation'] = TRUE;
539 539
 			}
540
-			$url = add_query_arg( $query_params, admin_url( 'admin.php' ) );
541
-			wp_safe_redirect( $url );
540
+			$url = add_query_arg($query_params, admin_url('admin.php'));
541
+			wp_safe_redirect($url);
542 542
 			exit();
543 543
 		}
544 544
 	}
@@ -552,31 +552,31 @@  discard block
 block discarded – undo
552 552
 	 *
553 553
 	 * @return void
554 554
 	 */
555
-	public function load_core_configuration(){
556
-		do_action( 'AHEE__EE_System__load_core_configuration__begin', $this );
557
-		$this->registry->load_core( 'EE_Load_Textdomain' );
555
+	public function load_core_configuration() {
556
+		do_action('AHEE__EE_System__load_core_configuration__begin', $this);
557
+		$this->registry->load_core('EE_Load_Textdomain');
558 558
 		//load textdomain
559 559
 		EE_Load_Textdomain::load_textdomain();
560 560
 		// load and setup EE_Config and EE_Network_Config
561
-		$this->registry->load_core( 'Config' );
562
-		$this->registry->load_core( 'Network_Config' );
561
+		$this->registry->load_core('Config');
562
+		$this->registry->load_core('Network_Config');
563 563
 		// setup autoloaders
564 564
 		// enable logging?
565
-		if ( $this->registry->CFG->admin->use_full_logging ) {
566
-			$this->registry->load_core( 'Log' );
565
+		if ($this->registry->CFG->admin->use_full_logging) {
566
+			$this->registry->load_core('Log');
567 567
 		}
568 568
 		// check for activation errors
569
-		$activation_errors = get_option( 'ee_plugin_activation_errors', FALSE );
570
-		if ( $activation_errors ) {
571
-			EE_Error::add_error( $activation_errors, __FILE__, __FUNCTION__, __LINE__ );
572
-			update_option( 'ee_plugin_activation_errors', FALSE );
569
+		$activation_errors = get_option('ee_plugin_activation_errors', FALSE);
570
+		if ($activation_errors) {
571
+			EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
572
+			update_option('ee_plugin_activation_errors', FALSE);
573 573
 		}
574 574
 		// get model names
575 575
 		$this->_parse_model_names();
576 576
 
577 577
 		//load caf stuff a chance to play during the activation process too.
578 578
 		$this->_maybe_brew_regular();
579
-		do_action( 'AHEE__EE_System__load_core_configuration__complete', $this );
579
+		do_action('AHEE__EE_System__load_core_configuration__complete', $this);
580 580
 	}
581 581
 
582 582
 
@@ -585,23 +585,23 @@  discard block
 block discarded – undo
585 585
 	 *
586 586
 	 * @return void
587 587
 	 */
588
-	private function _parse_model_names(){
588
+	private function _parse_model_names() {
589 589
 		//get all the files in the EE_MODELS folder that end in .model.php
590
-		$models = glob( EE_MODELS.'*.model.php');
590
+		$models = glob(EE_MODELS.'*.model.php');
591 591
 		$model_names = array();
592 592
 		$non_abstract_db_models = array();
593
-		foreach( $models as $model ){
593
+		foreach ($models as $model) {
594 594
 			// get model classname
595
-			$classname = EEH_File::get_classname_from_filepath_with_standard_filename( $model );
596
-			$short_name = str_replace( 'EEM_', '', $classname );
595
+			$classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
596
+			$short_name = str_replace('EEM_', '', $classname);
597 597
 			$reflectionClass = new ReflectionClass($classname);
598
-			if( $reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()){
599
-				$non_abstract_db_models[ $short_name ] = $classname;
598
+			if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
599
+				$non_abstract_db_models[$short_name] = $classname;
600 600
 			}
601
-			$model_names[ $short_name ] = $classname;
601
+			$model_names[$short_name] = $classname;
602 602
 		}
603
-		$this->registry->models = apply_filters( 'FHEE__EE_System__parse_model_names', $model_names );
604
-		$this->registry->non_abstract_db_models = apply_filters( 'FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models );
603
+		$this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
604
+		$this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names', $non_abstract_db_models);
605 605
 	}
606 606
 
607 607
 
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
 	 * @return void
612 612
 	 */
613 613
 	private function _maybe_brew_regular() {
614
-		if (( ! defined( 'EE_DECAF' ) ||  EE_DECAF !== TRUE ) && is_readable( EE_CAFF_PATH . 'brewing_regular.php' )) {
615
-			require_once EE_CAFF_PATH . 'brewing_regular.php';
614
+		if (( ! defined('EE_DECAF') || EE_DECAF !== TRUE) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) {
615
+			require_once EE_CAFF_PATH.'brewing_regular.php';
616 616
 		}
617 617
 	}
618 618
 
@@ -629,9 +629,9 @@  discard block
 block discarded – undo
629 629
 	 * @return void
630 630
 	 */
631 631
 	public function register_shortcodes_modules_and_widgets() {
632
-		do_action( 'AHEE__EE_System__register_shortcodes_modules_and_widgets' );
632
+		do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
633 633
 		// check for addons using old hookpoint
634
-		if ( has_action( 'AHEE__EE_System__register_shortcodes_modules_and_addons' )) {
634
+		if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
635 635
 			$this->_incompatible_addon_error();
636 636
 		}
637 637
 	}
@@ -645,19 +645,19 @@  discard block
 block discarded – undo
645 645
 	*/
646 646
 	private function _incompatible_addon_error() {
647 647
 		// get array of classes hooking into here
648
-		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( 'AHEE__EE_System__register_shortcodes_modules_and_addons' );
649
-		if ( ! empty( $class_names )) {
650
-			$msg = __( 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso' );
648
+		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons');
649
+		if ( ! empty($class_names)) {
650
+			$msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', 'event_espresso');
651 651
 			$msg .= '<ul>';
652
-			foreach ( $class_names as $class_name ) {
653
-				$msg .= '<li><b>Event Espresso - ' . str_replace( array( 'EE_', 'EEM_', 'EED_', 'EES_', 'EEW_' ), '', $class_name ) . '</b></li>';
652
+			foreach ($class_names as $class_name) {
653
+				$msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', $class_name).'</b></li>';
654 654
 			}
655 655
 			$msg .= '</ul>';
656
-			$msg .= __( 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso' );
656
+			$msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', 'event_espresso');
657 657
 			// save list of incompatible addons to wp-options for later use
658
-			add_option( 'ee_incompatible_addons', $class_names, '', 'no' );
659
-			if ( is_admin() ) {
660
-				EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
658
+			add_option('ee_incompatible_addons', $class_names, '', 'no');
659
+			if (is_admin()) {
660
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
661 661
 			}
662 662
 		}
663 663
 	}
@@ -674,25 +674,25 @@  discard block
 block discarded – undo
674 674
 	 *
675 675
 	 * @return void
676 676
 	 */
677
-	public function brew_espresso(){
678
-		do_action( 'AHEE__EE_System__brew_espresso__begin', $this );
677
+	public function brew_espresso() {
678
+		do_action('AHEE__EE_System__brew_espresso__begin', $this);
679 679
 		// load some final core systems
680
-		add_action( 'init', array( $this, 'set_hooks_for_core' ), 1 );
681
-		add_action( 'init', array( $this, 'perform_activations_upgrades_and_migrations' ), 3 );
682
-		add_action( 'init', array( $this, 'load_CPTs_and_session' ), 5 );
683
-		add_action( 'init', array( $this, 'load_controllers' ), 7 );
684
-		add_action( 'init', array( $this, 'core_loaded_and_ready' ), 9 );
685
-		add_action( 'init', array( $this, 'initialize' ), 10 );
686
-		add_action( 'init', array( $this, 'initialize_last' ), 100 );
687
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 25 );
688
-		add_action( 'admin_bar_menu', array( $this, 'espresso_toolbar_items' ), 100 );
689
-
690
-		if ( is_admin() && apply_filters( 'FHEE__EE_System__brew_espresso__load_pue', TRUE )  ) {
680
+		add_action('init', array($this, 'set_hooks_for_core'), 1);
681
+		add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
682
+		add_action('init', array($this, 'load_CPTs_and_session'), 5);
683
+		add_action('init', array($this, 'load_controllers'), 7);
684
+		add_action('init', array($this, 'core_loaded_and_ready'), 9);
685
+		add_action('init', array($this, 'initialize'), 10);
686
+		add_action('init', array($this, 'initialize_last'), 100);
687
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 25);
688
+		add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100);
689
+
690
+		if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', TRUE)) {
691 691
 			// pew pew pew
692
-			$this->registry->load_core( 'PUE' );
693
-			do_action( 'AHEE__EE_System__brew_espresso__after_pue_init' );
692
+			$this->registry->load_core('PUE');
693
+			do_action('AHEE__EE_System__brew_espresso__after_pue_init');
694 694
 		}
695
-		do_action( 'AHEE__EE_System__brew_espresso__complete', $this );
695
+		do_action('AHEE__EE_System__brew_espresso__complete', $this);
696 696
 	}
697 697
 
698 698
 
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 	 */
707 707
 	public function set_hooks_for_core() {
708 708
 		$this->_deactivate_incompatible_addons();
709
-		do_action( 'AHEE__EE_System__set_hooks_for_core' );
709
+		do_action('AHEE__EE_System__set_hooks_for_core');
710 710
 	}
711 711
 
712 712
 
@@ -715,15 +715,15 @@  discard block
 block discarded – undo
715 715
 	 * Using the information gathered in EE_System::_incompatible_addon_error,
716 716
 	 * deactivates any addons considered incompatible with the current version of EE
717 717
 	 */
718
-	private function _deactivate_incompatible_addons(){
719
-		$incompatible_addons = get_option( 'ee_incompatible_addons', array() );
720
-		if ( ! empty( $incompatible_addons )) {
721
-			$active_plugins = get_option( 'active_plugins', array() );
722
-			foreach ( $active_plugins as $active_plugin ) {
723
-				foreach ( $incompatible_addons as $incompatible_addon ) {
724
-					if ( strpos( $active_plugin,  $incompatible_addon ) !== FALSE ) {
725
-						unset( $_GET['activate'] );
726
-						espresso_deactivate_plugin( $active_plugin );
718
+	private function _deactivate_incompatible_addons() {
719
+		$incompatible_addons = get_option('ee_incompatible_addons', array());
720
+		if ( ! empty($incompatible_addons)) {
721
+			$active_plugins = get_option('active_plugins', array());
722
+			foreach ($active_plugins as $active_plugin) {
723
+				foreach ($incompatible_addons as $incompatible_addon) {
724
+					if (strpos($active_plugin, $incompatible_addon) !== FALSE) {
725
+						unset($_GET['activate']);
726
+						espresso_deactivate_plugin($active_plugin);
727 727
 					}
728 728
 				}
729 729
 			}
@@ -740,10 +740,10 @@  discard block
 block discarded – undo
740 740
 	 */
741 741
 	public function perform_activations_upgrades_and_migrations() {
742 742
 		//first check if we had previously attempted to setup EE's directories but failed
743
-		if( EEH_Activation::upload_directories_incomplete() ) {
743
+		if (EEH_Activation::upload_directories_incomplete()) {
744 744
 			EEH_Activation::create_upload_directories();
745 745
 		}
746
-		do_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' );
746
+		do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
747 747
 	}
748 748
 
749 749
 
@@ -755,10 +755,10 @@  discard block
 block discarded – undo
755 755
 	 *  	@return 	void
756 756
 	 */
757 757
 	public function load_CPTs_and_session() {
758
-		do_action( 'AHEE__EE_System__load_CPTs_and_session__start' );
758
+		do_action('AHEE__EE_System__load_CPTs_and_session__start');
759 759
 		// register Custom Post Types
760
-		$this->registry->load_core( 'Register_CPTs' );
761
-		do_action( 'AHEE__EE_System__load_CPTs_and_session__complete' );
760
+		$this->registry->load_core('Register_CPTs');
761
+		do_action('AHEE__EE_System__load_CPTs_and_session__complete');
762 762
 	}
763 763
 
764 764
 
@@ -773,16 +773,16 @@  discard block
 block discarded – undo
773 773
 	* @return void
774 774
 	*/
775 775
 	public function load_controllers() {
776
-		do_action( 'AHEE__EE_System__load_controllers__start' );
776
+		do_action('AHEE__EE_System__load_controllers__start');
777 777
 		// let's get it started
778
-		if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level() ) {
779
-			do_action( 'AHEE__EE_System__load_controllers__load_front_controllers' );
780
-			$this->registry->load_core( 'Front_Controller', array(), false, true );
781
-		} else if ( ! EE_FRONT_AJAX ) {
782
-			do_action( 'AHEE__EE_System__load_controllers__load_admin_controllers' );
783
-			EE_Registry::instance()->load_core( 'Admin' );
778
+		if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
779
+			do_action('AHEE__EE_System__load_controllers__load_front_controllers');
780
+			$this->registry->load_core('Front_Controller', array(), false, true);
781
+		} else if ( ! EE_FRONT_AJAX) {
782
+			do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
783
+			EE_Registry::instance()->load_core('Admin');
784 784
 		}
785
-		do_action( 'AHEE__EE_System__load_controllers__complete' );
785
+		do_action('AHEE__EE_System__load_controllers__complete');
786 786
 	}
787 787
 
788 788
 
@@ -796,9 +796,9 @@  discard block
 block discarded – undo
796 796
 	* @return void
797 797
 	*/
798 798
 	public function core_loaded_and_ready() {
799
-		do_action( 'AHEE__EE_System__core_loaded_and_ready' );
800
-		do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' );
801
-		$this->registry->load_core( 'Session' );
799
+		do_action('AHEE__EE_System__core_loaded_and_ready');
800
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
801
+		$this->registry->load_core('Session');
802 802
 		//		add_action( 'wp_loaded', array( $this, 'set_hooks_for_shortcodes_modules_and_addons' ), 1 );
803 803
 	}
804 804
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 	* @return void
814 814
 	*/
815 815
 	public function initialize() {
816
-		do_action( 'AHEE__EE_System__initialize' );
816
+		do_action('AHEE__EE_System__initialize');
817 817
 	}
818 818
 
819 819
 
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 	* @return void
828 828
 	*/
829 829
 	public function initialize_last() {
830
-		do_action( 'AHEE__EE_System__initialize_last' );
830
+		do_action('AHEE__EE_System__initialize_last');
831 831
 	}
832 832
 
833 833
 
@@ -859,21 +859,21 @@  discard block
 block discarded – undo
859 859
 	*/
860 860
 	public static function do_not_cache() {
861 861
 		// set no cache constants
862
-		if ( ! defined( 'DONOTCACHEPAGE' ) ) {
863
-			define( 'DONOTCACHEPAGE', true );
862
+		if ( ! defined('DONOTCACHEPAGE')) {
863
+			define('DONOTCACHEPAGE', true);
864 864
 		}
865
-		if ( ! defined( 'DONOTCACHCEOBJECT' ) ) {
866
-			define( 'DONOTCACHCEOBJECT', true );
865
+		if ( ! defined('DONOTCACHCEOBJECT')) {
866
+			define('DONOTCACHCEOBJECT', true);
867 867
 		}
868
-		if ( ! defined( 'DONOTCACHEDB' ) ) {
869
-			define( 'DONOTCACHEDB', true );
868
+		if ( ! defined('DONOTCACHEDB')) {
869
+			define('DONOTCACHEDB', true);
870 870
 		}
871 871
 		// add no cache headers
872
-		add_action( 'send_headers' , array( 'EE_System', 'nocache_headers' ), 10 );
872
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
873 873
 		// plus a little extra for nginx and Google Chrome
874
-		add_filter( 'nocache_headers', array( 'EE_System', 'extra_nocache_headers' ), 10, 1 );
874
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
875 875
 		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
876
-		remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );
876
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
877 877
 	}
878 878
 
879 879
 
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 	 * @param $headers
886 886
 	 * @return    array
887 887
 	 */
888
-	public static function extra_nocache_headers ( $headers ) {
888
+	public static function extra_nocache_headers($headers) {
889 889
 		// for NGINX
890 890
 		$headers['X-Accel-Expires'] = 0;
891 891
 		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
@@ -914,14 +914,14 @@  discard block
 block discarded – undo
914 914
 	 * @param  WP_Admin_Bar $admin_bar
915 915
 	 * @return void
916 916
 	 */
917
-	public function espresso_toolbar_items( WP_Admin_Bar $admin_bar ) {
917
+	public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) {
918 918
 
919 919
 		// if in full M-Mode, or its an AJAX request, or user is NOT an admin
920
-		if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! $this->registry->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) {
920
+		if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined('DOING_AJAX') || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')) {
921 921
 			return;
922 922
 		}
923 923
 
924
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
924
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
925 925
 		$menu_class = 'espresso_menu_item_class';
926 926
 		//we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL
927 927
 		//because they're only defined in each of their respective constructors
@@ -933,20 +933,20 @@  discard block
 block discarded – undo
933 933
 		//Top Level
934 934
 		$admin_bar->add_menu(array(
935 935
 				'id' => 'espresso-toolbar',
936
-				'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>',
936
+				'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'._x('Event Espresso', 'admin bar menu group label', 'event_espresso').'</span>',
937 937
 				'href' => $events_admin_url,
938 938
 				'meta' => array(
939 939
 						'title' => __('Event Espresso', 'event_espresso'),
940
-						'class' => $menu_class . 'first'
940
+						'class' => $menu_class.'first'
941 941
 				),
942 942
 		));
943 943
 
944 944
 		//Events
945
-		if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) {
945
+		if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) {
946 946
 			$admin_bar->add_menu(array(
947 947
 					'id' => 'espresso-toolbar-events',
948 948
 					'parent' => 'espresso-toolbar',
949
-					'title' => __( 'Events', 'event_espresso' ),
949
+					'title' => __('Events', 'event_espresso'),
950 950
 					'href' => $events_admin_url,
951 951
 					'meta' => array(
952 952
 							'title' => __('Events', 'event_espresso'),
@@ -957,13 +957,13 @@  discard block
 block discarded – undo
957 957
 		}
958 958
 
959 959
 
960
-		if ( $this->registry->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) {
960
+		if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) {
961 961
 			//Events Add New
962 962
 			$admin_bar->add_menu(array(
963 963
 					'id' => 'espresso-toolbar-events-new',
964 964
 					'parent' => 'espresso-toolbar-events',
965 965
 					'title' => __('Add New', 'event_espresso'),
966
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ),
966
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'create_new'), $events_admin_url),
967 967
 					'meta' => array(
968 968
 							'title' => __('Add New', 'event_espresso'),
969 969
 							'target' => '',
@@ -972,18 +972,18 @@  discard block
 block discarded – undo
972 972
 			));
973 973
 		}
974 974
 
975
-		if ( is_single() && ( get_post_type() == 'espresso_events' ) ) {
975
+		if (is_single() && (get_post_type() == 'espresso_events')) {
976 976
 
977 977
 			//Current post
978 978
 			global $post;
979 979
 
980
-	    	if ( $this->registry->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) {
980
+	    	if ($this->registry->CAP->current_user_can('ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)) {
981 981
 				//Events Edit Current Event
982 982
 				$admin_bar->add_menu(array(
983 983
 						'id' => 'espresso-toolbar-events-edit',
984 984
 						'parent' => 'espresso-toolbar-events',
985 985
 						'title' => __('Edit Event', 'event_espresso'),
986
-						'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ),
986
+						'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$post->ID), $events_admin_url),
987 987
 						'meta' => array(
988 988
 								'title' => __('Edit Event', 'event_espresso'),
989 989
 								'target' => '',
@@ -995,11 +995,11 @@  discard block
 block discarded – undo
995 995
 		}
996 996
 
997 997
 		//Events View
998
-		if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) {
998
+		if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view')) {
999 999
 			$admin_bar->add_menu(array(
1000 1000
 					'id' => 'espresso-toolbar-events-view',
1001 1001
 					'parent' => 'espresso-toolbar-events',
1002
-					'title' => __( 'View', 'event_espresso' ),
1002
+					'title' => __('View', 'event_espresso'),
1003 1003
 					'href' => $events_admin_url,
1004 1004
 					'meta' => array(
1005 1005
 							'title' => __('View', 'event_espresso'),
@@ -1009,12 +1009,12 @@  discard block
 block discarded – undo
1009 1009
 			));
1010 1010
 		}
1011 1011
 
1012
-		if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) {
1012
+		if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) {
1013 1013
 			//Events View All
1014 1014
 			$admin_bar->add_menu(array(
1015 1015
 					'id' => 'espresso-toolbar-events-all',
1016 1016
 					'parent' => 'espresso-toolbar-events-view',
1017
-					'title' => __( 'All', 'event_espresso' ),
1017
+					'title' => __('All', 'event_espresso'),
1018 1018
 					'href' => $events_admin_url,
1019 1019
 					'meta' => array(
1020 1020
 							'title' => __('All', 'event_espresso'),
@@ -1025,13 +1025,13 @@  discard block
 block discarded – undo
1025 1025
 		}
1026 1026
 
1027 1027
 
1028
-		if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) {
1028
+		if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today')) {
1029 1029
 			//Events View Today
1030 1030
 			$admin_bar->add_menu(array(
1031 1031
 					'id' => 'espresso-toolbar-events-today',
1032 1032
 					'parent' => 'espresso-toolbar-events-view',
1033 1033
 					'title' => __('Today', 'event_espresso'),
1034
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ),
1034
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $events_admin_url),
1035 1035
 					'meta' => array(
1036 1036
 							'title' => __('Today', 'event_espresso'),
1037 1037
 							'target' => '',
@@ -1041,13 +1041,13 @@  discard block
 block discarded – undo
1041 1041
 		}
1042 1042
 
1043 1043
 
1044
-		if ( $this->registry->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) {
1044
+		if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month')) {
1045 1045
 			//Events View This Month
1046 1046
 			$admin_bar->add_menu(array(
1047 1047
 					'id' => 'espresso-toolbar-events-month',
1048 1048
 					'parent' => 'espresso-toolbar-events-view',
1049
-					'title' => __( 'This Month', 'event_espresso'),
1050
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ),
1049
+					'title' => __('This Month', 'event_espresso'),
1050
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $events_admin_url),
1051 1051
 					'meta' => array(
1052 1052
 							'title' => __('This Month', 'event_espresso'),
1053 1053
 							'target' => '',
@@ -1057,11 +1057,11 @@  discard block
 block discarded – undo
1057 1057
 		}
1058 1058
 
1059 1059
 		//Registration Overview
1060
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) {
1060
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations')) {
1061 1061
 			$admin_bar->add_menu(array(
1062 1062
 					'id' => 'espresso-toolbar-registrations',
1063 1063
 					'parent' => 'espresso-toolbar',
1064
-					'title' => __( 'Registrations', 'event_espresso' ),
1064
+					'title' => __('Registrations', 'event_espresso'),
1065 1065
 					'href' => $reg_admin_url,
1066 1066
 					'meta' => array(
1067 1067
 							'title' => __('Registrations', 'event_espresso'),
@@ -1072,12 +1072,12 @@  discard block
 block discarded – undo
1072 1072
 		}
1073 1073
 
1074 1074
 		//Registration Overview Today
1075
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) {
1075
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today')) {
1076 1076
 			$admin_bar->add_menu(array(
1077 1077
 					'id' => 'espresso-toolbar-registrations-today',
1078 1078
 					'parent' => 'espresso-toolbar-registrations',
1079
-					'title' => __( 'Today', 'event_espresso'),
1080
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ),
1079
+					'title' => __('Today', 'event_espresso'),
1080
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today'), $reg_admin_url),
1081 1081
 					'meta' => array(
1082 1082
 							'title' => __('Today', 'event_espresso'),
1083 1083
 							'target' => '',
@@ -1087,14 +1087,14 @@  discard block
 block discarded – undo
1087 1087
 		}
1088 1088
 
1089 1089
 		//Registration Overview Today Completed
1090
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) {
1090
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')) {
1091 1091
 			$admin_bar->add_menu(array(
1092 1092
 					'id' => 'espresso-toolbar-registrations-today-approved',
1093 1093
 					'parent' => 'espresso-toolbar-registrations-today',
1094
-					'title' => __( 'Approved', 'event_espresso' ),
1095
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ),
1094
+					'title' => __('Approved', 'event_espresso'),
1095
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url),
1096 1096
 					'meta' => array(
1097
-							'title' => __('Approved', 'event_espresso' ),
1097
+							'title' => __('Approved', 'event_espresso'),
1098 1098
 							'target' => '',
1099 1099
 							'class' => $menu_class
1100 1100
 					),
@@ -1102,14 +1102,14 @@  discard block
 block discarded – undo
1102 1102
 		}
1103 1103
 
1104 1104
 		//Registration Overview Today Pending\
1105
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) {
1105
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')) {
1106 1106
 			$admin_bar->add_menu(array(
1107 1107
 					'id' => 'espresso-toolbar-registrations-today-pending',
1108 1108
 					'parent' => 'espresso-toolbar-registrations-today',
1109
-					'title' => __( 'Pending', 'event_espresso' ),
1110
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ),
1109
+					'title' => __('Pending', 'event_espresso'),
1110
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url),
1111 1111
 					'meta' => array(
1112
-							'title' => __('Pending Payment', 'event_espresso' ),
1112
+							'title' => __('Pending Payment', 'event_espresso'),
1113 1113
 							'target' => '',
1114 1114
 							'class' => $menu_class
1115 1115
 					),
@@ -1117,14 +1117,14 @@  discard block
 block discarded – undo
1117 1117
 		}
1118 1118
 
1119 1119
 		//Registration Overview Today Incomplete
1120
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) {
1120
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')) {
1121 1121
 			$admin_bar->add_menu(array(
1122 1122
 					'id' => 'espresso-toolbar-registrations-today-not-approved',
1123 1123
 					'parent' => 'espresso-toolbar-registrations-today',
1124
-					'title' => __( 'Not Approved', 'event_espresso' ),
1125
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ),
1124
+					'title' => __('Not Approved', 'event_espresso'),
1125
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url),
1126 1126
 					'meta' => array(
1127
-							'title' => __('Not Approved', 'event_espresso' ),
1127
+							'title' => __('Not Approved', 'event_espresso'),
1128 1128
 							'target' => '',
1129 1129
 							'class' => $menu_class
1130 1130
 					),
@@ -1132,12 +1132,12 @@  discard block
 block discarded – undo
1132 1132
 		}
1133 1133
 
1134 1134
 		//Registration Overview Today Incomplete
1135
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) {
1135
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')) {
1136 1136
 			$admin_bar->add_menu(array(
1137 1137
 					'id' => 'espresso-toolbar-registrations-today-cancelled',
1138 1138
 					'parent' => 'espresso-toolbar-registrations-today',
1139
-					'title' => __( 'Cancelled', 'event_espresso'),
1140
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ),
1139
+					'title' => __('Cancelled', 'event_espresso'),
1140
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url),
1141 1141
 					'meta' => array(
1142 1142
 							'title' => __('Cancelled', 'event_espresso'),
1143 1143
 							'target' => '',
@@ -1147,12 +1147,12 @@  discard block
 block discarded – undo
1147 1147
 		}
1148 1148
 
1149 1149
 		//Registration Overview This Month
1150
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) {
1150
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month')) {
1151 1151
 			$admin_bar->add_menu(array(
1152 1152
 					'id' => 'espresso-toolbar-registrations-month',
1153 1153
 					'parent' => 'espresso-toolbar-registrations',
1154
-					'title' => __( 'This Month', 'event_espresso' ),
1155
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ),
1154
+					'title' => __('This Month', 'event_espresso'),
1155
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month'), $reg_admin_url),
1156 1156
 					'meta' => array(
1157 1157
 							'title' => __('This Month', 'event_espresso'),
1158 1158
 							'target' => '',
@@ -1162,12 +1162,12 @@  discard block
 block discarded – undo
1162 1162
 		}
1163 1163
 
1164 1164
 		//Registration Overview This Month Approved
1165
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) {
1165
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')) {
1166 1166
 			$admin_bar->add_menu(array(
1167 1167
 					'id' => 'espresso-toolbar-registrations-month-approved',
1168 1168
 					'parent' => 'espresso-toolbar-registrations-month',
1169
-					'title' => __( 'Approved', 'event_espresso' ),
1170
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ),
1169
+					'title' => __('Approved', 'event_espresso'),
1170
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved), $reg_admin_url),
1171 1171
 					'meta' => array(
1172 1172
 							'title' => __('Approved', 'event_espresso'),
1173 1173
 							'target' => '',
@@ -1177,12 +1177,12 @@  discard block
 block discarded – undo
1177 1177
 		}
1178 1178
 
1179 1179
 		//Registration Overview This Month Pending
1180
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) {
1180
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')) {
1181 1181
 			$admin_bar->add_menu(array(
1182 1182
 					'id' => 'espresso-toolbar-registrations-month-pending',
1183 1183
 					'parent' => 'espresso-toolbar-registrations-month',
1184
-					'title' => __( 'Pending', 'event_espresso'),
1185
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ),
1184
+					'title' => __('Pending', 'event_espresso'),
1185
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment), $reg_admin_url),
1186 1186
 					'meta' => array(
1187 1187
 							'title' => __('Pending', 'event_espresso'),
1188 1188
 							'target' => '',
@@ -1192,14 +1192,14 @@  discard block
 block discarded – undo
1192 1192
 		}
1193 1193
 
1194 1194
 		//Registration Overview This Month Not Approved
1195
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) {
1195
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')) {
1196 1196
 			$admin_bar->add_menu(array(
1197 1197
 					'id' => 'espresso-toolbar-registrations-month-not-approved',
1198 1198
 					'parent' => 'espresso-toolbar-registrations-month',
1199
-					'title' => __( 'Not Approved', 'event_espresso'),
1200
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ),
1199
+					'title' => __('Not Approved', 'event_espresso'),
1200
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved), $reg_admin_url),
1201 1201
 					'meta' => array(
1202
-							'title' => __('Not Approved', 'event_espresso' ),
1202
+							'title' => __('Not Approved', 'event_espresso'),
1203 1203
 							'target' => '',
1204 1204
 							'class' => $menu_class
1205 1205
 					),
@@ -1208,12 +1208,12 @@  discard block
 block discarded – undo
1208 1208
 
1209 1209
 
1210 1210
 		//Registration Overview This Month Cancelled
1211
-		if ( $this->registry->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) {
1211
+		if ($this->registry->CAP->current_user_can('ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')) {
1212 1212
 			$admin_bar->add_menu(array(
1213 1213
 					'id' => 'espresso-toolbar-registrations-month-cancelled',
1214 1214
 					'parent' => 'espresso-toolbar-registrations-month',
1215 1215
 					'title' => __('Cancelled', 'event_espresso'),
1216
-					'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ),
1216
+					'href' => EEH_URL::add_query_args_and_nonce(array('action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled), $reg_admin_url),
1217 1217
 					'meta' => array(
1218 1218
 							'title' => __('Cancelled', 'event_espresso'),
1219 1219
 							'target' => '',
@@ -1223,11 +1223,11 @@  discard block
 block discarded – undo
1223 1223
 		}
1224 1224
 
1225 1225
 		//Extensions & Services
1226
-		if ( $this->registry->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) {
1226
+		if ($this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')) {
1227 1227
 			$admin_bar->add_menu(array(
1228 1228
 					'id' => 'espresso-toolbar-extensions-and-services',
1229 1229
 					'parent' => 'espresso-toolbar',
1230
-					'title' => __( 'Extensions & Services', 'event_espresso' ),
1230
+					'title' => __('Extensions & Services', 'event_espresso'),
1231 1231
 					'href' => $extensions_admin_url,
1232 1232
 					'meta' => array(
1233 1233
 							'title' => __('Extensions & Services', 'event_espresso'),
@@ -1249,8 +1249,8 @@  discard block
 block discarded – undo
1249 1249
 	 * @param  array  $exclude_array any existing pages being excluded are in this array.
1250 1250
 	 * @return array
1251 1251
 	 */
1252
-	public function remove_pages_from_wp_list_pages( $exclude_array ) {
1253
-		return  array_merge( $exclude_array, $this->registry->CFG->core->get_critical_pages_array() );
1252
+	public function remove_pages_from_wp_list_pages($exclude_array) {
1253
+		return  array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1254 1254
 	}
1255 1255
 
1256 1256
 
@@ -1270,12 +1270,12 @@  discard block
 block discarded – undo
1270 1270
 	 */
1271 1271
 	public function wp_enqueue_scripts() {
1272 1272
 		// unlike other systems, EE_System_scripts loading is turned ON by default, but prior to the init hook, can be turned off via: add_filter( 'FHEE_load_EE_System_scripts', '__return_false' );
1273
-		if ( apply_filters( 'FHEE_load_EE_System_scripts', TRUE ) ) {
1273
+		if (apply_filters('FHEE_load_EE_System_scripts', TRUE)) {
1274 1274
 			// jquery_validate loading is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via:  add_filter( 'FHEE_load_jquery_validate', '__return_true' );
1275
-			if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) {
1275
+			if (apply_filters('FHEE_load_jquery_validate', FALSE)) {
1276 1276
 				// register jQuery Validate and additional methods
1277
-				wp_register_script( 'jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery' ), '1.15.0', TRUE );
1278
-				wp_register_script( 'jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', array( 'jquery', 'jquery-validate' ), '1.15.0', TRUE );
1277
+				wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.15.0', TRUE);
1278
+				wp_register_script('jquery-validate-extra-methods', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', array('jquery', 'jquery-validate'), '1.15.0', TRUE);
1279 1279
 			}
1280 1280
 		}
1281 1281
 	}
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Spacing   +391 added lines, -391 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
 
@@ -803,14 +803,14 @@  discard block
 block discarded – undo
803 803
 	 *  @return 	string
804 804
 	 */
805 805
 	public static function get_page_for_posts() {
806
-		$page_for_posts = get_option( 'page_for_posts' );
807
-		if ( ! $page_for_posts ) {
806
+		$page_for_posts = get_option('page_for_posts');
807
+		if ( ! $page_for_posts) {
808 808
 			return 'posts';
809 809
 		}
810 810
 		/** @type WPDB $wpdb */
811 811
 		global $wpdb;
812 812
 		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
813
-		return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts ));
813
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
814 814
 	}
815 815
 
816 816
 
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 	 */
828 828
 	public function register_shortcodes_and_modules() {
829 829
 		// allow shortcodes to register with WP and to set hooks for the rest of the system
830
-		EE_Registry::instance()->shortcodes =$this->_register_shortcodes();
830
+		EE_Registry::instance()->shortcodes = $this->_register_shortcodes();
831 831
 		// allow modules to set hooks for the rest of the system
832 832
 		EE_Registry::instance()->modules = $this->_register_modules();
833 833
 	}
@@ -859,21 +859,21 @@  discard block
 block discarded – undo
859 859
 	public function widgets_init() {
860 860
 		//only init widgets on admin pages when not in complete maintenance, and
861 861
 		//on frontend when not in any maintenance mode
862
-		if (( is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance)  || ! EE_Maintenance_Mode::instance()->level() ) {
862
+		if ((is_admin() && EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) || ! EE_Maintenance_Mode::instance()->level()) {
863 863
 			// grab list of installed widgets
864
-			$widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR );
864
+			$widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
865 865
 			// filter list of modules to register
866
-			$widgets_to_register = apply_filters( 'FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register );
866
+			$widgets_to_register = apply_filters('FHEE__EE_Config__register_widgets__widgets_to_register', $widgets_to_register);
867 867
 
868
-			if ( ! empty( $widgets_to_register ) ) {
868
+			if ( ! empty($widgets_to_register)) {
869 869
 				// cycle thru widget folders
870
-				foreach ( $widgets_to_register as $widget_path ) {
870
+				foreach ($widgets_to_register as $widget_path) {
871 871
 					// add to list of installed widget modules
872
-					EE_Config::register_ee_widget( $widget_path );
872
+					EE_Config::register_ee_widget($widget_path);
873 873
 				}
874 874
 			}
875 875
 			// filter list of installed modules
876
-			EE_Registry::instance()->widgets = apply_filters( 'FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets );
876
+			EE_Registry::instance()->widgets = apply_filters('FHEE__EE_Config__register_widgets__installed_widgets', EE_Registry::instance()->widgets);
877 877
 		}
878 878
 	}
879 879
 
@@ -886,54 +886,54 @@  discard block
 block discarded – undo
886 886
 	 *  @param 	string 	$widget_path - full path up to and including widget folder
887 887
 	 *  @return 	void
888 888
 	 */
889
-	public static function register_ee_widget( $widget_path = NULL ) {
890
-		do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path );
889
+	public static function register_ee_widget($widget_path = NULL) {
890
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
891 891
 		$widget_ext = '.widget.php';
892 892
 		// make all separators match
893
-		$widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS );
893
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
894 894
 		// does the file path INCLUDE the actual file name as part of the path ?
895
-		if ( strpos( $widget_path, $widget_ext ) !== FALSE ) {
895
+		if (strpos($widget_path, $widget_ext) !== FALSE) {
896 896
 			// grab and shortcode file name from directory name and break apart at dots
897
-			$file_name = explode( '.', basename( $widget_path ));
897
+			$file_name = explode('.', basename($widget_path));
898 898
 			// take first segment from file name pieces and remove class prefix if it exists
899
-			$widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0];
899
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
900 900
 			// sanitize shortcode directory name
901
-			$widget = sanitize_key( $widget );
901
+			$widget = sanitize_key($widget);
902 902
 			// now we need to rebuild the shortcode path
903
-			$widget_path = explode( DS, $widget_path );
903
+			$widget_path = explode(DS, $widget_path);
904 904
 			// remove last segment
905
-			array_pop( $widget_path );
905
+			array_pop($widget_path);
906 906
 			// glue it back together
907
-			$widget_path = implode( DS, $widget_path );
907
+			$widget_path = implode(DS, $widget_path);
908 908
 		} else {
909 909
 			// grab and sanitize widget directory name
910
-			$widget = sanitize_key( basename( $widget_path ));
910
+			$widget = sanitize_key(basename($widget_path));
911 911
 		}
912 912
 		// create classname from widget directory name
913
-		$widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget )));
913
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
914 914
 		// add class prefix
915
-		$widget_class = 'EEW_' . $widget;
915
+		$widget_class = 'EEW_'.$widget;
916 916
 		// does the widget exist ?
917
-		if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext )) {
917
+		if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) {
918 918
 			$msg = sprintf(
919
-				__( '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' ),
919
+				__('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'),
920 920
 				$widget_class,
921
-				$widget_path . DS . $widget_class . $widget_ext
921
+				$widget_path.DS.$widget_class.$widget_ext
922 922
 			);
923
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
923
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
924 924
 			return;
925 925
 		}
926 926
 		// load the widget class file
927
-		require_once( $widget_path . DS . $widget_class . $widget_ext );
927
+		require_once($widget_path.DS.$widget_class.$widget_ext);
928 928
 		// verify that class exists
929
-		if ( ! class_exists( $widget_class )) {
930
-			$msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class );
931
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
929
+		if ( ! class_exists($widget_class)) {
930
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
931
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
932 932
 			return;
933 933
 		}
934
-		register_widget( $widget_class );
934
+		register_widget($widget_class);
935 935
 		// add to array of registered widgets
936
-		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
936
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext;
937 937
 	}
938 938
 
939 939
 
@@ -946,18 +946,18 @@  discard block
 block discarded – undo
946 946
 	 */
947 947
 	private function _register_shortcodes() {
948 948
 		// grab list of installed shortcodes
949
-		$shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR );
949
+		$shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR);
950 950
 		// filter list of modules to register
951
-		$shortcodes_to_register = apply_filters( 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register );
952
-		if ( ! empty( $shortcodes_to_register ) ) {
951
+		$shortcodes_to_register = apply_filters('FHEE__EE_Config__register_shortcodes__shortcodes_to_register', $shortcodes_to_register);
952
+		if ( ! empty($shortcodes_to_register)) {
953 953
 			// cycle thru shortcode folders
954
-			foreach ( $shortcodes_to_register as $shortcode_path ) {
954
+			foreach ($shortcodes_to_register as $shortcode_path) {
955 955
 				// add to list of installed shortcode modules
956
-				EE_Config::register_shortcode( $shortcode_path );
956
+				EE_Config::register_shortcode($shortcode_path);
957 957
 			}
958 958
 		}
959 959
 		// filter list of installed modules
960
-		return apply_filters( 'FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes );
960
+		return apply_filters('FHEE__EE_Config___register_shortcodes__installed_shortcodes', EE_Registry::instance()->shortcodes);
961 961
 	}
962 962
 
963 963
 
@@ -969,56 +969,56 @@  discard block
 block discarded – undo
969 969
 	 *  @param 	string 		$shortcode_path - full path up to and including shortcode folder
970 970
 	 *  @return 	bool
971 971
 	 */
972
-	public static function register_shortcode( $shortcode_path = NULL ) {
973
-		do_action( 'AHEE__EE_Config__register_shortcode__begin',$shortcode_path );
972
+	public static function register_shortcode($shortcode_path = NULL) {
973
+		do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path);
974 974
 		$shortcode_ext = '.shortcode.php';
975 975
 		// make all separators match
976
-		$shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path );
976
+		$shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path);
977 977
 		// does the file path INCLUDE the actual file name as part of the path ?
978
-		if ( strpos( $shortcode_path, $shortcode_ext ) !== FALSE ) {
978
+		if (strpos($shortcode_path, $shortcode_ext) !== FALSE) {
979 979
 			// grab shortcode file name from directory name and break apart at dots
980
-			$shortcode_file = explode( '.', basename( $shortcode_path ));
980
+			$shortcode_file = explode('.', basename($shortcode_path));
981 981
 			// take first segment from file name pieces and remove class prefix if it exists
982
-			$shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 ? substr( $shortcode_file[0], 4 ) : $shortcode_file[0];
982
+			$shortcode = strpos($shortcode_file[0], 'EES_') === 0 ? substr($shortcode_file[0], 4) : $shortcode_file[0];
983 983
 			// sanitize shortcode directory name
984
-			$shortcode = sanitize_key( $shortcode );
984
+			$shortcode = sanitize_key($shortcode);
985 985
 			// now we need to rebuild the shortcode path
986
-			$shortcode_path = explode( DS, $shortcode_path );
986
+			$shortcode_path = explode(DS, $shortcode_path);
987 987
 			// remove last segment
988
-			array_pop( $shortcode_path );
988
+			array_pop($shortcode_path);
989 989
 			// glue it back together
990
-			$shortcode_path = implode( DS, $shortcode_path ) . DS;
990
+			$shortcode_path = implode(DS, $shortcode_path).DS;
991 991
 		} else {
992 992
 			// we need to generate the filename based off of the folder name
993 993
 			// grab and sanitize shortcode directory name
994
-			$shortcode = sanitize_key( basename( $shortcode_path ));
995
-			$shortcode_path = rtrim( $shortcode_path, DS ) . DS;
994
+			$shortcode = sanitize_key(basename($shortcode_path));
995
+			$shortcode_path = rtrim($shortcode_path, DS).DS;
996 996
 		}
997 997
 		// create classname from shortcode directory or file name
998
-		$shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode )));
998
+		$shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode)));
999 999
 		// add class prefix
1000
-		$shortcode_class = 'EES_' . $shortcode;
1000
+		$shortcode_class = 'EES_'.$shortcode;
1001 1001
 		// does the shortcode exist ?
1002
-		if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext )) {
1002
+		if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) {
1003 1003
 			$msg = sprintf(
1004
-				__( 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso' ),
1004
+				__('The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', 'event_espresso'),
1005 1005
 				$shortcode_class,
1006
-				$shortcode_path . DS . $shortcode_class . $shortcode_ext
1006
+				$shortcode_path.DS.$shortcode_class.$shortcode_ext
1007 1007
 			);
1008
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1008
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1009 1009
 			return FALSE;
1010 1010
 		}
1011 1011
 		// load the shortcode class file
1012
-		require_once( $shortcode_path . $shortcode_class . $shortcode_ext );
1012
+		require_once($shortcode_path.$shortcode_class.$shortcode_ext);
1013 1013
 		// verify that class exists
1014
-		if ( ! class_exists( $shortcode_class )) {
1015
-			$msg = sprintf( __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), $shortcode_class );
1016
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1014
+		if ( ! class_exists($shortcode_class)) {
1015
+			$msg = sprintf(__('The requested %s shortcode class does not exist.', 'event_espresso'), $shortcode_class);
1016
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1017 1017
 			return FALSE;
1018 1018
 		}
1019
-		$shortcode = strtoupper( $shortcode );
1019
+		$shortcode = strtoupper($shortcode);
1020 1020
 		// add to array of registered shortcodes
1021
-		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext;
1021
+		EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext;
1022 1022
 		return TRUE;
1023 1023
 	}
1024 1024
 
@@ -1033,23 +1033,23 @@  discard block
 block discarded – undo
1033 1033
 	 */
1034 1034
 	private function _register_modules() {
1035 1035
 		// grab list of installed modules
1036
-		$modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR );
1036
+		$modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1037 1037
 		// filter list of modules to register
1038
-		$modules_to_register = apply_filters( 'FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register );
1038
+		$modules_to_register = apply_filters('FHEE__EE_Config__register_modules__modules_to_register', $modules_to_register);
1039 1039
 
1040 1040
 
1041
-		if ( ! empty( $modules_to_register ) ) {
1041
+		if ( ! empty($modules_to_register)) {
1042 1042
 			// loop through folders
1043
-			foreach ( $modules_to_register as $module_path ) {
1043
+			foreach ($modules_to_register as $module_path) {
1044 1044
 				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1045
-				if ( $module_path != EE_MODULES . 'zzz-copy-this-module-template' && $module_path != EE_MODULES . 'gateways' ) {
1045
+				if ($module_path != EE_MODULES.'zzz-copy-this-module-template' && $module_path != EE_MODULES.'gateways') {
1046 1046
 					// add to list of installed modules
1047
-					EE_Config::register_module( $module_path );
1047
+					EE_Config::register_module($module_path);
1048 1048
 				}
1049 1049
 			}
1050 1050
 		}
1051 1051
 		// filter list of installed modules
1052
-		return apply_filters( 'FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules );
1052
+		return apply_filters('FHEE__EE_Config___register_modules__installed_modules', EE_Registry::instance()->modules);
1053 1053
 	}
1054 1054
 
1055 1055
 
@@ -1062,54 +1062,54 @@  discard block
 block discarded – undo
1062 1062
 	 *  @param 	string 		$module_path - full path up to and including module folder
1063 1063
 	 *  @return 	bool
1064 1064
 	 */
1065
-	public static function register_module( $module_path = NULL ) {
1066
-		do_action( 'AHEE__EE_Config__register_module__begin', $module_path );
1065
+	public static function register_module($module_path = NULL) {
1066
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1067 1067
 		$module_ext = '.module.php';
1068 1068
 		// make all separators match
1069
-		$module_path = str_replace( array( '\\', '/' ), DS, $module_path );
1069
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1070 1070
 		// does the file path INCLUDE the actual file name as part of the path ?
1071
-		if ( strpos( $module_path, $module_ext ) !== FALSE ) {
1071
+		if (strpos($module_path, $module_ext) !== FALSE) {
1072 1072
 			// grab and shortcode file name from directory name and break apart at dots
1073
-			$module_file = explode( '.', basename( $module_path ));
1073
+			$module_file = explode('.', basename($module_path));
1074 1074
 			// now we need to rebuild the shortcode path
1075
-			$module_path = explode( DS, $module_path );
1075
+			$module_path = explode(DS, $module_path);
1076 1076
 			// remove last segment
1077
-			array_pop( $module_path );
1077
+			array_pop($module_path);
1078 1078
 			// glue it back together
1079
-			$module_path = implode( DS, $module_path ) . DS;
1079
+			$module_path = implode(DS, $module_path).DS;
1080 1080
 			// take first segment from file name pieces and sanitize it
1081
-			$module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] );
1081
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1082 1082
 			// ensure class prefix is added
1083
-			$module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module;
1083
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1084 1084
 		} else {
1085 1085
 			// we need to generate the filename based off of the folder name
1086 1086
 			// grab and sanitize module name
1087
-			$module = strtolower( basename( $module_path ));
1088
-			$module = preg_replace( '/[^a-z0-9_\-]/', '', $module);
1087
+			$module = strtolower(basename($module_path));
1088
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1089 1089
 			// like trailingslashit()
1090
-			$module_path = rtrim( $module_path, DS ) . DS;
1090
+			$module_path = rtrim($module_path, DS).DS;
1091 1091
 			// create classname from module directory name
1092
-			$module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module )));
1092
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1093 1093
 			// add class prefix
1094
-			$module_class = 'EED_' . $module;
1094
+			$module_class = 'EED_'.$module;
1095 1095
 		}
1096 1096
 		// does the module exist ?
1097
-		if ( ! is_readable( $module_path . DS . $module_class . $module_ext )) {
1098
-			$msg = sprintf( __( 'The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module );
1099
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1097
+		if ( ! is_readable($module_path.DS.$module_class.$module_ext)) {
1098
+			$msg = sprintf(__('The requested %s module file could not be found or is not readable due to file permissions.', 'event_espresso'), $module);
1099
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1100 1100
 			return FALSE;
1101 1101
 		}
1102 1102
 		// load the module class file
1103
-		require_once( $module_path . $module_class . $module_ext );
1103
+		require_once($module_path.$module_class.$module_ext);
1104 1104
 		// verify that class exists
1105
-		if ( ! class_exists( $module_class )) {
1106
-			$msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class );
1107
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1105
+		if ( ! class_exists($module_class)) {
1106
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1107
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1108 1108
 			return FALSE;
1109 1109
 		}
1110 1110
 		// add to array of registered modules
1111
-		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1112
-		do_action( 'AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} );
1111
+		EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1112
+		do_action('AHEE__EE_Config__register_module__complete', $module_class, EE_Registry::instance()->modules->{$module_class} );
1113 1113
 		return TRUE;
1114 1114
 	}
1115 1115
 
@@ -1123,23 +1123,23 @@  discard block
 block discarded – undo
1123 1123
 	 */
1124 1124
 	private function _initialize_shortcodes() {
1125 1125
 		// cycle thru shortcode folders
1126
-		foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) {
1126
+		foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) {
1127 1127
 			// add class prefix
1128
-			$shortcode_class = 'EES_' . $shortcode;
1128
+			$shortcode_class = 'EES_'.$shortcode;
1129 1129
 			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1130 1130
 			// which set hooks ?
1131
-			if ( is_admin() ) {
1131
+			if (is_admin()) {
1132 1132
 				// fire immediately
1133
-				call_user_func( array( $shortcode_class, 'set_hooks_admin' ));
1133
+				call_user_func(array($shortcode_class, 'set_hooks_admin'));
1134 1134
 			} else {
1135 1135
 				// delay until other systems are online
1136
-				add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $shortcode_class,'set_hooks' ));
1136
+				add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($shortcode_class, 'set_hooks'));
1137 1137
 				// convert classname to UPPERCASE and create WP shortcode.
1138
-				$shortcode_tag = strtoupper( $shortcode );
1138
+				$shortcode_tag = strtoupper($shortcode);
1139 1139
 				// but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor'
1140
-				if ( ! shortcode_exists( $shortcode_tag )) {
1140
+				if ( ! shortcode_exists($shortcode_tag)) {
1141 1141
 					// NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes()
1142
-					add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' ));
1142
+					add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor'));
1143 1143
 				}
1144 1144
 			}
1145 1145
 		}
@@ -1156,15 +1156,15 @@  discard block
 block discarded – undo
1156 1156
 	 */
1157 1157
 	private function _initialize_modules() {
1158 1158
 		// cycle thru shortcode folders
1159
-		foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) {
1159
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1160 1160
 			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1161 1161
 			// which set hooks ?
1162
-			if ( is_admin() ) {
1162
+			if (is_admin()) {
1163 1163
 				// fire immediately
1164
-				call_user_func( array( $module_class, 'set_hooks_admin' ));
1164
+				call_user_func(array($module_class, 'set_hooks_admin'));
1165 1165
 			} else {
1166 1166
 				// delay until other systems are online
1167
-				add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array( $module_class,'set_hooks' ));
1167
+				add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', array($module_class, 'set_hooks'));
1168 1168
 			}
1169 1169
 		}
1170 1170
 	}
@@ -1182,26 +1182,26 @@  discard block
 block discarded – undo
1182 1182
 	 *  @param 	string 		$key - url param key indicating a route is being called
1183 1183
 	 *  @return 	bool
1184 1184
 	 */
1185
-	public static function register_route( $route = NULL, $module = NULL, $method_name = NULL, $key = 'ee' ) {
1186
-		do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name );
1187
-		$module = str_replace( 'EED_', '', $module );
1188
-		$module_class = 'EED_' . $module;
1189
-		if ( ! isset( EE_Registry::instance()->modules->{$module_class} )) {
1190
-			$msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module );
1191
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1185
+	public static function register_route($route = NULL, $module = NULL, $method_name = NULL, $key = 'ee') {
1186
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1187
+		$module = str_replace('EED_', '', $module);
1188
+		$module_class = 'EED_'.$module;
1189
+		if ( ! isset(EE_Registry::instance()->modules->{$module_class} )) {
1190
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1191
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1192 1192
 			return FALSE;
1193 1193
 		}
1194
-		if ( empty( $route )) {
1195
-			$msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route );
1196
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1194
+		if (empty($route)) {
1195
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1196
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1197 1197
 			return FALSE;
1198 1198
 		}
1199
-		if ( ! method_exists ( 'EED_' . $module, $method_name )) {
1200
-			$msg = sprintf( __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), $route );
1201
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1199
+		if ( ! method_exists('EED_'.$module, $method_name)) {
1200
+			$msg = sprintf(__('A valid class method for the %s route has not been supplied.', 'event_espresso'), $route);
1201
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1202 1202
 			return FALSE;
1203 1203
 		}
1204
-		EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name );
1204
+		EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name);
1205 1205
 		return TRUE;
1206 1206
 	}
1207 1207
 
@@ -1215,11 +1215,11 @@  discard block
 block discarded – undo
1215 1215
 	 *  @param 	string 		$key - url param key indicating a route is being called
1216 1216
 	 *  @return 	string
1217 1217
 	 */
1218
-	public static function get_route( $route = NULL, $key = 'ee' ) {
1219
-		do_action( 'AHEE__EE_Config__get_route__begin',$route );
1220
-		$route = apply_filters( 'FHEE__EE_Config__get_route',$route );
1221
-		if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] )) {
1222
-			return EE_Config::$_module_route_map[ $key ][ $route ];
1218
+	public static function get_route($route = NULL, $key = 'ee') {
1219
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1220
+		$route = apply_filters('FHEE__EE_Config__get_route', $route);
1221
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1222
+			return EE_Config::$_module_route_map[$key][$route];
1223 1223
 		}
1224 1224
 		return NULL;
1225 1225
 	}
@@ -1248,35 +1248,35 @@  discard block
 block discarded – undo
1248 1248
 	 * @param    string 		$key - url param key indicating a route is being called
1249 1249
 	 * @return    bool
1250 1250
 	 */
1251
-	public static function register_forward( $route = NULL, $status = 0, $forward = NULL, $key = 'ee' ) {
1252
-		do_action( 'AHEE__EE_Config__register_forward',$route,$status,$forward );
1253
-		if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) ||  empty( $route )) {
1254
-			$msg = sprintf( __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), $route );
1255
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1251
+	public static function register_forward($route = NULL, $status = 0, $forward = NULL, $key = 'ee') {
1252
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1253
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1254
+			$msg = sprintf(__('The module route %s for this forward has not been registered.', 'event_espresso'), $route);
1255
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1256 1256
 			return FALSE;
1257 1257
 		}
1258
-		if ( empty( $forward )) {
1259
-			$msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route );
1260
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1258
+		if (empty($forward)) {
1259
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1260
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1261 1261
 			return FALSE;
1262 1262
 		}
1263
-		if ( is_array( $forward )) {
1264
-			if ( ! isset( $forward[1] )) {
1265
-				$msg = sprintf( __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), $route );
1266
-				EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1263
+		if (is_array($forward)) {
1264
+			if ( ! isset($forward[1])) {
1265
+				$msg = sprintf(__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), $route);
1266
+				EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1267 1267
 				return FALSE;
1268 1268
 			}
1269
-			if ( ! method_exists( $forward[0], $forward[1] )) {
1270
-				$msg = sprintf( __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward[1], $route );
1271
-				EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1269
+			if ( ! method_exists($forward[0], $forward[1])) {
1270
+				$msg = sprintf(__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward[1], $route);
1271
+				EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1272 1272
 				return FALSE;
1273 1273
 			}
1274
-		} else if ( ! function_exists( $forward )) {
1275
-			$msg = sprintf( __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), $forward, $route );
1276
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1274
+		} else if ( ! function_exists($forward)) {
1275
+			$msg = sprintf(__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), $forward, $route);
1276
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1277 1277
 			return FALSE;
1278 1278
 		}
1279
-		EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward;
1279
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1280 1280
 		return TRUE;
1281 1281
 	}
1282 1282
 
@@ -1291,10 +1291,10 @@  discard block
 block discarded – undo
1291 1291
 	 *  @param    string 		$key - url param key indicating a route is being called
1292 1292
 	 *  @return 	string
1293 1293
 	 */
1294
-	public static function get_forward( $route = NULL, $status = 0, $key = 'ee' ) {
1295
-		do_action( 'AHEE__EE_Config__get_forward__begin',$route,$status );
1296
-		if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] )) {
1297
-			return apply_filters( 'FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], $route,$status );
1294
+	public static function get_forward($route = NULL, $status = 0, $key = 'ee') {
1295
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1296
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1297
+			return apply_filters('FHEE__EE_Config__get_forward', EE_Config::$_module_forward_map[$key][$route][$status], $route, $status);
1298 1298
 		}
1299 1299
 		return NULL;
1300 1300
 	}
@@ -1311,19 +1311,19 @@  discard block
 block discarded – undo
1311 1311
 	 * @param    string 		$key - url param key indicating a route is being called
1312 1312
 	 * @return    bool
1313 1313
 	 */
1314
-	public static function register_view( $route = NULL, $status = 0, $view = NULL, $key = 'ee' ) {
1315
-		do_action( 'AHEE__EE_Config__register_view__begin',$route,$status,$view );
1316
-		if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) ||  empty( $route )) {
1317
-			$msg = sprintf( __( 'The module route %s for this view has not been registered.', 'event_espresso' ), $route );
1318
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1314
+	public static function register_view($route = NULL, $status = 0, $view = NULL, $key = 'ee') {
1315
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1316
+		if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1317
+			$msg = sprintf(__('The module route %s for this view has not been registered.', 'event_espresso'), $route);
1318
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1319 1319
 			return FALSE;
1320 1320
 		}
1321
-		if ( ! is_readable( $view )) {
1322
-			$msg = sprintf( __( 'The %s view file could not be found or is not readable due to file permissions.', 'event_espresso' ), $view );
1323
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
1321
+		if ( ! is_readable($view)) {
1322
+			$msg = sprintf(__('The %s view file could not be found or is not readable due to file permissions.', 'event_espresso'), $view);
1323
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1324 1324
 			return FALSE;
1325 1325
 		}
1326
-		EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view;
1326
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1327 1327
 		return TRUE;
1328 1328
 	}
1329 1329
 
@@ -1340,10 +1340,10 @@  discard block
 block discarded – undo
1340 1340
 	 *  @param    string 		$key - url param key indicating a route is being called
1341 1341
 	 *  @return 	string
1342 1342
 	 */
1343
-	public static function get_view( $route = NULL, $status = 0, $key = 'ee' ) {
1344
-		do_action( 'AHEE__EE_Config__get_view__begin',$route,$status );
1345
-		if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] )) {
1346
-			return apply_filters( 'FHEE__EE_Config__get_view', EE_Config::$_module_view_map[ $key ][ $route ][ $status ], $route,$status );
1343
+	public static function get_view($route = NULL, $status = 0, $key = 'ee') {
1344
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1345
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1346
+			return apply_filters('FHEE__EE_Config__get_view', EE_Config::$_module_view_map[$key][$route][$status], $route, $status);
1347 1347
 		}
1348 1348
 		return NULL;
1349 1349
 	}
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
 
1352 1352
 
1353 1353
 	public function shutdown() {
1354
-		update_option( 'ee_config_option_names', $this->_config_option_names );
1354
+		update_option('ee_config_option_names', $this->_config_option_names);
1355 1355
 	}
1356 1356
 
1357 1357
 
@@ -1367,7 +1367,7 @@  discard block
 block discarded – undo
1367 1367
  * magic functions in use, except we'll allow them to magically set and get stuff...
1368 1368
  * basically, they should just be well-defined stdClasses
1369 1369
  */
1370
-class EE_Config_Base{
1370
+class EE_Config_Base {
1371 1371
 
1372 1372
 	/**
1373 1373
 	 * Utility function for escaping the value of a property and returning.
@@ -1376,13 +1376,13 @@  discard block
 block discarded – undo
1376 1376
 	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1377 1377
 	 * @throws \EE_Error
1378 1378
 	 */
1379
-	public function get_pretty( $property ) {
1380
-		if ( ! property_exists( $this, $property ) ) {
1381
-			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 ) );
1379
+	public function get_pretty($property) {
1380
+		if ( ! property_exists($this, $property)) {
1381
+			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));
1382 1382
 		}
1383 1383
 		//just handling escaping of strings for now.
1384
-		if ( is_string( $this->{$property} ) ) {
1385
-			return stripslashes( $this->{$property} );
1384
+		if (is_string($this->{$property} )) {
1385
+			return stripslashes($this->{$property} );
1386 1386
 		}
1387 1387
 		return $this->{$property};
1388 1388
 	}
@@ -1391,19 +1391,19 @@  discard block
 block discarded – undo
1391 1391
 
1392 1392
 	public function populate() {
1393 1393
 		//grab defaults via a new instance of this class.
1394
-		$class_name = get_class( $this );
1394
+		$class_name = get_class($this);
1395 1395
 		$defaults = new $class_name;
1396 1396
 
1397 1397
 		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1398 1398
 		//default from our $defaults object.
1399
-		foreach ( get_object_vars( $defaults ) as $property => $value ) {
1400
-			if ( is_null( $this->{$property} ) ) {
1399
+		foreach (get_object_vars($defaults) as $property => $value) {
1400
+			if (is_null($this->{$property} )) {
1401 1401
 				$this->{$property} = $value;
1402 1402
 			}
1403 1403
 		}
1404 1404
 
1405 1405
 		//cleanup
1406
-		unset( $defaults );
1406
+		unset($defaults);
1407 1407
 	}
1408 1408
 
1409 1409
 
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 		$this->current_blog_id = get_current_blog_id();
1508 1508
 		$this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id;
1509 1509
 		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1510
-		$this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', false ) : true;
1510
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1511 1511
 		$this->post_shortcodes = array();
1512 1512
 		$this->module_route_map = array();
1513 1513
 		$this->module_forward_map = array();
@@ -1526,7 +1526,7 @@  discard block
 block discarded – undo
1526 1526
 		$this->event_cpt_slug = __('events', 'event_espresso');
1527 1527
 
1528 1528
 		//ueip constant check
1529
-		if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) {
1529
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1530 1530
 			$this->ee_ueip_optin = FALSE;
1531 1531
 			$this->ee_ueip_has_notified = TRUE;
1532 1532
 		}
@@ -1566,8 +1566,8 @@  discard block
 block discarded – undo
1566 1566
 	 *  @return 	string
1567 1567
 	 */
1568 1568
 	public function reg_page_url() {
1569
-		if ( ! $this->reg_page_url ) {
1570
-			$this->reg_page_url = get_permalink( $this->reg_page_id ) . '#checkout';
1569
+		if ( ! $this->reg_page_url) {
1570
+			$this->reg_page_url = get_permalink($this->reg_page_id).'#checkout';
1571 1571
 		}
1572 1572
 		return $this->reg_page_url;
1573 1573
 	}
@@ -1580,12 +1580,12 @@  discard block
 block discarded – undo
1580 1580
 	 *  @return 	string
1581 1581
 	 */
1582 1582
 	public function txn_page_url($query_args = array()) {
1583
-		if ( ! $this->txn_page_url ) {
1584
-			$this->txn_page_url = get_permalink( $this->txn_page_id );
1583
+		if ( ! $this->txn_page_url) {
1584
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1585 1585
 		}
1586
-		if($query_args){
1587
-			return add_query_arg($query_args,$this->txn_page_url);
1588
-		}else{
1586
+		if ($query_args) {
1587
+			return add_query_arg($query_args, $this->txn_page_url);
1588
+		} else {
1589 1589
 			return $this->txn_page_url;
1590 1590
 		}
1591 1591
 	}
@@ -1597,12 +1597,12 @@  discard block
 block discarded – undo
1597 1597
 	 *  @return 	string
1598 1598
 	 */
1599 1599
 	public function thank_you_page_url($query_args = array()) {
1600
-		if ( ! $this->thank_you_page_url ) {
1601
-			$this->thank_you_page_url = get_permalink( $this->thank_you_page_id );
1600
+		if ( ! $this->thank_you_page_url) {
1601
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1602 1602
 		}
1603
-		if($query_args){
1604
-			return add_query_arg($query_args,$this->thank_you_page_url);
1605
-		}else{
1603
+		if ($query_args) {
1604
+			return add_query_arg($query_args, $this->thank_you_page_url);
1605
+		} else {
1606 1606
 			return $this->thank_you_page_url;
1607 1607
 		}
1608 1608
 	}
@@ -1613,8 +1613,8 @@  discard block
 block discarded – undo
1613 1613
 	 *  @return 	string
1614 1614
 	 */
1615 1615
 	public function cancel_page_url() {
1616
-		if ( ! $this->cancel_page_url ) {
1617
-			$this->cancel_page_url = get_permalink( $this->cancel_page_id );
1616
+		if ( ! $this->cancel_page_url) {
1617
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1618 1618
 		}
1619 1619
 		return $this->cancel_page_url;
1620 1620
 	}
@@ -1641,22 +1641,22 @@  discard block
 block discarded – undo
1641 1641
 	 */
1642 1642
 	protected function _get_main_ee_ueip_optin() {
1643 1643
 		//if this is the main site then we can just bypass our direct query.
1644
-		if ( is_main_site() ) {
1645
-			return get_option( 'ee_ueip_optin', false );
1644
+		if (is_main_site()) {
1645
+			return get_option('ee_ueip_optin', false);
1646 1646
 		}
1647 1647
 
1648 1648
 		//is this already cached for this request?  If so use it.
1649
-		if ( ! empty( EE_Core_Config::$ee_ueip_option ) ) {
1649
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1650 1650
 			return EE_Core_Config::$ee_ueip_option;
1651 1651
 		}
1652 1652
 
1653 1653
 		global $wpdb;
1654 1654
 		$current_network_main_site = is_multisite() ? get_current_site() : null;
1655
-		$current_main_site_id = ! empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1;
1655
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1656 1656
 		$option = 'ee_ueip_optin';
1657 1657
 
1658 1658
 		//set correct table for query
1659
-		$table_name = $wpdb->get_blog_prefix( $current_main_site_id ) . 'options';
1659
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1660 1660
 
1661 1661
 
1662 1662
 		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
@@ -1664,20 +1664,20 @@  discard block
 block discarded – undo
1664 1664
 		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1665 1665
 		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1666 1666
 		//for the purpose of caching.
1667
-		$pre = apply_filters( 'pre_option_' . $option, false, $option );
1668
-		if ( false !== $pre ) {
1667
+		$pre = apply_filters('pre_option_'.$option, false, $option);
1668
+		if (false !== $pre) {
1669 1669
 			EE_Core_Config::$ee_ueip_option = $pre;
1670 1670
 			return EE_Core_Config::$ee_ueip_option;
1671 1671
 		}
1672 1672
 
1673
-		$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", $option ) );
1674
-		if ( is_object( $row ) ) {
1673
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", $option));
1674
+		if (is_object($row)) {
1675 1675
 			$value = $row->option_value;
1676 1676
 		} else { //option does not exist so use default.
1677
-			return apply_filters( 'default_option_' . $option, false, $option );
1677
+			return apply_filters('default_option_'.$option, false, $option);
1678 1678
 		}
1679 1679
 
1680
-		EE_Core_Config::$ee_ueip_option = apply_filters( 'option_' . $option, maybe_unserialize( $value ), $option );
1680
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1681 1681
 
1682 1682
 		return EE_Core_Config::$ee_ueip_option;
1683 1683
 	}
@@ -1692,7 +1692,7 @@  discard block
 block discarded – undo
1692 1692
 		//reset all url properties
1693 1693
 		$this->_reset_urls();
1694 1694
 		//return what to save to db
1695
-		return array_keys( get_object_vars( $this ) );
1695
+		return array_keys(get_object_vars($this));
1696 1696
 	}
1697 1697
 
1698 1698
 }
@@ -1924,38 +1924,38 @@  discard block
 block discarded – undo
1924 1924
 	 * @param null $CNT_ISO
1925 1925
 	 * @return \EE_Currency_Config
1926 1926
 	 */
1927
-	public function __construct( $CNT_ISO = NULL ) {
1927
+	public function __construct($CNT_ISO = NULL) {
1928 1928
 
1929 1929
 		// get country code from organization settings or use default
1930
-		$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;
1930
+		$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;
1931 1931
 		// but override if requested
1932
-		$CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT;
1932
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
1933 1933
 		// 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
1934
-		if ( ! empty( $CNT_ISO ) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists( EE_Registry::instance()->load_model( 'Country' )->table() ) ) {
1934
+		if ( ! empty($CNT_ISO) && EE_Maintenance_Mode::instance()->models_can_query() && EEH_Activation::table_exists(EE_Registry::instance()->load_model('Country')->table())) {
1935 1935
 			// retrieve the country settings from the db, just in case they have been customized
1936
-			$country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO );
1937
-			if ( $country instanceof EE_Country ) {
1938
-				$this->code = $country->currency_code(); 	// currency code: USD, CAD, EUR
1939
-				$this->name = $country->currency_name_single();	// Dollar
1940
-				$this->plural = $country->currency_name_plural(); 	// Dollars
1941
-				$this->sign =  $country->currency_sign(); 			// currency sign: $
1942
-				$this->sign_b4 = $country->currency_sign_before(); 		// currency sign before or after: $TRUE  or  FALSE$
1943
-				$this->dec_plc = $country->currency_decimal_places();	// decimal places: 2 = 0.00  3 = 0.000
1944
-				$this->dec_mrk = $country->currency_decimal_mark();	// decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1945
-				$this->thsnds = $country->currency_thousands_separator();	// thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1936
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
1937
+			if ($country instanceof EE_Country) {
1938
+				$this->code = $country->currency_code(); // currency code: USD, CAD, EUR
1939
+				$this->name = $country->currency_name_single(); // Dollar
1940
+				$this->plural = $country->currency_name_plural(); // Dollars
1941
+				$this->sign = $country->currency_sign(); // currency sign: $
1942
+				$this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE  or  FALSE$
1943
+				$this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
1944
+				$this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1945
+				$this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1946 1946
 			}
1947 1947
 		}
1948 1948
 		// fallback to hardcoded defaults, in case the above failed
1949
-		if ( empty( $this->code )) {
1949
+		if (empty($this->code)) {
1950 1950
 			// set default currency settings
1951
-			$this->code = 'USD'; 	// currency code: USD, CAD, EUR
1952
-			$this->name = __( 'Dollar', 'event_espresso' ); 	// Dollar
1953
-			$this->plural = __( 'Dollars', 'event_espresso' ); 	// Dollars
1954
-			$this->sign =  '$'; 	// currency sign: $
1955
-			$this->sign_b4 = TRUE; 	// currency sign before or after: $TRUE  or  FALSE$
1956
-			$this->dec_plc = 2; 	// decimal places: 2 = 0.00  3 = 0.000
1957
-			$this->dec_mrk = '.'; 	// decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1958
-			$this->thsnds = ','; 	// thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1951
+			$this->code = 'USD'; // currency code: USD, CAD, EUR
1952
+			$this->name = __('Dollar', 'event_espresso'); // Dollar
1953
+			$this->plural = __('Dollars', 'event_espresso'); // Dollars
1954
+			$this->sign = '$'; // currency sign: $
1955
+			$this->sign_b4 = TRUE; // currency sign before or after: $TRUE  or  FALSE$
1956
+			$this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
1957
+			$this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
1958
+			$this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
1959 1959
 		}
1960 1960
 	}
1961 1961
 }
@@ -2104,7 +2104,7 @@  discard block
 block discarded – undo
2104 2104
 	 * @since 4.8.8.rc.019
2105 2105
 	 */
2106 2106
 	public function do_hooks() {
2107
-		add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' ));
2107
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2108 2108
 	}
2109 2109
 
2110 2110
 
@@ -2112,7 +2112,7 @@  discard block
 block discarded – undo
2112 2112
 	 * @return void
2113 2113
 	 */
2114 2114
 	public function set_default_reg_status_on_EEM_Event() {
2115
-		EEM_Event::set_default_reg_status( $this->default_STS_ID );
2115
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2116 2116
 	}
2117 2117
 
2118 2118
 
@@ -2217,10 +2217,10 @@  discard block
 block discarded – undo
2217 2217
 	 * @param bool $reset
2218 2218
 	 * @return string
2219 2219
 	 */
2220
-	public function log_file_name( $reset = FALSE ) {
2221
-		if ( empty( $this->log_file_name ) || $reset ) {
2222
-			$this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', TRUE ))) . '.txt';
2223
-			EE_Config::instance()->update_espresso_config( FALSE, FALSE );
2220
+	public function log_file_name($reset = FALSE) {
2221
+		if (empty($this->log_file_name) || $reset) {
2222
+			$this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', TRUE))).'.txt';
2223
+			EE_Config::instance()->update_espresso_config(FALSE, FALSE);
2224 2224
 		}
2225 2225
 		return $this->log_file_name;
2226 2226
 	}
@@ -2232,10 +2232,10 @@  discard block
 block discarded – undo
2232 2232
 	 * @param bool $reset
2233 2233
 	 * @return string
2234 2234
 	 */
2235
-	public function debug_file_name( $reset = FALSE ) {
2236
-		if ( empty( $this->debug_file_name ) || $reset ) {
2237
-			$this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', TRUE ))) . '.txt';
2238
-			EE_Config::instance()->update_espresso_config( FALSE, FALSE );
2235
+	public function debug_file_name($reset = FALSE) {
2236
+		if (empty($this->debug_file_name) || $reset) {
2237
+			$this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', TRUE))).'.txt';
2238
+			EE_Config::instance()->update_espresso_config(FALSE, FALSE);
2239 2239
 		}
2240 2240
 		return $this->debug_file_name;
2241 2241
 	}
@@ -2408,21 +2408,21 @@  discard block
 block discarded – undo
2408 2408
 		// set default map settings
2409 2409
 		$this->use_google_maps = TRUE;
2410 2410
 		// for event details pages (reg page)
2411
-		$this->event_details_map_width = 585; 			// ee_map_width_single
2412
-		$this->event_details_map_height = 362; 			// ee_map_height_single
2413
-		$this->event_details_map_zoom = 14; 			// ee_map_zoom_single
2414
-		$this->event_details_display_nav = TRUE; 			// ee_map_nav_display_single
2415
-		$this->event_details_nav_size = FALSE; 			// ee_map_nav_size_single
2416
-		$this->event_details_control_type = 'default'; 		// ee_map_type_control_single
2417
-		$this->event_details_map_align = 'center'; 			// ee_map_align_single
2411
+		$this->event_details_map_width = 585; // ee_map_width_single
2412
+		$this->event_details_map_height = 362; // ee_map_height_single
2413
+		$this->event_details_map_zoom = 14; // ee_map_zoom_single
2414
+		$this->event_details_display_nav = TRUE; // ee_map_nav_display_single
2415
+		$this->event_details_nav_size = FALSE; // ee_map_nav_size_single
2416
+		$this->event_details_control_type = 'default'; // ee_map_type_control_single
2417
+		$this->event_details_map_align = 'center'; // ee_map_align_single
2418 2418
 		// for event list pages
2419
-		$this->event_list_map_width = 300; 			// ee_map_width
2420
-		$this->event_list_map_height = 185; 		// ee_map_height
2421
-		$this->event_list_map_zoom = 12; 			// ee_map_zoom
2422
-		$this->event_list_display_nav = FALSE; 		// ee_map_nav_display
2423
-		$this->event_list_nav_size = TRUE; 			// ee_map_nav_size
2424
-		$this->event_list_control_type = 'dropdown'; 		// ee_map_type_control
2425
-		$this->event_list_map_align = 'center'; 			// ee_map_align
2419
+		$this->event_list_map_width = 300; // ee_map_width
2420
+		$this->event_list_map_height = 185; // ee_map_height
2421
+		$this->event_list_map_zoom = 12; // ee_map_zoom
2422
+		$this->event_list_display_nav = FALSE; // ee_map_nav_display
2423
+		$this->event_list_nav_size = TRUE; // ee_map_nav_size
2424
+		$this->event_list_control_type = 'dropdown'; // ee_map_type_control
2425
+		$this->event_list_map_align = 'center'; // ee_map_align
2426 2426
 	}
2427 2427
 
2428 2428
 }
@@ -2433,7 +2433,7 @@  discard block
 block discarded – undo
2433 2433
 /**
2434 2434
  * stores Events_Archive settings
2435 2435
  */
2436
-class EE_Events_Archive_Config extends EE_Config_Base{
2436
+class EE_Events_Archive_Config extends EE_Config_Base {
2437 2437
 
2438 2438
 	public $display_status_banner;
2439 2439
 	public $display_description;
@@ -2452,7 +2452,7 @@  discard block
 block discarded – undo
2452 2452
 	/**
2453 2453
 	 *	class constructor
2454 2454
 	 */
2455
-	public function __construct(){
2455
+	public function __construct() {
2456 2456
 		$this->display_status_banner = 0;
2457 2457
 		$this->display_description = 1;
2458 2458
 		$this->display_ticket_selector = 0;
@@ -2472,7 +2472,7 @@  discard block
 block discarded – undo
2472 2472
 /**
2473 2473
  * Stores Event_Single_Config settings
2474 2474
  */
2475
-class EE_Event_Single_Config extends EE_Config_Base{
2475
+class EE_Event_Single_Config extends EE_Config_Base {
2476 2476
 
2477 2477
 	public $display_status_banner_single;
2478 2478
 	public $display_venue;
@@ -2501,7 +2501,7 @@  discard block
 block discarded – undo
2501 2501
 /**
2502 2502
  * Stores Ticket_Selector_Config settings
2503 2503
  */
2504
-class EE_Ticket_Selector_Config extends EE_Config_Base{
2504
+class EE_Ticket_Selector_Config extends EE_Config_Base {
2505 2505
 	public $show_ticket_sale_columns;
2506 2506
 	public $show_ticket_details;
2507 2507
 	public $show_expired_tickets;
@@ -2555,7 +2555,7 @@  discard block
 block discarded – undo
2555 2555
 	 * @return void
2556 2556
 	 */
2557 2557
 	protected function _set_php_values() {
2558
-		$this->php->max_input_vars = ini_get( 'max_input_vars' );
2558
+		$this->php->max_input_vars = ini_get('max_input_vars');
2559 2559
 		$this->php->version = phpversion();
2560 2560
 	}
2561 2561
 
@@ -2574,9 +2574,9 @@  discard block
 block discarded – undo
2574 2574
 	 *         @type string $msg 		Any message to be displayed.
2575 2575
 	 * }
2576 2576
 	 */
2577
-	public function max_input_vars_limit_check( $input_count = 0 ) {
2578
-		if ( ! empty( $this->php->max_input_vars ) && ( $input_count >= $this->php->max_input_vars ) && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >=9 ) ) {
2579
-			return  sprintf( __('The maximum 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.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', 'event_espresso'), '<br>', $input_count, $this->php->max_input_vars);
2577
+	public function max_input_vars_limit_check($input_count = 0) {
2578
+		if ( ! empty($this->php->max_input_vars) && ($input_count >= $this->php->max_input_vars) && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)) {
2579
+			return  sprintf(__('The maximum 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.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.', 'event_espresso'), '<br>', $input_count, $this->php->max_input_vars);
2580 2580
 		} else {
2581 2581
 			return '';
2582 2582
 		}
@@ -2611,7 +2611,7 @@  discard block
 block discarded – undo
2611 2611
  * stores payment gateway info
2612 2612
  * @deprecated
2613 2613
  */
2614
-class EE_Gateway_Config extends EE_Config_Base{
2614
+class EE_Gateway_Config extends EE_Config_Base {
2615 2615
 
2616 2616
 	/**
2617 2617
 	 * Array with keys that are payment gateways slugs, and values are arrays
@@ -2633,9 +2633,9 @@  discard block
 block discarded – undo
2633 2633
 	 *	class constructor
2634 2634
 	 * @deprecated
2635 2635
 	 */
2636
-	public function __construct(){
2636
+	public function __construct() {
2637 2637
 		$this->payment_settings = array();
2638
-		$this->active_gateways = array( 'Invoice' => FALSE );
2638
+		$this->active_gateways = array('Invoice' => FALSE);
2639 2639
 	}
2640 2640
 }
2641 2641
 
Please login to merge, or discard this patch.
core/EE_Registry.core.php 1 patch
Spacing   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 	 * @param  \EE_Dependency_Map $dependency_map
179 179
 	 * @return \EE_Registry instance
180 180
 	 */
181
-	public static function instance( \EE_Dependency_Map $dependency_map = null ) {
181
+	public static function instance(\EE_Dependency_Map $dependency_map = null) {
182 182
 		// check if class object is instantiated
183
-		if ( ! self::$_instance instanceof EE_Registry ) {
184
-			self::$_instance = new EE_Registry( $dependency_map );
183
+		if ( ! self::$_instance instanceof EE_Registry) {
184
+			self::$_instance = new EE_Registry($dependency_map);
185 185
 		}
186 186
 		return self::$_instance;
187 187
 	}
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 	 * @param  \EE_Dependency_Map $dependency_map
197 197
 	 * @return \EE_Registry
198 198
 	 */
199
-	protected function __construct( \EE_Dependency_Map $dependency_map ) {
199
+	protected function __construct(\EE_Dependency_Map $dependency_map) {
200 200
 		$this->_dependency_map = $dependency_map;
201
-		add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) );
201
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
202 202
 	}
203 203
 
204 204
 
@@ -225,19 +225,19 @@  discard block
 block discarded – undo
225 225
 		$this->modules = new StdClass();
226 226
 		$this->shortcodes = new StdClass();
227 227
 		$this->widgets = new StdClass();
228
-		$this->load_core( 'Base', array(), true );
228
+		$this->load_core('Base', array(), true);
229 229
 		// add our request and response objects to the cache
230
-		$request_loader = $this->_dependency_map->class_loader( 'EE_Request' );
230
+		$request_loader = $this->_dependency_map->class_loader('EE_Request');
231 231
 		$this->_set_cached_class(
232 232
 			$request_loader(),
233 233
 			'EE_Request'
234 234
 		);
235
-		$response_loader = $this->_dependency_map->class_loader( 'EE_Response' );
235
+		$response_loader = $this->_dependency_map->class_loader('EE_Response');
236 236
 		$this->_set_cached_class(
237 237
 			$response_loader(),
238 238
 			'EE_Response'
239 239
 		);
240
-		add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) );
240
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
241 241
 	}
242 242
 
243 243
 
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	public function init() {
252 252
 		// Get current page protocol
253
-		$protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://';
253
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
254 254
 		// Output admin-ajax.php URL with same protocol as current page
255
-		self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol );
256
-		self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false;
255
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
256
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
257 257
 	}
258 258
 
259 259
 
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
 	 * @return string
265 265
 	 */
266 266
 	public static function localize_i18n_js_strings() {
267
-		$i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
268
-		foreach ( $i18n_js_strings as $key => $value ) {
269
-			if ( is_scalar( $value ) ) {
270
-				$i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' );
267
+		$i18n_js_strings = (array) EE_Registry::$i18n_js_strings;
268
+		foreach ($i18n_js_strings as $key => $value) {
269
+			if (is_scalar($value)) {
270
+				$i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
271 271
 			}
272 272
 		}
273 273
 
274
-		return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */';
274
+		return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */';
275 275
 	}
276 276
 
277 277
 
@@ -279,15 +279,15 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * @param mixed string | EED_Module $module
281 281
 	 */
282
-	public function add_module( $module ) {
283
-		if ( $module instanceof EED_Module ) {
284
-			$module_class = get_class( $module );
282
+	public function add_module($module) {
283
+		if ($module instanceof EED_Module) {
284
+			$module_class = get_class($module);
285 285
 			$this->modules->{$module_class} = $module;
286 286
 		} else {
287
-			if ( ! class_exists( 'EE_Module_Request_Router' ) ) {
288
-				$this->load_core( 'Module_Request_Router' );
287
+			if ( ! class_exists('EE_Module_Request_Router')) {
288
+				$this->load_core('Module_Request_Router');
289 289
 			}
290
-			$this->modules->{$module} = EE_Module_Request_Router::module_factory( $module );
290
+			$this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
291 291
 		}
292 292
 	}
293 293
 
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 * @param string $module_name
298 298
 	 * @return mixed EED_Module | NULL
299 299
 	 */
300
-	public function get_module( $module_name = '' ) {
301
-		return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null;
300
+	public function get_module($module_name = '') {
301
+		return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null;
302 302
 	}
303 303
 
304 304
 
@@ -312,20 +312,20 @@  discard block
 block discarded – undo
312 312
 	 * @param bool $load_only
313 313
 	 * @return mixed
314 314
 	 */
315
-	public function load_core( $class_name, $arguments = array(), $load_only = false ) {
315
+	public function load_core($class_name, $arguments = array(), $load_only = false) {
316 316
 		$core_paths = apply_filters(
317 317
 			'FHEE__EE_Registry__load_core__core_paths',
318 318
 			array(
319 319
 				EE_CORE,
320 320
 				EE_ADMIN,
321 321
 				EE_CPTS,
322
-				EE_CORE . 'data_migration_scripts' . DS,
323
-				EE_CORE . 'request_stack' . DS,
324
-				EE_CORE . 'middleware' . DS,
322
+				EE_CORE.'data_migration_scripts'.DS,
323
+				EE_CORE.'request_stack'.DS,
324
+				EE_CORE.'middleware'.DS,
325 325
 			)
326 326
 		);
327 327
 		// retrieve instantiated class
328
-		return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only );
328
+		return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
329 329
 	}
330 330
 
331 331
 
@@ -339,15 +339,15 @@  discard block
 block discarded – undo
339 339
 	 * @param bool $load_only
340 340
 	 * @return mixed
341 341
 	 */
342
-	public function load_service( $class_name, $arguments = array(), $load_only = false ) {
342
+	public function load_service($class_name, $arguments = array(), $load_only = false) {
343 343
 		$service_paths = apply_filters(
344 344
 			'FHEE__EE_Registry__load_service__service_paths',
345 345
 			array(
346
-				EE_CORE . 'services' . DS,
346
+				EE_CORE.'services'.DS,
347 347
 			)
348 348
 		);
349 349
 		// retrieve instantiated class
350
-		return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only );
350
+		return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
351 351
 	}
352 352
 
353 353
 
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 	 * @param mixed $arguments
361 361
 	 * @return EE_Data_Migration_Script_Base
362 362
 	 */
363
-	public function load_dms( $class_name, $arguments = array() ) {
363
+	public function load_dms($class_name, $arguments = array()) {
364 364
 		// retrieve instantiated class
365
-		return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false );
365
+		return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
366 366
 	}
367 367
 
368 368
 
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
 	 * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
378 378
 	 * @return EE_Base_Class | bool
379 379
 	 */
380
-	public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) {
381
-		$paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array(
380
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) {
381
+		$paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
382 382
 			EE_CORE,
383 383
 			EE_CLASSES,
384 384
 			EE_BUSINESS
385
-		) );
385
+		));
386 386
 		// retrieve instantiated class
387
-		return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only );
387
+		return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
388 388
 	}
389 389
 
390 390
 
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 * @param bool $load_only
398 398
 	 * @return EEH_Base | bool
399 399
 	 */
400
-	public function load_helper( $class_name, $arguments = array(), $load_only = true ) {
400
+	public function load_helper($class_name, $arguments = array(), $load_only = true) {
401 401
 		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
402
-		$helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) );
402
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
403 403
 		// retrieve instantiated class
404
-		return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only );
404
+		return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
405 405
 	}
406 406
 
407 407
 
@@ -416,16 +416,16 @@  discard block
 block discarded – undo
416 416
 	 * @param bool $cache  whether to cache the object or not.
417 417
 	 * @return mixed
418 418
 	 */
419
-	public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) {
419
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) {
420 420
 		$paths = array(
421 421
 			EE_LIBRARIES,
422
-			EE_LIBRARIES . 'messages' . DS,
423
-			EE_LIBRARIES . 'shortcodes' . DS,
424
-			EE_LIBRARIES . 'qtips' . DS,
425
-			EE_LIBRARIES . 'payment_methods' . DS,
422
+			EE_LIBRARIES.'messages'.DS,
423
+			EE_LIBRARIES.'shortcodes'.DS,
424
+			EE_LIBRARIES.'qtips'.DS,
425
+			EE_LIBRARIES.'payment_methods'.DS,
426 426
 		);
427 427
 		// retrieve instantiated class
428
-		return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only );
428
+		return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
429 429
 	}
430 430
 
431 431
 
@@ -438,13 +438,13 @@  discard block
 block discarded – undo
438 438
 	 * @param bool $load_only
439 439
 	 * @return EEM_Base | bool
440 440
 	 */
441
-	public function load_model( $class_name, $arguments = array(), $load_only = false ) {
442
-		$paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array(
441
+	public function load_model($class_name, $arguments = array(), $load_only = false) {
442
+		$paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
443 443
 			EE_MODELS,
444 444
 			EE_CORE
445
-		) );
445
+		));
446 446
 		// retrieve instantiated class
447
-		return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only );
447
+		return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
448 448
 	}
449 449
 
450 450
 
@@ -457,15 +457,15 @@  discard block
 block discarded – undo
457 457
 	 * @param bool $load_only
458 458
 	 * @return mixed | bool
459 459
 	 */
460
-	public function load_model_class( $class_name, $arguments = array(), $load_only = true ) {
460
+	public function load_model_class($class_name, $arguments = array(), $load_only = true) {
461 461
 		$paths = array(
462
-			EE_MODELS . 'fields' . DS,
463
-			EE_MODELS . 'helpers' . DS,
464
-			EE_MODELS . 'relations' . DS,
465
-			EE_MODELS . 'strategies' . DS
462
+			EE_MODELS.'fields'.DS,
463
+			EE_MODELS.'helpers'.DS,
464
+			EE_MODELS.'relations'.DS,
465
+			EE_MODELS.'strategies'.DS
466 466
 		);
467 467
 		// retrieve instantiated class
468
-		return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only );
468
+		return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
469 469
 	}
470 470
 
471 471
 
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
476 476
 	 * @return boolean
477 477
 	 */
478
-	public function is_model_name( $model_name ) {
479
-		return isset( $this->models[ $model_name ] ) ? true : false;
478
+	public function is_model_name($model_name) {
479
+		return isset($this->models[$model_name]) ? true : false;
480 480
 	}
481 481
 
482 482
 
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 	 * @param bool $load_only
492 492
 	 * @return mixed
493 493
 	 */
494
-	public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) {
494
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) {
495 495
 		// retrieve instantiated class
496
-		return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only );
496
+		return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
497 497
 	}
498 498
 
499 499
 
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
 	 * @param bool $load_only
509 509
 	 * @return EE_Addon
510 510
 	 */
511
-	public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) {
511
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) {
512 512
 		// retrieve instantiated class
513
-		return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only );
513
+		return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
514 514
 	}
515 515
 
516 516
 
@@ -541,46 +541,46 @@  discard block
 block discarded – undo
541 541
 		$load_only = false
542 542
 	) {
543 543
 		// strip php file extension
544
-		$class_name = str_replace( '.php', '', trim( $class_name ) );
544
+		$class_name = str_replace('.php', '', trim($class_name));
545 545
 		// does the class have a prefix ?
546
-		if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) {
546
+		if ( ! empty($class_prefix) && $class_prefix != 'addon') {
547 547
 			// make sure $class_prefix is uppercase
548
-			$class_prefix = strtoupper( trim( $class_prefix ) );
548
+			$class_prefix = strtoupper(trim($class_prefix));
549 549
 			// add class prefix ONCE!!!
550
-			$class_name = $class_prefix . str_replace( $class_prefix, '', $class_name );
550
+			$class_name = $class_prefix.str_replace($class_prefix, '', $class_name);
551 551
 		}
552
-		$class_exists = class_exists( $class_name );
552
+		$class_exists = class_exists($class_name);
553 553
 		// if we're only loading the class and it already exists, then let's just return true immediately
554
-		if ( $load_only && $class_exists ) {
554
+		if ($load_only && $class_exists) {
555 555
 			return true;
556 556
 		}
557 557
 		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
558 558
 		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
559 559
 		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
560
-		if ( $this->_cache_on && $cache && ! $load_only ) {
560
+		if ($this->_cache_on && $cache && ! $load_only) {
561 561
 			// return object if it's already cached
562
-			$cached_class = $this->_get_cached_class( $class_name, $class_prefix );
563
-			if ( $cached_class !== null ) {
562
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix);
563
+			if ($cached_class !== null) {
564 564
 				return $cached_class;
565 565
 			}
566 566
 		}
567 567
 		// if the class doesn't already exist.. then we need to try and find the file and load it
568
-		if ( ! $class_exists ) {
568
+		if ( ! $class_exists) {
569 569
 			// get full path to file
570
-			$path = $this->_resolve_path( $class_name, $type, $file_paths );
570
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
571 571
 			// load the file
572
-			$loaded = $this->_require_file( $path, $class_name, $type, $file_paths );
572
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
573 573
 			// if loading failed, or we are only loading a file but NOT instantiating an object
574
-			if ( ! $loaded || $load_only ) {
574
+			if ( ! $loaded || $load_only) {
575 575
 				// return boolean if only loading, or null if an object was expected
576 576
 				return $load_only ? $loaded : null;
577 577
 			}
578 578
 		}
579 579
 		// instantiate the requested object
580
-		$class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db );
581
-		if ( $this->_cache_on && $cache ) {
580
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
581
+		if ($this->_cache_on && $cache) {
582 582
 			// save it for later... kinda like gum  { : $
583
-			$this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db );
583
+			$this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
584 584
 		}
585 585
 		$this->_cache_on = true;
586 586
 		return $class_obj;
@@ -603,21 +603,21 @@  discard block
 block discarded – undo
603 603
 	 * @param string $class_prefix
604 604
 	 * @return null|object
605 605
 	 */
606
-	protected function _get_cached_class( $class_name, $class_prefix = '' ) {
607
-		if ( isset( $this->_class_abbreviations[ $class_name ] ) ) {
608
-			$class_abbreviation = $this->_class_abbreviations[ $class_name ];
606
+	protected function _get_cached_class($class_name, $class_prefix = '') {
607
+		if (isset($this->_class_abbreviations[$class_name])) {
608
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
609 609
 		} else {
610 610
 			// have to specify something, but not anything that will conflict
611 611
 			$class_abbreviation = 'FANCY_BATMAN_PANTS';
612 612
 		}
613 613
 		// check if class has already been loaded, and return it if it has been
614
-		if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) {
614
+		if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) {
615 615
 			return $this->{$class_abbreviation};
616
-		} else if ( isset ( $this->{$class_name} ) ) {
616
+		} else if (isset ($this->{$class_name} )) {
617 617
 			return $this->{$class_name};
618
-		} else if ( isset ( $this->LIB->{$class_name} ) ) {
618
+		} else if (isset ($this->LIB->{$class_name} )) {
619 619
 			return $this->LIB->{$class_name};
620
-		} else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) {
620
+		} else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) {
621 621
 			return $this->addons->{$class_name};
622 622
 		}
623 623
 		return null;
@@ -638,20 +638,20 @@  discard block
 block discarded – undo
638 638
 	 * @param array $file_paths
639 639
 	 * @return string | bool
640 640
 	 */
641
-	protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) {
641
+	protected function _resolve_path($class_name, $type = '', $file_paths = array()) {
642 642
 		// make sure $file_paths is an array
643
-		$file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths );
643
+		$file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
644 644
 		// cycle thru paths
645
-		foreach ( $file_paths as $key => $file_path ) {
645
+		foreach ($file_paths as $key => $file_path) {
646 646
 			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
647
-			$file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES;
647
+			$file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
648 648
 			// prep file type
649
-			$type = ! empty( $type ) ? trim( $type, '.' ) . '.' : '';
649
+			$type = ! empty($type) ? trim($type, '.').'.' : '';
650 650
 			// build full file path
651
-			$file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php';
651
+			$file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php';
652 652
 			//does the file exist and can be read ?
653
-			if ( is_readable( $file_paths[ $key ] ) ) {
654
-				return $file_paths[ $key ];
653
+			if (is_readable($file_paths[$key])) {
654
+				return $file_paths[$key];
655 655
 			}
656 656
 		}
657 657
 		return false;
@@ -673,29 +673,29 @@  discard block
 block discarded – undo
673 673
 	 * @return boolean
674 674
 	 * @throws \EE_Error
675 675
 	 */
676
-	protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) {
676
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array()) {
677 677
 		// don't give up! you gotta...
678 678
 		try {
679 679
 			//does the file exist and can it be read ?
680
-			if ( ! $path ) {
680
+			if ( ! $path) {
681 681
 				// so sorry, can't find the file
682
-				throw new EE_Error (
682
+				throw new EE_Error(
683 683
 					sprintf(
684
-						__( 'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso' ),
685
-						trim( $type, '.' ),
684
+						__('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
685
+						trim($type, '.'),
686 686
 						$class_name,
687
-						'<br />' . implode( ',<br />', $file_paths )
687
+						'<br />'.implode(',<br />', $file_paths)
688 688
 					)
689 689
 				);
690 690
 			}
691 691
 			// get the file
692
-			require_once( $path );
692
+			require_once($path);
693 693
 			// if the class isn't already declared somewhere
694
-			if ( class_exists( $class_name, false ) === false ) {
694
+			if (class_exists($class_name, false) === false) {
695 695
 				// so sorry, not a class
696 696
 				throw new EE_Error(
697 697
 					sprintf(
698
-						__( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ),
698
+						__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
699 699
 						$type,
700 700
 						$path,
701 701
 						$class_name
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 				);
704 704
 			}
705 705
 
706
-		} catch ( EE_Error $e ) {
706
+		} catch (EE_Error $e) {
707 707
 			$e->get_error();
708 708
 			return false;
709 709
 		}
@@ -735,55 +735,55 @@  discard block
 block discarded – undo
735 735
 	 * @return null | object
736 736
 	 * @throws \EE_Error
737 737
 	 */
738
-	protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) {
738
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) {
739 739
 		$class_obj = null;
740 740
 		// don't give up! you gotta...
741 741
 		try {
742 742
 			// create reflection
743
-			$reflector = $this->get_ReflectionClass( $class_name );
743
+			$reflector = $this->get_ReflectionClass($class_name);
744 744
 			// make sure arguments are an array
745
-			$arguments = is_array( $arguments ) ? $arguments : array( $arguments );
745
+			$arguments = is_array($arguments) ? $arguments : array($arguments);
746 746
 			// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
747 747
 			// else wrap it in an additional array so that it doesn't get split into multiple parameters
748
-			$arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments )
748
+			$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
749 749
 				? $arguments
750
-				: array( $arguments );
750
+				: array($arguments);
751 751
 			// attempt to inject dependencies ?
752
-			if ( $this->_dependency_map->has( $class_name ) ) {
753
-				$arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments );
752
+			if ($this->_dependency_map->has($class_name)) {
753
+				$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
754 754
 			}
755 755
 			// instantiate the class and add to the LIB array for tracking
756 756
 			// EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db)
757
-			if ( $reflector->getConstructor() === null || $reflector->isAbstract() ) {
757
+			if ($reflector->getConstructor() === null || $reflector->isAbstract()) {
758 758
 				// no constructor = static methods only... nothing to instantiate, loading file was enough
759 759
 				//$instantiation_mode = "no constructor";
760 760
 				$class_obj = true;
761
-			} else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) {
761
+			} else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
762 762
 				//$instantiation_mode = "new_instance_from_db";
763
-				$class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments );
764
-			} else if ( method_exists( $class_name, 'new_instance' ) ) {
763
+				$class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
764
+			} else if (method_exists($class_name, 'new_instance')) {
765 765
 				//$instantiation_mode = "new_instance";
766
-				$class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments );
767
-			} else if ( method_exists( $class_name, 'instance' ) ) {
766
+				$class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
767
+			} else if (method_exists($class_name, 'instance')) {
768 768
 				//$instantiation_mode = "instance";
769
-				$class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments );
770
-			} else if ( $reflector->isInstantiable() ) {
769
+				$class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
770
+			} else if ($reflector->isInstantiable()) {
771 771
 				//$instantiation_mode = "isInstantiable";
772
-				$class_obj = $reflector->newInstanceArgs( $arguments );
772
+				$class_obj = $reflector->newInstanceArgs($arguments);
773 773
 			} else {
774 774
 				// heh ? something's not right !
775 775
 				//$instantiation_mode = 'none';
776 776
 				throw new EE_Error(
777 777
 					sprintf(
778
-						__( 'The %s file %s could not be instantiated.', 'event_espresso' ),
778
+						__('The %s file %s could not be instantiated.', 'event_espresso'),
779 779
 						$type,
780 780
 						$class_name
781 781
 					)
782 782
 				);
783 783
 			}
784
-		} catch ( Exception $e ) {
785
-			if ( ! $e instanceof EE_Error ) {
786
-				$e = new EE_Error( $e->getMessage() );
784
+		} catch (Exception $e) {
785
+			if ( ! $e instanceof EE_Error) {
786
+				$e = new EE_Error($e->getMessage());
787 787
 			}
788 788
 			$e->get_error();
789 789
 		}
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
 	 * @param array $array
798 798
 	 * @return bool
799 799
 	 */
800
-	protected function _array_is_numerically_and_sequentially_indexed( array $array ) {
801
-		return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true;
800
+	protected function _array_is_numerically_and_sequentially_indexed(array $array) {
801
+		return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
802 802
 	}
803 803
 
804 804
 
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 	 * @param string $class_name
814 814
 	 * @return ReflectionClass
815 815
 	 */
816
-	public function get_ReflectionClass( $class_name ) {
816
+	public function get_ReflectionClass($class_name) {
817 817
 		if (
818
-			! isset( $this->_reflectors[ $class_name ] )
819
-			|| ! $this->_reflectors[ $class_name ] instanceof ReflectionClass
818
+			! isset($this->_reflectors[$class_name])
819
+			|| ! $this->_reflectors[$class_name] instanceof ReflectionClass
820 820
 		) {
821
-			$this->_reflectors[ $class_name ] = new ReflectionClass( $class_name );
821
+			$this->_reflectors[$class_name] = new ReflectionClass($class_name);
822 822
 		}
823
-		return $this->_reflectors[ $class_name ];
823
+		return $this->_reflectors[$class_name];
824 824
 	}
825 825
 
826 826
 
@@ -845,45 +845,45 @@  discard block
 block discarded – undo
845 845
 	 * @param array $arguments
846 846
 	 * @return array
847 847
 	 */
848
-	protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) {
848
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) {
849 849
 		// let's examine the constructor
850 850
 		$constructor = $reflector->getConstructor();
851 851
 		// whu? huh? nothing?
852
-		if ( ! $constructor ) {
852
+		if ( ! $constructor) {
853 853
 			return $arguments;
854 854
 		}
855 855
 		// get constructor parameters
856 856
 		$params = $constructor->getParameters();
857 857
 		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
858
-		$argument_keys = array_keys( $arguments );
858
+		$argument_keys = array_keys($arguments);
859 859
 		// now loop thru all of the constructors expected parameters
860
-		foreach ( $params as $index => $param ) {
860
+		foreach ($params as $index => $param) {
861 861
 			// is this a dependency for a specific class ?
862 862
 			$param_class = $param->getClass() ? $param->getClass()->name : null;
863 863
 			if (
864 864
 				// param is not even a class
865
-				empty( $param_class )
865
+				empty($param_class)
866 866
 				// and something already exists in the incoming arguments for this param
867
-				&& isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] )
867
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
868 868
 			) {
869 869
 				// so let's skip this argument and move on to the next
870 870
 				continue;
871 871
 			} else if (
872 872
 				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
873
-				! empty( $param_class )
874
-				&& isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] )
875
-				&& $arguments[ $argument_keys[ $index ] ] instanceof $param_class
873
+				! empty($param_class)
874
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
875
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
876 876
 			) {
877 877
 				// skip this argument and move on to the next
878 878
 				continue;
879 879
 			} else if (
880 880
 				// parameter is type hinted as a class, and should be injected
881
-				! empty( $param_class )
882
-				&& $this->_dependency_map->has_dependency_for_class( $class_name, $param_class )
881
+				! empty($param_class)
882
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
883 883
 			) {
884
-				$arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index );
884
+				$arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
885 885
 			} else {
886
-				$arguments[ $index ] = $param->getDefaultValue();
886
+				$arguments[$index] = $param->getDefaultValue();
887 887
 			}
888 888
 
889 889
 		}
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 	 * @param mixed $index
901 901
 	 * @return array
902 902
 	 */
903
-	protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) {
903
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index) {
904 904
 		$dependency = null;
905 905
 		// should dependency be loaded from cache ?
906 906
 		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
@@ -910,30 +910,30 @@  discard block
 block discarded – undo
910 910
 			: false;
911 911
 		// we might have a dependency...
912 912
 		// let's MAYBE try and find it in our cache if that's what's been requested
913
-		$cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null;
913
+		$cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
914 914
 		// and grab it if it exists
915
-		if ( $cached_class instanceof $param_class ) {
915
+		if ($cached_class instanceof $param_class) {
916 916
 			$dependency = $cached_class;
917
-		} else if ( $param_class != $class_name ) {
917
+		} else if ($param_class != $class_name) {
918 918
 			// obtain the loader method from the dependency map
919
-			$loader = $this->_dependency_map->class_loader( $param_class );
919
+			$loader = $this->_dependency_map->class_loader($param_class);
920 920
 			// is loader a custom closure ?
921
-			if ( $loader instanceof Closure ) {
921
+			if ($loader instanceof Closure) {
922 922
 				$dependency = $loader();
923 923
 			} else {
924 924
 				// set the cache on property for the recursive loading call
925 925
 				$this->_cache_on = $cache_on;
926 926
 				// if not, then let's try and load it via the registry
927
-				$dependency = $this->{$loader}( $param_class );
927
+				$dependency = $this->{$loader}($param_class);
928 928
 			}
929 929
 		}
930 930
 		// did we successfully find the correct dependency ?
931
-		if ( $dependency instanceof $param_class ) {
931
+		if ($dependency instanceof $param_class) {
932 932
 			// then let's inject it into the incoming array of arguments at the correct location
933
-			if ( isset( $argument_keys[ $index ] ) ) {
934
-				$arguments[ $argument_keys[ $index ] ] = $dependency;
933
+			if (isset($argument_keys[$index])) {
934
+				$arguments[$argument_keys[$index]] = $dependency;
935 935
 			} else {
936
-				$arguments[ $index ] = $dependency;
936
+				$arguments[$index] = $dependency;
937 937
 			}
938 938
 		}
939 939
 		return $arguments;
@@ -958,16 +958,16 @@  discard block
 block discarded – undo
958 958
 	 * @param bool $from_db
959 959
 	 * @return void
960 960
 	 */
961
-	protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) {
961
+	protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) {
962 962
 		// return newly instantiated class
963
-		if ( isset( $this->_class_abbreviations[ $class_name ] ) ) {
964
-			$class_abbreviation = $this->_class_abbreviations[ $class_name ];
963
+		if (isset($this->_class_abbreviations[$class_name])) {
964
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
965 965
 			$this->{$class_abbreviation} = $class_obj;
966
-		} else if ( property_exists( $this, $class_name ) ) {
966
+		} else if (property_exists($this, $class_name)) {
967 967
 			$this->{$class_name} = $class_obj;
968
-		} else if ( $class_prefix == 'addon' ) {
968
+		} else if ($class_prefix == 'addon') {
969 969
 			$this->addons->{$class_name} = $class_obj;
970
-		} else if ( ! $from_db ) {
970
+		} else if ( ! $from_db) {
971 971
 			$this->LIB->{$class_name} = $class_obj;
972 972
 		}
973 973
 	}
@@ -984,12 +984,12 @@  discard block
 block discarded – undo
984 984
 	 * @param array  $arguments
985 985
 	 * @return object
986 986
 	 */
987
-	public static function factory( $classname, $arguments = array() ) {
988
-		$loader = self::instance()->_dependency_map->class_loader( $classname );
989
-		if ( $loader instanceof Closure ) {
990
-			return $loader( $arguments );
991
-		} else if ( method_exists( EE_Registry::instance(), $loader ) ) {
992
-			return EE_Registry::instance()->{$loader}( $classname, $arguments );
987
+	public static function factory($classname, $arguments = array()) {
988
+		$loader = self::instance()->_dependency_map->class_loader($classname);
989
+		if ($loader instanceof Closure) {
990
+			return $loader($arguments);
991
+		} else if (method_exists(EE_Registry::instance(), $loader)) {
992
+			return EE_Registry::instance()->{$loader}($classname, $arguments);
993 993
 		}
994 994
 		return null;
995 995
 	}
@@ -1002,9 +1002,9 @@  discard block
 block discarded – undo
1002 1002
 	 * @param string $name
1003 1003
 	 * @return EE_Addon
1004 1004
 	 */
1005
-	public function get_addon_by_name( $name ) {
1006
-		foreach ( $this->addons as $addon ) {
1007
-			if ( $addon->name() == $name ) {
1005
+	public function get_addon_by_name($name) {
1006
+		foreach ($this->addons as $addon) {
1007
+			if ($addon->name() == $name) {
1008 1008
 				return $addon;
1009 1009
 			}
1010 1010
 		}
@@ -1020,8 +1020,8 @@  discard block
 block discarded – undo
1020 1020
 	 */
1021 1021
 	public function get_addons_by_name() {
1022 1022
 		$addons = array();
1023
-		foreach ( $this->addons as $addon ) {
1024
-			$addons[ $addon->name() ] = $addon;
1023
+		foreach ($this->addons as $addon) {
1024
+			$addons[$addon->name()] = $addon;
1025 1025
 		}
1026 1026
 		return $addons;
1027 1027
 	}
@@ -1036,14 +1036,14 @@  discard block
 block discarded – undo
1036 1036
 	 * @return \EEM_Base
1037 1037
 	 * @throws \EE_Error
1038 1038
 	 */
1039
-	public function reset_model( $model_name ) {
1040
-		$model = $this->load_model( $model_name );
1041
-		$model_class_name = get_class( $model );
1039
+	public function reset_model($model_name) {
1040
+		$model = $this->load_model($model_name);
1041
+		$model_class_name = get_class($model);
1042 1042
 		//get that model reset it and make sure we nuke the old reference to it
1043
-		if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) {
1043
+		if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1044 1044
 			$this->LIB->{$model_class_name} = $model::reset();
1045 1045
 		} else {
1046
-			throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) );
1046
+			throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1047 1047
 		}
1048 1048
 		return $this->LIB->{$model_class_name};
1049 1049
 	}
@@ -1064,16 +1064,16 @@  discard block
 block discarded – undo
1064 1064
 	 *                                  code instead can just change the model context to a different blog id if necessary
1065 1065
 	 * @return EE_Registry
1066 1066
 	 */
1067
-	public static function reset( $hard = false, $reinstantiate = true, $reset_models = true ) {
1067
+	public static function reset($hard = false, $reinstantiate = true, $reset_models = true) {
1068 1068
 		$instance = self::instance();
1069 1069
 		EEH_Activation::reset();
1070 1070
 		$instance->_cache_on = true;
1071
-		$instance->CFG = EE_Config::reset( $hard, $reinstantiate );
1072
-		unset( $instance->LIB->EE_Data_Migration_Manager );
1071
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1072
+		unset($instance->LIB->EE_Data_Migration_Manager);
1073 1073
 		$instance->LIB = new stdClass();
1074
-		if ( $reset_models ) {
1075
-			foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) {
1076
-				$instance->reset_model( $model_name );
1074
+		if ($reset_models) {
1075
+			foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
1076
+				$instance->reset_model($model_name);
1077 1077
 			}
1078 1078
 		}
1079 1079
 		return $instance;
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 	 * @param $a
1095 1095
 	 * @param $b
1096 1096
 	 */
1097
-	final function __call( $a, $b ) {
1097
+	final function __call($a, $b) {
1098 1098
 	}
1099 1099
 
1100 1100
 
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 	/**
1103 1103
 	 * @param $a
1104 1104
 	 */
1105
-	final function __get( $a ) {
1105
+	final function __get($a) {
1106 1106
 	}
1107 1107
 
1108 1108
 
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 	 * @param $a
1112 1112
 	 * @param $b
1113 1113
 	 */
1114
-	final function __set( $a, $b ) {
1114
+	final function __set($a, $b) {
1115 1115
 	}
1116 1116
 
1117 1117
 
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 	/**
1120 1120
 	 * @param $a
1121 1121
 	 */
1122
-	final function __isset( $a ) {
1122
+	final function __isset($a) {
1123 1123
 	}
1124 1124
 
1125 1125
 
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 	/**
1128 1128
 	 * @param $a
1129 1129
 	 */
1130
-	final function __unset( $a ) {
1130
+	final function __unset($a) {
1131 1131
 	}
1132 1132
 
1133 1133
 
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 	 * @param $a
1175 1175
 	 * @param $b
1176 1176
 	 */
1177
-	final static function __callStatic( $a, $b ) {
1177
+	final static function __callStatic($a, $b) {
1178 1178
 	}
1179 1179
 
1180 1180
 	/**
@@ -1183,9 +1183,9 @@  discard block
 block discarded – undo
1183 1183
 	 */
1184 1184
 	public function cpt_models() {
1185 1185
 		$cpt_models = array();
1186
-		foreach( $this->non_abstract_db_models as $short_name => $classname ) {
1187
-			if( is_subclass_of(  $classname, 'EEM_CPT_Base' ) ) {
1188
-				$cpt_models[ $short_name ] = $classname;
1186
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1187
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1188
+				$cpt_models[$short_name] = $classname;
1189 1189
 			}
1190 1190
 		}
1191 1191
 		return $cpt_models;
Please login to merge, or discard this patch.
espresso.php 1 patch
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('ABSPATH')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  *
42 42
  */
43 43
 
44
-if ( function_exists( 'espresso_version' ) ) {
44
+if (function_exists('espresso_version')) {
45 45
 
46 46
 	/**
47 47
 	 *    espresso_duplicate_plugin_error
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 	function espresso_duplicate_plugin_error() {
51 51
 		?>
52 52
 		<div class="error">
53
-			<p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p>
53
+			<p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p>
54 54
 		</div>
55 55
 		<?php
56
-		espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
56
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
57 57
 	}
58
-	add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 );
58
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59 59
 
60 60
 } else {
61 61
 
@@ -66,103 +66,103 @@  discard block
 block discarded – undo
66 66
 	 * @return string
67 67
 	 */
68 68
 	function espresso_version() {
69
-		return apply_filters( 'FHEE__espresso__espresso_version', '4.9.0.rc.034' );
69
+		return apply_filters('FHEE__espresso__espresso_version', '4.9.0.rc.034');
70 70
 	}
71 71
 
72 72
 	// define versions
73
-	define( 'EVENT_ESPRESSO_VERSION', espresso_version() );
74
-	define( 'EE_MIN_WP_VER_REQUIRED', '4.1' );
75
-	define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' );
76
-	define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' );
77
-	define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' );
78
-	define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION );
79
-	define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ );
73
+	define('EVENT_ESPRESSO_VERSION', espresso_version());
74
+	define('EE_MIN_WP_VER_REQUIRED', '4.1');
75
+	define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
76
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.0');
77
+	define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
78
+	define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION);
79
+	define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
80 80
 	//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
81
-	if ( ! defined( 'DS' ) ) {
82
-		define( 'DS', '/' );
81
+	if ( ! defined('DS')) {
82
+		define('DS', '/');
83 83
 	}
84
-	if ( ! defined( 'PS' ) ) {
85
-		define( 'PS', PATH_SEPARATOR );
84
+	if ( ! defined('PS')) {
85
+		define('PS', PATH_SEPARATOR);
86 86
 	}
87
-	if ( ! defined( 'SP' ) ) {
88
-		define( 'SP', ' ' );
87
+	if ( ! defined('SP')) {
88
+		define('SP', ' ');
89 89
 	}
90
-	if ( ! defined( 'EENL' ) ) {
91
-		define( 'EENL', "\n" );
90
+	if ( ! defined('EENL')) {
91
+		define('EENL', "\n");
92 92
 	}
93
-	define( 'EE_SUPPORT_EMAIL', '[email protected]' );
93
+	define('EE_SUPPORT_EMAIL', '[email protected]');
94 94
 	// define the plugin directory and URL
95
-	define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) );
96
-	define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) );
97
-	define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) );
95
+	define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
96
+	define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
97
+	define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
98 98
 	// main root folder paths
99
-	define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS );
100
-	define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS );
101
-	define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS );
102
-	define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS );
103
-	define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS );
104
-	define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS );
105
-	define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS );
106
-	define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS );
99
+	define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS);
100
+	define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS);
101
+	define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS);
102
+	define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS);
103
+	define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS);
104
+	define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS);
105
+	define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS);
106
+	define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS);
107 107
 	// core system paths
108
-	define( 'EE_ADMIN', EE_CORE . 'admin' . DS );
109
-	define( 'EE_CPTS', EE_CORE . 'CPTs' . DS );
110
-	define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS );
111
-	define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS );
112
-	define( 'EE_BUSINESS', EE_CORE . 'business' . DS );
113
-	define( 'EE_MODELS', EE_CORE . 'db_models' . DS );
114
-	define( 'EE_HELPERS', EE_CORE . 'helpers' . DS );
115
-	define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS );
116
-	define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS );
117
-	define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS );
118
-	define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS );
119
-	define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS );
108
+	define('EE_ADMIN', EE_CORE.'admin'.DS);
109
+	define('EE_CPTS', EE_CORE.'CPTs'.DS);
110
+	define('EE_CLASSES', EE_CORE.'db_classes'.DS);
111
+	define('EE_INTERFACES', EE_CORE.'interfaces'.DS);
112
+	define('EE_BUSINESS', EE_CORE.'business'.DS);
113
+	define('EE_MODELS', EE_CORE.'db_models'.DS);
114
+	define('EE_HELPERS', EE_CORE.'helpers'.DS);
115
+	define('EE_LIBRARIES', EE_CORE.'libraries'.DS);
116
+	define('EE_TEMPLATES', EE_CORE.'templates'.DS);
117
+	define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS);
118
+	define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS);
119
+	define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS);
120 120
 	// gateways
121
-	define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS );
122
-	define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS );
121
+	define('EE_GATEWAYS', EE_MODULES.'gateways'.DS);
122
+	define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS);
123 123
 	// asset URL paths
124
-	define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS );
125
-	define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS );
126
-	define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS );
127
-	define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS );
128
-	define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' );
129
-	define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' );
124
+	define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS);
125
+	define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS);
126
+	define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS);
127
+	define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS);
128
+	define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/');
129
+	define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/');
130 130
 	// define upload paths
131 131
 	$uploads = wp_upload_dir();
132 132
 	// define the uploads directory and URL
133
-	define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS );
134
-	define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS );
133
+	define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS);
134
+	define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS);
135 135
 	// define the templates directory and URL
136
-	define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS );
137
-	define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS );
136
+	define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS);
137
+	define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS);
138 138
 	// define the gateway directory and URL
139
-	define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS );
140
-	define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS );
139
+	define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS);
140
+	define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS);
141 141
 	// languages folder/path
142
-	define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS );
143
-	define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS );
142
+	define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS);
143
+	define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS);
144 144
 	//check for dompdf fonts in uploads
145
-	if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) {
146
-		define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS );
145
+	if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) {
146
+		define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS);
147 147
 	}
148 148
 	//ajax constants
149
-	define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false );
150
-	define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false );
149
+	define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false);
150
+	define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false);
151 151
 	//just a handy constant occasionally needed for finding values representing infinity in the DB
152 152
 	//you're better to use this than its straight value (currently -1) in case you ever
153 153
 	//want to change its default value! or find when -1 means infinity
154
-	define( 'EE_INF_IN_DB', -1 );
155
-	define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX );
156
-	define( 'EE_DEBUG', false );
154
+	define('EE_INF_IN_DB', -1);
155
+	define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
156
+	define('EE_DEBUG', false);
157 157
 
158 158
 	/**
159 159
 	 *    espresso_plugin_activation
160 160
 	 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
161 161
 	 */
162 162
 	function espresso_plugin_activation() {
163
-		update_option( 'ee_espresso_activation', true );
163
+		update_option('ee_espresso_activation', true);
164 164
 	}
165
-	register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' );
165
+	register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
166 166
 
167 167
 
168 168
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		//	}
177 177
 		//
178 178
 	}
179
-	register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' );
179
+	register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
180 180
 
181 181
 
182 182
 
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 	 */
187 187
 	function espresso_load_error_handling() {
188 188
 		// load debugging tools
189
-		if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) {
190
-			require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' );
189
+		if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
190
+			require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php');
191 191
 			EEH_Debug_Tools::instance();
192 192
 		}
193 193
 		// load error handling
194
-		if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) {
195
-			require_once( EE_CORE . 'EE_Error.core.php' );
194
+		if (is_readable(EE_CORE.'EE_Error.core.php')) {
195
+			require_once(EE_CORE.'EE_Error.core.php');
196 196
 		} else {
197
-			wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) );
197
+			wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso'));
198 198
 		}
199 199
 	}
200 200
 
@@ -208,25 +208,25 @@  discard block
 block discarded – undo
208 208
 	 * @param    string $full_path_to_file
209 209
 	 * @throws    EE_Error
210 210
 	 */
211
-	function espresso_load_required( $classname, $full_path_to_file ) {
211
+	function espresso_load_required($classname, $full_path_to_file) {
212 212
 		static $error_handling_loaded = false;
213
-		if ( ! $error_handling_loaded ) {
213
+		if ( ! $error_handling_loaded) {
214 214
 			espresso_load_error_handling();
215 215
 			$error_handling_loaded = true;
216 216
 		}
217
-		if ( is_readable( $full_path_to_file ) ) {
218
-			require_once( $full_path_to_file );
217
+		if (is_readable($full_path_to_file)) {
218
+			require_once($full_path_to_file);
219 219
 		} else {
220
-			throw new EE_Error ( sprintf(
221
-				__( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ),
220
+			throw new EE_Error(sprintf(
221
+				__('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'),
222 222
 				$classname
223
-			) );
223
+			));
224 224
 		}
225 225
 	}
226 226
 
227
-	espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' );
228
-	espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' );
229
-	espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' );
227
+	espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php');
228
+	espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php');
229
+	espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php');
230 230
 	new EE_Bootstrap();
231 231
 
232 232
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
 
237 237
 
238
-if ( ! function_exists( 'espresso_deactivate_plugin' ) ) {
238
+if ( ! function_exists('espresso_deactivate_plugin')) {
239 239
 	/**
240 240
 	*    deactivate_plugin
241 241
 	* usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 	* @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
245 245
 	* @return    void
246 246
 	*/
247
-	function espresso_deactivate_plugin( $plugin_basename = '' ) {
248
-		if ( ! function_exists( 'deactivate_plugins' ) ) {
249
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
247
+	function espresso_deactivate_plugin($plugin_basename = '') {
248
+		if ( ! function_exists('deactivate_plugins')) {
249
+			require_once(ABSPATH.'wp-admin/includes/plugin.php');
250 250
 		}
251
-		unset( $_GET[ 'activate' ] );
252
-		unset( $_REQUEST[ 'activate' ] );
253
-		deactivate_plugins( $plugin_basename );
251
+		unset($_GET['activate']);
252
+		unset($_REQUEST['activate']);
253
+		deactivate_plugins($plugin_basename);
254 254
 	}
255 255
 }
Please login to merge, or discard this patch.