Completed
Branch BUG-10246-use-wp-json-encode (aacd81)
by
unknown
23:44 queued 12:52
created
core/EE_Session.core.php 2 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -163,18 +163,18 @@  discard block
 block discarded – undo
163 163
 				$this->{$var_name} = $session_setting;
164 164
 			}
165 165
 		}
166
-         // are we using encryption?
167
-         $this->_use_encryption = $encryption instanceof EE_Encryption && EE_Registry::instance()->CFG->admin->encode_session_data();
168
-         // \EEH_Debug_Tools::printr($this->_use_encryption, '$this->_use_encryption', __FILE__, __LINE__);
169
-        // encrypt data via: $this->encryption->encrypt();
170
-        $this->encryption = $encryption;
166
+		 // are we using encryption?
167
+		 $this->_use_encryption = $encryption instanceof EE_Encryption && EE_Registry::instance()->CFG->admin->encode_session_data();
168
+		 // \EEH_Debug_Tools::printr($this->_use_encryption, '$this->_use_encryption', __FILE__, __LINE__);
169
+		// encrypt data via: $this->encryption->encrypt();
170
+		$this->encryption = $encryption;
171 171
 		// filter hook allows outside functions/classes/plugins to change default empty cart
172 172
 		$extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() );
173 173
 		array_merge( $this->_default_session_vars, $extra_default_session_vars );
174 174
 		// apply default session vars
175 175
 		$this->_set_defaults();
176
-         add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
177
-         // check request for 'clear_session' param
176
+		 add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
177
+		 // check request for 'clear_session' param
178 178
 		add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' ));
179 179
 		// once everything is all said and done,
180 180
 		add_action( 'shutdown', array( $this, 'update' ), 100 );
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
 
185 185
 
186 186
 
187
-     /**
188
-      * @return void
189
-      * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
190
-      * @throws \EE_Error
191
-      */
187
+	 /**
188
+	  * @return void
189
+	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
190
+	  * @throws \EE_Error
191
+	  */
192 192
 	 public function open_session() {
193
-         // check for existing session and retrieve it from db
194
-         if ( ! $this->_espresso_session()) {
195
-             // or just start a new one
196
-             $this->_create_espresso_session();
197
-         }
198
-     }
193
+		 // check for existing session and retrieve it from db
194
+		 if ( ! $this->_espresso_session()) {
195
+			 // or just start a new one
196
+			 $this->_create_espresso_session();
197
+		 }
198
+	 }
199 199
 
200 200
 
201 201
 	 /**
@@ -408,16 +408,16 @@  discard block
 block discarded – undo
408 408
 		// set the "user agent"
409 409
 		$this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE;
410 410
 		// now let's retrieve what's in the db
411
-        $session_data = $this->_retrieve_session_data();
412
-        if (! empty($session_data)) {
413
-            // get the current time in UTC
411
+		$session_data = $this->_retrieve_session_data();
412
+		if (! empty($session_data)) {
413
+			// get the current time in UTC
414 414
 			$this->_time = isset( $this->_time ) ? $this->_time : time();
415 415
 			// and reset the session expiration
416 416
 			$this->_expiration = isset( $session_data['expiration'] )
417 417
 				? $session_data['expiration']
418 418
 				: $this->_time + $this->_lifespan;
419 419
 		} else {
420
-            // set initial site access time and the session expiration
420
+			// set initial site access time and the session expiration
421 421
 			$this->_set_init_access_and_expiration();
422 422
 			// set referer
423 423
 			$this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] )
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 			// no previous session = go back and create one (on top of the data above)
427 427
 			return FALSE;
428 428
 		}
429
-        // now the user agent
429
+		// now the user agent
430 430
 		if ( $session_data['user_agent'] !== $this->_user_agent ) {
431 431
 			return FALSE;
432 432
 		}
@@ -444,95 +444,95 @@  discard block
 block discarded – undo
444 444
 
445 445
 
446 446
 
447
-     /**
448
-      * _get_session_data
449
-      * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup databases
450
-      *
451
-      * @return array
452
-      * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
453
-      */
454
-     protected function _retrieve_session_data()
455
-     {
456
-         $ssn_key = EE_Session::session_id_prefix . $this->_sid;
457
-         try {
458
-             // we're using WP's Transient API to store session data using the PHP session ID as the option name
459
-             $session_data = get_transient($ssn_key);
460
-	         if ($session_data === false) {
461
-		         return array();
462
-             }
463
-             if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
464
-                 $hash_check = get_transient(EE_Session::hash_check_prefix . $this->_sid);
465
-                 if ($hash_check && $hash_check !== md5($session_data)) {
466
-	                 EE_Error::add_error(
467
-                         sprintf(
468
-                             __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'),
469
-                             EE_Session::session_id_prefix . $this->_sid
470
-                         ),
471
-                         __FILE__, __FUNCTION__, __LINE__
472
-                     );
473
-                 }
474
-             }
475
-         } catch (Exception $e) {
476
-             // let's just eat that error for now and attempt to correct any corrupted data
477
-             global $wpdb;
478
-             $row = $wpdb->get_row(
479
-                 $wpdb->prepare(
480
-                     "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
481
-                     '_transient_' . $ssn_key
482
-                 )
483
-             );
484
-             $session_data = is_object($row) ? $row->option_value : null;
485
-             if ($session_data) {
486
-                 $session_data = preg_replace_callback(
487
-                     '!s:(d+):"(.*?)";!',
488
-                     function ($match) {
489
-                         return $match[1] === strlen($match[2])
490
-                             ? $match[0]
491
-                             : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
492
-                     },
493
-                     $session_data
494
-                 );
495
-             }
496
-	         $session_data = maybe_unserialize($session_data);
497
-         }
498
-	     // in case the data is encoded... try to decode it
499
-         $session_data = $this->encryption instanceof EE_Encryption
500
-             ? $this->encryption->base64_string_decode($session_data)
501
-             : $session_data;
502
-
503
-         if ( ! is_array($session_data)) {
504
-             try {
505
-	             $session_data = maybe_unserialize($session_data);
506
-             } catch (Exception $e) {
507
-                 $msg = esc_html__(
508
-                     'An error occurred while attempting to unserialize the session data.',
509
-                     'event_espresso'
510
-                 );
511
-                 $msg .= WP_DEBUG
512
-                     ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
513
-                     : '';
514
-                 throw new InvalidSessionDataException($msg, 0, $e);
515
-             }
516
-         }
517
-         // just a check to make sure the session array is indeed an array
518
-         if ( ! is_array($session_data)) {
519
-             // no?!?! then something is wrong
520
-             $msg = esc_html__(
521
-                 'The session data is missing, invalid, or corrupted.',
522
-                 'event_espresso'
523
-             );
524
-             $msg .= WP_DEBUG
525
-                 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
526
-                 : '';
527
-	         throw new InvalidSessionDataException($msg);
528
-         }
529
-	     if ( isset( $this->_session_data['transaction'] ) && absint( $this->_session_data['transaction'] ) !== 0 ) {
530
-		     $this->_session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
531
-			     $this->_session_data['transaction']
532
-	         );
533
-	     }
534
-	     return $session_data;
535
-     }
447
+	 /**
448
+	  * _get_session_data
449
+	  * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup databases
450
+	  *
451
+	  * @return array
452
+	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
453
+	  */
454
+	 protected function _retrieve_session_data()
455
+	 {
456
+		 $ssn_key = EE_Session::session_id_prefix . $this->_sid;
457
+		 try {
458
+			 // we're using WP's Transient API to store session data using the PHP session ID as the option name
459
+			 $session_data = get_transient($ssn_key);
460
+			 if ($session_data === false) {
461
+				 return array();
462
+			 }
463
+			 if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
464
+				 $hash_check = get_transient(EE_Session::hash_check_prefix . $this->_sid);
465
+				 if ($hash_check && $hash_check !== md5($session_data)) {
466
+					 EE_Error::add_error(
467
+						 sprintf(
468
+							 __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'),
469
+							 EE_Session::session_id_prefix . $this->_sid
470
+						 ),
471
+						 __FILE__, __FUNCTION__, __LINE__
472
+					 );
473
+				 }
474
+			 }
475
+		 } catch (Exception $e) {
476
+			 // let's just eat that error for now and attempt to correct any corrupted data
477
+			 global $wpdb;
478
+			 $row = $wpdb->get_row(
479
+				 $wpdb->prepare(
480
+					 "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
481
+					 '_transient_' . $ssn_key
482
+				 )
483
+			 );
484
+			 $session_data = is_object($row) ? $row->option_value : null;
485
+			 if ($session_data) {
486
+				 $session_data = preg_replace_callback(
487
+					 '!s:(d+):"(.*?)";!',
488
+					 function ($match) {
489
+						 return $match[1] === strlen($match[2])
490
+							 ? $match[0]
491
+							 : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
492
+					 },
493
+					 $session_data
494
+				 );
495
+			 }
496
+			 $session_data = maybe_unserialize($session_data);
497
+		 }
498
+		 // in case the data is encoded... try to decode it
499
+		 $session_data = $this->encryption instanceof EE_Encryption
500
+			 ? $this->encryption->base64_string_decode($session_data)
501
+			 : $session_data;
502
+
503
+		 if ( ! is_array($session_data)) {
504
+			 try {
505
+				 $session_data = maybe_unserialize($session_data);
506
+			 } catch (Exception $e) {
507
+				 $msg = esc_html__(
508
+					 'An error occurred while attempting to unserialize the session data.',
509
+					 'event_espresso'
510
+				 );
511
+				 $msg .= WP_DEBUG
512
+					 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
513
+					 : '';
514
+				 throw new InvalidSessionDataException($msg, 0, $e);
515
+			 }
516
+		 }
517
+		 // just a check to make sure the session array is indeed an array
518
+		 if ( ! is_array($session_data)) {
519
+			 // no?!?! then something is wrong
520
+			 $msg = esc_html__(
521
+				 'The session data is missing, invalid, or corrupted.',
522
+				 'event_espresso'
523
+			 );
524
+			 $msg .= WP_DEBUG
525
+				 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
526
+				 : '';
527
+			 throw new InvalidSessionDataException($msg);
528
+		 }
529
+		 if ( isset( $this->_session_data['transaction'] ) && absint( $this->_session_data['transaction'] ) !== 0 ) {
530
+			 $this->_session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
531
+				 $this->_session_data['transaction']
532
+			 );
533
+		 }
534
+		 return $session_data;
535
+	 }
536 536
 
537 537
 
538 538
 
@@ -754,15 +754,15 @@  discard block
 block discarded – undo
754 754
 		}
755 755
 		// then serialize all of our session data
756 756
 		$session_data = serialize($this->_session_data);
757
-        //use the "private" function _wp_json_convert_string to convert the string to UTF8
758
-        //which is what the DB is usually in. This way when the string gets inserted into the DB, it won't change
759
-        //encodings at that point, which change can cause the hash to be different if some of the session data was
760
-        //in a different encoding, like ANSI.
761
-        //we double-check the function exists first because it's labelled "private", so it's possible it will be removed
762
-        //from WP some day2
763
-        if( function_exists( '_wp_json_convert_string' ) ) {
764
-            $session_data = _wp_json_convert_string( $session_data );
765
-        }
757
+		//use the "private" function _wp_json_convert_string to convert the string to UTF8
758
+		//which is what the DB is usually in. This way when the string gets inserted into the DB, it won't change
759
+		//encodings at that point, which change can cause the hash to be different if some of the session data was
760
+		//in a different encoding, like ANSI.
761
+		//we double-check the function exists first because it's labelled "private", so it's possible it will be removed
762
+		//from WP some day2
763
+		if( function_exists( '_wp_json_convert_string' ) ) {
764
+			$session_data = _wp_json_convert_string( $session_data );
765
+		}
766 766
 		// do we need to also encode it to avoid corrupted data when saved to the db?
767 767
 		$session_data = $this->_use_encryption ? $this->encryption->base64_string_encode( $session_data ) : $session_data;
768 768
 		// maybe save hash check
Please login to merge, or discard this patch.
Spacing   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\exceptions\InvalidSessionDataException;
2 2
 
3
-if (!defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
4 4
 /**
5 5
  *
6 6
  * EE_Session class
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	  * array for defining default session vars
92 92
 	  * @var array
93 93
 	  */
94
-	 private $_default_session_vars = array (
94
+	 private $_default_session_vars = array(
95 95
 		'id' => NULL,
96 96
 		'user_id' => NULL,
97 97
 		'ip_address' => NULL,
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 	  * @throws InvalidSessionDataException
112 112
 	  * @throws \EE_Error
113 113
 	  */
114
-	public static function instance( EE_Encryption $encryption = null ) {
114
+	public static function instance(EE_Encryption $encryption = null) {
115 115
 		// check if class object is instantiated
116 116
 		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
117 117
 		// add_filter( 'FHEE_load_EE_Session', '__return_false' );
118
-		if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) {
119
-			self::$_instance = new self( $encryption );
118
+		if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) {
119
+			self::$_instance = new self($encryption);
120 120
 		}
121 121
 		return self::$_instance;
122 122
 	}
@@ -132,15 +132,15 @@  discard block
 block discarded – undo
132 132
 	  * @throws \EE_Error
133 133
 	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
134 134
 	  */
135
-	 protected function __construct( EE_Encryption $encryption = null ) {
135
+	 protected function __construct(EE_Encryption $encryption = null) {
136 136
 
137 137
 		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' );
138
-		if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) {
138
+		if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) {
139 139
 			return;
140 140
 		}
141
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
142
-		if ( ! defined( 'ESPRESSO_SESSION' ) ) {
143
-			define( 'ESPRESSO_SESSION', true );
141
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
142
+		if ( ! defined('ESPRESSO_SESSION')) {
143
+			define('ESPRESSO_SESSION', true);
144 144
 		}
145 145
 		// default session lifespan in seconds
146 146
 		$this->_lifespan = apply_filters(
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 		 * 		}
155 155
 		 */
156 156
 		// retrieve session options from db
157
-		$session_settings = (array) get_option( 'ee_session_settings', array() );
158
-		if ( ! empty( $session_settings )) {
157
+		$session_settings = (array) get_option('ee_session_settings', array());
158
+		if ( ! empty($session_settings)) {
159 159
 			// cycle though existing session options
160
-			foreach ( $session_settings as $var_name => $session_setting ) {
160
+			foreach ($session_settings as $var_name => $session_setting) {
161 161
 				// set values for class properties
162
-				$var_name = '_' . $var_name;
162
+				$var_name = '_'.$var_name;
163 163
 				$this->{$var_name} = $session_setting;
164 164
 			}
165 165
 		}
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
         // encrypt data via: $this->encryption->encrypt();
170 170
         $this->encryption = $encryption;
171 171
 		// filter hook allows outside functions/classes/plugins to change default empty cart
172
-		$extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() );
173
-		array_merge( $this->_default_session_vars, $extra_default_session_vars );
172
+		$extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array());
173
+		array_merge($this->_default_session_vars, $extra_default_session_vars);
174 174
 		// apply default session vars
175 175
 		$this->_set_defaults();
176 176
          add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
177 177
          // check request for 'clear_session' param
178
-		add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' ));
178
+		add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded'));
179 179
 		// once everything is all said and done,
180
-		add_action( 'shutdown', array( $this, 'update' ), 100 );
181
-		add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 );
182
-		add_filter( 'wp_redirect', array( $this, 'update_on_redirect' ), 100, 1 );
180
+		add_action('shutdown', array($this, 'update'), 100);
181
+		add_action('shutdown', array($this, 'garbage_collection'), 999);
182
+		add_filter('wp_redirect', array($this, 'update_on_redirect'), 100, 1);
183 183
 	}
184 184
 
185 185
 
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
 	 */
225 225
 	private function _set_defaults() {
226 226
 		// set some defaults
227
-		foreach ( $this->_default_session_vars as $key => $default_var ) {
228
-			if ( is_array( $default_var )) {
229
-				$this->_session_data[ $key ] = array();
227
+		foreach ($this->_default_session_vars as $key => $default_var) {
228
+			if (is_array($default_var)) {
229
+				$this->_session_data[$key] = array();
230 230
 			} else {
231
-				$this->_session_data[ $key ] = '';
231
+				$this->_session_data[$key] = '';
232 232
 			}
233 233
 		}
234 234
 	}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	  * @param \EE_Cart $cart
251 251
 	  * @return bool
252 252
 	  */
253
-	 public function set_cart( EE_Cart $cart ) {
253
+	 public function set_cart(EE_Cart $cart) {
254 254
 		 $this->_session_data['cart'] = $cart;
255 255
 		 return TRUE;
256 256
 	 }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	  * @return \EE_Cart
271 271
 	  */
272 272
 	 public function cart() {
273
-		 return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL;
273
+		 return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL;
274 274
 	 }
275 275
 
276 276
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	  * @param \EE_Checkout $checkout
280 280
 	  * @return bool
281 281
 	  */
282
-	 public function set_checkout( EE_Checkout $checkout ) {
282
+	 public function set_checkout(EE_Checkout $checkout) {
283 283
 		 $this->_session_data['checkout'] = $checkout;
284 284
 		 return TRUE;
285 285
 	 }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	  * @return \EE_Checkout
300 300
 	  */
301 301
 	 public function checkout() {
302
-		 return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL;
302
+		 return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL;
303 303
 	 }
304 304
 
305 305
 
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
 	  * @return bool
310 310
 	  * @throws \EE_Error
311 311
 	  */
312
-	 public function set_transaction( EE_Transaction $transaction ) {
312
+	 public function set_transaction(EE_Transaction $transaction) {
313 313
 		 // first remove the session from the transaction before we save the transaction in the session
314
-		 $transaction->set_txn_session_data( NULL );
314
+		 $transaction->set_txn_session_data(NULL);
315 315
 		 $this->_session_data['transaction'] = $transaction;
316 316
 		 return TRUE;
317 317
 	 }
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	  * @return \EE_Transaction
332 332
 	  */
333 333
 	 public function transaction() {
334
-		 return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL;
334
+		 return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL;
335 335
 	 }
336 336
 
337 337
 
@@ -343,15 +343,15 @@  discard block
 block discarded – undo
343 343
 	  * @param bool $reset_cache
344 344
 	  * @return    array
345 345
 	  */
346
-	public function get_session_data( $key = NULL, $reset_cache = FALSE ) {
347
-		if ( $reset_cache ) {
346
+	public function get_session_data($key = NULL, $reset_cache = FALSE) {
347
+		if ($reset_cache) {
348 348
 			$this->reset_cart();
349 349
 			$this->reset_checkout();
350 350
 			$this->reset_transaction();
351 351
 		}
352
-		 if ( ! empty( $key ))  {
353
-			return  isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL;
354
-		}  else  {
352
+		 if ( ! empty($key)) {
353
+			return  isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL;
354
+		} else {
355 355
 			return $this->_session_data;
356 356
 		}
357 357
 	}
@@ -364,20 +364,20 @@  discard block
 block discarded – undo
364 364
 	  * @param 	array $data
365 365
 	  * @return 	TRUE on success, FALSE on fail
366 366
 	  */
367
-	public function set_session_data( $data ) {
367
+	public function set_session_data($data) {
368 368
 
369 369
 		// nothing ??? bad data ??? go home!
370
-		if ( empty( $data ) || ! is_array( $data )) {
371
-			EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
370
+		if (empty($data) || ! is_array($data)) {
371
+			EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
372 372
 			return FALSE;
373 373
 		}
374 374
 
375
-		foreach ( $data as $key =>$value ) {
376
-			if ( isset( $this->_default_session_vars[ $key ] )) {
377
-				EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ );
375
+		foreach ($data as $key =>$value) {
376
+			if (isset($this->_default_session_vars[$key])) {
377
+				EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__);
378 378
 				return FALSE;
379 379
 			} else {
380
-				$this->_session_data[ $key ] = $value;
380
+				$this->_session_data[$key] = $value;
381 381
 			}
382 382
 		}
383 383
 
@@ -395,9 +395,9 @@  discard block
 block discarded – undo
395 395
 	  * @throws \EE_Error
396 396
 	  */
397 397
 	private function _espresso_session() {
398
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
398
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
399 399
 		// check that session has started
400
-		if ( session_id() === '' ) {
400
+		if (session_id() === '') {
401 401
 			//starts a new session if one doesn't already exist, or re-initiates an existing one
402 402
 			session_start();
403 403
 		}
@@ -406,38 +406,38 @@  discard block
 block discarded – undo
406 406
 		// and the visitors IP
407 407
 		$this->_ip_address = $this->_visitor_ip();
408 408
 		// set the "user agent"
409
-		$this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE;
409
+		$this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE;
410 410
 		// now let's retrieve what's in the db
411 411
         $session_data = $this->_retrieve_session_data();
412
-        if (! empty($session_data)) {
412
+        if ( ! empty($session_data)) {
413 413
             // get the current time in UTC
414
-			$this->_time = isset( $this->_time ) ? $this->_time : time();
414
+			$this->_time = isset($this->_time) ? $this->_time : time();
415 415
 			// and reset the session expiration
416
-			$this->_expiration = isset( $session_data['expiration'] )
416
+			$this->_expiration = isset($session_data['expiration'])
417 417
 				? $session_data['expiration']
418 418
 				: $this->_time + $this->_lifespan;
419 419
 		} else {
420 420
             // set initial site access time and the session expiration
421 421
 			$this->_set_init_access_and_expiration();
422 422
 			// set referer
423
-			$this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] )
424
-				? esc_attr( $_SERVER['HTTP_REFERER'] )
423
+			$this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER'])
424
+				? esc_attr($_SERVER['HTTP_REFERER'])
425 425
 				: '';
426 426
 			// no previous session = go back and create one (on top of the data above)
427 427
 			return FALSE;
428 428
 		}
429 429
         // now the user agent
430
-		if ( $session_data['user_agent'] !== $this->_user_agent ) {
430
+		if ($session_data['user_agent'] !== $this->_user_agent) {
431 431
 			return FALSE;
432 432
 		}
433 433
 		// wait a minute... how old are you?
434
-		if ( $this->_time > $this->_expiration ) {
434
+		if ($this->_time > $this->_expiration) {
435 435
 			// yer too old fer me!
436 436
 			// wipe out everything that isn't a default session datum
437
-			$this->clear_session( __CLASS__, __FUNCTION__ );
437
+			$this->clear_session(__CLASS__, __FUNCTION__);
438 438
 		}
439 439
 		// make event espresso session data available to plugin
440
-		$this->_session_data = array_merge( $this->_session_data, $session_data );
440
+		$this->_session_data = array_merge($this->_session_data, $session_data);
441 441
 		return TRUE;
442 442
 
443 443
 	}
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
       */
454 454
      protected function _retrieve_session_data()
455 455
      {
456
-         $ssn_key = EE_Session::session_id_prefix . $this->_sid;
456
+         $ssn_key = EE_Session::session_id_prefix.$this->_sid;
457 457
          try {
458 458
              // we're using WP's Transient API to store session data using the PHP session ID as the option name
459 459
              $session_data = get_transient($ssn_key);
@@ -461,12 +461,12 @@  discard block
 block discarded – undo
461 461
 		         return array();
462 462
              }
463 463
              if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
464
-                 $hash_check = get_transient(EE_Session::hash_check_prefix . $this->_sid);
464
+                 $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid);
465 465
                  if ($hash_check && $hash_check !== md5($session_data)) {
466 466
 	                 EE_Error::add_error(
467 467
                          sprintf(
468 468
                              __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'),
469
-                             EE_Session::session_id_prefix . $this->_sid
469
+                             EE_Session::session_id_prefix.$this->_sid
470 470
                          ),
471 471
                          __FILE__, __FUNCTION__, __LINE__
472 472
                      );
@@ -478,17 +478,17 @@  discard block
 block discarded – undo
478 478
              $row = $wpdb->get_row(
479 479
                  $wpdb->prepare(
480 480
                      "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
481
-                     '_transient_' . $ssn_key
481
+                     '_transient_'.$ssn_key
482 482
                  )
483 483
              );
484 484
              $session_data = is_object($row) ? $row->option_value : null;
485 485
              if ($session_data) {
486 486
                  $session_data = preg_replace_callback(
487 487
                      '!s:(d+):"(.*?)";!',
488
-                     function ($match) {
488
+                     function($match) {
489 489
                          return $match[1] === strlen($match[2])
490 490
                              ? $match[0]
491
-                             : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
491
+                             : 's:'.strlen($match[2]).':"'.$match[2].'";';
492 492
                      },
493 493
                      $session_data
494 494
                  );
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
                      'event_espresso'
510 510
                  );
511 511
                  $msg .= WP_DEBUG
512
-                     ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
512
+                     ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data)
513 513
                      : '';
514 514
                  throw new InvalidSessionDataException($msg, 0, $e);
515 515
              }
@@ -522,11 +522,11 @@  discard block
 block discarded – undo
522 522
                  'event_espresso'
523 523
              );
524 524
              $msg .= WP_DEBUG
525
-                 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
525
+                 ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data)
526 526
                  : '';
527 527
 	         throw new InvalidSessionDataException($msg);
528 528
          }
529
-	     if ( isset( $this->_session_data['transaction'] ) && absint( $this->_session_data['transaction'] ) !== 0 ) {
529
+	     if (isset($this->_session_data['transaction']) && absint($this->_session_data['transaction']) !== 0) {
530 530
 		     $this->_session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
531 531
 			     $this->_session_data['transaction']
532 532
 	         );
@@ -547,12 +547,12 @@  discard block
 block discarded – undo
547 547
 	  */
548 548
 	protected function _generate_session_id() {
549 549
 		// check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
550
-		if ( isset( $_REQUEST[ 'EESID' ] ) ) {
551
-			$session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] );
550
+		if (isset($_REQUEST['EESID'])) {
551
+			$session_id = sanitize_text_field($_REQUEST['EESID']);
552 552
 		} else {
553
-			$session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() );
553
+			$session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt());
554 554
 		}
555
-		return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id );
555
+		return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
556 556
 	}
557 557
 
558 558
 
@@ -564,20 +564,20 @@  discard block
 block discarded – undo
564 564
 	  */
565 565
 	protected function _get_sid_salt() {
566 566
 		// was session id salt already saved to db ?
567
-		if ( empty( $this->_sid_salt ) ) {
567
+		if (empty($this->_sid_salt)) {
568 568
 			// no?  then maybe use WP defined constant
569
-			if ( defined( 'AUTH_SALT' ) ) {
569
+			if (defined('AUTH_SALT')) {
570 570
 				$this->_sid_salt = AUTH_SALT;
571 571
 			}
572 572
 			// if salt doesn't exist or is too short
573
-			if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) {
573
+			if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) {
574 574
 				// create a new one
575
-				$this->_sid_salt = wp_generate_password( 64 );
575
+				$this->_sid_salt = wp_generate_password(64);
576 576
 			}
577 577
 			// and save it as a permanent session setting
578
-			$session_settings = get_option( 'ee_session_settings' );
579
-			$session_settings[ 'sid_salt' ] = $this->_sid_salt;
580
-			update_option( 'ee_session_settings', $session_settings );
578
+			$session_settings = get_option('ee_session_settings');
579
+			$session_settings['sid_salt'] = $this->_sid_salt;
580
+			update_option('ee_session_settings', $session_settings);
581 581
 		}
582 582
 		return $this->_sid_salt;
583 583
 	}
@@ -605,19 +605,19 @@  discard block
 block discarded – undo
605 605
 	  * @param bool $new_session
606 606
 	  * @return TRUE on success, FALSE on fail
607 607
 	  */
608
-	public function update( $new_session = FALSE ) {
609
-		$this->_session_data = isset( $this->_session_data )
610
-			&& is_array( $this->_session_data )
611
-			&& isset( $this->_session_data['id'])
608
+	public function update($new_session = FALSE) {
609
+		$this->_session_data = isset($this->_session_data)
610
+			&& is_array($this->_session_data)
611
+			&& isset($this->_session_data['id'])
612 612
 			? $this->_session_data
613 613
 			: array();
614
-		if ( empty( $this->_session_data )) {
614
+		if (empty($this->_session_data)) {
615 615
 			$this->_set_defaults();
616 616
 		}
617 617
 		$session_data = array();
618
-		foreach ( $this->_session_data as $key => $value ) {
618
+		foreach ($this->_session_data as $key => $value) {
619 619
 
620
-			switch( $key ) {
620
+			switch ($key) {
621 621
 
622 622
 				case 'id' :
623 623
 					// session ID
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
 				break;
636 636
 
637 637
 				case 'init_access' :
638
-					$session_data['init_access'] = absint( $value );
638
+					$session_data['init_access'] = absint($value);
639 639
 				break;
640 640
 
641 641
 				case 'last_access' :
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 
646 646
 				case 'expiration' :
647 647
 					// when the session expires
648
-					$session_data['expiration'] = ! empty( $this->_expiration )
648
+					$session_data['expiration'] = ! empty($this->_expiration)
649 649
 						? $this->_expiration
650 650
 						: $session_data['init_access'] + $this->_lifespan;
651 651
 				break;
@@ -657,11 +657,11 @@  discard block
 block discarded – undo
657 657
 
658 658
 				case 'pages_visited' :
659 659
 					$page_visit = $this->_get_page_visit();
660
-					if ( $page_visit ) {
660
+					if ($page_visit) {
661 661
 						// set pages visited where the first will be the http referrer
662
-						$this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit;
662
+						$this->_session_data['pages_visited'][$this->_time] = $page_visit;
663 663
 						// we'll only save the last 10 page visits.
664
-						$session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 );
664
+						$session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
665 665
 					}
666 666
 				break;
667 667
 
@@ -675,9 +675,9 @@  discard block
 block discarded – undo
675 675
 
676 676
 		$this->_session_data = $session_data;
677 677
 		// creating a new session does not require saving to the db just yet
678
-		if ( ! $new_session ) {
678
+		if ( ! $new_session) {
679 679
 			// ready? let's save
680
-			if ( $this->_save_session_to_db() ) {
680
+			if ($this->_save_session_to_db()) {
681 681
 				return TRUE;
682 682
 			} else {
683 683
 				return FALSE;
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 	  * @param string $location
700 700
 	  * @return mixed
701 701
 	  */
702
-	 public function update_on_redirect( $location ) {
702
+	 public function update_on_redirect($location) {
703 703
 		 $this->update();
704 704
 		 return $location;
705 705
 	}
@@ -711,9 +711,9 @@  discard block
 block discarded – undo
711 711
 	 * 	@return bool
712 712
 	 */
713 713
 	private function _create_espresso_session( ) {
714
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
714
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
715 715
 		// use the update function for now with $new_session arg set to TRUE
716
-		return  $this->update( TRUE ) ? TRUE : FALSE;
716
+		return  $this->update(TRUE) ? TRUE : FALSE;
717 717
 	}
718 718
 
719 719
 
@@ -739,15 +739,15 @@  discard block
 block discarded – undo
739 739
 				// OR an admin request that is NOT AJAX
740 740
 				|| (
741 741
 					is_admin()
742
-					&& ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
742
+					&& ! (defined('DOING_AJAX') && DOING_AJAX)
743 743
 				)
744 744
 			)
745 745
 		) {
746 746
 			return false;
747 747
 		}
748 748
 		$transaction = $this->transaction();
749
-		if ( $transaction instanceof EE_Transaction ) {
750
-			if ( ! $transaction->ID() ) {
749
+		if ($transaction instanceof EE_Transaction) {
750
+			if ( ! $transaction->ID()) {
751 751
 				$transaction->save();
752 752
 			}
753 753
 			$this->_session_data['transaction'] = $transaction->ID();
@@ -760,17 +760,17 @@  discard block
 block discarded – undo
760 760
         //in a different encoding, like ANSI.
761 761
         //we double-check the function exists first because it's labelled "private", so it's possible it will be removed
762 762
         //from WP some day2
763
-        if( function_exists( '_wp_json_convert_string' ) ) {
764
-            $session_data = _wp_json_convert_string( $session_data );
763
+        if (function_exists('_wp_json_convert_string')) {
764
+            $session_data = _wp_json_convert_string($session_data);
765 765
         }
766 766
 		// do we need to also encode it to avoid corrupted data when saved to the db?
767
-		$session_data = $this->_use_encryption ? $this->encryption->base64_string_encode( $session_data ) : $session_data;
767
+		$session_data = $this->_use_encryption ? $this->encryption->base64_string_encode($session_data) : $session_data;
768 768
 		// maybe save hash check
769
-		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
770
-			set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan );
769
+		if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
770
+			set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan);
771 771
 		}
772 772
 		// we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient(  transient ID, data, expiry )
773
-		return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan );
773
+		return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan);
774 774
 	}
775 775
 
776 776
 
@@ -796,10 +796,10 @@  discard block
 block discarded – undo
796 796
 			'HTTP_FORWARDED',
797 797
 			'REMOTE_ADDR'
798 798
 		);
799
-		foreach ( $server_keys as $key ){
800
-			if ( isset( $_SERVER[ $key ] )) {
801
-				foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) {
802
-					if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) {
799
+		foreach ($server_keys as $key) {
800
+			if (isset($_SERVER[$key])) {
801
+				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
802
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) {
803 803
 						$visitor_ip = $ip;
804 804
 					}
805 805
 				}
@@ -818,32 +818,32 @@  discard block
 block discarded – undo
818 818
 	 *			@return string
819 819
 	 */
820 820
 	public function _get_page_visit() {
821
-		$page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
821
+		$page_visit = home_url('/').'wp-admin/admin-ajax.php';
822 822
 		// check for request url
823
-		if ( isset( $_SERVER['REQUEST_URI'] )) {
823
+		if (isset($_SERVER['REQUEST_URI'])) {
824 824
 			$http_host = '';
825 825
 			$page_id = '?';
826 826
 			$e_reg = '';
827
-			$request_uri = esc_url( $_SERVER['REQUEST_URI'] );
828
-			$ru_bits = explode( '?', $request_uri );
827
+			$request_uri = esc_url($_SERVER['REQUEST_URI']);
828
+			$ru_bits = explode('?', $request_uri);
829 829
 			$request_uri = $ru_bits[0];
830 830
 			// check for and grab host as well
831
-			if ( isset( $_SERVER['HTTP_HOST'] )) {
832
-				$http_host = esc_url( $_SERVER['HTTP_HOST'] );
831
+			if (isset($_SERVER['HTTP_HOST'])) {
832
+				$http_host = esc_url($_SERVER['HTTP_HOST']);
833 833
 			}
834 834
 			// check for page_id in SERVER REQUEST
835
-			if ( isset( $_REQUEST['page_id'] )) {
835
+			if (isset($_REQUEST['page_id'])) {
836 836
 				// rebuild $e_reg without any of the extra parameters
837
-				$page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&amp;';
837
+				$page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&amp;';
838 838
 			}
839 839
 			// check for $e_reg in SERVER REQUEST
840
-			if ( isset( $_REQUEST['ee'] )) {
840
+			if (isset($_REQUEST['ee'])) {
841 841
 				// rebuild $e_reg without any of the extra parameters
842
-				$e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] );
842
+				$e_reg = 'ee='.esc_attr($_REQUEST['ee']);
843 843
 			}
844
-			$page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' );
844
+			$page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?');
845 845
 		}
846
-		return $page_visit !== home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : '';
846
+		return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
847 847
 
848 848
 	}
849 849
 
@@ -872,14 +872,14 @@  discard block
 block discarded – undo
872 872
 	  * @param string $function
873 873
 	  * @return void
874 874
 	  */
875
-	public function clear_session( $class = '', $function = '' ) {
875
+	public function clear_session($class = '', $function = '') {
876 876
 		//echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span>    <b style="font-size:10px;">  ' . __LINE__ . ' </b></h3>';
877
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
877
+		do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()');
878 878
 		$this->reset_cart();
879 879
 		$this->reset_checkout();
880 880
 		$this->reset_transaction();
881 881
 		// wipe out everything that isn't a default session datum
882
-		$this->reset_data( array_keys( $this->_session_data ));
882
+		$this->reset_data(array_keys($this->_session_data));
883 883
 		// reset initial site access time and the session expiration
884 884
 		$this->_set_init_access_and_expiration();
885 885
 		$this->_save_session_to_db();
@@ -894,42 +894,42 @@  discard block
 block discarded – undo
894 894
 	  * @param bool  $show_all_notices
895 895
 	  * @return TRUE on success, FALSE on fail
896 896
 	  */
897
-	public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) {
897
+	public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) {
898 898
 		// if $data_to_reset is not in an array, then put it in one
899
-		if ( ! is_array( $data_to_reset ) ) {
900
-			$data_to_reset = array ( $data_to_reset );
899
+		if ( ! is_array($data_to_reset)) {
900
+			$data_to_reset = array($data_to_reset);
901 901
 		}
902 902
 		// nothing ??? go home!
903
-		if ( empty( $data_to_reset )) {
904
-			EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
903
+		if (empty($data_to_reset)) {
904
+			EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
905 905
 			return FALSE;
906 906
 		}
907 907
 		$return_value = TRUE;
908 908
 		// since $data_to_reset is an array, cycle through the values
909
-		foreach ( $data_to_reset as $reset ) {
909
+		foreach ($data_to_reset as $reset) {
910 910
 
911 911
 			// first check to make sure it is a valid session var
912
-			if ( isset( $this->_session_data[ $reset ] )) {
912
+			if (isset($this->_session_data[$reset])) {
913 913
 				// then check to make sure it is not a default var
914
-				if ( ! array_key_exists( $reset, $this->_default_session_vars )) {
914
+				if ( ! array_key_exists($reset, $this->_default_session_vars)) {
915 915
 					// remove session var
916
-					unset( $this->_session_data[ $reset ] );
917
-					if ( $show_all_notices ) {
918
-						EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
916
+					unset($this->_session_data[$reset]);
917
+					if ($show_all_notices) {
918
+						EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
919 919
 					}
920
-					$return_value = !isset($return_value) ? TRUE : $return_value;
920
+					$return_value = ! isset($return_value) ? TRUE : $return_value;
921 921
 
922 922
 				} else {
923 923
 					// yeeeeeeeeerrrrrrrrrrr OUT !!!!
924
-					if ( $show_all_notices ) {
925
-						EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
924
+					if ($show_all_notices) {
925
+						EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
926 926
 					}
927 927
 					$return_value = FALSE;
928 928
 				}
929 929
 
930
-			} else if ( $show_all_notices ) {
930
+			} else if ($show_all_notices) {
931 931
 				// oops! that session var does not exist!
932
-				EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
932
+				EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
933 933
 				$return_value = FALSE;
934 934
 			}
935 935
 
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 	 *   @access public
950 950
 	 */
951 951
 	public function wp_loaded() {
952
-		if ( isset(  EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) {
953
-			$this->clear_session( __CLASS__, __FUNCTION__ );
952
+		if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) {
953
+			$this->clear_session(__CLASS__, __FUNCTION__);
954 954
 		}
955 955
 	}
956 956
 
@@ -975,24 +975,24 @@  discard block
 block discarded – undo
975 975
 	  */
976 976
 	 public function garbage_collection() {
977 977
 		 // only perform during regular requests
978
-		 if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) {
978
+		 if ( ! defined('DOING_AJAX') || ! DOING_AJAX) {
979 979
 			 /** @type WPDB $wpdb */
980 980
 			 global $wpdb;
981 981
 			 // since transient expiration timestamps are set in the future, we can compare against NOW
982 982
 			 $expiration = time();
983
-			 $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 );
983
+			 $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2);
984 984
 			 // filter the query limit. Set to 0 to turn off garbage collection
985
-			 $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 ));
985
+			 $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50));
986 986
 			 // non-zero LIMIT means take out the trash
987
-			 if ( $expired_session_transient_delete_query_limit ) {
987
+			 if ($expired_session_transient_delete_query_limit) {
988 988
 				 //array of transient keys that require garbage collection
989 989
 				 $session_keys = array(
990 990
 					 EE_Session::session_id_prefix,
991 991
 					 EE_Session::hash_check_prefix,
992 992
 				 );
993
-				 foreach ( $session_keys as $session_key ) {
994
-					 $session_key = str_replace( '_', '\_', $session_key );
995
-					 $session_key = '\_transient\_timeout\_' . $session_key . '%';
993
+				 foreach ($session_keys as $session_key) {
994
+					 $session_key = str_replace('_', '\_', $session_key);
995
+					 $session_key = '\_transient\_timeout\_'.$session_key.'%';
996 996
 					 $SQL = "
997 997
 					SELECT option_name
998 998
 					FROM {$wpdb->options}
@@ -1002,25 +1002,25 @@  discard block
 block discarded – undo
1002 1002
 					OR option_value > {$too_far_in_the_the_future} )
1003 1003
 					LIMIT {$expired_session_transient_delete_query_limit}
1004 1004
 				";
1005
-					 $expired_sessions = $wpdb->get_col( $SQL );
1005
+					 $expired_sessions = $wpdb->get_col($SQL);
1006 1006
 					 // valid results?
1007
-					 if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) {
1007
+					 if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
1008 1008
 						 // format array of results into something usable within the actual DELETE query's IN clause
1009 1009
 						 $expired = array();
1010
-						 foreach ( $expired_sessions as $expired_session ) {
1011
-							 $expired[ ] = "'" . $expired_session . "'";
1012
-							 $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'";
1010
+						 foreach ($expired_sessions as $expired_session) {
1011
+							 $expired[] = "'".$expired_session."'";
1012
+							 $expired[] = "'".str_replace('timeout_', '', $expired_session)."'";
1013 1013
 						 }
1014
-						 $expired = implode( ', ', $expired );
1014
+						 $expired = implode(', ', $expired);
1015 1015
 						 $SQL = "
1016 1016
 						DELETE FROM {$wpdb->options}
1017 1017
 						WHERE option_name
1018 1018
 						IN ( $expired );
1019 1019
 					 ";
1020
-						 $results = $wpdb->query( $SQL );
1020
+						 $results = $wpdb->query($SQL);
1021 1021
 						 // if something went wrong, then notify the admin
1022
-						 if ( $results instanceof WP_Error && is_admin() ) {
1023
-							 EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
1022
+						 if ($results instanceof WP_Error && is_admin()) {
1023
+							 EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
1024 1024
 						 }
1025 1025
 					 }
1026 1026
 				 }
@@ -1041,34 +1041,34 @@  discard block
 block discarded – undo
1041 1041
 	  * @param $data1
1042 1042
 	  * @return string
1043 1043
 	  */
1044
-	 private function find_serialize_error( $data1 ) {
1044
+	 private function find_serialize_error($data1) {
1045 1045
 		$error = "<pre>";
1046 1046
 		 $data2 = preg_replace_callback(
1047 1047
 			 '!s:(\d+):"(.*?)";!',
1048
-			 function ( $match ) {
1049
-				 return ( $match[1] === strlen( $match[2] ) )
1048
+			 function($match) {
1049
+				 return ($match[1] === strlen($match[2]))
1050 1050
 					 ? $match[0]
1051 1051
 					 : 's:'
1052
-					   . strlen( $match[2] )
1052
+					   . strlen($match[2])
1053 1053
 					   . ':"'
1054 1054
 					   . $match[2]
1055 1055
 					   . '";';
1056 1056
 			 },
1057 1057
 			 $data1
1058 1058
 		 );
1059
-		$max = ( strlen( $data1 ) > strlen( $data2 ) ) ? strlen( $data1 ) : strlen( $data2 );
1060
-		$error .= $data1 . PHP_EOL;
1061
-		$error .= $data2 . PHP_EOL;
1062
-		for ( $i = 0; $i < $max; $i++ ) {
1063
-			if ( @$data1[ $i ] !== @$data2[ $i ] ) {
1064
-				$error .= "Difference " . @$data1[ $i ] . " != " . @$data2[ $i ] . PHP_EOL;
1065
-				$error .= "\t-> ORD number " . ord( @$data1[ $i ] ) . " != " . ord( @$data2[ $i ] ) . PHP_EOL;
1066
-				$error .= "\t-> Line Number = $i" . PHP_EOL;
1067
-				$start = ( $i - 20 );
1068
-				$start = ( $start < 0 ) ? 0 : $start;
1059
+		$max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1060
+		$error .= $data1.PHP_EOL;
1061
+		$error .= $data2.PHP_EOL;
1062
+		for ($i = 0; $i < $max; $i++) {
1063
+			if (@$data1[$i] !== @$data2[$i]) {
1064
+				$error .= "Difference ".@$data1[$i]." != ".@$data2[$i].PHP_EOL;
1065
+				$error .= "\t-> ORD number ".ord(@$data1[$i])." != ".ord(@$data2[$i]).PHP_EOL;
1066
+				$error .= "\t-> Line Number = $i".PHP_EOL;
1067
+				$start = ($i - 20);
1068
+				$start = ($start < 0) ? 0 : $start;
1069 1069
 				$length = 40;
1070 1070
 				$point = $max - $i;
1071
-				if ( $point < 20 ) {
1071
+				if ($point < 20) {
1072 1072
 					$rlength = 1;
1073 1073
 					$rpoint = -$point;
1074 1074
 				} else {
@@ -1077,16 +1077,16 @@  discard block
 block discarded – undo
1077 1077
 				}
1078 1078
 				$error .= "\t-> Section Data1  = ";
1079 1079
 				$error .= substr_replace(
1080
-					substr( $data1, $start, $length ),
1081
-					"<b style=\"color:green\">{$data1[ $i ]}</b>",
1080
+					substr($data1, $start, $length),
1081
+					"<b style=\"color:green\">{$data1[$i]}</b>",
1082 1082
 					$rpoint,
1083 1083
 					$rlength
1084 1084
 				);
1085 1085
 				$error .= PHP_EOL;
1086 1086
 				$error .= "\t-> Section Data2  = ";
1087 1087
 				$error .= substr_replace(
1088
-					substr( $data2, $start, $length ),
1089
-					"<b style=\"color:red\">{$data2[ $i ]}</b>",
1088
+					substr($data2, $start, $length),
1089
+					"<b style=\"color:red\">{$data2[$i]}</b>",
1090 1090
 					$rpoint,
1091 1091
 					$rlength
1092 1092
 				);
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_state_system_question.dmsstage.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5 5
 }
6 6
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @author				Brent Christensen
14 14
  *
15 15
  */
16
-class EE_DMS_4_6_0_state_system_question extends EE_Data_Migration_Script_Stage_Table{
16
+class EE_DMS_4_6_0_state_system_question extends EE_Data_Migration_Script_Stage_Table {
17 17
 
18 18
 
19 19
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function __construct() {
26 26
 		global $wpdb;
27
-		$this->_pretty_name = __( 'State - System Question', 'event_espresso' );
27
+		$this->_pretty_name = __('State - System Question', 'event_espresso');
28 28
 		$this->_old_table = $wpdb->prefix.'esp_question';
29 29
 		$this->_extra_where_sql = "WHERE QST_system = 'state'";
30 30
 		parent::__construct();
@@ -37,21 +37,21 @@  discard block
 block discarded – undo
37 37
 	 * @param array $question an associative array where keys are column names and values are their values.
38 38
 	 * @return null
39 39
 	 */
40
-	protected function _migrate_old_row( $question ) {
41
-		if ( $question['QST_ID'] && $question['QST_system'] == 'state' ) {
40
+	protected function _migrate_old_row($question) {
41
+		if ($question['QST_ID'] && $question['QST_system'] == 'state') {
42 42
 			global $wpdb;
43 43
 			$success = $wpdb->update(
44 44
 				$this->_old_table,
45
-				array( 'QST_type' => 'STATE' ),  // data
46
-				array( 'QST_ID' => $question['QST_ID'] ),  // where
47
-				array( '%s' ),   // data format
48
-				array( '%d' )  // where format
45
+				array('QST_type' => 'STATE'), // data
46
+				array('QST_ID' => $question['QST_ID']), // where
47
+				array('%s'), // data format
48
+				array('%d')  // where format
49 49
 			);
50
-			if ( ! $success ) {
50
+			if ( ! $success) {
51 51
 				$this->add_error(
52 52
 					sprintf(
53
-						__( 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso' ),
54
-						wp_json_encode( $question['QST_system'] ),
53
+						__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
54
+						wp_json_encode($question['QST_system']),
55 55
 						$question['QST_ID'],
56 56
 						$wpdb->last_error
57 57
 					)
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_question_types.dmsstage.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	public function __construct() {
28 28
 		global $wpdb;
29
-		$this->_pretty_name = __( 'Question Types', 'event_espresso' );
29
+		$this->_pretty_name = __('Question Types', 'event_espresso');
30 30
 		$this->_old_table = $wpdb->prefix.'esp_question';
31 31
 		$this->_question_type_conversions = array(
32 32
 			'MULTIPLE' 			=> 'CHECKBOX',
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 		//when fetching rows, because we automatically use a limit and offset
36 36
 		//rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted
37 37
 		//so we need to include both the migrated rows as well as the non-migrated rows
38
-		$QST_types_to_count = array_merge( array_keys( $this->_question_type_conversions ), $this->_question_type_conversions );
39
-		$this->_extra_where_sql = "WHERE QST_type IN ('" . implode( "', '", $QST_types_to_count ) . "')" ;
38
+		$QST_types_to_count = array_merge(array_keys($this->_question_type_conversions), $this->_question_type_conversions);
39
+		$this->_extra_where_sql = "WHERE QST_type IN ('".implode("', '", $QST_types_to_count)."')";
40 40
 		parent::__construct();
41 41
 	}
42 42
 
@@ -44,21 +44,21 @@  discard block
 block discarded – undo
44 44
 	 * @param array $question an associative array where keys are column names and values are their values.
45 45
 	 * @return null
46 46
 	 */
47
-	protected function _migrate_old_row( $question ) {
47
+	protected function _migrate_old_row($question) {
48 48
 		global $wpdb;
49
-		if ( $question['QST_ID'] && isset( $this->_question_type_conversions[ $question['QST_type'] ] )) {
49
+		if ($question['QST_ID'] && isset($this->_question_type_conversions[$question['QST_type']])) {
50 50
 			$success = $wpdb->update(
51 51
 				$this->_old_table,
52
-				array( 'QST_type' => $this->_question_type_conversions[ $question['QST_type'] ] ), 	// data
53
-				array( 'QST_ID' => $question['QST_ID'] ),  // where
54
-				array( '%s' ),   // data format
55
-				array( '%d' )  // where format
52
+				array('QST_type' => $this->_question_type_conversions[$question['QST_type']]), // data
53
+				array('QST_ID' => $question['QST_ID']), // where
54
+				array('%s'), // data format
55
+				array('%d')  // where format
56 56
 			);
57
-			if ( ! $success ) {
57
+			if ( ! $success) {
58 58
 				$this->add_error(
59 59
 					sprintf(
60
-						__( 'Could not update question type %1$s for question ID=%2$d because "%3$s"', 'event_espresso' ),
61
-						wp_json_encode( $question['QST_type'] ),
60
+						__('Could not update question type %1$s for question ID=%2$d because "%3$s"', 'event_espresso'),
61
+						wp_json_encode($question['QST_type']),
62 62
 						$question['QST_ID'],
63 63
 						$wpdb->last_error
64 64
 					)
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_country_system_question.dmsstage.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5 5
 }
6 6
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @author				Brent Christensen
14 14
  *
15 15
  */
16
-class EE_DMS_4_6_0_country_system_question extends EE_Data_Migration_Script_Stage_Table{
16
+class EE_DMS_4_6_0_country_system_question extends EE_Data_Migration_Script_Stage_Table {
17 17
 
18 18
 
19 19
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function __construct() {
26 26
 		global $wpdb;
27
-		$this->_pretty_name = __( 'Country - System Question', 'event_espresso' );
27
+		$this->_pretty_name = __('Country - System Question', 'event_espresso');
28 28
 		$this->_old_table = $wpdb->prefix.'esp_question';
29 29
 		$this->_extra_where_sql = "WHERE QST_system = 'country'";
30 30
 		parent::__construct();
@@ -37,21 +37,21 @@  discard block
 block discarded – undo
37 37
 	 * @param array $question an associative array where keys are column names and values are their values.
38 38
 	 * @return null
39 39
 	 */
40
-	protected function _migrate_old_row( $question ) {
41
-		if ( $question['QST_ID'] && $question['QST_system'] == 'country' ) {
40
+	protected function _migrate_old_row($question) {
41
+		if ($question['QST_ID'] && $question['QST_system'] == 'country') {
42 42
 			global $wpdb;
43 43
 			$success = $wpdb->update(
44 44
 				$this->_old_table,
45
-				array( 'QST_type' => 'COUNTRY' ),  // data
46
-				array( 'QST_ID' => $question['QST_ID'] ),  // where
47
-				array( '%s' ),   // data format
48
-				array( '%d' )  // where format
45
+				array('QST_type' => 'COUNTRY'), // data
46
+				array('QST_ID' => $question['QST_ID']), // where
47
+				array('%s'), // data format
48
+				array('%d')  // where format
49 49
 			);
50
-			if ( ! $success ) {
50
+			if ( ! $success) {
51 51
 				$this->add_error(
52 52
 					sprintf(
53
-						__( 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso' ),
54
-						wp_json_encode( $question['QST_system'] ),
53
+						__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
54
+						wp_json_encode($question['QST_system']),
55 55
 						$question['QST_ID'],
56 56
 						$wpdb->last_error
57 57
 					)
Please login to merge, or discard this patch.
core/data_migration_scripts/4_6_0_stages/EE_DMS_4_6_0_gateways.dmsstage.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
 	exit('No direct script access allowed');
4 4
 }
5 5
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  * Migrates 4.1-4.5-style gateway settings (which were stores in EE_Config)
15 15
  * to 4.6-style payment methods (which have their database table)
16 16
  */
17
-class EE_DMS_4_6_0_gateways extends EE_Data_Migration_Script_Stage{
17
+class EE_DMS_4_6_0_gateways extends EE_Data_Migration_Script_Stage {
18 18
 
19 19
 	protected $_new_table_name;
20 20
 	protected $_extra_meta_table_name;
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	protected function _migration_step($num_items_to_migrate = 50) {
75 75
 		$items_actually_migrated = 0;
76
-		$gateways_to_deal_with = array_slice(EE_Config::instance()->gateway->payment_settings,$this->count_records_migrated(),$num_items_to_migrate);
77
-		foreach($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings){
76
+		$gateways_to_deal_with = array_slice(EE_Config::instance()->gateway->payment_settings, $this->count_records_migrated(), $num_items_to_migrate);
77
+		foreach ($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings) {
78 78
 
79
-			if( in_array( $old_gateway_slug, $this->_gateway_we_know_to_migrate ) ) {
80
-				if( ! $old_gateway_settings){
79
+			if (in_array($old_gateway_slug, $this->_gateway_we_know_to_migrate)) {
80
+				if ( ! $old_gateway_settings) {
81 81
 					//no settings existed for this gateway anyways... weird...
82 82
 					$items_actually_migrated++;
83 83
 					continue;
@@ -86,16 +86,16 @@  discard block
 block discarded – undo
86 86
 				$success = $this->_convert_gateway_settings(
87 87
 						$old_gateway_slug,
88 88
 						$old_gateway_settings,
89
-						isset( EE_Config::instance()->gateway->active_gateways[ $old_gateway_slug ] ) );
90
-				if( $success ) {
91
-					EE_Config::instance()->gateway->payment_settings[ $old_gateway_slug ] = 'Deprecated';
89
+						isset(EE_Config::instance()->gateway->active_gateways[$old_gateway_slug]) );
90
+				if ($success) {
91
+					EE_Config::instance()->gateway->payment_settings[$old_gateway_slug] = 'Deprecated';
92 92
 				}
93 93
 			}
94 94
 			$items_actually_migrated++;
95 95
 		}
96 96
 
97
-		EE_Config::instance()->update_espresso_config(false,false);
98
-		if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){
97
+		EE_Config::instance()->update_espresso_config(false, false);
98
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
99 99
 			$this->set_completed();
100 100
 		}
101 101
 		return $items_actually_migrated;
@@ -108,22 +108,22 @@  discard block
 block discarded – undo
108 108
 	 * @param boolean $active indicates the gateway is currently active
109 109
 	 * @return boolean success
110 110
 	 */
111
-	protected function _convert_gateway_settings($old_gateway_slug,$old_gateway_settings,$active){
112
-		switch($old_gateway_slug){
111
+	protected function _convert_gateway_settings($old_gateway_slug, $old_gateway_settings, $active) {
112
+		switch ($old_gateway_slug) {
113 113
 			case 'Aim':
114 114
 				$extra_meta_key_values = array(
115 115
 					'login_id'=>$old_gateway_settings['authnet_aim_login_id'],
116 116
 					'transaction_key'=>$old_gateway_settings['authnet_aim_transaction_key'],
117 117
 					'test_transactions'=>$old_gateway_settings['test_transactions']
118 118
 				);
119
-				$desc = __( 'Please provide the following billing information.', 'event_espresso' );
119
+				$desc = __('Please provide the following billing information.', 'event_espresso');
120 120
 				break;
121 121
 			case 'Bank':
122 122
 				$extra_meta_key_values = array(
123 123
 					'page_title'=>$old_gateway_settings['page_title'],
124 124
 					'payment_instructions'=>
125
-					sprintf( __('%1$s<br/>Name on Bank Account: %2$s<br/>Bank Account Number: %3$s<br/>Bank Name: %4$s<br/>Bank Address:%5$s', 'event_espresso'), $old_gateway_settings['bank_instructions'] , $old_gateway_settings['account_name'], $old_gateway_settings['account_number'], $old_gateway_settings['bank_name'], $old_gateway_settings['bank_address'] ) );
126
-				$desc = __( 'Make payment using an electronic funds transfer from your bank.', 'event_espresso' );
125
+					sprintf(__('%1$s<br/>Name on Bank Account: %2$s<br/>Bank Account Number: %3$s<br/>Bank Name: %4$s<br/>Bank Address:%5$s', 'event_espresso'), $old_gateway_settings['bank_instructions'], $old_gateway_settings['account_name'], $old_gateway_settings['account_number'], $old_gateway_settings['bank_name'], $old_gateway_settings['bank_address']) );
126
+				$desc = __('Make payment using an electronic funds transfer from your bank.', 'event_espresso');
127 127
 				break;
128 128
 			case 'Check':
129 129
 				$extra_meta_key_values = array(
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 					'payment_instructions'=>$old_gateway_settings['check_instructions'],
132 132
 					'address_to_send_payment'=>$old_gateway_settings['payment_address']
133 133
 				);
134
-				$desc = __( 'On the next page you will be given instructions on how to make a payment by check.', 'event_espresso' );
134
+				$desc = __('On the next page you will be given instructions on how to make a payment by check.', 'event_espresso');
135 135
 				break;
136 136
 			case 'Invoice':
137 137
 				$extra_meta_key_values = array(
@@ -139,23 +139,23 @@  discard block
 block discarded – undo
139 139
 					'pdf_payee_email' => $old_gateway_settings['template_invoice_email'],
140 140
 					'pdf_payee_tax_number' => $old_gateway_settings['template_invoice_tax_number'],
141 141
 					'pdf_payee_address' => $old_gateway_settings['template_invoice_address'],
142
-					'pdf_instructions' => $old_gateway_settings[ 'template_payment_instructions' ],
143
-					'pdf_logo_image' => $old_gateway_settings[ 'invoice_logo_url' ],
144
-					'page_confirmation_text' => isset( $old_gateway_settings[ 'page_instructions' ] ) ? $old_gateway_settings[ 'page_instructions' ] : '',
145
-					'page_extra_info' => isset( $old_gateway_settings[ 'payment_address' ] ) ? $old_gateway_settings[ 'payment_address' ] : '',
142
+					'pdf_instructions' => $old_gateway_settings['template_payment_instructions'],
143
+					'pdf_logo_image' => $old_gateway_settings['invoice_logo_url'],
144
+					'page_confirmation_text' => isset($old_gateway_settings['page_instructions']) ? $old_gateway_settings['page_instructions'] : '',
145
+					'page_extra_info' => isset($old_gateway_settings['payment_address']) ? $old_gateway_settings['payment_address'] : '',
146 146
 					'legacy_invoice_css' => $old_gateway_settings['invoice_css']
147 147
 				);
148 148
 				//if they didnt want the invoiec gateway to show, pretend it was inactive
149
-				if( ! $old_gateway_settings['show'] ){
149
+				if ( ! $old_gateway_settings['show']) {
150 150
 					$active = FALSE;
151 151
 				}
152
-				$desc = __( 'On the next page you will be able to access your invoice and instructions on how to pay it.', 'event_espresso' );
152
+				$desc = __('On the next page you will be able to access your invoice and instructions on how to pay it.', 'event_espresso');
153 153
 				break;
154 154
 			case 'Mijireh':
155 155
 				$extra_meta_key_values = array(
156
-					'access_key' => $old_gateway_settings[ 'access_key' ]
156
+					'access_key' => $old_gateway_settings['access_key']
157 157
 				);
158
-				$desc =  __( 'On the next page you will be able to enter your billing information to make the payment.', 'event_espresso' );
158
+				$desc = __('On the next page you will be able to enter your billing information to make the payment.', 'event_espresso');
159 159
 				break;
160 160
 			case 'Paypal_Pro':
161 161
 				$extra_meta_key_values = array(
@@ -164,31 +164,31 @@  discard block
 block discarded – undo
164 164
 					'signature'=>$old_gateway_settings['signature'],
165 165
 					'credit_card_types'=>$old_gateway_settings['credit_cards'],
166 166
 				);
167
-				$desc = __( 'Please provide the following billing information.', 'event_espresso' );
167
+				$desc = __('Please provide the following billing information.', 'event_espresso');
168 168
 				break;
169 169
 			case 'Paypal_Standard':
170 170
 				$extra_meta_key_values = array(
171
-					'paypal_id' => $old_gateway_settings[ 'paypal_id' ],
172
-					'image_url' => $old_gateway_settings[ 'image_url' ],
173
-					'shipping_details' => isset( $old_gateway_settings[ 'no_shipping' ] ) ? $old_gateway_settings[ 'no_shipping' ] : false,
171
+					'paypal_id' => $old_gateway_settings['paypal_id'],
172
+					'image_url' => $old_gateway_settings['image_url'],
173
+					'shipping_details' => isset($old_gateway_settings['no_shipping']) ? $old_gateway_settings['no_shipping'] : false,
174 174
 
175 175
 				);
176
-				$desc = sprintf( __( 'After clicking \'Finalize Registration\', you will be forwarded to PayPal to make your payment. Make sure you return to this site in order to properly finalize your registration.', 'event_espresso' ), '<strong>','</strong>' );
176
+				$desc = sprintf(__('After clicking \'Finalize Registration\', you will be forwarded to PayPal to make your payment. Make sure you return to this site in order to properly finalize your registration.', 'event_espresso'), '<strong>', '</strong>');
177 177
 				break;
178 178
 			default:
179 179
 				//if we don't recognize the payment method, just put everything in it into extra meta. At least this way its preserved somewhere
180 180
 				$extra_meta_key_values = $old_gateway_settings;
181 181
 				$desc = '';
182 182
 		}
183
-		$pretty_name = isset( $old_gateway_settings[ 'display_name' ] ) ? $old_gateway_settings[ 'display_name' ] : $old_gateway_slug;
184
-		$offline_gateways = array( 'Bank', 'Check', 'Invoice' );
185
-		if( $active && in_array( $old_gateway_slug, $offline_gateways ) ) {
186
-			$scope = array( 'CART', 'ADMIN');
187
-		}elseif( $active && ! in_array( $old_gateway_slug, $offline_gateways ) ) {
188
-			$scope = array( 'CART' );
189
-		}elseif( ! $active && in_array($old_gateway_slug,$offline_gateways ) ) {
190
-			$scope = array( 'ADMIN' );
191
-		}else{
183
+		$pretty_name = isset($old_gateway_settings['display_name']) ? $old_gateway_settings['display_name'] : $old_gateway_slug;
184
+		$offline_gateways = array('Bank', 'Check', 'Invoice');
185
+		if ($active && in_array($old_gateway_slug, $offline_gateways)) {
186
+			$scope = array('CART', 'ADMIN');
187
+		}elseif ($active && ! in_array($old_gateway_slug, $offline_gateways)) {
188
+			$scope = array('CART');
189
+		}elseif ( ! $active && in_array($old_gateway_slug, $offline_gateways)) {
190
+			$scope = array('ADMIN');
191
+		} else {
192 192
 			$scope = array();
193 193
 		}
194 194
 		$payment_method_col_values = array(
@@ -196,25 +196,25 @@  discard block
 block discarded – undo
196 196
 			'PMD_name' => $pretty_name,
197 197
 			'PMD_desc' => $desc,
198 198
 			'PMD_admin_name' => $pretty_name,
199
-			'PMD_slug' => sanitize_key( $old_gateway_slug ),
200
-			'PMD_debug_mode' => isset( $old_gateway_settings[ 'use_sandbox' ] ) ? $old_gateway_settings['use_sandbox'] : FALSE,
201
-			'PMD_button_url' => isset( $old_gateway_settings[ 'button_url' ] ) ? $old_gateway_settings[ 'button_url' ] : NULL,
202
-			'PMD_scope' =>  serialize( $scope )
199
+			'PMD_slug' => sanitize_key($old_gateway_slug),
200
+			'PMD_debug_mode' => isset($old_gateway_settings['use_sandbox']) ? $old_gateway_settings['use_sandbox'] : FALSE,
201
+			'PMD_button_url' => isset($old_gateway_settings['button_url']) ? $old_gateway_settings['button_url'] : NULL,
202
+			'PMD_scope' =>  serialize($scope)
203 203
 		);
204 204
 		$db_types = array(
205
-			'%s',//PMD_type
206
-			'%s',//PMD_name
207
-			'%s',//PMD_desc
208
-			'%s',//PMD_admin_name
209
-			'%s',//PMD_slug
210
-			'%d',//PMD_debug_mode
211
-			'%s',//PMD_button_url
212
-			'%s',//PMD_scope
205
+			'%s', //PMD_type
206
+			'%s', //PMD_name
207
+			'%s', //PMD_desc
208
+			'%s', //PMD_admin_name
209
+			'%s', //PMD_slug
210
+			'%d', //PMD_debug_mode
211
+			'%s', //PMD_button_url
212
+			'%s', //PMD_scope
213 213
 		);
214 214
 		global $wpdb;
215 215
 		//first: check if it already exists
216
-		$id = $wpdb->get_var( $wpdb->prepare( "SELECT PMD_ID FROM {$this->_new_table_name} WHERE PMD_slug=%s", $payment_method_col_values[ 'PMD_slug' ] ) );
217
-		if( $id ){
216
+		$id = $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM {$this->_new_table_name} WHERE PMD_slug=%s", $payment_method_col_values['PMD_slug']));
217
+		if ($id) {
218 218
 			//just update that payment method instead of creating a new one
219 219
 			$success = $wpdb->update(
220 220
 					$this->_new_table_name,
@@ -224,27 +224,27 @@  discard block
 block discarded – undo
224 224
 					),
225 225
 					$db_types,
226 226
 					array(
227
-						'%d',//PMD_ID
227
+						'%d', //PMD_ID
228 228
 					));
229
-			if( ! $success ){
230
-				$this->add_error(sprintf(__('Could not update payment method %d with properties %s because %s', "event_espresso"),$id,wp_json_encode($payment_method_col_values),$wpdb->last_error));
229
+			if ( ! $success) {
230
+				$this->add_error(sprintf(__('Could not update payment method %d with properties %s because %s', "event_espresso"), $id, wp_json_encode($payment_method_col_values), $wpdb->last_error));
231 231
 			}
232
-		}else{
232
+		} else {
233 233
 			$success = $wpdb->insert(
234 234
 					$this->_new_table_name,
235 235
 					$payment_method_col_values,
236 236
 					$db_types);
237
-			if ( ! $success ) {
237
+			if ( ! $success) {
238 238
 				$this->add_error($wpdb->last_error);
239 239
 				return false;
240
-			}else{
240
+			} else {
241 241
 				$id = $wpdb->insert_id;
242 242
 			}
243 243
 		}
244 244
 
245
-		if( $id ){
246
-			$this->_convert_extra_meta_values( $id, $extra_meta_key_values );
247
-			$this->get_migration_script()->set_mapping( 'EE_Gateway_Config', $old_gateway_slug, $this->_new_table_name, $id );
245
+		if ($id) {
246
+			$this->_convert_extra_meta_values($id, $extra_meta_key_values);
247
+			$this->get_migration_script()->set_mapping('EE_Gateway_Config', $old_gateway_slug, $this->_new_table_name, $id);
248 248
 			return true;
249 249
 		}
250 250
 		return false;
@@ -258,26 +258,26 @@  discard block
 block discarded – undo
258 258
 	 * @param int $id
259 259
 	 * @param array $extra_meta_key_values
260 260
 	 */
261
-	private function _convert_extra_meta_values($id,$extra_meta_key_values){
261
+	private function _convert_extra_meta_values($id, $extra_meta_key_values) {
262 262
 		global $wpdb;
263
-		foreach( $extra_meta_key_values as $key => $value ){
263
+		foreach ($extra_meta_key_values as $key => $value) {
264 264
 			$exm_args = array(
265 265
 				'OBJ_ID'=>$id,
266 266
 				'EXM_type'=>'Payment_Method',
267 267
 				'EXM_key'=>$key,
268
-				'EXM_value'=> maybe_serialize($value )
268
+				'EXM_value'=> maybe_serialize($value)
269 269
 			);
270 270
 			$success = $wpdb->insert(
271 271
 					$this->_extra_meta_table_name,
272 272
 					$exm_args,
273 273
 					array(
274
-						'%d',//OBJ_ID
275
-						'%s',//EXM_type
276
-						'%s',//EXM_key
277
-						'%s',//EXM_value
274
+						'%d', //OBJ_ID
275
+						'%s', //EXM_type
276
+						'%s', //EXM_key
277
+						'%s', //EXM_value
278 278
 					));
279
-			if( ! $success ){
280
-				$this->add_error(sprintf(__('Could not insert extra meta key with values %s. %s', "event_espresso"),wp_json_encode($exm_args),$wpdb->last_error));
279
+			if ( ! $success) {
280
+				$this->add_error(sprintf(__('Could not insert extra meta key with values %s. %s', "event_espresso"), wp_json_encode($exm_args), $wpdb->last_error));
281 281
 			}
282 282
 		}
283 283
 	}
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_payment_method_currencies.dmsstage.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5 5
 }
6 6
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @author				Mike Nelson
14 14
  *
15 15
  */
16
-class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage{
16
+class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage {
17 17
 	protected $_currency_table_name;
18 18
 	protected $_currency_payment_method_table_name;
19 19
 	protected $_payment_method_table_name;
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	);
90 90
 	public function __construct() {
91 91
 		global $wpdb;
92
-		$this->_pretty_name = __( 'Payment Method Currencies', 'event_espresso' );
92
+		$this->_pretty_name = __('Payment Method Currencies', 'event_espresso');
93 93
 		$this->_payment_method_table_name = $wpdb->prefix.'esp_payment_method';
94 94
 		$this->_currency_payment_method_table_name = $wpdb->prefix.'esp_currency_payment_method';
95 95
 		$this->_currency_table_name = $wpdb->prefix.'esp_currency';
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 
99 99
 	protected function _count_records_to_migrate() {
100 100
 		$count = 0;
101
-		foreach($this->_gateway_currencies as $currencies){
102
-			if( $currencies == 'all'){
101
+		foreach ($this->_gateway_currencies as $currencies) {
102
+			if ($currencies == 'all') {
103 103
 				$currencies = $this->_get_all_currencies();
104 104
 			}
105 105
 			$count += count($currencies);
@@ -109,20 +109,20 @@  discard block
 block discarded – undo
109 109
 
110 110
 
111 111
 
112
-	protected function _migration_step( $num_items_to_migrate = 50 ) {
112
+	protected function _migration_step($num_items_to_migrate = 50) {
113 113
 		$items_actually_migrated = 0;
114 114
 		$relations_to_add_this_step = $this->_gather_relations_to_add($num_items_to_migrate);
115
-		foreach($relations_to_add_this_step as $pm_slug => $currencies){
115
+		foreach ($relations_to_add_this_step as $pm_slug => $currencies) {
116 116
 
117
-			$id = $this->get_migration_script()->get_mapping_new_pk( 'EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name );
118
-			foreach( $currencies as $currency ){
119
-				if( $id ){
120
-					$this->_add_currency_relations( $id, $currency );
117
+			$id = $this->get_migration_script()->get_mapping_new_pk('EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name);
118
+			foreach ($currencies as $currency) {
119
+				if ($id) {
120
+					$this->_add_currency_relations($id, $currency);
121 121
 				}
122 122
 				$items_actually_migrated++;
123 123
 			}
124 124
 		}
125
-		if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){
125
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
126 126
 			$this->set_completed();
127 127
 		}
128 128
 		return $items_actually_migrated;
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 		$relations_to_add_this_step = array();
133 133
 		$migrate_up_to_count = $this->count_records_migrated() + $num_items_to_migrate;
134 134
 		$iterator = 0;
135
-		foreach($this->_gateway_currencies as $pm_slug => $currencies){
136
-			if( $currencies == 'all' ){
135
+		foreach ($this->_gateway_currencies as $pm_slug => $currencies) {
136
+			if ($currencies == 'all') {
137 137
 				$currencies = $this->_get_all_currencies();
138 138
 			}
139
-			foreach($currencies as $currency_code){
140
-				if( $this->count_records_migrated() <= $iterator &&
141
-						$iterator < $migrate_up_to_count ){
142
-					$relations_to_add_this_step[ $pm_slug ] [] = $currency_code;
139
+			foreach ($currencies as $currency_code) {
140
+				if ($this->count_records_migrated() <= $iterator &&
141
+						$iterator < $migrate_up_to_count) {
142
+					$relations_to_add_this_step[$pm_slug] [] = $currency_code;
143 143
 				}
144 144
 				$iterator++;
145 145
 			}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * Gets all the currency codes in the database
151 151
 	 * @return array
152 152
 	 */
153
-	private function _get_all_currencies(){
153
+	private function _get_all_currencies() {
154 154
 		global $wpdb;
155 155
 		$currencies = $wpdb->get_col("SELECT CUR_code FROM {$this->_currency_table_name}");
156 156
 		return $currencies;
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @param int $id
162 162
 	 * @param string $gateway_slug
163 163
 	 */
164
-	private function _add_currency_relations($pm_id,$currency_code){
164
+	private function _add_currency_relations($pm_id, $currency_code) {
165 165
 		global $wpdb;
166 166
 		$cur_pm_relation = array(
167 167
 					'CUR_code'=>$currency_code,
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 		$success = $wpdb->insert($this->_currency_payment_method_table_name,
171 171
 				$cur_pm_relation,
172 172
 				array(
173
-					'%s',//CUR_code
174
-					'%d',//PMD_ID
173
+					'%s', //CUR_code
174
+					'%d', //PMD_ID
175 175
 				));
176
-		if( ! $success ){
177
-			$this->add_error( sprintf( __( 'Could not add currency relation %s because %s', "event_espresso" ), wp_json_encode( $cur_pm_relation ), $wpdb->last_error ) );
176
+		if ( ! $success) {
177
+			$this->add_error(sprintf(__('Could not add currency relation %s because %s', "event_espresso"), wp_json_encode($cur_pm_relation), $wpdb->last_error));
178 178
 		}
179 179
 	}
180 180
 }
Please login to merge, or discard this patch.
4_9_0_stages/EE_DMS_4_9_0_Email_System_Question.dmsstage.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5 5
 }
6 6
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @author				Brent Christensen
14 14
  *
15 15
  */
16
-class EE_DMS_4_9_0_Email_System_Question extends EE_Data_Migration_Script_Stage_Table{
16
+class EE_DMS_4_9_0_Email_System_Question extends EE_Data_Migration_Script_Stage_Table {
17 17
 
18 18
 
19 19
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public function __construct() {
26 26
 		global $wpdb;
27
-		$this->_pretty_name = __( 'Email - System Question', 'event_espresso' );
27
+		$this->_pretty_name = __('Email - System Question', 'event_espresso');
28 28
 		$this->_old_table = $wpdb->prefix.'esp_question';
29 29
 		$this->_extra_where_sql = "WHERE QST_system = 'email'";
30 30
 		parent::__construct();
@@ -37,21 +37,21 @@  discard block
 block discarded – undo
37 37
 	 * @param array $question an associative array where keys are column names and values are their values.
38 38
 	 * @return null
39 39
 	 */
40
-	protected function _migrate_old_row( $question ) {
41
-		if ( $question['QST_ID'] && $question['QST_system'] == 'email' ) {
40
+	protected function _migrate_old_row($question) {
41
+		if ($question['QST_ID'] && $question['QST_system'] == 'email') {
42 42
 			global $wpdb;
43 43
 			$success = $wpdb->update(
44 44
 				$this->_old_table,
45
-				array( 'QST_type' => 'EMAIL' ),  // data
46
-				array( 'QST_ID' => $question['QST_ID'] ),  // where
47
-				array( '%s' ),   // data format
48
-				array( '%d' )  // where format
45
+				array('QST_type' => 'EMAIL'), // data
46
+				array('QST_ID' => $question['QST_ID']), // where
47
+				array('%s'), // data format
48
+				array('%d')  // where format
49 49
 			);
50
-			if ( ! $success ) {
50
+			if ( ! $success) {
51 51
 				$this->add_error(
52 52
 					sprintf(
53
-						__( 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso' ),
54
-						wp_json_encode( $question['QST_system'] ),
53
+						__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
54
+						wp_json_encode($question['QST_system']),
55 55
 						$question['QST_ID'],
56 56
 						$wpdb->last_error
57 57
 					)
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/model/Read.php 1 patch
Spacing   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\libraries\rest_api\Rest_Exception;
7 7
 use EventEspresso\core\libraries\rest_api\Model_Data_Translator;
8 8
 
9
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
10
-	exit( 'No direct script access allowed' );
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 /**
@@ -46,22 +46,22 @@  discard block
 block discarded – undo
46 46
 	 * @param \WP_REST_Request $request
47 47
 	 * @return \WP_REST_Response|\WP_Error
48 48
 	 */
49
-	public static function handle_request_get_all( \WP_REST_Request $request) {
49
+	public static function handle_request_get_all(\WP_REST_Request $request) {
50 50
 		$controller = new Read();
51
-		try{
51
+		try {
52 52
 			$matches = $controller->parse_route(
53 53
 				$request->get_route(),
54
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~',
55
-				array( 'version', 'model' )
54
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~',
55
+				array('version', 'model')
56 56
 			);
57
-			$controller->set_requested_version( $matches[ 'version' ] );
58
-			$model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
59
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) {
57
+			$controller->set_requested_version($matches['version']);
58
+			$model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
59
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) {
60 60
 				return $controller->send_response(
61 61
 					new \WP_Error(
62 62
 						'endpoint_parsing_error',
63 63
 						sprintf(
64
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
64
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
65 65
 							$model_name_singular
66 66
 						)
67 67
 					)
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 			}
70 70
 			return $controller->send_response(
71 71
 					$controller->get_entities_from_model(
72
-							$controller->get_model_version_info()->load_model( $model_name_singular ),
72
+							$controller->get_model_version_info()->load_model($model_name_singular),
73 73
 							$request
74 74
 					)
75 75
 			);
76
-		} catch( \Exception $e ) {
77
-			return $controller->send_response( $e );
76
+		} catch (\Exception $e) {
77
+			return $controller->send_response($e);
78 78
 		}
79 79
 	}
80 80
 
@@ -84,21 +84,21 @@  discard block
 block discarded – undo
84 84
 	 * @param \WP_REST_Request $request
85 85
 	 * @return \WP_REST_Response|\WP_Error
86 86
 	 */
87
-	public static function handle_request_get_one( \WP_REST_Request $request ) {
87
+	public static function handle_request_get_one(\WP_REST_Request $request) {
88 88
 		$controller = new Read();
89
-		try{
89
+		try {
90 90
 			$matches = $controller->parse_route(
91 91
 				$request->get_route(),
92
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~',
93
-				array( 'version', 'model', 'id' ) );
94
-			$controller->set_requested_version( $matches[ 'version' ] );
95
-			$model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
96
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) {
92
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~',
93
+				array('version', 'model', 'id') );
94
+			$controller->set_requested_version($matches['version']);
95
+			$model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
96
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) {
97 97
 				return $controller->send_response(
98 98
 					new \WP_Error(
99 99
 						'endpoint_parsing_error',
100 100
 						sprintf(
101
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
101
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
102 102
 							$model_name_singular
103 103
 						)
104 104
 					)
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 			}
107 107
 			return $controller->send_response(
108 108
 					$controller->get_entity_from_model(
109
-							$controller->get_model_version_info()->load_model( $model_name_singular ),
109
+							$controller->get_model_version_info()->load_model($model_name_singular),
110 110
 							$request
111 111
 						)
112 112
 				);
113
-		} catch( \Exception $e ) {
114
-			return $controller->send_response( $e );
113
+		} catch (\Exception $e) {
114
+			return $controller->send_response($e);
115 115
 		}
116 116
 	}
117 117
 
@@ -123,40 +123,40 @@  discard block
 block discarded – undo
123 123
 	 * @param \WP_REST_Request $request
124 124
 	 * @return \WP_REST_Response|\WP_Error
125 125
 	 */
126
-	public static function handle_request_get_related( \WP_REST_Request $request ) {
126
+	public static function handle_request_get_related(\WP_REST_Request $request) {
127 127
 		$controller = new Read();
128
-		try{
128
+		try {
129 129
 			$matches = $controller->parse_route(
130 130
 				$request->get_route(),
131
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~',
132
-				array( 'version', 'model', 'id', 'related_model' )
131
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~',
132
+				array('version', 'model', 'id', 'related_model')
133 133
 			);
134
-			$controller->set_requested_version( $matches[ 'version' ] );
135
-			$main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
136
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) {
134
+			$controller->set_requested_version($matches['version']);
135
+			$main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
136
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) {
137 137
 				return $controller->send_response(
138 138
 					new \WP_Error(
139 139
 						'endpoint_parsing_error',
140 140
 						sprintf(
141
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
141
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
142 142
 							$main_model_name_singular
143 143
 						)
144 144
 					)
145 145
 				);
146 146
 			}
147
-			$main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular );
147
+			$main_model = $controller->get_model_version_info()->load_model($main_model_name_singular);
148 148
 			//assume the related model name is plural and try to find the model's name
149
-			$related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] );
150
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) {
149
+			$related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']);
150
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) {
151 151
 				//so the word didn't singularize well. Maybe that's just because it's a singular word?
152
-				$related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] );
152
+				$related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']);
153 153
 			}
154
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) {
154
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) {
155 155
 				return $controller->send_response(
156 156
 					new \WP_Error(
157 157
 						'endpoint_parsing_error',
158 158
 						sprintf(
159
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
159
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
160 160
 							$related_model_name_singular
161 161
 						)
162 162
 					)
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
 
166 166
 			return $controller->send_response(
167 167
 					$controller->get_entities_from_relation(
168
-						$request->get_param( 'id' ),
169
-						$main_model->related_settings_for( $related_model_name_singular ) ,
168
+						$request->get_param('id'),
169
+						$main_model->related_settings_for($related_model_name_singular),
170 170
 						$request
171 171
 					)
172 172
 				);
173
-		} catch( \Exception $e ) {
174
-			return $controller->send_response( $e );
173
+		} catch (\Exception $e) {
174
+			return $controller->send_response($e);
175 175
 		}
176 176
 	}
177 177
 
@@ -184,28 +184,28 @@  discard block
 block discarded – undo
184 184
 	 * @param \WP_REST_Request $request
185 185
 	 * @return array|\WP_Error
186 186
 	 */
187
-	public function get_entities_from_model( $model, $request) {
188
-		$query_params = $this->create_model_query_params( $model, $request->get_params() );
189
-		if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) {
190
-			$model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() );
187
+	public function get_entities_from_model($model, $request) {
188
+		$query_params = $this->create_model_query_params($model, $request->get_params());
189
+		if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) {
190
+			$model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name());
191 191
 			return new \WP_Error(
192
-				sprintf( 'rest_%s_cannot_list', $model_name_plural ),
192
+				sprintf('rest_%s_cannot_list', $model_name_plural),
193 193
 				sprintf(
194
-					__( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ),
194
+					__('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'),
195 195
 					$model_name_plural,
196
-					Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] )
196
+					Capabilities::get_missing_permissions_string($model, $query_params['caps'])
197 197
 				),
198
-				array( 'status' => 403 )
198
+				array('status' => 403)
199 199
 			);
200 200
 		}
201
-		if( ! $request->get_header( 'no_rest_headers' ) ) {
202
-			$this->_set_headers_from_query_params( $model, $query_params );
201
+		if ( ! $request->get_header('no_rest_headers')) {
202
+			$this->_set_headers_from_query_params($model, $query_params);
203 203
 		}
204 204
 		/** @type array $results */
205
-		$results = $model->get_all_wpdb_results( $query_params );
205
+		$results = $model->get_all_wpdb_results($query_params);
206 206
 		$nice_results = array( );
207
-		foreach ( $results as $result ) {
208
-			$nice_results[ ] = $this->create_entity_from_wpdb_result(
207
+		foreach ($results as $result) {
208
+			$nice_results[] = $this->create_entity_from_wpdb_result(
209 209
 					$model,
210 210
 					$result,
211 211
 					$request
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 	 * @param \WP_REST_Request $request
222 222
 	 * @return \WP_Error|array
223 223
 	 */
224
-	protected function _get_entities_from_relation( $primary_model_query_params, $relation, $request ) {
225
-		$context = $this->validate_context( $request->get_param( 'caps' ));
224
+	protected function _get_entities_from_relation($primary_model_query_params, $relation, $request) {
225
+		$context = $this->validate_context($request->get_param('caps'));
226 226
 		$model = $relation->get_this_model();
227 227
 		$related_model = $relation->get_other_model();
228
-		if( ! isset( $primary_model_query_params[0]) ) {
228
+		if ( ! isset($primary_model_query_params[0])) {
229 229
 			$primary_model_query_params[0] = array();
230 230
 		}
231 231
 		//check if they can access the 1st model object
@@ -233,60 +233,60 @@  discard block
 block discarded – undo
233 233
 			0 => $primary_model_query_params[0],
234 234
 			'limit' => 1
235 235
 		);
236
-		if( $model instanceof \EEM_Soft_Delete_Base ){
237
-			$primary_model_query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included( $primary_model_query_params );
236
+		if ($model instanceof \EEM_Soft_Delete_Base) {
237
+			$primary_model_query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($primary_model_query_params);
238 238
 		}
239 239
 		$restricted_query_params = $primary_model_query_params;
240
-		$restricted_query_params[ 'caps' ] = $context;
241
-		$this->_set_debug_info( 'main model query params', $restricted_query_params );
242
-		$this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) );
240
+		$restricted_query_params['caps'] = $context;
241
+		$this->_set_debug_info('main model query params', $restricted_query_params);
242
+		$this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context));
243 243
 
244
-		if(
244
+		if (
245 245
 			! (
246
-				Capabilities::current_user_has_partial_access_to( $related_model, $context )
247
-				&& $model->exists( $restricted_query_params )
246
+				Capabilities::current_user_has_partial_access_to($related_model, $context)
247
+				&& $model->exists($restricted_query_params)
248 248
 			)
249
-		){
250
-			if( $relation instanceof \EE_Belongs_To_Relation ) {
251
-				$related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() );
252
-			}else{
253
-				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() );
249
+		) {
250
+			if ($relation instanceof \EE_Belongs_To_Relation) {
251
+				$related_model_name_maybe_plural = strtolower($related_model->get_this_model_name());
252
+			} else {
253
+				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name());
254 254
 			}
255 255
 			return new \WP_Error(
256
-				sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ),
256
+				sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural),
257 257
 				sprintf(
258
-					__(	'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ),
258
+					__('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'),
259 259
 					$related_model_name_maybe_plural,
260 260
 					$relation->get_this_model()->get_this_model_name(),
261 261
 					implode(
262 262
 						',',
263 263
 						array_keys(
264
-							Capabilities::get_missing_permissions( $related_model, $context )
264
+							Capabilities::get_missing_permissions($related_model, $context)
265 265
 						)
266 266
 					)
267 267
 				),
268
-				array( 'status' => 403 )
268
+				array('status' => 403)
269 269
 			);
270 270
 		}
271
-		$query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() );
272
-		foreach( $primary_model_query_params[0] as $where_condition_key => $where_condition_value ) {
273
-			 $query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $where_condition_key ] = $where_condition_value;
271
+		$query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params());
272
+		foreach ($primary_model_query_params[0] as $where_condition_key => $where_condition_value) {
273
+			 $query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$where_condition_key] = $where_condition_value;
274 274
 		}
275
-		$query_params[ 'default_where_conditions' ] = 'none';
276
-		$query_params[ 'caps' ] = $context;
277
-		if( ! $request->get_header( 'no_rest_headers' ) ) {
278
-			$this->_set_headers_from_query_params( $relation->get_other_model(), $query_params );
275
+		$query_params['default_where_conditions'] = 'none';
276
+		$query_params['caps'] = $context;
277
+		if ( ! $request->get_header('no_rest_headers')) {
278
+			$this->_set_headers_from_query_params($relation->get_other_model(), $query_params);
279 279
 		}
280 280
 		/** @type array $results */
281
-		$results = $relation->get_other_model()->get_all_wpdb_results( $query_params );
281
+		$results = $relation->get_other_model()->get_all_wpdb_results($query_params);
282 282
 		$nice_results = array();
283
-		foreach( $results as $result ) {
283
+		foreach ($results as $result) {
284 284
 			$nice_result = $this->create_entity_from_wpdb_result(
285 285
 				$relation->get_other_model(),
286 286
 				$result,
287 287
 				$request
288 288
 			);
289
-			if( $relation instanceof \EE_HABTM_Relation ) {
289
+			if ($relation instanceof \EE_HABTM_Relation) {
290 290
 				//put the unusual stuff (properties from the HABTM relation) first, and make sure
291 291
 				//if there are conflicts we prefer the properties from the main model
292 292
 				$join_model_result = $this->create_entity_from_wpdb_result(
@@ -294,18 +294,18 @@  discard block
 block discarded – undo
294 294
 					$result,
295 295
 					$request
296 296
 				);
297
-				$joined_result = array_merge( $nice_result, $join_model_result );
297
+				$joined_result = array_merge($nice_result, $join_model_result);
298 298
 				//but keep the meta stuff from the main model
299
-				if( isset( $nice_result['meta'] ) ){
299
+				if (isset($nice_result['meta'])) {
300 300
 					$joined_result['meta'] = $nice_result['meta'];
301 301
 				}
302 302
 				$nice_result = $joined_result;
303 303
 			}
304 304
 			$nice_results[] = $nice_result;
305 305
 		}
306
-		if( $relation instanceof \EE_Belongs_To_Relation ){
307
-			return array_shift( $nice_results );
308
-		}else{
306
+		if ($relation instanceof \EE_Belongs_To_Relation) {
307
+			return array_shift($nice_results);
308
+		} else {
309 309
 			return $nice_results;
310 310
 		}
311 311
 	}
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 	 * @return array|\WP_Error
325 325
 	 * @throws \EE_Error
326 326
 	 */
327
-	public function get_entities_from_relation( $id, $relation, $request ) {
328
-		if( ! $relation->get_this_model()->has_primary_key_field() ) {
327
+	public function get_entities_from_relation($id, $relation, $request) {
328
+		if ( ! $relation->get_this_model()->has_primary_key_field()) {
329 329
 			throw new \EE_Error(
330 330
 				sprintf(
331
-					__( 'Read::get_entities_from_relation should only be called from a model with a primary key, it was called from %1$s', 'event_espresso'),
331
+					__('Read::get_entities_from_relation should only be called from a model with a primary key, it was called from %1$s', 'event_espresso'),
332 332
 					$relation->get_this_model()->get_this_model_name()
333 333
 				)
334 334
 			);
@@ -352,30 +352,30 @@  discard block
 block discarded – undo
352 352
 	 * @param array $query_params
353 353
 	 * @return void
354 354
 	 */
355
-	protected function _set_headers_from_query_params( $model, $query_params ) {
356
-		$this->_set_debug_info( 'model query params', $query_params );
357
-		$this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) );
355
+	protected function _set_headers_from_query_params($model, $query_params) {
356
+		$this->_set_debug_info('model query params', $query_params);
357
+		$this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps']));
358 358
 		//normally the limit to a 2-part array, where the 2nd item is the limit
359
-		if( ! isset( $query_params[ 'limit' ] ) ) {
360
-			$query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit();
359
+		if ( ! isset($query_params['limit'])) {
360
+			$query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit();
361 361
 		}
362
-		if( is_array( $query_params[ 'limit' ] )  ) {
363
-			$limit_parts = $query_params[ 'limit' ];
362
+		if (is_array($query_params['limit'])) {
363
+			$limit_parts = $query_params['limit'];
364 364
 		} else {
365
-			$limit_parts = explode(',', $query_params[ 'limit' ] );
366
-			if( count( $limit_parts ) == 1 ){
367
-				$limit_parts = array(0, $limit_parts[ 0 ] );
365
+			$limit_parts = explode(',', $query_params['limit']);
366
+			if (count($limit_parts) == 1) {
367
+				$limit_parts = array(0, $limit_parts[0]);
368 368
 			}
369 369
 		}
370 370
 		//remove the group by and having parts of the query, as those will
371 371
 		//make the sql query return an array of values, instead of just a single value
372
-		unset( $query_params[ 'group_by' ], $query_params[ 'having' ], $query_params[ 'limit' ] );
373
-		$count = $model->count( $query_params, null, true );
372
+		unset($query_params['group_by'], $query_params['having'], $query_params['limit']);
373
+		$count = $model->count($query_params, null, true);
374 374
 
375
-		$pages = $count / $limit_parts[ 1 ];
376
-		$this->_set_response_header( 'Total', $count, false );
377
-		$this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false );
378
-		$this->_set_response_header( 'TotalPages', ceil( $pages ), false );
375
+		$pages = $count / $limit_parts[1];
376
+		$this->_set_response_header('Total', $count, false);
377
+		$this->_set_response_header('PageSize', $limit_parts[1], false);
378
+		$this->_set_response_header('TotalPages', ceil($pages), false);
379 379
 	}
380 380
 
381 381
 
@@ -388,50 +388,50 @@  discard block
 block discarded – undo
388 388
 	 * @param string $deprecated no longer used
389 389
 	 * @return array ready for being converted into json for sending to client
390 390
 	 */
391
-	public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) {
392
-		if( ! $rest_request instanceof \WP_REST_Request ) {
391
+	public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) {
392
+		if ( ! $rest_request instanceof \WP_REST_Request) {
393 393
 			//ok so this was called in the old style, where the 3rd arg was
394 394
 			//$include, and the 4th arg was $context
395 395
 			//now setup the request just to avoid fatal errors, although we won't be able
396 396
 			//to truly make use of it because it's kinda devoid of info
397 397
 			$rest_request = new \WP_REST_Request();
398
-			$rest_request->set_param( 'include', $rest_request );
399
-			$rest_request->set_param( 'caps', $deprecated );
398
+			$rest_request->set_param('include', $rest_request);
399
+			$rest_request->set_param('caps', $deprecated);
400 400
 		}
401
-		if( $rest_request->get_param( 'caps' ) == null ) {
402
-			$rest_request->set_param( 'caps', \EEM_Base::caps_read );
401
+		if ($rest_request->get_param('caps') == null) {
402
+			$rest_request->set_param('caps', \EEM_Base::caps_read);
403 403
 		}
404
-		$entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row );
405
-		$entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array );
406
-		$entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array );
407
-		$entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request );
408
-		$entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array, $db_row );
404
+		$entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row);
405
+		$entity_array = $this->_add_extra_fields($model, $db_row, $entity_array);
406
+		$entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array);
407
+		$entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request);
408
+		$entity_array = $this->_include_requested_models($model, $rest_request, $entity_array, $db_row);
409 409
 		$entity_array = apply_filters(
410 410
 			'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal',
411 411
 			$entity_array,
412 412
 			$model,
413
-			$rest_request->get_param( 'caps' ),
413
+			$rest_request->get_param('caps'),
414 414
 			$rest_request,
415 415
 			$this
416 416
 		);
417 417
 		$result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields(
418 418
 			$entity_array,
419 419
 			$model,
420
-			$rest_request->get_param( 'caps' ),
420
+			$rest_request->get_param('caps'),
421 421
 			$this->get_model_version_info(),
422 422
 			$model->get_index_primary_key_string(
423
-				$model->deduce_fields_n_values_from_cols_n_values($db_row )
423
+				$model->deduce_fields_n_values_from_cols_n_values($db_row)
424 424
 			)
425 425
 		);
426 426
 		$this->_set_debug_info(
427 427
 			'inaccessible fields',
428
-			array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) )
428
+			array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields))
429 429
 		);
430 430
 		return apply_filters(
431 431
 			'FHEE__Read__create_entity_from_wpdb_results__entity_return',
432 432
 			$result_without_inaccessible_fields,
433 433
 			$model,
434
-			$rest_request->get_param( 'caps' )
434
+			$rest_request->get_param('caps')
435 435
 		);
436 436
 	}
437 437
 
@@ -443,39 +443,39 @@  discard block
 block discarded – undo
443 443
 	 * @param array $db_row
444 444
 	 * @return array entity mostly ready for converting to JSON and sending in the response
445 445
 	 */
446
-	protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) {
447
-		$result = $model->deduce_fields_n_values_from_cols_n_values( $db_row );
448
-		$result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) );
449
-		foreach( $result as $field_name => $raw_field_value ) {
446
+	protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) {
447
+		$result = $model->deduce_fields_n_values_from_cols_n_values($db_row);
448
+		$result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model));
449
+		foreach ($result as $field_name => $raw_field_value) {
450 450
 			$field_obj = $model->field_settings_for($field_name);
451
-			$field_value = $field_obj->prepare_for_set_from_db( $raw_field_value );
452
-			if( $this->is_subclass_of_one(  $field_obj, $this->get_model_version_info()->fields_ignored() ) ){
453
-				unset( $result[ $field_name ] );
454
-			}elseif(
455
-				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() )
456
-			){
457
-				$result[ $field_name ] = array(
458
-					'raw' => $field_obj->prepare_for_get( $field_value ),
459
-					'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value )
451
+			$field_value = $field_obj->prepare_for_set_from_db($raw_field_value);
452
+			if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) {
453
+				unset($result[$field_name]);
454
+			}elseif (
455
+				$this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format())
456
+			) {
457
+				$result[$field_name] = array(
458
+					'raw' => $field_obj->prepare_for_get($field_value),
459
+					'rendered' => $field_obj->prepare_for_pretty_echoing($field_value)
460 460
 				);
461
-			}elseif(
462
-				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() )
463
-			){
464
-				$result[ $field_name ] = array(
465
-					'raw' => $field_obj->prepare_for_get( $field_value ),
466
-					'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value )
461
+			}elseif (
462
+				$this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format())
463
+			) {
464
+				$result[$field_name] = array(
465
+					'raw' => $field_obj->prepare_for_get($field_value),
466
+					'pretty' => $field_obj->prepare_for_pretty_echoing($field_value)
467 467
 				);
468
-			} elseif ( $field_obj instanceof \EE_Datetime_Field ) {
469
-				if( $field_value instanceof \DateTime ) {
468
+			} elseif ($field_obj instanceof \EE_Datetime_Field) {
469
+				if ($field_value instanceof \DateTime) {
470 470
 					$timezone = $field_value->getTimezone();
471
-					$field_value->setTimezone( new \DateTimeZone( 'UTC' ) );
472
-					$result[ $field_name . '_gmt' ] = Model_Data_Translator::prepare_field_value_for_json(
471
+					$field_value->setTimezone(new \DateTimeZone('UTC'));
472
+					$result[$field_name.'_gmt'] = Model_Data_Translator::prepare_field_value_for_json(
473 473
 						$field_obj,
474 474
 						$field_value,
475 475
 						$this->get_model_version_info()->requested_version()
476 476
 					);
477
-					$field_value->setTimezone( $timezone );
478
-					$result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json(
477
+					$field_value->setTimezone($timezone);
478
+					$result[$field_name] = Model_Data_Translator::prepare_field_value_for_json(
479 479
 						$field_obj,
480 480
 						$field_value,
481 481
 						$this->get_model_version_info()->requested_version()
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
 				}
484 484
 
485 485
 			} else {
486
-				$result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json(
486
+				$result[$field_name] = Model_Data_Translator::prepare_field_value_for_json(
487 487
 					$field_obj,
488
-					$field_obj->prepare_for_get( $field_value ),
488
+					$field_obj->prepare_for_get($field_value),
489 489
 					$this->get_model_version_info()->requested_version()
490 490
 				);
491 491
 			}
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 	 * @param array $entity_array
501 501
 	 * @return array modified entity
502 502
 	 */
503
-	protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) {
504
-		if( $model instanceof \EEM_CPT_Base ) {
505
-			$entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] );
503
+	protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) {
504
+		if ($model instanceof \EEM_CPT_Base) {
505
+			$entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]);
506 506
 		}
507 507
 		return $entity_array;
508 508
 	}
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 	 * @param array $entity_array
517 517
 	 * @return array the _links item in the entity
518 518
 	 */
519
-	protected function _get_entity_links( $model, $db_row, $entity_array ) {
519
+	protected function _get_entity_links($model, $db_row, $entity_array) {
520 520
 		//add basic links
521 521
 		$links = array();
522
-		if( $model->has_primary_key_field() ) {
522
+		if ($model->has_primary_key_field()) {
523 523
 			$links['self'] = array(
524 524
 				array(
525 525
 					'href' => $this->get_versioned_link_to(
526
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ]
526
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()]
527 527
 					)
528 528
 				)
529 529
 			);
@@ -531,33 +531,33 @@  discard block
 block discarded – undo
531 531
 		$links['collection'] = array(
532 532
 			array(
533 533
 				'href' => $this->get_versioned_link_to(
534
-					\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() )
534
+					\EEH_Inflector::pluralize_and_lower($model->get_this_model_name())
535 535
 				)
536 536
 			)
537 537
 		);
538 538
 
539 539
 		//add link to the wp core endpoint, if wp api is active
540 540
 		global $wp_rest_server;
541
-		if( $model instanceof \EEM_CPT_Base &&
541
+		if ($model instanceof \EEM_CPT_Base &&
542 542
 			$wp_rest_server instanceof \WP_REST_Server &&
543
-			$wp_rest_server->get_route_options( '/wp/v2/posts' ) &&
544
-			$model->has_primary_key_field() ) {
545
-			$links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array(
543
+			$wp_rest_server->get_route_options('/wp/v2/posts') &&
544
+			$model->has_primary_key_field()) {
545
+			$links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array(
546 546
 				array(
547
-					'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ),
547
+					'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]),
548 548
 					'single' => true
549 549
 				)
550 550
 			);
551 551
 		}
552 552
 
553 553
 		//add links to related models
554
-		if( $model->has_primary_key_field() ) {
555
-			foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) {
556
-				$related_model_part = Read::get_related_entity_name( $relation_name, $relation_obj );
557
-				$links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array(
554
+		if ($model->has_primary_key_field()) {
555
+			foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) {
556
+				$related_model_part = Read::get_related_entity_name($relation_name, $relation_obj);
557
+				$links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array(
558 558
 					array(
559 559
 						'href' => $this->get_versioned_link_to(
560
-							\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part
560
+							\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part
561 561
 						),
562 562
 						'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false
563 563
 					)
@@ -575,52 +575,52 @@  discard block
 block discarded – undo
575 575
 	 * @param array $db_row
576 576
 	 * @return array the modified entity
577 577
 	 */
578
-	protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array, $db_row = array() ) {
578
+	protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array, $db_row = array()) {
579 579
 		//if $db_row not included, hope the entity array has what we need
580
-		if( ! $db_row ) {
580
+		if ( ! $db_row) {
581 581
 			$db_row = $entity_array;
582 582
 		}
583
-		$includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' );
584
-		$includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model );
583
+		$includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), '');
584
+		$includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model);
585 585
 		//if they passed in * or didn't specify any includes, return everything
586
-		if( ! in_array( '*', $includes_for_this_model )
587
-			&& ! empty( $includes_for_this_model ) ) {
588
-			if( $model->has_primary_key_field() ) {
586
+		if ( ! in_array('*', $includes_for_this_model)
587
+			&& ! empty($includes_for_this_model)) {
588
+			if ($model->has_primary_key_field()) {
589 589
 				//always include the primary key. ya just gotta know that at least
590 590
 				$includes_for_this_model[] = $model->primary_key_name();
591 591
 			}
592
-			if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) {
592
+			if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) {
593 593
 				$includes_for_this_model[] = '_calculated_fields';
594 594
 			}
595
-			$entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) );
595
+			$entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model));
596 596
 		}
597
-		$relation_settings = $this->get_model_version_info()->relation_settings( $model );
598
-		foreach( $relation_settings as $relation_name => $relation_obj ) {
597
+		$relation_settings = $this->get_model_version_info()->relation_settings($model);
598
+		foreach ($relation_settings as $relation_name => $relation_obj) {
599 599
 			$related_fields_to_include = $this->explode_and_get_items_prefixed_with(
600
-				$rest_request->get_param( 'include' ),
600
+				$rest_request->get_param('include'),
601 601
 				$relation_name
602 602
 			);
603 603
 			$related_fields_to_calculate = $this->explode_and_get_items_prefixed_with(
604
-				$rest_request->get_param( 'calculate' ),
604
+				$rest_request->get_param('calculate'),
605 605
 				$relation_name
606 606
 			);
607 607
 			//did they specify they wanted to include a related model, or
608 608
 			//specific fields from a related model?
609 609
 			//or did they specify to calculate a field from a related model?
610
-			if( $related_fields_to_include || $related_fields_to_calculate ) {
610
+			if ($related_fields_to_include || $related_fields_to_calculate) {
611 611
 				//if so, we should include at least some part of the related model
612 612
 				$pretend_related_request = new \WP_REST_Request();
613 613
 				$pretend_related_request->set_query_params(
614 614
 					array(
615
-						'caps' => $rest_request->get_param( 'caps' ),
615
+						'caps' => $rest_request->get_param('caps'),
616 616
 						'include' => $related_fields_to_include,
617 617
 						'calculate' => $related_fields_to_calculate,
618 618
 					)
619 619
 				);
620
-				$pretend_related_request->add_header( 'no_rest_headers', true );
620
+				$pretend_related_request->add_header('no_rest_headers', true);
621 621
 				$primary_model_query_params = $model->alter_query_params_to_restrict_by_ID(
622 622
 					$model->get_index_primary_key_string(
623
-						$model->deduce_fields_n_values_from_cols_n_values( $db_row )
623
+						$model->deduce_fields_n_values_from_cols_n_values($db_row)
624 624
 					)
625 625
 				);
626 626
 				$related_results = $this->_get_entities_from_relation(
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 					$relation_obj,
629 629
 					$pretend_related_request
630 630
 				);
631
-				$entity_array[ Read::get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error
631
+				$entity_array[Read::get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error
632 632
 					? null
633 633
 					: $related_results;
634 634
 			}
@@ -642,8 +642,8 @@  discard block
 block discarded – undo
642 642
 	 * @param array $arr
643 643
 	 * @return array
644 644
 	 */
645
-	private function _remove_model_names_from_array( $arr ) {
646
-		return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) );
645
+	private function _remove_model_names_from_array($arr) {
646
+		return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models));
647 647
 	}
648 648
 	/**
649 649
 	 * Gets the calculated fields for the response
@@ -653,15 +653,15 @@  discard block
 block discarded – undo
653 653
 	 * @param \WP_REST_Request $rest_request
654 654
 	 * @return \stdClass the _calculations item in the entity
655 655
 	 */
656
-	protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) {
656
+	protected function _get_entity_calculations($model, $wpdb_row, $rest_request) {
657 657
 		$calculated_fields = $this->explode_and_get_items_prefixed_with(
658
-			$rest_request->get_param( 'calculate' ),
658
+			$rest_request->get_param('calculate'),
659 659
 			''
660 660
 		);
661 661
 		//note: setting calculate=* doesn't do anything
662 662
 		$calculated_fields_to_return = new \stdClass();
663
-		foreach( $calculated_fields as $field_to_calculate ) {
664
-			try{
663
+		foreach ($calculated_fields as $field_to_calculate) {
664
+			try {
665 665
 				$calculated_fields_to_return->$field_to_calculate = Model_Data_Translator::prepare_field_value_for_json(
666 666
 					null,
667 667
 					$this->_fields_calculator->retrieve_calculated_field_value(
@@ -673,10 +673,10 @@  discard block
 block discarded – undo
673 673
 					),
674 674
 					$this->get_model_version_info()->requested_version()
675 675
 				);
676
-			} catch( Rest_Exception $e ) {
676
+			} catch (Rest_Exception $e) {
677 677
 				//if we don't have permission to read it, just leave it out. but let devs know about the problem
678 678
 				$this->_set_response_header(
679
-					'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']',
679
+					'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']',
680 680
 					$e->getMessage(),
681 681
 					true
682 682
 				);
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 	 * @param string $link_part_after_version_and_slash eg "events/10/datetimes"
691 691
 	 * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes"
692 692
 	 */
693
-	public function get_versioned_link_to( $link_part_after_version_and_slash ) {
693
+	public function get_versioned_link_to($link_part_after_version_and_slash) {
694 694
 		return rest_url(
695 695
 			\EED_Core_Rest_Api::ee_api_namespace
696 696
 			. $this->get_model_version_info()->requested_version()
@@ -706,11 +706,11 @@  discard block
 block discarded – undo
706 706
 	 * @param \EE_Model_Relation_Base $relation_obj
707 707
 	 * @return string
708 708
 	 */
709
-	public static function get_related_entity_name( $relation_name, $relation_obj ){
710
-		if( $relation_obj instanceof \EE_Belongs_To_Relation ) {
711
-			return strtolower( $relation_name );
712
-		}else{
713
-			return \EEH_Inflector::pluralize_and_lower( $relation_name );
709
+	public static function get_related_entity_name($relation_name, $relation_obj) {
710
+		if ($relation_obj instanceof \EE_Belongs_To_Relation) {
711
+			return strtolower($relation_name);
712
+		} else {
713
+			return \EEH_Inflector::pluralize_and_lower($relation_name);
714 714
 		}
715 715
 	}
716 716
 
@@ -723,43 +723,43 @@  discard block
 block discarded – undo
723 723
 	 * @param \WP_REST_Request $request
724 724
 	 * @return array|\WP_Error
725 725
 	 */
726
-	public function get_entity_from_model( $model, $request ) {
727
-		$query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1);
728
-		if( $model instanceof \EEM_Soft_Delete_Base ){
726
+	public function get_entity_from_model($model, $request) {
727
+		$query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1);
728
+		if ($model instanceof \EEM_Soft_Delete_Base) {
729 729
 			$query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params);
730 730
 		}
731 731
 		$restricted_query_params = $query_params;
732
-		$restricted_query_params[ 'caps' ] =  $this->validate_context(  $request->get_param( 'caps' ) );
733
-		$this->_set_debug_info( 'model query params', $restricted_query_params );
734
-		$model_rows = $model->get_all_wpdb_results( $restricted_query_params );
735
-		if ( ! empty ( $model_rows ) ) {
732
+		$restricted_query_params['caps'] = $this->validate_context($request->get_param('caps'));
733
+		$this->_set_debug_info('model query params', $restricted_query_params);
734
+		$model_rows = $model->get_all_wpdb_results($restricted_query_params);
735
+		if ( ! empty ($model_rows)) {
736 736
 			return $this->create_entity_from_wpdb_result(
737 737
 				$model,
738
-				array_shift( $model_rows ),
738
+				array_shift($model_rows),
739 739
 				$request );
740 740
 		} else {
741 741
 			//ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities
742
-			$lowercase_model_name = strtolower( $model->get_this_model_name() );
743
-			$model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params );
744
-			if( ! empty( $model_rows_found_sans_restrictions ) ) {
742
+			$lowercase_model_name = strtolower($model->get_this_model_name());
743
+			$model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params);
744
+			if ( ! empty($model_rows_found_sans_restrictions)) {
745 745
 				//you got shafted- it existed but we didn't want to tell you!
746 746
 				return new \WP_Error(
747 747
 					'rest_user_cannot_read',
748 748
 					sprintf(
749
-						__( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ),
750
-						strtolower( $model->get_this_model_name() ),
749
+						__('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'),
750
+						strtolower($model->get_this_model_name()),
751 751
 						Capabilities::get_missing_permissions_string(
752 752
 							$model,
753
-							$this->validate_context( $request->get_param( 'caps' ) ) )
753
+							$this->validate_context($request->get_param('caps')) )
754 754
 					),
755
-					array( 'status' => 403 )
755
+					array('status' => 403)
756 756
 				);
757 757
 			} else {
758 758
 				//it's not you. It just doesn't exist
759 759
 				return new \WP_Error(
760
-					sprintf( 'rest_%s_invalid_id', $lowercase_model_name ),
761
-					sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ),
762
-					array( 'status' => 404 )
760
+					sprintf('rest_%s_invalid_id', $lowercase_model_name),
761
+					sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name),
762
+					array('status' => 404)
763 763
 				);
764 764
 			}
765 765
 		}
@@ -772,14 +772,14 @@  discard block
 block discarded – undo
772 772
 	 * @param string $context
773 773
 	 * @return string array key of EEM_Base::cap_contexts_to_cap_action_map()
774 774
 	 */
775
-	public function validate_context( $context ) {
776
-		if( ! $context ) {
775
+	public function validate_context($context) {
776
+		if ( ! $context) {
777 777
 			$context = \EEM_Base::caps_read;
778 778
 		}
779 779
 		$valid_contexts = \EEM_Base::valid_cap_contexts();
780
-		if( in_array( $context, $valid_contexts )  ){
780
+		if (in_array($context, $valid_contexts)) {
781 781
 			return $context;
782
-		}else{
782
+		} else {
783 783
 			return \EEM_Base::caps_read;
784 784
 		}
785 785
 	}
@@ -798,87 +798,87 @@  discard block
 block discarded – undo
798 798
 	 *                          that absolutely no results should be returned
799 799
 	 * @throws \EE_Error
800 800
 	 */
801
-	public function create_model_query_params( $model, $query_parameters ) {
801
+	public function create_model_query_params($model, $query_parameters) {
802 802
 		$model_query_params = array( );
803
-		if ( isset( $query_parameters[ 'where' ] ) ) {
804
-			$model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models(
805
-				$query_parameters[ 'where' ],
803
+		if (isset($query_parameters['where'])) {
804
+			$model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models(
805
+				$query_parameters['where'],
806 806
 				$model,
807 807
 				$this->get_model_version_info()->requested_version()
808 808
 			);
809 809
 		}
810
-		if ( isset( $query_parameters[ 'order_by' ] ) ) {
811
-			$order_by = $query_parameters[ 'order_by' ];
812
-		} elseif ( isset( $query_parameters[ 'orderby' ] ) ) {
813
-			$order_by = $query_parameters[ 'orderby' ];
814
-		}else{
810
+		if (isset($query_parameters['order_by'])) {
811
+			$order_by = $query_parameters['order_by'];
812
+		} elseif (isset($query_parameters['orderby'])) {
813
+			$order_by = $query_parameters['orderby'];
814
+		} else {
815 815
 			$order_by = null;
816 816
 		}
817
-		if( $order_by !== null ){
818
-			if( is_array( $order_by ) ) {
819
-				$order_by = Model_Data_Translator::prepare_field_names_in_array_keys_from_json( $order_by );
817
+		if ($order_by !== null) {
818
+			if (is_array($order_by)) {
819
+				$order_by = Model_Data_Translator::prepare_field_names_in_array_keys_from_json($order_by);
820 820
 			} else {
821 821
 				//it's a single item
822
-				$order_by = Model_Data_Translator::prepare_field_name_from_json( $order_by );
822
+				$order_by = Model_Data_Translator::prepare_field_name_from_json($order_by);
823 823
 			}
824
-			$model_query_params[ 'order_by' ] =  $order_by;
824
+			$model_query_params['order_by'] = $order_by;
825 825
 		}
826
-		if ( isset( $query_parameters[ 'group_by' ] ) ) {
827
-			$group_by = $query_parameters[ 'group_by' ];
828
-		} elseif ( isset( $query_parameters[ 'groupby' ] ) ) {
829
-			$group_by = $query_parameters[ 'groupby' ];
830
-		}else{
831
-			$group_by = array_keys( $model->get_combined_primary_key_fields() );
826
+		if (isset($query_parameters['group_by'])) {
827
+			$group_by = $query_parameters['group_by'];
828
+		} elseif (isset($query_parameters['groupby'])) {
829
+			$group_by = $query_parameters['groupby'];
830
+		} else {
831
+			$group_by = array_keys($model->get_combined_primary_key_fields());
832 832
 		}
833 833
 		//make sure they're all real names
834
-		if( is_array( $group_by ) ) {
835
-			$group_by = Model_Data_Translator::prepare_field_names_from_json( $group_by );
834
+		if (is_array($group_by)) {
835
+			$group_by = Model_Data_Translator::prepare_field_names_from_json($group_by);
836 836
 		}
837
-		if( $group_by !== null ){
838
-			$model_query_params[ 'group_by' ] = $group_by;
837
+		if ($group_by !== null) {
838
+			$model_query_params['group_by'] = $group_by;
839 839
 		}
840
-		if ( isset( $query_parameters[ 'having' ] ) ) {
841
-			$model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models(
842
-				$query_parameters[ 'having' ],
840
+		if (isset($query_parameters['having'])) {
841
+			$model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models(
842
+				$query_parameters['having'],
843 843
 				$model,
844 844
 				$this->get_model_version_info()->requested_version()
845 845
 			);
846 846
 		}
847
-		if ( isset( $query_parameters[ 'order' ] ) ) {
848
-			$model_query_params[ 'order' ] = $query_parameters[ 'order' ];
847
+		if (isset($query_parameters['order'])) {
848
+			$model_query_params['order'] = $query_parameters['order'];
849 849
 		}
850
-		if ( isset( $query_parameters[ 'mine' ] ) ){
851
-			$model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params );
850
+		if (isset($query_parameters['mine'])) {
851
+			$model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params);
852 852
 		}
853
-		if( isset( $query_parameters[ 'limit' ] ) ) {
853
+		if (isset($query_parameters['limit'])) {
854 854
 			//limit should be either a string like '23' or '23,43', or an array with two items in it
855
-			if( ! is_array( $query_parameters[ 'limit' ] ) ) {
856
-				$limit_array = explode(',', (string)$query_parameters['limit']);
857
-			}else {
858
-				$limit_array = $query_parameters[ 'limit' ];
855
+			if ( ! is_array($query_parameters['limit'])) {
856
+				$limit_array = explode(',', (string) $query_parameters['limit']);
857
+			} else {
858
+				$limit_array = $query_parameters['limit'];
859 859
 			}
860 860
 			$sanitized_limit = array();
861
-			foreach( $limit_array as $key => $limit_part ) {
862
-				if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) {
861
+			foreach ($limit_array as $key => $limit_part) {
862
+				if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) {
863 863
 					throw new \EE_Error(
864 864
 						sprintf(
865
-							__( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ),
866
-							wp_json_encode( $query_parameters[ 'limit' ] )
865
+							__('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'),
866
+							wp_json_encode($query_parameters['limit'])
867 867
 						)
868 868
 					);
869 869
 				}
870
-				$sanitized_limit[] = (int)$limit_part;
870
+				$sanitized_limit[] = (int) $limit_part;
871 871
 			}
872
-			$model_query_params[ 'limit' ] = implode( ',', $sanitized_limit );
873
-		}else{
874
-			$model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit();
872
+			$model_query_params['limit'] = implode(',', $sanitized_limit);
873
+		} else {
874
+			$model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit();
875 875
 		}
876
-		if( isset( $query_parameters[ 'caps' ] ) ) {
877
-			$model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] );
878
-		}else{
879
-			$model_query_params[ 'caps' ] = \EEM_Base::caps_read;
876
+		if (isset($query_parameters['caps'])) {
877
+			$model_query_params['caps'] = $this->validate_context($query_parameters['caps']);
878
+		} else {
879
+			$model_query_params['caps'] = \EEM_Base::caps_read;
880 880
 		}
881
-		return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model );
881
+		return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model);
882 882
 	}
883 883
 
884 884
 
@@ -890,13 +890,13 @@  discard block
 block discarded – undo
890 890
 	 * @param array     $query_params sub-array from @see EEM_Base::get_all()
891 891
 	 * @return array
892 892
 	 */
893
-	public function prepare_rest_query_params_key_for_models( $model,  $query_params ) {
893
+	public function prepare_rest_query_params_key_for_models($model, $query_params) {
894 894
 		$model_ready_query_params = array();
895
-		foreach( $query_params as $key => $value ) {
896
-			if( is_array( $value ) ) {
897
-				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value );
898
-			}else{
899
-				$model_ready_query_params[ $key ] = $value;
895
+		foreach ($query_params as $key => $value) {
896
+			if (is_array($value)) {
897
+				$model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value);
898
+			} else {
899
+				$model_ready_query_params[$key] = $value;
900 900
 			}
901 901
 		}
902 902
 		return $model_ready_query_params;
@@ -910,13 +910,13 @@  discard block
 block discarded – undo
910 910
 	 * @param $query_params
911 911
 	 * @return array
912 912
 	 */
913
-	public function prepare_rest_query_params_values_for_models( $model, $query_params ) {
913
+	public function prepare_rest_query_params_values_for_models($model, $query_params) {
914 914
 		$model_ready_query_params = array();
915
-		foreach( $query_params as $key => $value ) {
916
-			if( is_array( $value ) ) {
917
-				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value );
915
+		foreach ($query_params as $key => $value) {
916
+			if (is_array($value)) {
917
+				$model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value);
918 918
 			} else {
919
-				$model_ready_query_params[ $key ] = $value;
919
+				$model_ready_query_params[$key] = $value;
920 920
 			}
921 921
 		}
922 922
 		return $model_ready_query_params;
@@ -931,33 +931,33 @@  discard block
 block discarded – undo
931 931
 	 * we only return strings starting with that and a period; if no prefix was specified
932 932
 	 * we return all items containing NO periods
933 933
 	 */
934
-	public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) {
935
-		if( is_string( $string_to_explode ) ) {
936
-			$exploded_contents = explode( ',', $string_to_explode );
937
-		} else if( is_array( $string_to_explode ) ) {
934
+	public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) {
935
+		if (is_string($string_to_explode)) {
936
+			$exploded_contents = explode(',', $string_to_explode);
937
+		} else if (is_array($string_to_explode)) {
938 938
 			$exploded_contents = $string_to_explode;
939 939
 		} else {
940 940
 			$exploded_contents = array();
941 941
 		}
942 942
 		//if the string was empty, we want an empty array
943
-		$exploded_contents = array_filter( $exploded_contents );
943
+		$exploded_contents = array_filter($exploded_contents);
944 944
 		$contents_with_prefix = array();
945
-		foreach( $exploded_contents as $item ) {
946
-			$item = trim( $item );
945
+		foreach ($exploded_contents as $item) {
946
+			$item = trim($item);
947 947
 			//if no prefix was provided, so we look for items with no "." in them
948
-			if( ! $prefix ) {
948
+			if ( ! $prefix) {
949 949
 				//does this item have a period?
950
-				if( strpos( $item, '.' ) === false ) {
950
+				if (strpos($item, '.') === false) {
951 951
 					//if not, then its what we're looking for
952 952
 					$contents_with_prefix[] = $item;
953 953
 				}
954
-			} else if( strpos( $item, $prefix . '.' ) === 0 ) {
954
+			} else if (strpos($item, $prefix.'.') === 0) {
955 955
 				//this item has the prefix and a period, grab it
956 956
 				$contents_with_prefix[] = substr(
957 957
 					$item,
958
-					strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' )
958
+					strpos($item, $prefix.'.') + strlen($prefix.'.')
959 959
 					);
960
-			} else if( $item === $prefix ) {
960
+			} else if ($item === $prefix) {
961 961
 				//this item is JUST the prefix
962 962
 				//so let's grab everything after, which is a blank string
963 963
 				$contents_with_prefix[] = '';
@@ -980,33 +980,33 @@  discard block
 block discarded – undo
980 980
 	 * the fields for that model, with the model's name removed from each.
981 981
 	 * If $include_string was blank or '*' returns an empty array
982 982
 	 */
983
-	public function extract_includes_for_this_model( $include_string, $model_name = null ) {
984
-		if( is_array( $include_string ) ) {
985
-			$include_string = implode( ',', $include_string );
983
+	public function extract_includes_for_this_model($include_string, $model_name = null) {
984
+		if (is_array($include_string)) {
985
+			$include_string = implode(',', $include_string);
986 986
 		}
987
-		if( $include_string === '*' || $include_string === '' ) {
987
+		if ($include_string === '*' || $include_string === '') {
988 988
 			return array();
989 989
 		}
990
-		$includes = explode( ',', $include_string );
990
+		$includes = explode(',', $include_string);
991 991
 		$extracted_fields_to_include = array();
992
-		if( $model_name ){
993
-			foreach( $includes as $field_to_include ) {
994
-				$field_to_include = trim( $field_to_include );
995
-				if( strpos( $field_to_include, $model_name . '.' ) === 0 ) {
992
+		if ($model_name) {
993
+			foreach ($includes as $field_to_include) {
994
+				$field_to_include = trim($field_to_include);
995
+				if (strpos($field_to_include, $model_name.'.') === 0) {
996 996
 					//found the model name at the exact start
997
-					$field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include );
997
+					$field_sans_model_name = str_replace($model_name.'.', '', $field_to_include);
998 998
 					$extracted_fields_to_include[] = $field_sans_model_name;
999
-				}elseif( $field_to_include == $model_name ){
999
+				}elseif ($field_to_include == $model_name) {
1000 1000
 					$extracted_fields_to_include[] = '*';
1001 1001
 				}
1002 1002
 			}
1003
-		}else{
1003
+		} else {
1004 1004
 			//look for ones with no period
1005
-			foreach( $includes as $field_to_include ) {
1006
-				$field_to_include = trim( $field_to_include );
1005
+			foreach ($includes as $field_to_include) {
1006
+				$field_to_include = trim($field_to_include);
1007 1007
 				if (
1008
-					strpos( $field_to_include, '.' ) === false
1009
-					&& ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include )
1008
+					strpos($field_to_include, '.') === false
1009
+					&& ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include)
1010 1010
 				) {
1011 1011
 					$extracted_fields_to_include[] = $field_to_include;
1012 1012
 				}
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/Base.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\rest_api\controllers;
3 3
 use EventEspresso\core\libraries\rest_api\Rest_Exception;
4
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 /**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 	public function __construct() {
52
-		$this->_debug_mode = defined( 'EE_REST_API_DEBUG_MODE' ) ? EE_REST_API_DEBUG_MODE : false;
52
+		$this->_debug_mode = defined('EE_REST_API_DEBUG_MODE') ? EE_REST_API_DEBUG_MODE : false;
53 53
 	}
54 54
 
55 55
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * Sets the version the user requested
58 58
 	 * @param string $version eg '4.8'
59 59
 	 */
60
-	public function set_requested_version( $version ) {
60
+	public function set_requested_version($version) {
61 61
 		$this->_requested_version = $version;
62 62
 	}
63 63
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	 * @param string $key
67 67
 	 * @param string|array $info
68 68
 	 */
69
-	protected function _set_debug_info( $key, $info ){
70
-		$this->_debug_info[ $key ] = $info;
69
+	protected function _set_debug_info($key, $info) {
70
+		$this->_debug_info[$key] = $info;
71 71
 	}
72 72
 
73 73
 	/**
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 	 * @param boolean      $use_ee_prefix whether to use the EE prefix on the header, or fallback to
80 80
 	 *                                    the standard WP one
81 81
 	 */
82
-	protected function _set_response_header( $header_key, $value, $use_ee_prefix = true ) {
83
-		if( is_array( $value ) ) {
84
-			foreach( $value as $value_key => $value_value ) {
85
-				$this->_set_response_header(  $header_key . '[' . $value_key . ']', $value_value );
82
+	protected function _set_response_header($header_key, $value, $use_ee_prefix = true) {
83
+		if (is_array($value)) {
84
+			foreach ($value as $value_key => $value_value) {
85
+				$this->_set_response_header($header_key.'['.$value_key.']', $value_value);
86 86
 			}
87 87
 		} else {
88 88
 			$prefix = $use_ee_prefix ? Base::header_prefix_for_ee : Base::header_prefix_for_wp;
89
-			$this->_response_headers[ $prefix . $header_key  ] = $value;
89
+			$this->_response_headers[$prefix.$header_key] = $value;
90 90
 		}
91 91
 	}
92 92
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @return array
96 96
 	 */
97 97
 	protected function _get_response_headers() {
98
-		return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
98
+		return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers',
99 99
 			$this->_response_headers,
100 100
 			$this,
101 101
 			$this->_requested_version
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 	 * @param \WP_Error $wp_error_response
108 108
 	 * @return \WP_Error
109 109
 	 */
110
-	protected function _add_ee_errors_to_response( \WP_Error $wp_error_response ) {
110
+	protected function _add_ee_errors_to_response(\WP_Error $wp_error_response) {
111 111
 		$notices_during_checkin = \EE_Error::get_raw_notices();
112
-		if( ! empty( $notices_during_checkin[ 'errors' ] ) ) {
113
-			foreach( $notices_during_checkin[ 'errors' ] as $error_code => $error_message ) {
112
+		if ( ! empty($notices_during_checkin['errors'])) {
113
+			foreach ($notices_during_checkin['errors'] as $error_code => $error_message) {
114 114
 				$wp_error_response->add(
115
-					sanitize_key( $error_code ),
116
-					strip_tags( $error_message ) );
115
+					sanitize_key($error_code),
116
+					strip_tags($error_message) );
117 117
 			}
118 118
 		}
119 119
 		return $wp_error_response;
@@ -131,27 +131,27 @@  discard block
 block discarded – undo
131 131
 	 * @param array|\WP_Error|\Exception $response
132 132
 	 * @return \WP_REST_Response
133 133
 	 */
134
-	public function send_response( $response ) {
135
-		if( $response instanceof Rest_Exception ) {
136
-			$response = new \WP_Error( $response->get_string_code(), $response->getMessage(), $response->get_data() );
134
+	public function send_response($response) {
135
+		if ($response instanceof Rest_Exception) {
136
+			$response = new \WP_Error($response->get_string_code(), $response->getMessage(), $response->get_data());
137 137
 		}
138
-		if( $response instanceof \Exception ) {
138
+		if ($response instanceof \Exception) {
139 139
 			$code = $response->getCode() ? $response->getCode() : 'error_occurred';
140
-			$response = new \WP_Error( $code, $response->getMessage() );
140
+			$response = new \WP_Error($code, $response->getMessage());
141 141
 		}
142
-		if( $response instanceof \WP_Error ) {
143
-			$response = $this->_add_ee_errors_to_response( $response );
144
-			$rest_response = $this->_create_rest_response_from_wp_error( $response );
145
-		}else{
146
-			$rest_response = new \WP_REST_Response( $response, 200 );
142
+		if ($response instanceof \WP_Error) {
143
+			$response = $this->_add_ee_errors_to_response($response);
144
+			$rest_response = $this->_create_rest_response_from_wp_error($response);
145
+		} else {
146
+			$rest_response = new \WP_REST_Response($response, 200);
147 147
 		}
148 148
 		$headers = array();
149
-		if( $this->_debug_mode && is_array( $this->_debug_info ) ) {
150
-			foreach( $this->_debug_info  as $debug_key => $debug_info ) {
151
-				if( is_array( $debug_info ) ) {
152
-					$debug_info = wp_json_encode( $debug_info );
149
+		if ($this->_debug_mode && is_array($this->_debug_info)) {
150
+			foreach ($this->_debug_info  as $debug_key => $debug_info) {
151
+				if (is_array($debug_info)) {
152
+					$debug_info = wp_json_encode($debug_info);
153 153
 				}
154
-				$headers[ 'X-EE4-Debug-' . ucwords( $debug_key ) ] = $debug_info;
154
+				$headers['X-EE4-Debug-'.ucwords($debug_key)] = $debug_info;
155 155
 			}
156 156
 		}
157 157
 		$headers = array_merge(
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			$this->_get_headers_from_ee_notices()
161 161
 		);
162 162
 
163
-		$rest_response->set_headers( $headers );
163
+		$rest_response->set_headers($headers);
164 164
 		return $rest_response;
165 165
 	}
166 166
 
@@ -171,31 +171,31 @@  discard block
 block discarded – undo
171 171
 	 * @param \WP_Error $wp_error
172 172
 	 * @return \WP_REST_Response
173 173
 	 */
174
-	protected function _create_rest_response_from_wp_error( \WP_Error $wp_error ) {
174
+	protected function _create_rest_response_from_wp_error(\WP_Error $wp_error) {
175 175
 		$error_data = $wp_error->get_error_data();
176
-		if ( is_array( $error_data ) && isset( $error_data['status'] ) ) {
176
+		if (is_array($error_data) && isset($error_data['status'])) {
177 177
 			$status = $error_data['status'];
178 178
 		} else {
179 179
 			$status = 500;
180 180
 		}
181 181
 
182 182
 		$errors = array();
183
-		foreach ( (array) $wp_error->errors as $code => $messages ) {
184
-			foreach ( (array) $messages as $message ) {
183
+		foreach ((array) $wp_error->errors as $code => $messages) {
184
+			foreach ((array) $messages as $message) {
185 185
 				$errors[] = array(
186 186
 					'code'    => $code,
187 187
 					'message' => $message,
188
-					'data'    => $wp_error->get_error_data( $code )
188
+					'data'    => $wp_error->get_error_data($code)
189 189
 				);
190 190
 			}
191 191
 		}
192
-		$data = isset( $errors[0] ) ? $errors[0] : array();
193
-		if ( count( $errors ) > 1 ) {
192
+		$data = isset($errors[0]) ? $errors[0] : array();
193
+		if (count($errors) > 1) {
194 194
 			// Remove the primary error.
195
-			array_shift( $errors );
195
+			array_shift($errors);
196 196
 			$data['additional_errors'] = $errors;
197 197
 		}
198
-		return new \WP_REST_Response( $data, $status );
198
+		return new \WP_REST_Response($data, $status);
199 199
 	}
200 200
 
201 201
 	/**
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
 	protected function _get_headers_from_ee_notices() {
206 206
 		$headers = array();
207 207
 		$notices = \EE_Error::get_raw_notices();
208
-		foreach( $notices as $notice_type => $sub_notices ) {
209
-			if( ! is_array( $sub_notices ) ) {
208
+		foreach ($notices as $notice_type => $sub_notices) {
209
+			if ( ! is_array($sub_notices)) {
210 210
 				continue;
211 211
 			}
212
-			foreach( $sub_notices as $notice_code => $sub_notice ) {
213
-				$headers[ 'X-EE4-Notices-' . \EEH_Inflector::humanize( $notice_type ) . '[' . $notice_code . ']' ] = strip_tags( $sub_notice );
212
+			foreach ($sub_notices as $notice_code => $sub_notice) {
213
+				$headers['X-EE4-Notices-'.\EEH_Inflector::humanize($notice_type).'['.$notice_code.']'] = strip_tags($sub_notice);
214 214
 			}
215 215
 		}
216 216
 		return apply_filters(
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 	 * @param string $route
229 229
 	 * @return string
230 230
 	 */
231
-	public function get_requested_version( $route = null ) {
231
+	public function get_requested_version($route = null) {
232 232
 		$matches = $this->parse_route(
233 233
 			$route,
234
-			'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '~',
235
-			array( 'version' )
234
+			'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'~',
235
+			array('version')
236 236
 			);
237
-		if( isset( $matches[ 'version' ] ) ) {
238
-			return $matches[ 'version' ];
237
+		if (isset($matches['version'])) {
238
+			return $matches['version'];
239 239
 		} else {
240 240
 			return \EED_Core_Rest_Api::latest_rest_api_version();
241 241
 		}
@@ -260,23 +260,23 @@  discard block
 block discarded – undo
260 260
 	 * array( 'model' => 'foo', 'id' => 'bar' )
261 261
 	 * @throws \EE_Error if it couldn't be parsed
262 262
 	 */
263
-	public function parse_route( $route, $regex, $match_keys ) {
263
+	public function parse_route($route, $regex, $match_keys) {
264 264
 		$indexed_matches = array();
265
-		$success = preg_match( $regex, $route, $matches );
266
-		if(
267
-			is_array( $matches ) ) {
265
+		$success = preg_match($regex, $route, $matches);
266
+		if (
267
+			is_array($matches) ) {
268 268
 			//skip the overall regex match. Who cares
269
-			for( $i = 1; $i <= count( $match_keys ); $i++ ) {
270
-				if( ! isset( $matches[ $i ] ) ) {
269
+			for ($i = 1; $i <= count($match_keys); $i++) {
270
+				if ( ! isset($matches[$i])) {
271 271
 					$success = false;
272 272
 				} else {
273
-					$indexed_matches[ $match_keys[ $i - 1 ] ] = $matches[ $i ];
273
+					$indexed_matches[$match_keys[$i - 1]] = $matches[$i];
274 274
 				}
275 275
 			}
276 276
 		}
277
-		if( ! $success ) {
277
+		if ( ! $success) {
278 278
 			throw new \EE_Error(
279
-				__( 'We could not parse the URL. Please contact Event Espresso Support', 'event_espresso' ),
279
+				__('We could not parse the URL. Please contact Event Espresso Support', 'event_espresso'),
280 280
 				'endpoint_parsing_error'
281 281
 			);
282 282
 		}
Please login to merge, or discard this patch.